]> git.saurik.com Git - wxWidgets.git/blob - src/os2/frame.cpp
Made HelpGen compile here.
[wxWidgets.git] / src / os2 / frame.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: frame.cpp
3 // Purpose: wxFrame
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/27/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifndef WX_PRECOMP
16 #include "wx/setup.h"
17 #include "wx/frame.h"
18 #include "wx/menu.h"
19 #include "wx/app.h"
20 #include "wx/utils.h"
21 #include "wx/dialog.h"
22 #include "wx/settings.h"
23 #include "wx/dcclient.h"
24 #endif // WX_PRECOMP
25
26 #include "wx/os2/private.h"
27
28 #if wxUSE_STATUSBAR
29 #include "wx/statusbr.h"
30 #endif // wxUSE_STATUSBAR
31
32 #if wxUSE_TOOLBAR
33 #include "wx/toolbar.h"
34 #endif // wxUSE_TOOLBAR
35
36 #include "wx/menuitem.h"
37 #include "wx/log.h"
38
39 // ----------------------------------------------------------------------------
40 // globals
41 // ----------------------------------------------------------------------------
42
43 extern wxWindowList wxModelessWindows;
44 extern wxList WXDLLEXPORT wxPendingDelete;
45 extern wxChar wxFrameClassName[];
46 extern wxMenu *wxCurrentPopupMenu;
47
48 // ----------------------------------------------------------------------------
49 // event tables
50 // ----------------------------------------------------------------------------
51
52 BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
53 EVT_ACTIVATE(wxFrame::OnActivate)
54 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
55 END_EVENT_TABLE()
56
57 IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
58
59 // ============================================================================
60 // implementation
61 // ============================================================================
62
63 // ----------------------------------------------------------------------------
64 // static class members
65 // ----------------------------------------------------------------------------
66
67 #if wxUSE_NATIVE_STATUSBAR
68 bool wxFrame::m_useNativeStatusBar = TRUE;
69 #else
70 bool wxFrame::m_useNativeStatusBar = FALSE;
71 #endif
72
73 // ----------------------------------------------------------------------------
74 // creation/destruction
75 // ----------------------------------------------------------------------------
76
77 void wxFrame::Init()
78 {
79 m_iconized = FALSE;
80
81 #if wxUSE_TOOLTIPS
82 m_hwndToolTip = 0;
83 #endif
84 }
85
86 bool wxFrame::Create(wxWindow *parent,
87 wxWindowID id,
88 const wxString& title,
89 const wxPoint& pos,
90 const wxSize& size,
91 long style,
92 const wxString& name)
93 {
94 SetName(name);
95 m_windowStyle = style;
96 m_frameMenuBar = NULL;
97 m_frameToolBar = NULL;
98 m_frameStatusBar = NULL;
99
100 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
101
102 if ( id > -1 )
103 m_windowId = id;
104 else
105 m_windowId = (int)NewControlId();
106
107 if (parent) parent->AddChild(this);
108
109 int x = pos.x;
110 int y = pos.y;
111 int width = size.x;
112 int height = size.y;
113
114 m_iconized = FALSE;
115
116 // we pass NULL as parent to MSWCreate because frames with parents behave
117 // very strangely under Win95 shell
118 // Alteration by JACS: keep normal Windows behaviour (float on top of parent)
119 // with this style.
120 if ((m_windowStyle & wxFRAME_FLOAT_ON_PARENT) == 0)
121 parent = NULL;
122
123 if (!parent)
124 wxTopLevelWindows.Append(this);
125
126 OS2Create(m_windowId, parent, wxFrameClassName, this, title,
127 x, y, width, height, style);
128
129 wxModelessWindows.Append(this);
130 return TRUE;
131 }
132
133 wxFrame::~wxFrame()
134 {
135 m_isBeingDeleted = TRUE;
136 wxTopLevelWindows.DeleteObject(this);
137
138 // TODO:
139 /*
140 DeleteAllBars();
141
142 if (wxTheApp && (wxTopLevelWindows.Number() == 0))
143 {
144 wxTheApp->SetTopWindow(NULL);
145
146 if (wxTheApp->GetExitOnFrameDelete())
147 {
148 PostQuitMessage(0);
149 }
150 }
151
152 wxModelessWindows.DeleteObject(this);
153
154 // For some reason, wxWindows can activate another task altogether
155 // when a frame is destroyed after a modal dialog has been invoked.
156 // Try to bring the parent to the top.
157 // MT:Only do this if this frame is currently the active window, else weird
158 // things start to happen
159 if ( wxGetActiveWindow() == this )
160 if (GetParent() && GetParent()->GetHWND())
161 ::BringWindowToTop((HWND) GetParent()->GetHWND());
162 */
163 }
164
165 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
166 void wxFrame::DoGetClientSize(int *x, int *y) const
167 {
168 // TODO:
169 /*
170 RECT rect;
171 ::GetClientRect(GetHwnd(), &rect);
172
173 #if wxUSE_STATUSBAR
174 if ( GetStatusBar() )
175 {
176 int statusX, statusY;
177 GetStatusBar()->GetClientSize(&statusX, &statusY);
178 rect.bottom -= statusY;
179 }
180 #endif // wxUSE_STATUSBAR
181
182 wxPoint pt(GetClientAreaOrigin());
183 rect.bottom -= pt.y;
184 rect.right -= pt.x;
185
186 if ( x )
187 *x = rect.right;
188 if ( y )
189 *y = rect.bottom;
190 */
191 }
192
193 // Set the client size (i.e. leave the calculation of borders etc.
194 // to wxWindows)
195 void wxFrame::DoSetClientSize(int width, int height)
196 {
197 HWND hWnd = GetHwnd();
198
199 // TODO:
200 /*
201 RECT rect;
202 ::GetClientRect(hWnd, &rect);
203
204 RECT rect2;
205 GetWindowRect(hWnd, &rect2);
206
207 // Find the difference between the entire window (title bar and all)
208 // and the client area; add this to the new client size to move the
209 // window
210 int actual_width = rect2.right - rect2.left - rect.right + width;
211 int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
212
213 #if wxUSE_STATUSBAR
214 if ( GetStatusBar() )
215 {
216 int statusX, statusY;
217 GetStatusBar()->GetClientSize(&statusX, &statusY);
218 actual_height += statusY;
219 }
220 #endif // wxUSE_STATUSBAR
221
222 wxPoint pt(GetClientAreaOrigin());
223 actual_width += pt.y;
224 actual_height += pt.x;
225
226 POINT point;
227 point.x = rect2.left;
228 point.y = rect2.top;
229
230 MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)TRUE);
231
232 wxSizeEvent event(wxSize(width, height), m_windowId);
233 event.SetEventObject( this );
234 GetEventHandler()->ProcessEvent(event);
235 */
236 }
237
238 void wxFrame::DoGetSize(int *width, int *height) const
239 {
240 // TODO:
241 /*
242 RECT rect;
243 GetWindowRect(GetHwnd(), &rect);
244 *width = rect.right - rect.left;
245 *height = rect.bottom - rect.top;
246 */
247 }
248
249 void wxFrame::DoGetPosition(int *x, int *y) const
250 {
251 // TODO:
252 /*
253 RECT rect;
254 GetWindowRect(GetHwnd(), &rect);
255 POINT point;
256 point.x = rect.left;
257 point.y = rect.top;
258
259 *x = point.x;
260 *y = point.y;
261 */
262 }
263
264 // ----------------------------------------------------------------------------
265 // variations around ::ShowWindow()
266 // ----------------------------------------------------------------------------
267
268 void wxFrame::DoShowWindow(int nShowCmd)
269 {
270 // TODO:
271 /*
272 ::ShowWindow(GetHwnd(), nShowCmd);
273
274 m_iconized = nShowCmd == SW_MINIMIZE;
275 */
276 }
277
278 bool wxFrame::Show(bool show)
279 {
280 // TODO:
281 /*
282 DoShowWindow(show ? SW_SHOW : SW_HIDE);
283
284 if ( show )
285 {
286 ::BringWindowToTop(GetHwnd());
287
288 wxActivateEvent event(wxEVT_ACTIVATE, TRUE, m_windowId);
289 event.SetEventObject( this );
290 GetEventHandler()->ProcessEvent(event);
291 }
292 else
293 {
294 // Try to highlight the correct window (the parent)
295 if ( GetParent() )
296 {
297 HWND hWndParent = GetHwndOf(GetParent());
298 if (hWndParent)
299 ::BringWindowToTop(hWndParent);
300 }
301 }
302 */
303 return TRUE;
304 }
305
306 void wxFrame::Iconize(bool iconize)
307 {
308 // DoShowWindow(iconize ? SW_MINIMIZE : SW_RESTORE);
309 }
310
311 void wxFrame::Maximize(bool maximize)
312 {
313 // DoShowWindow(maximize ? SW_MAXIMIZE : SW_RESTORE);
314 }
315
316 void wxFrame::Restore()
317 {
318 // DoShowWindow(SW_RESTORE);
319 }
320
321 bool wxFrame::IsIconized() const
322 {
323 // TODO:
324 /*
325 ((wxFrame *)this)->m_iconized = (::IsIconic(GetHwnd()) != 0);
326 return m_iconized;
327 */
328 return FALSE;
329 }
330
331 // Is it maximized?
332 bool wxFrame::IsMaximized() const
333 {
334 // TODO:
335 /*
336 return (::IsZoomed(GetHwnd()) != 0);
337 */
338 return FALSE;
339 }
340
341 void wxFrame::SetIcon(const wxIcon& icon)
342 {
343 wxFrameBase::SetIcon(icon);
344
345 // TODO:
346 /*
347 if ( m_icon.Ok() )
348 {
349 SendMessage(GetHwnd(), WM_SETICON,
350 (WPARAM)TRUE, (LPARAM)(HICON) m_icon.GetHICON());
351 }
352 */
353 }
354
355 #if wxUSE_STATUSBAR
356 wxStatusBar *wxFrame::OnCreateStatusBar(int number,
357 long style,
358 wxWindowID id,
359 const wxString& name)
360 {
361 wxStatusBar *statusBar = NULL;
362
363 statusBar = wxFrameBase::OnCreateStatusBar(number, style, id, name);
364
365 return statusBar;
366 }
367
368 void wxFrame::PositionStatusBar()
369 {
370 // TODO:
371 /*
372 // native status bar positions itself
373 if ( m_frameStatusBar )
374 {
375 int w, h;
376 GetClientSize(&w, &h);
377 int sw, sh;
378 m_frameStatusBar->GetSize(&sw, &sh);
379
380 // Since we wish the status bar to be directly under the client area,
381 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
382 m_frameStatusBar->SetSize(0, h, w, sh);
383 }
384 */
385 }
386 #endif // wxUSE_STATUSBAR
387
388 void wxFrame::DetachMenuBar()
389 {
390 if (m_frameMenuBar)
391 {
392 m_frameMenuBar->Detach();
393 m_frameMenuBar = NULL;
394 }
395 }
396
397 void wxFrame::SetMenuBar(wxMenuBar *menu_bar)
398 {
399 if (!menu_bar)
400 {
401 DetachMenuBar();
402 return;
403 }
404
405 wxCHECK_RET( !menu_bar->GetFrame(), wxT("this menubar is already attached") );
406
407 if (m_frameMenuBar)
408 delete m_frameMenuBar;
409
410 m_hMenu = menu_bar->Create();
411
412 if ( !m_hMenu )
413 return;
414
415 InternalSetMenuBar();
416
417 m_frameMenuBar = menu_bar;
418 menu_bar->Attach(this);
419 }
420
421 void wxFrame::InternalSetMenuBar()
422 {
423 // TODO:
424 /*
425 if ( !::SetMenu(GetHwnd(), (HMENU)m_hMenu) )
426 {
427 wxLogLastError("SetMenu");
428 }
429 */
430 }
431
432 // Responds to colour changes, and passes event on to children.
433 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
434 {
435 // TODO:
436 /*
437 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
438 Refresh();
439
440 if ( m_frameStatusBar )
441 {
442 wxSysColourChangedEvent event2;
443 event2.SetEventObject( m_frameStatusBar );
444 m_frameStatusBar->GetEventHandler()->ProcessEvent(event2);
445 }
446
447 // Propagate the event to the non-top-level children
448 wxWindow::OnSysColourChanged(event);
449 */
450 }
451
452 /*
453 * Frame window
454 *
455 */
456
457 bool wxFrame::OS2Create(int id, wxWindow *parent, const wxChar *wclass, wxWindow *wx_win, const wxChar *title,
458 int x, int y, int width, int height, long style)
459
460 {
461 m_defaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON);
462
463 // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
464 // could be the culprit. But without it, you can get a lot of flicker.
465
466 // TODO:
467 /*
468 DWORD msflags = 0;
469 if ((style & wxCAPTION) == wxCAPTION)
470 msflags = WS_OVERLAPPED;
471 else
472 msflags = WS_POPUP;
473
474 if (style & wxMINIMIZE_BOX)
475 msflags |= WS_MINIMIZEBOX;
476 if (style & wxMAXIMIZE_BOX)
477 msflags |= WS_MAXIMIZEBOX;
478 if (style & wxTHICK_FRAME)
479 msflags |= WS_THICKFRAME;
480 if (style & wxSYSTEM_MENU)
481 msflags |= WS_SYSMENU;
482 if ((style & wxMINIMIZE) || (style & wxICONIZE))
483 msflags |= WS_MINIMIZE;
484 if (style & wxMAXIMIZE)
485 msflags |= WS_MAXIMIZE;
486 if (style & wxCAPTION)
487 msflags |= WS_CAPTION;
488 if (style & wxCLIP_CHILDREN)
489 msflags |= WS_CLIPCHILDREN;
490
491 // Keep this in wxFrame because it saves recoding this function
492 // in wxTinyFrame
493 #if wxUSE_ITSY_BITSY
494 if (style & wxTINY_CAPTION_VERT)
495 msflags |= IBS_VERTCAPTION;
496 if (style & wxTINY_CAPTION_HORIZ)
497 msflags |= IBS_HORZCAPTION;
498 #else
499 if (style & wxTINY_CAPTION_VERT)
500 msflags |= WS_CAPTION;
501 if (style & wxTINY_CAPTION_HORIZ)
502 msflags |= WS_CAPTION;
503 #endif
504 if ((style & wxTHICK_FRAME) == 0)
505 msflags |= WS_BORDER;
506
507 WXDWORD extendedStyle = MakeExtendedStyle(style);
508
509 #if !defined(__WIN16__) && !defined(__SC__)
510 if (style & wxFRAME_TOOL_WINDOW)
511 extendedStyle |= WS_EX_TOOLWINDOW;
512 #endif
513
514 if (style & wxSTAY_ON_TOP)
515 extendedStyle |= WS_EX_TOPMOST;
516
517 m_iconized = FALSE;
518 if ( !wxWindow::MSWCreate(id, parent, wclass, wx_win, title, x, y, width, height,
519 msflags, NULL, extendedStyle) )
520 return FALSE;
521
522 // Seems to be necessary if we use WS_POPUP
523 // style instead of WS_OVERLAPPED
524 if (width > -1 && height > -1)
525 ::PostMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(width, height));
526 */
527 return TRUE;
528 }
529
530 // Default activation behaviour - set the focus for the first child
531 // subwindow found.
532 void wxFrame::OnActivate(wxActivateEvent& event)
533 {
534 for ( wxWindowList::Node *node = GetChildren().GetFirst();
535 node;
536 node = node->GetNext() )
537 {
538 // FIXME all this is totally bogus - we need to do the same as wxPanel,
539 // but how to do it without duplicating the code?
540
541 // restore focus
542 wxWindow *child = node->GetData();
543
544 if ( !child->IsTopLevel()
545 #if wxUSE_TOOLBAR
546 && !wxDynamicCast(child, wxToolBar)
547 #endif // wxUSE_TOOLBAR
548 #if wxUSE_STATUSBAR
549 && !wxDynamicCast(child, wxStatusBar)
550 #endif // wxUSE_STATUSBAR
551 )
552 {
553 child->SetFocus();
554 return;
555 }
556 }
557 }
558
559 // ----------------------------------------------------------------------------
560 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
561 // from the client area, so the client area is what's really available for the
562 // frame contents
563 // ----------------------------------------------------------------------------
564
565 // Checks if there is a toolbar, and returns the first free client position
566 wxPoint wxFrame::GetClientAreaOrigin() const
567 {
568 wxPoint pt(0, 0);
569 if (GetToolBar())
570 {
571 int w, h;
572 GetToolBar()->GetSize(& w, & h);
573
574 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
575 {
576 pt.x += w;
577 }
578 else
579 {
580 pt.y += h;
581 }
582 }
583 return pt;
584 }
585
586 void wxFrame::DoScreenToClient(int *x, int *y) const
587 {
588 wxWindow::DoScreenToClient(x, y);
589
590 // We may be faking the client origin.
591 // So a window that's really at (0, 30) may appear
592 // (to wxWin apps) to be at (0, 0).
593 wxPoint pt(GetClientAreaOrigin());
594 *x -= pt.x;
595 *y -= pt.y;
596 }
597
598 void wxFrame::DoClientToScreen(int *x, int *y) const
599 {
600 // We may be faking the client origin.
601 // So a window that's really at (0, 30) may appear
602 // (to wxWin apps) to be at (0, 0).
603 wxPoint pt1(GetClientAreaOrigin());
604 *x += pt1.x;
605 *y += pt1.y;
606
607 wxWindow::DoClientToScreen(x, y);
608 }
609
610 // ----------------------------------------------------------------------------
611 // tool/status bar stuff
612 // ----------------------------------------------------------------------------
613
614 #if wxUSE_TOOLBAR
615
616 wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
617 {
618 if ( wxFrameBase::CreateToolBar(style, id, name) )
619 {
620 PositionToolBar();
621 }
622
623 return m_frameToolBar;
624 }
625
626 void wxFrame::PositionToolBar()
627 {
628 // TODO:
629 /*
630 RECT rect;
631 ::GetClientRect(GetHwnd(), &rect);
632
633 #if wxUSE_STATUSBAR
634 if ( GetStatusBar() )
635 {
636 int statusX, statusY;
637 GetStatusBar()->GetClientSize(&statusX, &statusY);
638 rect.bottom -= statusY;
639 }
640 #endif // wxUSE_STATUSBAR
641
642 if ( GetToolBar() )
643 {
644 int tw, th;
645 GetToolBar()->GetSize(&tw, &th);
646
647 if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL )
648 {
649 th = rect.bottom;
650 }
651 else
652 {
653 tw = rect.right;
654 }
655
656 // Use the 'real' MSW position here
657 GetToolBar()->SetSize(0, 0, tw, th, wxSIZE_NO_ADJUSTMENTS);
658 }
659 */
660 }
661 #endif // wxUSE_TOOLBAR
662
663 // ----------------------------------------------------------------------------
664 // frame state (iconized/maximized/...)
665 // ----------------------------------------------------------------------------
666
667 // propagate our state change to all child frames: this allows us to emulate X
668 // Windows behaviour where child frames float independently of the parent one
669 // on the desktop, but are iconized/restored with it
670 void wxFrame::IconizeChildFrames(bool bIconize)
671 {
672 for ( wxWindowList::Node *node = GetChildren().GetFirst();
673 node;
674 node = node->GetNext() )
675 {
676 wxWindow *win = node->GetData();
677
678 if ( win->IsKindOf(CLASSINFO(wxFrame)) )
679 {
680 ((wxFrame *)win)->Iconize(bIconize);
681 }
682 }
683 }
684
685 // ===========================================================================
686 // message processing
687 // ===========================================================================
688
689 // ---------------------------------------------------------------------------
690 // preprocessing
691 // ---------------------------------------------------------------------------
692
693 bool wxFrame::OS2TranslateMessage(WXMSG* pMsg)
694 {
695 // TODO:
696 /*
697 if ( wxWindow::OS2TranslateMessage(pMsg) )
698 return TRUE;
699 */
700 // try the menu bar accels
701 wxMenuBar *menuBar = GetMenuBar();
702 if ( !menuBar )
703 return FALSE;
704
705 const wxAcceleratorTable& acceleratorTable = menuBar->GetAccelTable();
706 return acceleratorTable.Translate(this, pMsg);
707 }
708
709 // ---------------------------------------------------------------------------
710 // our private (non virtual) message handlers
711 // ---------------------------------------------------------------------------
712
713 bool wxFrame::HandlePaint()
714 {
715 // TODO:
716 /*
717 RECT rect;
718 if ( GetUpdateRect(GetHwnd(), &rect, FALSE) )
719 {
720 if ( m_iconized )
721 {
722 HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon)
723 : (HICON)m_defaultIcon;
724
725 // Hold a pointer to the dc so long as the OnPaint() message
726 // is being processed
727 PAINTSTRUCT ps;
728 HDC hdc = ::BeginPaint(GetHwnd(), &ps);
729
730 // Erase background before painting or we get white background
731 MSWDefWindowProc(WM_ICONERASEBKGND, (WORD)(LONG)ps.hdc, 0L);
732
733 if ( hIcon )
734 {
735 RECT rect;
736 ::GetClientRect(GetHwnd(), &rect);
737
738 // FIXME: why hardcoded?
739 static const int icon_width = 32;
740 static const int icon_height = 32;
741
742 int icon_x = (int)((rect.right - icon_width)/2);
743 int icon_y = (int)((rect.bottom - icon_height)/2);
744
745 ::DrawIcon(hdc, icon_x, icon_y, hIcon);
746 }
747
748 ::EndPaint(GetHwnd(), &ps);
749
750 return TRUE;
751 }
752 else
753 {
754 return wxWindow::HandlePaint();
755 }
756 }
757 else
758 {
759 // nothing to paint - processed
760 return TRUE;
761 }
762 */
763 return FALSE;
764 }
765
766 bool wxFrame::HandleSize(int x, int y, WXUINT id)
767 {
768 bool processed = FALSE;
769
770 // TODO:
771 /*
772 switch ( id )
773 {
774 case SIZENORMAL:
775 // only do it it if we were iconized before, otherwise resizing the
776 // parent frame has a curious side effect of bringing it under it's
777 // children
778 if ( !m_iconized )
779 break;
780
781 // restore all child frames too
782 IconizeChildFrames(FALSE);
783
784 // fall through
785
786 case SIZEFULLSCREEN:
787 m_iconized = FALSE;
788 break;
789
790 case SIZEICONIC:
791 // iconize all child frames too
792 IconizeChildFrames(TRUE);
793
794 m_iconized = TRUE;
795 break;
796 }
797
798 if ( !m_iconized )
799 {
800 // forward WM_SIZE to status bar control
801 #if wxUSE_NATIVE_STATUSBAR
802 if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95)))
803 {
804 wxSizeEvent event(wxSize(x, y), m_frameStatusBar->GetId());
805 event.SetEventObject( m_frameStatusBar );
806
807 ((wxStatusBar95 *)m_frameStatusBar)->OnSize(event);
808 }
809 #endif // wxUSE_NATIVE_STATUSBAR
810
811 PositionStatusBar();
812 PositionToolBar();
813
814 wxSizeEvent event(wxSize(x, y), m_windowId);
815 event.SetEventObject( this );
816 processed = GetEventHandler()->ProcessEvent(event);
817 }
818 */
819 return processed;
820 }
821
822 bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
823 {
824 // TODO:
825 /*
826 if ( control )
827 {
828 // In case it's e.g. a toolbar.
829 wxWindow *win = wxFindWinFromHandle(control);
830 if ( win )
831 return win->MSWCommand(cmd, id);
832 }
833
834 // handle here commands from menus and accelerators
835 if ( cmd == 0 || cmd == 1 )
836 {
837 if ( wxCurrentPopupMenu )
838 {
839 wxMenu *popupMenu = wxCurrentPopupMenu;
840 wxCurrentPopupMenu = NULL;
841
842 return popupMenu->MSWCommand(cmd, id);
843 }
844
845 if ( ProcessCommand(id) )
846 {
847 return TRUE;
848 }
849 }
850 */
851 return FALSE;
852 }
853
854 bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu)
855 {
856 int item;
857 if ( flags == 0xFFFF && hMenu == 0 )
858 {
859 // menu was removed from screen
860 item = -1;
861 }
862 // TODO:
863 /*
864 else if ( !(flags & MF_POPUP) && !(flags & MF_SEPARATOR) )
865 {
866 item = nItem;
867 }
868 else
869 {
870 // don't give hints for separators (doesn't make sense) nor for the
871 // items opening popup menus (they don't have them anyhow)
872 return FALSE;
873 }
874 */
875 wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item);
876 event.SetEventObject( this );
877
878 return GetEventHandler()->ProcessEvent(event);
879 }
880
881 // ---------------------------------------------------------------------------
882 // the window proc for wxFrame
883 // ---------------------------------------------------------------------------
884
885 MRESULT wxFrame::OS2WindowProc(HWND hwnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
886 {
887 long rc = 0;
888 bool processed = FALSE;
889
890 // TODO:
891 /*
892 switch ( message )
893 {
894 case WM_CLOSE:
895 // if we can't close, tell the system that we processed the
896 // message - otherwise it would close us
897 processed = !Close();
898 break;
899
900 case WM_COMMAND:
901 {
902 WORD id, cmd;
903 WXHWND hwnd;
904 UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam,
905 &id, &hwnd, &cmd);
906
907 processed = HandleCommand(id, cmd, (WXHWND)hwnd);
908 }
909 break;
910
911 case WM_MENUSELECT:
912 {
913 WXWORD item, flags;
914 WXHMENU hmenu;
915 UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu);
916
917 processed = HandleMenuSelect(item, flags, hmenu);
918 }
919 break;
920
921 case WM_PAINT:
922 processed = HandlePaint();
923 break;
924
925 case WM_QUERYDRAGICON:
926 {
927 HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon)
928 : (HICON)(m_defaultIcon);
929 rc = (long)hIcon;
930 processed = rc != 0;
931 }
932 break;
933
934 case WM_SIZE:
935 processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam);
936 break;
937 }
938
939 if ( !processed )
940 rc = wxWindow::MSWWindowProc(message, wParam, lParam);
941
942 return rc;
943 */
944 return (MRESULT)0;
945 }
946