File: dialog.h

package info (click to toggle)
asc 2.6.1.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 81,740 kB
  • sloc: cpp: 158,704; sh: 11,544; ansic: 6,736; makefile: 604; perl: 138
file content (202 lines) | stat: -rw-r--r-- 6,464 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*! \file dialog.h
    \brief Interface for all the dialog boxes used by the game and the mapeditor
*/

/*
    This file is part of Advanced Strategic Command; http://www.asc-hq.de
    Copyright (C) 1994-2010  Martin Bickel  and  Marc Schellenberger

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; see the file COPYING. If not, write to the 
    Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
    Boston, MA  02111-1307  USA
*/

#ifndef dialogH
#define dialogH


#include <sigc++/sigc++.h>
#include "ascstring.h"
#include "dlg_box.h"
#include "password.h"
#include "typen.h"

#include "actions/actionresult.h"

const int dbluedark = 248;

// ASCString  selectFile( const ASCString& ext, bool load );

extern void displaymessage2( const char* formatstring, ... );
   
//! displays a message in the message line
extern void  dispmessage2(int id, const char * st = NULL );
extern void  dispmessage2( const ActionResult& result );
   
  
  
// extern void  statisticarmies(void);
   
// extern void  statisticbuildings(void);
   


extern Uint8 mix3colors ( int p1, int p2, int p3 );
extern Uint8 mix2colors ( int a, int b );
extern Uint8 mix4colors ( int a, int b, int c, int d );


  class   tviewanytext : public tdialogbox, public tviewtextwithscrolling {
               public:
                   const char                 *txt;
                   int              ok;
                    
                   int              scrollbarvisible;
                   int                 action;
                   
                   // int                  textsizey, textsizeycomplete;
                   int                  textstart;
                   int                  rightspace;

                   void                 init( const char* title, const char* text , int xx1 = 50, int yy1 = 50 , int xxsize = 360, int yysize = 360 );
                   virtual void         run ( void );
                   virtual void         buttonpressed( int id);
                   void                 redraw ( void );
                   int                  getcapabilities ( void ) { return 1; };
                   void                 repaintscrollbar ( void );
                };

//! the dialog box for setting up how to load bi3 graphics and maps. Since ASC now uses its own graphics, this dialog is not used any more.
extern void bi3preferences  ( void );


//! a dialog box that lets a user resize the active map. Should only be used in the mapeditor
extern void resizemap ( void );

extern void choosezoomlevel ( void );

extern void viewUnitSetinfo ( void );

/*! displays a dialog with two buttons, to select one of them

    \param title: the message text; printf style arguments allowed
    \param leftButton the text on the left button
    \param rightButton the text on the right button
    \returns 1 if the left button has been pressed; 2 if the right button has been pressed
 */
extern int   choice_dlg(const ASCString& title,
                        const ASCString& leftButton,
                        const ASCString& rightButton );



typedef class tparagraph* pparagraph;
class  tparagraph {
        public:
          tparagraph ( void );
          tparagraph ( pparagraph prv );   // f?gt einen neuen paragraph hinter prv an

          void join ( void );   // returnvalue : paragraph to delete;
          void changesize ( int newsize );

          void addchar ( char c );
          pparagraph erasechar ( int c );
          void checkcursor ( void );
          pparagraph movecursor ( int dx, int dy );
          pparagraph cut ( void );

          int  reflow( int all = 1 );
          void display ( void );

          void checkscrollup ( void );
          void checkscrolldown ( void );
          int  checkcursorpos ( void );

          void addtext ( const ASCString& txt );
          ~tparagraph ();

          void setpos ( int x1, int y1, int y2, int linepos, int linenum );

          void displaycursor ( void );
          int cursor;
          int cursorstat;
          int cursorx;
          int normcursorx;
          int cursory;
          int searchcursorpos;
          static int maxlinenum;

          int size;
          int allocated;
          char* text;

          static int winy1;
          static int winy2;
          static int winx1;
          struct {
             int line1num;
          } ps;

          dynamic_array<char*> linestart;
          dynamic_array<int>   linelength;

          int   linenum;

          pparagraph next;
          pparagraph prev;
      };


class tmessagedlg : public tdialogbox {
           protected:
               int to[8];

                pparagraph firstparagraph;
                pparagraph actparagraph;

                int tx1, ty1, tx2, ty2,ok;
                int lastcursortick;
                int blinkspeed;

            public:
                tmessagedlg ( void );
                virtual void setup ( void );
                void inserttext ( const ASCString& txt );
                void run ( void );
                ASCString extracttext ();
                ~tmessagedlg();
         };

class MultilineEdit : public tmessagedlg  {
               ASCString& text;
               ASCString dlg_title;
               bool textchanged;
            public:
               MultilineEdit ( ASCString& txt, const ASCString& title ) : text ( txt ), dlg_title ( title ), textchanged ( false ) {};
               void init ( void );
               void setup ( void );
               void buttonpressed ( int id );
               void run ( void );
               bool changed ( ) { return textchanged; };
       };

extern void selectgraphicset ( void );

extern int editInt( const ASCString& title, int defaultValue, int minValue = 0, int maxValue = maxint );


class ActionResult;
extern void displayActionError( const ActionResult& result, const ASCString& additionalInfo = "" );

#endif