Derive wxScrollBar from wxScrollBarBase, plus miscellaneous
refactoring. Adjusted default scrollbar size to match the size of wxScrolledWindow (and other scrolled controls) scrollbars. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20750 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -16,10 +16,8 @@
|
|||||||
#pragma interface "scrolbar.h"
|
#pragma interface "scrolbar.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/control.h"
|
|
||||||
|
|
||||||
// Scrollbar item
|
// Scrollbar item
|
||||||
class WXDLLEXPORT wxScrollBar: public wxControl
|
class WXDLLEXPORT wxScrollBar: public wxScrollBarBase
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxScrollBar)
|
DECLARE_DYNAMIC_CLASS(wxScrollBar)
|
||||||
|
|
||||||
@@ -47,7 +45,6 @@ public:
|
|||||||
inline int GetThumbSize() const { return m_pageSize; }
|
inline int GetThumbSize() const { return m_pageSize; }
|
||||||
inline int GetPageSize() const { return m_viewSize; }
|
inline int GetPageSize() const { return m_viewSize; }
|
||||||
inline int GetRange() const { return m_objectSize; }
|
inline int GetRange() const { return m_objectSize; }
|
||||||
inline bool IsVertical() const { return FALSE; }
|
|
||||||
|
|
||||||
virtual void SetThumbPosition(int viewStart);
|
virtual void SetThumbPosition(int viewStart);
|
||||||
virtual void SetScrollbar(int position, int thumbSize, int range, int pageSize,
|
virtual void SetScrollbar(int position, int thumbSize, int range, int pageSize,
|
||||||
@@ -58,7 +55,6 @@ public:
|
|||||||
// Implementation
|
// Implementation
|
||||||
virtual void ChangeFont(bool keepOriginalSize = TRUE);
|
virtual void ChangeFont(bool keepOriginalSize = TRUE);
|
||||||
virtual void ChangeBackgroundColour();
|
virtual void ChangeBackgroundColour();
|
||||||
virtual void ChangeForegroundColour();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_pageSize;
|
int m_pageSize;
|
||||||
|
@@ -14,15 +14,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
|
|
||||||
#include "wx/scrolbar.h"
|
#include "wx/scrolbar.h"
|
||||||
|
|
||||||
#ifdef __VMS__
|
#ifdef __VMS__
|
||||||
#pragma message disable nosimpint
|
#pragma message disable nosimpint
|
||||||
#endif
|
#endif
|
||||||
#include <X11/IntrinsicP.h>
|
|
||||||
#include <Xm/Xm.h>
|
#include <Xm/Xm.h>
|
||||||
#include <Xm/RowColumn.h>
|
|
||||||
#include <Xm/ScrollBar.h>
|
#include <Xm/ScrollBar.h>
|
||||||
#ifdef __VMS__
|
#ifdef __VMS__
|
||||||
#pragma message enable nosimpint
|
#pragma message enable nosimpint
|
||||||
@@ -42,64 +39,26 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
|
|||||||
const wxValidator& validator,
|
const wxValidator& validator,
|
||||||
const wxString& name)
|
const wxString& name)
|
||||||
{
|
{
|
||||||
if (!parent)
|
if( !CreateControl( parent, id, pos, size, style, validator, name ) )
|
||||||
return FALSE;
|
return false;
|
||||||
parent->AddChild(this);
|
|
||||||
SetName(name);
|
|
||||||
m_backgroundColour = parent->GetBackgroundColour();
|
|
||||||
m_foregroundColour = parent->GetForegroundColour();
|
|
||||||
SetValidator(validator);
|
|
||||||
|
|
||||||
m_windowStyle = style;
|
wxSize newSize =
|
||||||
|
( style & wxHORIZONTAL ) ? wxSize( 140, 16 ) : wxSize( 16, 140 );
|
||||||
if ( id == -1 )
|
if( size.x != -1 ) newSize.x = size.x;
|
||||||
m_windowId = (int)NewControlId();
|
if( size.y != -1 ) newSize.y = size.y;
|
||||||
else
|
|
||||||
m_windowId = id;
|
|
||||||
|
|
||||||
int x = pos.x;
|
|
||||||
int y = pos.y;
|
|
||||||
int width = size.x;
|
|
||||||
int height = size.y;
|
|
||||||
|
|
||||||
if (width == -1)
|
|
||||||
{
|
|
||||||
if (style & wxHORIZONTAL)
|
|
||||||
width = 140;
|
|
||||||
else
|
|
||||||
width = 12;
|
|
||||||
}
|
|
||||||
if (height == -1)
|
|
||||||
{
|
|
||||||
if (style & wxVERTICAL)
|
|
||||||
height = 140;
|
|
||||||
else
|
|
||||||
height = 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||||
int direction = (style & wxHORIZONTAL) ? XmHORIZONTAL: XmVERTICAL;
|
|
||||||
|
|
||||||
Widget scrollBarWidget = XtVaCreateManagedWidget("scrollBarWidget",
|
m_mainWidget =
|
||||||
xmScrollBarWidgetClass, parentWidget,
|
DoCreateScrollBar( (WXWidget)parentWidget,
|
||||||
XmNorientation, direction,
|
(wxOrientation)(style & (wxHORIZONTAL|wxVERTICAL)),
|
||||||
NULL);
|
(void (*)())wxScrollBarCallback );
|
||||||
|
|
||||||
m_mainWidget = (Widget) scrollBarWidget;
|
AttachWidget (parent, m_mainWidget, (WXWidget) NULL,
|
||||||
|
pos.x, pos.y, newSize.x, newSize.y);
|
||||||
XtAddCallback(scrollBarWidget, XmNvalueChangedCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
|
||||||
XtAddCallback(scrollBarWidget, XmNdragCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
|
||||||
XtAddCallback(scrollBarWidget, XmNdecrementCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
|
||||||
XtAddCallback(scrollBarWidget, XmNincrementCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
|
||||||
XtAddCallback(scrollBarWidget, XmNpageDecrementCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
|
||||||
XtAddCallback(scrollBarWidget, XmNpageIncrementCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
|
||||||
XtAddCallback(scrollBarWidget, XmNtoTopCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
|
||||||
XtAddCallback(scrollBarWidget, XmNtoBottomCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
|
||||||
|
|
||||||
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height);
|
|
||||||
ChangeBackgroundColour();
|
ChangeBackgroundColour();
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxScrollBar::~wxScrollBar()
|
wxScrollBar::~wxScrollBar()
|
||||||
@@ -108,25 +67,17 @@ wxScrollBar::~wxScrollBar()
|
|||||||
|
|
||||||
void wxScrollBar::SetThumbPosition(int pos)
|
void wxScrollBar::SetThumbPosition(int pos)
|
||||||
{
|
{
|
||||||
if (m_mainWidget)
|
XtVaSetValues ((Widget) m_mainWidget,
|
||||||
{
|
XmNvalue, pos,
|
||||||
XtVaSetValues ((Widget) m_mainWidget,
|
NULL);
|
||||||
XmNvalue, pos,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxScrollBar::GetThumbPosition() const
|
int wxScrollBar::GetThumbPosition() const
|
||||||
{
|
{
|
||||||
if (m_mainWidget)
|
int pos;
|
||||||
{
|
XtVaGetValues((Widget) m_mainWidget,
|
||||||
int pos;
|
XmNvalue, &pos, NULL);
|
||||||
XtVaGetValues((Widget) m_mainWidget,
|
return pos;
|
||||||
XmNvalue, &pos, NULL);
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize,
|
void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageSize,
|
||||||
@@ -171,15 +122,11 @@ void wxScrollBar::ChangeBackgroundColour()
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxScrollBar::ChangeForegroundColour()
|
static void wxScrollBarCallback(Widget widget, XtPointer clientData,
|
||||||
|
XmScaleCallbackStruct *cbs)
|
||||||
{
|
{
|
||||||
wxWindow::ChangeForegroundColour();
|
wxScrollBar *scrollBar = (wxScrollBar*)wxGetWindowFromTable(widget);
|
||||||
}
|
wxOrientation orientation = (wxOrientation)(int)clientData;
|
||||||
|
|
||||||
static void wxScrollBarCallback(Widget WXUNUSED(widget), XtPointer clientData,
|
|
||||||
XmScaleCallbackStruct *cbs)
|
|
||||||
{
|
|
||||||
wxScrollBar *scrollBar = (wxScrollBar *)clientData;
|
|
||||||
wxEventType eventType = wxEVT_NULL;
|
wxEventType eventType = wxEVT_NULL;
|
||||||
|
|
||||||
switch (cbs->reason)
|
switch (cbs->reason)
|
||||||
@@ -232,13 +179,8 @@ static void wxScrollBarCallback(Widget WXUNUSED(widget), XtPointer clientData,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxScrollEvent event(eventType, scrollBar->GetId());
|
wxScrollEvent event(eventType, scrollBar->GetId(),
|
||||||
|
cbs->value, orientation);
|
||||||
event.SetEventObject(scrollBar);
|
event.SetEventObject(scrollBar);
|
||||||
event.SetPosition(cbs->value);
|
|
||||||
scrollBar->GetEventHandler()->ProcessEvent(event);
|
scrollBar->GetEventHandler()->ProcessEvent(event);
|
||||||
/*
|
|
||||||
if (!scrollBar->inSetValue)
|
|
||||||
scrollBar->ProcessCommand(event);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user