home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / ftp.vapor.com / microdot-1 / md1_src_02.lzx / brettwin.c < prev    next >
C/C++ Source or Header  |  2014-05-19  |  5KB  |  200 lines

  1. #include "microdot.h"
  2.  
  3. #include "ogre.h"
  4. #include "ogre_protos.h"
  5.  
  6. #define BE_OK 1
  7. #define BE_CANCEL 2
  8.  
  9. #define BE_NAME 3
  10. #define BE_BET 4
  11. #define BE_HOLD 5
  12. #define BE_NOCRUNCH 6
  13. #define BE_DISKIN 7
  14. #define BE_DISKINSEL 8
  15. #define BE_ORIGIN 9
  16. #define BE_EDITORIGIN 10
  17. #define BE_PFAD 11
  18. #define BE_PFADSEL 12
  19.  
  20. #define BE_LANG 13
  21.  
  22. #define BE_PM_HEAD 15
  23. #define BE_PM_MASK 16
  24. #define BE_ANTWORTAN 17
  25.  
  26. static char *origin_options[] = 
  27.    {
  28.       "Normal",
  29.       "Keiner",
  30.       "Spezial",
  31.       NULL
  32.    };
  33.  
  34. static char *langopts[ 8 ];
  35.  
  36. static char **initlangopts( void )
  37. {
  38.     char *p;
  39.     int c;
  40.  
  41.     for( c = 0; c < 7; c++ )
  42.     {
  43.         p = &prefs.langnames[ác * 30 ];
  44.  
  45.         if( !*p )
  46.             sprintf( p, "Sprache %ld", c + 1 );
  47.  
  48.         langopts[ác ]á= p;
  49.     }
  50.     return( langopts );
  51. }
  52.  
  53. extern void makebrettnamenoup( char * );
  54. int dobrettprefs( struct mbrett *mb, int new, char *title )
  55. {
  56.     struct ogwin *ogw;
  57.     struct Window *iw;
  58.     struct IntuiMessage *im;
  59.     struct brettinfo *bi = getbrettinfo( mb );
  60.     char *p;
  61.     int Done = FALSE;
  62.     int ispm = mb->b.flags & BFLAG_EXTEND_PM;
  63.  
  64.     ogw = ogreInitWindow( scr, 0, 0, title );
  65.  
  66.     ogreAddGroup( ogw, 0, OGFRAME_OUTLINE, " Allgemein " );
  67.  
  68.     ogreAddString( ogw, 0, 'n', "Brett_name:", BE_NAME, mb->b.name, 40, 80 );
  69.     ogreAddString( ogw, 1, 'b',   " _Betreff:", BE_BET, mb->b.betreff, 40, 32 );
  70.  
  71.     ogreAddGroup( ogw, 1, OGFRAME_OUTLINE, " Halten " );
  72.     ogreAddInteger( ogw, 0, 'h', "_Haltezeit in Tagen:", BE_HOLD, mb->b.days, 0, MAXINT, 8, 8 );
  73.     ogreAddCheckbox( ogw, 0, 'l', "Nie _l÷schen?", BE_NOCRUNCH, mb->b.flags & BFLAG_NOCRUNCH );
  74.  
  75.     ogreAddGroup( ogw, 2, OGFRAME_OUTLINE, " Sonstiges " );
  76.     ogreAddString( ogw, 0, 'p', " Auslager_pfad:", BE_PFAD, bi->autoexpfad, 40, 128 );
  77.     ogreAddButton( ogw, 0 | OGGP_KEEPSIZE, 'P', "?", BE_PFADSEL );
  78.     ogreAddCycle( ogw, 1, 'r',  "       O_rigin:", BE_ORIGIN, origin_options, 8, ( mb->b.flags & BFLAG_SPECIALORIGIN ) ? 2 : ( ( mb->b.flags & BFLAG_NOORIGIN ) ? 1 : 0 ) );
  79.     ogreAddButton( ogw, 1, 'e', "Origin _Editieren", BE_EDITORIGIN );
  80.     ogreAddCycle( ogw, 2, 's',  "      _Sprache:", BE_LANG, initlangopts(), 8, mb->b.language );
  81.     ogreAddString( ogw, 3, 'd', "_Diskussion-In:", BE_DISKIN, bi->diskussionin, 40, 40 );
  82.     ogreAddButton( ogw, 3 | OGGP_KEEPSIZE, 'D', "?", BE_DISKINSEL );
  83.  
  84.     ogreAddGroup( ogw, 3, OGFRAME_OUTLINE, " PM-Brett-Parameter " );
  85.     ogreAddString( ogw, 0, 'v', "_Vergleichs-Header:", BE_PM_HEAD, bi->expm_header, 40, 32 );
  86.     ogreAddString( ogw, 1, 'i', "Vergleichs-_Inhalt:", BE_PM_MASK, bi->expm_data, 40, 128 );
  87.     ogreAddString( ogw, 2, 'f', "Emp_fΣnger:", BE_ANTWORTAN, bi->antwortan, 40, 128 );
  88.  
  89.     ogreAddGroup( ogw, 4, OGFRAME_NONE, NULL );
  90.     ogreAddButton( ogw, 0 | OGB_ONENTER, 'o', "_OK", BE_OK );
  91.     ogreAddButton( ogw, 0, 0x5f, "Hilfe", OGID_HELP );
  92.     ogreAddButton( ogw, 0 | OGB_ONESC, 'a', "_Abbruch", BE_CANCEL );
  93.  
  94.     if( !new )
  95.         ogreEnable( ogw, FALSE, BE_NAME, 0 );
  96.  
  97.     if( !ispm )
  98.         ogreEnable( ogw, FALSE, BE_PM_HEAD, BE_PM_MASK, BE_ANTWORTAN, 0 );
  99.  
  100.     iw = ogreOpenWindow( ogw );
  101.     if( !iw )
  102.         return( 0 );
  103.  
  104.     while( !Done )
  105.     {
  106.  
  107.         ogreEnable( ogw, ogreValue( ogw, BE_ORIGIN ) == 2, BE_EDITORIGIN, 0 );
  108.         ogreEnable( ogw, !ogreValue( ogw, BE_NOCRUNCH ), BE_HOLD, 0 );
  109.  
  110.         im = ogreWaitIM( ogw );
  111.  
  112.         if( im->Class == IDCMP_GADGETHELP)
  113.             showguidenum( "brett_gads", im->Code );
  114.         else if( im->Class == IDCMP_GADGETUP )
  115.         {
  116.             switch( im->Code )
  117.             {
  118.                 case BE_OK:
  119.                     p = ogreStringValue( ogw, BE_NAME );
  120.                     if( p && *p )
  121.                         Done = 2;
  122.                     else
  123.                         askreq( "Ungⁿltiger Brettname.", "Weiter" );
  124.                     break;
  125.                 case BE_CANCEL:
  126.                     Done = 1;
  127.                     break;
  128.  
  129.                 case BE_PFADSEL:
  130.                     newdofrseldir( ogw, BE_PFAD, "Pfad fⁿr Auslagerung..." );
  131.                     break;
  132.  
  133.                 case BE_DISKINSEL:
  134.                     p = dobrettreq();
  135.                     if( p )
  136.                         ogreSetStringValue( ogw, BE_DISKIN, p );
  137.                     break;
  138.  
  139.                 case BE_EDITORIGIN:
  140.                     calleditor( "T:mdtemp.origin" );
  141.                     break;
  142.             }
  143.         }
  144.         ogreIMReply( ogw, im );
  145.     }
  146.  
  147.     if( Done == 2 )
  148.     {
  149.         struct brettinfo binfo;
  150.         int c;
  151.  
  152.         ogreCopyStringValue( ogw, BE_DISKIN, binfo.diskussionin );
  153.         if( !strchr( binfo.diskussionin, '@' ) )
  154.             makebrettname( binfo.diskussionin );
  155.         ogreCopyStringValue( ogw, BE_PFAD, binfo.autoexpfad );
  156.         makedospath( binfo.autoexpfad );
  157.  
  158.         ogreCopyStringValue( ogw, BE_NAME, mb->b.name );
  159.         if( new )
  160.         {
  161.             if( ispm )
  162.                 makebrettnamenoup( mb->b.name );
  163.             else
  164.                 makebrettname( mb->b.name );
  165.         }
  166.  
  167.         ogreCopyStringValue( ogw, BE_BET, mb->b.betreff );
  168.  
  169.         ogreCopyStringValue( ogw, BE_PM_HEAD, binfo.expm_header );
  170.         ogreCopyStringValue( ogw, BE_PM_MASK, binfo.expm_data );
  171.         ogreCopyStringValue( ogw, BE_ANTWORTAN, binfo.antwortan );
  172.  
  173.         mb->b.days = ogreValue( ogw, BE_HOLD );
  174.  
  175.         /* Flags initialisieren */
  176.         mb->b.flags = ispm ? BFLAG_EXTEND_PM : 0;
  177.  
  178.         if( ogreValue( ogw, BE_NOCRUNCH ) )
  179.             mb->b.flags |= BFLAG_NOCRUNCH;
  180.  
  181.         c = ogreValue( ogw, BE_ORIGIN );
  182.         if( c == 1 )
  183.             mb->b.flags |= BFLAG_NOORIGIN;
  184.         else if( c == 2 )
  185.             mb->b.flags |= BFLAG_SPECIALORIGIN;
  186.  
  187.         mb->b.language = ogreValue( ogw, BE_LANG );
  188.  
  189.         setbrettinfo( mb, &binfo );
  190.  
  191.         makembrettlastwrite( mb );
  192.  
  193.     }
  194.  
  195.     ogreExitWindow( ogw );
  196.  
  197.     return( Done == 2 );
  198.  
  199. }
  200.