home *** CD-ROM | disk | FTP | other *** search
/ Informática Multimedia: Special Games / INFESPGAMES.mdf / os2 / spl / src / bookwin.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-26  |  4.4 KB  |  135 lines

  1. /* bookwin.hpp:  header for book windows
  2.  
  3.     Copyright (C) 1993, 1994 John-Marc Chandonia
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. */
  20.  
  21. // some messages sent between book windows and their object windows
  22. #define WM_USER_ACK WM_USER
  23. #define WM_USER_LOAD WM_USER+1
  24. #define WM_USER_SHOW_MASTER WM_USER+2
  25. #define WM_USER_LOAD_MASTER WM_USER+3
  26. #define WM_USER_SAVE WM_USER+4
  27. #define WM_USER_CREATE_SUBSET WM_USER+6
  28. #define WM_USER_DETAILS_FIELDS WM_USER+7
  29. #define WM_USER_SORT WM_USER+8
  30.  
  31. // flags defining fields to show in details view
  32. #define FL_LEVEL 1
  33. #define FL_CAST 2
  34. #define FL_RANGE 4
  35. #define FL_DURATION 8
  36. #define FL_AREA 16
  37. #define FL_SPHERESCHOOL 32
  38. #define FL_COMPONENTS 64
  39. #define FL_SAVE 128
  40.  
  41. // a spellbook window class 
  42. class bookwindow {
  43. public:
  44.     // handles for all relevant windows 
  45.     HWND hwnd;  // main window
  46.     HWND hwndframe;  // frame window
  47.     HWND hwndcnr;  // container window
  48.     HWND hwndobject; // object window.
  49.     HWND hwndpopup; // popup menu
  50.     HWND hwndsppopup; // popup menu when on a spell
  51.  
  52.     // object thread
  53.     TID tidobject;
  54.     boolean busy;
  55.  
  56.     // one spellbook per window.
  57.     spellbook *sb;
  58.     char *filename; // file it was read from, if applicable
  59.  
  60.     boolean readonly;  // is is changeable?
  61.     boolean saved;  // has it been saved since last change?
  62.     boolean master_list_win;  // is it the master list?
  63.  
  64.     // maintain double linked list 
  65.     bookwindow *next;
  66.     bookwindow *prev;
  67.  
  68.     // new book with a certain name
  69.     bookwindow(char *bookname="New Spellbook");
  70.     // new book, read from a file
  71.     bookwindow(char *filename, boolean is_master);
  72.     void init(char *bookname); // called by both constructors
  73.     ~bookwindow();
  74.  
  75.     // show container in current mode
  76.     ULONG view; // name, icon, text, or detailed
  77.     ULONG miniicon; // container shows mini icons
  78.     LONG splitbarpos; // position of split bar in details mode
  79.     ULONG details_fields; // fields to show in details view.
  80.     PFIELDINFO pfieldinfo; // pointer to actual allocated fields.
  81.     void query_splitbar(); // record new splitbarpos
  82.     void show();
  83.     char *fontname;
  84.     void load_attr(); // load the above from INI or EA
  85.     void save_attr(); // save these to INI or EA
  86.  
  87.     void disable(); // make the window busy and inactive
  88.     void enable(); // restore window
  89.  
  90.     boolean save_book(boolean just_titles);
  91.     boolean set_spellbook(spellbook *);
  92.     boolean sort_book(ULONG sortorder);
  93.  
  94.     boolean insert_fields();
  95.     void show_fields();  // show fields specified in details_fields
  96.     boolean add_spell(spell *s, spellrecord *where=NULL);
  97.     boolean add_all_spells(spellbook *x, spellrecord *where=NULL);
  98.     boolean add_new_spell();
  99.     boolean delete_spell(spellrecord *s);
  100.     boolean delete_selected_spells();
  101.     boolean change_spell(spell *oldsp, spell *newsp);
  102.     boolean refresh();  // redraw the window after adding or deleting spells.
  103. };
  104.  
  105. // attributes saved with each window, in EA or INI
  106. class book_attr {
  107.   public:
  108.     ULONG view, miniicon;
  109.     LONG splitbarpos;
  110.     SHORT x, cx, y, cy;
  111.     ULONG foregroundcolor, backgroundcolor;
  112.     char fontnamesize[128];
  113.     ULONG details_fields;
  114. };
  115.  
  116. #define spbclass "Bookwindow"
  117. #define spbobjclass "Bookwindow Thread 2"
  118.  
  119. // routines to be called from outside
  120. boolean load_book();
  121. void change_all(spell *old_spell, spell *mod_spell);
  122. void find_and_show_spell(bookwindow *mywin, spell *s);
  123. boolean create_subset(bookwindow *mywin,HWND dlg);
  124.  
  125. // client & object window procedures
  126. MRESULT EXPENTRY book_window_func(HWND hwnd, ULONG msg, 
  127.                   MPARAM param1, MPARAM param2);
  128. MRESULT EXPENTRY object_window_func(HWND hwnd, ULONG msg, 
  129.                     MPARAM param1, MPARAM param2);
  130.  
  131. // object thread procedure
  132. void _Optlink threadmain(void *);
  133.  
  134.  
  135.