Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

dlg_box.h

Go to the documentation of this file.
00001 
00005 /*
00006     This file is part of Advanced Strategic Command; http://www.asc-hq.de
00007     Copyright (C) 1994-1999  Martin Bickel  and  Marc Schellenberger
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU General Public License for more details.
00018 
00019     You should have received a copy of the GNU General Public License
00020     along with this program; see the file COPYING. If not, write to the 
00021     Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
00022     Boston, MA  02111-1307  USA
00023 */
00024 
00025 #ifndef dlg_boxH
00026 #define dlg_boxH
00027 
00028 #include "newfont.h"
00029 #include "events.h"
00030 #include "basegfx.h"
00031 
00032   #define dlg_wintitle 1  
00033   #define dlg_in3d 2  
00034   #define dlg_notitle 4  
00035   #define dlg_3dtitle 8
00036 
00037 
00038   class   tdlgengine {
00039                  protected:
00040                     int              x1, y1, xsize, ysize;
00041 
00042                  public:
00043 
00044                     struct tbutton {
00045                                int  art;                   /*  art:  0: normaler button
00046                                                                                   style:
00047                                                                                     � 1:   standard
00048                                                                                     � 2:   mit "dauerfeuer"  */
00049 
00050                                int      x1, y1, x2, y2;              /*  1: texteingabefield  */
00051                                int id;                          /*  2: zahleingabefield  */
00052                                int style;                       /*  3: checkbox
00053                                                                                   style:
00054                                                                                      � 10 : nur einschaltbar */
00055                                int status;                      /*  4: schieberegler    */
00056                                tbutton*      next;                        /*  5: scrollbar        */
00057                                const char*  text;
00058                                void*      data;
00059                                void*      data2;
00060                                int      min, max;   // max = itemsvisible bei scrollbar
00061                                char      active;
00062 
00063                                int          keynum;
00064                                tkey         key[6];
00065 
00066                                int          markedkeynum;
00067                                tkey         markedkey[6];
00068                                int          scrollspeed;
00069                                char         pressed;
00070                                int          newpressed;    // nur f?r Maus-"Dauerfeuer"
00071                                int          lasttick;      //  nur f?r Maus-"Dauerfeuer"
00072                                const char** entries;       // only for drop down
00073                                int          entrynum;      // only for drop down
00074                             };
00075 
00076                     typedef tbutton* pbutton;
00077 
00078 
00079 
00080                   struct ttaborder {
00081                      int         id;
00082                      tbutton*      button;
00083                      int      x1, y1, x2, y2;
00084                   };
00085 
00086                      pbutton      firstbutton;
00087 
00088                      tkey         taste;
00089                      int          prntkey;
00090 
00091                      void         addbutton( const char *       ltxt,
00092                        int          lx1,
00093                        int          ly1,
00094                        int          lx2,
00095                        int          ly2,
00096                        int         lart,
00097                        int         lstyle,
00098                        int         lid,
00099                        char      enabled);
00100                      void         addbutton( const char *       ltxt,
00101                        tmouserect   rect1,
00102                        int         lart,
00103                        int         lstyle,
00104                        int         lid,
00105                        char      enabled);
00106 
00107                                                        /********************************/
00108                                                        /* art:  0: Normaler Button     */
00109                                                        /*       1: Texteingabefield     */
00110                                                        /*       2: ZahlEingabefield     */
00111                                                        /*       3: CheckBox            */
00112                                                        /*       4: Schieberegler       */
00113                                                        /*       5: Scrollbar           */
00114                                                        /*       6: Drop Down           */
00115                                                        /********************************/
00116 
00117 
00118                      void         addeingabe(int         lid,
00119                         void*      data,
00120                         int      min,
00121                         int      max);
00122 
00123                      void         addscrollbar(int          lx1,
00124                           int          ly1,
00125                           int          lx2,
00126                           int          ly2,
00127                           int*         numberofitems,
00128                           int          itemsvisible,
00129                           int*         actitem,
00130                           int         lid,
00131                           int         keys);  /*   0 = keine tasten-, 1 = immer tasten-, 2= markiert tasten  */
00132                                    /*   !! a scrollbar needs the two ids following lid for internal usage !!   */ 
00133                      void         addscrollbar( tmouserect rec,
00134                           int*         numberofitems,
00135                           int          itemsvisible,
00136                           int*         actitem,
00137                           int         lid,
00138                           int         keys);
00139 
00140                      void addDropDown( int x1, int y1, int x2, int y2, int ID, const char** entries, int entrynum, int* pos );
00141 
00142 
00143                      virtual void         buttonpressed(int         id) ;
00144                      virtual void         showbutton(int         id) = 0;
00145                       void                 clearkey ( char id );
00146                       void                 addkey(int         id, tkey         key);
00147                       void                 addmarkedkey( int id, tkey         key);
00148                      pbutton getbutton ( int id );
00149 
00150                      virtual ~tdlgengine() {};
00151                   };
00152 typedef class tdialogbox* pdialogbox;
00153 
00154   class   tdialogbox : public tdlgengine  {
00155                      bool eventQueue;
00156                  public:
00157                      int             textcolor;
00158                      int          starty;
00159                      int           ms;
00160                      void*      tp;
00161                      char      imagesaved; 
00162                      const char*        title;
00163                      int         windowstyle;
00164                      ttaborder    taborder[100]; 
00165                      int         tabcount; 
00166                      int         markedtab; 
00167                      int         disablecolor; 
00168                      int          boxstatus;
00169                      static collategraphicoperations* pcgo;
00170 
00171                      tdialogbox();
00172 
00173                      void         init(void);
00174                      void         buildgraphics(void);       
00175                      virtual void   changecoordinates(void)  ;
00176                      virtual void   run(void) ;
00177                      void         done(void);
00178 
00179 
00180                       virtual char      checkvalue(int         id, void*      p)  ;
00181                       void                 editfield(pbutton      pb);
00182                       void                 editfield( int id );
00183                       void                 toggleswitch(pbutton      pb);
00184                       virtual void         enablebutton(int         id)  ;
00185                       virtual void         disablebutton(int         id)  ;
00186                       virtual void         execbutton(pbutton      pb, char      mouse) ;
00187                       void         showbutton(int         id);
00188                       void         hidebutton(int         id);
00189                       void         setscrollspeed(char        id , int  speed);
00190                       void         rebuildtaborder(void);
00191                       void         showtabmark(int         b);
00192 
00193 
00194                       virtual void setclipping ( void );
00195                       virtual void paint     ( void );    // komplettes zeichnen, mit framebuf, redraw und copy ...
00196                       virtual void redrawall ( void );    // l��t die aktuelle und alle darunterliegenden Boxen sich neu zeichnen
00197                       virtual void redrawall2 ( int xx1, int yy1, int xx2, int yy2 );    // l��t die aktuelle und bei Bedarf alle darunterliegenden Boxen sich neu zeichnen
00198                       virtual int  getcapabilities ( void );  // Dann mu� REDRAW ?berladen werden
00199                       void repaintdisplay( void );
00200               protected:
00201                       int virtualbufoffset;
00202                       pdialogbox next;
00203                       pdialogbox prev;
00204                       static pdialogbox first;
00205 
00206                       int dlg_mode;           /*            Bit 1 :  redraw funktionalit�t 
00207                                                                 2 :  zugrunde liegende Dialogboxen unterst?tzen redraw  */
00208 
00209                       virtual void redraw ( void );       // Zeichner die dialogbox in den aktuellen Puffer
00210 
00211                       virtual void setvirtualframebuf ( void );
00212                       virtual void copyvirtualframebuf ( void );
00213 
00214                       char knopfsuccessful;
00215                       void         newknopf(int      xx1,
00216                                             int      yy1,
00217                                             int      xx2,
00218                                             int      yy2);
00219                       void         knopfdruck(int      xx1,
00220                                               int      yy1,
00221                                               int      xx2,
00222                                               int      yy2);
00223                       void         knopf(int      xx1,
00224                                          int      yy1,
00225                                          int      xx2,
00226                                          int      yy2);
00227                       void         newknopfdruck4(int      xx1,
00228                                                   int      yy1,
00229                                                   int      xx2,
00230                                                   int      yy2);
00231                       void         newknopfdruck3(int      xx1,
00232                                                   int      yy1,
00233                                                   int      xx2,
00234                                                   int      yy2);
00235                       void         newknopfdruck2(int      xx1,
00236                                                   int      yy1,
00237                                                   int      xx2,
00238                                                   int      yy2);
00239 
00240                       void         newknopfdruck(int      xx1,
00241                                                  int      yy1,
00242                                                  int      xx2,
00243                                                  int      yy2);
00244                       void         rahmen(bool      invers,
00245                                           int          x1,
00246                                           int          y1,
00247                                           int          x2,
00248                                           int          y2);
00249                       void         rahmen(bool      invers,
00250                                           tmouserect   rect );
00251 
00252                       void         rahmen3(const char *       txt,
00253                                            int      x1,
00254                                            int      y1,
00255                                            int      x2,
00256                                            int      y2,
00257                                            int         style);
00258                       void         bar ( tmouserect rect, int color );
00259                       void         bar ( int x1, int y1, int x2, int y2, int color );
00260 
00261                       virtual void dispeditstring ( char* st ,
00262                                                     int   x1, 
00263                                                     int   y1 );
00264                                            
00265                       void         stredit(char *       s,
00266                                            int          x1,
00267                                            int          y1,
00268                                            int          wdth,
00269                                            int          max);
00270                                            
00271                       virtual int    gettextwdth_stredit ( char* txt, 
00272                                                            pfont font );
00273                                            
00274                       virtual void         lne(int          x1,
00275                                                int          y1,
00276                                                char *       s,
00277                                                int          position,
00278                                                char      einfuegen);
00279                                                
00280                       void         intedit(int     *    st,
00281                                            int          x1,
00282                                            int          y1,
00283                                            int          wdth,
00284                                            int          min,
00285                                            int          max);
00286                       void         paintsurface2 ( int xx1, int yy1, int xx2, int yy2 );
00287                       void         paintsurface  ( int xx1, int yy1, int xx2, int yy2 );
00288                       virtual ~tdialogbox();
00289                    };
00290 
00291 
00292 
00300 extern void displaymessage( const char* formatstring, int num, ... );
00301 
00302 
00310 extern void displaymessage( const ASCString& text, int num );
00311 
00313 extern void removemessage( void );
00314 
00316 extern void  help( int id);
00317 
00319 extern void viewtext2 ( int id);
00320 
00321 extern int  viewtextquery( int        id,
00322                            const char *       title,
00323                            const char *       s1,
00324                            const char *       s2);
00325 
00326 
00327 class tviewtext {
00328       protected:
00329          struct tstartpoint {
00330                      int ypos;
00331                      int textcolor;
00332                      int background;
00333                      pfont font;
00334                      int eeinzug;
00335                      int aeinzug;
00336                      int height;
00337                      const char* textpointer;
00338                      tstartpoint* next;
00339                      int xpos;
00340                      int maxlineheight;
00341                 };
00342          typedef tstartpoint* pstartpoint;
00343 
00344        public: 
00345          tviewtext();
00346 
00347          void setparams ( int xx1, int yy1, int xx2, int yy2, const char* ttxt, char clr, char bkgr);
00348          void setpos ( int xx1, int yy1, int xx2, int yy2 );
00349 
00350          void displaytext ( void );
00351          void evalcommand ( const char** s);
00352          void nextline ( int einzug, const char* txtptr );
00353          void displaysingleline ( char* t);
00354          void fillline ( int x1, int x2 );
00355          void setnewlineheight ( int h );
00356 
00357          int tvt_x1, tvt_y1, tvt_x2, tvt_y2, tvt_xp,  tvt_yp, tvt_starty;
00358          int tvt_color, tvt_background;
00359          int tvt_dispactive;
00360          int eeinzug, aeinzug;
00361          int tvt_maxlineheight;
00362          const char*  tvt_text;
00363          char*  actline;
00364          char*  tvt_firstlinebuf;
00365          tgraphmodeparameters tvt_firstlinebufparm;
00366          int   tvt_firstlinebufheight;
00367                      
00368          virtual ~tviewtext();
00369        protected:
00370          pstartpoint tvt_startpoint;
00371          int defaulttextcolor;
00372       };
00373 
00374 
00375 class tviewtextwithscrolling : public tviewtext {
00376         public:
00377           void checkscrolling ( void );
00378           int textsizey, textsizeycomplete;
00379           virtual void repaintscrollbar ( void ) = 0;
00380       };
00381 
00382 extern int actdisplayedmessage;
00383 extern long lastdisplayedmessageticker ;
00384 
00385 
00386 #define linesshown 13  
00387 
00388 class tvirtualscreenbuf {
00389       public:
00390         int size; 
00391         tvirtualscreenbuf ( void );
00392         void init ( void );
00393         ~tvirtualscreenbuf ();
00394         void* buf;
00395       } ;
00396 
00397 extern tvirtualscreenbuf virtualscreenbuf; 
00398 extern int getplayercolor ( int i );
00399 
00400 extern void   strrd8u(int  l, char* s);   // aufrunden
00401 extern void   strrd8d(int  l, char* s);   // abrunden
00402 extern void   strrd8n(int  l, char* s);   // mathematisch korrekt runden
00403 extern char*  strrrd8u(int  l);           // aufrunden
00404 extern char*  strrrd8d(int  l);           // abrunden
00405 extern char*  strrrd8n(int  l);           // mathematisch korrekt runden
00406 
00407 
00410 extern ASCString readtextmessage( int id );
00411 
00412 
00413 
00414 class   tstringselect : public tdialogbox {
00415                 public :
00416                      char txt[2000];
00417                      char  ok;
00418                      int sy,ey,sx,ex,action,dx;
00419                      int dk;
00420                      int msel,mouseselect,redline,lnshown,numberoflines,firstvisibleline,startpos;
00421                      char scrollbarvisible;
00422                      void init(void);
00423                      tstringselect ( );
00424                      virtual void setup(void);
00425                      virtual void run(void);
00426                      virtual void buttonpressed(int id);
00427                      void scrollbar_on(void);
00428                      void viewtext(void);
00429                      virtual void resettextfield(void);
00430                      virtual void get_text( int nr);
00431                      void done(void);
00432                  };
00433 
00434 
00435                  
00436 extern int getid( const char* title, int lval, int min, int max );
00437 extern ASCString editString( const ASCString& title, const ASCString& defaultValue = "" );
00438 
00439 
00440 
00447 extern int chooseString ( const ASCString& title, const vector<ASCString>& entries, int defaultEntry = -1 );
00448 
00456 extern pair<int,int> chooseString ( const ASCString& title, const vector<ASCString>& entries, const vector<ASCString>& buttons, int defaultEntry = -1 );
00457 
00458 #endif
00459 

Generated on Tue Jun 24 01:27:39 2008 for Advanced Strategic Command by  doxygen 1.4.2