home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / B_SBINIT.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  15KB  |  381 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*            This module was originally written by Bob Hartman             */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                  BinkleyTerm Initial Fullscreen Setup                    */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46. /* Include this file before any other includes or defines! */
  47.  
  48. #include "includes.h"
  49.  
  50. #ifndef MILQ
  51. #define WHOLEWIN
  52. #endif
  53.  
  54. #ifdef MILQ
  55. #define MENU_ENABLED
  56. #if defined (MENU_ENABLED) || defined (MILQ)
  57. #define RESOURCE_ENABLED
  58. #endif
  59. #endif
  60.  
  61. extern VIOMODEINFO vfos_mode;
  62. void MilqMassageWnd( REGIONP Win, int Color );
  63.  
  64. #ifdef MILQ
  65. int PASCAL color_enum( HWND hWnd,
  66.                        DWORD lParam ) {
  67.   WinSetAttr( hWnd, (int)lParam, FALSE );
  68.   return TRUE;
  69.   }
  70.  
  71. HWND MilqDlgCreate( REGIONP  Win,
  72.                     char    *Nm,
  73.                     DLGPROC *dlgfunc,
  74.                     int      Color ) {
  75.   Win->hWnd = CreateDialog( MilqueRsrc, Nm, MilqueMailerWnd, dlgfunc );
  76.   MilqMassageWnd( Win, Color );
  77.   return Win->hWnd;
  78.   }
  79.  
  80. void MilqMassageWnd( REGIONP Win,
  81.                      int     Color ) {
  82.   int                   Bgd = WHITE;
  83.   HWND                  hMenu;
  84.  
  85.   hMenu = GetSystemMenu( Win->hWnd, FALSE );
  86.   DeleteMenu( hMenu, SC_CLOSE, MF_BYCOMMAND );
  87.   AppendMenu( hMenu, MF_ENABLED, SC_SIZE, "~Size" );
  88.   GetWindowRect( Win->hWnd, &Win->MilqSave.OrgRect );
  89.   if ( !UseWinColors ) {
  90.     if ( Color ) {
  91.       WinSetAttr( Win->hWnd, Color, FALSE );
  92.       EnumChildWindows( Win->hWnd, color_enum, (long)Color );
  93.       }                                /* end of if ( Color )         */
  94.     }                                  /* end of if ( !UseWinColors ) */
  95.   SetFocus( Win->hWnd );
  96.   }
  97. #endif
  98.  
  99. void b_sbinit () {
  100. #ifdef MILQ
  101.    char                 Buf[81];
  102. #endif
  103.  
  104.    register int         r;
  105.    char                *savep;
  106.  
  107. #ifdef MILQ
  108.    KbMapSet( &UnattendedKeyFncHdr );
  109.    WinInit();
  110.    MDIInitialize();
  111.    MilqueClassRegister();
  112.    WinUseSysColors (MilqueRootWnd, TRUE);
  113.    OrgVidInfo.VidMode = VidGetMode();
  114.    WinUseMonoMap( TRUE );
  115.  
  116.    MilqueRsrc = OpenResourceFile((PSTR) PRDCT_PRFX);
  117.  
  118.    /* Fetch the ega status and toggle if needed */
  119.  
  120.    UseWinColors = GetPrivateProfileInt( "Milque", "UseWinColors", 0, "Milque.Ini" );
  121.    node_Pwd_Enable = GetPrivateProfileInt( "Milque", "PWD", 0, "Milque.Ini" );
  122. #ifdef NEW_BIG_SCREEN
  123.    switch ( VidQueryAdapterType() ) {
  124.      case CGA:
  125.      case MDA:
  126.        break;
  127.      default:
  128.        if ( GetPrivateProfileInt( "Milque", "EGA", 0, "Milque.Ini" ) ) {
  129.          ToggleEGA();
  130.          MilqueVidInfo.EGAState = TRUE;
  131.          }
  132.        break;
  133.      }
  134. #endif
  135.  
  136.    if ( !( MilqueMailerAccel = LoadAccelerators( MilqueRsrc,
  137.                                                  (LPSTR)"MailerAccel" ) ) ) {
  138.      MessageBox( MilqueRootWnd,
  139.                  (PSTR)"Cannot load Mailer Accelerators",
  140.                  (PSTR)"Fatal Error",
  141.                  MB_OK );
  142.      exit(1);
  143.      }
  144.    MilqueActvAccel = MilqueMailerAccel;
  145.    if ( !( MilqueTrmnlAccel = LoadAccelerators( MilqueRsrc,
  146.                                                 (LPSTR)"TrmnlAccel" ) ) ) {
  147.      MessageBox( MilqueRootWnd,
  148.                  (PSTR)"Cannot load Terminal Accelerators",
  149.                  (PSTR)"Fatal Error",
  150.                  MB_OK );
  151.      exit(1);
  152.      }
  153.    if ( !( MilqueMailerMnu = LoadMenu( MilqueRsrc, (LPSTR)"MailerMenu" ) ) ) {
  154.      MessageBox( MilqueRootWnd,
  155.                  (PSTR)"Cannot load the menu",
  156.                  (PSTR)"Fatal Error",
  157.                  MB_OK);
  158.      exit(1);
  159.      }
  160.  
  161.    randomize();
  162.    MilqueMailerWnd = CreateWindow( (PSTR)"Normal",       /* class */
  163.                                    (PSTR)"BTMewel",      /* title */
  164.                                    WIN_HAS_BORDER   |
  165.                                      WIN_MINMAXBOX  |
  166.                                      WIN_MOVEBOX    |
  167.                                      WIN_SIZEBOX    |
  168.                                      WIN_SYSMENU    |
  169.                                      WIN_TITLEBAR   |
  170.                                      WS_CLIP        |
  171.                                      WS_MAXIMIZEBOX |
  172.                                      WS_MINIMIZEBOX,
  173.                                    0,0,            /* x,y,width,height */
  174.                                    GetSystemMetrics(SM_CXSCREEN),
  175.                                    GetSystemMetrics(SM_CYSCREEN),
  176.                                    MilqueRootWnd,   /* hParent */
  177.                                    MilqueMailerMnu,  /* hMenu */
  178.                                    0,              /* hInst */
  179.                                    0L);           /* lpParam */
  180.    MilqueActvWnd = MilqueMailerWnd;
  181.    WinSetWinProc( MilqueMailerWnd, MailerWndPrc );
  182. #endif
  183.  
  184.    savep = calloc (1, 4096);
  185.    for (r = 0; r < 132; r++)
  186.       {
  187.       blanks[r * 2] = ' ';
  188.       blanks[r * 2 + 1] = 7;
  189.       }
  190.  
  191.    vfossil_init ();
  192.    if (vfos_mode.col < 80)
  193.       vfos_mode.col = 80;
  194.    if (vfos_mode.row < 23)
  195.       vfos_mode.row = 23;
  196.  
  197. #ifndef MILQ
  198.    SB_ROWS = vfos_mode.row - 1;
  199.    SB_COLS = vfos_mode.col;
  200. #else
  201.    SB_ROWS = GetSystemMetrics( SM_CYSCREEN ) - 1;
  202.    SB_COLS = GetSystemMetrics( SM_CXSCREEN );
  203. #endif
  204.  
  205.    SB_COLS_M_1 = SB_COLS - 1;
  206.    SB_ROWS_M_1 = SB_ROWS - 1;
  207.    SB_ROWS_M_2 = SB_ROWS - 2;
  208.    SB_ROW_STATUS = SB_ROWS -  15;
  209.  
  210.    screen_clear ();
  211.    sb_init ();
  212.    free (savep);
  213.  
  214.    wholewin = (REGIONP) sb_new (0, 0, SB_ROWS, SB_COLS);
  215.    settingswin = (REGIONP) sb_new (1, 1, 7, 22);
  216.    historywin = (REGIONP) sb_new (1, 23, 7, 23);
  217.    holdwin = (REGIONP) sb_new (1, 46, 7, SB_COLS - 47);
  218.    callwin = (REGIONP) sb_new  (8, 1, SB_ROWS -  13, SB_COLS - 2);
  219.    filewin = (REGIONP) sb_new (SB_ROWS - 5, 1, 4, SB_COLS - 2);
  220.  
  221. #ifdef MILQ
  222.    nodewin = (REGIONP) sb_new (1, 23, 7, 23);
  223.    CurWinSet( callwin );
  224.    MilqDlgCreate( callwin, "Call", CallDlgPrc, colors.call );
  225.    MilqDlgCreate( filewin, "File", FileDlgPrc, colors.file );
  226.    MilqDlgCreate( historywin, "History", HistoryDlgPrc, colors.history );
  227.                                        /* These should be message sends to */
  228.                                        /* the dialog box rather than functions */
  229.    MilqDlgCreate( holdwin, "Hold", HoldDlgPrc, colors.hold );
  230.    MilqDlgCreate( nodewin, "NodeDtl", NodeDtlDlgPrc, colors.settings );
  231.    MilqDlgCreate( settingswin, "Settings", SettingsDlgPrc, colors.settings );
  232.    NextWnd = history_hWnd;
  233. #endif
  234.  
  235.    sb_fill (wholewin, ' ', colors.background);
  236.    sb_fill (settingswin, ' ', colors.settings);
  237.    sb_fill (historywin, ' ', colors.history);
  238.    sb_fill (holdwin, ' ', colors.hold);
  239.    sb_fill (callwin, ' ', colors.call);
  240.    sb_fill (filewin, ' ', colors.file);
  241.  
  242.    sb_box (settingswin, boxtype, colors.settings);
  243.    sb_box (historywin, boxtype, colors.history);
  244.    sb_box (holdwin, boxtype, colors.hold);
  245.    sb_box (callwin, boxtype, colors.call);
  246.    sb_box (filewin, boxtype, colors.file);
  247.  
  248.    sb_caption (settingswin, MSG_TXT(M_CURRENT_SETTINGS));
  249.    sb_caption (historywin, MSG_TXT(M_TODAY_GLANCE));
  250.    sb_caption (holdwin, MSG_TXT(M_PENDING_OUTBOUND));
  251.    sb_caption (callwin, MSG_TXT(M_RECENT_ACTIVITY));
  252.    sb_caption (filewin, MSG_TXT(M_TRANSFER_STATUS));
  253.  
  254. #ifdef MILQ
  255. /* These are to set up the references to the specific controls for each
  256.  * data item displayed on the screen. Rather than computing and recomputing
  257.  * these buggers, we compute 'em once. God help us when we begin closing
  258.  * windows.
  259.  */
  260.  
  261.   history_BBS     = GetDlgItem( history_hWnd,  GD_BBS );
  262.   history_Cost    = GetDlgItem( history_hWnd,  GD_COST );
  263.   history_Fl      = GetDlgItem( history_hWnd,  GD_FL );
  264.   history_Last    = GetDlgItem( history_hWnd,  GD_LAST );
  265.   history_Out     = GetDlgItem( history_hWnd,  GD_OUT );
  266.   hold_Addr       = GetDlgItem( hold_hWnd,     GD_ADDR );
  267.   hold_Hdr        = GetDlgItem( hold_hWnd,     GD_HDR );
  268.   hold_Init       = GetDlgItem( hold_hWnd,     GD_INIT );
  269.   hold_Poll       = GetDlgItem( hold_hWnd,     GD_POLL );
  270. /*
  271.  * Thinking about eliminating these. Actually, this whole approach sort
  272.  * of sucks.
  273.  */
  274.   node_Addr       = GetDlgItem( node_hWnd,     GD_ADDR );
  275.   node_Baud       = GetDlgItem( node_hWnd,     GD_BAUD );
  276.   node_Elapsed    = GetDlgItem( node_hWnd,     GD_DUR );
  277.   node_Flags16    = GetDlgItem( node_hWnd,     GD_FLG16 );
  278.   node_Hub        = GetDlgItem( node_hWnd,     GD_HUB );
  279.   node_Loc        = GetDlgItem( node_hWnd,     GD_LOC );
  280.   node_Mdm        = GetDlgItem( node_hWnd,     GD_MDM );
  281.   node_Nm         = GetDlgItem( node_hWnd,     GD_NM );
  282.   node_Phn        = GetDlgItem( node_hWnd,     GD_PHN );
  283.   node_Pwd        = GetDlgItem( node_hWnd,     GD_PWD );
  284.   node_Rate       = GetDlgItem( node_hWnd,     GD_RATE );
  285.   node_Sysop      = GetDlgItem( node_hWnd,     GD_SYSOP );
  286. /*
  287.  * These we do often enough and in time critical enough situations that we
  288.  * will continue to do it this way.
  289.  */
  290.   settings_DtTm   = GetDlgItem( settings_hWnd, GD_DTTM );
  291.   settings_Evt    = GetDlgItem( settings_hWnd, GD_EVT );
  292.   settings_Free   = GetDlgItem( settings_hWnd, GD_LST );
  293.   settings_MTask  = GetDlgItem( settings_hWnd, GD_MTASK );
  294.   settings_Port   = GetDlgItem( settings_hWnd, GD_PORT );
  295.   settings_Status = GetDlgItem( settings_hWnd, GD_STATUS );
  296. #endif
  297.  
  298.    FlLnModeSet( FILE_LN_1, 0 );
  299.    FlLnModeSet( FILE_LN_2, 0 );
  300.    SendMessage( hold_hWnd, WM_COMMAND, GD_MODE, 0L );
  301.    SendMessage( hold_hWnd, WM_COMMAND, GD_CLR, 0L );
  302.  
  303.    sb_move (hold_hWnd, 3, 7);
  304.    sb_puts (hold_Init, MSG_TXT(M_INITIALIZING_SYSTEM));
  305.  
  306. #ifdef WHOLEWIN
  307.    sb_move (wholewin, 0, 1);
  308.    (void) sprintf (junk, MSG_TXT(M_NODE_COLON), Full_Addr_Str (&my_addr));
  309.    sb_puts (wholewin, junk);
  310.    sb_move (wholewin, 0, SB_COLS - 1 - (int) strlen (system_name));
  311.    sb_puts (wholewin, system_name);
  312. #endif
  313.  
  314. #ifdef MILQ
  315. #ifndef WHOLEWIN
  316.    (void) sprintf (Buf, MSG_TXT(M_NODE_COLON), Full_Addr_Str (&my_addr));
  317.    SetWindowText (MilqueMailerWnd, Buf);
  318. #endif
  319. #endif
  320.  
  321.    bottom_line ();
  322.  
  323. #ifndef MILQ
  324.    sb_move (settingswin, SET_EVNT_ROW, 2);
  325.    sb_puts (settingswin, MSG_TXT(M_EVENT_COLON));
  326.    sb_move (settingswin, SET_PORT_ROW, 2);
  327.    sb_puts (settingswin, MSG_TXT(M_PORT_COLON));
  328.    sb_move (settingswin, SET_STAT_ROW, 2);
  329.    sb_puts (settingswin, MSG_TXT(M_STATUS_INIT));
  330. #endif
  331.  
  332.    do_today ();
  333.  
  334. #ifndef MILQ
  335.    settingswin->sr0 = settingswin->r0 + 1;
  336.    settingswin->sr1 = settingswin->r1 - 1;
  337.    settingswin->sc0 = settingswin->c0 + 1;
  338.    settingswin->sc1 = settingswin->c1 - 1;
  339.  
  340.    historywin->sr0 = historywin->r0 + 1;
  341.    historywin->sr1 = historywin->r1 - 1;
  342.    historywin->sc0 = historywin->c0 + 1;
  343.    historywin->sc1 = historywin->c1 - 1;
  344.  
  345.    holdwin->sr0 = holdwin->r0 + 1;
  346.    holdwin->sr1 = holdwin->r1 - 1;
  347.    holdwin->sc0 = holdwin->c0 + 1;
  348.    holdwin->sc1 = holdwin->c1 - 1;
  349.  
  350.    callwin->sr0 = callwin->r0 + 1;
  351.    callwin->sr1 = callwin->r1 - 1;
  352.    callwin->sc0 = callwin->c0 + 1;
  353.    callwin->sc1 = callwin->c1 - 1;
  354.  
  355.    filewin->sr0 = filewin->r0 + 1;
  356.    filewin->sr1 = filewin->r1 - 1;
  357.    filewin->sc0 = filewin->c0 + 1;
  358.    filewin->sc1 = filewin->c1 - 1;
  359. #endif
  360.  
  361. #ifdef MILQ
  362.    MilqueScrLoad();
  363.  
  364.    if ( MilqueVidInfo.EGAState ) {
  365.      switch ( VidQueryAdapterType() ) {
  366.        case CGA:
  367.        case MDA:
  368.          break;
  369.        default:
  370.          if ( 25 == GetSystemMetrics( SM_CYSCREEN ) ) {
  371.            ToggleEGA();
  372.            }
  373.          break;
  374.        }
  375.      }
  376.  
  377.    MilqueMailerActvWnd = GetFocus();
  378. #endif
  379. }
  380.  
  381.