-
Notifications
You must be signed in to change notification settings - Fork 2
/
PScrollBar.cxx
47 lines (40 loc) · 1.66 KB
/
PScrollBar.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//==============================================================================
// File: PScrollBar.cxx
//
// Copyright (c) 2017, Phil Harvey, Queen's University
//==============================================================================
#include <Xm/ScrollBar.h>
#include "PScrollBar.h"
#include "PScrollingWindow.h"
const int kScrollIncrement = 100;
// scrollBar callback
static void scrollBarProc(Widget w, PScrollBar *aScroll, XmScrollBarCallbackStruct *call_data)
{
if (aScroll->GetHandler()) {
aScroll->GetHandler()->ScrollValueChanged(aScroll->GetType(), call_data->value);
}
}
// ------------------------------------------------------------------------------------------------------------
// PScrollBar constructor
//
PScrollBar::PScrollBar(Widget container, EScrollBar bar, char *name, Arg *aWargs, int an, PScrollHandler *handler)
{
int n;
Arg wargs[10];
mType = bar;
mHandler = handler;
mScrollWidget = XtCreateManagedWidget(name, xmScrollBarWidgetClass, container, aWargs, an);
// override scrollbar range to set all scrollbars to 0 -> kScrollMax
n = 0;
XtSetArg(wargs[n], XmNminimum, 0); ++n;
XtSetArg(wargs[n], XmNmaximum, kScrollMax + kSliderSize); ++n;
XtSetArg(wargs[n], XmNsliderSize, kSliderSize); ++n;
XtSetArg(wargs[n], XmNpageIncrement, kSliderSize); ++n;
XtSetArg(wargs[n], XmNincrement, kScrollIncrement); ++n;
XtSetValues(mScrollWidget, wargs, n);
XtAddCallback(mScrollWidget, XmNvalueChangedCallback, (XtCallbackProc)scrollBarProc, this);
XtAddCallback(mScrollWidget, XmNdragCallback, (XtCallbackProc)scrollBarProc, this);
}
PScrollBar::~PScrollBar()
{
}