home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Snippets / Dim Text 3.0 / main_3.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-04  |  1.7 KB  |  81 lines  |  [TEXT/CWIE]

  1. #define        STRICT_WINDOWS    1
  2. #include <Dialogs.h>
  3. #include <Menus.h>
  4.  
  5. #include "ToolBoxInit.h"
  6. #include "Dim_text_3.h"
  7.  
  8. enum {    // dialog item numbers
  9.     i_done = 1,
  10.     i_title,
  11.     i_checkbox1,
  12.     i_checkbox2,
  13.     i_stat1,
  14.     i_edit1,
  15.     i_edit3,
  16.     i_stat2,
  17.     i_edit2,
  18.     i_refresh
  19. };
  20.  
  21. void main( void )
  22. {
  23.     DialogRef        dp;
  24.     ControlHandle    checkbox1, checkbox2;
  25.     Rect            iRect;
  26.     short            iType, hit, val;
  27.     MenuHandle        apple_menu;
  28.     ModalFilterUPP    Dialog_filter_UPP;
  29.     
  30.     ToolBoxInit();
  31.     apple_menu = NewMenu( 128, "\p\x14" );
  32.     AppendMenu( apple_menu, "\pYo;(-" );
  33.     AddResMenu( apple_menu, 'DRVR' );
  34.     InsertMenu( apple_menu, 0 );
  35.     DrawMenuBar();
  36.     
  37.     Dialog_filter_UPP = NewModalFilterProc( Dim_filter_proc );
  38.     
  39.     dp = GetNewDialog( 128, NULL, (WindowRef)-1L );
  40.     SetGrafPortOfDialog( dp );
  41.     SetDialogDefaultItem( dp, i_done );
  42.     GetDialogItem( dp, i_checkbox1, &iType, (Handle *)&checkbox1, &iRect );
  43.     GetDialogItem( dp, i_checkbox2, &iType, (Handle *)&checkbox2, &iRect );
  44.     Init_dimmer( dp, NULL );
  45.     
  46.     ShowWindow( GetDialogWindow( dp ) );
  47.     do {
  48.         ModalDialog( Dialog_filter_UPP, &hit );
  49.         switch (hit)
  50.         {
  51.             case i_checkbox1:
  52.                 val = !GetControlValue( checkbox1 );
  53.                 SetControlValue( checkbox1, val );
  54.                 Dim_text( dp, i_stat1, val );
  55.                 Dim_text( dp, i_edit1, val );
  56.                 Dim_text( dp, i_edit3, val );
  57.                 break;
  58.                 
  59.             case i_checkbox2:
  60.                 val = !GetControlValue( checkbox2 );
  61.                 if (val)
  62.                 {
  63.                     Alert( 129, NULL );
  64.                 }
  65.                 SetControlValue( checkbox2, val );
  66.                 Dim_text( dp, i_stat2, val );
  67.                 Dim_text( dp, i_edit2, val );
  68.                 break;
  69.             
  70.             case i_refresh:
  71.                 EraseRect( &qd.thePort->portRect );
  72.                 InvalRect( &qd.thePort->portRect );
  73.                 break;
  74.         }
  75.     } while (hit != i_done);
  76.     
  77.     Dispose_dimmer( dp );
  78.     DisposeDialog( dp );
  79.     DisposeRoutineDescriptor( Dialog_filter_UPP );
  80. }
  81.