X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4bb6408c2631988fab9925014c6619358bf867de..a5e13868ca700aa39bae26b8fb13c640f466d9f0:/src/motif/frame.cpp?ds=sidebyside diff --git a/src/motif/frame.cpp b/src/motif/frame.cpp index 43727d9930..c294be1df8 100644 --- a/src/motif/frame.cpp +++ b/src/motif/frame.cpp @@ -51,7 +51,7 @@ #include "wx/motif/private.h" void wxCloseFrameCallback(Widget, XtPointer, XmAnyCallbackStruct *cbs); -static void wxFrameFocusProc(Widget workArea, XtPointer clientData, +void wxFrameFocusProc(Widget workArea, XtPointer clientData, XmAnyCallbackStruct *cbs); static void wxFrameMapProc(Widget frameShell, XtPointer clientData, XCrossingEvent * event); @@ -76,7 +76,7 @@ END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) #endif -#if USE_NATIVE_STATUSBAR +#if wxUSE_NATIVE_STATUSBAR bool wxFrame::m_useNativeStatusBar = TRUE; #else bool wxFrame::m_useNativeStatusBar = FALSE; @@ -126,7 +126,9 @@ bool wxFrame::Create(wxWindow *parent, m_visibleStatus = TRUE; m_title = ""; - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); + m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE); + m_foregroundColour = *wxBLACK; + m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); if ( id > -1 ) m_windowId = id; @@ -221,8 +223,10 @@ bool wxFrame::Create(wxWindow *parent, m_mainWidget = m_frameWidget; + ChangeFont(FALSE); + // This patch comes from Torsten Liermann lier@lier1.muc.de - if (XmIsMotifWMRunning( (Widget) wxTheApp->GetTopLevelWidget())) + if (XmIsMotifWMRunning( (Widget) m_frameShell )) { int decor = 0 ; if (style & wxRESIZE_BORDER) @@ -248,7 +252,7 @@ bool wxFrame::Create(wxWindow *parent, else { if (style == 0) - XtVaSetValues((Widget) m_frameShell,XmNoverrideRedirect,TRUE,NULL); + XtVaSetValues((Widget) m_frameShell,XmNoverrideRedirect,TRUE,NULL); } XtRealizeWidget((Widget) m_frameShell); @@ -264,6 +268,8 @@ bool wxFrame::Create(wxWindow *parent, #endif #endif + ChangeBackgroundColour(); + PreResize(); wxSizeEvent sizeEvent(wxSize(width, height), GetId()); @@ -310,14 +316,21 @@ wxFrame::~wxFrame() XtDestroyWidget (statusLineWidget); */ - wxDeleteWindowFromTable((Widget) m_workArea); + if (m_workArea) + { + wxDeleteWindowFromTable((Widget) m_workArea); - XtDestroyWidget ((Widget) m_workArea); - XtDestroyWidget ((Widget) m_frameWidget); + XtDestroyWidget ((Widget) m_workArea); + } - wxDeleteWindowFromTable((Widget) m_frameWidget); + if (m_frameWidget) + { + wxDeleteWindowFromTable((Widget) m_frameWidget); + XtDestroyWidget ((Widget) m_frameWidget); + } - XtDestroyWidget ((Widget) m_frameShell); + if (m_frameShell) + XtDestroyWidget ((Widget) m_frameShell); SetMainWidget((WXWidget) NULL); @@ -329,7 +342,7 @@ wxFrame::~wxFrame() if (wxTheApp->GetExitOnFrameDelete()) { - // TODO signal to the app that we're going to close + // Signal to the app that we're going to close wxTheApp->ExitMainLoop(); } } @@ -342,15 +355,22 @@ void wxFrame::GetClientSize(int *x, int *y) const Dimension xx, yy; XtVaGetValues((Widget) m_workArea, XmNwidth, &xx, XmNheight, &yy, NULL); - /* TODO - if (status_line_exists) + if (m_frameStatusBar) { - Dimension ys; - XtVaGetValues(statusLineWidget, XmNheight, &ys, NULL); - yy -= ys; + int sbw, sbh; + m_frameStatusBar->GetSize(& sbw, & sbh); + yy -= sbh; } - */ - + if (m_frameToolBar) + { + int tbw, tbh; + m_frameToolBar->GetSize(& tbw, & tbh); + if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL) + xx -= tbw; + else + yy -= tbh; + } +/* if (GetMenuBar() != (wxMenuBar*) NULL) { // it seems that if a frame holds a panel, the menu bar size @@ -370,6 +390,7 @@ void wxFrame::GetClientSize(int *x, int *y) const yy -= ys; } } + */ *x = xx; *y = yy; } @@ -386,14 +407,22 @@ void wxFrame::SetClientSize(int width, int height) if (height > -1) { - /* TODO - if (status_line_exists) + if (m_frameStatusBar) { - Dimension ys; - XtVaGetValues(statusLineWidget, XmNheight, &ys, NULL); - height += ys; + int sbw, sbh; + m_frameStatusBar->GetSize(& sbw, & sbh); + height += sbh; + } + if (m_frameToolBar) + { + int tbw, tbh; + m_frameToolBar->GetSize(& tbw, & tbh); + if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL) + width += tbw; + else + height += tbh; } - */ + XtVaSetValues((Widget) m_workArea, XmNheight, height, NULL); } PreResize(); @@ -579,6 +608,9 @@ void wxFrame::SetStatusWidths(int n, const int widths_field[]) void wxFrame::PositionStatusBar() { + if (!m_frameStatusBar) + return; + int w, h; GetClientSize(&w, &h); int sw, sh; @@ -591,11 +623,9 @@ void wxFrame::PositionStatusBar() WXWidget wxFrame::GetMenuBarWidget() const { - /* TODO if (GetMenuBar()) return GetMenuBar()->GetMainWidget(); else - */ return (WXWidget) NULL; } @@ -612,8 +642,6 @@ void wxFrame::SetMenuBar(wxMenuBar *menuBar) m_frameMenuBar = menuBar; - // TODO -#if 0 Widget menuBarW = XmCreateMenuBar ((Widget) m_frameWidget, "MenuBar", NULL, 0); m_frameMenuBar->SetMainWidget( (WXWidget) menuBarW); @@ -621,12 +649,13 @@ void wxFrame::SetMenuBar(wxMenuBar *menuBar) for (i = 0; i < menuBar->GetMenuCount(); i++) { wxMenu *menu = menuBar->GetMenu(i); - menu->SetButtonWidget(menu->CreateMenu (menuBar, menuBarW, menu, menuBar->m_titles[i], TRUE); + wxString title(menuBar->m_titles[i]); + menu->SetButtonWidget(menu->CreateMenu (menuBar, menuBarW, menu, title, TRUE)); /* * COMMENT THIS OUT IF YOU DON'T LIKE A RIGHT-JUSTIFIED HELP MENU */ - wxStripMenuCodes (menuBar->m_titles[i], wxBuffer); + wxStripMenuCodes ((char*) (const char*) title, wxBuffer); if (strcmp (wxBuffer, "Help") == 0) XtVaSetValues ((Widget) menuBarW, XmNmenuHelpWidget, (Widget) menu->GetButtonWidget(), NULL); @@ -635,7 +664,6 @@ void wxFrame::SetMenuBar(wxMenuBar *menuBar) XtRealizeWidget ((Widget) menuBarW); XtManageChild ((Widget) menuBarW); menuBar->SetMenuBarFrame(this); -#endif } void wxFrame::Fit() @@ -689,7 +717,7 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) void wxFrame::OnSize(wxSizeEvent& event) { // if we're using constraints - do use them - #if USE_CONSTRAINTS + #if wxUSE_CONSTRAINTS if ( GetAutoLayout() ) { Layout(); return; @@ -878,26 +906,15 @@ wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& nam wxToolBar* wxFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name) { - return new wxToolBar(this, id, wxDefaultPosition, wxDefaultSize, style, name); + return new wxToolBar(this, id, wxPoint(0, 0), wxSize(100, 24), style, name); } void wxFrame::PositionToolBar() { int cw, ch; - // TODO: we actually need to use the low-level client size, before - // the toolbar/status bar were added. - // So DEFINITELY replace the line below with something appropriate. - GetClientSize(& cw, &ch); - if ( GetStatusBar() ) - { - int statusX, statusY; - GetStatusBar()->GetClientSize(&statusX, &statusY); - ch -= statusY; - } - if (GetToolBar()) { int tw, th; @@ -908,7 +925,7 @@ void wxFrame::PositionToolBar() // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS // means, pretend we don't have toolbar/status bar, so we // have the original client size. - GetToolBar()->SetSize(0, 0, tw, ch, wxSIZE_NO_ADJUSTMENTS); + GetToolBar()->SetSize(0, 0, tw, ch + th, wxSIZE_NO_ADJUSTMENTS); } else { @@ -978,7 +995,7 @@ void wxFrame::SetToolBar(wxToolBar *toolbar) wxToolBar *wxFrame::GetToolBar() const { return m_frameToolBar; } -static void wxFrameFocusProc(Widget workArea, XtPointer clientData, +void wxFrameFocusProc(Widget workArea, XtPointer clientData, XmAnyCallbackStruct *cbs) { wxFrame *frame = (wxFrame *)clientData; @@ -1016,35 +1033,29 @@ static void wxFrameMapProc(Widget frameShell, XtPointer clientData, //// Motif-specific bool wxFrame::PreResize() { - /* TODO - // Set status line, if any - if (status_line_exists) - { - Dimension clientW, clientH; - XtVaGetValues(clientArea, XmNwidth, &clientW, XmNheight, &clientH, NULL); - Dimension xx, yy; - XtVaGetValues(statusLineWidget, XmNwidth, &xx, XmNheight, &yy, NULL); - - XtUnmanageChild(statusLineWidget); - XtVaSetValues(statusLineWidget, XmNx, 0, XmNy, clientH - yy, XmNwidth, clientW, NULL); + PositionToolBar(); + PositionStatusBar(); + return TRUE; +} - if (statusLineForm) - XtVaSetValues(statusLineForm, XmNwidth, clientW, NULL); +WXWidget wxFrame::GetClientWidget() const +{ + return m_clientArea; +} - XtManageChild(statusLineWidget); - } +void wxFrame::ChangeFont(bool keepOriginalSize) +{ + // TODO +} - int width, height; - GetSize(&width, &height); +void wxFrame::ChangeBackgroundColour() +{ + // TODO +} - if (width == lastWidth && height == lastHeight) - return FALSE; - else - { - return TRUE; - } - */ - return TRUE; +void wxFrame::ChangeForegroundColour() +{ + // TODO } void wxCloseFrameCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs) @@ -1057,3 +1068,4 @@ void wxCloseFrameCallback(Widget widget, XtPointer client_data, XmAnyCallbackStr // May delete the frame (with delayed deletion) frame->GetEventHandler()->ProcessEvent(closeEvent); } +