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

  1.  
  2.  
  3. #include "menudrv.h"
  4. #include "ids.h"
  5.  
  6. #include "ui/menu.h"
  7. #include "ui/stddlg.h"
  8. #include "ui/applic.h"
  9. #include "ui/composit.h"
  10. #include "ui/label.h"
  11.  
  12.  
  13. #if defined(__GNUC__)
  14. template class CL_Binding<MenuDriver>; // Instantiate the binding
  15. #endif
  16.  
  17. extern UI_Application* _TheApplication;
  18.  
  19. typedef CL_Binding<MenuDriver> MenuBinding;
  20.  
  21. #if 0
  22. MenuDriver::MenuDriver()
  23. {
  24.     UI_CompositeVObject* root = _TheApplication->MainWindow();
  25.     UI_Rectangle shape = root->ClientArea ();
  26.     status = new UI_Label (root, UI_Rectangle (0, shape.Height()-30,
  27.                                                shape.Width(), 30));
  28.     status->ShowBorder ();
  29. //     MenuBinding bind (this, &MenuDriver::Resize);
  30. //     root->AddEventDependent (Event_Reconfigure, bind, 1);
  31. }
  32. #endif
  33.  
  34.  
  35.  
  36. struct DispatcherStruct {
  37.     UI_ViewID              menu_id;
  38.     MenuBinding::MethodPtr method;
  39.     UI_EventType           event;
  40.     long                   parameter;
  41. } FAR dispatch [] = {
  42.     {ID_JAN,      MenuDriver::Inform, Event_Select,  ID_JAN}
  43.   , {ID_FEB,      MenuDriver::Inform, Event_Select,  ID_FEB}
  44.   , {ID_MAR,      MenuDriver::Inform, Event_Select,  ID_MAR}
  45.   , {ID_APR,      MenuDriver::Inform, Event_Select,  ID_APR}
  46.   , {ID_MAY,      MenuDriver::Inform, Event_Select,  ID_MAY}
  47. };
  48.  
  49.  
  50.  
  51. void MenuDriver::Setup (UI_Menu* menu)
  52. {
  53.     _menu = menu;
  54.     for (short i = 0; i < sizeof dispatch/sizeof (DispatcherStruct); i++) {
  55.         (*menu)[dispatch[i].menu_id]->AddEventDependent
  56.             (dispatch[i].event, MenuBinding (this, dispatch[i].method),
  57.              dispatch[i].parameter);
  58.     }
  59. }
  60.  
  61.  
  62.  
  63.  
  64. bool MenuDriver::Inform (CL_Object&, long item_id)
  65. {
  66.     UI_SimpleDialog ("You chose " + (*_menu)[item_id]->Title());
  67.     return TRUE;
  68. }
  69.  
  70.