Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/CMiniButton.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: 1536 byte(s)


1 #include "stdafx.h"
2 #include "CMiniButton.h"
3 #include "CSkinPlugin.h"
4
5 /*
6 * 初期化
7 */
8 void CMiniButton::Init(
9 int x, int y, // 座標
10 int w, int h, // サイズ
11 CInterface *p, // 親
12 float u, float v, // テクスチャ座標
13 bool m // モード
14 ){
15 CInterface::Init(x, y, w, h, "", p);
16 m_State = m_Repeat = 0;
17 m_Pushed = false;
18 m_TexU = u; m_TexV = v;
19 m_Mode = m;
20 LinkTab(false);
21 }
22
23 /*
24 * 入力チェック
25 */
26 bool CMiniButton::ScanInput(){
27 if(!m_Visible) return ScanInputBrother();
28 POINT pos = g_Cursor.GetPos();
29 m_Pushed = false;
30 if(IsInside(pos.x, pos.y)){
31 switch(GetButton(DIM_LEFT)){
32 case S_PUSH:
33 m_State = 2;
34 GiveFocus();
35 return true;
36 case S_HOLD:
37 if(m_State){
38 m_State = 2;
39 m_Repeat++;
40 return true;
41 }
42 break;
43 default:
44 if(m_State){
45 m_Pushed = true;
46 if(!m_Mode) g_Skin->MouseUp();
47 }
48 m_State = m_Repeat = 0;
49 break;
50 }
51 }else if(m_State){
52 switch(GetButton(DIM_LEFT)){
53 case S_HOLD:
54 m_State = 1;
55 return true;
56 default:
57 m_State = m_Repeat = 0;
58 break;
59 }
60 }
61 return CInterface::ScanInput();
62 }
63
64 /*
65 * レンダリング
66 */
67 void CMiniButton::Render(){
68 CInterface::RenderBrother();
69 int px, py, push = m_State==2;
70 float tv = m_State==2 ? m_TexV+0.125f : m_TexV;
71 GetAbsPos(&px, &py);
72 g_Skin->SetInterfaceTexture();
73 SetUVMap(m_TexU, tv, m_TexU+0.125f, tv+0.125f);
74 TexMap2DRect(px, py, px+m_Width, py+m_Height, 0xffffffff);
75 CInterface::RenderChild();
76 if(IsFocus()) DrawFocusFrame();
77 }

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