00001 #ifndef CSDESKTOP_h 00002 #define CSDESKTOP_h 00003 00004 // USES SDL_Surface 00005 // USES SDL_Rect 00006 // USES SDL_Events 00007 00008 #ifdef WIN32 00009 #pragma warning(disable : 4786 ) 00010 #endif 00011 00012 #include <vector> 00013 #include <string> 00014 00015 #include "CSGrafikElement.h" 00016 #include "CSLog.h" 00017 00018 class CSMouseCursor; 00019 class CSGame; 00020 class CSLabel; 00021 class CSPanel; 00022 00023 class CSDesktop : public CSGrafikElement 00024 { 00025 friend CSGame; 00026 friend CSGrafikElement; // for modal desktop only 00027 private: 00028 CSGrafikElement *mFocusedComponent; 00029 CSGrafikElement *mStartDown; 00030 CSGrafikElement *mCurrentUnderMouseComponent; 00031 CSGrafikElement *mModalComponent; 00032 CSPanel *mTooltipPanel; 00033 CSLabel *mTooltipLabel; 00034 CSPanel *mNorth; 00035 CSPanel *mWest; 00036 CSPanel *mSouth; 00037 CSPanel *mEast; 00038 CSPanel *mCenter; 00039 int mCursorX; 00040 int mCursorY; 00041 long mLastTimePainted; 00042 int mLastCursorX; 00043 int mLastCursorY; 00044 SDL_Rect mScreenArea; // mX, mY, mHeight, mWidth (of screen) 00045 00046 void onMouseMotion(int x, int y); 00047 void onMouseDown(int x, int y); 00048 void onMouseUp(int x, int y); 00049 bool dispatchKeyEvent(const SDL_Event &event, int state); 00050 00051 // following privates are for modal desktop only 00052 void runModalDesktop(CSGrafikElement *modalElement, SDL_Surface *destination); 00053 void onMouseMotion(SDL_MouseMotionEvent event); 00054 void onMouseButtonDown(SDL_MouseButtonEvent event); 00055 void onMouseButtonUp(SDL_MouseButtonEvent event); 00056 void handleEvents(); 00057 void showToolTip(); 00058 00059 protected: 00060 void layoutSetupDesktop(); 00061 00062 public: 00063 static const char *CLASS; 00064 virtual std::string getType() {return (std::string) CLASS;} 00065 CSDesktop(); 00066 CSDesktop(SDL_Rect area); 00067 ~CSDesktop(); 00068 virtual void paint(SDL_Surface *destination, SDL_Rect *parentViewport); 00069 void setFocusedComponent(CSGrafikElement *element); 00070 CSGrafikElement *getFocusedComponent() {return mFocusedComponent;} 00071 void focusedNextComponent(); 00072 void addElementNorth(CSGrafikElement *element); 00073 void addElementSouth(CSGrafikElement *element); 00074 void addElementEast(CSGrafikElement *element); 00075 void addElementWest(CSGrafikElement *element); 00076 virtual void layoutSetup() {layoutSetupDesktop();} 00077 void correctElementHandling(CSGrafikElement *element); 00078 00079 }; 00080 00081 #endif // CSDESKTOP_h