1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        wx/msw/frame.h
3 // Purpose:     wxFrame class
4 // Author:      Julian Smart
5 // Modified by:
6 // Created:     01/02/97
7 // Copyright:   (c) Julian Smart
8 // Licence:     wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10 
11 #ifndef _WX_FRAME_H_
12 #define _WX_FRAME_H_
13 
14 #if wxUSE_TASKBARBUTTON
15 class WXDLLIMPEXP_FWD_CORE wxTaskBarButton;
16 #endif
17 
18 class WXDLLIMPEXP_CORE wxFrame : public wxFrameBase
19 {
20 public:
21     // construction
wxFrame()22     wxFrame() { Init(); }
23     wxFrame(wxWindow *parent,
24             wxWindowID id,
25             const wxString& title,
26             const wxPoint& pos = wxDefaultPosition,
27             const wxSize& size = wxDefaultSize,
28             long style = wxDEFAULT_FRAME_STYLE,
29             const wxString& name = wxASCII_STR(wxFrameNameStr))
30     {
31         Init();
32 
33         Create(parent, id, title, pos, size, style, name);
34     }
35 
36     bool Create(wxWindow *parent,
37                 wxWindowID id,
38                 const wxString& title,
39                 const wxPoint& pos = wxDefaultPosition,
40                 const wxSize& size = wxDefaultSize,
41                 long style = wxDEFAULT_FRAME_STYLE,
42                 const wxString& name = wxASCII_STR(wxFrameNameStr));
43     virtual ~wxFrame();
44 
45     // implement base class pure virtuals
46     virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) wxOVERRIDE;
47 
48     // implementation only from now on
49     // -------------------------------
50 
51     // event handlers
52     void OnSysColourChanged(wxSysColourChangedEvent& event);
53 
54     // Toolbar
55 #if wxUSE_TOOLBAR
56     virtual wxToolBar* CreateToolBar(long style = -1,
57                                      wxWindowID id = wxID_ANY,
58                                      const wxString& name = wxASCII_STR(wxToolBarNameStr)) wxOVERRIDE;
59 #endif // wxUSE_TOOLBAR
60 
61     // Status bar
62 #if wxUSE_STATUSBAR
63     virtual wxStatusBar* OnCreateStatusBar(int number = 1,
64                                            long style = wxSTB_DEFAULT_STYLE,
65                                            wxWindowID id = 0,
66                                            const wxString& name = wxASCII_STR(wxStatusLineNameStr)) wxOVERRIDE;
67 
68     // Hint to tell framework which status bar to use: the default is to use
69     // native one for the platforms which support it (Win32), the generic one
70     // otherwise
71 
72     // TODO: should this go into a wxFrameworkSettings class perhaps?
UseNativeStatusBar(bool useNative)73     static void UseNativeStatusBar(bool useNative)
74         { m_useNativeStatusBar = useNative; }
UsesNativeStatusBar()75     static bool UsesNativeStatusBar()
76         { return m_useNativeStatusBar; }
77 #endif // wxUSE_STATUSBAR
78 
79     // event handlers
80     bool HandleSize(int x, int y, WXUINT flag);
81     bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
82 
83     // tooltip management
84 #if wxUSE_TOOLTIPS
GetToolTipCtrl()85     WXHWND GetToolTipCtrl() const { return m_hwndToolTip; }
SetToolTipCtrl(WXHWND hwndTT)86     void SetToolTipCtrl(WXHWND hwndTT) { m_hwndToolTip = hwndTT; }
87 #endif // tooltips
88 
89     // override the base class function to handle iconized/maximized frames
90     virtual void SendSizeEvent(int flags = 0) wxOVERRIDE;
91 
92     virtual wxPoint GetClientAreaOrigin() const wxOVERRIDE;
93 
94     // override base class version to add menu bar accel processing
MSWTranslateMessage(WXMSG * msg)95     virtual bool MSWTranslateMessage(WXMSG *msg) wxOVERRIDE
96     {
97         return MSWDoTranslateMessage(this, msg);
98     }
99 
100     // window proc for the frames
101     virtual WXLRESULT MSWWindowProc(WXUINT message,
102                                     WXWPARAM wParam,
103                                     WXLPARAM lParam) wxOVERRIDE;
104 
105 #if wxUSE_MENUS
106     // get the currently active menu: this is the same as the frame menu for
107     // normal frames but is overridden by wxMDIParentFrame
MSWGetActiveMenu()108     virtual WXHMENU MSWGetActiveMenu() const { return m_hMenu; }
109 
110     virtual bool HandleMenuSelect(WXWORD nItem, WXWORD nFlags, WXHMENU hMenu) wxOVERRIDE;
111     virtual bool DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu) wxOVERRIDE;
112 
113     // Look up the menu in the menu bar.
114     virtual wxMenu* MSWFindMenuFromHMENU(WXHMENU hMenu) wxOVERRIDE;
115 #endif // wxUSE_MENUS
116 
117 #if wxUSE_TASKBARBUTTON
118     // Return the taskbar button of the window.
119     //
120     // The pointer returned by this method belongs to the window and will be
121     // deleted when the window itself is, do not delete it yourself. May return
122     // NULL if the initialization of taskbar button failed.
123     wxTaskBarButton* MSWGetTaskBarButton();
124 #endif // wxUSE_TASKBARBUTTON
125 
126 protected:
127     // common part of all ctors
128     void Init();
129 
130     // override base class virtuals
131     virtual void DoGetClientSize(int *width, int *height) const wxOVERRIDE;
132     virtual void DoSetClientSize(int width, int height) wxOVERRIDE;
133 
134 #if wxUSE_MENUS_NATIVE
135     // perform MSW-specific action when menubar is changed
136     virtual void AttachMenuBar(wxMenuBar *menubar) wxOVERRIDE;
137 
138     // a plug in for MDI frame classes which need to do something special when
139     // the menubar is set
140     virtual void InternalSetMenuBar();
141 #endif // wxUSE_MENUS_NATIVE
142 
143     // propagate our state change to all child frames
144     void IconizeChildFrames(bool bIconize);
145 
146     // the real implementation of MSWTranslateMessage(), also used by
147     // wxMDIChildFrame
148     bool MSWDoTranslateMessage(wxFrame *frame, WXMSG *msg);
149 
IsMDIChild()150     virtual bool IsMDIChild() const { return false; }
151 
152     // get default (wxWidgets) icon for the frame
153     virtual WXHICON GetDefaultIcon() const;
154 
155 #if wxUSE_TOOLBAR
156     virtual void PositionToolBar() wxOVERRIDE;
157 #endif // wxUSE_TOOLBAR
158 
159 #if wxUSE_STATUSBAR
160     virtual void PositionStatusBar() wxOVERRIDE;
161 
162     static bool           m_useNativeStatusBar;
163 #endif // wxUSE_STATUSBAR
164 
165 #if wxUSE_MENUS
166     // frame menu, NULL if none
167     WXHMENU m_hMenu;
168 
169     // The number of currently opened menus: 0 initially, 1 when a top level
170     // menu is opened, 2 when its submenu is opened and so on.
171     int m_menuDepth;
172 #endif // wxUSE_MENUS
173 
174 private:
175 #if wxUSE_TOOLTIPS
176     WXHWND                m_hwndToolTip;
177 #endif // tooltips
178 
179     // used by IconizeChildFrames(), see comments there
180     bool m_wasMinimized;
181 
182 #if wxUSE_TASKBARBUTTON
183     wxTaskBarButton* m_taskBarButton;
184 #endif
185 
186     wxDECLARE_EVENT_TABLE();
187     wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxFrame);
188 };
189 
190 #endif
191     // _WX_FRAME_H_
192