home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / uidemo / color / appwin.cxx next >
C/C++ Source or Header  |  1995-04-08  |  2KB  |  87 lines

  1.  
  2.  
  3. #include "ui/dsplsurf.h"
  4. #include "ui/interval.h"
  5. #include "appwin.h"
  6.  
  7. #include <iostream.h> // DEBUG
  8. #define ID_MESSAGE 10
  9. const int MaxColor = 100;
  10.  
  11. typedef CL_Binding<AppWindow> Bind;
  12.  
  13. #if defined(__GNUC__)
  14. template class CL_Binding<AppWindow>;
  15. #endif
  16.  
  17. AppWindow::AppWindow()
  18. : UI_CompositeVObject (NULL, NULL, FALSE, UI_Rectangle (50, 50, 600, 300))
  19. {
  20.     _red      = new UI_Label (this, UI_Rectangle (260, 10, 80, 30));
  21.     _blue     = new UI_Label (this, UI_Rectangle (360, 10, 80, 30));
  22.     _green    = new UI_Label (this, UI_Rectangle (460, 10, 90, 30));
  23.     _redBar   = new UI_VScrollBar (this, UI_Rectangle (300, 50, 20, 150), 10);
  24.     _blueBar  = new UI_VScrollBar (this, UI_Rectangle (400, 50, 20, 150), 11);
  25.     _greenBar = new UI_VScrollBar (this, UI_Rectangle (500, 50, 20, 150), 12);
  26.  
  27.     _redBar  ->Range() = CL_Interval (0, MaxColor);
  28.     _greenBar->Range() = CL_Interval (0, MaxColor);
  29.     _blueBar ->Range() = CL_Interval (0, MaxColor);
  30.  
  31.     Bind bind (this, (Bind::MethodPtr) &AppWindow::DoScroll);
  32.     _redBar  ->ClientSet().Add (bind, 1);
  33.     _greenBar->ClientSet().Add (bind, 1);
  34.     _blueBar ->ClientSet().Add (bind, 1);
  35.  
  36.     _title = "YACL Color Demo";
  37. }
  38.  
  39. AppWindow::~AppWindow()
  40. {
  41.     DestroyDisplaySurface ();
  42. }
  43.  
  44.  
  45. void AppWindow::Initialize ()
  46. {
  47.     CreateDisplaySurface ();
  48. }
  49.  
  50.  
  51. UI_VisualObject::ViewSize   AppWindow::MinSize () const
  52. {
  53.     return UI_VisualObject::ViewSize (550, 275);
  54. }
  55.  
  56.  
  57. UI_VisualObject::ViewSize   AppWindow::MaxSize () const
  58. {
  59.     return UI_VisualObject::ViewSize (700, 450);
  60. }
  61.  
  62.  
  63.  
  64. bool AppWindow::Paint ()
  65. {
  66.     long red, green, blue;
  67.     red   = ((CL_Interval&) _redBar  ->Model()).Low();
  68.     green = ((CL_Interval&) _greenBar->Model()).Low();
  69.     blue  = ((CL_Interval&) _blueBar ->Model()).Low();
  70.     
  71.     UI_Color color (red/((double) MaxColor), green/((double) MaxColor),
  72.                     blue/((double) MaxColor));
  73.     _displaySurface->ColorRectangle (UI_Rectangle (30, 20, 200, 200),
  74.                                      color);
  75.     _red  ->Title() = "Red: "   + CL_String (red);
  76.     _blue ->Title() = "Blue: "  + CL_String (blue);
  77.     _green->Title() = "Green: " + CL_String (green);
  78.     return FALSE;
  79. }
  80.  
  81. bool AppWindow::DoScroll (CL_Object&, long)
  82. {
  83.     return Paint ();
  84. }
  85.  
  86.  
  87.