From: Michael H. <mh...@us...> - 2000-12-13 22:34:15
|
Update of /cvsroot/pythianproject/Prototypes/GLCanvas In directory slayer.i.sourceforge.net:/tmp/cvs-serv22700/GLCanvas Modified Files: QuadTextUnit.pas glCanvas.pas Log Message: added underlining to GLCanvas. fixed text bug. -mike Index: QuadTextUnit.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/QuadTextUnit.pas,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** QuadTextUnit.pas 2000/12/12 22:15:56 1.6 --- QuadTextUnit.pas 2000/12/13 22:34:11 1.7 *************** *** 43,48 **** COURIERNEW_WIDTHS :TQuadTextWidthsArray = ( 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 8, 8, 8, 8, 8, 8, 8, 8, 3, 3, 8, 3, 12, 8, 8, 8, 8, 5, 8, 5, 8, 8, --- 43,48 ---- COURIERNEW_WIDTHS :TQuadTextWidthsArray = ( + 10, 10, 10, 10, 10, 10, 10, 10, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 8, 8, 8, 8, 8, 8, 8, 8, 3, 3, 8, 3, 12, 8, 8, 8, 8, 5, 8, 5, 8, 8, *************** *** 69,72 **** --- 69,74 ---- 12, 5, 7, 2, 8, 8, 2, 2, 4, 4, 12, 15, 15); + + QT_UNDERLINE_CHARACTER = '|'; type TQuadText = record *************** *** 160,163 **** --- 162,166 ---- var o,a:integer; + underline:boolean; begin glMatrixMode(GL_TEXTURE); // modify texture matrix; *************** *** 168,188 **** glPushMatrix; glPushMatrix; if length(s) = 1 then begin qtDrawGridChar(qt,s[1]); end else - for a := 1 to Length(s) do begin ! if s[a] = #13 then begin ! glPopMatrix; ! glTranslatef(0,QT.GridSquareHeight,0); // translate down ! glPushMatrix; ! end else if s[a] <> #$A then begin ! o := qtDrawGridChar(QT,s[a]); ! if o <> -1 then ! glTranslatef(QT.TexWidths[o]+QT.GridCharSpacing,0,0) ! else // translate for space character ! glTranslatef(QT.SpaceWidth,0,0); end; end; --- 171,208 ---- glPushMatrix; glPushMatrix; + underline := false; if length(s) = 1 then begin qtDrawGridChar(qt,s[1]); end else begin ! a := 1; ! while a <= Length(s) do begin ! if s[a] = #13 then ! begin ! glPopMatrix; ! glTranslatef(0,QT.GridSquareHeight,0); // translate down ! glPushMatrix; ! end else if s[a] = QT_UNDERLINE_CHARACTER then ! underline := not underline ! else if s[a] <> #$A then begin ! o := qtDrawGridChar(QT,s[a]); ! if o <> -1 then ! begin ! if underline then ! begin ! glDisable(GL_TEXTURE_2D); ! glBegin(GL_LINES); ! glVertex2i(0,QT.GridSquareHeight); ! glVertex2i(QT.TexWidths[o]+QT.GridCharSpacing,QT.GridSquareHeight); ! glEnd; ! glEnable(GL_TEXTURE_2D); ! end; ! glTranslatef(QT.TexWidths[o]+QT.GridCharSpacing,0,0) ! end else // translate for space character ! glTranslatef(QT.SpaceWidth,0,0); ! end; ! inc(a); end; end; Index: glCanvas.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/glCanvas.pas,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** glCanvas.pas 2000/12/12 22:15:57 1.12 --- glCanvas.pas 2000/12/13 22:34:12 1.13 *************** *** 226,229 **** --- 226,230 ---- function GetWidth(index: integer): integer; + class procedure FreeRegisteredFonts; public *************** *** 232,237 **** QT:TQuadText; //quadtext record for this text object ! // the fontname property holds a filename for GLF ! // or another ID for a different text system property FontName :string read FFontName write SetFontName; property Lines:TStringList read FLines; --- 233,237 ---- QT:TQuadText; //quadtext record for this text object ! // the fontname property holds a font name property FontName :string read FFontName write SetFontName; property Lines:TStringList read FLines; *************** *** 333,336 **** --- 333,337 ---- GLCanvasFonts :TList; + function CompareRect(r1,r2:TRect):boolean; begin *************** *** 552,557 **** end; end; - glPopAttrib; end; --- 553,559 ---- end; end; + // restore clipping rect + SetClipping(FClipRect); glPopAttrib; end; *************** *** 791,795 **** end else if TextType = GLCANVAS_TEXT_QUADTEXT then begin - if assigned(FTexture) then FTexture.Free; // if not already loaded if not assigned(f.Texture) then --- 793,796 ---- *************** *** 1108,1111 **** --- 1109,1124 ---- end; + class procedure TGLText.FreeRegisteredFonts; + var + o:Tobject; + begin + while GLCanvasFonts.Count > 0 do + begin + o := TObject(GLCanvasFonts[0]); + GLCanvasFonts.Delete(0); + o.Free; + end; + end; + { TGLTexturedFont } *************** *** 1134,1137 **** --- 1147,1151 ---- finalization + TGLText.FreeRegisteredFonts; GLCanvasFonts.Free; |