X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/338dd992160bf20205743c092b353d96ef7604fb..9c85202a7af32ca0f497e489a74fe623c3f6461f:/src/motif/gauge.cpp?ds=sidebyside diff --git a/src/motif/gauge.cpp b/src/motif/gauge.cpp index 58bb544b9d..f7c6a70d2e 100644 --- a/src/motif/gauge.cpp +++ b/src/motif/gauge.cpp @@ -9,24 +9,39 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "gauge.h" #endif -#include "wx/gauge.h" +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __VMS +#include +#undef XtDisplay +#undef XtScreen +#undef XtWindow +#undef XtIsRealized +#undef XtParent +#endif + +# include "wx/gauge.h" #ifdef __VMS__ #pragma message disable nosimpint #endif #include +#ifdef __WXMOTIF20__ +#include +#endif // __WXMOTIF20__ #ifdef __VMS__ #pragma message enable nosimpint #endif #include "wx/motif/private.h" -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl) -#endif + +#if !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF() // XmGauge copyright notice: @@ -77,7 +92,7 @@ XmGaugeSetValue(Widget w, int value); int XmGaugeGetValue(Widget w); - +#endif // !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF() bool wxGauge::Create(wxWindow *parent, wxWindowID id, int range, @@ -87,25 +102,14 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - SetName(name); - SetValidator(validator); - m_rangeMax = range; - m_windowStyle = style; - m_backgroundColour = parent->GetBackgroundColour(); - m_foregroundColour = parent->GetForegroundColour(); - - if (parent) parent->AddChild(this); - - if ( id == -1 ) - m_windowId = (int)NewControlId(); - else - m_windowId = id; + if( !CreateControl( parent, id, pos, size, style, validator, name ) ) + return false; Widget parentWidget = (Widget) parent->GetClientWidget(); - Arg args[4]; + Arg args[7]; int count = 4; - if (style & wxHORIZONTAL) + if (style & wxGA_HORIZONTAL) { XtSetArg (args[0], XmNorientation, XmHORIZONTAL); XtSetArg (args[1], XmNprocessingDirection, XmMAX_ON_RIGHT); @@ -117,29 +121,45 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id, } XtSetArg(args[2], XmNminimum, 0); XtSetArg(args[3], XmNmaximum, range); - Widget gaugeWidget = XtCreateManagedWidget("gauge", xmGaugeWidgetClass, parentWidget, args, count); +#if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF() + XtSetArg(args[4], XmNeditable, False); ++count; + XtSetArg(args[5], XmNslidingMode, XmTHERMOMETER); ++count; + // XtSetArg(args[6], XmNsliderVisual, XmFOREGROUND_COLOR ); ++count; + Widget gaugeWidget = + XtCreateManagedWidget("gauge", xmScaleWidgetClass, + parentWidget, args, count); +#else + Widget gaugeWidget = + XtCreateManagedWidget("gauge", xmGaugeWidgetClass, + parentWidget, args, count); +#endif m_mainWidget = (WXWidget) gaugeWidget ; XtManageChild (gaugeWidget); int x = pos.x; int y = pos.y; - int width = size.x; int height = size.y; - if (width == -1) - width = 150; - if (height == -1) - height = 80; + wxSize best = GetBestSize(); + if( size.x != -1 ) best.x = size.x; + if( size.y != -1 ) best.y = size.y; - m_font = parent->GetFont(); ChangeFont(FALSE); - SetCanAddEventHandler(TRUE); - AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height); + AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, + best.x, best.y); ChangeBackgroundColour(); return TRUE; } +wxSize wxGauge::DoGetBestSize() const +{ + if( HasFlag(wxGA_HORIZONTAL) ) + return wxSize( 100, 18 ); + else + return wxSize( 18, 100 ); +} + void wxGauge::SetShadowWidth(int w) { if (w == 0) @@ -147,19 +167,13 @@ void wxGauge::SetShadowWidth(int w) XtVaSetValues((Widget) m_mainWidget, XmNshadowThickness, w, NULL); } -void wxGauge::SetBezelFace(int WXUNUSED(w)) -{ -} - void wxGauge::SetRange(int r) { - m_rangeMax = r; XtVaSetValues((Widget) m_mainWidget, XmNmaximum, r, NULL); } void wxGauge::SetValue(int pos) { - m_gaugePos = pos; XtVaSetValues((Widget) m_mainWidget, XmNvalue, pos, NULL); } @@ -170,17 +184,11 @@ int wxGauge::GetShadowWidth() const return (int)w; } -int wxGauge::GetBezelFace() const -{ - return 0; -} - int wxGauge::GetRange() const { int r; XtVaGetValues((Widget) m_mainWidget, XmNmaximum, &r, NULL); return (int)r; - // return m_rangeMax; } int wxGauge::GetValue() const @@ -188,23 +196,19 @@ int wxGauge::GetValue() const int pos; XtVaGetValues((Widget) m_mainWidget, XmNvalue, &pos, NULL); return pos; - // return m_gaugePos; } -void wxGauge::ChangeFont(bool keepOriginalSize) +void wxGauge::DoMoveWindow(int x, int y, int width, int height) { - wxWindow::ChangeFont(keepOriginalSize); + wxGaugeBase::DoMoveWindow( x, y, width, height ); +#ifdef __WXMOTIF20__ + XtVaSetValues( (Widget)m_mainWidget, + XmNscaleHeight, height, + NULL ); +#endif } -void wxGauge::ChangeBackgroundColour() -{ - wxWindow::ChangeBackgroundColour(); -} - -void wxGauge::ChangeForegroundColour() -{ - wxWindow::ChangeForegroundColour(); -} +#if !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF() //// PRIVATE DECLARATIONS FOR XMGAUGE @@ -607,7 +611,7 @@ WidgetClass xmGaugeWidgetClass = (WidgetClass)&xmGaugeClassRec; void GaugePick(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardinal *WXUNUSED(num_args)) { - /* Commented out for a read-only gauge in wxWindows */ + /* Commented out for a read-only gauge in wxWidgets */ #if 0 XmGaugeWidget gw = (XmGaugeWidget)w; #define THIS gw->gauge @@ -673,7 +677,7 @@ GaugePick(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardi void GaugeDrag(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardinal *WXUNUSED(num_args)) { - /* Commented out for a read-only gauge in wxWindows */ + /* Commented out for a read-only gauge in wxWidgets */ #if 0 XmGaugeWidget gw = (XmGaugeWidget)w; #define THIS gw->gauge @@ -742,7 +746,7 @@ GaugeDrag(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardi void GaugeDrop(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardinal *WXUNUSED(num_args)) { - /* Commented out for a read-only gauge in wxWindows */ + /* Commented out for a read-only gauge in wxWidgets */ #if 0 XmGaugeWidget gw = (XmGaugeWidget)w; #define THIS gw->gauge @@ -777,3 +781,5 @@ XmGaugeGetValue(Widget w) return gw->gauge.value; } + +#endif // !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF()