00001 #include <gui/MessageBox.h>
00002 #include <gui/MessageQueue.h>
00003 #include <gui/Button.h>
00004 #include <gui/TextView.h>
00005 #include <gui/TopView.h>
00006 #include <gui/Exceptions.h>
00007 #include <gui/Window.h>
00008 #include <gui/StringView.h>
00009 #include <gui/ApplicationWindow.h>
00010 #include <gui/Application.h>
00011 #include <gui/Menu.h>
00012 #include <gui/StatusBar.h>
00013 #include <gui/CheckBox.h>
00014 #include <gui/MessageBox.h>
00015 #include <iostream>
00016
00017 using namespace SkyGI;
00018
00019 #define ID_ADD 10000
00020
00021 class MyMessageBox : public View
00022 {
00023 public:
00024 MyMessageBox(Window *pParent, const Rect &rFrame, unsigned int nWindowLayoutFlags);
00025
00026 void OnModal();
00027 void OnNonModal();
00028 };
00029
00030
00031 void MyMessageBox::OnModal()
00032 {
00033 {
00034 MessageBox pMessageBox("Modal", "No icon\nYes/No", NULL, MESSAGEBOX_FLAG_YESNO);
00035 pMessageBox.Run(true);
00036 }
00037 {
00038 MessageBox pMessageBox("Modal", "16x16 icon\nOk", new Image("/boot/addon/icons/noerr.ico", 16, 16, 0, 0), MESSAGEBOX_FLAG_OK);
00039 pMessageBox.Run(true);
00040 }
00041 {
00042 MessageBox pMessageBox("Modal", "32 icon\nOk/Cancel", new Image("/boot/addon/icons/noerr.ico", 32, 32, 0, 0), MESSAGEBOX_FLAG_OK | MESSAGEBOX_FLAG_CANCEL);
00043 pMessageBox.Run(true);
00044 }
00045 {
00046 MessageBox pMessageBox("Modal", "48x48 icon\nCancel", new Image("/boot/addon/icons/noerr.ico", 48, 48, 0, 0), MESSAGEBOX_FLAG_CANCEL);
00047 pMessageBox.Run(true);
00048 }
00049 {
00050 MessageBox pMessageBox("Modal", "32x32 icon\nCancel\nInfo icon", NULL, MESSAGEBOX_FLAG_INFO | MESSAGEBOX_FLAG_CANCEL);
00051 pMessageBox.Run(true);
00052 }
00053 {
00054 Image *pImage = new Image("/boot/addon/backgrnd/Images/Aurora.jpg");
00055 pImage = pImage->Scale(Point(120,120), pImage->GetBounds());
00056 MessageBox pMessageBox("Modal", "32x32 icon\nCustom Buttons", pImage, MESSAGEBOX_FLAG_USER, "Button1", ID_OK, "Button2", ID_OK, "Button3", ID_OK, NULL, 0);
00057 pMessageBox.Run(true);
00058 }
00059 }
00060
00061 void MyMessageBox::OnNonModal()
00062 {
00063 MessageBox *pMessageBox = new MessageBox("NonModal", "This is a non modal message box!", MESSAGEBOX_FLAG_OK);
00064 pMessageBox->Run(false);
00065 }
00066
00067 MyMessageBox::MyMessageBox(Window *pParent, const Rect &rFrame, unsigned int nWindowLayoutFlags) : View(pParent, rFrame, nWindowLayoutFlags)
00068 {
00069 Button *pButton;
00070
00071 pButton = new Button(this, Rect(), "Modal", 0);
00072 pButton->SetRect(Point(10, 10), pButton->GetPreferredSize());
00073 pButton->Clicked.Connect(this, &MyMessageBox::OnModal);
00074 pButton = new Button(this, Rect(), "Non Modal", 0);
00075 pButton->SetRect(Point(10, 60), pButton->GetPreferredSize());
00076 pButton->Clicked.Connect(this, &MyMessageBox::OnNonModal);
00077
00078 TextView *pTextView = new TextView(this, Rect(10, 100, 100, 120), 0, TEXTVIEW_FLAG_SINGLE_LINE);
00079 }
00080
00081 void MessageBoxTest()
00082 {
00083 Rect r(Point(100, 100), Point(400, 440));
00084
00085 ApplicationWindow* pApplicationWindow = new ApplicationWindow(r, "MessageBox", WINDOW_LAYOUT_NOTHING, APPLICATION_WINDOW_NO_VIEW);
00086
00087 pApplicationWindow->GetTitleWindow()->SetFlags( (TitleWindowFlags)(pApplicationWindow->GetTitleWindow()->GetFlags() ));
00088 pApplicationWindow->AttachView(new MyMessageBox(pApplicationWindow, pApplicationWindow->GetClientRect(), WINDOW_LAYOUT_NOTHING));
00089 pApplicationWindow->Show();
00090 }
00091