home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / CIT.v4 / Demo / ScreenTest.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  2.1 KB  |  97 lines

  1. #include "CITGroup.h"
  2. #include "CITButton.h"
  3. #include "CITGetScreenMode.h"
  4.  
  5. #include <libraries/asl.h>
  6.  
  7. #define NEWSCREEN (MAIN_STOPMASK<<1)
  8.  
  9. CITApp Application;
  10.  
  11. CITScreen        DemoScreen;
  12. CITWindow        DemoWindow;
  13. CITVGroup        winGroup;
  14. CITGetScreenMode screenModeReq;
  15. CITButton        quitButton;
  16.  
  17. ULONG modeID = DEF_MONITOR;
  18. UBYTE depth = 0;
  19.  
  20. void CloseEvent();
  21. void ScreenModeReqEvent(ULONG ID);
  22. void QuitEvent(ULONG ID);
  23.  
  24. int main(void)
  25. {
  26.   ULONG StopCode;
  27.   BOOL  Error=FALSE;
  28.  
  29.   DemoScreen.InsObject(DemoWindow,Error);
  30.     DemoWindow.Position(WPOS_CENTERSCREEN);
  31.     DemoWindow.CloseGadget();
  32.     DemoWindow.DragBar();
  33.     DemoWindow.SizeGadget();
  34.     DemoWindow.DepthGadget();
  35.     DemoWindow.IconifyGadget();
  36.     DemoWindow.Activate();
  37.     DemoWindow.Caption("CITGetScreenMode Test");
  38.     DemoWindow.CloseEventHandler(CloseEvent);
  39.     DemoWindow.InsObject(winGroup,Error);
  40.       winGroup.SpaceOuter();
  41.       winGroup.InsObject(screenModeReq,Error);
  42.         screenModeReq.LabelText("ScreenMode:");
  43.         screenModeReq.TitleText("Select ScreenMode..");
  44.         screenModeReq.EventHandler(ScreenModeReqEvent);
  45.       winGroup.InsObject(quitButton,Error);
  46.         quitButton.Text("Quit");
  47.         quitButton.MaxHeight(30);
  48.         quitButton.EventHandler(QuitEvent);
  49.   do
  50.   {
  51.     DemoScreen.Display(modeID);
  52.     DemoScreen.Depth(depth);
  53.  
  54.     Application.InsObject(DemoScreen,Error);
  55.  
  56.     // Ok?
  57.     if( Error )
  58.       return 10;
  59.  
  60.     StopCode = Application.Run(NEWSCREEN|MAIN_STOPMASK);
  61.  
  62.     Application.RemObject(DemoScreen);
  63.   }
  64.   while( !(StopCode&MAIN_STOPMASK) );
  65.  
  66.   return 0;
  67. }
  68.  
  69. void ScreenModeReqEvent(ULONG ID)
  70. {
  71.   ULONG oldModeID;
  72.   UBYTE oldDepth;
  73.  
  74.   quitButton.Disabled(TRUE);
  75.  
  76.   oldModeID = screenModeReq.DisplayID();
  77.   oldDepth = screenModeReq.DisplayDepth();
  78.   screenModeReq.ReqScreenMode();
  79.   modeID = screenModeReq.DisplayID();
  80.   depth = screenModeReq.DisplayDepth();
  81.  
  82.   if( (oldModeID != modeID) || (oldDepth != depth) )
  83.     Application.Stop(NEWSCREEN);
  84.  
  85.   quitButton.Disabled(FALSE);
  86. }
  87.  
  88. void QuitEvent(ULONG ID)
  89. {
  90.   Application.Stop();
  91. }
  92.  
  93. void CloseEvent()
  94. {
  95.   Application.Stop();
  96. }
  97.