00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "pgmessagebox.h"
00030 #include "pglog.h"
00031 #include "pgwindow.h"
00032 #include "pgmultilineedit.h"
00033
00034
00035 PG_MessageBox::PG_MessageBox(PG_Widget* parent, const PG_Rect& r, const std::string& windowtitle, const std::string& windowtext, const PG_Rect& btn1, const std::string& btn1text, const PG_Rect& btn2, const std::string& btn2text, PG_Label::TextAlign textalign, const std::string& style) :
00036 PG_Window(parent, r, windowtitle, MODAL) {
00037
00038 my_btnok = new PG_Button(this, btn1, btn1text);
00039 my_btnok->SetID(1);
00040 my_btnok->sigClick.connect(slot(*this, &PG_MessageBox::handleButton));
00041
00042 my_btncancel = new PG_Button(this, btn2, btn2text);
00043 my_btncancel->SetID(2);
00044 my_btncancel->sigClick.connect(slot(*this, &PG_MessageBox::handleButton));
00045
00046 Init(windowtext, textalign, style);
00047 }
00048
00049 PG_MessageBox::PG_MessageBox(PG_Widget* parent, const PG_Rect& r, const std::string& windowtitle, const std::string& windowtext, const PG_Rect& btn1, const std::string& btn1text, PG_Label::TextAlign textalign, const std::string& style) :
00050 PG_Window(parent, r, windowtitle, MODAL) {
00051
00052 my_btnok = new PG_Button(this, btn1, btn1text);
00053 my_btnok->SetID(1);
00054 my_btnok->sigClick.connect(slot(*this, &PG_MessageBox::handleButton));
00055 my_btncancel = NULL;
00056
00057 Init(windowtext, textalign, style);
00058 }
00059
00060
00061 PG_MessageBox::~PG_MessageBox() {
00062 delete my_btnok;
00063 delete my_btncancel;
00064 }
00065
00066 void PG_MessageBox::Init(const std::string& windowtext, int textalign, const std::string& style) {
00067
00068 my_textbox = new PG_MultiLineEdit(this, PG_Rect(10, 40, my_width-20, my_btnok->y - my_ypos - 40));
00069 my_textbox->SendToBack();
00070 my_textbox->SetTransparency(255);
00071 my_textbox->SetEditable(false);
00072 my_textbox->SetText(windowtext);
00073
00074 my_msgalign = textalign;
00075
00076 LoadThemeStyle(style);
00077 }
00078
00079 void PG_MessageBox::LoadThemeStyle(const std::string& widgettype) {
00080 PG_Window::LoadThemeStyle(widgettype);
00081
00082 my_btnok->LoadThemeStyle(widgettype, "Button1");
00083 if(my_btncancel) {
00084 my_btncancel->LoadThemeStyle(widgettype, "Button2");
00085 }
00086 }
00087
00088
00089 bool PG_MessageBox::handleButton(PG_Button* button) {
00090
00091 SetModalStatus(button->GetID());
00092 QuitModal();
00093 return true;
00094 }