]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/toplevel.h | |
3 | // Purpose: Top level window, abstraction of wxFrame and wxDialog | |
4 | // Author: Vaclav Slavik | |
5 | // Id: $Id$ | |
6 | // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com) | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | ||
11 | #ifndef __WX_UNIV_TOPLEVEL_H__ | |
12 | #define __WX_UNIV_TOPLEVEL_H__ | |
13 | ||
14 | #ifdef __GNUG__ | |
15 | #pragma interface "univtoplevel.h" | |
16 | #endif | |
17 | ||
18 | #include "wx/univ/inpcons.h" | |
19 | #include "wx/univ/inphand.h" | |
20 | ||
21 | // ---------------------------------------------------------------------------- | |
22 | // constants | |
23 | // ---------------------------------------------------------------------------- | |
24 | ||
25 | // frame decorations type flags used in wxRenderer and wxColourScheme | |
26 | enum | |
27 | { | |
28 | wxTOPLEVEL_ACTIVE = 0x00000001, | |
29 | wxTOPLEVEL_MAXIMIZED = 0x00000002, | |
30 | wxTOPLEVEL_TITLEBAR = 0x00000004, | |
31 | wxTOPLEVEL_ICON = 0x00000008, | |
32 | wxTOPLEVEL_RESIZEABLE = 0x00000010, | |
33 | wxTOPLEVEL_BORDER = 0x00000020, | |
34 | wxTOPLEVEL_BUTTON_CLOSE = 0x01000000, | |
35 | wxTOPLEVEL_BUTTON_MAXIMIZE = 0x02000000, | |
36 | wxTOPLEVEL_BUTTON_ICONIZE = 0x04000000, | |
37 | wxTOPLEVEL_BUTTON_RESTORE = 0x08000000, | |
38 | wxTOPLEVEL_BUTTON_HELP = 0x10000000, | |
39 | }; | |
40 | ||
41 | // frame hit test return values: | |
42 | enum | |
43 | { | |
44 | wxHT_TOPLEVEL_NOWHERE = 0x00000000, | |
45 | wxHT_TOPLEVEL_CLIENT_AREA = 0x00000001, | |
46 | wxHT_TOPLEVEL_ICON = 0x00000002, | |
47 | wxHT_TOPLEVEL_TITLEBAR = 0x00000004, | |
48 | ||
49 | wxHT_TOPLEVEL_BORDER_N = 0x00000010, | |
50 | wxHT_TOPLEVEL_BORDER_S = 0x00000020, | |
51 | wxHT_TOPLEVEL_BORDER_E = 0x00000040, | |
52 | wxHT_TOPLEVEL_BORDER_W = 0x00000080, | |
53 | wxHT_TOPLEVEL_BORDER_NE = wxHT_TOPLEVEL_BORDER_N | wxHT_TOPLEVEL_BORDER_E, | |
54 | wxHT_TOPLEVEL_BORDER_SE = wxHT_TOPLEVEL_BORDER_S | wxHT_TOPLEVEL_BORDER_E, | |
55 | wxHT_TOPLEVEL_BORDER_NW = wxHT_TOPLEVEL_BORDER_N | wxHT_TOPLEVEL_BORDER_W, | |
56 | wxHT_TOPLEVEL_BORDER_SW = wxHT_TOPLEVEL_BORDER_S | wxHT_TOPLEVEL_BORDER_W, | |
57 | wxHT_TOPLEVEL_ANY_BORDER = 0x000000F0, | |
58 | ||
59 | wxHT_TOPLEVEL_BUTTON_CLOSE = /*0x01000000*/ wxTOPLEVEL_BUTTON_CLOSE, | |
60 | wxHT_TOPLEVEL_BUTTON_MAXIMIZE = /*0x02000000*/ wxTOPLEVEL_BUTTON_MAXIMIZE, | |
61 | wxHT_TOPLEVEL_BUTTON_ICONIZE = /*0x04000000*/ wxTOPLEVEL_BUTTON_ICONIZE, | |
62 | wxHT_TOPLEVEL_BUTTON_RESTORE = /*0x08000000*/ wxTOPLEVEL_BUTTON_RESTORE, | |
63 | wxHT_TOPLEVEL_BUTTON_HELP = /*0x10000000*/ wxTOPLEVEL_BUTTON_HELP, | |
64 | wxHT_TOPLEVEL_ANY_BUTTON = 0x1F000000 | |
65 | }; | |
66 | ||
67 | // ---------------------------------------------------------------------------- | |
68 | // the actions supported by this control | |
69 | // ---------------------------------------------------------------------------- | |
70 | ||
71 | #define wxACTION_TOPLEVEL_ACTIVATE _T("activate") // (de)activate the frame | |
72 | #define wxACTION_TOPLEVEL_BUTTON_PRESS _T("pressbtn") // press titlebar btn | |
73 | #define wxACTION_TOPLEVEL_BUTTON_RELEASE _T("releasebtn") // press titlebar btn | |
74 | #define wxACTION_TOPLEVEL_BUTTON_CLICK _T("clickbtn") // press titlebar btn | |
75 | #define wxACTION_TOPLEVEL_MOVE _T("move") // move the frame | |
76 | #define wxACTION_TOPLEVEL_RESIZE _T("resize") // resize the frame | |
77 | ||
78 | //----------------------------------------------------------------------------- | |
79 | // wxTopLevelWindow | |
80 | //----------------------------------------------------------------------------- | |
81 | ||
82 | class WXDLLEXPORT wxTopLevelWindow : public wxTopLevelWindowNative, | |
83 | public wxInputConsumer | |
84 | { | |
85 | public: | |
86 | // construction | |
87 | wxTopLevelWindow() { Init(); } | |
88 | wxTopLevelWindow(wxWindow *parent, | |
89 | wxWindowID id, | |
90 | const wxString& title, | |
91 | const wxPoint& pos = wxDefaultPosition, | |
92 | const wxSize& size = wxDefaultSize, | |
93 | long style = wxDEFAULT_FRAME_STYLE, | |
94 | const wxString& name = wxFrameNameStr) | |
95 | { | |
96 | Init(); | |
97 | ||
98 | Create(parent, id, title, pos, size, style, name); | |
99 | } | |
100 | ||
101 | bool Create(wxWindow *parent, | |
102 | wxWindowID id, | |
103 | const wxString& title, | |
104 | const wxPoint& pos = wxDefaultPosition, | |
105 | const wxSize& size = wxDefaultSize, | |
106 | long style = wxDEFAULT_FRAME_STYLE, | |
107 | const wxString& name = wxFrameNameStr); | |
108 | ||
109 | // implement base class pure virtuals | |
110 | virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL); | |
111 | virtual wxPoint GetClientAreaOrigin() const; | |
112 | virtual void DoGetClientSize(int *width, int *height) const; | |
113 | virtual void DoSetClientSize(int width, int height); | |
114 | virtual void SetIcon(const wxIcon& icon); | |
115 | ||
116 | // implementation from now on | |
117 | // -------------------------- | |
118 | ||
119 | // tests for frame's part at given point | |
120 | long HitTest(const wxPoint& pt) const; | |
121 | ||
122 | protected: | |
123 | virtual bool PerformAction(const wxControlAction& action, | |
124 | long numArg = -1, | |
125 | const wxString& strArg = wxEmptyString); | |
126 | // handle titlebar button click event | |
127 | virtual void ClickTitleBarButton(long button); | |
128 | ||
129 | virtual wxWindow *GetInputWindow() const { return (wxWindow*)this; } | |
130 | ||
131 | // return wxTOPLEVEL_xxx combination based on current state of the frame | |
132 | long GetDecorationsStyle() const; | |
133 | ||
134 | // common part of all ctors | |
135 | void Init(); | |
136 | ||
137 | void RefreshTitleBar(); | |
138 | void OnNcPaint(wxPaintEvent& event); | |
139 | ||
140 | // TRUE if wxTLW should render decorations (aka titlebar) itself | |
141 | static int ms_drawDecorations; | |
142 | // true for currently active frame | |
143 | bool m_isActive:1; | |
144 | // version of icon for titlebar (16x16) | |
145 | wxIcon m_titlebarIcon; | |
146 | // saved window style in fullscreen mdoe | |
147 | long m_fsSavedStyle; | |
148 | // currently pressed titlebar button | |
149 | long m_pressedButton; | |
150 | ||
151 | DECLARE_DYNAMIC_CLASS(wxTopLevelWindow) | |
152 | DECLARE_EVENT_TABLE() | |
153 | WX_DECLARE_INPUT_CONSUMER() | |
154 | }; | |
155 | ||
156 | // ---------------------------------------------------------------------------- | |
157 | // wxStdFrameInputHandler: handles focus, resizing and titlebar buttons clicks | |
158 | // ---------------------------------------------------------------------------- | |
159 | ||
160 | class WXDLLEXPORT wxStdFrameInputHandler : public wxStdInputHandler | |
161 | { | |
162 | public: | |
163 | wxStdFrameInputHandler(wxInputHandler *inphand); | |
164 | ||
165 | virtual bool HandleMouse(wxInputConsumer *consumer, | |
166 | const wxMouseEvent& event); | |
167 | virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event); | |
168 | virtual bool HandleActivation(wxInputConsumer *consumer, bool activated); | |
169 | ||
170 | private: | |
171 | // the window (button) which has capture or NULL and the last hittest result | |
172 | wxTopLevelWindow *m_winCapture; | |
173 | long m_winHitTest; | |
174 | long m_winPressed; | |
175 | bool m_borderCursorOn; | |
176 | wxCursor m_origCursor; | |
177 | }; | |
178 | ||
179 | #endif // __WX_UNIV_TOPLEVEL_H__ |