]> git.saurik.com Git - wxWidgets.git/blame - src/os2/frame.cpp
wxProgressDialog now accepts wxGA_SMOOTH style
[wxWidgets.git] / src / os2 / frame.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: frame.cpp
3// Purpose: wxFrame
f0a56ab0 4// Author: David Webster
0e320a79 5// Modified by:
29435d81 6// Created: 10/27/99
0e320a79 7// RCS-ID: $Id$
f0a56ab0 8// Copyright: (c) David Webster
0e320a79
DW
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
21802234
DW
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"
f38374d0
DW
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
0e320a79 36#include "wx/menuitem.h"
21802234 37#include "wx/log.h"
0e320a79 38
f38374d0
DW
39// ----------------------------------------------------------------------------
40// globals
41// ----------------------------------------------------------------------------
42
21802234
DW
43extern wxWindowList wxModelessWindows;
44extern wxList WXDLLEXPORT wxPendingDelete;
45extern wxChar wxFrameClassName[];
46extern wxMenu *wxCurrentPopupMenu;
0e320a79 47
f38374d0
DW
48// ----------------------------------------------------------------------------
49// event tables
50// ----------------------------------------------------------------------------
51
f38374d0
DW
52BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
53 EVT_ACTIVATE(wxFrame::OnActivate)
54 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
0e320a79
DW
55END_EVENT_TABLE()
56
57IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
0e320a79 58
f38374d0
DW
59// ============================================================================
60// implementation
61// ============================================================================
0e320a79 62
f38374d0
DW
63// ----------------------------------------------------------------------------
64// static class members
65// ----------------------------------------------------------------------------
0e320a79 66
f38374d0
DW
67#if wxUSE_NATIVE_STATUSBAR
68 bool wxFrame::m_useNativeStatusBar = TRUE;
69#else
70 bool wxFrame::m_useNativeStatusBar = FALSE;
71#endif
0e320a79 72
f38374d0
DW
73// ----------------------------------------------------------------------------
74// creation/destruction
75// ----------------------------------------------------------------------------
76
77void wxFrame::Init()
0e320a79 78{
f38374d0
DW
79 m_iconized = FALSE;
80
21802234
DW
81#if wxUSE_TOOLTIPS
82 m_hwndToolTip = 0;
83#endif
f38374d0 84}
0e320a79 85
f38374d0
DW
86bool 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{
0e320a79
DW
94 SetName(name);
95 m_windowStyle = style;
96 m_frameMenuBar = NULL;
f38374d0 97 m_frameToolBar = NULL;
0e320a79
DW
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
21802234
DW
109 int x = pos.x;
110 int y = pos.y;
111 int width = size.x;
112 int height = size.y;
0e320a79 113
21802234
DW
114 m_iconized = FALSE;
115
29435d81
DW
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.
21802234
DW
120 if ((m_windowStyle & wxFRAME_FLOAT_ON_PARENT) == 0)
121 parent = NULL;
0e320a79 122
21802234
DW
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;
0e320a79
DW
131}
132
133wxFrame::~wxFrame()
134{
21802234 135 m_isBeingDeleted = TRUE;
0e320a79
DW
136 wxTopLevelWindows.DeleteObject(this);
137
f38374d0
DW
138// TODO:
139/*
140 DeleteAllBars();
29435d81 141
0e320a79
DW
142 if (wxTheApp && (wxTopLevelWindows.Number() == 0))
143 {
144 wxTheApp->SetTopWindow(NULL);
145
146 if (wxTheApp->GetExitOnFrameDelete())
147 {
f38374d0 148 PostQuitMessage(0);
0e320a79
DW
149 }
150 }
151
152 wxModelessWindows.DeleteObject(this);
21802234
DW
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 )
29435d81
DW
160 if (GetParent() && GetParent()->GetHWND())
161 ::BringWindowToTop((HWND) GetParent()->GetHWND());
162*/
0e320a79
DW
163}
164
165// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
21802234 166void wxFrame::DoGetClientSize(int *x, int *y) const
0e320a79 167{
29435d81
DW
168// TODO:
169/*
21802234 170 RECT rect;
29435d81 171 ::GetClientRect(GetHwnd(), &rect);
21802234 172
f38374d0 173#if wxUSE_STATUSBAR
21802234
DW
174 if ( GetStatusBar() )
175 {
176 int statusX, statusY;
177 GetStatusBar()->GetClientSize(&statusX, &statusY);
29435d81 178 rect.bottom -= statusY;
21802234 179 }
f38374d0 180#endif // wxUSE_STATUSBAR
21802234
DW
181
182 wxPoint pt(GetClientAreaOrigin());
21802234
DW
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*/
0e320a79
DW
191}
192
193// Set the client size (i.e. leave the calculation of borders etc.
194// to wxWindows)
21802234 195void wxFrame::DoSetClientSize(int width, int height)
0e320a79 196{
21802234 197 HWND hWnd = GetHwnd();
0e320a79 198
29435d81
DW
199// TODO:
200/*
21802234 201 RECT rect;
29435d81 202 ::GetClientRect(hWnd, &rect);
21802234
DW
203
204 RECT rect2;
29435d81 205 GetWindowRect(hWnd, &rect2);
21802234
DW
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
21802234
DW
210 int actual_width = rect2.right - rect2.left - rect.right + width;
211 int actual_height = rect2.bottom - rect2.top - rect.bottom + height;
29435d81 212
f38374d0 213#if wxUSE_STATUSBAR
21802234
DW
214 if ( GetStatusBar() )
215 {
216 int statusX, statusY;
217 GetStatusBar()->GetClientSize(&statusX, &statusY);
29435d81 218 actual_height += statusY;
21802234 219 }
f38374d0 220#endif // wxUSE_STATUSBAR
29435d81 221
21802234
DW
222 wxPoint pt(GetClientAreaOrigin());
223 actual_width += pt.y;
224 actual_height += pt.x;
225
226 POINT point;
21802234
DW
227 point.x = rect2.left;
228 point.y = rect2.top;
229
230 MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)TRUE);
29435d81 231
21802234
DW
232 wxSizeEvent event(wxSize(width, height), m_windowId);
233 event.SetEventObject( this );
234 GetEventHandler()->ProcessEvent(event);
29435d81 235*/
0e320a79
DW
236}
237
21802234 238void wxFrame::DoGetSize(int *width, int *height) const
0e320a79 239{
29435d81
DW
240// TODO:
241/*
21802234 242 RECT rect;
29435d81
DW
243 GetWindowRect(GetHwnd(), &rect);
244 *width = rect.right - rect.left;
245 *height = rect.bottom - rect.top;
246*/
0e320a79
DW
247}
248
21802234 249void wxFrame::DoGetPosition(int *x, int *y) const
0e320a79 250{
29435d81
DW
251// TODO:
252/*
21802234 253 RECT rect;
29435d81
DW
254 GetWindowRect(GetHwnd(), &rect);
255 POINT point;
256 point.x = rect.left;
257 point.y = rect.top;
21802234
DW
258
259 *x = point.x;
260 *y = point.y;
29435d81 261*/
0e320a79
DW
262}
263
f38374d0
DW
264// ----------------------------------------------------------------------------
265// variations around ::ShowWindow()
266// ----------------------------------------------------------------------------
267
268void wxFrame::DoShowWindow(int nShowCmd)
0e320a79 269{
29435d81 270// TODO:
21802234 271/*
f38374d0 272 ::ShowWindow(GetHwnd(), nShowCmd);
21802234 273
f38374d0 274 m_iconized = nShowCmd == SW_MINIMIZE;
29435d81 275*/
0e320a79
DW
276}
277
f38374d0 278bool wxFrame::Show(bool show)
0e320a79 279{
29435d81
DW
280// TODO:
281/*
f38374d0 282 DoShowWindow(show ? SW_SHOW : SW_HIDE);
21802234 283
f38374d0
DW
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 }
29435d81 302*/
f38374d0
DW
303 return TRUE;
304}
305
306void wxFrame::Iconize(bool iconize)
307{
308// DoShowWindow(iconize ? SW_MINIMIZE : SW_RESTORE);
0e320a79
DW
309}
310
0e320a79
DW
311void wxFrame::Maximize(bool maximize)
312{
f38374d0
DW
313// DoShowWindow(maximize ? SW_MAXIMIZE : SW_RESTORE);
314}
315
316void wxFrame::Restore()
317{
318// DoShowWindow(SW_RESTORE);
0e320a79
DW
319}
320
321bool wxFrame::IsIconized() const
322{
29435d81
DW
323// TODO:
324/*
325 ((wxFrame *)this)->m_iconized = (::IsIconic(GetHwnd()) != 0);
21802234 326 return m_iconized;
29435d81 327*/
f38374d0 328 return FALSE;
0e320a79
DW
329}
330
21802234
DW
331// Is it maximized?
332bool wxFrame::IsMaximized() const
0e320a79 333{
f38374d0
DW
334// TODO:
335/*
336 return (::IsZoomed(GetHwnd()) != 0);
337*/
338 return FALSE;
0e320a79
DW
339}
340
341void wxFrame::SetIcon(const wxIcon& icon)
342{
f38374d0
DW
343 wxFrameBase::SetIcon(icon);
344
29435d81
DW
345// TODO:
346/*
f38374d0
DW
347 if ( m_icon.Ok() )
348 {
349 SendMessage(GetHwnd(), WM_SETICON,
350 (WPARAM)TRUE, (LPARAM)(HICON) m_icon.GetHICON());
351 }
29435d81 352*/
0e320a79
DW
353}
354
21802234 355#if wxUSE_STATUSBAR
f38374d0
DW
356wxStatusBar *wxFrame::OnCreateStatusBar(int number,
357 long style,
358 wxWindowID id,
359 const wxString& name)
0e320a79
DW
360{
361 wxStatusBar *statusBar = NULL;
0e320a79 362
f38374d0 363 statusBar = wxFrameBase::OnCreateStatusBar(number, style, id, name);
0e320a79 364
f38374d0 365 return statusBar;
0e320a79
DW
366}
367
368void wxFrame::PositionStatusBar()
369{
f38374d0
DW
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*/
0e320a79 385}
21802234 386#endif // wxUSE_STATUSBAR
0e320a79 387
21802234 388void wxFrame::DetachMenuBar()
0e320a79 389{
21802234 390 if (m_frameMenuBar)
0e320a79 391 {
29435d81 392 m_frameMenuBar->Detach();
0e320a79 393 m_frameMenuBar = NULL;
21802234
DW
394 }
395}
396
397void wxFrame::SetMenuBar(wxMenuBar *menu_bar)
398{
399 if (!menu_bar)
400 {
401 DetachMenuBar();
0e320a79
DW
402 return;
403 }
c3d43472 404
29435d81 405 wxCHECK_RET( !menu_bar->GetFrame(), wxT("this menubar is already attached") );
0e320a79 406
21802234
DW
407 if (m_frameMenuBar)
408 delete m_frameMenuBar;
409
29435d81 410 m_hMenu = menu_bar->Create();
21802234
DW
411
412 if ( !m_hMenu )
413 return;
414
415 InternalSetMenuBar();
416
417 m_frameMenuBar = menu_bar;
29435d81 418 menu_bar->Attach(this);
0e320a79
DW
419}
420
21802234 421void wxFrame::InternalSetMenuBar()
0e320a79 422{
21802234 423// TODO:
29435d81
DW
424/*
425 if ( !::SetMenu(GetHwnd(), (HMENU)m_hMenu) )
0e320a79 426 {
21802234 427 wxLogLastError("SetMenu");
0e320a79 428 }
21802234 429*/
0e320a79
DW
430}
431
432// Responds to colour changes, and passes event on to children.
433void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
434{
f38374d0
DW
435// TODO:
436/*
0e320a79
DW
437 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
438 Refresh();
439
440 if ( m_frameStatusBar )
441 {
442 wxSysColourChangedEvent event2;
443 event2.SetEventObject( m_frameStatusBar );
21802234 444 m_frameStatusBar->GetEventHandler()->ProcessEvent(event2);
0e320a79
DW
445 }
446
447 // Propagate the event to the non-top-level children
448 wxWindow::OnSysColourChanged(event);
f38374d0 449*/
0e320a79
DW
450}
451
21802234
DW
452/*
453 * Frame window
454 *
455 */
456
457bool 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.
29435d81 465
21802234
DW
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;
29435d81 518 if ( !wxWindow::MSWCreate(id, parent, wclass, wx_win, title, x, y, width, height,
21802234
DW
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));
29435d81 526*/
f38374d0 527 return TRUE;
0e320a79
DW
528}
529
530// Default activation behaviour - set the focus for the first child
531// subwindow found.
532void wxFrame::OnActivate(wxActivateEvent& event)
533{
21802234
DW
534 for ( wxWindowList::Node *node = GetChildren().GetFirst();
535 node;
536 node = node->GetNext() )
0e320a79 537 {
21802234
DW
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 }
0e320a79 556 }
0e320a79
DW
557}
558
f38374d0
DW
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// ----------------------------------------------------------------------------
0e320a79
DW
564
565// Checks if there is a toolbar, and returns the first free client position
566wxPoint 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
e6ebb514 586void wxFrame::DoScreenToClient(int *x, int *y) const
0e320a79 587{
29435d81 588 wxWindow::DoScreenToClient(x, y);
0e320a79
DW
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
e6ebb514 598void wxFrame::DoClientToScreen(int *x, int *y) const
0e320a79
DW
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
e6ebb514 607 wxWindow::DoClientToScreen(x, y);
0e320a79
DW
608}
609
f38374d0
DW
610// ----------------------------------------------------------------------------
611// tool/status bar stuff
612// ----------------------------------------------------------------------------
613
21802234 614#if wxUSE_TOOLBAR
f38374d0 615
0e320a79
DW
616wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
617{
f38374d0 618 if ( wxFrameBase::CreateToolBar(style, id, name) )
0e320a79 619 {
0e320a79 620 PositionToolBar();
0e320a79 621 }
0e320a79 622
f38374d0 623 return m_frameToolBar;
0e320a79
DW
624}
625
626void wxFrame::PositionToolBar()
627{
29435d81
DW
628// TODO:
629/*
21802234 630 RECT rect;
29435d81 631 ::GetClientRect(GetHwnd(), &rect);
0e320a79 632
f38374d0 633#if wxUSE_STATUSBAR
0e320a79
DW
634 if ( GetStatusBar() )
635 {
f38374d0
DW
636 int statusX, statusY;
637 GetStatusBar()->GetClientSize(&statusX, &statusY);
638 rect.bottom -= statusY;
0e320a79 639 }
f38374d0 640#endif // wxUSE_STATUSBAR
0e320a79 641
f38374d0 642 if ( GetToolBar() )
0e320a79
DW
643 {
644 int tw, th;
f38374d0 645 GetToolBar()->GetSize(&tw, &th);
0e320a79 646
f38374d0 647 if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL )
0e320a79 648 {
f38374d0 649 th = rect.bottom;
0e320a79
DW
650 }
651 else
652 {
f38374d0 653 tw = rect.right;
21802234 654 }
f38374d0
DW
655
656 // Use the 'real' MSW position here
657 GetToolBar()->SetSize(0, 0, tw, th, wxSIZE_NO_ADJUSTMENTS);
21802234 658 }
29435d81 659*/
21802234
DW
660}
661#endif // wxUSE_TOOLBAR
662
f38374d0
DW
663// ----------------------------------------------------------------------------
664// frame state (iconized/maximized/...)
665// ----------------------------------------------------------------------------
666
21802234
DW
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
670void 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);
0e320a79
DW
681 }
682 }
683}
684
21802234
DW
685// ===========================================================================
686// message processing
687// ===========================================================================
688
689// ---------------------------------------------------------------------------
690// preprocessing
691// ---------------------------------------------------------------------------
692
693bool wxFrame::OS2TranslateMessage(WXMSG* pMsg)
694{
f38374d0
DW
695// TODO:
696/*
29435d81
DW
697 if ( wxWindow::OS2TranslateMessage(pMsg) )
698 return TRUE;
f38374d0 699*/
21802234
DW
700 // try the menu bar accels
701 wxMenuBar *menuBar = GetMenuBar();
702 if ( !menuBar )
703 return FALSE;
704
29435d81
DW
705 const wxAcceleratorTable& acceleratorTable = menuBar->GetAccelTable();
706 return acceleratorTable.Translate(this, pMsg);
21802234
DW
707}
708
709// ---------------------------------------------------------------------------
710// our private (non virtual) message handlers
711// ---------------------------------------------------------------------------
712
713bool wxFrame::HandlePaint()
714{
21802234 715// TODO:
29435d81
DW
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
21802234
DW
725 // Hold a pointer to the dc so long as the OnPaint() message
726 // is being processed
29435d81
DW
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);
21802234
DW
737
738 // FIXME: why hardcoded?
29435d81
DW
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;
21802234
DW
764}
765
766bool wxFrame::HandleSize(int x, int y, WXUINT id)
767{
768 bool processed = FALSE;
769
29435d81
DW
770// TODO:
771/*
772 switch ( id )
21802234
DW
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 }
f38374d0 797
21802234
DW
798 if ( !m_iconized )
799 {
29435d81 800 // forward WM_SIZE to status bar control
f38374d0
DW
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
21802234
DW
811 PositionStatusBar();
812 PositionToolBar();
813
814 wxSizeEvent event(wxSize(x, y), m_windowId);
815 event.SetEventObject( this );
816 processed = GetEventHandler()->ProcessEvent(event);
817 }
f38374d0 818*/
21802234
DW
819 return processed;
820}
821
822bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
823{
f38374d0
DW
824// TODO:
825/*
21802234
DW
826 if ( control )
827 {
828 // In case it's e.g. a toolbar.
829 wxWindow *win = wxFindWinFromHandle(control);
830 if ( win )
f38374d0 831 return win->MSWCommand(cmd, id);
21802234
DW
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
f38374d0 842 return popupMenu->MSWCommand(cmd, id);
21802234
DW
843 }
844
845 if ( ProcessCommand(id) )
846 {
847 return TRUE;
848 }
849 }
f38374d0 850*/
21802234
DW
851 return FALSE;
852}
853
854bool 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 }
29435d81 862// TODO:
21802234
DW
863/*
864 else if ( !(flags & MF_POPUP) && !(flags & MF_SEPARATOR) )
865 {
866 item = nItem;
867 }
21802234
DW
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 }
f38374d0 874*/
21802234
DW
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
885MRESULT wxFrame::OS2WindowProc(HWND hwnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
886{
f38374d0 887 long rc = 0;
21802234
DW
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 }
f38374d0 938
21802234 939 if ( !processed )
f38374d0 940 rc = wxWindow::MSWWindowProc(message, wParam, lParam);
21802234
DW
941
942 return rc;
f38374d0
DW
943*/
944 return (MRESULT)0;
21802234
DW
945}
946