Do not derive wxCursor from wxBitmap, plus misc cleanup.

Derive wxGauge from wxGaugeBase, use XmScale for the
implementation if the Motif version supports the
XmTHERMOMETER style.
  Derive wxSlider from wxSliderBase; generate
wxEVT_SCROLL_THUMBRELEASE in addition to wxEVT_SCROLL_THUMBTRACK;
misc cleanup.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19705 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon 2003-03-22 15:46:22 +00:00
parent 13de23f6d8
commit 93e73c740e
6 changed files with 187 additions and 450 deletions

View File

@ -16,38 +16,13 @@
#pragma interface "cursor.h"
#endif
#include "wx/bitmap.h"
#include "wx/list.h"
#include "wx/object.h"
#include "wx/gdicmn.h"
/* Cursor for one display, so we can choose the correct one for
* the current display.
*/
class wxXCursor : public wxObject
{
DECLARE_DYNAMIC_CLASS(wxXCursor)
public:
WXDisplay* m_display;
WXCursor m_cursor;
};
class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData
{
friend class WXDLLEXPORT wxBitmap;
friend class WXDLLEXPORT wxCursor;
public:
wxCursorRefData();
~wxCursorRefData();
wxList m_cursors; // wxXCursor objects, one per display
wxStockCursor m_cursorId; // wxWindows standard cursor id
};
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData)
class WXDLLEXPORT wxImage;
// Cursor
class WXDLLEXPORT wxCursor: public wxBitmap
class WXDLLEXPORT wxCursor: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxCursor)
@ -70,15 +45,19 @@ public:
wxCursor(wxStockCursor id);
~wxCursor();
virtual bool Ok() const { return ((m_refData != NULL) && M_CURSORDATA->m_ok); }
wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; }
bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; }
bool operator != (const wxCursor& cursor) const { return m_refData != cursor.m_refData; }
virtual bool Ok() const;
wxCursor& operator = (const wxCursor& cursor)
{ if (*this == cursor) return (*this); Ref(cursor); return *this; }
bool operator == (const wxCursor& cursor) const
{ return m_refData == cursor.m_refData; }
bool operator != (const wxCursor& cursor) const
{ return m_refData != cursor.m_refData; }
// Motif-specific.
// Create/get a cursor for the current display
WXCursor GetXCursor(WXDisplay* display) ;
private:
// Make a cursor from standard id
WXCursor MakeCursor(WXDisplay* display, wxStockCursor id);
};

View File

@ -16,12 +16,10 @@
#pragma interface "gauge.h"
#endif
#include "wx/control.h"
WXDLLEXPORT_DATA(extern const char*) wxGaugeNameStr;
// Group box
class WXDLLEXPORT wxGauge : public wxControl
class WXDLLEXPORT wxGauge : public wxGaugeBase
{
DECLARE_DYNAMIC_CLASS(wxGauge)
@ -48,25 +46,18 @@ public:
const wxString& name = wxGaugeNameStr);
void SetShadowWidth(int w);
void SetBezelFace(int w);
void SetRange(int r);
void SetValue(int pos);
int GetShadowWidth() const ;
int GetBezelFace() const ;
int GetRange() const ;
int GetValue() const ;
virtual void Command(wxCommandEvent& WXUNUSED(event)) {} ;
// Implementation
virtual void ChangeFont(bool keepOriginalSize = TRUE);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
protected:
int m_rangeMax;
int m_gaugePos;
private:
virtual wxSize DoGetBestSize() const;
virtual void DoMoveWindow(int x, int y, int width, int height);
};
#endif

View File

@ -21,7 +21,7 @@
WXDLLEXPORT_DATA(extern const char*) wxSliderNameStr;
// Slider
class WXDLLEXPORT wxSlider: public wxControl
class WXDLLEXPORT wxSlider: public wxSliderBase
{
DECLARE_DYNAMIC_CLASS(wxSlider)
@ -52,42 +52,26 @@ public:
virtual int GetValue() const ;
virtual void SetValue(int);
void GetSize(int *x, int *y) const ;
void SetRange(int minValue, int maxValue);
inline int GetMin() const { return m_rangeMin; }
inline int GetMax() const { return m_rangeMax; }
// For trackbars only
void SetTickFreq(int n, int pos);
inline int GetTickFreq() const { return m_tickFreq; }
void SetPageSize(int pageSize);
int GetPageSize() const ;
void ClearSel() ;
void ClearTicks() ;
void SetLineSize(int lineSize);
int GetLineSize() const ;
int GetSelEnd() const ;
int GetSelStart() const ;
void SetSelection(int minPos, int maxPos);
void SetThumbLength(int len) ;
int GetThumbLength() const ;
void SetTick(int tickPos) ;
void Command(wxCommandEvent& event);
// Implementation
virtual void ChangeFont(bool keepOriginalSize = TRUE);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
protected:
int m_rangeMin;
int m_rangeMax;
int m_pageSize;
int m_lineSize;
int m_tickFreq;
virtual void DoSetSize(int x, int y,
int width, int height,

View File

@ -14,10 +14,9 @@
#endif
#include "wx/cursor.h"
#include "wx/gdicmn.h"
#include "wx/icon.h"
#include "wx/app.h"
#include "wx/utils.h"
#include "wx/list.h"
#if wxUSE_IMAGE
#include "wx/image.h"
#endif
@ -33,23 +32,47 @@
#include "wx/motif/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
IMPLEMENT_DYNAMIC_CLASS(wxXCursor, wxObject)
// Cursor for one display, so we can choose the correct one for
// the current display.
class wxXCursor
{
public:
WXDisplay* m_display;
WXCursor m_cursor;
};
WX_DECLARE_LIST(wxXCursor, wxXCursorList);
#include "wx/listimpl.cpp"
WX_DEFINE_LIST(wxXCursorList);
class WXDLLEXPORT wxCursorRefData: public wxObjectRefData
{
friend class WXDLLEXPORT wxCursor;
public:
wxCursorRefData();
~wxCursorRefData();
wxXCursorList m_cursors; // wxXCursor objects, one per display
wxStockCursor m_cursorId; // wxWindows standard cursor id
};
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxObject)
wxCursorRefData::wxCursorRefData()
{
m_width = 32; m_height = 32;
m_cursorId = wxCURSOR_NONE;
}
wxCursorRefData::~wxCursorRefData()
{
wxList::Node* node = m_cursors.GetFirst();
wxXCursorList::Node* node = m_cursors.GetFirst();
while (node)
{
wxXCursor* c = (wxXCursor*) node->GetData();
// TODO: how to delete cursor?
// XDestroyCursor((Display*) c->m_display, (Cursor) c->m_cursor); // ??
wxXCursor* c = node->GetData();
XFreeCursor((Display*) c->m_display, (Cursor) c->m_cursor);
delete c;
node = node->GetNext();
}
@ -89,7 +112,6 @@ wxCursor::wxCursor(const wxImage & image)
}
}
unsigned long keyMaskColor;
if (bHasMask)
{
unsigned char
@ -110,60 +132,13 @@ wxCursor::wxCursor(const wxImage & image)
cMask = cMask * 2;
}
}
keyMaskColor = (r << 16) | (g << 8) | b;
}
else // no mask
{
for (i=0; i<imagebitcount; i++)
maskBits[i] = 0xFF;
// init it to avoid compiler warnings
keyMaskColor = 0;
}
/*
// find the most frequent color(s)
wxImageHistogram histogram;
image.ComputeHistogram(histogram);
// colors as rrggbb
unsigned long key;
unsigned long value;
long colMostFreq = 0;
unsigned long nMost = 0;
long colNextMostFreq = 0;
unsigned long nNext = 0;
for ( wxImageHistogram::iterator entry = histogram.begin();
entry != histogram.end();
++entry )
{
value = entry->second.value;
key = entry->first;
if ( !bHasMask || (key != keyMaskColor) )
{
if (value > nMost)
{
nMost = value;
colMostFreq = key;
}
else if (value > nNext)
{
nNext = value;
colNextMostFreq = key;
}
}
}
wxColour fg = wxColour ( (unsigned char)(colMostFreq >> 16),
(unsigned char)(colMostFreq >> 8),
(unsigned char)(colMostFreq) );
wxColour bg = wxColour ( (unsigned char)(colNextMostFreq >> 16),
(unsigned char)(colNextMostFreq >> 8),
(unsigned char)(colNextMostFreq) );
end of color code
*/
int hotSpotX;
int hotSpotY;
@ -230,13 +205,7 @@ end of color code
c->m_cursor = (WXCursor) cursor;
c->m_display = (WXDisplay*) dpy;
M_CURSORDATA->m_cursors.Append(c);
M_CURSORDATA->m_ok = TRUE;
}
else
{
M_CURSORDATA->m_ok = TRUE;
}
}
#endif
@ -291,11 +260,6 @@ wxCursor::wxCursor(const char bits[], int width, int height,
c->m_cursor = (WXCursor) cursor;
c->m_display = (WXDisplay*) dpy;
M_CURSORDATA->m_cursors.Append(c);
M_CURSORDATA->m_ok = TRUE;
}
else
{
M_CURSORDATA->m_ok = TRUE;
}
}
@ -318,10 +282,6 @@ wxCursor::wxCursor(const wxString& name, long flags, int hotSpotX, int hotSpotY)
wxConstCast(name.c_str(), char),
&w, &h, &pixmap, &hotX, &hotY);
M_BITMAPDATA->m_width = w;
M_BITMAPDATA->m_height = h;
M_BITMAPDATA->m_depth = 1;
if ((value == BitmapFileInvalid) ||
(value == BitmapOpenFailed) ||
(value == BitmapNoMemory))
@ -366,7 +326,6 @@ wxCursor::wxCursor(const wxString& name, long flags, int hotSpotX, int hotSpotY)
c->m_cursor = (WXCursor) cursor;
c->m_display = (WXDisplay*) dpy;
M_CURSORDATA->m_cursors.Append(c);
M_CURSORDATA->m_ok = TRUE;
}
}
@ -377,36 +336,32 @@ wxCursor::wxCursor(wxStockCursor id)
{
m_refData = new wxCursorRefData;
M_CURSORDATA->m_cursorId = id;
M_CURSORDATA->m_ok = TRUE;
WXDisplay* display = wxGetDisplay();
if (!display)
return;
WXCursor cursor = GetXCursor(display);
if (cursor)
{
wxXCursor* c = new wxXCursor;
c->m_cursor = cursor;
c->m_display = wxGetDisplay();
M_CURSORDATA->m_cursors.Append(c);
M_CURSORDATA->m_ok = TRUE;
}
}
wxCursor::~wxCursor()
{
}
bool wxCursor::Ok() const
{
return m_refData != NULL;
}
// Motif-specific: create/get a cursor for the current display
WXCursor wxCursor::GetXCursor(WXDisplay* display)
{
if (!M_CURSORDATA)
return (WXCursor) 0;
wxList::Node* node = M_CURSORDATA->m_cursors.GetFirst();
wxXCursorList::Node* node = M_CURSORDATA->m_cursors.GetFirst();
while (node)
{
wxXCursor* c = (wxXCursor*) node->GetData();
wxXCursor* c = node->GetData();
if (c->m_display == display)
return c->m_cursor;
node = node->GetNext();
@ -438,181 +393,79 @@ WXCursor wxCursor::MakeCursor(WXDisplay* display, wxStockCursor id)
{
Display* dpy = (Display*) display;
Cursor cursor = (Cursor) 0;
int x_cur = -1;
switch (id)
{
case wxCURSOR_WAIT:
{
cursor = XCreateFontCursor (dpy, XC_watch);
break;
}
case wxCURSOR_CROSS:
{
cursor = XCreateFontCursor (dpy, XC_crosshair);
break;
}
case wxCURSOR_CHAR:
{
// Nothing
break;
}
case wxCURSOR_HAND:
{
cursor = XCreateFontCursor (dpy, XC_hand1);
break;
}
case wxCURSOR_BULLSEYE:
{
cursor = XCreateFontCursor (dpy, XC_target);
break;
}
case wxCURSOR_PENCIL:
{
cursor = XCreateFontCursor (dpy, XC_pencil);
break;
}
case wxCURSOR_MAGNIFIER:
{
cursor = XCreateFontCursor (dpy, XC_sizing);
break;
}
case wxCURSOR_IBEAM:
{
cursor = XCreateFontCursor (dpy, XC_xterm);
break;
}
case wxCURSOR_NO_ENTRY:
{
cursor = XCreateFontCursor (dpy, XC_pirate);
break;
}
case wxCURSOR_LEFT_BUTTON:
{
cursor = XCreateFontCursor (dpy, XC_leftbutton);
break;
}
case wxCURSOR_RIGHT_BUTTON:
{
cursor = XCreateFontCursor (dpy, XC_rightbutton);
break;
}
case wxCURSOR_MIDDLE_BUTTON:
{
cursor = XCreateFontCursor (dpy, XC_middlebutton);
break;
}
case wxCURSOR_QUESTION_ARROW:
{
cursor = XCreateFontCursor (dpy, XC_question_arrow);
break;
}
case wxCURSOR_SIZING:
{
cursor = XCreateFontCursor (dpy, XC_sizing);
break;
}
case wxCURSOR_WATCH:
{
cursor = XCreateFontCursor (dpy, XC_watch);
break;
}
case wxCURSOR_SPRAYCAN:
{
cursor = XCreateFontCursor (dpy, XC_spraycan);
break;
}
case wxCURSOR_PAINT_BRUSH:
{
cursor = XCreateFontCursor (dpy, XC_spraycan);
break;
}
case wxCURSOR_SIZENWSE:
case wxCURSOR_SIZENESW:
{
// Not available in X
cursor = XCreateFontCursor (dpy, XC_crosshair);
break;
}
case wxCURSOR_SIZEWE:
{
cursor = XCreateFontCursor (dpy, XC_sb_h_double_arrow);
break;
}
case wxCURSOR_SIZENS:
{
cursor = XCreateFontCursor (dpy, XC_sb_v_double_arrow);
break;
}
case wxCURSOR_POINT_LEFT:
{
cursor = XCreateFontCursor (dpy, XC_sb_left_arrow);
break;
}
case wxCURSOR_POINT_RIGHT:
{
cursor = XCreateFontCursor (dpy, XC_sb_right_arrow);
break;
}
case wxCURSOR_WAIT: x_cur = XC_watch; break;
case wxCURSOR_CROSS: x_cur = XC_crosshair; break;
case wxCURSOR_CHAR: return (WXCursor)cursor; break;
case wxCURSOR_HAND: x_cur = XC_hand1; break;
case wxCURSOR_BULLSEYE: x_cur = XC_target; break;
case wxCURSOR_PENCIL: x_cur = XC_pencil; break;
case wxCURSOR_MAGNIFIER: x_cur = XC_sizing; break;
case wxCURSOR_IBEAM: x_cur = XC_xterm; break;
case wxCURSOR_NO_ENTRY: x_cur = XC_pirate; break;
case wxCURSOR_LEFT_BUTTON: x_cur = XC_leftbutton; break;
case wxCURSOR_RIGHT_BUTTON: x_cur = XC_rightbutton; break;
case wxCURSOR_MIDDLE_BUTTON: x_cur = XC_middlebutton; break;
case wxCURSOR_QUESTION_ARROW: x_cur = XC_question_arrow; break;
case wxCURSOR_SIZING: x_cur = XC_sizing; break;
case wxCURSOR_WATCH: x_cur = XC_watch; break;
case wxCURSOR_SPRAYCAN: x_cur = XC_spraycan; break;
case wxCURSOR_PAINT_BRUSH: x_cur = XC_spraycan; break;
case wxCURSOR_SIZENWSE:
case wxCURSOR_SIZENESW: x_cur = XC_crosshair; break;
case wxCURSOR_SIZEWE: x_cur = XC_sb_h_double_arrow; break;
case wxCURSOR_SIZENS: x_cur = XC_sb_v_double_arrow; break;
case wxCURSOR_POINT_LEFT: x_cur = XC_sb_left_arrow; break;
case wxCURSOR_POINT_RIGHT: x_cur = XC_sb_right_arrow; break;
// (JD Huggins) added more stock cursors for X
// X-only cursors BEGIN
case wxCURSOR_CROSS_REVERSE:
{
cursor = XCreateFontCursor(dpy, XC_cross_reverse);
break;
}
case wxCURSOR_DOUBLE_ARROW:
{
cursor = XCreateFontCursor(dpy, XC_double_arrow);
break;
}
case wxCURSOR_BASED_ARROW_UP:
{
cursor = XCreateFontCursor(dpy, XC_based_arrow_up);
break;
}
case wxCURSOR_BASED_ARROW_DOWN:
{
cursor = XCreateFontCursor(dpy, XC_based_arrow_down);
break;
}
default:
case wxCURSOR_ARROW:
{
cursor = XCreateFontCursor (dpy, XC_top_left_arrow);
break;
}
case wxCURSOR_BLANK:
{
GC gc;
XGCValues gcv;
Pixmap empty_pixmap;
XColor blank_color;
case wxCURSOR_CROSS_REVERSE: x_cur = XC_cross_reverse; break;
case wxCURSOR_DOUBLE_ARROW: x_cur = XC_double_arrow; break;
case wxCURSOR_BASED_ARROW_UP: x_cur = XC_based_arrow_up; break;
case wxCURSOR_BASED_ARROW_DOWN: x_cur = XC_based_arrow_down; break;
case wxCURSOR_BLANK:
{
GC gc;
XGCValues gcv;
Pixmap empty_pixmap;
XColor blank_color;
empty_pixmap = XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)),
16, 16, 1);
gcv.function = GXxor;
gc = XCreateGC (dpy,
empty_pixmap,
GCFunction,
&gcv);
XCopyArea (dpy,
empty_pixmap =
XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)),
16, 16, 1);
gcv.function = GXxor;
gc = XCreateGC (dpy,
empty_pixmap,
GCFunction,
&gcv);
XCopyArea (dpy,
empty_pixmap,
empty_pixmap,
gc,
0, 0,
16, 16,
0, 0);
XFreeGC (dpy, gc);
cursor = XCreatePixmapCursor (dpy,
empty_pixmap,
empty_pixmap,
&blank_color,
&blank_color,
8, 8);
XFreeGC (dpy, gc);
cursor = XCreatePixmapCursor (dpy,
empty_pixmap,
empty_pixmap,
&blank_color,
&blank_color,
8, 8);
break;
}
break;
}
case wxCURSOR_ARROW:
default: x_cur = XC_top_left_arrow; break;
}
if( x_cur == -1 )
return (WXCursor)cursor;
cursor = XCreateFontCursor (dpy, x_cur);
return (WXCursor) cursor;
}

View File

@ -23,6 +23,9 @@
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#ifdef __WXMOTIF20__
#include <Xm/Scale.h>
#endif // __WXMOTIF20__
#ifdef __VMS__
#pragma message enable nosimpint
#endif
@ -30,6 +33,8 @@
IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
#if !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF()
// XmGauge copyright notice:
/*
@ -79,7 +84,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,
@ -89,25 +94,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);
@ -119,29 +113,46 @@ 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)
@ -149,19 +160,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);
}
@ -172,17 +177,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
@ -190,23 +189,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
@ -779,3 +774,5 @@ XmGaugeGetValue(Widget w)
return gw->gauge.value;
}
#endif // !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF()

View File

@ -46,7 +46,6 @@ wxSlider::wxSlider()
m_lineSize = 1;
m_rangeMax = 0;
m_rangeMin = 0;
m_tickFreq = 0;
}
bool wxSlider::Create(wxWindow *parent, wxWindowID id,
@ -55,25 +54,15 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
const wxSize& size, long style,
const wxValidator& validator,
const wxString& name)
{
{
if ( !((style & wxSL_HORIZONTAL) || (style & wxSL_VERTICAL)) )
style |= wxSL_HORIZONTAL;
SetName(name);
SetValidator(validator);
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
if( !CreateControl( parent, id, pos, size, style, validator, name ) )
return false;
m_lineSize = 1;
m_windowStyle = style;
m_tickFreq = 0;
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
m_rangeMax = maxValue;
m_rangeMin = minValue;
@ -114,8 +103,6 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
XtAddCallback (sliderWidget, XmNdragCallback, (XtCallbackProc) wxSliderCallback, (XtPointer) this);
m_font = parent->GetFont();
ChangeFont(FALSE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
@ -141,11 +128,6 @@ void wxSlider::SetValue(int value)
XtVaSetValues ((Widget) m_mainWidget, XmNvalue, value, NULL);
}
void wxSlider::GetSize(int *width, int *height) const
{
wxControl::GetSize(width, height);
}
void wxSlider::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
Widget widget = (Widget) m_mainWidget;
@ -186,12 +168,6 @@ void wxSlider::SetRange(int minValue, int maxValue)
}
// For trackbars only
void wxSlider::SetTickFreq(int n, int WXUNUSED(pos))
{
// Not implemented in Motif
m_tickFreq = n;
}
void wxSlider::SetPageSize(int pageSize)
{
// Not implemented in Motif
@ -203,16 +179,6 @@ int wxSlider::GetPageSize() const
return m_pageSize;
}
void wxSlider::ClearSel()
{
// Not implemented in Motif
}
void wxSlider::ClearTicks()
{
// Not implemented in Motif
}
void wxSlider::SetLineSize(int lineSize)
{
// Not implemented in Motif
@ -225,23 +191,6 @@ int wxSlider::GetLineSize() const
return m_lineSize;
}
int wxSlider::GetSelEnd() const
{
// Not implemented in Motif
return 0;
}
int wxSlider::GetSelStart() const
{
// Not implemented in Motif
return 0;
}
void wxSlider::SetSelection(int WXUNUSED(minPos), int WXUNUSED(maxPos))
{
// Not implemented in Motif
}
void wxSlider::SetThumbLength(int WXUNUSED(len))
{
// Not implemented in Motif (?)
@ -253,57 +202,41 @@ int wxSlider::GetThumbLength() const
return 0;
}
void wxSlider::SetTick(int WXUNUSED(tickPos))
{
// Not implemented in Motif
}
void wxSlider::Command (wxCommandEvent & event)
{
SetValue (event.GetInt());
ProcessCommand (event);
}
void wxSlider::ChangeFont(bool keepOriginalSize)
{
wxWindow::ChangeFont(keepOriginalSize);
}
void wxSlider::ChangeBackgroundColour()
{
wxWindow::ChangeBackgroundColour();
}
void wxSlider::ChangeForegroundColour()
{
wxWindow::ChangeForegroundColour();
}
void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruct * cbs)
void wxSliderCallback (Widget widget, XtPointer clientData,
XmScaleCallbackStruct * cbs)
{
wxSlider *slider = (wxSlider *) clientData;
wxEventType scrollEvent;
switch (cbs->reason)
{
case XmCR_VALUE_CHANGED:
scrollEvent = wxEVT_SCROLL_THUMBRELEASE;
break;
case XmCR_DRAG:
scrollEvent = wxEVT_SCROLL_THUMBTRACK;
break;
default:
{
// TODO: the XmCR_VALUE_CHANGED case should be handled
// differently (it's not sent continually as the slider moves).
// In which case we need a similar behaviour for other platforms.
wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, slider->GetId());
XtVaGetValues (widget, XmNvalue, &event.m_commandInt, NULL);
event.SetEventObject(slider);
slider->ProcessCommand(event);
// Also send a wxCommandEvent for compatibility.
wxCommandEvent event2(wxEVT_COMMAND_SLIDER_UPDATED, slider->GetId());
event2.SetEventObject(slider);
event2.SetInt( event.GetInt() );
slider->ProcessCommand(event2);
break;
}
return;
}
wxScrollEvent event(scrollEvent, slider->GetId());
XtVaGetValues (widget, XmNvalue, &event.m_commandInt, NULL);
event.SetEventObject(slider);
slider->GetEventHandler()->ProcessEvent(event);
// Also send a wxCommandEvent for compatibility.
wxCommandEvent event2(wxEVT_COMMAND_SLIDER_UPDATED, slider->GetId());
event2.SetEventObject(slider);
event2.SetInt( event.GetInt() );
slider->GetEventHandler()->ProcessEvent(event2);
}