Interface.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 5 -*- */
00002 
00003 /*
00004  * Combination of a first person action and a real time strategy battle game.
00005  */
00006 
00007 /*
00008  * Interface.h
00009  * MetalWarriors
00010  * $Revision: 1.9 $
00011  *
00012  * Created by Daniel Aarno on Sun Oct 12 2003.
00013  * Copyright (c) 2003 Daniel Aarno and Erik Ytterberg - All rights reserved.
00014  *
00015  *     This program is free software; you can redistribute it and/or modify
00016  *     it under the terms of the GNU General Public License as published by
00017  *     the Free Software Foundation; either version 2 of the License, or
00018  *     (at your option) any later version.
00019  *
00020  *     This program is distributed in the hope that it will be useful,
00021  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *     GNU General Public License for more details.
00024  *
00025  *     You should have received a copy of the GNU General Public License
00026  *     along with this program; if not, write to the Free Software
00027  *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00028  */
00029  
00030 #ifndef _INTERFACE_
00031 #define _INTERFACE_
00032 
00033 typedef enum {
00034      MOD_NONE  = 0x0000,
00035      MOD_LSHIFT= 0x0001,
00036      MOD_RSHIFT= 0x0002,
00037      MOD_LCTRL = 0x0040,
00038      MOD_RCTRL = 0x0080,
00039      MOD_LALT  = 0x0100,
00040      MOD_RALT  = 0x0200,
00041      MOD_LMETA = 0x0400,
00042      MOD_RMETA = 0x0800,
00043      MOD_NUM   = 0x1000,
00044      MOD_CAPS  = 0x2000,
00045      MOD_MODE  = 0x4000,
00046 } ModMask;
00047 
00048 #define MOD_CTRL   (MOD_LCTRL|MOD_RCTRL)
00049 #define MOD_SHIFT  (MOD_LSHIFT|MOD_RSHIFT)
00050 #define MOD_ALT    (MOD_LALT|MOD_RALT)
00051 #define MOD_META   (MOD_LMETA|MOD_RMETA)
00052 
00056 class Interface
00057 {
00058 private:
00059      static Interface *sharedInstance;
00060   
00061 public:
00063      typedef enum {
00064           LEFT_BUTTON = 1,
00065           MIDDLE_BUTTON = 1 << 1,
00066           RIGHT_BUTTON = 1 << 2,
00067           FOURTH_BUTTON = 1 << 3,
00068           FIFTH_BUTTON = 1 << 4
00069      } MouseButtonType;
00070   
00071   /*enum {
00072     KEY_LEFT = 1,
00073     KEY_RIGHT,
00074     KEY_UP,
00075     KEY_DOWN,
00076     KEY_PAGE_UP,
00077     KEY_PAGE_DOWN,
00078     KEY_HOME,
00079     KEY_END,
00080     KEY_INSERT,
00081     MOD_SHIFT,
00082     MOD_CTRL,
00083     MOD_ALT
00084     };*/
00085   
00087      virtual ~Interface() {}
00088   
00091      static Interface* GetSharedInstance() { return sharedInstance; }
00092 
00104      static int Init(Interface* iface, int argc, const char* argv[], 
00105                     int width, int height);
00106 
00110      static void Exit();
00111 
00113      virtual int start()=0;
00114      
00116      virtual void flush()=0;
00118      virtual void repaint()=0;
00119      
00126      virtual void setIdleCallback(void (*func)(void))=0;
00127 
00134      virtual void setPaintCallback(void (*func)(void))=0;
00135 
00142      virtual void setKeyboardCallback(void (*func)(int key, int x, int y, 
00143                     bool special, bool down, unsigned int modifiers))=0;
00144 
00154      virtual void addTimerCallback(void (*func)(int value), int time_ms, 
00155                     int val=0)=0;
00156 
00163      virtual void setMouseEventCallback(void (*func)(int x, int y, 
00164                     MouseButtonType button, bool down))=0;
00165 
00172      virtual void setMouseMotionCallback(void (*func)(int x, int y))=0;
00173 
00180      virtual void setRawEventCallback(void (*func)(void *event))=0;
00181      
00183      virtual void setWindowSize(int width, int height)=0;
00184      
00191      virtual void setFullScreen(bool fullScreen)=0;
00192 
00199      virtual bool getFullScreen(void)=0;
00200 
00205      virtual int getTime()=0;
00206 
00208      virtual int getWindowWidth()=0;
00209 
00211      virtual int getWindowHeight()=0;
00212      
00214      virtual const char* name() { return "UNKNOWN"; }
00215      
00216 protected:
00217      virtual int init(int argc, const char* argv[], int width, int height)=0;
00218 };
00219 
00220 #endif //_INTERFACE_

Generated on Sun Mar 11 15:33:23 2007 for MetalWarriors by  doxygen 1.4.7