1 /* bzflag 2 * Copyright (c) 1993-2021 Tim Riker 3 * 4 * This package is free software; you can redistribute it and/or 5 * modify it under the terms of the license found in the file 6 * named COPYING that should have accompanied this file. 7 * 8 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 9 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 10 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11 */ 12 13 /* BzfDisplay: 14 * Encapsulates a display -- input and output devices. 15 */ 16 17 #ifndef BZF_DISPLAY_H 18 #define BZF_DISPLAY_H 19 20 #include "common.h" 21 22 class BzfEvent; 23 24 class BzfDisplay 25 { 26 public: 27 BzfDisplay(); 28 virtual ~BzfDisplay(); 29 30 virtual bool isValid() const = 0; 31 virtual bool isEventPending() const = 0; 32 virtual bool getEvent(BzfEvent&) const = 0; 33 virtual bool peekEvent(BzfEvent&) const = 0; 34 hasGetKeyMode()35 virtual bool hasGetKeyMode() 36 { 37 return false; 38 }; getModState(bool & shift,bool & control,bool & alt)39 virtual void getModState(bool &shift, bool &control, bool &alt) 40 { 41 shift = false; 42 control = false; 43 alt = false; 44 }; 45 46 int getWidth() const; 47 int getHeight() const; 48 void setFullScreenFormat(int); 49 50 void setPassthroughSize(int w, int h); 51 int getPassthroughWidth() const; 52 int getPassthroughHeight() const; 53 54 public: 55 class ResInfo 56 { 57 public: 58 ResInfo(const char* name, int w, int h, int r); 59 ~ResInfo(); 60 public: 61 char* name; 62 int width; 63 int height; 64 int refresh; 65 }; 66 67 int getNumResolutions() const; 68 const ResInfo* getResolution(int index) const; 69 int getResolution() const; 70 int getDefaultResolution() const; 71 bool setResolution(int index); 72 bool setDefaultResolution(); 73 int findResolution(const char* name) const; 74 bool isValidResolution(int index) const; 75 76 protected: 77 void initResolutions(ResInfo**, int num, int current); 78 79 private: 80 BzfDisplay(const BzfDisplay&); 81 BzfDisplay& operator=(const BzfDisplay&); 82 83 virtual bool doSetResolution(int) = 0; 84 virtual bool doSetDefaultResolution(); 85 86 private: 87 int passWidth, passHeight; 88 int numResolutions; 89 int defaultResolution; 90 int currentResolution; 91 ResInfo** resolutions; 92 protected: 93 int modeIndex; 94 }; 95 96 #endif // BZF_DISPLAY_H 97 98 // Local Variables: *** 99 // mode: C++ *** 100 // tab-width: 4 *** 101 // c-basic-offset: 4 *** 102 // indent-tabs-mode: nil *** 103 // End: *** 104 // ex: shiftwidth=4 tabstop=4 105