Back to index

extremetuxracer  0.5beta
ui_mgr.h
Go to the documentation of this file.
00001 /* 
00002  * PPRacer 
00003  * Copyright (C) 2004-2005 Volker Stroebel <volker@planetpenguin.de>
00004  *
00005  * Copyright (C) 1999-2001 Jasmin F. Patry
00006  * 
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020  */
00021 
00022 #ifndef UI_MGR_H
00023 #define UI_MGR_H
00024 
00025 #include "winsys.h"
00026 #include "widget.h"
00027 
00028 #include "alg/vec2d.h"
00029 
00030 #include <list>
00031 
00032 namespace pp{
00033        
00034 class Widget;
00035 
00036 class UIManager 
00037 {
00038        std::list<pp::Widget*> widgets;    
00039               
00040        pp::Widget* focusWidget;
00041               
00042        bool leftMouseButtonDown;
00043        bool middleMouseButtonDown;
00044        bool rightMouseButtonDown;
00045        
00046        bool dirty;
00047        pp::Vec2d cursorPos;
00048        
00049        void drawCursor();
00050        
00051 public:
00052        UIManager();
00053        ~UIManager();
00054 
00055        void add(pp::Widget *widget);
00056        void remove(pp::Widget *widget);
00057        
00058        void setDirty();
00059        void checkDirty();
00060 
00061        void setupDisplay();
00062        void draw();
00063        void mouseEvent( int button, int state, int x, int y );
00064        void motionEvent( int x, int y );
00065        pp::Vec2d getMousePosition();
00066 
00067        bool keyboardEvent(SDLKey key, SDLMod mod, bool release);
00068 
00069        void grabFocus(pp::Widget* widget,bool focus);
00070 
00071 };
00072 
00073 } //namespace pp
00074 
00075 extern pp::UIManager UIMgr;
00076 
00077 #endif // UI_MGR_H