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 /* WinDisplay:
14  *  Encapsulates an Windows windows display
15  */
16 
17 #ifndef BZF_WINDISPLAY_H
18 #define BZF_WINDISPLAY_H
19 #include "common.h"
20 #include "BzfDisplay.h"
21 #include "bzfgl.h"
22 
23 class BzfKeyEvent;
24 class Resolution;
25 
26 class WinDisplay : public BzfDisplay
27 {
28 public:
29     WinDisplay(const char* displayName,
30                const char* videoFormat);
31     ~WinDisplay();
32 
33     virtual bool    isValid() const;
34     bool        isEventPending() const;
35     bool        getEvent(BzfEvent&) const;
hasGetKeyMode()36     bool        hasGetKeyMode()
37     {
38         return true;
39     };
40     void        getModState(bool &shift, bool &control, bool &alt);
41 
42     bool        setDefaultResolution() const;
43 
44     bool        isFullScreenOnly() const;
45     int         getFullWidth() const;
46     int         getFullHeight() const;
47 
48     bool        peekEvent(BzfEvent& event) const;
49 
50 
51     // for other Windows stuff
52     class Rep
53     {
54     public:
55         Rep(const char*);
56         ~Rep();
57 
58         void        ref();
59         void        unref();
60 
61     private:
62         static LONG WINAPI windowProc(HWND, UINT, WPARAM, LPARAM);
63 
64     private:
65         int     refCount;
66 
67     public:
68         HINSTANCE   hInstance;
69     };
getRep()70     Rep*        getRep() const
71     {
72         return rep;
73     }
74 
75 private:
76     WinDisplay(const WinDisplay&);
77     WinDisplay&     operator=(const WinDisplay&);
78 
79     bool        getKey(const MSG&, BzfKeyEvent&) const;
80     bool        isNastyKey(const MSG&) const;
81 
82     bool        doSetResolution(int);
83     ResInfo**       getVideoFormats(int& num, int& current);
84     static bool     canChangeDepth();
85 
86     bool windowsEventToBZFEvent ( MSG &msg, BzfEvent& event ) const;
87 
88 private:
89     Rep*        rep;
90 
91     // resolution info
92     HWND        hwnd;
93     int         fullWidth;
94     int         fullHeight;
95     Resolution*     resolutions;
96 
97     // for key to character translations
98     bool        translated;
99     int         charCode;
100 
101     // keyboard mapping
102     static const int    asciiMap[];
103     static const int    asciiShiftMap[];
104     static const int    buttonMap[];
105 };
106 
107 #endif // BZF_WINDISPLAY_H
108 
109 // Local Variables: ***
110 // mode: C++ ***
111 // tab-width: 4 ***
112 // c-basic-offset: 4 ***
113 // indent-tabs-mode: nil ***
114 // End: ***
115 // ex: shiftwidth=4 tabstop=4
116