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

pgmessagebox.cpp

Go to the documentation of this file.
00001 /*
00002     ParaGUI - crossplatform widgetset
00003     Copyright (C) 2000,2001,2002  Alexander Pipelka
00004  
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009  
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014  
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  
00019     Alexander Pipelka
00020     pipelka@teleweb.at
00021  
00022     Last Update:      $Author: mbickel $
00023     Update Date:      $Date: 2007-04-13 16:16:03 $
00024     Source File:      $Source: /home/cvspsrv/cvsroot/games/asc/source/libs/paragui/src/widgets/pgmessagebox.cpp,v $
00025     CVS/RCS Revision: $Revision: 1.2 $
00026     Status:           $State: Exp $
00027 */
00028 
00029 #include "pgmessagebox.h"
00030 #include "pglog.h"
00031 #include "pgwindow.h"
00032 #include "pgmultilineedit.h"
00033 
00034 //create PopUp and 2 Buttons
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 //Delete the Buttons
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 //Event?
00089 bool PG_MessageBox::handleButton(PG_Button* button) {
00090         //Set Buttonflag to ButtonID
00091         SetModalStatus(button->GetID());
00092         QuitModal();
00093         return true;
00094 }

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