bsp
|
00001 #pragma once 00002 00003 struct WNDATTR 00004 { 00005 HWND parent; 00006 int width; 00007 int height; 00008 int x; 00009 int y; 00010 DWORD dwExStyle; 00011 DWORD dwStyle; 00012 HMENU menu; 00013 LPVOID param; 00014 }; 00015 00016 // 00017 // Window 00018 // 00019 class Window 00020 { 00021 public: 00022 HWND hwnd; 00023 WNDCLASSEX wc; 00024 WNDATTR attr; 00025 char caption[256]; 00026 00027 protected: 00028 bool created; 00029 00030 //methods 00031 public: 00032 //constructors 00033 Window(HWND parent, const char *caption); 00034 virtual ~Window(); 00035 00036 bool Create(bool show = true); 00037 bool IsValid(); 00038 00039 static LRESULT CALLBACK MsgRouter(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam); 00040 virtual LRESULT WndProc(UINT msg,WPARAM wParam,LPARAM lParam) = 0; 00041 00042 LRESULT SendMessage(UINT msg,WPARAM wParam,LPARAM lParam); 00043 int ShowWindow(int nCmdShow = SW_RESTORE); 00044 virtual void SetCaption(const char *caption); 00045 bool IsIconic(); 00046 bool IsZoomed(); 00047 bool IsVisible(); 00048 bool IsWindowVisible(); 00049 bool SetWindowPos(HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags); 00050 bool SetWindowPos(HWND hWndInsertAfter, RECT *rc, UINT uFlags); 00051 HWND SetFocus(); 00052 void SetIcon(int resid); 00053 virtual bool CanClose(); 00054 }; 00055 00056 // 00057 // WFloatingList 00058 // 00059 class WList; 00060 class WFloatingList : public Window 00061 { 00062 public: 00063 WFloatingList(HWND parent); 00064 ~WFloatingList(); 00065 virtual LRESULT WndProc(UINT msg,WPARAM wParam,LPARAM lParam); 00066 void Redraw(); 00067 WList *list; 00068 bool mdown; 00069 int part, startx, starty; 00070 RECT startrc; 00071 }; 00072 00073 // 00074 // MDIClient 00075 // 00076 class MDIClient : public Window 00077 { 00078 public: 00079 MDIClient(HWND parent); 00080 virtual LRESULT WndProc(UINT msg,WPARAM wParam,LPARAM lParam); 00081 }; 00082 00083 // 00084 // MDIChild 00085 // 00086 class MDIChild : public Window 00087 { 00088 public: 00089 MDIChild(HWND parent, const char *caption); 00090 static LRESULT CALLBACK MsgRouter(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam); 00091 }; 00092 00093 00094 #define BORDER_X 1 00095 #define BORDER_Y 1 00096 #define FRAME_X 4 00097 #define FRAME_Y 4 00098 // 00099 // TCWindow - Tiny Caption Window 00100 // 00101 class DockWindow; 00102 class TCWindow : public MDIChild 00103 { 00104 public: 00105 TCWindow(HWND parent, const char *caption); 00106 00107 virtual LRESULT WndProc(UINT msg,WPARAM wParam,LPARAM lParam); 00108 00109 bool ToggleAlwaysOnTop(); 00110 virtual int DoNCHitTest(LPPOINT screenPt); 00111 void DoNCPaint(); 00112 int DoNCCalcSize(LPNCCALCSIZE_PARAMS calcSize); 00113 virtual bool DoNCRButtonDown(int hitTest, LPPOINTS screenPt); 00114 virtual bool DoNCLButtonDown(int hitTest, LPPOINTS screenPt); 00115 virtual bool DoMouseMove(); 00116 bool DoLButtonUp(); 00117 bool DoNCActivate(bool active); 00118 bool DoCommand(UINT id, int notifyCode, int& result); 00119 bool DoSysCommand(int cmdType); 00120 void PaintButton(HDC hdc, LPRECT rc, bool pressed); 00121 void PaintSysBox(HDC hdc); 00122 void PaintMinBox(HDC hdc, bool pressed); 00123 void PaintMaxBox(HDC hdc, bool pressed); 00124 virtual void PaintCaption(bool active); 00125 void GetCaptionRect(LPRECT rc); 00126 void GetSysBoxRect(LPRECT rc); 00127 void GetMinBoxRect(LPRECT rc); 00128 void GetMaxBoxRect(LPRECT rc); 00129 void DoSysMenu(); 00130 00131 bool WaitingForSysCmd; 00132 int DownHit; 00133 bool IsPressed; 00134 DockWindow *docked; 00135 static HWND topmost; //window set as topmost, or null 00136 }; 00137 00138 //dock window 00139 class DockWindow : public TCWindow 00140 { 00141 public: 00142 enum CPOS {TL=1, BL=2, BR=4, TR=8}; 00143 struct child 00144 { 00145 bool inuse; 00146 TCWindow *win; 00147 int pos; 00148 int oldstyle; 00149 }; 00150 child children[4]; 00151 POINT center; 00152 RECT wmsizerc; 00153 00154 DockWindow(HWND parent, const char*caption); 00155 virtual LRESULT WndProc(UINT msg,WPARAM wParam,LPARAM lParam); 00156 bool CanClose(); 00157 void PositionWindows(); 00158 bool Dock(TCWindow *win); 00159 bool UnDock(TCWindow *win); 00160 }; 00161 00162 00163 00164 //PaletteWindow 00165 class PaletteWindow : public TCWindow 00166 { 00167 public: 00168 PaletteWindow(HWND parent, const char*caption); 00169 LRESULT WndProc(UINT msg,WPARAM wParam,LPARAM lParam); 00170 void Redraw(); 00171 }; 00172 00173 //ImageView 00174 class ImageView : public TCWindow 00175 { 00176 public: 00177 int width; 00178 int height; 00179 HBITMAP bmp; 00180 ImageView(HWND parent, const char*caption, unsigned char*img,int width, int height); 00181 ~ImageView(); 00182 LRESULT WndProc(UINT msg,WPARAM wParam,LPARAM lParam); 00183 void Redraw(); 00184 void ResetSize(); 00185 };