doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DeviceContext.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #ifndef __DEVICECONTEXT_H__
30 #define __DEVICECONTEXT_H__
31 
32 // device context support for gui stuff
33 //
34 
35 #include "Rectangle.h"
36 
37 const int VIRTUAL_WIDTH = 640;
38 const int VIRTUAL_HEIGHT = 480;
39 const int BLINK_DIVISOR = 200;
40 
42 public:
45 
46  void Init();
47  void Shutdown();
48  bool Initialized() { return initialized; }
49  void EnableLocalization();
50 
52 
53  void SetTransformInfo(const idVec3 &origin, const idMat3 &mat);
54  void DrawMaterial(float x, float y, float w, float h, const idMaterial *mat, const idVec4 &color, float scalex = 1.0, float scaley = 1.0);
55  void DrawRect(float x, float y, float width, float height, float size, const idVec4 &color);
56  void DrawFilledRect(float x, float y, float width, float height, const idVec4 &color);
57  int DrawText(const char *text, float textScale, int textAlign, idVec4 color, idRectangle rectDraw, bool wrap, int cursor = -1, bool calcOnly = false, idList<int> *breaks = NULL, int limit = 0 );
58  void DrawMaterialRect( float x, float y, float w, float h, float size, const idMaterial *mat, const idVec4 &color);
59  void DrawStretchPic(float x, float y, float w, float h, float s0, float t0, float s1, float t1, const idMaterial *mat);
60 
61  void DrawMaterialRotated(float x, float y, float w, float h, const idMaterial *mat, const idVec4 &color, float scalex = 1.0, float scaley = 1.0, float angle = 0.0f);
62  void DrawStretchPicRotated(float x, float y, float w, float h, float s0, float t0, float s1, float t1, const idMaterial *mat, float angle = 0.0f);
63 
64  int CharWidth( const char c, float scale );
65  int TextWidth(const char *text, float scale, int limit);
66  int TextHeight(const char *text, float scale, int limit);
67  int MaxCharHeight(float scale);
68  int MaxCharWidth(float scale);
69 
70  int FindFont( const char *name );
71  void SetupFonts();
72 
73  idRegion *GetTextRegion(const char *text, float textScale, idRectangle rectDraw, float xStart, float yStart);
74 
75  void SetSize(float width, float height);
76 
78 
79  void DrawCursor(float *x, float *y, float size);
80  void SetCursor(int n);
81 
82  void AdjustCoords(float *x, float *y, float *w, float *h);
83  bool ClippedCoords(float *x, float *y, float *w, float *h);
84  bool ClippedCoords(float *x, float *y, float *w, float *h, float *s1, float *t1, float *s2, float *t2);
85 
86  void PushClipRect(float x, float y, float w, float h);
88  void PopClipRect();
89 
90  void EnableClipping(bool b) { enableClipping = b; };
91  void SetFont( int num );
92 
93  void SetOverStrike(bool b) { overStrikeMode = b; }
94 
95  bool GetOverStrike() { return overStrikeMode; }
96 
97  void DrawEditCursor(float x, float y, float scale);
98 
99  enum {
103  };
104 
105  enum {
109  };
110 
111  enum {
120  };
121 
127  static idVec4 colorRed;
131 
132 private:
133  int DrawText(float x, float y, float scale, idVec4 color, const char *text, float adjust, int limit, int style, int cursor = -1);
134  void PaintChar(float x,float y,float width,float height,float scale,float s,float t,float s2,float t2,const idMaterial *hShader);
135  void SetFontByScale( float scale );
136  void Clear( void );
137 
144  float xScale;
145  float yScale;
146 
147  float vidHeight;
148  float vidWidth;
149 
150  int cursor;
151 
153 
156 
158 
160 
164 
165  bool mbcs;
166 };
167 
168 #endif /* !__DEVICECONTEXT_H__ */
void SetTransformInfo(const idVec3 &origin, const idMat3 &mat)
byte color[4]
Definition: MegaTexture.cpp:54
fontInfo_t * useFont
const int VIRTUAL_WIDTH
Definition: DeviceContext.h:37
static idVec4 colorYellow
void DrawEditCursor(float x, float y, float scale)
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:4804
void DrawMaterialRect(float x, float y, float w, float h, float size, const idMaterial *mat, const idVec4 &color)
GLenum GLint GLint y
Definition: glext.h:2849
GLenum GLsizei n
Definition: glext.h:3705
static idVec4 colorGreen
const idMaterial * whiteImage
Definition: Vector.h:316
static idVec4 colorOrange
fontInfoEx_t * activeFont
static idVec4 colorWhite
void PushClipRect(float x, float y, float w, float h)
GLdouble s
Definition: glext.h:2935
GLenum GLint x
Definition: glext.h:2849
void SetFont(int num)
GLuint GLuint num
Definition: glext.h:5390
bool ClippedCoords(float *x, float *y, float *w, float *h)
void SetFontByScale(float scale)
static idVec4 colorPurple
int FindFont(const char *name)
void DrawMaterialRotated(float x, float y, float w, float h, const idMaterial *mat, const idVec4 &color, float scalex=1.0, float scaley=1.0, float angle=0.0f)
static idVec4 colorBlue
int MaxCharWidth(float scale)
const idMaterial * scrollBarImages[SCROLLBAR_COUNT]
int DrawText(const char *text, float textScale, int textAlign, idVec4 color, idRectangle rectDraw, bool wrap, int cursor=-1, bool calcOnly=false, idList< int > *breaks=NULL, int limit=0)
GLuint index
Definition: glext.h:3476
const GLubyte * c
Definition: glext.h:4677
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:3454
Definition: Vector.h:808
idRegion * GetTextRegion(const char *text, float textScale, idRectangle rectDraw, float xStart, float yStart)
int TextWidth(const char *text, float scale, int limit)
void DrawFilledRect(float x, float y, float width, float height, const idVec4 &color)
#define NULL
Definition: Lib.h:88
void DrawStretchPic(float x, float y, float w, float h, float s0, float t0, float s1, float t1, const idMaterial *mat)
void GetTransformInfo(idVec3 &origin, idMat3 &mat)
void EnableClipping(bool b)
Definition: DeviceContext.h:90
GLenum GLsizei width
Definition: glext.h:2846
int MaxCharHeight(float scale)
static idVec4 colorNone
void SetOverStrike(bool b)
Definition: DeviceContext.h:93
GLenum GLsizei GLsizei height
Definition: glext.h:2856
void DrawCursor(float *x, float *y, float size)
static idVec4 colorBlack
GLubyte GLubyte b
Definition: glext.h:4662
int CharWidth(const char c, float scale)
idList< idRectangle > clipRects
GLdouble GLdouble GLdouble r
Definition: glext.h:2951
Definition: Matrix.h:333
bool GetOverStrike()
Definition: DeviceContext.h:95
void AdjustCoords(float *x, float *y, float *w, float *h)
tuple f
Definition: idal.py:89
const GLcharARB * name
Definition: glext.h:3629
GLsizeiptr size
Definition: glext.h:3112
void PaintChar(float x, float y, float width, float height, float scale, float s, float t, float s2, float t2, const idMaterial *hShader)
Definition: Str.h:116
void EnableLocalization()
void SetCursor(int n)
const idMaterial * cursorImages[CURSOR_COUNT]
int TextHeight(const char *text, float scale, int limit)
static idList< fontInfoEx_t > fonts
void SetSize(float width, float height)
void DrawStretchPicRotated(float x, float y, float w, float h, float s0, float t0, float s1, float t1, const idMaterial *mat, float angle=0.0f)
void DrawMaterial(float x, float y, float w, float h, const idMaterial *mat, const idVec4 &color, float scalex=1.0, float scaley=1.0)
const idMaterial * GetScrollBarImage(int index)
const int BLINK_DIVISOR
Definition: DeviceContext.h:39
void DrawRect(float x, float y, float width, float height, float size, const idVec4 &color)
static idVec4 colorRed
GLdouble GLdouble t
Definition: glext.h:2943
const int VIRTUAL_HEIGHT
Definition: DeviceContext.h:38