Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

ColorTargetModalDialog.h

Go to the documentation of this file.
00001 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00002 // NOTE: Should use oglSys.GetTopOGLWND() rather than walking the parents.
00003 //       This way it would also work correctly when C++ embedded in C components.
00004 // Author: Richard van Balen, for University of Amsterdam
00006 
00007 #ifndef OglGui_ColorTargetModalDialog_h
00008 #define OglGui_ColorTargetModalDialog_h
00009 
00010 #ifndef OglGui_ColorDialog_h
00011 #include "OglGui/ColorDialog.h"
00012 #endif
00013 
00014 #ifndef OglGui_TitledWindow_h
00015 #include "OglGui/TitledWindow.h"
00016 #endif
00017 
00018 namespace OglGui {
00019 
00020 class ColorTargetModalDialog : ButtonListener
00021 {
00022 public:
00023     // which : 0=background, 1=borderbackground, 2=foreground
00024     ColorTargetModalDialog(Window* parent, Window* target, int what,
00025                            ULONG startCol=oglBLACK,int w=600, int h=300)
00026     {
00027         Window* topWnd = parent;
00028         while(parent = parent->GetParent())
00029             topWnd = parent;
00030         int tW = topWnd->W();
00031         int tH = topWnd->H();
00032 
00033         mTargetWnd = target;
00034         mWhat      = what;
00035 
00036         mModalWnd  = new Window(topWnd,0,0,tW,tH);
00037         mModalWnd->ConnectTo(topWnd);
00038 
00039         TitledWindow* tWnd =
00040             new TitledWindow(mModalWnd,tW/2-w/2,tH/2-h/2,w,h,"Choose Color");
00041         mColorDialog =
00042             new ColorDialog(tWnd,4,4,200,200); // Note dims here unimportant
00043         mColorDialog->Color(startCol);
00044         tWnd->SetContentPane(mColorDialog);
00045         tWnd->SetBorderBackground(oglGUI_BG);
00046 
00047         mColorDialog->OkBtn()->SetButtonListener(this);
00048         mColorDialog->CancelBtn()->SetButtonListener(this);
00049     }
00050 
00051     virtual void ButtonSelectionEvent(Button *src, void* userData)
00052     {
00053         if (src == mColorDialog->OkBtn())
00054         {
00055             ULONG col = mColorDialog->ColorWnd()->GetBorderBackground();
00056             if (mWhat==0)
00057                 mTargetWnd->SetBackground(col);
00058             if (mWhat==1)
00059                 mTargetWnd->SetBorderBackground(col);
00060             if (mWhat==2)
00061                 mTargetWnd->SetForeground(col);
00062             mTargetWnd->UpdateScene();
00063         }
00064         delete mModalWnd;
00065         delete this;
00066     }
00067 private:
00068     ColorDialog*    mColorDialog;
00069     Window*         mTargetWnd;
00070     Window*         mModalWnd;
00071     int             mWhat;
00072 };
00073 
00074 void ColorTargetModalDialogFunc(Window* parent, Window* target, int what,
00075                                 ULONG startCol=oglBLACK,int w=600, int h=300)
00076 {
00077     new ColorTargetModalDialog(parent,target,what,startCol,w,h);
00078 }
00079 
00080 } // namespace OglGui
00081 
00082 #endif

Generated on Fri Mar 19 09:31:34 2010 for ImpalaSrc by  doxygen 1.5.1