Advanced Strategic Command
dialog.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 dialogH
26 #define dialogH
27 
28 
29 #include <sigc++/sigc++.h>
30 #include "ascstring.h"
31 #include "dlg_box.h"
32 #include "password.h"
33 #include "typen.h"
34 
35 #include "actions/actionresult.h"
36 
37 const int dbluedark = 248;
38 
39 // ASCString selectFile( const ASCString& ext, bool load );
40 
41 extern void displaymessage2( const char* formatstring, ... );
42 
44 extern void dispmessage2(int id, const char * st = NULL );
45 extern void dispmessage2( const ActionResult& result );
46 
47 
48 
49 // extern void statisticarmies(void);
50 
51 // extern void statisticbuildings(void);
52 
53 
54 
55 extern Uint8 mix3colors ( int p1, int p2, int p3 );
56 extern Uint8 mix2colors ( int a, int b );
57 extern Uint8 mix4colors ( int a, int b, int c, int d );
58 
59 
61  public:
62  const char *txt;
63  int ok;
64 
66  int action;
67 
68  // int textsizey, textsizeycomplete;
69  int textstart;
71 
72  void init( const char* title, const char* text , int xx1 = 50, int yy1 = 50 , int xxsize = 360, int yysize = 360 );
73  virtual void run ( void );
74  virtual void buttonpressed( int id);
75  void redraw ( void );
76  int getcapabilities ( void ) { return 1; };
77  void repaintscrollbar ( void );
78  };
79 
81 extern void bi3preferences ( void );
82 
83 
85 extern void resizemap ( void );
86 
87 extern void choosezoomlevel ( void );
88 
89 extern void viewUnitSetinfo ( void );
90 
98 extern int choice_dlg(const ASCString& title,
99  const ASCString& leftButton,
100  const ASCString& rightButton );
101 
102 
103 
104 typedef class tparagraph* pparagraph;
105 class tparagraph {
106  public:
107  tparagraph ( void );
108  tparagraph ( pparagraph prv ); // f?gt einen neuen paragraph hinter prv an
109 
110  void join ( void ); // returnvalue : paragraph to delete;
111  void changesize ( int newsize );
112 
113  void addchar ( char c );
114  pparagraph erasechar ( int c );
115  void checkcursor ( void );
116  pparagraph movecursor ( int dx, int dy );
117  pparagraph cut ( void );
118 
119  int reflow( int all = 1 );
120  void display ( void );
121 
122  void checkscrollup ( void );
123  void checkscrolldown ( void );
124  int checkcursorpos ( void );
125 
126  void addtext ( const ASCString& txt );
127  ~tparagraph ();
128 
129  void setpos ( int x1, int y1, int y2, int linepos, int linenum );
130 
131  void displaycursor ( void );
132  int cursor;
134  int cursorx;
136  int cursory;
138  static int maxlinenum;
139 
140  int size;
142  char* text;
143 
144  static int winy1;
145  static int winy2;
146  static int winx1;
147  struct {
148  int line1num;
149  } ps;
150 
153 
154  int linenum;
155 
156  pparagraph next;
157  pparagraph prev;
158  };
159 
160 
161 class tmessagedlg : public tdialogbox {
162  protected:
163  int to[8];
164 
165  pparagraph firstparagraph;
166  pparagraph actparagraph;
167 
168  int tx1, ty1, tx2, ty2,ok;
171 
172  public:
173  tmessagedlg ( void );
174  virtual void setup ( void );
175  void inserttext ( const ASCString& txt );
176  void run ( void );
178  ~tmessagedlg();
179  };
180 
181 class MultilineEdit : public tmessagedlg {
182  ASCString& text;
183  ASCString dlg_title;
184  bool textchanged;
185  public:
186  MultilineEdit ( ASCString& txt, const ASCString& title ) : text ( txt ), dlg_title ( title ), textchanged ( false ) {};
187  void init ( void );
188  void setup ( void );
189  void buttonpressed ( int id );
190  void run ( void );
191  bool changed ( ) { return textchanged; };
192  };
193 
194 extern void selectgraphicset ( void );
195 
196 extern int editInt( const ASCString& title, int defaultValue, int minValue = 0, int maxValue = maxint );
197 
198 
199 class ActionResult;
200 extern void displayActionError( const ActionResult& result, const ASCString& additionalInfo = "" );
201 
202 #endif
int rightspace
Definition: dialog.h:70
tmessagedlg(void)
Definition: dialog.cpp:1918
pparagraph cut(void)
Definition: dialog.cpp:1629
int size
Definition: dialog.h:140
int action
Definition: dialog.h:66
void buttonpressed(int id)
Definition: dialog.cpp:2126
void run(void)
Definition: dialog.cpp:2136
int checkcursorpos(void)
Definition: dialog.cpp:1606
void setpos(int x1, int y1, int y2, int linepos, int linenum)
Definition: dialog.cpp:1874
void setup(void)
Definition: dialog.cpp:2105
int lastcursortick
Definition: dialog.h:169
int ok
Definition: dialog.h:168
A class for holding, encoding and comparing passwords.
void changesize(int newsize)
Definition: dialog.cpp:1496
Uint8 mix2colors(int a, int b)
int scrollbarvisible
Definition: dialog.h:65
tparagraph(void)
Definition: dialog.cpp:1436
class tparagraph * pparagraph
Definition: dialog.h:104
int line1num
Definition: dialog.h:148
int cursor
Definition: dialog.h:132
const int dbluedark
Definition: dialog.h:37
int allocated
Definition: dialog.h:141
int ty2
Definition: dialog.h:168
Interface for some basic classes from which all of ASC's dialogs are derived.
pparagraph firstparagraph
Definition: dialog.h:165
int normcursorx
Definition: dialog.h:135
int blinkspeed
Definition: dialog.h:170
int tx2
Definition: dialog.h:168
void choosezoomlevel(void)
Definition: dialog.cpp:1324
void addchar(char c)
Definition: dialog.cpp:1553
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
Uint8 mix3colors(int p1, int p2, int p3)
int ty1
Definition: dialog.h:168
int choice_dlg(const ASCString &title, const ASCString &leftButton, const ASCString &rightButton)
Definition: dialog.cpp:616
void resizemap(void)
a dialog box that lets a user resize the active map. Should only be used in the mapeditor ...
Definition: dialog.cpp:1256
virtual void run(void)
Definition: dialog.cpp:1009
virtual void buttonpressed(int id)
Definition: dialog.cpp:999
struct tparagraph::@7 ps
int cursorstat
Definition: dialog.h:133
pparagraph actparagraph
Definition: dialog.h:166
int tx1
Definition: dialog.h:168
void inserttext(const ASCString &txt)
Definition: dialog.cpp:1925
int linenum
Definition: dialog.h:154
void run(void)
Definition: dialog.cpp:1971
void displaymessage2(const char *formatstring,...)
displays a message in the status line of ASC
dynamic_array< int > linelength
Definition: dialog.h:152
static int maxlinenum
Definition: dialog.h:138
static int winx1
Definition: dialog.h:146
int reflow(int all=1)
Definition: dialog.cpp:1679
int textstart
Definition: dialog.h:69
int editInt(const ASCString &title, int defaultValue, int minValue=0, int maxValue=maxint)
Definition: dialog.cpp:2163
int cursorx
Definition: dialog.h:134
bool changed()
Definition: dialog.h:191
Uint8 mix4colors(int a, int b, int c, int d)
void bi3preferences(void)
the dialog box for setting up how to load bi3 graphics and maps. Since ASC now uses its own graphics...
Definition: dialog.cpp:1124
void display(void)
Definition: dialog.cpp:1883
MultilineEdit(ASCString &txt, const ASCString &title)
Definition: dialog.h:186
void displaycursor(void)
Definition: dialog.cpp:1852
void checkscrolldown(void)
Definition: dialog.cpp:1663
void viewUnitSetinfo(void)
Definition: dialog.cpp:1367
static int winy2
Definition: dialog.h:145
int to[8]
Definition: dialog.h:163
int searchcursorpos
Definition: dialog.h:137
#define maxint
Definition: typen.h:462
void init(void)
Definition: dlg_box.cpp:314
void checkscrollup(void)
Definition: dialog.cpp:1652
void dispmessage2(int id, const char *st=NULL)
displays a message in the message line
Definition: dialog.cpp:472
void init(void)
Definition: dialog.cpp:2069
void redraw(void)
Definition: dialog.cpp:975
void addtext(const ASCString &txt)
Definition: dialog.cpp:1530
pparagraph movecursor(int dx, int dy)
Definition: dialog.cpp:1784
pparagraph prev
Definition: dialog.h:157
static int winy1
Definition: dialog.h:144
dynamic_array< char * > linestart
Definition: dialog.h:151
const char * txt
Definition: dialog.h:62
int getcapabilities(void)
Definition: dialog.h:76
void displayActionError(const ActionResult &result, const ASCString &additionalInfo="")
Definition: dialog.cpp:2168
void join(void)
Definition: dialog.cpp:1512
char * text
Definition: dialog.h:142
void selectgraphicset(void)
Definition: dialog.cpp:2151
virtual void setup(void)
Definition: dialog.cpp:2032
pparagraph next
Definition: dialog.h:156
int cursory
Definition: dialog.h:136
pparagraph erasechar(int c)
Definition: dialog.cpp:1573
const char * title
Definition: dlg_box.h:162
void checkcursor(void)
Definition: dialog.cpp:1540
int ok
Definition: dialog.h:63
void repaintscrollbar(void)
Definition: dialog.cpp:969
ASCString extracttext()
Definition: dialog.cpp:2008