From 66f8b9ace213e02e184460e0c1a212cacea27edd Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Sun, 30 Mar 2003 19:34:51 +0000 Subject: [PATCH] Moved wxWindow::SetSizeHints implementation to wxTopLevelWindow, where it belongs, verified that it works for wxDialog, too. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19886 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/motif/toplevel.h | 4 ++++ include/wx/motif/window.h | 3 --- src/motif/toplevel.cpp | 19 +++++++++++++++ src/motif/window.cpp | 48 +++++++------------------------------ 4 files changed, 32 insertions(+), 42 deletions(-) diff --git a/include/wx/motif/toplevel.h b/include/wx/motif/toplevel.h index 61c26d82e8..359b51178b 100644 --- a/include/wx/motif/toplevel.h +++ b/include/wx/motif/toplevel.h @@ -56,6 +56,10 @@ public: virtual wxString GetTitle() const { return m_title; } virtual void SetTitle( const wxString& title ) { m_title = title; } + virtual void SetSizeHints( int minW, int minH, + int maxW = -1, int maxH = -1, + int incW = -1, int incH = -1 ); + WXWidget GetShellWidget() const; protected: // common part of all constructors diff --git a/include/wx/motif/window.h b/include/wx/motif/window.h index 27e20b37b8..d0cb75935e 100644 --- a/include/wx/motif/window.h +++ b/include/wx/motif/window.h @@ -92,9 +92,6 @@ public: virtual void ScrollWindow( int dx, int dy, const wxRect* rect = (wxRect *) NULL ); - virtual void SetSizeHints(int minW, int minH, - int maxW = -1, int maxH = -1, - int incW = -1, int incH = -1); #if wxUSE_DRAG_AND_DROP virtual void SetDropTarget( wxDropTarget *dropTarget ); #endif // wxUSE_DRAG_AND_DROP diff --git a/src/motif/toplevel.cpp b/src/motif/toplevel.cpp index 031a3c23dd..9968142e41 100644 --- a/src/motif/toplevel.cpp +++ b/src/motif/toplevel.cpp @@ -317,6 +317,25 @@ bool wxTopLevelWindowMotif::IsMaximized() const return FALSE; } +void wxTopLevelWindowMotif::SetSizeHints( int minW, int minH, + int maxW, int maxH, + int incW, int incH ) +{ + wxTopLevelWindowBase::SetSizeHints( minW, minH, maxW, maxH, incW, incH ); + + int count = 0; + Arg args[6]; + + if( minW > -1 ) { XtSetArg( args[count], XmNminWidth, minW ); ++count; } + if( minH > -1 ) { XtSetArg( args[count], XmNminHeight, minH ); ++count; } + if( maxW > -1 ) { XtSetArg( args[count], XmNmaxWidth, maxW ); ++count; } + if( maxH > -1 ) { XtSetArg( args[count], XmNmaxHeight, maxH ); ++count; } + if( incW > -1 ) { XtSetArg( args[count], XmNwidthInc, incW ); ++count; } + if( incH > -1 ) { XtSetArg( args[count], XmNheightInc, incH ); ++count; } + + XtSetValues( (Widget)GetShellWidget(), args, count ); +} + // --------------------------------------------------------------------------- // Callback definition // --------------------------------------------------------------------------- diff --git a/src/motif/window.cpp b/src/motif/window.cpp index 49f5579731..17b3de81b2 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -1334,7 +1334,7 @@ void wxWindow::DoSetSizeIntr(int x, int y, int width, int height, wxSize size(-1, -1); if ( width <= 0 ) { - if ( sizeFlags & wxSIZE_AUTO_WIDTH && !fromCtor ) + if ( ( sizeFlags & wxSIZE_AUTO_WIDTH ) && !fromCtor ) { size = DoGetBestSize(); width = size.x; @@ -1347,7 +1347,7 @@ void wxWindow::DoSetSizeIntr(int x, int y, int width, int height, if ( height == -1 ) { - if( sizeFlags & wxSIZE_AUTO_HEIGHT && !fromCtor ) + if( ( sizeFlags & wxSIZE_AUTO_HEIGHT ) && !fromCtor ) { if( size.x == -1 ) size = DoGetBestSize(); height = size.y; @@ -1438,36 +1438,6 @@ wxPoint wxWindow::GetClientAreaOrigin() const return wxPoint(0, 0); } -void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int incW, int incH) -{ - m_minWidth = minW; - m_minHeight = minH; - m_maxWidth = maxW; - m_maxHeight = maxH; - - wxFrame *frame = wxDynamicCast(this, wxFrame); - if ( !frame ) - { - // TODO what about dialogs? - return; - } - - Widget widget = (Widget) frame->GetShellWidget(); - - if (minW > -1) - XtVaSetValues(widget, XmNminWidth, minW, NULL); - if (minH > -1) - XtVaSetValues(widget, XmNminHeight, minH, NULL); - if (maxW > -1) - XtVaSetValues(widget, XmNmaxWidth, maxW, NULL); - if (maxH > -1) - XtVaSetValues(widget, XmNmaxHeight, maxH, NULL); - if (incW > -1) - XtVaSetValues(widget, XmNwidthInc, incW, NULL); - if (incH > -1) - XtVaSetValues(widget, XmNheightInc, incH, NULL); -} - void wxWindow::DoMoveWindowIntr(int xx, int yy, int w, int h, int flags) { @@ -1479,7 +1449,6 @@ void wxWindow::DoMoveWindowIntr(int xx, int yy, int w, int h, (Widget) m_scrolledWindow; bool managed = XtIsManaged(borderOrScrolled); - if (managed) XtUnmanageChild (borderOrScrolled); XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL); @@ -2025,7 +1994,8 @@ WXWidget wxWindow::GetLabelWidget() const // All widgets should have this as their resize proc. // OnSize sent to wxWindow via client data. -void wxWidgetResizeProc(Widget w, XConfigureEvent *WXUNUSED(event), String WXUNUSED(args)[], int *WXUNUSED(num_args)) +void wxWidgetResizeProc(Widget w, XConfigureEvent *WXUNUSED(event), + String WXUNUSED(args)[], int *WXUNUSED(num_args)) { wxWindow *win = wxGetWindowFromTable(w); if (!win) @@ -2290,8 +2260,8 @@ static void wxCanvasInputEvent(Widget drawingArea, if (wxTranslateKeyEvent (event, canvas, (Widget) 0, &local_event)) { // Implement wxFrame::OnCharHook by checking ancestor. - wxWindow *parent = canvas->GetParent(); - while (parent && !parent->IsKindOf(CLASSINFO(wxFrame))) + wxWindow *parent = canvas; + while (parent && !parent->IsTopLevel()) parent = parent->GetParent(); if (parent) @@ -2308,9 +2278,9 @@ static void wxCanvasInputEvent(Widget drawingArea, // Only process OnChar if OnKeyDown didn't swallow it if (!canvas->GetEventHandler()->ProcessEvent (event)) { - event.SetEventType(wxEVT_CHAR); - canvas->GetEventHandler()->ProcessEvent (event); - } + event.SetEventType(wxEVT_CHAR); + canvas->GetEventHandler()->ProcessEvent (event); + } } break; } -- 2.45.2