00001 #ifdef WIN32 00002 #pragma warning(disable : 4786 ) 00003 #endif 00004 00005 #include "CSMessageBox.h" 00006 #include "CSIcon.h" 00007 #include "CSLAF.h" 00008 #include "CSLabel.h" 00009 #include "CSFont.h" 00010 00011 const char *CSMessageBox::CLASS = "CSMessageBox"; 00012 00013 CSMessageBox::CSMessageBox(std::string message, std::string title, int kind) 00014 : CSWindow(100,300) 00015 { 00016 static char *functionName="CSMessageBox"; 00017 LOG_ENTER 00018 mKind = kind; 00019 mTextarea = 0; 00020 mIcon = 0; 00021 mMessage = message; 00022 00023 setGUIType(CSWindow::CLASS); 00024 setModal(true); 00025 setTitle(title); 00026 setSizeable(true); 00027 rebuildElement(); 00028 layoutSetup(); 00029 LOG_EXIT 00030 } 00031 00032 CSMessageBox::~CSMessageBox() 00033 { 00034 static char *functionName="~CSMessageBox"; 00035 LOG_ENTER 00036 LOG_EXIT 00037 } 00038 00039 void CSMessageBox::rebuildElement() 00040 { 00041 CSLAF *laf = CSLAF::getCurrentLAF(); 00042 00043 if (mTextarea) 00044 { 00045 removeElement(mTextarea); 00046 delete (mTextarea); 00047 mTextarea = 0; 00048 } 00049 if (mIcon) 00050 { 00051 removeElement(mIcon); 00052 delete (mIcon); 00053 mIcon = 0; 00054 } 00055 00056 rebuildElementWindow(); 00057 00058 mTextarea = new CSTextarea(100, 300); 00059 if (mKind == QUESTION_ICON) 00060 { 00061 mIcon = laf->getIcon(LAF_ICON_TYPE_QUESTION); 00062 } 00063 if (mKind == WARN_ICON) 00064 { 00065 mIcon = laf->getIcon(LAF_ICON_TYPE_WARN); 00066 } 00067 if (mKind == ERROR_ICON) 00068 { 00069 mIcon = laf->getIcon(LAF_ICON_TYPE_ERROR); 00070 } 00071 if (mKind == INFO_ICON) 00072 { 00073 mIcon = laf->getIcon(LAF_ICON_TYPE_INFO); 00074 } 00075 mTextarea->setMultiLineText(mMessage); 00076 mTextarea->setEditable(false); 00077 addElement(mIcon, 20, (mHeight-20)/2-mIcon->getHeight()/2); 00078 addElement(mTextarea, 20 + mIcon->getX()+mIcon->getWidth(), 20); 00079 } 00080 00081 void CSMessageBox::layoutSetupMessageBox() 00082 { 00083 static char *functionName="layoutSetupMessageBox"; 00084 LOG_ENTER 00085 00086 mHeight = 20+20 + mIcon->getHeight() + mTextarea->getHeight(); 00087 mWidth = mIcon->getWidth()+3*20 + mTextarea->getWidth(); 00088 mMinHeight = mHeight; 00089 mMinWidth = mWidth; 00090 00091 mHeight += getBorder()->getTotalHeight() + getInset().getTotalHeight(); 00092 mWidth += getBorder()->getTotalWidth() + getInset().getTotalWidth(); 00093 00094 layoutSetupWindow(); 00095 LOG_EXIT 00096 }