home *** CD-ROM | disk | FTP | other *** search
- #ifndef _STATEBUT_H_
- #define _STATEBUT_H_
-
- #ifndef __CONTROL_H
- #include <control.h>
- #endif
-
- #define SB_OFF 0 //Off
- #define SB_ON 1 //On
-
- _CLASSDEF(TStateButton)
- class _EXPORT TStateButton : public TControl
- {
- protected:
- struct
- {
- unsigned int State : 1;
- unsigned int Focus : 1; //Has input focus
- unsigned int Capture : 1; //Captured, LButton Down
- unsigned int Space : 1; //Space bar down
- unsigned int LastIn : 1; //Last mouse pos in control
- unsigned int Changing: 1; //State is changing
- } Chars;
- RECT ClientRect;
-
- virtual void DrawOff(HDC DrawDC);
- virtual void DrawOn(HDC DrawDC);
- virtual void ChangeFocus(HDC DrawDC);
-
- virtual LPSTR GetClassName()
- { return (LPSTR)"SBUTTON"; };
- virtual void GetWindowClass(WNDCLASS& WndClass);
-
- private:
- void StateChange(void);
- public:
- TStateButton(PTWindowsObject AParent, int AnId,
- LPSTR ATitle, int X, int Y, int W, int H,
- PTModule ATModule = NULL);
- TStateButton(PTWindowsObject AParent, int ResourceId,
- PTModule ATModule = NULL);
- virtual Config();
-
- virtual void SetupWindow();
-
- virtual void WMSetFocus(RTMessage Msg) = [WM_FIRST + WM_SETFOCUS];
- virtual void WMKillFocus(RTMessage Msg) = [WM_FIRST + WM_KILLFOCUS];
- virtual void WMLButtonDown(RTMessage Msg) = [WM_FIRST + WM_LBUTTONDOWN];
- virtual void WMLButtonUp(RTMessage Msg) = [WM_FIRST + WM_LBUTTONUP];
- virtual void WMKeyDown(RTMessage Msg) = [WM_FIRST + WM_KEYDOWN];
- virtual void WMKeyUp(RTMessage Msg) = [WM_FIRST + WM_KEYUP];
- virtual void WMGetDlgCode(RTMessage Msg) = [WM_FIRST + WM_GETDLGCODE];
- virtual void WMMouseMove(RTMessage Msg) = [WM_FIRST + WM_MOUSEMOVE];
- virtual void Paint(HDC PaintDC, PAINTSTRUCT _FAR & PaintInfo);
- virtual void WMSize(RTMessage Msg) = [WM_FIRST + WM_SIZE];
- virtual void WMMouseActivate(RTMessage Msg) = [WM_FIRST + WM_MOUSEACTIVATE]
- { SetFocus(HWindow); };
-
- void SetState(BOOL State)
- { Chars.State = State;
- StateChange(); };
- BOOL GetState(void)
- { return Chars.State; }
- BOOL IsOn(void)
- { return (Chars.State == SB_ON); }
- BOOL IsOff(void)
- { return (Chars.State == SB_OFF); }
- void TurnOn(void)
- { SetState(SB_ON); }
- void TurnOff(void)
- { SetState(SB_OFF); }
- void Toggle(void)
- { SetState(!Chars.State); }
-
- };
-
- #endif