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

PoliceMan.h

Go to the documentation of this file.
00001 /*
00002 12345678901234567890123456789012345678901234567890123456789012345678901234567890
00003 */
00004 // Author: Richard van Balen
00005 
00006 #ifndef Impala_Application_SDash_PoliceMan_h
00007 #define Impala_Application_SDash_PoliceMan_h
00008 
00009 #ifndef Impala_Application_SDash_PoliceManListener_h
00010 #include "Application/sdash/PoliceManListener.h"
00011 #endif
00012 
00013 #ifndef OglGui_TextEdit_h
00014 #include OglGui_TextEdit.h"
00015 #endif
00016 
00017 
00018 namespace Impala {
00019 namespace Application {
00020 namespace SDash {
00021 
00022 class PoliceMan : public OglGui::Window
00023 {
00024     typedef OglGui::Window      Window;
00025     typedef OglGui::TextEdit    TextEdit;
00026 
00027 public:
00028     PoliceMan(Window* parent, int x, int y, int w, int h,
00029               strconst text, ULONG col=oglGREEN) :
00030         Window(parent, x, y, w, h)
00031     {
00032         Init(x,y,w,h,text,col);
00033     }
00034 
00035     void
00036     SetPoliceManListener(PoliceManListener* listener, void* listenerData = 0)
00037     {
00038         mListener = listener;
00039         mListenerData = listenerData;
00040     }
00041 
00042     void         HighlightColor(ULONG col)  { mHighlightColor = col; }
00043     ULONG        HighlightColor()           { return mHighlightColor; }
00044     TextEdit*    Balloon()                  { return mBalloon; }
00045     void         SetText(std::string text)  { mBalloon->SetText(text); }
00046     std::string  GetText()                  { return mBalloon->GetText(); }
00047 
00048     virtual void DisplayFunc()
00049     {
00050         int w = W(), h = H();
00051         OGC myOGC;
00052         OGCSave(&myOGC);
00053 
00054         SetSolidLineColor(mMouseOver ? mHighlightColor : oglBLACK);
00055         SetSolidFillColor(mForeGroundColor);
00056 
00057         FillOval(w/2,5*h/6,w/4,h/6);
00058         FillRectangle(1,h/3,w-2,h/3);
00059         SetSolidFillColor(oglLIGHTBLUE);
00060         FillRectangle(w/4,0,w/2,2*h/3);
00061 
00062         DrawOval(w/2,5*h/6,w/4,h/6);
00063         DrawRectangle(1,h/3,w-2,h/3);
00064         DrawRectangle(w/4,0,w/2,2*h/3);
00065         DrawLine(w/2,0,w/2,h/3);
00066         FillRectangle(w/4,5*h/6+2,w/2,h/6);
00067 
00068         mBalloon->SetDimensions(X(),Y()+H(),RETAIN,RETAIN);
00069 
00070         Window::DisplayFunc();
00071         OGCRestore(&myOGC);
00072     }
00073 
00074     virtual void MouseFunc(int msg, int btn, int state, int x, int y)
00075     {
00076         if (msg == oglMouseEnter || msg == oglMouseLeave)
00077         {
00078             mMouseOver = (msg == oglMouseEnter);
00079             mBalloon->SetVisible(mMouseOver);
00080         }
00081         if (msg == oglMouseDown && mListener != 0)
00082             mListener->PoliceManClicked(this, btn, state, x, y, mListenerData);
00083     }
00084 
00085 private:
00086     void Init(int x, int y, int w, int h, strconst text, ULONG col)
00087     {
00088         mBalloon = new TextEdit(GetParent(),x,y+h,160,50,text,0);
00089         //mBalloon->TextShadowed(true);
00090         mBalloon->SetVisible(false);
00091         mBalloon->SetForeground(oglWHITE);
00092         mBalloon->SetBackground(0x804040ff);
00093 
00094         SetForeground(col);
00095 
00096         mHighlightColor = oglWHITE;
00097         mListener = 0;
00098         mMouseOver = false;
00099         mStateFeedbackColor = 0x80ffffff;
00100         mDoStateFeedback = false;
00101     }
00102 
00103     PoliceManListener*  mListener;
00104     void*               mListenerData;
00105 
00106     TextEdit*           mBalloon;
00107     std::string         mString;
00108 
00109     bool                mMouseOver;
00110 
00111     ULONG               mHighlightColor;
00112 };
00113 
00114 }
00115 }
00116 }
00117 #endif

Generated on Fri Mar 19 09:30:38 2010 for ImpalaSrc by  doxygen 1.5.1