home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / BK-SC1_4.DMS / in.adf / MUIClass.Lha / Demo / Demo3 / Class.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-05  |  2.8 KB  |  130 lines

  1. //
  2. //    c 1996 Thomas Wilhelmi
  3. //
  4. //
  5. // Address : Taunusstrasse 14
  6. //           61138 Niederdorfelden
  7. //           Germany
  8. //
  9. //  E-Mail : willi@twi.rhein-main.de
  10. //
  11. //   Phone : +49 (0)6101 531060
  12. //   Fax   : +49 (0)6101 531061
  13. //
  14.  
  15. #include <clib/alib_protos.h>
  16. #include <proto/utility.h>
  17. #include "Class.h"
  18.  
  19. TWiList::TWiList()
  20.     :   MUIList(ReadListFrame,
  21.             MUIA_List_CompareHook, compare(),
  22.             MUIA_List_ConstructHook, construct(),
  23.             MUIA_List_DestructHook, destruct(),
  24.             MUIA_List_DisplayHook, display(),
  25.             TAG_DONE)
  26.     {
  27.     };
  28.  
  29. LONG TWiList::CompareHookFunc(struct Hook *h, APTR e2, APTR e1)
  30.     {
  31.     return(Stricmp(((ListCont *)e1)->getStr(),((ListCont *)e2)->getStr()));
  32.     };
  33.  
  34. APTR TWiList::ConstructHookFunc(struct Hook *h, APTR p, APTR e)
  35.     {
  36.     return(new ListCont((STRPTR)e));
  37.     };
  38.  
  39. void TWiList::DestructHookFunc(struct Hook *h, APTR p, APTR e)
  40.     {
  41.     delete (ListCont *)e;
  42.     };
  43.  
  44. void TWiList::DisplayHookFunc(struct Hook *h, STRPTR *a, APTR e)
  45.     {
  46.     *a = ((ListCont *)e)->getStr();
  47.     };
  48.  
  49. TWiWin::TWiWin()
  50.     :   MUIWindow(),
  51.         Liste(),
  52.         lv(MUIA_Listview_Input, TRUE,
  53.             MUIA_Listview_MultiSelect, MUIV_Listview_MultiSelect_None,
  54.             MUIA_Listview_List, Liste.object(),
  55.             MUIA_CycleChain, 1,
  56.             TAG_DONE),
  57.         BSave("_Save"),
  58.         BUse("_Use"),
  59.         BCancel("_Cancel"),
  60.         MsgSave(0L,"Demo-Message","_Ok","Es wurde 'Save' gedrückt",0UL),
  61.         MsgUse(0L,"Demo-Message","_Ok","Es wurde 'Use' gedrückt",0UL),
  62.         MsgCan(0L,"Demo-Message","_Ok","Es wurde 'Cancel' gedrückt",0UL)
  63.     {
  64.     Liste.InsertSingle("3. String",MUIV_List_Insert_Sorted);
  65.     Liste.InsertSingle("2. String",MUIV_List_Insert_Sorted);
  66.     Liste.InsertSingle("4. String",MUIV_List_Insert_Sorted);
  67.     Liste.InsertSingle("1. String",MUIV_List_Insert_Sorted);
  68.     Liste.InsertSingle("5. String",MUIV_List_Insert_Sorted);
  69.     Create(
  70.         MUIA_Window_Title, "TWiDVI Ver 1.0",
  71.         MUIA_Window_ID,    MakeId('T','D','V','I'),
  72.         WindowContents,    VGroup,
  73.             Child, lv.object(),
  74.             Child, HGroup,
  75.                 MUIA_Group_SameSize, TRUE,
  76.                 Child, (Object *)BSave,
  77.                 Child, (Object *)BUse,
  78.                 Child, (Object *)BCancel,
  79.                 End,
  80.             End,
  81.         TAG_DONE);
  82.     BSave.CycleChain(1);
  83.     BUse.CycleChain(1);
  84.     BCancel.CycleChain(1);
  85.     DefaultObject(lv);
  86.     BSave.Notify(MUIA_Pressed,   FALSE, *this, 1, MUIM_Demo_Save);
  87.     BUse.Notify(MUIA_Pressed,    FALSE, *this, 1, MUIM_Demo_Use);
  88.     BCancel.Notify(MUIA_Pressed, FALSE, *this, 1, MUIM_Demo_Cancel);
  89.     };
  90.  
  91. TWiWin::~TWiWin()
  92.     {
  93.     }
  94.  
  95. void TWiWin::save()
  96.     {
  97.     MsgSave.show(*AppClass(),*this);
  98.     };
  99.  
  100. void TWiWin::use()
  101.     {
  102.     MsgUse.show(*AppClass(),*this);
  103.     };
  104.  
  105. void TWiWin::cancel()
  106.     {
  107.     MsgCan.show(*AppClass(),*this);
  108.     };
  109.  
  110. ULONG TWiWin::UserDispatch(struct IClass *cl, Object *obj, Msg msg)
  111.     {
  112.     ULONG rc = 0UL;
  113.     switch(msg->MethodID)
  114.         {
  115.         case MUIM_Demo_Save:
  116.             save();
  117.             break;
  118.         case MUIM_Demo_Use:
  119.             use();
  120.             break;
  121.         case MUIM_Demo_Cancel:
  122.             cancel();
  123.             break;
  124.         default:
  125.             rc = DoSuperMethodA(cl,obj,msg);
  126.             break;
  127.         }
  128.     return(rc);
  129.     };
  130.