Changeset 1288


Ignore:
Timestamp:
2000-07-18T10:59:21+12:00 (24 years ago)
Author:
sjboddie
Message:

Had an initial attempt at merging the old 'server' and 'single user'
versions of the windows local library. Works ok but may need some work
on the wording and some discussion on what the various versions should
be called.

Location:
trunk/gsdl/src/w32server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/w32server/fnord.cpp

    r1203 r1288  
    7777#define ENTERBUTTONY ((MAINWINDOWHEIGHT-RESTHEIGHT)+5)
    7878
     79// size and position of version buttons
     80#define GOLDBUTTONWIDTH 150
     81#define SILVERBUTTONWIDTH 150
     82#define GOLDBUTTONHEIGHT 25
     83#define SILVERBUTTONHEIGHT GOLDBUTTONHEIGHT
     84#define GOLDBUTTONX STATUSX
     85#define SILVERBUTTONX GOLDBUTTONX
     86#define GOLDBUTTONY ((MAINWINDOWHEIGHT-RESTHEIGHT)-15)
     87#define SILVERBUTTONY ((GOLDBUTTONY+GOLDBUTTONHEIGHT)+3)
     88
     89
    7990#define VERSIONSTRING "version x.xx"
    8091const char versionstring[] = VERSIONSTRING;
     
    8899"and begin using the static version\n"
    89100"of this library";
     101const char strinitstatus[] = "Select 'Gold' or 'Silver' version. Use the 'Gold' version\n"
     102"unless your computer doesn't\n"
     103"have networking installed\n";
    90104const char *statusstring = NULL; // points to the current status string
    91105const char *infostring = NULL; // points to the current info string
     
    114128
    115129HWND GoButton = NULL;
    116 
     130HWND Gold = NULL;
     131HWND Silver = NULL;
     132int init_type = 0;
     133int init_done = 0;
    117134
    118135void finish_up() {
     
    173190    deflogobitmap = (HBITMAP)SelectObject (logodc, logobitmap);
    174191  }
     192
     193
     194  if (init_done && (overlap (GOLDBUTTONX, GOLDBUTTONY, GOLDBUTTONX+GOLDBUTTONWIDTH,
     195                 SILVERBUTTONY+SILVERBUTTONHEIGHT, updateRect))) {
     196    RECT initRect;
     197    initRect.left = GOLDBUTTONX;
     198    initRect.top = GOLDBUTTONY;
     199    initRect.right = GOLDBUTTONX+GOLDBUTTONWIDTH;
     200    initRect.bottom = SILVERBUTTONY+SILVERBUTTONHEIGHT;
     201    FillRect(pdc, &initRect, (HBRUSH)GetStockObject(WHITE_BRUSH));
     202  }
     203
     204
    175205 
    176206  // update the collection title if needed
     
    196226 
    197227  // decide what we want to draw
    198   if (gsdl_show_console) {
     228  if (init_done && gsdl_show_console) {
    199229    // we want to draw a "console" window
    200230    if (window_state != console_window ||
     
    211241   
    212242    // update the status string if needed
    213     if ((statusstring != NULL) && (strlen(statusstring) > 0)
    214     && overlap (STATUSX, STATUSY,
    215             STATUSX+STATUSWIDTH, STATUSY+STATUSHEIGHT,
    216             updateRect)) {
    217       RECT statusRect;
    218       statusRect.left = STATUSX;
    219       statusRect.top = STATUSY;
    220       statusRect.right = STATUSX+STATUSWIDTH;
    221       statusRect.bottom = STATUSY+STATUSHEIGHT;
    222       FillRect(pdc, &statusRect, (HBRUSH)GetStockObject(WHITE_BRUSH));
     243    if (overlap (STATUSX, STATUSY, STATUSX+STATUSWIDTH,
     244         STATUSY+STATUSHEIGHT, updateRect)) {
     245
     246    RECT statusRect;
     247    statusRect.left = STATUSX;
     248    statusRect.top = STATUSY;
     249    statusRect.right = STATUSX+STATUSWIDTH;
     250    statusRect.bottom = STATUSY+STATUSHEIGHT;
     251    FillRect(pdc, &statusRect, (HBRUSH)GetStockObject(WHITE_BRUSH));
     252
     253    if ((statusstring != NULL) && (strlen(statusstring) > 0)) {
    223254     
    224       int cury = STATUSY;
    225       int startline = 0, here = 0;
    226       while (statusstring[here] != '\0') {
    227     if (statusstring[here] < ' ') {
     255      int cury = STATUSY;
     256      int startline = 0, here = 0;
     257      while (statusstring[here] != '\0') {
     258        if (statusstring[here] < ' ') {
     259          if (here - startline > 0) {
     260        // output the text
     261        TextOut (pdc, STATUSX, cury,
     262             &statusstring[startline], here-startline);
     263        cury += line_spacing;
     264          }
     265          startline = here+1;
     266        }
     267        here++;
     268      }
     269      // output any remaining text
    228270      if (here - startline > 0) {
    229         // output the text
    230         TextOut (pdc, STATUSX, cury,
    231              &statusstring[startline], here-startline);
    232         cury += line_spacing;
     271        TextOut (pdc, STATUSX, cury, &statusstring[startline], here-startline);
    233272      }
    234       startline = here+1;
    235273    }
    236     here++;
    237       }
    238       // output any remaining text
    239       if (here - startline > 0) {
    240     TextOut (pdc, STATUSX, cury, &statusstring[startline], here-startline);
    241       }
    242274    }
    243275   
     
    251283 
    252284  // update the info string if needed
    253   if ((GoButton == NULL) && (infostring != NULL) &&
    254       overlap (INFOX, INFOY,
    255            INFOX+INFOWIDTH, INFOY+INFOHEIGHT,
    256            updateRect)) {
     285  if (init_done && ((GoButton == NULL) && (infostring != NULL) &&
     286            overlap (INFOX, INFOY,
     287                 INFOX+INFOWIDTH, INFOY+INFOHEIGHT,
     288                 updateRect))) {
    257289    RECT infoRect;
    258290    infoRect.left = INFOX;
     
    488520    break;
    489521   
    490   case WM_CHAR:
     522    //  case WM_CHAR:
    491523    // if the user hit the return key and if this is not a
    492524    // repeat key press then attempt to start a browser
    493     if ((WParam == '\r') && !(LParam & 0xe0000000)) {
    494       if (enter_library (Window) && !gsdl_show_console)
    495     ShowWindow(Window,SW_MINIMIZE);
    496     }
    497    
     525    //    if ((WParam == '\r') && !(LParam & 0xe0000000)) {
     526    //      if (init_done) {
     527    //  if (enter_library (Window) && !gsdl_show_console)
     528    //    ShowWindow(Window,SW_MINIMIZE);
     529    //      } else {
     530    //  init_done = 1;
     531    //  init_type = 1;
     532    //      }
     533    //    }
     534 
    498535  case WM_COMMAND:
    499     if ((HWND)LParam == GoButton) {
     536    if ((GoButton != NULL) && ((HWND)LParam == GoButton)) {
    500537      // attempt to start a browser
    501538      if (enter_library (Window) && !gsdl_show_console)
    502539    ShowWindow(Window,SW_MINIMIZE);
     540
     541    } else if ((HWND)LParam == Gold) {
     542      init_done = 1;
     543      init_type = 1;
     544
     545    } else if ((HWND)LParam == Silver) {
     546      init_done = 1;
     547      init_type = 0;
    503548
    504549    } else {
     
    597642  startbrowserdir[0] = '\0';
    598643  netscapeneeded = 0;
    599   //  int err = tryinitnetwork (Instance, MsgWindow, NULL);
    600644  int err = 1;
     645  if (init_type == 1) err = tryinitnetwork (Instance, MsgWindow, NULL);
    601646 
    602647  // if an error occurred, try again with billsock
     
    743788        "on the CD-ROM.");
    744789   
    745     MessageBox (NULL, message, "Greestone Digital Library Software", MB_OK);
     790    MessageBox (NULL, message, "Greenstone Digital Library Software", MB_OK);
    746791  }
    747792 
     
    823868  coltitlebitmap = LoadBitmap (Instance, MAKEINTRESOURCE(GSDL_COL_TITLE));
    824869  logobitmap= LoadBitmap (Instance, MAKEINTRESOURCE(GSDL_LOGO));
    825  
     870
    826871  // Create the main window
    827   MainWindow = CreateWindow("Greenstone Digital Library Software",
     872  MainWindow = CreateWindowEx(WS_EX_CONTROLPARENT, "Greenstone Digital Library Software",
    828873                "Greenstone Digital Library Software",
    829874                WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
     
    862907  // init various modules
    863908  read_settings (0); // don't know if netscape is needed at this point
     909
     910  // add the select version checkbox
     911  Gold = CreateWindow("BUTTON",             // predefined class
     912              "Gold Version",       // button text
     913              WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_DEFPUSHBUTTON,  // styles
     914              GOLDBUTTONX,          // starting x position
     915              GOLDBUTTONY,          // starting y position
     916              GOLDBUTTONWIDTH,      // button width
     917              GOLDBUTTONHEIGHT,     // button height
     918              MainWindow,           // parent window
     919              NULL,                 // No menu
     920              Instance,
     921              NULL);                // pointer not needed
     922
     923  Silver = CreateWindow("BUTTON",             // predefined class
     924            "Silver Version",     // button text
     925            WS_VISIBLE | WS_CHILD | WS_TABSTOP | BS_PUSHBUTTON, // styles
     926            SILVERBUTTONX,        // starting x position
     927            SILVERBUTTONY,        // starting y position
     928            SILVERBUTTONWIDTH,    // button width
     929            SILVERBUTTONHEIGHT,   // button height
     930            MainWindow,           // parent window
     931            NULL,                 // No menu
     932            Instance,
     933            NULL);                // pointer not needed
     934
     935  SetFocus (Gold);
     936
     937  statusstring = strinitstatus;
     938  paint_window (pdc, windowRect);
     939
     940  // message loop for init buttons
     941  while (!init_done) {
     942    if (PeekMessage(&Message, NULL, 0, 0, PM_REMOVE)) {
     943      if (Message.message == WM_QUIT) return Message.wParam;
     944      if (!IsDialogMessage (MainWindow, &Message)) {
     945    TranslateMessage(&Message); /* translate keyboard messages */
     946    DispatchMessage(&Message);  /* return control to Windows NT */
     947      }
     948    } else {
     949      Sleep (1);
     950    }
     951  }
     952
     953  // don't want these buttons anymore
     954  DestroyWindow (Gold);
     955  DestroyWindow (Silver);
     956
     957  statusstring = "";
     958  paint_window (pdc, windowRect);
    864959
    865960  // attempt to initialise the network
     
    9051000 
    9061001  // add the "enter library" button
    907   GoButton = CreateWindow(
    908               "BUTTON",             // predefined class
    909               "Enter Library",      // button text
    910               WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,  // styles
    911               ENTERBUTTONX,         // starting x position
    912               ENTERBUTTONY,         // starting y position
    913               ENTERBUTTONWIDTH,     // button width
    914               ENTERBUTTONHEIGHT,    // button height
    915               MainWindow,           // parent window
    916               NULL,                 // No menu
     1002  GoButton = CreateWindow("BUTTON",              // predefined class
     1003              "Enter Library",       // button text
     1004              WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // styles
     1005              ENTERBUTTONX,          // starting x position
     1006              ENTERBUTTONY,          // starting y position
     1007              ENTERBUTTONWIDTH,      // button width
     1008              ENTERBUTTONHEIGHT,     // button height
     1009              MainWindow,            // parent window
     1010              NULL,                  // No menu
    9171011              Instance,
    918               NULL);                // pointer not needed
     1012              NULL);                 // pointer not needed
     1013
     1014  SetFocus (GoButton);
    9191015 
    9201016  if (have_networking) statusstring = strenterlib;
    9211017  else statusstring = strenterstaticlib;
    9221018  paint_window (pdc, windowRect);
    923  
     1019
    9241020  // release the DC used to display the init messages
    9251021  ReleaseDC (MainWindow, pdc);
     
    9371033    if (PeekMessage(&Message, NULL, 0, 0, PM_REMOVE)) {
    9381034      if (Message.message == WM_QUIT) break;
    939       TranslateMessage(&Message); /* translate keyboard messages */
    940       DispatchMessage(&Message);  /* return control to Windows NT */
     1035      if (!IsDialogMessage (MainWindow, &Message)) {
     1036    TranslateMessage(&Message); /* translate keyboard messages */
     1037    DispatchMessage(&Message);  /* return control to Windows NT */
     1038      }
    9411039     
    9421040    } else {
Note: See TracChangeset for help on using the changeset viewer.