X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/319fefa9109ef95cab9f6dcbd46e3f3edbcff8c9..678cd6de66095373ebaed01d8d013f256cac326b:/src/msw/frame.cpp diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 4cba2dd81f..aded67d34f 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -154,6 +154,9 @@ wxFrame::~wxFrame() // For some reason, wxWindows can activate another task altogether // when a frame is destroyed after a modal dialog has been invoked. // Try to bring the parent to the top. + // MT:Only do this if this frame is currently the active window, else weird + // things start to happen + if ( wxGetActiveWindow() == this ) if (GetParent() && GetParent()->GetHWND()) ::BringWindowToTop((HWND) GetParent()->GetHWND()); } @@ -175,8 +178,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. @@ -239,32 +244,6 @@ void wxFrame::DoGetPosition(int *x, int *y) const *y = point.y; } -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; - - 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); -} - bool wxFrame::Show(bool show) { int cshow; @@ -384,7 +363,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, - _T("recreating status bar in wxFrame") ); + wxT("recreating status bar in wxFrame") ); m_frameStatusBar = OnCreateStatusBar(number, style, id, name); @@ -399,14 +378,14 @@ wxStatusBar* wxFrame::CreateStatusBar(int number, long style, wxWindowID id, void wxFrame::SetStatusText(const wxString& text, int number) { - wxCHECK_RET( m_frameStatusBar != NULL, _T("no statusbar to set text for") ); + wxCHECK_RET( m_frameStatusBar != NULL, wxT("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, _T("no statusbar to set widths for") ); + wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set widths for") ); m_frameStatusBar->SetStatusWidths(n, widths_field); PositionStatusBar(); @@ -433,15 +412,24 @@ void wxFrame::PositionStatusBar() } #endif // wxUSE_STATUSBAR +void wxFrame::DetachMenuBar() +{ + if (m_frameMenuBar) + { + m_frameMenuBar->Detach(); + m_frameMenuBar = NULL; + } +} + void wxFrame::SetMenuBar(wxMenuBar *menu_bar) { if (!menu_bar) { - m_frameMenuBar = NULL; + DetachMenuBar(); return; } - wxCHECK_RET( !menu_bar->GetFrame(), _T("this menubar is already attached") ); + wxCHECK_RET( !menu_bar->GetFrame(), wxT("this menubar is already attached") ); if (m_frameMenuBar) delete m_frameMenuBar; @@ -653,18 +641,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); } } @@ -680,10 +671,8 @@ bool wxFrame::ProcessCommand(int id) return FALSE; wxMenuItem *item = bar->FindItemForId(id); - if ( !item ) - return FALSE; - if ( item->IsCheckable() ) + if ( item && item->IsCheckable() ) { bar->Check(id, !bar->IsChecked(id)) ; } @@ -716,9 +705,9 @@ wxPoint wxFrame::GetClientAreaOrigin() const return pt; } -void wxFrame::ScreenToClient(int *x, int *y) const +void wxFrame::DoScreenToClient(int *x, int *y) const { - wxWindow::ScreenToClient(x, y); + wxWindow::DoScreenToClient(x, y); // We may be faking the client origin. // So a window that's really at (0, 30) may appear @@ -728,7 +717,7 @@ void wxFrame::ScreenToClient(int *x, int *y) const *y -= pt.y; } -void wxFrame::ClientToScreen(int *x, int *y) const +void wxFrame::DoClientToScreen(int *x, int *y) const { // We may be faking the client origin. // So a window that's really at (0, 30) may appear @@ -737,14 +726,14 @@ void wxFrame::ClientToScreen(int *x, int *y) const *x += pt1.x; *y += pt1.y; - wxWindow::ClientToScreen(x, y); + wxWindow::DoClientToScreen(x, y); } #if wxUSE_TOOLBAR wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) { wxCHECK_MSG( m_frameToolBar == NULL, FALSE, - _T("recreating toolbar in wxFrame") ); + wxT("recreating toolbar in wxFrame") ); wxToolBar* toolBar = OnCreateToolBar(style, id, name); if (toolBar) @@ -846,10 +835,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); } // --------------------------------------------------------------------------- @@ -863,7 +849,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 @@ -895,10 +881,7 @@ bool wxFrame::HandlePaint() } else { - wxPaintEvent event(m_windowId); - event.m_eventObject = this; - - return GetEventHandler()->ProcessEvent(event); + return wxWindow::HandlePaint(); } } else @@ -992,20 +975,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; } @@ -1059,7 +1044,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; @@ -1076,3 +1061,4 @@ long wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) return rc; } +