1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Top level window, abstraction of wxFrame and wxDialog
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __WX_UNIV_TOPLEVEL_H__
12 #define __WX_UNIV_TOPLEVEL_H__
14 #include "wx/univ/inpcons.h"
15 #include "wx/univ/inphand.h"
18 // ----------------------------------------------------------------------------
20 // ----------------------------------------------------------------------------
22 // frame decorations type flags used in wxRenderer and wxColourScheme
25 wxTOPLEVEL_ACTIVE
= 0x00000001,
26 wxTOPLEVEL_MAXIMIZED
= 0x00000002,
27 wxTOPLEVEL_TITLEBAR
= 0x00000004,
28 wxTOPLEVEL_ICON
= 0x00000008,
29 wxTOPLEVEL_RESIZEABLE
= 0x00000010,
30 wxTOPLEVEL_BORDER
= 0x00000020,
31 wxTOPLEVEL_BUTTON_CLOSE
= 0x01000000,
32 wxTOPLEVEL_BUTTON_MAXIMIZE
= 0x02000000,
33 wxTOPLEVEL_BUTTON_ICONIZE
= 0x04000000,
34 wxTOPLEVEL_BUTTON_RESTORE
= 0x08000000,
35 wxTOPLEVEL_BUTTON_HELP
= 0x10000000
38 // frame hit test return values:
41 wxHT_TOPLEVEL_NOWHERE
= 0x00000000,
42 wxHT_TOPLEVEL_CLIENT_AREA
= 0x00000001,
43 wxHT_TOPLEVEL_ICON
= 0x00000002,
44 wxHT_TOPLEVEL_TITLEBAR
= 0x00000004,
46 wxHT_TOPLEVEL_BORDER_N
= 0x00000010,
47 wxHT_TOPLEVEL_BORDER_S
= 0x00000020,
48 wxHT_TOPLEVEL_BORDER_E
= 0x00000040,
49 wxHT_TOPLEVEL_BORDER_W
= 0x00000080,
50 wxHT_TOPLEVEL_BORDER_NE
= wxHT_TOPLEVEL_BORDER_N
| wxHT_TOPLEVEL_BORDER_E
,
51 wxHT_TOPLEVEL_BORDER_SE
= wxHT_TOPLEVEL_BORDER_S
| wxHT_TOPLEVEL_BORDER_E
,
52 wxHT_TOPLEVEL_BORDER_NW
= wxHT_TOPLEVEL_BORDER_N
| wxHT_TOPLEVEL_BORDER_W
,
53 wxHT_TOPLEVEL_BORDER_SW
= wxHT_TOPLEVEL_BORDER_S
| wxHT_TOPLEVEL_BORDER_W
,
54 wxHT_TOPLEVEL_ANY_BORDER
= 0x000000F0,
56 wxHT_TOPLEVEL_BUTTON_CLOSE
= /*0x01000000*/ wxTOPLEVEL_BUTTON_CLOSE
,
57 wxHT_TOPLEVEL_BUTTON_MAXIMIZE
= /*0x02000000*/ wxTOPLEVEL_BUTTON_MAXIMIZE
,
58 wxHT_TOPLEVEL_BUTTON_ICONIZE
= /*0x04000000*/ wxTOPLEVEL_BUTTON_ICONIZE
,
59 wxHT_TOPLEVEL_BUTTON_RESTORE
= /*0x08000000*/ wxTOPLEVEL_BUTTON_RESTORE
,
60 wxHT_TOPLEVEL_BUTTON_HELP
= /*0x10000000*/ wxTOPLEVEL_BUTTON_HELP
,
61 wxHT_TOPLEVEL_ANY_BUTTON
= 0x1F000000
64 // Flags for interactive frame manipulation functions (only in wxUniversal):
67 wxINTERACTIVE_MOVE
= 0x00000001,
68 wxINTERACTIVE_RESIZE
= 0x00000002,
69 wxINTERACTIVE_RESIZE_S
= 0x00000010,
70 wxINTERACTIVE_RESIZE_N
= 0x00000020,
71 wxINTERACTIVE_RESIZE_W
= 0x00000040,
72 wxINTERACTIVE_RESIZE_E
= 0x00000080,
73 wxINTERACTIVE_WAIT_FOR_INPUT
= 0x10000000
76 // ----------------------------------------------------------------------------
77 // the actions supported by this control
78 // ----------------------------------------------------------------------------
80 #define wxACTION_TOPLEVEL_ACTIVATE _T("activate") // (de)activate the frame
81 #define wxACTION_TOPLEVEL_BUTTON_PRESS _T("pressbtn") // press titlebar btn
82 #define wxACTION_TOPLEVEL_BUTTON_RELEASE _T("releasebtn") // press titlebar btn
83 #define wxACTION_TOPLEVEL_BUTTON_CLICK _T("clickbtn") // press titlebar btn
84 #define wxACTION_TOPLEVEL_MOVE _T("move") // move the frame
85 #define wxACTION_TOPLEVEL_RESIZE _T("resize") // resize the frame
87 //-----------------------------------------------------------------------------
89 //-----------------------------------------------------------------------------
91 class WXDLLEXPORT wxTopLevelWindow
: public wxTopLevelWindowNative
,
92 public wxInputConsumer
96 wxTopLevelWindow() { Init(); }
97 wxTopLevelWindow(wxWindow
*parent
,
99 const wxString
& title
,
100 const wxPoint
& pos
= wxDefaultPosition
,
101 const wxSize
& size
= wxDefaultSize
,
102 long style
= wxDEFAULT_FRAME_STYLE
,
103 const wxString
& name
= wxFrameNameStr
)
107 Create(parent
, id
, title
, pos
, size
, style
, name
);
110 bool Create(wxWindow
*parent
,
112 const wxString
& title
,
113 const wxPoint
& pos
= wxDefaultPosition
,
114 const wxSize
& size
= wxDefaultSize
,
115 long style
= wxDEFAULT_FRAME_STYLE
,
116 const wxString
& name
= wxFrameNameStr
);
118 // wxUniv-specific methods: do [not] use native decorations for this (or
121 // notice that this has no effect if the system doesn't support any native
122 // decorations anyhow and that by default native decorations are used
124 // if UseNativeDecorations() is used, it must be called before Create()
125 static UseNativeDecorationsByDefault(bool native
= true);
126 void UseNativeDecorations(bool native
= true);
127 bool IsUsingNativeDecorations() const;
130 // implement base class pure virtuals
131 virtual bool ShowFullScreen(bool show
, long style
= wxFULLSCREEN_ALL
);
132 virtual wxPoint
GetClientAreaOrigin() const;
133 virtual void SetIcon(const wxIcon
& icon
) { SetIcons( wxIconBundle( icon
) ); }
134 virtual void SetIcons(const wxIconBundle
& icons
);
136 // implementation from now on
137 // --------------------------
139 // tests for frame's part at given point
140 long HitTest(const wxPoint
& pt
) const;
142 virtual bool PerformAction(const wxControlAction
& action
,
144 const wxString
& strArg
= wxEmptyString
);
146 static wxInputHandler
*GetStdInputHandler(wxInputHandler
*handlerDef
);
147 virtual wxInputHandler
*DoGetStdInputHandler(wxInputHandler
*handlerDef
)
149 return GetStdInputHandler(handlerDef
);
152 // move/resize the frame interactively, i.e. let the user do it
153 virtual void InteractiveMove(int flags
= wxINTERACTIVE_MOVE
);
155 virtual int GetMinWidth() const;
156 virtual int GetMinHeight() const;
158 virtual wxWindow
*GetInputWindow() const { return wx_const_cast(wxTopLevelWindow
*, this); }
161 virtual void DoGetClientSize(int *width
, int *height
) const;
162 virtual void DoSetClientSize(int width
, int height
);
164 // handle titlebar button click event
165 virtual void ClickTitleBarButton(long button
);
167 // return wxTOPLEVEL_xxx combination based on current state of the frame
168 long GetDecorationsStyle() const;
170 // common part of all ctors
173 void RefreshTitleBar();
174 void OnNcPaint(wxNcPaintEvent
& event
);
175 void OnSystemMenu(wxCommandEvent
& event
);
177 // true if wxTLW should render decorations (aka titlebar) itself
178 static int ms_drawDecorations
;
179 // true if wxTLW can be iconized
180 static int ms_canIconize
;
182 // true if we're using native decorations
183 bool m_usingNativeDecorations
;
184 // true for currently active frame
186 // version of icon for titlebar (16x16)
187 wxIcon m_titlebarIcon
;
188 // saved window style in fullscreen mdoe
190 // currently pressed titlebar button
191 long m_pressedButton
;
193 DECLARE_DYNAMIC_CLASS(wxTopLevelWindow
)
194 DECLARE_EVENT_TABLE()
195 WX_DECLARE_INPUT_CONSUMER()
198 #endif // __WX_UNIV_TOPLEVEL_H__