|
1 | 1 | (******************************************************************************) |
2 | 2 | (* uOpenGL_WidgetSet.pas ??.??.???? *) |
3 | 3 | (* *) |
4 | | -(* Version : 0.07 *) |
| 4 | +(* Version : 0.08 *) |
5 | 5 | (* *) |
6 | 6 | (* Author : Uwe Schächterle (Corpsman) *) |
7 | 7 | (* *) |
|
33 | 33 | (* 0.05 = Erlauben OnClick für TOpenGl_Image *) |
34 | 34 | (* 0.06 = Umbau auf ueventer.pas *) |
35 | 35 | (* 0.07 = Umstellen auf smClamp => deutlich bessere Graphiken *) |
| 36 | +(* 0.08 = Support für OpenGLASCIIFont *) |
36 | 37 | (* *) |
37 | 38 | (******************************************************************************) |
38 | 39 |
|
|
57 | 58 | LCLType, |
58 | 59 | lclintf, |
59 | 60 | uopengl_graphikengine, |
| 61 | + uopengl_font_common, |
60 | 62 | ueventer; |
61 | 63 |
|
62 | 64 | Type |
|
84 | 86 | Function FGetFontSize: single; |
85 | 87 | Procedure FSetFontSize(value: Single); |
86 | 88 | protected |
87 | | - FFont: TOpenGL_TrueType_Font; // Das Kontrollelement bekommt noch zusätzlich eine OpenGLFont |
| 89 | + FFont: TOpenGL_Font; // Das Kontrollelement bekommt noch zusätzlich eine OpenGLFont |
88 | 90 | Property FontColor: TVector3 read fGetFontColor write fSetFontColor; |
89 | 91 | Property FontSize: Single read FGetFontSize write FSetFontSize; |
90 | 92 | public |
|
849 | 851 | glvertex2f(left + 2, 4 + top + round(ffont.TextHeight('8') * (i + 0))); |
850 | 852 | glend; |
851 | 853 | End; |
852 | | - ffont.Color3v := FLineColors[fTopIndex + i]; |
| 854 | + ffont.Colorv3 := FLineColors[fTopIndex + i]; |
853 | 855 | s := FItems[i + fTopIndex]; |
854 | 856 | While (ffont.TextWidth(s) > width - 4 - ScrollbarWidth) And (s <> '') Do Begin |
855 | 857 | delete(s, length(s), 1); |
|
1173 | 1175 | While (FFont.TextWidth(tex) > Width - 6) And (tex <> '') Do Begin |
1174 | 1176 | delete(tex, 1, 1); |
1175 | 1177 | End; |
1176 | | - FFont.Color3v := FontColor; |
| 1178 | + FFont.Colorv3 := FontColor; |
1177 | 1179 | FFont.Textout(left + 2, top + 2, tex); |
1178 | 1180 | // Dann den Cursor |
1179 | 1181 | If FFocus Then Begin |
|
1234 | 1236 |
|
1235 | 1237 | Function TOpenGL_BaseFontClass.fGetFontColor: TVector3; |
1236 | 1238 | Begin |
1237 | | - result := FFont.Color3v; |
| 1239 | + result := FFont.ColorV3; |
1238 | 1240 | End; |
1239 | 1241 |
|
1240 | 1242 | Procedure TOpenGL_BaseFontClass.fSetFontColor(Value: TVector3); |
1241 | 1243 | Begin |
1242 | | - FFont.Color3v := value; |
| 1244 | + FFont.Colorv3 := value; |
1243 | 1245 | End; |
1244 | 1246 |
|
1245 | 1247 | Function TOpenGL_BaseFontClass.FGetFontSize: single; |
|
1255 | 1257 | Constructor TOpenGL_BaseFontClass.create(Owner: TOpenGLControl; FontFile: String |
1256 | 1258 | ); |
1257 | 1259 | Begin |
1258 | | - FFont := TOpenGL_TrueType_Font.Create(); |
1259 | | - ffont.LoadfromFile(FontFile); |
| 1260 | + If (FontFile <> '') And FileExists(FontFile) Then Begin |
| 1261 | + FFont := TOpenGL_TrueType_Font.Create(); |
| 1262 | + TOpenGL_TrueType_Font(ffont).LoadfromFile(FontFile); |
| 1263 | + End |
| 1264 | + Else Begin |
| 1265 | + If Not assigned(OpenGL_ASCII_Font) Then Begin |
| 1266 | + Create_ASCII_Font; |
| 1267 | + End; |
| 1268 | + FFont := OpenGL_ASCII_Font; |
| 1269 | + End; |
1260 | 1270 | Inherited create(Owner); |
1261 | 1271 | End; |
1262 | 1272 |
|
1263 | 1273 | Destructor TOpenGL_BaseFontClass.destroy; |
1264 | 1274 | Begin |
1265 | | - ffont.free; |
| 1275 | + If OpenGL_ASCII_Font <> FFont Then Begin |
| 1276 | + ffont.free; |
| 1277 | + End; |
1266 | 1278 | Inherited destroy; |
1267 | 1279 | End; |
1268 | 1280 |
|
|
0 commit comments