| 1 |
#ifndef CINTERFACE_H_INCLUDED |
| 2 |
#define CINTERFACE_H_INCLUDED |
| 3 |
|
| 4 |
#include "CCursor.h" |
| 5 |
|
| 6 |
const int TILE_UNIT = 16; // 単位タイル幅 [px] |
| 7 |
const int TILE_HALF = TILE_UNIT/2; // 半分 |
| 8 |
const int TILE_QUAD = TILE_UNIT/4; // 1/4 |
| 9 |
|
| 10 |
/* |
| 11 |
* ユーザーインターフェイスクラス |
| 12 |
*/ |
| 13 |
class CInterface{ |
| 14 |
friend class CPopMenu; |
| 15 |
protected: |
| 16 |
static CInterface *ms_Focus; // フォーカス |
| 17 |
static CInterface *ms_Drop; // ドロップ先 |
| 18 |
static CInterface *ms_TabHead; // タブリンク |
| 19 |
int m_PosX, m_PosY; // 座標 |
| 20 |
int m_Width, m_Height; // サイズ |
| 21 |
bool m_Enabled; // 有効フラグ |
| 22 |
bool m_Visible; // 表示フラグ |
| 23 |
string m_Text; // テキスト |
| 24 |
CInterface *m_Parent; // 親 |
| 25 |
CInterface *m_Brother; // 兄弟 |
| 26 |
CInterface *m_Child; // 子 |
| 27 |
CInterface *m_Owner; // フォーカス所有者 |
| 28 |
CInterface *m_TabPrev; // タブ次 |
| 29 |
CInterface *m_TabNext; // タブ前 |
| 30 |
public: |
| 31 |
static void ResetTabHead(){ ms_TabHead = NULL; } |
| 32 |
static void ProcessKey(); |
| 33 |
static CInterface *GetFocus(){ return ms_Focus; } |
| 34 |
static void SetFocus(CInterface *f){ ms_Focus = f; } |
| 35 |
CInterface(); |
| 36 |
virtual ~CInterface(); |
| 37 |
void Init(int, int, int, int, char *, CInterface *); |
| 38 |
CInterface *GetParent(){ return m_Parent; } |
| 39 |
void SetChild(CInterface *); |
| 40 |
void SetBrother(CInterface *); |
| 41 |
void RemoveChild(CInterface *); |
| 42 |
void SetOwner(CInterface *o){ m_Owner = o; } |
| 43 |
void LinkTab(bool); |
| 44 |
bool IsFocus(){ return ms_Focus==this; } |
| 45 |
CInterface *FindTabItem(); |
| 46 |
int GetPosX(){ return m_PosX; } |
| 47 |
int GetPosY(){ return m_PosY; } |
| 48 |
void SetPos(int x, int y){ m_PosX = x; m_PosY = y; } |
| 49 |
int GetWidth(){ return m_Width; } |
| 50 |
int GetHeight(){ return m_Height; } |
| 51 |
virtual void SetSize(int w, int h){ m_Width = w; m_Height = h; } |
| 52 |
char *GetText(){ return (char *)m_Text.c_str(); } |
| 53 |
void SetText(char *t){ m_Text = t; } |
| 54 |
void GetAbsPos(int *, int *); |
| 55 |
bool IsEnabled(){ return m_Enabled; } |
| 56 |
void Enable(bool en){ m_Enabled = en; } |
| 57 |
bool IsVisible(); |
| 58 |
void Show(bool f){ m_Visible = f; } |
| 59 |
bool IsInside(int, int); |
| 60 |
void DrawFocusFrame(); |
| 61 |
virtual void GiveFocus(bool snd = true); |
| 62 |
virtual bool ScanInput(); |
| 63 |
bool ScanInputChild(){ return m_Child && m_Child->ScanInput(); } |
| 64 |
bool ScanInputBrother(){ return m_Brother && m_Brother->ScanInput(); } |
| 65 |
virtual void Render(); |
| 66 |
void RenderChild(){ if(m_Child) m_Child->Render(); } |
| 67 |
void RenderBrother(){ if(m_Brother) m_Brother->Render(); } |
| 68 |
}; |
| 69 |
|
| 70 |
/* |
| 71 |
* フォント縦位置修正 |
| 72 |
*/ |
| 73 |
inline int FontY(int h){ return (h-FONT_HEIGHT)>>1; } |
| 74 |
|
| 75 |
#endif |