Advanced Strategic Command
dlg_box.h
Go to the documentation of this file.
1 
5 /*
6  This file is part of Advanced Strategic Command; http://www.asc-hq.de
7  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
8 
9  This program is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; see the file COPYING. If not, write to the
21  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22  Boston, MA 02111-1307 USA
23 */
24 
25 #ifndef dlg_boxH
26 #define dlg_boxH
27 
28 #include "newfont.h"
29 #include "events.h"
30 #include "basegfx.h"
31 
32  #define dlg_wintitle 1
33  #define dlg_in3d 2
34  #define dlg_notitle 4
35  #define dlg_3dtitle 8
36 
37 
38  class tdlgengine {
39  protected:
40  int x1, y1, xsize, ysize;
41 
42  public:
43 
44  struct tbutton {
45  int art; /* art: 0: normaler button
46  style:
47  � 1: standard
48  � 2: mit "dauerfeuer" */
49 
50  int x1, y1, x2, y2; /* 1: texteingabefield */
51  int id; /* 2: zahleingabefield */
52  int style; /* 3: checkbox
53  style:
54  � 10 : nur einschaltbar */
55  int status; /* 4: schieberegler */
56  tbutton* next; /* 5: scrollbar */
57  const char* text;
58  void* data;
59  void* data2;
60  int min, max; // max = itemsvisible bei scrollbar
61  int active;
62 
63  int keynum;
64  tkey key[6];
65 
69  int pressed;
70  int newpressed; // nur f?r Maus-"Dauerfeuer"
71  int lasttick; // nur f?r Maus-"Dauerfeuer"
72  const char** entries; // only for drop down
73  int entrynum; // only for drop down
74  };
75 
76  typedef tbutton* pbutton;
77 
78 
79 
80  struct ttaborder {
81  int id;
83  int x1, y1, x2, y2;
84  };
85 
87 
89  int prntkey;
90 
91  void addbutton( const char * ltxt,
92  int lx1,
93  int ly1,
94  int lx2,
95  int ly2,
96  int lart,
97  int lstyle,
98  int lid,
99  bool enabled);
100  void addbutton( const char * ltxt,
101  tmouserect rect1,
102  int lart,
103  int lstyle,
104  int lid,
105  bool enabled);
106 
107  /********************************/
108  /* art: 0: Normaler Button */
109  /* 1: Texteingabefield */
110  /* 2: ZahlEingabefield */
111  /* 3: CheckBox */
112  /* 4: Schieberegler */
113  /* 5: Scrollbar */
114  /* 6: Drop Down */
115  /********************************/
116 
117 
118  void addeingabe(int lid,
119  void* data,
120  int min,
121  int max);
122 
123  void addscrollbar(int lx1,
124  int ly1,
125  int lx2,
126  int ly2,
127  int* numberofitems,
128  int itemsvisible,
129  int* actitem,
130  int lid,
131  int keys); /* 0 = keine tasten-, 1 = immer tasten-, 2= markiert tasten */
132  /* !! a scrollbar needs the two ids following lid for internal usage !! */
133  void addscrollbar( tmouserect rec,
134  int* numberofitems,
135  int itemsvisible,
136  int* actitem,
137  int lid,
138  int keys);
139 
140  void addDropDown( int x1, int y1, int x2, int y2, int ID, const char** entries, int entrynum, int* pos );
141 
142 
143  virtual void buttonpressed(int id) ;
144  virtual void showbutton(int id) = 0;
145  void clearkey ( char id );
146  void addkey(int id, tkey key);
147  void addmarkedkey( int id, tkey key);
148  pbutton getbutton ( int id );
149 
150  virtual ~tdlgengine() {};
151  };
152 typedef class tdialogbox* pdialogbox;
153 
154  class tdialogbox : public tdlgengine {
155  bool eventQueue;
156  public:
158  int starty;
159  int ms;
160  void* tp;
162  const char* title;
165  int tabcount;
166  int markedtab;
170 
171  tdialogbox();
172 
173  void init(void);
174  void buildgraphics(void);
175  virtual void changecoordinates(void) ;
176  virtual void run(void) ;
177  void done(void);
178 
179 
180  virtual Uint8 checkvalue(int id, void* p) ;
181  void editfield(pbutton pb);
182  void editfield( int id );
183  void toggleswitch(pbutton pb);
184  virtual void enablebutton(int id) ;
185  virtual void disablebutton(int id) ;
186  virtual void execbutton(pbutton pb, char mouse) ;
187  void showbutton(int id);
188  void hidebutton(int id);
189  void setscrollspeed(char id , int speed);
190  void rebuildtaborder(void);
191  void showtabmark(int b);
192 
193 
194  virtual void setclipping ( void );
195  virtual void paint ( void ); // komplettes zeichnen, mit framebuf, redraw und copy ...
196  virtual void redrawall ( void ); // l��t die aktuelle und alle darunterliegenden Boxen sich neu zeichnen
197  virtual void redrawall2 ( int xx1, int yy1, int xx2, int yy2 ); // l��t die aktuelle und bei Bedarf alle darunterliegenden Boxen sich neu zeichnen
198  virtual int getcapabilities ( void ); // Dann mu� REDRAW ?berladen werden
199  void repaintdisplay( void );
200  protected:
202  pdialogbox next;
203  pdialogbox prev;
204  static pdialogbox first;
205 
206  int dlg_mode; /* Bit 1 : redraw funktionalit�t
207  2 : zugrunde liegende Dialogboxen unterst?tzen redraw */
208 
209  virtual void redraw ( void ); // Zeichner die dialogbox in den aktuellen Puffer
210 
211  virtual void setvirtualframebuf ( void );
212  virtual void copyvirtualframebuf ( void );
213 
215  void newknopf(int xx1,
216  int yy1,
217  int xx2,
218  int yy2);
219  void knopfdruck(int xx1,
220  int yy1,
221  int xx2,
222  int yy2);
223  void knopf(int xx1,
224  int yy1,
225  int xx2,
226  int yy2);
227  void newknopfdruck4(int xx1,
228  int yy1,
229  int xx2,
230  int yy2);
231  void newknopfdruck3(int xx1,
232  int yy1,
233  int xx2,
234  int yy2);
235  void newknopfdruck2(int xx1,
236  int yy1,
237  int xx2,
238  int yy2);
239 
240  void newknopfdruck(int xx1,
241  int yy1,
242  int xx2,
243  int yy2);
244  void rahmen(bool invers,
245  int x1,
246  int y1,
247  int x2,
248  int y2);
249  void rahmen(bool invers,
250  tmouserect rect );
251 
252  void rahmen3(const char * txt,
253  int x1,
254  int y1,
255  int x2,
256  int y2,
257  int style);
258  void bar ( tmouserect rect, int color );
259  void bar ( int x1, int y1, int x2, int y2, int color );
260 
261  virtual void dispeditstring ( char* st ,
262  int x1,
263  int y1 );
264 
265  void stredit(char * s,
266  int x1,
267  int y1,
268  int wdth,
269  int max);
270 
271  virtual int gettextwdth_stredit ( char* txt,
272  pfont font );
273 
274  virtual void lne(int x1,
275  int y1,
276  char * s,
277  int position,
278  int einfuegen);
279 
280  void intedit(int * st,
281  int x1,
282  int y1,
283  int wdth,
284  int min,
285  int max);
286  void paintsurface2 ( int xx1, int yy1, int xx2, int yy2 );
287  void paintsurface ( int xx1, int yy1, int xx2, int yy2 );
288  virtual ~tdialogbox();
289  };
290 
291 
292 
300 extern void displaymessage( const char* formatstring, int num, ... );
301 
302 
310 extern void displaymessage( const ASCString& text, int num );
311 
313 extern void removemessage( void );
314 
316 extern void help( int id);
317 
319 extern void viewtext2 ( int id);
320 
321 extern int viewtextquery( int id,
322  const char * title,
323  const char * s1,
324  const char * s2);
325 
326 
327 class tviewtext {
328  protected:
329  struct tstartpoint {
330  int ypos;
334  int eeinzug;
335  int aeinzug;
336  int height;
337  const char* textpointer;
339  int xpos;
341  };
343 
344  public:
345  tviewtext();
346 
347  void setparams ( int xx1, int yy1, int xx2, int yy2, const char* ttxt, char clr, char bkgr);
348  void setpos ( int xx1, int yy1, int xx2, int yy2 );
349 
350  void displaytext ( void );
351  void evalcommand ( const char** s);
352  void nextline ( int einzug, const char* txtptr );
353  void displaysingleline ( char* t);
354  void fillline ( int x1, int x2 );
355  void setnewlineheight ( int h );
356 
362  const char* tvt_text;
363  char* actline;
367 
368  virtual ~tviewtext();
369  protected:
372  };
373 
374 
376  public:
377  void checkscrolling ( void );
379  virtual void repaintscrollbar ( void ) = 0;
380  };
381 
382 extern int actdisplayedmessage;
383 extern long lastdisplayedmessageticker ;
384 
385 
386 #define linesshown 13
387 
389  public:
390  int size;
391  tvirtualscreenbuf ( void );
392  void init ( void );
394  void* buf;
395  } ;
396 
398 extern int getplayercolor ( int i );
399 
400 extern void strrd8u(int l, char* s); // aufrunden
401 extern void strrd8d(int l, char* s); // abrunden
402 extern void strrd8n(int l, char* s); // mathematisch korrekt runden
403 extern char* strrrd8u(int l); // aufrunden
404 extern char* strrrd8d(int l); // abrunden
405 extern char* strrrd8n(int l); // mathematisch korrekt runden
406 
407 
410 extern ASCString readtextmessage( int id );
411 
412 
413 
414 class tstringselect : public tdialogbox {
415  public :
416  char txt[2000];
417  int ok;
419  int dk;
422  void init(void);
423  tstringselect ( );
424  virtual void setup(void);
425  virtual void run(void);
426  virtual void buttonpressed(int id);
427  void scrollbar_on(void);
428  void viewtext(void);
429  virtual void resettextfield(void);
430  virtual void get_text( int nr);
431  void done(void);
432  };
433 
434 
435 
436 extern int getid( const char* title, int lval, int min, int max );
437 extern ASCString editString( const ASCString& title, const ASCString& defaultValue = "" );
438 
439 
440 
447 extern int chooseString ( const ASCString& title, const vector<ASCString>& entries, int defaultEntry = -1 );
448 
456 extern pair<int,int> chooseString ( const ASCString& title, const vector<ASCString>& entries, const vector<ASCString>& buttons, int defaultEntry = -1 );
457 
458 #endif
459 
void intedit(int *st, int x1, int y1, int wdth, int min, int max)
Definition: dlg_box.cpp:2252
int startpos
Definition: dlg_box.h:420
int mouseselect
Definition: dlg_box.h:420
tbutton * next
Definition: dlg_box.h:56
int boxstatus
Definition: dlg_box.h:168
const char ** entries
Definition: dlg_box.h:72
void showtabmark(int b)
Definition: dlg_box.cpp:1470
virtual void setvirtualframebuf(void)
Definition: dlg_box.cpp:247
int x1
Definition: dlg_box.h:40
void viewtext2(int id)
displays a dialogbog with the given message
Definition: dlg_box.cpp:3296
int numberoflines
Definition: dlg_box.h:420
pbutton firstbutton
Definition: dlg_box.h:86
int markedtab
Definition: dlg_box.h:166
virtual void get_text(int nr)
Definition: dlg_box.cpp:3574
int dlg_mode
Definition: dlg_box.h:206
void paintsurface2(int xx1, int yy1, int xx2, int yy2)
Definition: dlg_box.cpp:2492
virtual void showbutton(int id)=0
virtual ~tdialogbox()
Definition: dlg_box.cpp:2511
static pdialogbox first
Definition: dlg_box.h:204
void fillline(int x1, int x2)
Definition: dlg_box.cpp:2574
virtual int getcapabilities(void)
Definition: dlg_box.cpp:180
int aeinzug
Definition: dlg_box.h:360
int viewtextquery(int id, const char *title, const char *s1, const char *s2)
Definition: dlg_box.cpp:3394
long lastdisplayedmessageticker
Definition: dlg_box.cpp:98
char * strrrd8n(int l)
Definition: dlg_box.cpp:87
virtual void copyvirtualframebuf(void)
Definition: dlg_box.cpp:261
void init(void)
Definition: dlg_box.cpp:3424
const char * text
Definition: dlg_box.h:57
int y1
Definition: dlg_box.h:40
virtual void run(void)
Definition: dlg_box.cpp:1477
void clearkey(char id)
Definition: dlg_box.cpp:762
int ms
Definition: dlg_box.h:159
void help(int id)
displays a dialogbog with the given help topic
Definition: dlg_box.cpp:3286
int defaulttextcolor
Definition: dlg_box.h:371
void rahmen3(const char *txt, int x1, int y1, int x2, int y2, int style)
Definition: dlg_box.cpp:1718
virtual Uint8 checkvalue(int id, void *p)
Definition: dlg_box.cpp:1644
virtual void buttonpressed(int id)
Definition: dlg_box.cpp:369
pdialogbox next
Definition: dlg_box.h:202
const char * tvt_text
Definition: dlg_box.h:362
int starty
Definition: dlg_box.h:158
int xsize
Definition: dlg_box.h:40
void paintsurface(int xx1, int yy1, int xx2, int yy2)
Definition: dlg_box.cpp:2501
void rahmen(bool invers, int x1, int y1, int x2, int y2)
Definition: dlgraph.cpp:97
int tvt_starty
Definition: dlg_box.h:357
void buildgraphics(void)
Definition: dlg_box.cpp:1180
void newknopf(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:180
int tabcount
Definition: dlg_box.h:165
void knopfdruck(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:134
int actdisplayedmessage
Definition: dlg_box.cpp:97
tstartpoint * pstartpoint
Definition: dlg_box.h:342
int tvt_x1
Definition: dlg_box.h:357
int tvt_firstlinebufheight
Definition: dlg_box.h:366
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
virtual void lne(int x1, int y1, char *s, int position, int einfuegen)
Definition: dlg_box.cpp:2226
void addscrollbar(int lx1, int ly1, int lx2, int ly2, int *numberofitems, int itemsvisible, int *actitem, int lid, int keys)
Definition: dlg_box.cpp:582
tkey taste
Definition: dlg_box.h:88
void displaymessage(const char *formatstring, int num,...)
displays a dialog box with a message
Definition: dlg_box.cpp:1849
void hidebutton(int id)
Definition: dlg_box.cpp:742
int ysize
Definition: dlg_box.h:40
int knopfsuccessful
Definition: dlg_box.h:214
void done(void)
Definition: dlg_box.cpp:3617
virtual void repaintscrollbar(void)=0
int imagesaved
Definition: dlg_box.h:161
int getplayercolor(int i)
Definition: dlg_box.cpp:303
int tvt_x2
Definition: dlg_box.h:357
void newknopfdruck4(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:283
int tvt_background
Definition: dlg_box.h:358
virtual void dispeditstring(char *st, int x1, int y1)
Definition: dlg_box.cpp:1989
int firstvisibleline
Definition: dlg_box.h:420
int disablecolor
Definition: dlg_box.h:167
void evalcommand(const char **s)
Definition: dlg_box.cpp:2826
tkey markedkey[6]
Definition: dlg_box.h:67
int tvt_yp
Definition: dlg_box.h:357
void done(void)
Definition: dlg_box.cpp:1235
int tvt_y2
Definition: dlg_box.h:357
int windowstyle
Definition: dlg_box.h:163
void toggleswitch(pbutton pb)
Definition: dlg_box.cpp:1618
virtual void redrawall(void)
Definition: dlg_box.cpp:224
char txt[2000]
Definition: dlg_box.h:416
static collategraphicoperations * pcgo
Definition: dlg_box.h:169
int tvt_xp
Definition: dlg_box.h:357
tbutton * pbutton
Definition: dlg_box.h:76
virtual ~tviewtext()
Definition: dlg_box.cpp:2971
virtual int gettextwdth_stredit(char *txt, pfont font)
Definition: dlg_box.cpp:2220
int tvt_y1
Definition: dlg_box.h:357
virtual void setup(void)
Definition: dlg_box.cpp:3471
void knopf(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:122
pstartpoint tvt_startpoint
Definition: dlg_box.h:370
int scrollbarvisible
Definition: dlg_box.h:421
class tdialogbox * pdialogbox
Definition: dlg_box.h:152
void addbutton(const char *ltxt, int lx1, int ly1, int lx2, int ly2, int lart, int lstyle, int lid, bool enabled)
Definition: dlg_box.cpp:471
tgraphmodeparameters tvt_firstlinebufparm
Definition: dlg_box.h:365
virtual ~tdlgengine()
Definition: dlg_box.h:150
void strrd8u(int l, char *s)
Definition: dlg_box.cpp:62
void init(void)
Definition: dlg_box.cpp:110
virtual void disablebutton(int id)
Definition: dlg_box.cpp:993
void rebuildtaborder(void)
Definition: dlg_box.cpp:651
int tvt_color
Definition: dlg_box.h:358
void addDropDown(int x1, int y1, int x2, int y2, int ID, const char **entries, int entrynum, int *pos)
Definition: dlg_box.cpp:548
pbutton getbutton(int id)
Definition: dlg_box.cpp:361
void viewtext(void)
Definition: dlg_box.cpp:3586
const char * textpointer
Definition: dlg_box.h:337
void setpos(int xx1, int yy1, int xx2, int yy2)
Definition: dlg_box.cpp:2657
void bar(tmouserect rect, int color)
Definition: dlg_box.cpp:537
char * strrrd8d(int l)
Definition: dlg_box.cpp:73
ttaborder taborder[100]
Definition: dlg_box.h:164
void newknopfdruck3(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:260
void editfield(pbutton pb)
Definition: dlg_box.cpp:1662
void addkey(int id, tkey key)
Definition: dlg_box.cpp:774
void repaintdisplay(void)
Definition: dlg_box.cpp:188
virtual void paint(void)
Definition: dlg_box.cpp:292
void strrd8n(int l, char *s)
Definition: dlg_box.cpp:67
void addmarkedkey(int id, tkey key)
Definition: dlg_box.cpp:793
int getid(const char *title, int lval, int min, int max)
Definition: dlg_box.cpp:3701
int prntkey
Definition: dlg_box.h:89
void checkscrolling(void)
Definition: dlg_box.cpp:2982
void setscrollspeed(char id, int speed)
Definition: dlg_box.cpp:814
void * tp
Definition: dlg_box.h:160
void displaytext(void)
Definition: dlg_box.cpp:2693
int tkey
Definition: events.h:126
void removemessage(void)
closes a message dialog box that has been opened by displaymessage()
Definition: dlg_box.cpp:1976
basegfx.h is the interface for the legacy graphic routines (of which some are platform dependent)...
char * strrrd8u(int l)
Definition: dlg_box.cpp:80
virtual void execbutton(pbutton pb, char mouse)
Definition: dlg_box.cpp:1266
int textcolor
Definition: dlg_box.h:157
void strrd8d(int l, char *s)
Definition: dlg_box.cpp:57
int virtualbufoffset
Definition: dlg_box.h:201
virtual void redraw(void)
Definition: dlg_box.cpp:1113
tbutton * button
Definition: dlg_box.h:82
void setparams(int xx1, int yy1, int xx2, int yy2, const char *ttxt, char clr, char bkgr)
Definition: dlg_box.cpp:2665
pdialogbox prev
Definition: dlg_box.h:203
void newknopfdruck2(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:194
virtual void redrawall2(int xx1, int yy1, int xx2, int yy2)
Definition: dlg_box.cpp:233
void setnewlineheight(int h)
Definition: dlg_box.cpp:2547
char * tvt_firstlinebuf
Definition: dlg_box.h:364
int eeinzug
Definition: dlg_box.h:360
int tvt_dispactive
Definition: dlg_box.h:359
void newknopfdruck(int xx1, int yy1, int xx2, int yy2)
Definition: dlgraph.cpp:302
virtual void enablebutton(int id)
Definition: dlg_box.cpp:860
int tvt_maxlineheight
Definition: dlg_box.h:361
ASCString editString(const ASCString &title, const ASCString &defaultValue="")
Definition: dlg_box.cpp:3894
void init(void)
Definition: dlg_box.cpp:314
tstartpoint * next
Definition: dlg_box.h:338
const T & max(const T &a, const T &b, const T &c)
Definition: misc.h:97
const T & min(const T &a, const T &b, const T &c)
Definition: misc.h:80
tvirtualscreenbuf(void)
Definition: dlg_box.cpp:104
ASCString readtextmessage(int id)
returns the message with the given ID from the message system.
Definition: dlg_box.cpp:3048
virtual void buttonpressed(int id)
Definition: dlg_box.cpp:3476
a graphical surface.
Definition: basegfx.h:51
virtual void changecoordinates(void)
Definition: dlg_box.cpp:356
char * actline
Definition: dlg_box.h:363
void addeingabe(int lid, void *data, int min, int max)
Definition: dlg_box.cpp:833
void scrollbar_on(void)
Definition: dlg_box.cpp:3579
virtual void run(void)
Definition: dlg_box.cpp:3487
Collects all graphic operations and updates the screen on destruction When porting ASC from DOS to SD...
Definition: basegfx.h:406
void displaysingleline(char *t)
Definition: dlg_box.cpp:2622
virtual void setclipping(void)
Definition: dlg_box.cpp:254
void nextline(int einzug, const char *txtptr)
Definition: dlg_box.cpp:2592
void showbutton(int id)
Definition: dlg_box.cpp:707
int chooseString(const ASCString &title, const vector< ASCString > &entries, int defaultEntry=-1)
displays a dialogbox which lets you choose one of a number of strings.
Definition: dlg_box.cpp:3788
const char * title
Definition: dlg_box.h:162
tvirtualscreenbuf virtualscreenbuf
Definition: dlg_box.cpp:101
void stredit(char *s, int x1, int y1, int wdth, int max)
Definition: dlg_box.cpp:1995
Definition: newfont.h:150
virtual void resettextfield(void)
Definition: dlg_box.cpp:3568