Main Page   Packages   Class Hierarchy   Alphabetical List   Data Structures   File List   Namespace Members   Data Fields   Globals  

Dialog.cpp

Go to the documentation of this file.
00001 /*
00002  * $Id: Dialog.cpp,v 1.6 2002/08/09 04:52:08 virtualcasino Exp $
00003  */
00004 #include<Dialog.h>
00005 #include<SDL.h>
00006 
00007 extern SDL_Event globalEvent;
00008 
00009 namespace clawsoft{
00010         Dialog::~Dialog(){ 
00011                 /*delete okBtn;
00012                 delete cancelBtn;
00013                 delete helpBtn;*/
00014         }
00015 
00016         Dialog::Dialog(){
00017                 setClassName("Dialog");
00018                 /*okBtn = new OKButton();
00019                 helpBtn = new HelpButton();
00020                 cancelBtn = new CancelButton();
00021                 okBtn->me = this;
00022                 cancelBtn->me = this;
00023                 helpBtn->me = this;*/
00024                 dType = DLG_OK_CANCEL;
00025         }
00026 
00027         Dialog::Dialog(Rect &r, DialogType t):Window(r, "Dialog Window"){
00028                 setClassName("Dialog");
00029                 /*okBtn = new OKButton();
00030                 helpBtn = new HelpButton();
00031                 cancelBtn = new CancelButton();
00032                 okBtn->me = this;
00033                 cancelBtn->me = this;
00034                 helpBtn->me = this;*/
00035                 dType = t;
00036         }
00037 
00038         Dialog::Dialog(Rect &r, const char *cap, DialogType t):Window(r, cap){
00039                 setClassName("Dialog");
00040                 /*okBtn = new OKButton();
00041                 helpBtn = new HelpButton();
00042                 cancelBtn = new CancelButton();
00043                 okBtn->me = this;
00044                 cancelBtn->me = this;
00045                 helpBtn->me = this;*/
00046                 dType = t;
00047         }
00048 
00049         Dialog::Dialog(Rect &r, String cap, DialogType t):Window(r, cap){
00050                 setClassName("Dialog");
00051                 /*okBtn = new OKButton();
00052                 helpBtn = new HelpButton();
00053                 cancelBtn = new CancelButton();
00054                 okBtn->me = this;
00055                 cancelBtn->me = this;
00056                 helpBtn->me = this;*/
00057                 dType = t;
00058         }
00059 
00060         Dialog::OKButton::OKButton(){
00061                 setClassName("Dialog::OKButton");
00062                 setCaption("Aceptar");
00063         }
00064         
00065         Dialog::CancelButton::CancelButton(){
00066                 setClassName("Dialog::CancelButton");
00067                 setCaption("Cancelar");
00068         }
00069 
00070         Dialog::HelpButton::HelpButton(){
00071                 setClassName("Dialog::HelpButton");
00072                 setCaption("Ayuda");
00073         }
00074 
00075         void Dialog::OKButton::action(int xx, int yy, int bb){
00076                 //Dialog::okAction(xx, yy, bb);
00077         }
00078 
00079         void Dialog::CancelButton::action(int xx, int yy, int bb){
00080                 //Dialog::cancelAction(xx, yy, bb);
00081         }
00082 
00083         void Dialog::HelpButton::action(int xx, int yy, int bb){
00084                 //Dialog::helpAction(xx, yy, bb);
00085         }
00086 
00087         void Dialog::drawComponents(){
00088                 switch(dType){
00089                         case DLG_CANCEL:
00090                                 cancelBtn.draw();
00091                                 break;
00092                         case DLG_OK_CANCEL_HELP:
00093                                 helpBtn.draw();
00094                         case DLG_OK_CANCEL:
00095                                 cancelBtn.draw();
00096                         case DLG_OK:
00097                                 okBtn.draw();
00098                 }
00099                 drawContents();
00100         }
00101 
00102         void Dialog::map(){
00103                 Window::map();
00104                 helpBtn.map();
00105                 okBtn.map();
00106                 cancelBtn.map();
00107                 helpBtn.Y(getBottom() +53 );
00108                 okBtn.Y(getBottom() + 53);
00109                 cancelBtn.Y(getBottom() + 53);
00110                 switch(dType){
00111                         case DLG_OK_CANCEL_HELP:
00112                                 helpBtn.X(getRight() - helpBtn.W() + 20);
00113                                 cancelBtn.X(helpBtn.X() - cancelBtn.W() + 20);
00114                                 okBtn.X(cancelBtn.X() - okBtn.W() + 20);
00115                                 break;
00116                         case DLG_OK_CANCEL:
00117                                 cancelBtn.X(getRight() - cancelBtn.W() + 20);
00118                                 okBtn.X(cancelBtn.X() - okBtn.W() + 20);
00119                                 break;
00120                         case DLG_OK:
00121                                 okBtn.X(getRight() - okBtn.W() + 20);
00122                                 break;
00123                         case DLG_CANCEL:
00124                                 cancelBtn.X(getRight() - cancelBtn.W() + 20);
00125                                 break;
00126                 }
00127         }
00128 
00129         bool Dialog::checkMouseEvents(){
00130                 bool f1 = false, f2 = false, f3 = false, flag = false;
00131                 int xx, yy;
00132                 switch(dType){
00133                         case DLG_CANCEL:
00134                                 f2 = cancelBtn.checkMouseEvents();
00135                                 break;
00136                         case DLG_OK_CANCEL_HELP:
00137                                 f1 = helpBtn.checkMouseEvents();
00138                         case DLG_OK_CANCEL:
00139                                 f2 = cancelBtn.checkMouseEvents();
00140                         case DLG_OK:
00141                                 f3 = okBtn.checkMouseEvents();
00142                 }
00143                 xx = globalEvent.motion.x;
00144                 yy = globalEvent.motion.y;
00145                 if(f1){
00146                         flag = true;
00147                         helpAction(xx, yy, SDL_BUTTON_LEFT);
00148                 }
00149                 else{
00150                         if(f2){
00151                                 flag = true;
00152                                 cancelAction(xx, yy, SDL_BUTTON_LEFT);
00153                         }
00154                         else{
00155                                 if(f3){
00156                                         flag = true;
00157                                         okAction(xx, yy, SDL_BUTTON_LEFT);
00158                                 }
00159                         }
00160                 }
00161                 return flag;
00162         }
00163 }

Powered by:

SourceForge Logo