DlgBox.hh

00001 /*
00002 ** TowBowlTactics, an adaptation of the tabletop game Blood Bowl.
00003 **
00004 ** Copyright (C) 2006 The TBT Team.
00005 **
00006 ** This program is free software; you can redistribute it and/or
00007 ** modify it under the terms of the GNU General Public License
00008 ** as published by the Free Software Foundation; either version 2
00009 ** of the License, or (at your option) any later version.
00010 **
00011 ** The complete GNU General Public Licence Notice can be found as the
00012 ** `NOTICE' file in the root directory.
00013 **
00014 ** The TBT Team consists of people listed in the `AUTHORS' file.
00015 */
00016 
00017 #ifndef DLGBOX_HH_
00018 # define DLGBOX_HH_
00019 
00020 # include "VirtualSurface.hh"
00021 # include "Sprite.hh"
00022 # include "TextSurface.hh"
00023 
00024 BEGIN_NS(sdlvisu);
00025 
00027 enum eDlgBoxIcon {
00028   eDlgError = 2,
00029   eDlgWarning = 3,
00030   eDlgQuestion = 6,
00031   eDlgInfo = 7,
00032 };
00033 
00035 enum eDlgBoxButton {
00036   eDlgBoxYesNo,
00037   eDlgBoxOk,
00038   eDlgBoxBlock,
00039 };
00040 
00041 class Game;
00042 
00047 class DialogBoxCb
00048 {
00049 public:
00050   DialogBoxCb() {}
00051   virtual ~DialogBoxCb() {}
00052 
00053   virtual void clicked(int btn_index) = 0;
00054 };
00055 
00065 class DialogBox : public VirtualSurface
00066 {
00067 public:
00068   DialogBox(Game& game);
00069   DialogBox(Game& game, enum eDlgBoxButton style, enum eDlgBoxIcon icon);
00070   virtual ~DialogBox();
00071 
00072   void setStyle(enum eDlgBoxButton style, enum eDlgBoxIcon icon);
00073   void setText(const std::string& msg);
00074   void setActionHandler(DialogBoxCb* handler);
00075 
00076   DialogBoxCb* getActionHandler();
00077 
00081   void addBlockButton(int dice_face);
00082 
00085   int addRerollLabel();
00086   
00087   virtual void enable();
00088   virtual void disable();
00089   virtual void update();
00090 
00091 private:
00092   Game& game_;
00093   DialogBoxCb* handler_;
00094 
00095   Surface bg_;
00096   TextSurface text_;
00097   Sprite icon_;
00098 
00099   // Only for eDlgBoxBlock. -->
00100   typedef std::vector<Surface*> ButtonList;
00101   ButtonList button_;
00102   // <--
00103 
00104   bool dragging_;
00105   Point drag_delta_;
00106   bool always_display_button_;
00107 };
00108 
00109 END_NS(sdlvisu);
00110 
00111 #endif /* !DLGBOX_HH_ */

Generated on Sat Jun 23 16:07:23 2007 for Stechec/TBT by  doxygen 1.4.7