home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
yacl-012.zip
/
uidemo
/
scroll
/
appwin.cxx
next >
Wrap
C/C++ Source or Header
|
1995-02-11
|
1KB
|
49 lines
#include "appwin.h"
#include "ui/cntroler.h"
#define ID_BAR 10
#define ID_LABEL 11
#define ID_BTN 12
typedef CL_Binding<AppWindow> Bind;
#if defined(__GNUC__)
template class CL_Binding<AppWindow>;
#endif
AppWindow::AppWindow()
: UI_CompositeVObject (NULL, NULL, FALSE, UI_Rectangle (100, 100, 270, 260))
{
_btn = new UI_ToggleButton (this, UI_Rectangle (10, 10, 150, 25),
ID_BTN);
_msg = new UI_Label (this, UI_Rectangle (30, 90, 80, 20), ID_LABEL);
_bar = new UI_VScrollBar (this, UI_Rectangle (150, 35, 25, 180), ID_BAR);
_bar->Range() = CL_Interval (0, 255);
Bind bind (this, &AppWindow::_DoScroll);
_bar->ClientSet().Add (bind, ID_BAR);
CL_Interval init (26, 26); // Initial setting
(_bar->Model()) = init;
(_msg->Model()) = init.AsString();
(_btn->Model()) = CL_Integer ((short) TRUE);
(_btn->Title()) = "Smooth scroll";
}
bool AppWindow::_DoScroll (CL_Object&, long)
{
CL_String& s = (CL_String&) _msg->Model();
s = _bar->Model().AsString();
_Controller->GiveFocusTo (*_bar);
return TRUE;
}
bool AppWindow::HandleChildEvent (const UI_Event& e)
{
if (e.Origin()->ViewID() != ID_BTN || e.Type() != Event_Select)
return FALSE;
CL_Integer& v = (CL_Integer&) (e.Origin()->Model());
_bar->SmoothScroll() = v.Value();
return TRUE;
}