1 // SHE library 2 // Copyright (C) 2012-2017 David Capello 3 // 4 // This file is released under the terms of the MIT license. 5 // Read LICENSE.txt for more information. 6 7 #ifndef SHE_SYSTEM_H_INCLUDED 8 #define SHE_SYSTEM_H_INCLUDED 9 #pragma once 10 11 #include "gfx/fwd.h" 12 #include "she/capabilities.h" 13 #include "she/keys.h" 14 15 #include <stdexcept> 16 17 namespace she { 18 19 class Display; 20 class EventQueue; 21 class Font; 22 class Logger; 23 class Menus; 24 class NativeDialogs; 25 class Surface; 26 27 class DisplayCreationException : public std::runtime_error { 28 public: DisplayCreationException(const char * msg)29 DisplayCreationException(const char* msg) throw() 30 : std::runtime_error(msg) { } 31 }; 32 33 class System { 34 public: ~System()35 virtual ~System() { } 36 virtual void dispose() = 0; 37 virtual void activateApp() = 0; 38 virtual void finishLaunching() = 0; 39 virtual Capabilities capabilities() const = 0; 40 41 // Disables loading wintab32.dll (sometimes a program can be 42 // locked when we load the wintab32.dll, so we need a way to 43 // opt-out loading this library.) 44 virtual void useWintabAPI(bool enable) = 0; 45 46 virtual Logger* logger() = 0; 47 virtual Menus* menus() = 0; 48 virtual NativeDialogs* nativeDialogs() = 0; 49 virtual EventQueue* eventQueue() = 0; 50 virtual bool gpuAcceleration() const = 0; 51 virtual void setGpuAcceleration(bool state) = 0; 52 virtual gfx::Size defaultNewDisplaySize() = 0; 53 virtual Display* defaultDisplay() = 0; 54 virtual Display* createDisplay(int width, int height, int scale) = 0; 55 virtual Surface* createSurface(int width, int height) = 0; 56 virtual Surface* createRgbaSurface(int width, int height) = 0; 57 virtual Surface* loadSurface(const char* filename) = 0; 58 virtual Surface* loadRgbaSurface(const char* filename) = 0; 59 virtual Font* loadSpriteSheetFont(const char* filename, int scale = 1) = 0; 60 virtual Font* loadTrueTypeFont(const char* filename, int height) = 0; 61 62 // Returns true if the the given scancode key is pressed/actived. 63 virtual bool isKeyPressed(KeyScancode scancode) = 0; 64 65 // Returns the active pressed modifiers. 66 virtual KeyModifiers keyModifiers() = 0; 67 68 // Returns the latest unicode character that activated the given 69 // scancode. 70 virtual int getUnicodeFromScancode(KeyScancode scancode) = 0; 71 72 // Clears the keyboard buffer (used only in the Allegro port). 73 // TODO (deprecated) 74 virtual void clearKeyboardBuffer() = 0; 75 76 // Indicates if you want to use dead keys or not. By default it's 77 // false, which behaves as regular shortcuts. You should set this 78 // to true when you're inside a text field in your app. 79 virtual void setTranslateDeadKeys(bool state) = 0; 80 81 }; 82 83 System* create_system(); 84 System* instance(); 85 86 } // namespace she 87 88 #endif 89