X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b54238992fada5b370ff7ac7f0f62913622c5c5f..2356708db31b737c6eae53c2316b642aa5a2e68d:/src/msw/frame.cpp diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 2c459e4c3a..3549546754 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -43,7 +43,7 @@ extern wxWindowList wxModelessWindows; extern wxList WXDLLEXPORT wxPendingDelete; -extern char wxFrameClassName[]; +extern wxChar wxFrameClassName[]; extern wxMenu *wxCurrentPopupMenu; #if !USE_SHARED_LIBRARY @@ -86,9 +86,6 @@ bool wxFrame::Create(wxWindow *parent, m_hwndToolTip = 0; #endif - if (!parent) - wxTopLevelWindows.Append(this); - SetName(name); m_windowStyle = style; m_frameMenuBar = NULL; @@ -119,6 +116,9 @@ bool wxFrame::Create(wxWindow *parent, if ((m_windowStyle & wxFRAME_FLOAT_ON_PARENT) == 0) parent = NULL; + if (!parent) + wxTopLevelWindows.Append(this); + MSWCreate(m_windowId, parent, wxFrameClassName, this, title, x, y, width, height, style); @@ -175,8 +175,10 @@ void wxFrame::DoGetClientSize(int *x, int *y) const rect.bottom -= pt.y; rect.right -= pt.x; - *x = rect.right; - *y = rect.bottom; + if ( x ) + *x = rect.right; + if ( y ) + *y = rect.bottom; } // Set the client size (i.e. leave the calculation of borders etc. @@ -241,28 +243,11 @@ void wxFrame::DoGetPosition(int *x, int *y) const void wxFrame::DoSetSize(int x, int y, int width, int height, int sizeFlags) { - int currentX, currentY; - int x1 = x; - int y1 = y; - int w1 = width; - int h1 = height; - - GetPosition(¤tX, ¤tY); - if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) - x1 = currentX; - if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) - y1 = currentY; + wxWindow::DoSetSize(x, y, width, height, sizeFlags); - int ww,hh ; - GetSize(&ww,&hh) ; - if (width == -1) w1 = ww ; - if (height==-1) h1 = hh ; - - MoveWindow(GetHwnd(), x1, y1, w1, h1, (BOOL)TRUE); - - wxSizeEvent event(wxSize(width, height), m_windowId); - event.SetEventObject( this ); - GetEventHandler()->ProcessEvent(event); + wxSizeEvent event(wxSize(width, height), m_windowId); + event.SetEventObject( this ); + GetEventHandler()->ProcessEvent(event); } bool wxFrame::Show(bool show) @@ -346,6 +331,7 @@ void wxFrame::SetIcon(const wxIcon& icon) #endif } +#if wxUSE_STATUSBAR wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id, const wxString& name) { @@ -383,7 +369,7 @@ wxStatusBar* wxFrame::CreateStatusBar(int number, long style, wxWindowID id, { // VZ: calling CreateStatusBar twice is an error - why anyone would do it? wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, - "recreating status bar in wxFrame" ); + _T("recreating status bar in wxFrame") ); m_frameStatusBar = OnCreateStatusBar(number, style, id, name); @@ -398,14 +384,14 @@ wxStatusBar* wxFrame::CreateStatusBar(int number, long style, wxWindowID id, void wxFrame::SetStatusText(const wxString& text, int number) { - wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set text for" ); + wxCHECK_RET( m_frameStatusBar != NULL, _T("no statusbar to set text for") ); m_frameStatusBar->SetStatusText(text, number); } void wxFrame::SetStatusWidths(int n, const int widths_field[]) { - wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set widths for" ); + wxCHECK_RET( m_frameStatusBar != NULL, _T("no statusbar to set widths for") ); m_frameStatusBar->SetStatusWidths(n, widths_field); PositionStatusBar(); @@ -430,6 +416,7 @@ void wxFrame::PositionStatusBar() m_frameStatusBar->SetSize(0, h, w, sh); } } +#endif // wxUSE_STATUSBAR void wxFrame::SetMenuBar(wxMenuBar *menu_bar) { @@ -439,7 +426,7 @@ void wxFrame::SetMenuBar(wxMenuBar *menu_bar) return; } - wxCHECK_RET( !menu_bar->GetFrame(), "this menubar is already attached" ); + wxCHECK_RET( !menu_bar->GetFrame(), _T("this menubar is already attached") ); if (m_frameMenuBar) delete m_frameMenuBar; @@ -485,7 +472,7 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) * */ -bool wxFrame::MSWCreate(int id, wxWindow *parent, const char *wclass, wxWindow *wx_win, const char *title, +bool wxFrame::MSWCreate(int id, wxWindow *parent, const wxChar *wclass, wxWindow *wx_win, const wxChar *title, int x, int y, int width, int height, long style) { @@ -571,13 +558,19 @@ void wxFrame::OnSize(wxSizeEvent& event) // do we have _exactly_ one child? wxWindow *child = NULL; - for ( wxNode *node = GetChildren().First(); node; node = node->Next() ) + for ( wxWindowList::Node *node = GetChildren().GetFirst(); + node; + node = node->GetNext() ) { - wxWindow *win = (wxWindow *)node->Data(); - if ( !win->IsKindOf(CLASSINFO(wxFrame)) && - !win->IsKindOf(CLASSINFO(wxDialog)) && - (win != GetStatusBar()) && - (win != GetToolBar()) ) + wxWindow *win = node->GetData(); + if ( !win->IsTopLevel() +#if wxUSE_STATUSBAR + && (win != GetStatusBar()) +#endif // wxUSE_STATUSBAR +#if wxUSE_TOOLBAR + && (win != GetToolBar()) +#endif // wxUSE_TOOLBAR + ) { if ( child ) return; // it's our second subwindow - nothing to do @@ -601,17 +594,29 @@ void wxFrame::OnSize(wxSizeEvent& event) // subwindow found. void wxFrame::OnActivate(wxActivateEvent& event) { - for(wxNode *node = GetChildren().First(); node; node = node->Next()) - { - // Find a child that's a subwindow, but not a dialog box. - wxWindow *child = (wxWindow *)node->Data(); - if (!child->IsKindOf(CLASSINFO(wxFrame)) && - !child->IsKindOf(CLASSINFO(wxDialog))) + for ( wxWindowList::Node *node = GetChildren().GetFirst(); + node; + node = node->GetNext() ) { - child->SetFocus(); - return; + // FIXME all this is totally bogus - we need to do the same as wxPanel, + // but how to do it without duplicating the code? + + // restore focus + wxWindow *child = node->GetData(); + + if ( !child->IsTopLevel() +#if wxUSE_TOOLBAR + && !wxDynamicCast(child, wxToolBar) +#endif // wxUSE_TOOLBAR +#if wxUSE_STATUSBAR + && !wxDynamicCast(child, wxStatusBar) +#endif // wxUSE_STATUSBAR + ) + { + child->SetFocus(); + return; + } } - } } // The default implementation for the close window event. @@ -633,18 +638,21 @@ void wxFrame::OnMenuHighlight(wxMenuEvent& event) { if (GetStatusBar()) { + wxString help; int menuId = event.GetMenuId(); if ( menuId != -1 ) { wxMenuBar *menuBar = GetMenuBar(); if (menuBar && menuBar->FindItem(menuId)) { - // set status text even if the string is empty - this will at - // least remove the string from the item which was previously - // selected - SetStatusText(menuBar->GetHelpString(menuId)); + help = menuBar->GetHelpString(menuId); } } + + // set status text even if the string is empty - this will at + // least remove the string from the item which was previously + // selected + SetStatusText(help); } } @@ -720,10 +728,11 @@ void wxFrame::ClientToScreen(int *x, int *y) const wxWindow::ClientToScreen(x, y); } +#if wxUSE_TOOLBAR wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) { wxCHECK_MSG( m_frameToolBar == NULL, FALSE, - "recreating toolbar in wxFrame" ); + _T("recreating toolbar in wxFrame") ); wxToolBar* toolBar = OnCreateToolBar(style, id, name); if (toolBar) @@ -772,6 +781,7 @@ void wxFrame::PositionToolBar() } } } +#endif // wxUSE_TOOLBAR // propagate our state change to all child frames: this allows us to emulate X // Windows behaviour where child frames float independently of the parent one @@ -824,10 +834,7 @@ bool wxFrame::MSWTranslateMessage(WXMSG* pMsg) return FALSE; const wxAcceleratorTable& acceleratorTable = menuBar->GetAccelTable(); - return acceleratorTable.Ok() && - ::TranslateAccelerator(GetHwnd(), - GetTableHaccel(acceleratorTable), - (MSG *)pMsg); + return acceleratorTable.Translate(this, pMsg); } // --------------------------------------------------------------------------- @@ -841,7 +848,7 @@ bool wxFrame::HandlePaint() { if ( m_iconized ) { - HICON hIcon = m_icon.Ok() ? GetIconHicon(m_icon) + HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon) : (HICON)m_defaultIcon; // Hold a pointer to the dc so long as the OnPaint() message @@ -873,10 +880,7 @@ bool wxFrame::HandlePaint() } else { - wxPaintEvent event(m_windowId); - event.m_eventObject = this; - - return GetEventHandler()->ProcessEvent(event); + return wxWindow::HandlePaint(); } } else @@ -970,20 +974,22 @@ bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) return FALSE; } -bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD nFlags, WXHMENU hMenu) +bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu) { int item; - if ( nFlags == 0xFFFF && hMenu == 0 ) + if ( flags == 0xFFFF && hMenu == 0 ) { - // FIXME: what does this do? does it ever happen? + // menu was removed from screen item = -1; } - else if ((nFlags != MF_SEPARATOR) && (nItem != 0) && (nItem != 65535)) + else if ( !(flags & MF_POPUP) && !(flags & MF_SEPARATOR) ) { item = nItem; } else { + // don't give hints for separators (doesn't make sense) nor for the + // items opening popup menus (they don't have them anyhow) return FALSE; } @@ -1037,7 +1043,7 @@ long wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) case WM_QUERYDRAGICON: { - HICON hIcon = m_icon.Ok() ? GetIconHicon(m_icon) + HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon) : (HICON)(m_defaultIcon); rc = (long)hIcon; processed = rc != 0;