home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / uidemo / scroll / appwin.cxx next >
C/C++ Source or Header  |  1995-02-11  |  1KB  |  49 lines

  1.  
  2. #include "appwin.h"
  3. #include "ui/cntroler.h"
  4.  
  5. #define ID_BAR    10
  6. #define ID_LABEL  11
  7. #define ID_BTN    12
  8.  
  9. typedef CL_Binding<AppWindow> Bind;
  10.  
  11. #if defined(__GNUC__)
  12. template class CL_Binding<AppWindow>;
  13. #endif
  14.  
  15. AppWindow::AppWindow()
  16. : UI_CompositeVObject (NULL, NULL, FALSE, UI_Rectangle (100, 100, 270, 260))
  17. {
  18.     _btn   = new UI_ToggleButton (this, UI_Rectangle (10, 10, 150, 25),
  19.                                   ID_BTN);
  20.     _msg   = new UI_Label (this, UI_Rectangle (30, 90, 80, 20), ID_LABEL);
  21.     _bar   = new UI_VScrollBar (this, UI_Rectangle (150, 35, 25, 180), ID_BAR);
  22.     _bar->Range() = CL_Interval (0, 255);
  23.     Bind bind (this, &AppWindow::_DoScroll);
  24.     _bar->ClientSet().Add (bind, ID_BAR);
  25.     CL_Interval init (26, 26); // Initial setting
  26.     (_bar->Model()) = init;
  27.     (_msg->Model()) = init.AsString();
  28.     (_btn->Model()) = CL_Integer ((short) TRUE);
  29.     (_btn->Title()) = "Smooth scroll";
  30. }
  31.  
  32. bool AppWindow::_DoScroll (CL_Object&, long)
  33. {
  34.     CL_String& s = (CL_String&) _msg->Model();
  35.     s = _bar->Model().AsString();
  36.     _Controller->GiveFocusTo (*_bar);
  37.     return TRUE;
  38. }
  39.  
  40.  
  41. bool AppWindow::HandleChildEvent (const UI_Event& e)
  42. {
  43.     if (e.Origin()->ViewID() !=  ID_BTN || e.Type() != Event_Select)
  44.         return FALSE;
  45.     CL_Integer& v = (CL_Integer&) (e.Origin()->Model());
  46.     _bar->SmoothScroll() = v.Value();
  47.     return TRUE;
  48. }
  49.