Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/CCheckBox.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Sun Aug 15 01:53:13 2010 UTC (13 years, 9 months ago) by okadu
File MIME type: text/x-c++src
File size: 2270 byte(s)


1 #include "stdafx.h"
2 #include "CCheckBox.h"
3 #include "CSkinPlugin.h"
4
5 /*
6 * 初期化
7 */
8 void CCheckBox::Init(
9 int x, int y, // 座標
10 int w, int h, // サイズ
11 char *t, // テキスト
12 CInterface *p // 親
13 ){
14 CInterface::Init(x, y, w, h, t, p);
15 m_State = 0;
16 m_Check = 0;
17 LinkTab(true);
18 }
19
20 /*
21 * 入力チェック
22 */
23 bool CCheckBox::ScanInput(){
24 if(!m_Enabled){
25 m_State = 0;
26 return CInterface::ScanInput();
27 }
28 if(!m_Visible) return ScanInputBrother();
29 POINT pos = g_Cursor.GetPos();
30 int key = GetKey(DIK_SPACE)|GetKey(DIK_RETURN)|GetKey(DIK_NUMPADENTER);
31 bool in = IsInside(pos.x, pos.y), focus = IsFocus();
32 if(in || focus && key){
33 int stt = 0;
34 if(in) stt |= GetButton(DIM_LEFT);
35 if(focus) stt |= key;
36 switch(stt){
37 case S_PUSH:
38 m_State = 2;
39 GiveFocus();
40 return true;
41 case S_HOLD:
42 if(m_State){
43 m_State = 2;
44 return true;
45 }
46 break;
47 default:
48 if(m_State){
49 g_Skin->MouseUp();
50 m_Check = !m_Check;
51 }
52 m_State = 0;
53 break;
54 }
55 }else if(m_State){
56 switch(GetButton(DIM_LEFT)){
57 case S_HOLD:
58 m_State = 1;
59 return true;
60 default:
61 m_State = 0;
62 break;
63 }
64 }
65 return CInterface::ScanInput();
66 }
67
68 /*
69 * レンダリング
70 */
71 void CCheckBox::Render(){
72 CInterface::RenderBrother();
73 if(!m_Visible) return;
74 int px, py, push = m_State==2;
75 float tv = m_State==2 ? 0.125f : (m_Check ? 0.25f : 0.0f);
76 GetAbsPos(&px, &py);
77 g_Skin->SetInterfaceTexture();
78 SetUVMap(0.375f, tv, 0.5f, tv+0.125f);
79 TexMap2DRect(px, py, px+TILE_UNIT, py+m_Height, 0xffffffff);
80 int lim = m_Width-TILE_UNIT*3/2-push;
81 D3DCOLOR fc = g_Skin->m_InterfaceData.m_StaticFontColor, sdw = 0;
82 if(!m_Enabled){
83 fc = g_Skin->m_PopupMenuData.m_DisabledFontColor;
84 sdw = g_Skin->m_PopupMenuData.m_DisabledShadowColor;
85 }
86 if(sdw) g_StrTex->RenderLeft(px+TILE_UNIT*3/2+push, py+FontY(m_Height)+push,
87 sdw, 0, m_Text.c_str(), lim>0 ? lim : 1);
88 g_StrTex->RenderLeft(px+TILE_UNIT*3/2+push, py+FontY(m_Height)+push,
89 fc, 0, m_Text.c_str(), lim>0 ? lim : 1);
90 CInterface::RenderChild();
91 if(m_Text.size() && IsFocus()){
92 devSetTexture(0, NULL);
93 Draw2DRect(px+TILE_UNIT*5/4, py, px+m_Width, py+m_Height,
94 g_Skin->m_InterfaceData.m_FocusFrameColor);
95 }
96 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26