OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
messagebox.hpp
Go to the documentation of this file.
1 #ifndef MWGUI_MESSAGE_BOX_H
2 #define MWGUI_MESSAGE_BOX_H
3 
4 #include "windowbase.hpp"
5 
6 #undef MessageBox
7 
8 namespace MyGUI
9 {
10  class Widget;
11  class Button;
12  class EditBox;
13 }
14 
15 namespace MWGui
16 {
17  class InteractiveMessageBox;
18  class MessageBoxManager;
19  class MessageBox;
21  {
22  public:
23  MessageBoxManager (float timePerChar);
25  void onFrame (float frameDuration);
26  void createMessageBox (const std::string& message, bool stat = false);
27  void removeStaticMessageBox ();
28  bool createInteractiveMessageBox (const std::string& message, const std::vector<std::string>& buttons);
30 
32  void clear();
33 
34  bool removeMessageBox (MessageBox *msgbox);
35 
37  int readPressedButton (bool reset=true);
38 
39  typedef MyGUI::delegates::CMultiDelegate1<int> EventHandle_Int;
40 
41  // Note: this delegate unassigns itself after it was fired, i.e. works once.
43 
44  void onButtonPressed(int button) { eventButtonPressed(button); eventButtonPressed.clear(); }
45 
46  private:
47  std::vector<MessageBox*> mMessageBoxes;
52  };
53 
54  class MessageBox : public Layout
55  {
56  public:
57  MessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message);
58  void setMessage (const std::string& message);
59  int getHeight ();
60  void update (int height);
61 
62  float mCurrentTime;
63  float mMaxTime;
64 
65  protected:
67  const std::string& mMessage;
68  MyGUI::EditBox* mMessageWidget;
71  };
72 
74  {
75  public:
76  InteractiveMessageBox (MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector<std::string>& buttons);
77  void mousePressed (MyGUI::Widget* _widget);
78  int readPressedButton ();
79 
81 
82  private:
83  void buttonActivated (MyGUI::Widget* _widget);
84  void onKeyPressed(MyGUI::Widget* _sender, MyGUI::KeyCode _key, MyGUI::Char _char);
85 
87  MyGUI::EditBox* mMessageWidget;
88  MyGUI::Widget* mButtonsWidget;
89  std::vector<MyGUI::Button*> mButtons;
90 
92  };
93 
94 }
95 
96 #endif
float mMaxTime
Definition: messagebox.hpp:63
void message(CodeContainer &code, Literals &literals, const std::string &message, int buttons)
Definition: generator.cpp:537
~MessageBoxManager()
Definition: messagebox.cpp:28
MyGUI::Widget * mButtonsWidget
Definition: messagebox.hpp:88
void onKeyPressed(MyGUI::Widget *_sender, MyGUI::KeyCode _key, MyGUI::Char _char)
Definition: messagebox.cpp:370
MessageBox(MessageBoxManager &parMessageBoxManager, const std::string &message)
Definition: messagebox.cpp:165
Definition: messagebox.hpp:73
bool removeMessageBox(MessageBox *msgbox)
Definition: messagebox.cpp:139
MyGUI::EditBox * mMessageWidget
Definition: messagebox.hpp:87
bool isInteractiveMessageBox()
Definition: messagebox.cpp:133
void onFrame(float frameDuration)
Definition: messagebox.cpp:54
void mousePressed(MyGUI::Widget *_widget)
Definition: messagebox.cpp:376
void removeStaticMessageBox()
Definition: messagebox.cpp:112
Definition: messagebox.hpp:20
InteractiveMessageBox * mInterMessageBoxe
Definition: messagebox.hpp:48
MessageBoxManager(float timePerChar)
Definition: messagebox.cpp:20
MessageBoxManager & mMessageBoxManager
Definition: messagebox.hpp:86
int mBottomPadding
Definition: messagebox.hpp:69
int readPressedButton()
Definition: messagebox.cpp:398
void update(int height)
Definition: messagebox.cpp:181
const std::string & mMessage
Definition: messagebox.hpp:67
InteractiveMessageBox(MessageBoxManager &parMessageBoxManager, const std::string &message, const std::vector< std::string > &buttons)
Definition: messagebox.cpp:198
Definition: messagebox.hpp:54
int mNextBoxPadding
Definition: messagebox.hpp:70
EventHandle_Int eventButtonPressed
Definition: messagebox.hpp:42
void onButtonPressed(int button)
Definition: messagebox.hpp:44
bool createInteractiveMessageBox(const std::string &message, const std::vector< std::string > &buttons)
Definition: messagebox.cpp:118
int mButtonPressed
Definition: messagebox.hpp:91
bool mMarkedToDelete
Definition: messagebox.hpp:80
void setMessage(const std::string &message)
void buttonActivated(MyGUI::Widget *_widget)
Definition: messagebox.cpp:381
MyGUI::EditBox * mMessageWidget
Definition: messagebox.hpp:68
Definition: layout.hpp:13
float mMessageBoxSpeed
Definition: messagebox.hpp:50
int mLastButtonPressed
Definition: messagebox.hpp:51
float mCurrentTime
Definition: messagebox.hpp:62
MessageBox * mStaticMessageBox
Definition: messagebox.hpp:49
int getHeight()
Definition: messagebox.cpp:191
void createMessageBox(const std::string &message, bool stat=false)
Definition: messagebox.cpp:87
MyGUI::delegates::CMultiDelegate1< int > EventHandle_Int
Definition: messagebox.hpp:39
void clear()
Remove all message boxes.
Definition: messagebox.cpp:37
std::vector< MessageBox * > mMessageBoxes
Definition: messagebox.hpp:47
KeyCode
Keyboard scan codes.
Definition: OISCompat.hpp:10
std::vector< MyGUI::Button * > mButtons
Definition: messagebox.hpp:89
int readPressedButton(bool reset=true)
Definition: messagebox.cpp:154
Definition: windowbase.hpp:41
MessageBoxManager & mMessageBoxManager
Definition: messagebox.hpp:66