You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(18) |
Oct
(33) |
Nov
(27) |
Dec
(26) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(22) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(46) |
Sep
|
Oct
|
Nov
|
Dec
|
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
(13) |
May
(7) |
Jun
(9) |
Jul
(23) |
Aug
(5) |
Sep
(4) |
Oct
(6) |
Nov
(1) |
Dec
|
2009 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Michael H. <mh...@us...> - 2000-12-15 18:36:33
|
Update of /cvsroot/pythianproject/Prototypes/GUISystem In directory slayer.i.sourceforge.net:/tmp/cvs-serv31590/GUISystem Modified Files: StartupForm.pas vglClasses.pas vglStdCtrls.pas Log Message: added multi-line edit -mike Index: StartupForm.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/StartupForm.pas,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** StartupForm.pas 2000/12/13 22:34:12 1.9 --- StartupForm.pas 2000/12/15 18:36:31 1.10 *************** *** 3,7 **** interface ! { bug: Doesn't work in fullscreen mode - probably because of fault in GLForms } uses --- 3,9 ---- interface ! // undefine this to force fonts directory to be same as app directory ! // when defined fonts are in ..\GLCanvas ! {$DEFINE DEVELOPMENT} uses *************** *** 25,31 **** CB: TvglCheckBox; cc: TvglComponent; ! Elapsed,FirstTime:Cardinal; ! ClipTestP1,ClipTestP2,ClipTestP3,ClipTestP4 :TvglPanel; public { Public declarations } --- 27,34 ---- CB: TvglCheckBox; cc: TvglComponent; ! Edit1:TvglEdit; ClipTestP1,ClipTestP2,ClipTestP3,ClipTestP4 :TvglPanel; + + Elapsed,FirstTime:Cardinal; public { Public declarations } *************** *** 44,47 **** --- 47,52 ---- procedure CB1OnChange(Sender:TObject); + procedure ManagerOnFocusChange(Sender:TObject); + procedure go; end; *************** *** 72,83 **** Elapsed := timeGetTime - FirstTime; // elapsed time from beginning - GLForm.Run InterfaceManager.Update(Elapsed); ! if cc <> InterfaceManager.Focused then ! begin ! cc := InterfaceManager.Focused; ! if cc <> nil then ! Label1.Lines.Text := cc.Name ! else ! Label1.Lines.Text := 'FOCUS LOST!'; ! end; InterfaceManager.DrawAll; end; --- 77,81 ---- Elapsed := timeGetTime - FirstTime; // elapsed time from beginning - GLForm.Run InterfaceManager.Update(Elapsed); ! InterfaceManager.DrawAll; end; *************** *** 159,163 **** --- 157,163 ---- GLForm.Open; + {$IFDEF DEVELOPMENT} FontsDirectory := '..\GLCanvas\'; + {$ENDIF} if not GLForm.FullScreen then GLC := TGLCanvas.Create(GLForm.Width-6,GLForm.Height-25) // must take into account window borders *************** *** 170,176 **** else InterfaceManager := TvglInterfaceManager.Create(GLForm.Handle, GLC); // create test components Panel1 := TvglPanel.Create('Panel1',InterfaceManager.Desktop); ! Panel1.Bounds := Rect(50,50,250,250); Panel1.Textured := True; Panel1.OnMouseDown := Panel1OnMouseDown; --- 170,178 ---- else InterfaceManager := TvglInterfaceManager.Create(GLForm.Handle, GLC); + InterfaceManager.OnFocusChange := ManagerOnFocusChange; + // create test components Panel1 := TvglPanel.Create('Panel1',InterfaceManager.Desktop); ! Panel1.Bounds := Rect(10,30,200,200); Panel1.Textured := True; Panel1.OnMouseDown := Panel1OnMouseDown; *************** *** 221,226 **** Label1 := TvglTextBox.Create('Label1',InterfaceManager.Desktop); ! Label1.Top := 320; ! Label1.Left := 20; Label1.Color := clBlack; Label1.Font := 'Courier New'; --- 223,228 ---- Label1 := TvglTextBox.Create('Label1',InterfaceManager.Desktop); ! Label1.Top := 192; ! Label1.Left := 468; Label1.Color := clBlack; Label1.Font := 'Courier New'; *************** *** 249,252 **** --- 251,259 ---- LB.ScrollBars := ssBoth; + Edit1 := TvglEdit.Create('Edit1',InterfaceManager.Desktop); + Edit1.Bounds := Rect(20,300,220,400); + Edit1.Lines.Add('Hello World 1'); + Edit1.Lines.Add('Hello World 2'); + InterfaceManager.SetNewFocus(LB); Hide; *************** *** 269,272 **** --- 276,291 ---- CB.Caption := 'Checked' else CB.Caption := 'Unchecked'; + end; + + procedure TfrmStartup.ManagerOnFocusChange(Sender: TObject); + begin + if cc <> InterfaceManager.Focused then + begin + cc := InterfaceManager.Focused; + if cc <> nil then + Label1.Lines.Text := cc.Name + else + Label1.Lines.Text := 'FOCUS LOST!'; + end; end; Index: vglClasses.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/vglClasses.pas,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** vglClasses.pas 2000/12/13 20:25:21 1.6 --- vglClasses.pas 2000/12/15 18:36:31 1.7 *************** *** 37,46 **** - Resource sharing (done except reference counting/garbage collection) - Name generation/usage (!) - - Events (pretty much done) - Display list optimizations - Components - - Improve name creation algorithm - Done: - Decent parent/child relationships implementation, drawing etc. --- 37,43 ---- *************** *** 179,182 **** --- 176,180 ---- procedure SetOnKeyDown(const Value: TVGLKeyboardEvent); procedure SetOnKeyUp(const Value: TVGLKeyboardEvent); + function KeyDataToShiftState(KeyData: Longint): TShiftState; protected FFocusable: Boolean; *************** *** 392,395 **** --- 390,394 ---- FSwitchingTo, FLastFocused: TvglComponent; + FOnFocusChange: TNotifyEvent; // these are used to generate onMouseEntry, onMouseExit events NewMouseList, OldMouseList, TempMouseList :TvglObjList; *************** *** 422,425 **** --- 421,426 ---- // resource management function GetResource(aName:string):TObject; + + // focus procedure SetNewFocus(C: TvglComponent); *************** *** 433,436 **** --- 434,438 ---- published property OnCreateDesktop: TCreateDesktopEvent read FOnCreateDesktop write SetOnCreateDesktop; + property OnFocusChange :TNotifyEvent read FOnFocusChange write FOnFocusChange; end; *************** *** 955,958 **** --- 957,970 ---- end; + function TvglComponent.KeyDataToShiftState(KeyData: Longint): TShiftState; + const + AltMask = $20000000; + begin + Result := []; + if GetKeyState(VK_SHIFT) < 0 then Include(Result, ssShift); + if GetKeyState(VK_CONTROL) < 0 then Include(Result, ssCtrl); + if KeyData and AltMask <> 0 then Include(Result, ssAlt); + end; + { TvglObjList } *************** *** 993,996 **** --- 1005,1009 ---- FMouseCursor := TvglMouseCursor.Create('MouseCursor',Desktop); FFocusedComponent := nil; + FOnFocusChange := nil; FSwitchingTo := nil; FLastFocused := nil; *************** *** 1207,1232 **** procedure TvglPanel.DrawSelf(where:TRect); - var - curClip,newClip:TRect; - tilex,tiley:integer; - texwidth,texheight:integer; begin inherited DrawSelf(where); if Textured then ! begin ! CurClip := Canvas.ClipRect; ! NewClip := FitRectToRect(where,CurClip); ! Canvas.SetClipping(NewClip); ! ! // tile the texture ! texwidth := VGL_SKINRECT_BACKGROUND.Right-VGL_SKINRECT_BACKGROUND.Left-1; ! texheight := VGL_SKINRECT_BACKGROUND.Bottom-VGL_SKINRECT_BACKGROUND.Top-1; ! for tilex := 0 to ((where.Right-where.Left) div texWidth) do ! for tiley := 0 to ((where.bottom-where.top) div texHeight) do ! Canvas.DrawBitmapSubRect(where.Left+(tilex*texwidth),where.Top+(tiley*texHeight),VGL_SKINRECT_BACKGROUND,FTexture); ! ! Canvas.SetClipping(CurClip); ! end else ! begin Canvas.CurrentColor := FColor; Canvas.Solid := true; --- 1220,1228 ---- procedure TvglPanel.DrawSelf(where:TRect); begin inherited DrawSelf(where); if Textured then ! Canvas.TileBitmapSubRect(FitRectToRect(where,Canvas.ClipRect),VGL_SKINRECT_BACKGROUND,FTexture) ! else begin Canvas.CurrentColor := FColor; Canvas.Solid := true; *************** *** 1353,1356 **** --- 1349,1354 ---- if Assigned(FFocusedComponent) then FFocusedComponent.DoSetFocus; + + if assigned(FOnFocusChange) then FOnFocusChange(FFocusedComponent); end; Index: vglStdCtrls.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/vglStdCtrls.pas,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** vglStdCtrls.pas 2000/12/13 22:34:12 1.4 --- vglStdCtrls.pas 2000/12/15 18:36:31 1.5 *************** *** 32,36 **** interface ! uses Windows, GLCanvas, Classes, vglClasses, Graphics; const --- 32,36 ---- interface ! uses Windows, GLCanvas, Classes, vglClasses, Graphics, SysUtils; const *************** *** 311,317 **** end; implementation uses ! Consts, Math; const --- 311,344 ---- end; + TvglEdit = class(TVGLComponent) + protected + FCursorX: integer; + FCursorY: integer; + FLines :TStringList; + FText :TGLText; + FColor: TColor; + function GetComponentType:string; override ; + procedure SetCursorX(const Value: integer); + procedure SetCursorY(const Value: integer); + procedure DoOnKeyDown(KeyCode, KeyData: Integer; KBMOD: TVGLKBModifiers; var AllowHP: Boolean); override; + public + constructor Create(aName:String; aOwner:TvglComponent); + destructor Destroy; override ; + + procedure DrawSelf(where:TRect); override ; + procedure Update(const ElapsedTime: Cardinal); override; + + { these specify the character "after" which the cursor appears } + property CursorX :integer read FCursorX write SetCursorX; + property CursorY :integer read FCursorY write SetCursorY; + published + property Lines :TStringList read FLines; + property Text :TGLText read FText; + property Color :TColor read FColor write FColor; + end; + implementation uses ! Consts, Math, QuadTextUnit; const *************** *** 1266,1274 **** begin inherited DoOnMouseClick(x, y); ! if PointInRect(GetCheckMarkBounds(ScreenBounds), X, Y) then ! begin ! FChecked := not FChecked; ! DoChanged; ! end; end; --- 1293,1298 ---- begin inherited DoOnMouseClick(x, y); ! FChecked := not FChecked; ! DoChanged; end; *************** *** 1450,1454 **** begin inherited DrawSelf(where); - //@@todo - text centreing case FButtonState of vglbsUp: FImage.Intensity := 255; --- 1474,1477 ---- *************** *** 1460,1464 **** tw := FCaptionText.Width[0]; if FCaptionText.Text <> '' then ! Canvas.DrawText( ((where.Right-where.Left-16))-(tw div 2), where.top+12,FCaptionText); end; --- 1483,1487 ---- tw := FCaptionText.Width[0]; if FCaptionText.Text <> '' then ! Canvas.DrawText( where.left+((where.Right-where.Left) div 2)-(tw div 2), where.top+12,FCaptionText); end; *************** *** 1577,1580 **** --- 1600,1701 ---- Width := longest; Height := FText.Lines.Count*FText.QT.GridSquareHeight; + end; + + { TvglEdit } + + constructor TvglEdit.Create(aName:String; aOwner:TvglComponent); + begin + inherited Create(aName,aOwner); + FText := TGLText.Create('Arial'); + Color := clGreen; + FLines := FText.Lines; + CursorX := 3; CursorY := 2; + FFocusable := true; + FAcceptsChildren := false; + end; + + destructor TvglEdit.Destroy; + begin + FText.Free; + inherited; + end; + + procedure TvglEdit.DoOnKeyDown(KeyCode, KeyData: Integer; + KBMOD: TVGLKBModifiers; var AllowHP: Boolean); + var s:string; + begin + inherited; + AllowHP := false; + case KeyCode of + VK_LEFT :if CursorX > 0 then dec(FCursorX); + VK_RIGHT:if CursorX < Length(Lines[FCursorY-1]) then inc(FCursorX); + VK_UP :if CursorY > 1 then CursorY := CursorY - 1; + VK_DOWN :if CursorY < Lines.Count then CursorY := CursorY + 1; + else + if (KeyCode = VK_BACK) then + begin + if CursorX > 0 then + begin + s := FLines[CursorY-1]; + Delete(s,CursorX,1); + FLines[CursorY-1] := s; + CursorX := CursorX - 1; + end; + end else if (KeyCode = VK_RETURN) then + begin + FLines.Insert(CursorY,Copy(Flines[CursorY-1],CursorX,Length(FLines[CursorY-1]))); // add new line + FLines[CursorY-1] := Copy(FLines[CursorY-1],0,CursorX); + CursorX := 0; CursorY := CursorY + 1; + end else if (KeyCode <> VK_SHIFT) and (KeyCode <> VK_MENU) and (KeyCode <> VK_CONTROL) then + begin + s := FLines[CursorY-1]; + Insert(Char(KeyCode),s,CursorX+1); // BUG: shift key has no effect :( + FLines[CursorY-1] := s; + CursorX := CursorX + 1; + end; + end; + end; + + procedure TvglEdit.DrawSelf(where: TRect); + var + i,cx,cy:integer; + begin + inherited DrawSelf(where); + Canvas.CurrentColor := Color; + Canvas.Solid := false; + Canvas.Rectangle(where.left,where.top,where.right,where.bottom); + Canvas.Solid := true; + Canvas.FillAlpha := 0.5; + Canvas.Rectangle(where.left,where.top,where.right,where.bottom); + + Canvas.SetClipping(Where); + Canvas.DrawText(where.left+2,where.top,FText); + + // draw the cursor + cx := FText.StringWidth(Copy(FText.Lines[CursorY-1],0,CursorX)); + Canvas.CurrentColor := clWhite; + Canvas.Line(where.left+cx+1,where.Top+((CursorY-1)*FText.QT.GridSquareHeight)+3,where.left+cx+1,where.Top + (CursorY*FText.QT.GridSquareHeight)-3); + end; + + function TvglEdit.GetComponentType: string; + begin + result := 'Edit'; + end; + + procedure TvglEdit.SetCursorX(const Value: integer); + begin + FCursorX := Value; + end; + + procedure TvglEdit.SetCursorY(const Value: integer); + begin + FCursorY := Value; + end; + + procedure TvglEdit.Update(const ElapsedTime: Cardinal); + begin + // check cursor bounds are ok + if CursorY > FLines.Count then CursorY := FLines.Count; + if CursorX > Length(Flines[CursorY-1]) then CursorX := Length(Flines[CursorY-1]); end; |
From: Michael H. <mh...@us...> - 2000-12-15 18:36:33
|
Update of /cvsroot/pythianproject/Prototypes/GLCanvas In directory slayer.i.sourceforge.net:/tmp/cvs-serv31590/GLCanvas Modified Files: glCanvas.pas glcanvas.htm Log Message: added multi-line edit -mike Index: glCanvas.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/glCanvas.pas,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** glCanvas.pas 2000/12/13 22:34:12 1.13 --- glCanvas.pas 2000/12/15 18:36:29 1.14 *************** *** 50,53 **** --- 50,56 ---- New- TRGB, ColorToRGB + Line drawing + Font structuring + Underline Notes- *************** *** 92,96 **** TTexBMPData = record DisplayList :integer; - //TexIDs :array[1..GLC_MAXTEXIDS] of Cardinal; Textures :array[1..GLC_MAXTEXIDS] of TTexture; cellsWidth, cellsHeight :integer; --- 95,98 ---- *************** *** 98,136 **** end; - { TGLCanvasFontData = record - Name, FileName:string; - FontType :integer; - end; - - TArrayOfGLCanvasFontData = array[1..GLC_MAXFONTS] of TGLCanvasFontData; } - - {const - GLC_DEFAULT_FONT_DATA :TArrayOfGLCanvasFontData = ( - (Name: 'Arial'; - FileName: 'arial1.glf'; - FontType: GLCANVAS_TEXT_GLF; - ), - (Name: 'Courier New'; - FileName: 'courier1.glf'; - FontType: GLCANVAS_TEXT_GLF; - ), - (Name: 'Courier New'; - FileName: 'CourierNew Grid.bmp'; - FontType: GLCANVAS_TEXT_QUADTEXT; - ), - (Name: 'Arial'; - FileName: 'Arial Grid.bmp'; - FontType: GLCANVAS_TEXT_QUADTEXT; - ), - (Name: 'VinerHand ITC'; - FileName: 'VinerHand ITC Grid.bmp'; - FontType: GLCANVAS_TEXT_QUADTEXT; - ) - ); } - - - type - TRGB = record r,g,b:byte; --- 100,104 ---- *************** *** 255,258 **** --- 223,227 ---- procedure SetColor(const Value: TColor); procedure LinesOnChange(Sender:TObject); // be sure to call if you override this event handler + function StringWidth(s:string):integer; // returns string width class procedure RegisterFont(name,filename:string;widths:TQuadTextWidthsArray); overload ; *************** *** 293,296 **** --- 262,267 ---- procedure DrawBitmap(X,Y:integer; bmp:TGLBitmap); virtual ; procedure DrawBitmapSubRect(X,Y:integer; SubRect:TRect; bmp:TGLBitmap); virtual ; + procedure TileBitmap(where:TRect; bmp:TGLBitmap); virtual ; + procedure TileBitmapSubRect(where,subRect:TRect; bmp:TGLBitmap); virtual ; // other *************** *** 307,310 **** --- 278,282 ---- // shape routines here - will standardise on the american spelling of colo(u)r procedure Rectangle(Left, Top, Right, Bottom:integer); virtual ; + procedure Line(X1,Y1,X2,Y2 :integer); virtual ; function ColorToRGB(c:TColor):TRGB; *************** *** 579,599 **** procedure TGLCanvas.Rectangle(Left, Top, Right, Bottom: integer); begin - (* glColor4f(FFillR,FFillG,FFillB,FFillAlpha); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity; - - //glScalef(2.0 / Width, -2.0 / Height, 1.0); - //glTranslatef(-(Width/2),-(Height/2),0); - glScalef(2.0 / Width, 2.0 / Height, 1.0); - glTranslatef(-(Width/2),(Height/2),0); - glScalef(1.0,-1.0,1.0); - - glBegin(GL_QUADS); - glVertex2i(Left,Top); - glVertex2i(Left,Bottom); - glVertex2i(Right,Bottom); - glVertex2i(Right,Top); - glEnd; *) - glDisable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); --- 551,554 ---- *************** *** 604,608 **** glScalef(2.0 / Width, 2.0 / Height, 1.0); glTranslatef(-(Width/2),(Height/2),0); - //glScalef(1.0,-1.0,1.0); if Solid then --- 559,562 ---- *************** *** 689,692 **** --- 643,685 ---- end; + procedure TGLCanvas.TileBitmap(where: TRect; bmp: TGLBitmap); + begin + TileBitmapSubRect(where,Rect(0,0,bmp.Width,bmp.Height),bmp); + end; + + + procedure TGLCanvas.TileBitmapSubRect(where, subRect: TRect; + bmp: TGLBitmap); + var + w,h,tilex,tiley:integer; + cr:TRect; + begin + // tile the texture + cr := FClipRect; + SetClipping(where); + w := subRect.Right-subRect.Left-1; + h := subRect.Bottom-subRect.Top-1; + for tilex := 0 to ((where.Right-where.Left) div w) do + for tiley := 0 to ((where.bottom-where.top) div h) do + DrawBitmapSubRect(where.Left+(tilex*w),where.Top+(tiley*h),subRect,bmp); + SetClipping(cr); // restore clipping + end; + + procedure TGLCanvas.Line(X1, Y1, X2, Y2: integer); + begin + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor4f(CurrentRed,CurrentGreen,CurrentBlue,FFillAlpha); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity; + glScalef(2.0 / Width, 2.0 / Height, 1.0); + glTranslatef(-(Width/2),(Height/2),0); + + glBegin(GL_LINES); + glVertex2i(X1, -Y1); + glVertex2i(X2, -Y2); + glEnd; + end; + { TGLText } *************** *** 1119,1122 **** --- 1112,1120 ---- o.Free; end; + end; + + function TGLText.StringWidth(s: string): integer; + begin + result := qtGetStringWidth(QT,s); end; Index: glcanvas.htm =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/glcanvas.htm,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** glcanvas.htm 2000/12/09 19:52:04 1.2 --- glcanvas.htm 2000/12/15 18:36:30 1.3 *************** *** 11,14 **** --- 11,16 ---- + + Hearn</a><br> <a href="mailto:d_...@sy...">Darryl Long</a><br> *************** *** 18,21 **** --- 20,24 ---- Change Log:<br> <br> + - 14th December 2000: Changed to reflect new font registration system<br> - 4th December 2000: Add info about InitMatrix (doh!)<br> <hr align="Left" width="100%" size="2"><br> *************** *** 24,39 **** --- 27,50 ---- + + drawing 2D graphics onto an OpenGL canvas much easier than it would otherwise + + be. The algorithms used in the canvas have been designed for speed and ease + + of use, not necessarily simplicity. This is why some operations with it + + may seem a strange way of doing things. Anyway, let's go.<br> <br> *************** *** 52,69 **** DrawText().<br> <br> <u>Drawing Images</u><br> <br> ! Images in OpenGL are not directly supported unless you use the glDrawPixels() ! ! command which directly copies pixel data from system memory to the pixel ! ! buffer. This would be ideal but unfortunately this is a <b>very</b>slow - operation, and I mean slow. Drawing a 640x480 image in this way on my machine - takes almost half a second :(<br> - Nevertheless, the Canvas supports this method for when performance is not --- 63,80 ---- + + DrawText().<br> <br> <u>Drawing Images</u><br> <br> ! Images in OpenGL are not directly supported unless you use the glDrawPixels() ! command which directly copies pixel data from system memory to the pixel ! buffer. This would be ideal but unfortunately this is a <b>very</b> ! slow operation, and I mean slow. Drawing a 640x480 image in this way on ! my machine takes almost half a second :(<br> ! Nevertheless, the Canvas supports this method for when performance is not *************** *** 75,102 **** --- 86,127 ---- + + things that results in much better framerates (ie. about 120fps on my machine + + for a 640x480 image :) This system breaks the image you want to draw into + + multiple textures and then uses polygons to display them. Because these + + images are hardware accellerated things move along much better. Why multiple + + textures? Well, most hardware cards have a limit of 256x256 pixels for textures + + due to the internals of their engines. So the canvas breaks an image into + + multiple textures when the image is loaded.<br> <br> *************** *** 105,116 **** --- 130,147 ---- + + by objects, in this case the TGLBitmap class is used. To use a bitmap it + + must be loaded into one of these objects, which can then be passed to the + + DrawBitmap() method of the GLCanvas. Here's an example:<br> <br> *************** *** 130,144 **** --- 161,187 ---- <br> Note that before any GLCanvas methods can be called you must call InitMatrix, + this initializes the co-ordinate systems. This example would display "logo.png"at + location 50,50 from the top left of the window. As you can see, there is + nothing to it. However, we can do more than this! The GLBitmap class supports + transparency using a transparent colour: if we set the transparent colour + to black then any black pixels in the picture will be see-through, meaning + you can draw non-rectangular bitmaps. This is done by setting the <code>UseTransparency</code>property + to true and setting the TransparentColor property to the colour you want + (it defaults to black). Because the GLCanvas is based partly on the FastDIB + library you must specify the colour as RGB data, not a Delphi colour constant. + Although in some places you can use constants like clBlack or clAqua in + this instance that's not allowed. You create a colour for this property + using the FRGB function:<br> <br> *************** *** 147,150 **** --- 190,195 ---- Picture.TransparentColor := FRGB(0,0,255); // blue is our transparent + + colour<br> Picture.LoadFromFile("logo.png");</code><br> *************** *** 152,155 **** --- 197,202 ---- Notice that you <i>must</i>set the transparency properties before loading + + the file. If you want you can use direct drawing by using a different constructor:<br> <br> *************** *** 158,161 **** --- 205,210 ---- However, this isn't really supported very well - for instance transparency + + doesn't work with this method. Also, it's slow so it's best to avoid this.<br> <br> *************** *** 163,184 **** <br> Again, OpenGL has no direct support for drawing text. There are many, many - different ways of drawing text (for more information on this subject check - - out NeHe's excellent <a href="http://nehe.gamedev.net/opengl/">tutorial pages</a>) and the Canvas - - offers you two which should combine the best of both worlds - bitmapped - text which looks nice at small sizes, and vector text which can be resized ! to any area needed without losing resolution. Vector fonts are drawn using - the <a href="http://romka.demonews.com">GLF library</a>written by Romka, who is a seriously - cool guy. You can get more fonts from his website.<br> - <br> - Bitmapped fonts are drawn using my own system that uses a 256x256 bitmap - - with letters arranged in a grid formation. Textured polygons are drawn that use this and this means <i>fast fast fast!</i><br> --- 212,230 ---- <br> Again, OpenGL has no direct support for drawing text. There are many, many + different ways of drawing text (for more information on this subject + check out NeHe's excellent <a href="http://nehe.gamedev.net/opengl/">tutorial pages</a>) and + the Canvas offers you two which should combine the best of both worlds - + bitmapped text which looks nice at small sizes, and vector text which + can be resized to any area needed without losing resolution. Vector fonts + are drawn using the <a href="http://romka.demonews.com">GLF library </a>written by Romka, + who is a seriously cool guy. You can get more fonts from his website.<br> + <br> + Bitmapped fonts are drawn using my own system that uses a 256x256 bitmap ! with letters arranged in a grid formation. Textured polygons are drawn that use this and this means <i>fast fast fast!</i><br> *************** *** 186,203 **** --- 232,265 ---- This also means that fonts are very easy to make, although it does take some + + time. You can use the included "20x20grid.bmp" file to help you create new + + fonts. To use the text facility you can use the TGLText object. The reason + + that text is represented by objects too is for performance reasons, when + + you use an object something called pre-caching becomes available which stores + + the commands for drawing the text in the hardware accellerator itself, meaning + + - yep, you've guessed it, faster execution! Of course, if this isn't important + + to you it's possible to use the DrawString() command for simplicity but + + it's really designed to use an object. Here's a simple example of it:<br> <br> *************** *** 216,225 **** --- 278,295 ---- As you can see, this is quite easy, but you can do more :) Text objects can + + have multiple lines (accessed through the Lines property), and of course + + this can be used to load text files. The demo program shows this in action. + + This uses textured quads to draw bitmapped text. To use the GLF vector based + + text:<br> <br> *************** *** 227,236 **** <br> begin<br> ! Text2 := TGLText.Create("Hello World","Arial",GLCANVAS_TEXT_GLF,GLC_DEFAULT_FONT_DATA);<br> // here we have used the other overloaded constructor to select GLF text. you can ignore<br> // the last parameter, it selects a font data array, the default one will do for now.<br> Text2.Size := 20;<br> --- 297,310 ---- <br> begin<br> ! Text2 := TGLText.Create("Hello World","Arial",GLCANVAS_TEXT_GLF);<br> // here we have used the other overloaded constructor to select GLF text. + + you can ignore<br> // the last parameter, it selects a font data array, the default one will + + do for now.<br> Text2.Size := 20;<br> *************** *** 238,245 **** end;</code><br> <br> ! If you want to change the directory fonts are loaded from (the default is ! for the current directory) you can set the FontsDirectory variable in the ! unit. This is a string that is appended to the start of the font filenames ! before they are loaded, and therefore they <b>must</b>have a / at the end. For instance:<br> <br> --- 312,319 ---- end;</code><br> <br> ! If you want to change the directory fonts are loaded from (the default is ! for the current directory) you can set the FontsDirectory variable in the ! unit. This is a string that is appended to the start of the font filenames ! before they are loaded, and therefore they <b>must</b>have a / at the end. For instance:<br> <br> *************** *** 248,261 **** <br> How you add new fonts depends on the system you use. If you're drawing vector - text you can simply download more GLF fonts from Romkas website but I'm ! ! not sure how you can make your own. Then you add the entry for it to the ! ! GLC_DEFAULT_FONT_DATA array as shown below. For bitmap text it's more complex ! ! (i'm afraid the canvas only comes with Arial and Courier New) but everything ! ! can be done using Paint Shop Pro or a similar program.<br> <br> To create a new bitmapped font:<br> --- 322,330 ---- <br> How you add new fonts depends on the system you use. If you're drawing vector text you can simply download more GLF fonts from Romkas website but I'm ! not sure how you can make your own. Then you register the font as shown ! below. For bitmap text it's more complex (i'm afraid the canvas only ! comes with Arial and Courier New) but everything can be done using Paint ! Shop Pro or a similar program.<br> <br> To create a new bitmapped font:<br> *************** *** 264,295 **** <li>Paste the "20x20 Grid.bmp" file over the top. This will show you where to place characters. If you want you can place the grid over the fonts that come with the canvas to see how it's done.</li> <li>For each character place the letter (in white) in each square aligned to the left of each grid square.</li> <li>Once this is done for every character (well, every character that is in the font set, you can see them in the other font grids) save it and change ! the GLCanvas.pas file in the following way:</li> ! <li>Add a new entry to the GLC_DEFAULT_FONT_DATA array. The fields are ! fairly self-explanatory, just make sure you set FontType to be GLCANVAS_TEXT_QUADTEXT.</li> <li>You also need to add a widths array to the QuadTextUnit.pas file. This array specifies the width of each character and is how the system support - variable width fonts. See the code for examples of how to do this.</li> - <li>Finally, you need to add an entry to the MatchFontWidths method of ! the TGLText class. This just returns the array given a font name.</li> <li>That's it! I know it's long winded, some time I may automate it but for now that's the way to do it. If you want to add some sort of exotic character not already in the font set add it to the array and set the rest of the widths in the other arrays to 0.</li> </ol> --- 333,385 ---- <li>Paste the "20x20 Grid.bmp" file over the top. This will show you where + + to place characters. If you want you can place the grid over the fonts that + + come with the canvas to see how it's done.</li> <li>For each character place the letter (in white) in each square aligned + + to the left of each grid square.</li> <li>Once this is done for every character (well, every character that is + + in the font set, you can see them in the other font grids) save it and change ! ! the GLCanvas.pas file in the following way:</li> <li>You also need to add a widths array to the QuadTextUnit.pas file. This + + array specifies the width of each character and is how the system support ! ! variable width fonts. See the code for examples of how to do this.</li> ! <li>Then you add an entry to the initialization section of the GLCanvas ! unit like this:<br> ! <br> ! TGLText.RegisterFont('Arial','Arial Grid.bmp',ARIAL_WIDTHS);<br> ! <br> ! where you specify the widths array you created above.<br> ! </li> <li>That's it! I know it's long winded, some time I may automate it but + + for now that's the way to do it. If you want to add some sort of exotic + + character not already in the font set add it to the array and set the rest + + of the widths in the other arrays to 0.</li> </ol> *************** *** 299,302 **** --- 389,394 ---- You can draw rectangles using the Rectangle() method. This takes 4 coordinates, + + X1, X2, Y1 and Y2. It draws a rectangle based on the:<br> <br> *************** *** 307,311 **** --- 399,407 ---- properties. If solid is true then the rectangle will be filled with the colour + + and at the opacity specified with FillAlpha. If solid is false then the + + outline is all that is drawn.<br> |
From: Kamil K. <kkr...@us...> - 2000-12-14 20:25:47
|
Update of /cvsroot/pythianproject/Prototypes/GUISystem In directory slayer.i.sourceforge.net:/tmp/cvs-serv5898 Added Files: vglEdits.pas Log Message: new unit --- NEW FILE --- unit vglEdits; { VGL Standard Editing Controls (C) 2000- The Pythian Project - Kamil Krauspe (kr...@gm...) } // KEY MIKE: see at my GetQByC function: you should implement this into your // QuadTextUnit - higher performance, though // In the edit component may be many bugs. // TODO: horiz. scrollbar. // Clipboard??? // optimize... // mouse selecting interface uses Windows, GLCanvas, Classes, vglClasses, Graphics, QuadTextUnit; type TvglEditNavigationAction = (venaPrev, venaNext, venaPrevLine, venaNextLine, venaTop, venaBottom, venaPageUp, venaPageDown); TvglNavigateEvent = procedure(var Action: TvglEditNavigationAction; var KBM: TVGLKBModifiers) of object; TvglWriteEvent = procedure(var Code: Char; var KBM: TVGLKBModifiers) of object; TvglSingleLineEdit = class(TvglComponent) // single line editor private FCharWidths: array of Integer; procedure RecalculateWidths; // recalculate FCharWidths procedure InsertChar(C: Char; Pos: Integer); procedure InsertString(S: string; Pos: Integer); procedure DeleteChar(Pos: Integer); procedure DeleteBlock(Start, Length: Integer); procedure ClearText; procedure InitializeWidths; procedure FinalizeWidths; protected FGLText: TGLText; FSelStart: Integer; FSelLength: Integer; FSelStarted: Integer; FTranslucency: Single; FSelTranslulency: Single; FFontName: string; FText: string; FSelTextColor: TColor; FFontColor: TColor; FSelColor: TColor; FColor: TColor; FCurX: Integer; FOnNavigate: TvglNavigateEvent; FOnWrite: TvglWriteEvent; FTimerDiff, FTimerLast: Cardinal; FTimerCursorVis: Boolean; FTimerInterval: Cardinal; function GetSelEnd: Integer; procedure SetSelEnd(const Value: Integer); procedure SetOnNavigate(const Value: TvglNavigateEvent); procedure SetOnWrite(const Value: TvglWriteEvent); procedure SetCurX(const Value: Integer); procedure SetColor(const Value: TColor); procedure SetFontColor(const Value: TColor); procedure SetFontName(const Value: string); procedure SetSelColor(const Value: TColor); procedure SetSelLength(const Value: Integer); procedure SetSelStart(const Value: Integer); procedure SetSelTextColor(const Value: TColor); procedure SetSelTranslulency(const Value: Single); procedure SetText(const Value: string); procedure SetTranslucency(const Value: Single); function GetComponentType: string; override; procedure DrawBackround(where: TRect); // background and selection background procedure DrawText(where: TRect); // the text with selected text procedure DrawCursor(where: TRect); procedure DoOnMouseDown(button, x, y: Integer); override; procedure DoOnMouseUp(button, x, y: Integer); override; procedure DoOnGlobalMouseMove(x, y: Integer); override; procedure DoOnKeyDown(KeyCode, KeyDown: Integer; KBMOD: TVGLKBModifiers; var AllowHP: Boolean); override; function GetWidthBy(Start, Pos: Integer): Integer; // getwidth of text from Start to Pos inclusive procedure TriggerNavigation(Action: TvglEditNavigationAction; KBM: TVGLKBModifiers); procedure TriggerWritting(Code: Char; KBM: TVGLKBModifiers); procedure DoOnNavigate(var Action: TvglEditNavigationAction; var KBM: TVGLKBModifiers); virtual; procedure DoOnWrite(var Code: Char; var KBM: TVGLKBModifiers); virtual; procedure Update(const ElapsedTime: Cardinal); override; procedure UpdateCursor; public constructor Create(aName:string; AOwner:TvglComponent); destructor Destroy; override ; procedure DrawSelf(where:TRect); override; function GetPosAt(X, Y: Integer; where: TRect): Integer; procedure SetDefHeight; published property SelStart: Integer read FSelStart write SetSelStart; property SelLength: Integer read FSelLength write SetSelLength; property SelEnd: Integer read GetSelEnd write SetSelEnd; property FontName: string read FFontName write SetFontName; property CurX: Integer read FCurX write SetCurX; // this supports only quadtext - GLF not support by now! property FontColor: TColor read FFontColor write SetFontColor; property Color: TColor read FColor write SetColor; property Translucency: Single read FTranslucency write SetTranslucency; property SelTranslulency: Single read FSelTranslulency write SetSelTranslulency; property SelColor: TColor read FSelColor write SetSelColor; property SelTextColor: TColor read FSelTextColor write SetSelTextColor; property Text: string read FText write SetText; property OnNavigate: TvglNavigateEvent read FOnNavigate write SetOnNavigate; property OnWrite: TvglWriteEvent read FOnWrite write SetOnWrite; end; implementation uses SysUtils, Math; const vgl_CursorBlinkRate = 500; function GetQByC(C: Char): Integer; var i: Integer; begin Result := -1; if (C >= 'a') and (C <= 'z') then Result := Ord(C) - 27 else if (C >= 'A') and (C <= 'Z') then Result := Ord(C) - 64 else if (C >= '1') and (C <= '9') then Result := Ord(C) + 4 else for i := 62 to NUMCHARS do if TEX_CHARS[i] = C then begin Result := i; Exit; end; end; { TvglSingleLineEdit } procedure TvglSingleLineEdit.ClearText; begin FText := ''; SetLength(FCharWidths, 0); FSelStart := 1; FSelLength := 1; end; constructor TvglSingleLineEdit.Create(aName: string; AOwner: TvglComponent); begin inherited Create(aName, aOwner); FFocusable := True; FAcceptsChildren := False; FGLText := TGLText.Create('Arial'); FGLText.SetColor(FFontColor); InitializeWidths; FColor := clWhite; FTranslucency := 0; FSelStart := 1; FSelLength := 0; FSelTranslulency := 0; FSelColor := clNavy; FSelTextColor := clWhite; FFontColor := clBlack; FTimerInterval := vgl_CursorBlinkRate; FOnNavigate := nil; FOnWrite := nil; Text := 'SingleLineEdit'; FCurX := 1; FTimerCursorVis := True; end; procedure TvglSingleLineEdit.DeleteBlock(Start, Length: Integer); begin if (Start < 0) or (Start > System.Length(FText)) then Exit; System.Delete(FText, Start, Length); RecalculateWidths; // in future this will be changed to optimize the code // ...and will use Move(...) to reorganize the FCharWidths faster end; procedure TvglSingleLineEdit.DeleteChar(Pos: Integer); begin DeleteBlock(Pos, 1); end; destructor TvglSingleLineEdit.Destroy; begin FGLText := nil; FinalizeWidths; inherited; end; procedure TvglSingleLineEdit.DoOnGlobalMouseMove(x, y: Integer); begin inherited; end; procedure TvglSingleLineEdit.DoOnKeyDown(KeyCode, KeyDown: Integer; KBMOD: TVGLKBModifiers; var AllowHP: Boolean); var i: Integer; C: Char; begin inherited; if (vkmAlt in KBMOD) or (vkmControl in KBMOD) then Exit; AllowHP := False; case KeyCode of VK_UP: TriggerNavigation(venaPrevLine, KBMOD); VK_DOWN: TriggerNavigation(venaNextLine, KBMOD); VK_LEFT: TriggerNavigation(venaPrev, KBMOD); VK_RIGHT: TriggerNavigation(venaNext, KBMOD); VK_HOME: TriggerNavigation(venaTop, KBMOD); VK_END: TriggerNavigation(venaBottom, KBMOD); VK_BACK: begin if SelLength = 0 then begin DeleteChar(CurX - 1); CurX := CurX - 1; end else begin DeleteBlock(SelStart, SelLength); SelLength := 0; CurX := SelStart; end; Text := FText; end; VK_DELETE: begin if SelLength = 0 then DeleteChar(CurX) else begin DeleteBlock(SelStart, SelLength); SelLength := 0; CurX := SelStart; end; Text := FText; UpdateCursor; end; else if (KeyCode >= VK_NUMPAD0) and (KeyCode <= VK_NUMPAD9) then KeyCode := KeyCode - 48; C := Chr(KeyCode); if not (vkmShift in KBMOD) then C := LowerCase(C)[1]; i := GetQByC(C); if (i > 0) or (KeyCode = VK_SPACE) then TriggerWritting(C, KBMOD) else AllowHP := True; end; end; procedure TvglSingleLineEdit.DoOnMouseDown(button, x, y: Integer); begin inherited; CurX := GetPosAt(X, Y, ScreenBounds); end; procedure TvglSingleLineEdit.DoOnMouseUp(button, x, y: Integer); begin inherited; end; procedure TvglSingleLineEdit.DoOnNavigate( var Action: TvglEditNavigationAction; var KBM: TVGLKBModifiers); begin if Assigned(FOnNavigate) then FOnNavigate(Action, KBM); end; procedure TvglSingleLineEdit.DoOnWrite(var Code: Char; var KBM: TVGLKBModifiers); begin if Assigned(FOnWrite) then FOnWrite(Code, KBM); end; procedure TvglSingleLineEdit.DrawBackround(where: TRect); begin FCanvas.CurrentColor := FColor; FCanvas.FillAlpha := 1 - FTranslucency; FCanvas.Solid := True; FCanvas.Rectangle(where.Left, where.Top, where.Right, where.Bottom); FCanvas.Solid := False; FCanvas.FillAlpha := 1; FCanvas.Rectangle(where.Left, where.Top, where.Right, where.Bottom); end; procedure TvglSingleLineEdit.DrawCursor(where: TRect); var i, h: Integer; begin FCanvas.SetClipping(where); i := GetWidthBy(1, CurX - 1); h := FGLText.QT.GridSquareHeight; FCanvas.CurrentRed := 1 - FCanvas.CurrentRed; FCanvas.CurrentGreen := 1 - FCanvas.CurrentGreen; FCanvas.CurrentBlue := 1 - FCanvas.CurrentBlue; FCanvas.FillAlpha := 1; FCanvas.Solid := True; FCanvas.Rectangle(where.Left + i, where.Top, where.Left + i + 1, where.Top + h); FCanvas.CancelClipping; end; procedure TvglSingleLineEdit.DrawSelf(where: TRect); begin inherited; DrawBackround(where); DrawText(where); if Focused and FTimerCursorVis then DrawCursor(where); end; procedure TvglSingleLineEdit.DrawText(where: TRect); var w: Integer; l1, l2, l3: Integer; // widths of blocks: before sel., selection, after selection r1: TRect; begin w := FGLText.QT.GridSquareHeight; r1 := where; r1.Bottom := r1.Top + W; if FSelLength > 0 then begin l1 := 0; l3 := 0; if FSelStart > 1 then l1 := GetWidthBy(1, FSelStart - 1); l2 := GetWidthBy(FSelStart, FSelStart + FSelLength - 1); if FSelStart + FSelLength <= System.Length(FText) then l3 := GetWidthBy(FSelStart + FSelLength, System.Length(FText)); if l1 > 0 then begin FGLText.SetColor(FFontColor); r1.Right := r1.Left + l1; r1 := FitRectToRect(r1, where); FCanvas.SetClipping(r1); FCanvas.DrawText(where.Left, where.Top, FGLText); FCanvas.CancelClipping; r1.Left := r1.Right; end; FGLText.SetColor(FSelTextColor); r1.Right := r1.Left + l2; r1 := FitRectToRect(r1, where); FCanvas.SetClipping(r1); FCanvas.FillAlpha := 1 - FSelTranslulency; FCanvas.CurrentColor := FSelColor; FCanvas.Solid := True; FCanvas.Rectangle(r1.Left, r1.Top, r1.Right, r1.Bottom); FCanvas.DrawText(where.Left, where.Top, FGLText); FCanvas.CancelClipping; r1.Left := r1.Right; if l3 > 0 then begin FGLText.SetColor(FFontColor); r1.Right := r1.Left + l3; r1 := FitRectToRect(r1, where); FCanvas.SetClipping(r1); FCanvas.DrawText(where.Left, where.Top, FGLText); FCanvas.CancelClipping; end; end else begin FGLText.SetColor(FFontColor); FCanvas.SetClipping(where); FCanvas.DrawText(where.Left, where.Top, FGLText); FCanvas.CancelClipping; end end; procedure TvglSingleLineEdit.FinalizeWidths; begin ClearText; end; function TvglSingleLineEdit.GetComponentType: string; begin Result := 'SingleLineEdit'; end; function TvglSingleLineEdit.GetPosAt(X, Y: Integer; where: TRect): Integer; var Cnt, a, i: Integer; begin if not PointInRect(where, X, Y) then Exit; a := where.Left; Cnt := System.Length(FCharWidths); Result := 0; for i := 0 to Cnt - 1 do begin a := a + FCharWidths[i] + FGLText.QT.GridCharSpacing; if X < a then begin Result := i + 1; Exit; end; end; Result := Cnt + 1; end; function TvglSingleLineEdit.GetSelEnd: Integer; begin Result := SelStart + SelLength; end; function TvglSingleLineEdit.GetWidthBy(Start, Pos: Integer): Integer; var i, j: Integer; s: string; begin if (Start <= 0) or (Pos <= 0) then begin Result := 0; Exit; end; Start := Math.Max(Math.Min(Start, System.Length(FCharWidths)), 1); Pos := Math.Max(Math.Min(Pos, System.Length(FCharWidths)), 1); { j := 0; for i := Start to Pos do Inc(j, FCharWidths[i - 1] + FGLText.QT.GridCharSpacing); Result := j; } j := Pos - Start + 1; s := Copy(FText, Start, j); Result := qtGetStringWidth(FGLText.QT, s); end; procedure TvglSingleLineEdit.InitializeWidths; begin SetLength(FCharWidths, 0); FText := ''; FSelLength := 0; FSelStart := 0; end; procedure TvglSingleLineEdit.InsertChar(C: Char; Pos: Integer); begin InsertString(C, Pos); end; procedure TvglSingleLineEdit.InsertString(S: string; Pos: Integer); begin if (Pos < 0) then Exit; if Pos > Length(FText) then FText := FText + S else System.Insert(S, FText, Pos); RecalculateWidths; end; procedure TvglSingleLineEdit.RecalculateWidths; var i, j, k: Integer; begin j := Length(FText); if j = 0 then Exit; SetLength(FCharWidths, j); for i := 0 to j - 1 do begin k := GetQByC(FText[i + 1]); if k = -1 then k := FGLText.QT.SpaceWidth else k := FGLText.QT.TexWidths[k]; FCharWidths[i] := k; end; end; procedure TvglSingleLineEdit.SetColor(const Value: TColor); begin FColor := Value; end; procedure TvglSingleLineEdit.SetCurX(const Value: Integer); begin FCurX := Value; UpdateCursor; end; procedure TvglSingleLineEdit.SetDefHeight; begin Height := FGLText.QT.GridSquareHeight + 1; end; procedure TvglSingleLineEdit.SetFontColor(const Value: TColor); begin FFontColor := Value; end; procedure TvglSingleLineEdit.SetFontName(const Value: string); begin FFontName := Value; FGLText.FontName := FFontName; RecalculateWidths; end; procedure TvglSingleLineEdit.SetOnNavigate(const Value: TvglNavigateEvent); begin FOnNavigate := Value; end; procedure TvglSingleLineEdit.SetOnWrite(const Value: TvglWriteEvent); begin FOnWrite := Value; end; procedure TvglSingleLineEdit.SetSelColor(const Value: TColor); begin FSelColor := Value; end; procedure TvglSingleLineEdit.SetSelEnd(const Value: Integer); var i: Integer; begin i := Value - SelStart; SelLength := i; if i < 0 then SelStart := Value; end; procedure TvglSingleLineEdit.SetSelLength(const Value: Integer); begin FSelLength := Value; end; procedure TvglSingleLineEdit.SetSelStart(const Value: Integer); begin FSelStart := Max(Value, 1); end; procedure TvglSingleLineEdit.SetSelTextColor(const Value: TColor); begin FSelTextColor := Value; end; procedure TvglSingleLineEdit.SetSelTranslulency(const Value: Single); begin FSelTranslulency := Value; end; procedure TvglSingleLineEdit.SetText(const Value: string); begin SelLength := 0; SelStart := 1; FText := Value; FGLText.Text := Text; RecalculateWidths; end; procedure TvglSingleLineEdit.SetTranslucency(const Value: Single); begin FTranslucency := Value; end; procedure TvglSingleLineEdit.TriggerNavigation( Action: TvglEditNavigationAction; KBM: TVGLKBModifiers); var Sel: Boolean; i, j: Integer; OldSelStart, OldSelEnd, OldCurX, ASelEnd: Integer; begin DoOnNavigate(Action, KBM); Sel := vkmShift in KBM; if not Sel then begin SelStart := CurX; SelLength := 0; end; OldSelStart := SelStart; OldSelEnd := OldSelStart + SelLength; OldCurX := CurX; case Action of venaPrev: CurX := CurX - 1; venaNext: CurX := CurX + 1; venaPrevLine: CurX := CurX - 1; venaNextLine: CurX := CurX + 1; venaTop: CurX := 1; venaBottom: CurX := System.Length(FText) + 1; end; if Sel then begin i := CurX - OldCurX; // indicates direction if SelLength = 0 then begin FSelStarted := OldCurX; // anchor starting selection point SelStart := OldCurX; end; ASelEnd := SelEnd; if i = 1 then begin if (CurX > FSelStarted) and (FSelStarted = SelStart) then SelEnd := SelEnd + 1 else begin SelStart := SelStart + 1; SelEnd := ASelEnd; end; end else if i = -1 then begin if (CurX < FSelStarted) and (FSelStarted >= SelStart) then begin SelStart := SelStart - 1; SelEnd := ASelEnd; end else begin SelLength := SelLength - 1; end; end else if CurX = System.Length(FText) + 1 then // END begin SelStart := FSelStarted; SelEnd := CurX; end else if CurX = 1 then // HOME begin SelStart := 1; SelEnd := FSelStarted; end; end; end; procedure TvglSingleLineEdit.TriggerWritting(Code: Char; KBM: TVGLKBModifiers); begin DoOnWrite(Code, KBM); if FSelLength > 0 then begin DeleteBlock(FSelStart, FSelLength); FSelLength := 0; CurX := FSelStart; end; InsertChar(Code, CurX); CurX := CurX + 1; Text := FText; end; procedure TvglSingleLineEdit.Update(const ElapsedTime: Cardinal); begin inherited; FTimerDiff := ElapsedTime - FTimerLast; if FTimerDiff >= FTimerInterval then begin FTimerLast := ElapsedTime; FTimerCursorVis := not FTimerCursorVis; end; end; procedure TvglSingleLineEdit.UpdateCursor; begin FCurX := Max(Min(FCurX, System.Length(FText) + 1), 1); if SelLength = 0 then SelStart := FCurX; end; end. |
From: Michael H. <mh...@us...> - 2000-12-13 22:34:15
|
Update of /cvsroot/pythianproject/Prototypes/GUISystem In directory slayer.i.sourceforge.net:/tmp/cvs-serv22700/GUISystem Modified Files: StartupForm.pas vglStdCtrls.pas Log Message: added underlining to GLCanvas. fixed text bug. -mike Index: StartupForm.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/StartupForm.pas,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** StartupForm.pas 2000/12/13 20:25:21 1.8 --- StartupForm.pas 2000/12/13 22:34:12 1.9 *************** *** 44,49 **** procedure CB1OnChange(Sender:TObject); - - procedure go; end; --- 44,47 ---- *************** *** 134,138 **** Image1.Visible := not Image1.Visible; if Image1.Visible then ! Button.Caption := 'hide image' else Button.Caption := 'show image'; end; --- 132,143 ---- Image1.Visible := not Image1.Visible; if Image1.Visible then ! begin ! Button.Caption := '|h|ide image'; ! Button.HotKey := Ord('H'); ! end else ! begin ! Button.Caption := '|s|how image'; ! button.HotKey := Ord('S'); ! end; end; *************** *** 191,201 **** CB.Caption := 'This is a checkbox'; CB.OnChanged := CB1OnChange; Button := TvglButton.Create('Button',Panel1); ! Button.Caption := 'hide image'; Button.Bounds := Rect(10,60,0,0); Button.OnClick := ButtonOnClick; ! Button.Hotkey := Ord('B'); ! Button.HotKeyShiftState := [vkmControl]; Button.HasHotkey := True; --- 196,207 ---- CB.Caption := 'This is a checkbox'; CB.OnChanged := CB1OnChange; + CB.Text.FontName := 'VinerHand ITC'; Button := TvglButton.Create('Button',Panel1); ! Button.Caption := '|h|ide image'; Button.Bounds := Rect(10,60,0,0); Button.OnClick := ButtonOnClick; ! Button.Hotkey := Ord('H'); ! Button.HotKeyShiftState := [vkmAlt]; Button.HasHotkey := True; *************** *** 242,245 **** --- 248,252 ---- LB.Bounds := Rect(260, 30, 450, 280); LB.ScrollBars := ssBoth; + InterfaceManager.SetNewFocus(LB); Hide; Index: vglStdCtrls.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/vglStdCtrls.pas,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** vglStdCtrls.pas 2000/12/13 20:25:21 1.3 --- vglStdCtrls.pas 2000/12/13 22:34:12 1.4 *************** *** 200,203 **** --- 200,204 ---- property SelBgColor: TColor read FSelBgColor write SetSelBgColor; property SelFgColor: TColor read FSelFgColor write SetSelFgColor; + property Text :TGLText read FGLText; property Items: TStringList read FItems write SetItems; *************** *** 243,246 **** --- 244,248 ---- procedure DrawSelf(where:TRect); override ; published + property Text :TGLText read FCaptionText; property Checked: Boolean read FChecked write SetChecked default False; property Color :TColor write SetColor; *************** *** 318,321 **** --- 320,325 ---- vglSB_TimerInterval = 100; vglSB_TimerIntervalFirst = 500; + + { TvglScrollbar } vglLB_TimerInterval = 100; vglLB_TimerIntervalFirst = 500; *************** *** 328,332 **** vglSB_InAccuracyMoveVert = 25; - function TvglScrollBar.CheckPart(X, Y: Integer): Integer; var --- 332,335 ---- *************** *** 832,836 **** FItems := TStringList.Create; FItems.OnChange := ItemsChanged; - //FGLTexts := TStringList.Create; FGLText := TGLText.Create('Arial'); FAcceptsChildren := False; --- 835,838 ---- *************** *** 1319,1325 **** SkinRect := GetCheckMarkSkinRect; MarkRect := GetCheckMarkBounds(where); if FCaptionText.Text <> '' then Canvas.DrawText(where.Left + SkinRect.Right - SkinRect.Left + 5, where.Top, FCaptionText); - Canvas.DrawBitmapSubRect(MarkRect.Left, MarkRect.Top, SkinRect, FImage); FImage.Intensity := 255; end; --- 1321,1327 ---- SkinRect := GetCheckMarkSkinRect; MarkRect := GetCheckMarkBounds(where); + Canvas.DrawBitmapSubRect(MarkRect.Left, MarkRect.Top, SkinRect, FImage); if FCaptionText.Text <> '' then Canvas.DrawText(where.Left + SkinRect.Right - SkinRect.Left + 5, where.Top, FCaptionText); FImage.Intensity := 255; end; *************** *** 1409,1412 **** --- 1411,1415 ---- begin FImage := nil; + FCaptionText.Free; inherited; end; |
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; |
From: Michael H. <mh...@us...> - 2000-12-12 22:16:06
|
Update of /cvsroot/pythianproject/Prototypes/GLCanvas In directory slayer.i.sourceforge.net:/tmp/cvs-serv12095/GLCanvas Modified Files: QuadTextUnit.pas glCanvas.pas Log Message: small changes. altered GLCanvas to use better font registration system. fixed bug which caused multiple texture loading. small other changes. rearranged VGL units -mike Index: QuadTextUnit.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/QuadTextUnit.pas,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** QuadTextUnit.pas 2000/12/11 19:15:11 1.5 --- QuadTextUnit.pas 2000/12/12 22:15:56 1.6 *************** *** 34,37 **** --- 34,45 ---- '¯'); + NULL_WIDTHS :TQuadTextWidthsArray = + ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {32} + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0); + COURIERNEW_WIDTHS :TQuadTextWidthsArray = ( 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, Index: glCanvas.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/glCanvas.pas,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** glCanvas.pas 2000/12/12 20:40:36 1.11 --- glCanvas.pas 2000/12/12 22:15:57 1.12 *************** *** 98,109 **** end; ! TGLCanvasFontData = record Name, FileName:string; FontType :integer; end; ! TArrayOfGLCanvasFontData = array[1..GLC_MAXFONTS] of TGLCanvasFontData; ! const GLC_DEFAULT_FONT_DATA :TArrayOfGLCanvasFontData = ( (Name: 'Arial'; --- 98,109 ---- end; ! { TGLCanvasFontData = record Name, FileName:string; FontType :integer; end; ! TArrayOfGLCanvasFontData = array[1..GLC_MAXFONTS] of TGLCanvasFontData; } ! {const GLC_DEFAULT_FONT_DATA :TArrayOfGLCanvasFontData = ( (Name: 'Arial'; *************** *** 127,131 **** FontType: GLCANVAS_TEXT_QUADTEXT; ) ! ); --- 127,131 ---- FontType: GLCANVAS_TEXT_QUADTEXT; ) ! ); } *************** *** 188,196 **** end; TGLText = class private // wraps up the GLF library and possibly other text systems - FFonts :TArrayOfGLCanvasFontData; - FLines :TStringList; FFontName :string; --- 188,202 ---- end; + TGLTexturedFont = class + Name, FileName:string; + FontType :integer; + Widths:TQuadTextWidthsArray; + Texture:TTexture; + constructor Create(aName:string; aFileName:string; aWidths:TQuadTextWidthsArray); + end; + TGLText = class private // wraps up the GLF library and possibly other text systems FLines :TStringList; FFontName :string; *************** *** 217,224 **** procedure DrawInternal(line:integer); virtual; ! function MatchFontName(name:string; tt:Integer):TGLCanvasFontData; ! function MatchFontWidths(f:TGLCanvasFontData):TQuadTextWidthsArray; - procedure LinesOnChange(Sender:TObject); function GetWidth(index: integer): integer; public --- 223,228 ---- procedure DrawInternal(line:integer); virtual; ! function MatchFontName(name:string; tt:Integer):TGLTexturedFont; function GetWidth(index: integer): integer; public *************** *** 245,253 **** property DisplayList :integer read FDisplayList; ! constructor Create(aText, aFontName:string; aPreferredTextType:integer; FontData:TArrayOfGLCanvasFontData); overload; constructor Create(aFontName:string); overload; // auto creates with no text, and quadtext selected destructor Destroy; override ; procedure Draw(Line:integer); virtual ; procedure SetColor(const Value: TColor); end; --- 249,261 ---- property DisplayList :integer read FDisplayList; ! constructor Create(aText, aFontName:string; aPreferredTextType:integer); overload; constructor Create(aFontName:string); overload; // auto creates with no text, and quadtext selected destructor Destroy; override ; procedure Draw(Line:integer); virtual ; procedure SetColor(const Value: TColor); + procedure LinesOnChange(Sender:TObject); // be sure to call if you override this event handler + + class procedure RegisterFont(name,filename:string;widths:TQuadTextWidthsArray); overload ; + class procedure RegisterFont(name,filename:string); overload ; end; *************** *** 318,323 **** --- 326,336 ---- function FitRectToRect(src,dest:TRect):TRect; + + implementation + var + GLCanvasFonts :TList; + function CompareRect(r1,r2:TRect):boolean; begin *************** *** 552,556 **** var t:TGLText; begin ! t := TGLText.Create(str,FontName,aFontType,GLC_DEFAULT_FONT_DATA); DrawText(X,Y,t); t.Free; --- 565,569 ---- var t:TGLText; begin ! t := TGLText.Create(str,FontName,aFontType); DrawText(X,Y,t); t.Free; *************** *** 676,680 **** { TGLText } ! constructor TGLText.Create(aText, aFontName: string; aPreferredTextType:integer; FontData:TArrayOfGLCanvasFontData); begin inherited Create; --- 689,693 ---- { TGLText } ! constructor TGLText.Create(aText, aFontName: string; aPreferredTextType:integer); begin inherited Create; *************** *** 687,691 **** TextType := aPreferredTextType; FFontName := aFontName; - FFonts := FontData; FTexture := nil; LoadFont; --- 700,703 ---- *************** *** 697,701 **** constructor TGLText.Create(aFontName: string); begin ! Create('',aFontName,GLCANVAS_TEXT_QUADTEXT,GLC_DEFAULT_FONT_DATA); end; --- 709,713 ---- constructor TGLText.Create(aFontName: string); begin ! Create('',aFontName,GLCANVAS_TEXT_QUADTEXT); end; *************** *** 766,770 **** procedure TGLText.LoadFont; ! var f:TGLCanvasFontData; begin f := MatchFontName(FontName,TextType); --- 778,782 ---- procedure TGLText.LoadFont; ! var f:TGLTexturedFont; begin f := MatchFontName(FontName,TextType); *************** *** 780,785 **** begin if assigned(FTexture) then FTexture.Free; ! FTexture := TTexture.Create; ! FTexture.LoadFromFile(FontsDirectory + f.FileName); QT.TextureID := FTexture.TexID; QT.GridSquareWidth := 20; --- 792,802 ---- begin if assigned(FTexture) then FTexture.Free; ! // if not already loaded ! if not assigned(f.Texture) then ! begin ! FTexture := TTexture.Create; ! FTexture.LoadFromFile(FontsDirectory + f.FileName); ! f.Texture := FTexture; ! end else FTexture := f.Texture; QT.TextureID := FTexture.TexID; QT.GridSquareWidth := 20; *************** *** 788,803 **** QT.GridCharSpacing := 2; QT.SpaceWidth := 5; ! QT.TexWidths := MatchFontWidths(f); end; // add more text types here end; ! function TGLText.MatchFontName(name: string; tt: Integer): TGLCanvasFontData; var a:integer; begin // returns first match for a := 1 to GLC_MAXFONTS do ! if (UpperCase(FFonts[a].Name) = UpperCase(name)) and (FFonts[a].FontType = tt) then begin ! Result := FFonts[a]; exit; end; --- 805,820 ---- QT.GridCharSpacing := 2; QT.SpaceWidth := 5; ! QT.TexWidths := f.Widths; end; // add more text types here end; ! function TGLText.MatchFontName(name: string; tt: Integer): TGLTexturedFont; var a:integer; begin // returns first match for a := 1 to GLC_MAXFONTS do ! if (UpperCase(TGLTexturedFont(GLCanvasFonts[a]).Name) = UpperCase(name)) and (TGLTexturedFont(GLCanvasFonts[a]).FontType = tt) then begin ! Result := GLCanvasFonts[a]; exit; end; *************** *** 805,822 **** end; - function TGLText.MatchFontWidths( - f: TGLCanvasFontData): TQuadTextWidthsArray; - begin - // fudge, delphi won't let me specify this in the - // defaults array for some reason. - - if UpperCase(f.Name) = 'ARIAL' then - result := ARIAL_WIDTHS - else if UpperCase(f.Name) = 'COURIER NEW' then - Result := COURIERNEW_WIDTHS - else if UpperCase(f.Name) = 'VINERHAND ITC' then - Result := VINERHAND_WIDTHS; - end; - procedure TGLText.SetBlue(const Value: byte); begin --- 822,825 ---- *************** *** 882,885 **** --- 885,900 ---- end; + class procedure TGLText.RegisterFont(name, filename: string; + widths: TQuadTextWidthsArray); + begin + GLCanvasFonts.Add(TGLTexturedFont.Create(name,filename,widths)); + end; + + class procedure TGLText.RegisterFont(name, filename: string); + begin + GLCanvasFonts.Add(TGLTexturedFont.Create(name,filename,NULL_WIDTHS)); + end; + + // *********************** texture bitmaps ************************** *************** *** 1093,1098 **** --- 1108,1138 ---- end; + { TGLTexturedFont } + + constructor TGLTexturedFont.Create(aName, aFileName: string; aWidths:TQuadTextWidthsArray); + begin + inherited Create; + Name := aName; + FileName := afileName; + Widths := aWidths; + Texture := nil; + if (ExtractFileExt(FileName) = '.glf') or (ExtractFileExt(FileName) = '.glf') then + FontType := GLCANVAS_TEXT_GLF else FontType := GLCANVAS_TEXT_QUADTEXT; + end; + initialization FontsDirectory := ''; // is appended to font file name + + // create list + GLCanvasFonts := TList.Create; + + TGLText.RegisterFont('Arial','arial1.glf'); + TGLText.RegisterFont('Courier New','courier1.glf'); + TGLText.RegisterFont('Arial','Arial Grid.bmp',ARIAL_WIDTHS); + TGLText.RegisterFont('Courier New','CourierNew Grid.bmp',COURIERNEW_WIDTHS); + TGLText.RegisterFont('VinerHand ITC','VinerHand ITC Grid.bmp',VINERHAND_WIDTHS); + + finalization + GLCanvasFonts.Free; end. |
From: Michael H. <mh...@us...> - 2000-12-12 22:16:06
|
Update of /cvsroot/pythianproject/Prototypes/GUISystem In directory slayer.i.sourceforge.net:/tmp/cvs-serv12095/GUISystem Modified Files: StartupForm.pas skin1.png vglClasses.pas vglStdCtrls.pas Removed Files: vglCheckBox.pas Log Message: small changes. altered GLCanvas to use better font registration system. fixed bug which caused multiple texture loading. small other changes. rearranged VGL units -mike Index: StartupForm.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/StartupForm.pas,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** StartupForm.pas 2000/12/12 20:40:37 1.6 --- StartupForm.pas 2000/12/12 22:15:57 1.7 *************** *** 7,11 **** uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ! StdCtrls, GLForms, GLCanvas, OpenGL, vglClasses, vglStdCtrls, vglCheckBox; type --- 7,11 ---- uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ! StdCtrls, GLForms, GLCanvas, OpenGL, vglClasses, vglStdCtrls; type *************** *** 43,46 **** --- 43,47 ---- procedure Panel1OnMouseExit(Sender:TObject); procedure ButtonOnclick(Sender:TObject); + procedure CB1OnChange(Sender:TObject); procedure go; *************** *** 173,176 **** --- 174,178 ---- CB.Color := clWhite; CB.Caption := 'This is a checkbox'; + CB.OnChanged := CB1OnChange; Button := TvglButton.Create('Button',Panel1); *************** *** 194,199 **** Label1 := TvglTextBox.Create('Label1',InterfaceManager.Desktop); ! Label1.Top := 250; ! Label1.Left := 60; Label1.Color := clBlack; Label1.Caption := 'Hello World'#13'This is Mike speaking to you'; --- 196,201 ---- Label1 := TvglTextBox.Create('Label1',InterfaceManager.Desktop); ! Label1.Top := 300; ! Label1.Left := 20; Label1.Color := clBlack; Label1.Caption := 'Hello World'#13'This is Mike speaking to you'; *************** *** 233,236 **** --- 235,245 ---- Close; + end; + + procedure TfrmStartup.CB1OnChange(Sender: TObject); + begin + if CB.Checked then + CB.Caption := 'Checked' + else CB.Caption := 'Unchecked'; end; Index: skin1.png =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/skin1.png,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 Binary files /tmp/cvs0yFqWn and /tmp/cvsctzQ1A differ Index: vglClasses.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/vglClasses.pas,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** vglClasses.pas 2000/12/11 19:15:12 1.4 --- vglClasses.pas 2000/12/12 22:15:57 1.5 *************** *** 248,300 **** end; - TvglButtonState = (vglbsUp, vglbsDown, vglbsOver); - TvglButton = class(TvglComponent) - protected - FImage :TGLBitmap; - FCaptionText :TGLText; - FButtonState :TvglButtonState; - procedure SetCaption(const Value: string); - procedure SetBounds(const Value: TRect); override ; - function GetCaption: string; - - function GetComponentType:string; override ; - - procedure DoOnMouseEntry; override ; - procedure DoOnMouseExit; override ; - procedure DoOnMouseDown(mb,x,y:integer); override ; - public - property Caption :string read GetCaption write SetCaption; - - constructor Create(aName:string; AOwner:TvglComponent); - destructor Destroy; override ; - - procedure DrawSelf(where:TRect); override ; - end; - - TvglTextBox = class(TvglComponent) - private - function GetFont: string; - procedure SetFont(const Value: string); - procedure SetColor(const Value: TColor); - protected - FText :TGLText; - function GetCaption: string; - procedure SetCaption(const Value: string); - function GetComponentType:string; override ; - function GetLines: TStringList; - - procedure LinesOnChange(Sender:TObject); - procedure UpdateBounds; - public - property Lines:TStringList read GetLines; - property Caption:string read GetCaption write SetCaption; - property Font :string read GetFont write SetFont; - property Color :TColor write SetColor; - - constructor Create(aName:string; aOwner:TVGLComponent); - destructor Destroy; override ; - procedure DrawSelf(where:TRect); override ; - end; - TvglMouseCursor = class(TvglComponent) protected --- 248,251 ---- *************** *** 1015,1094 **** end; - { TvglButton } - - constructor TvglButton.Create(aName: string; AOwner: TvglComponent); - begin - inherited Create(aName,AOwner); - FImage := TGLBitmap(Manager.GetResource(VGL_SKIN_1)); - FCaptionText := TGLText.Create('Arial'); - FCaptionText.SetColor(clBlack); - FButtonState := vglbsUp; - end; - - destructor TvglButton.Destroy; - begin - FImage := nil; - inherited; - end; - - procedure TvglButton.DoOnMouseDown(mb, x, y: integer); - begin - inherited DoOnMouseDown(mb,x,y); - FButtonState := vglbsDown; - end; - - procedure TvglButton.DoOnMouseEntry; - begin - inherited DoOnMouseEntry; - FButtonState := vglbsOver; - end; - - procedure TvglButton.DoOnMouseExit; - begin - inherited DoOnMouseExit; - FButtonState := vglbsUp; - end; - - procedure TvglButton.DrawSelf(where: TRect); - var tw:integer; - begin - inherited DrawSelf(where); - //@@todo - text centreing - case FButtonState of - vglbsUp: FImage.Intensity := 255; - vglbsOver: FImage.Intensity := 200; - vglbsDown: FImage.Intensity := 200; - end; - Canvas.DrawBitmapSubRect(where.Left,where.Top,VGL_SKINRECT_BUTTON,FImage); - FImage.Intensity := 255; // remember to reset!!! - tw := FCaptionText.Width[0]; - if FCaptionText.Text <> '' then - Canvas.DrawText( ((where.Right-where.Left-16))-(tw div 2), where.top+12,FCaptionText); - end; - - function TvglButton.GetCaption: string; - begin - Result := FCaptionText.Text; - end; - - function TvglButton.GetComponentType: string; - begin - Result := 'Button'; - end; - - procedure TvglButton.SetBounds(const Value: TRect); - var tmp:TRect; - begin - tmp := Value; - tmp.Right := (VGL_SKINRECT_BUTTON.Right-VGL_SKINRECT_BUTTON.Left)+tmp.Left; - tmp.Bottom := tmp.Top+(VGL_SKINRECT_BUTTON.Bottom-VGL_SKINRECT_BUTTON.Top); - inherited SetBounds(tmp); - end; - - procedure TvglButton.SetCaption(const Value: string); - begin - FCaptionText.Text := Value; - end; - { TvglMouseCursor } --- 966,969 ---- *************** *** 1110,1187 **** end; - { TvglTextBox } - - constructor TvglTextBox.Create(aName: string; aOwner: TVGLComponent); - begin - inherited Create(aName,aOwner); - FText := TGLText.Create('Arial'); - FText.Lines.OnChange := LinesOnChange; - end; - - destructor TvglTextBox.Destroy; - begin - FText.Free; - inherited Destroy; - end; - - procedure TvglTextBox.DrawSelf(where: TRect); - begin - inherited DrawSelf(where); - Canvas.DrawText(where.Left,where.Top,FText); - end; - - function TvglTextBox.GetCaption: string; - begin - Result := Lines.Text; - end; - - function TvglTextBox.GetComponentType: string; - begin - Result := 'Label'; - end; - function TvglTextBox.GetFont: string; - begin - Result := FText.FontName; - end; - - function TvglTextBox.GetLines: TStringList; - begin - Result := FText.Lines; - end; - - procedure TvglTextBox.LinesOnChange(Sender: TObject); - begin - // update bounds - UpdateBounds; - end; - - procedure TvglTextBox.SetCaption(const Value: string); - begin - Lines.Text := Value; - end; - - procedure TvglTextBox.SetColor(const Value: TColor); - begin - FText.SetColor(Value); - end; - - procedure TvglTextBox.SetFont(const Value: string); - begin - FText.FontName := Value; - end; - - procedure TvglTextBox.UpdateBounds; - var - i:integer; - longest:integer; - begin - // locate longest line - longest := 0; - for i := 0 to FText.Lines.Count-1 do - if FText.Width[i] > longest then longest := FText.Width[i]; - Width := longest; - Height := FText.Lines.Count*FText.QT.GridSquareHeight; - end; end. --- 985,989 ---- Index: vglStdCtrls.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/vglStdCtrls.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** vglStdCtrls.pas 2000/12/12 20:48:59 1.1 --- vglStdCtrls.pas 2000/12/12 22:15:57 1.2 *************** *** 25,28 **** --- 25,34 ---- VGL_SKINRECT_SCROLL_TAB :TRect = (Left:90;Top:185;Right:116;Bottom:198); + VGL_SKINRECT_CHECKBOXSET: TRect = (Left: 0; Top: 205; Right: 13; Bottom: 217); + VGL_SKINRECT_CHECKBOXUNSET: TRect = (Left: 12; Top: 205; Right: 25; Bottom: 217); + vglCheckOver_Intensity = 220; + vglCheckUp_Intensity = 255; + vglCheckDown_Intensity = 200; + type TvglScrollBarKind = (sbHorizontal, sbVertical); *************** *** 47,51 **** FOnScroll: TvglScrollEvent; FPageSize: Integer; - FBackPanel :TvglPanel; FColor: TColor; FPageAlpha: Single; --- 53,56 ---- *************** *** 173,176 **** --- 178,271 ---- end; + TvglCheckBox = class(TvglComponent) + private + procedure SetColor(const Value: TColor); + protected + FChecked: Boolean; + FOnChanged: TNotifyEvent; + FImage: TGLBitmap; + FCaptionText: TGLText; + FMouseMarkDown: Boolean; + FMouseMarkOver: Boolean; + FMouseOver: Boolean; + procedure SetCaption(const Value: string); + function GetCaption: string; + procedure SetOnChanged(const Value: TNotifyEvent); + procedure SetChecked(const Value: Boolean); + + procedure DoChanged; dynamic; + function GetComponentType: string; override ; + + procedure DoOnMouseEntry; override ; + procedure DoOnMouseExit; override ; + procedure DoOnMouseDown(mb, x, y: Integer); override; + procedure DoOnMouseClick(x, y: Integer); override; + procedure DoOnMouseUp(mb, x, y: Integer); override; + procedure DoOnMouseMove(X,Y:integer); override; + procedure UpdateBounds; + function GetCheckMarkBounds(where: TRect): TRect; virtual; + function GetCheckMarkSkinRect: TRect; + procedure CheckMarkOver(X, Y: Integer); + public + constructor Create(aName:string; AOwner:TvglComponent); + destructor Destroy; override ; + + procedure DrawSelf(where:TRect); override ; + published + property Checked: Boolean read FChecked write SetChecked default False; + property Color :TColor write SetColor; + property Caption: string read GetCaption write SetCaption; + property OnChanged: TNotifyEvent read FOnChanged write SetOnChanged; + end; + + TvglButtonState = (vglbsUp, vglbsDown, vglbsOver); + TvglButton = class(TvglComponent) + protected + FImage :TGLBitmap; + FCaptionText :TGLText; + FButtonState :TvglButtonState; + procedure SetCaption(const Value: string); + procedure SetBounds(const Value: TRect); override ; + function GetCaption: string; + + function GetComponentType:string; override ; + + procedure DoOnMouseEntry; override ; + procedure DoOnMouseExit; override ; + procedure DoOnMouseDown(mb,x,y:integer); override ; + public + property Caption :string read GetCaption write SetCaption; + + constructor Create(aName:string; AOwner:TvglComponent); + destructor Destroy; override ; + + procedure DrawSelf(where:TRect); override ; + end; + + TvglTextBox = class(TvglComponent) + private + function GetFont: string; + procedure SetFont(const Value: string); + procedure SetColor(const Value: TColor); + protected + FText :TGLText; + function GetCaption: string; + procedure SetCaption(const Value: string); + function GetComponentType:string; override ; + function GetLines: TStringList; + + procedure LinesOnChange(Sender:TObject); + procedure UpdateBounds; + public + property Lines:TStringList read GetLines; + property Caption:string read GetCaption write SetCaption; + property Font :string read GetFont write SetFont; + property Color :TColor write SetColor; + + constructor Create(aName:string; aOwner:TVGLComponent); + destructor Destroy; override ; + procedure DrawSelf(where:TRect); override ; + end; + implementation uses *************** *** 769,800 **** var i: Integer; - TT: TGLText; begin if FScrollBar = nil then Exit; UpdateScrollBar; - { for i := 0 to FGLTexts.Count - 1 do - begin - if FGLTexts.Objects[i] <> nil then - FGLTexts.Objects[i].Free; - end;} FGLText.Lines.Clear; for i := 0 to FItems.Count - 1 do - begin - {TT := TGLText.Create(FItems[i], FGLTexttmpl.FontName, FGLTexttmpl.TextType, GLC_DEFAULT_FONT_DATA); - with TGLText(TT) do - begin - GLFFontHandle := FGLTexttmpl.GLFFontHandle; - QT := FGLTexttmpl.QT; - Red := FGLTexttmpl.Red; - Blue := FGLTexttmpl.Blue; - Green := FGLTexttmpl.Green; - Size := FGLTexttmpl.Size; - Precache := FGLTexttmpl.Precache; - end; - FGLTexts.AddObject(FItems[i], TT);} FGLText.Lines.Add(FItems[i]); - end; end; --- 864,875 ---- *************** *** 914,917 **** --- 989,1309 ---- FScrollBar.Max := FItems.Count - FScrollBar.PageSize; FScrollBar.LargeChange := FScrollBar.PageSize; + end; + + { TvglCheckBox } + + procedure TvglCheckBox.CheckMarkOver(X, Y: Integer); + begin + FMouseMarkOver := PointInRect(GetCheckMarkBounds(ScreenBounds), X, Y); + end; + + constructor TvglCheckBox.Create(aName: string; AOwner: TvglComponent); + begin + inherited Create(aName, AOwner); + FImage := TGLBitmap(Manager.GetResource(VGL_SKIN_1)); + // FCaptionText := TGLText.Create('Courier New'); + FCaptionText := TGLText.Create('Arial'); + FCaptionText.Text := aName; + FCaptionText.SetColor(clBlack); + FMouseMarkDown := False; + FMouseOver := False; + FChecked := False; + FOnChanged := nil; + UpdateBounds; + end; + + destructor TvglCheckBox.Destroy; + begin + FImage := nil; + inherited Destroy; + end; + + procedure TvglCheckBox.DoChanged; + begin + if Assigned(FOnChanged) then + FOnChanged(Self); + end; + + procedure TvglCheckBox.DoOnMouseClick(x, y: Integer); + begin + inherited DoOnMouseClick(x, y); + if PointInRect(GetCheckMarkBounds(ScreenBounds), X, Y) then + begin + FChecked := not FChecked; + DoChanged; + end; + end; + + procedure TvglCheckBox.DoOnMouseDown(mb, x, y: Integer); + begin + inherited DoOnMouseDown(mb, x, y); + if mb <> VGL_MOUSE_LEFT then + Exit; + if PointInRect(GetCheckMarkBounds(ScreenBounds), X, Y) then + FMouseMarkDown := True; + end; + + procedure TvglCheckBox.DoOnMouseEntry; + begin + inherited DoOnMouseEntry; + FMouseOver := True; + end; + + procedure TvglCheckBox.DoOnMouseExit; + begin + inherited DoOnMouseExit; + FMouseOver := False; + FMouseMarkOver := False; + end; + + procedure TvglCheckBox.DoOnMouseMove(X, Y: integer); + begin + inherited DoOnMouseMove(X, Y); + CheckMarkOver(X, Y); + end; + + procedure TvglCheckBox.DoOnMouseUp(mb, x, y: Integer); + begin + inherited DoOnMouseUp(mb, x, y); + FMouseMarkDown := False; + end; + + procedure TvglCheckBox.DrawSelf(where: TRect); + var + MarkRect,SkinRect: TRect; + begin + inherited DrawSelf(where); + if (FMouseMarkDown) and (FMouseMarkOver) then + FImage.Intensity := vglCheckDown_Intensity + else + if FMouseMarkOver then + FImage.Intensity := vglCheckOver_Intensity + else + FImage.Intensity := vglCheckUp_Intensity; + SkinRect := GetCheckMarkSkinRect; + MarkRect := GetCheckMarkBounds(where); + if FCaptionText.Text <> '' then + Canvas.DrawText(where.Left + SkinRect.Right - SkinRect.Left + 5, where.Top, FCaptionText); + Canvas.DrawBitmapSubRect(MarkRect.Left, MarkRect.Top, SkinRect, FImage); + FImage.Intensity := 255; + end; + + + function TvglCheckBox.GetCaption: string; + begin + Result := FCaptionText.Text; + end; + + function TvglCheckBox.GetCheckMarkBounds(where: TRect): TRect; + var + SkinRect: TRect; + begin + SkinRect := GetCheckMarkSkinRect; + Result.Left := where.Left; + Result.Top := where.Top + (((where.Bottom - where.Top) - (SkinRect.Bottom - SkinRect.TOP)) div 2); + Result.Right := Result.Left + SkinRect.Right - SkinRect.Left; + Result.Bottom := Result.Top + SkinRect.Bottom - SkinRect.Top; + end; + + function TvglCheckBox.GetCheckMarkSkinRect: TRect; + begin + if FChecked then + Result := VGL_SKINRECT_CHECKBOXSET + else + Result := VGL_SKINRECT_CHECKBOXUNSET; + end; + + function TvglCheckBox.GetComponentType: string; + begin + Result := 'CheckBox'; + end; + + procedure TvglCheckBox.SetCaption(const Value: string); + begin + FCaptionText.Text := Value; + UpdateBounds; + end; + + procedure TvglCheckBox.SetChecked(const Value: Boolean); + begin + FChecked := Value; + end; + + procedure TvglCheckBox.SetColor(const Value: TColor); + begin + FCaptionText.SetColor(Value); + end; + + procedure TvglCheckBox.SetOnChanged(const Value: TNotifyEvent); + begin + FOnChanged := Value; + end; + + procedure TvglCheckBox.UpdateBounds; + var + i:integer; + longest:integer; + SKINRECT: TRect; + begin + SKINRECT := GetCheckMarkSkinRect; + // locate longest line + longest := 0; + for i := 0 to FCaptionText.Lines.Count-1 do + if FCaptionText.Width[i] > longest then longest := FCaptionText.Width[i]; + Width := longest + (SKINRECT.Right - SKINRECT.Left) + 5; + Height := Math.Max(Math.Max(FCaptionText.Lines.Count*FCaptionText.QT.GridSquareHeight, SKINRECT.Bottom - SKINRECT.TOP + 1), Height); + end; + + { TvglButton } + + constructor TvglButton.Create(aName: string; AOwner: TvglComponent); + begin + inherited Create(aName,AOwner); + FImage := TGLBitmap(Manager.GetResource(VGL_SKIN_1)); + FCaptionText := TGLText.Create('Arial'); + FCaptionText.SetColor(clBlack); + FButtonState := vglbsUp; + end; + + destructor TvglButton.Destroy; + begin + FImage := nil; + inherited; + end; + + procedure TvglButton.DoOnMouseDown(mb, x, y: integer); + begin + inherited DoOnMouseDown(mb,x,y); + FButtonState := vglbsDown; + end; + + procedure TvglButton.DoOnMouseEntry; + begin + inherited DoOnMouseEntry; + FButtonState := vglbsOver; + end; + + procedure TvglButton.DoOnMouseExit; + begin + inherited DoOnMouseExit; + FButtonState := vglbsUp; + end; + + procedure TvglButton.DrawSelf(where: TRect); + var tw:integer; + begin + inherited DrawSelf(where); + //@@todo - text centreing + case FButtonState of + vglbsUp: FImage.Intensity := 255; + vglbsOver: FImage.Intensity := 200; + vglbsDown: FImage.Intensity := 200; + end; + Canvas.DrawBitmapSubRect(where.Left,where.Top,VGL_SKINRECT_BUTTON,FImage); + FImage.Intensity := 255; // remember to reset!!! + tw := FCaptionText.Width[0]; + if FCaptionText.Text <> '' then + Canvas.DrawText( ((where.Right-where.Left-16))-(tw div 2), where.top+12,FCaptionText); + end; + + function TvglButton.GetCaption: string; + begin + Result := FCaptionText.Text; + end; + + function TvglButton.GetComponentType: string; + begin + Result := 'Button'; + end; + + procedure TvglButton.SetBounds(const Value: TRect); + var tmp:TRect; + begin + tmp := Value; + tmp.Right := (VGL_SKINRECT_BUTTON.Right-VGL_SKINRECT_BUTTON.Left)+tmp.Left; + tmp.Bottom := tmp.Top+(VGL_SKINRECT_BUTTON.Bottom-VGL_SKINRECT_BUTTON.Top); + inherited SetBounds(tmp); + end; + + procedure TvglButton.SetCaption(const Value: string); + begin + FCaptionText.Text := Value; + end; + + { TvglTextBox } + + constructor TvglTextBox.Create(aName: string; aOwner: TVGLComponent); + begin + inherited Create(aName,aOwner); + FText := TGLText.Create('Arial'); + FText.Precache := true; + FText.Lines.OnChange := LinesOnChange; + end; + + destructor TvglTextBox.Destroy; + begin + FText.Free; + inherited Destroy; + end; + + procedure TvglTextBox.DrawSelf(where: TRect); + begin + inherited DrawSelf(where); + Canvas.DrawText(where.Left,where.Top,FText); + end; + + function TvglTextBox.GetCaption: string; + begin + Result := Lines.Text; + end; + + function TvglTextBox.GetComponentType: string; + begin + Result := 'Label'; + end; + + function TvglTextBox.GetFont: string; + begin + Result := FText.FontName; + end; + + function TvglTextBox.GetLines: TStringList; + begin + Result := FText.Lines; + end; + + procedure TvglTextBox.LinesOnChange(Sender: TObject); + begin + // update bounds + FText.LinesOnChange(Sender); //call text handler to prevent overriding + UpdateBounds; + end; + + procedure TvglTextBox.SetCaption(const Value: string); + begin + Lines.Text := Value; + end; + + procedure TvglTextBox.SetColor(const Value: TColor); + begin + FText.SetColor(Value); + end; + + procedure TvglTextBox.SetFont(const Value: string); + begin + FText.FontName := Value; + end; + + procedure TvglTextBox.UpdateBounds; + var + i:integer; + longest:integer; + begin + // locate longest line + longest := 0; + for i := 0 to FText.Lines.Count-1 do + if FText.Width[i] > longest then longest := FText.Width[i]; + Width := longest; + Height := FText.Lines.Count*FText.QT.GridSquareHeight; end; --- vglCheckBox.pas DELETED --- |
From: Michael H. <mh...@us...> - 2000-12-12 20:53:05
|
Update of /cvsroot/pythianproject/Prototypes/GLCanvas In directory slayer.i.sourceforge.net:/tmp/cvs-serv1742 Added Files: VinerHand ITC Grid.bmp Log Message: can't remember exact changes, just got cooler that's all -mike ***** Bogus filespec: VinerHand ***** Bogus filespec: ITC ***** Error reading new file: (2, 'No such file or directory') |
From: Michael H. <mh...@us...> - 2000-12-12 20:49:03
|
Update of /cvsroot/pythianproject/Prototypes/GUISystem In directory slayer.i.sourceforge.net:/tmp/cvs-serv1414 Added Files: vglStdCtrls.pas Log Message: can't remember exact changes, just got cooler that's all -mike --- NEW FILE --- unit vglStdCtrls; { VGL Standard Controls (C) 2000- The Pythian Project - Kamil Krauspe - Michael Hearn Notes: * Changed scrollbar to use skins - 11th December 2000 * Changed listbox to use one TGLText object for increased efficiency, cut loading time from 8 seconds to 2 :) Bugs: * Scrollbar doesn't quite work correctly in horizontal mode } interface uses Windows, GLCanvas, Classes, vglClasses, Graphics; const VGL_SKINRECT_SCROLLBUTTON_LEFT :TRect = (Left:32;Top:174;Right:51;Bottom:187); VGL_SKINRECT_SCROLLBUTTON_RIGHT :TRect = (Left:31;Top:191;Right:51;Bottom:204); VGL_SKINRECT_SCROLLBUTTON_UP :TRect = (Left:73;Top:180;Right:86;Bottom:199); VGL_SKINRECT_SCROLLBUTTON_DOWN :TRect = (Left:56;Top:180;Right:69;Bottom:199); VGL_SKINRECT_SCROLL_TAB :TRect = (Left:90;Top:185;Right:116;Bottom:198); type TvglScrollBarKind = (sbHorizontal, sbVertical); TvglScrollBarInc = 1..32767; TvglScrollCode = (scLineUp, scLineDown, scPageUp, scPageDown, scPosition, scTrack, scTop, scBottom, scEndScroll); TvglScrollEvent = procedure(Sender: TObject; ScrollCode: TvglScrollCode; var ScrollPos: Integer) of object; TvglScrollStyle = (ssNone, ssHorizontal, ssVertical, ssBoth); TvglScrollBar = class(TvglComponent) private FMin: Integer; FPosition: Integer; FScrollingPos: Integer; FMax: Integer; FOnChange: TNotifyEvent; FSmallChange: TvglScrollBarInc; FLargeChange: TvglScrollBarInc; FKind: TvglScrollBarKind; FOnScroll: TvglScrollEvent; FPageSize: Integer; FBackPanel :TvglPanel; FColor: TColor; FPageAlpha: Single; procedure SetKind(const Value: TvglScrollBarKind); procedure SetMax(const Value: Integer); procedure SetMin(const Value: Integer); procedure SetPosition(const Value: Integer); procedure SetPageSize(const Value: Integer); function GetPageRect(where: TRect): TRect; function GetMinBtnRect(where: TRect): TRect; function GetMaxBtnRect(where: TRect): TRect; function GetBodyRect(where: TRect): TRect; procedure TimerPass; procedure TimerReset; procedure HandleMousePositioning(X, Y: Integer); protected FMouseOver: Boolean; FMouseDwnC: Boolean; FMousePositioning: Boolean; FMouseDown: Boolean; FMousePosConst: Integer; FMousePart, OldMousePart: Integer; FTiming: Boolean; FTimerInterval: Cardinal; FTimerLast, FTimerDiff: Cardinal; FTimingFirst: Boolean; FElapsedTime: Cardinal; FHighLightPaging: Boolean; FImage :TGLBitmap; function GetComponentType: string; override; function GetClientBounds: TRect; override; procedure SetWidth(const Value: integer); override; procedure SetHeight(const Value: integer); override; procedure DoOnMouseEntry; override ; procedure DoOnMouseExit; override ; procedure DoOnMouseDown(mb,x,y:integer); override ; procedure DoOnMouseMove(X,Y:integer); override; procedure DoOnMouseUp(mb, X,Y:integer); override; function CheckPart(X, Y: Integer): Integer; procedure Update(const ElapsedTime: Cardinal); override; public constructor Create(aName: string; AOwner: TvglComponent); destructor Destroy; override; procedure DrawSelf(where: TRect); override; procedure SetParams(APosition, AMin, AMax: Integer); procedure DoChange; dynamic; procedure DoScroll(ScrollCode: TvglScrollCode; var ScrollPos: Integer); dynamic; procedure Trigger(ScrollCode: TvglScrollCode); published property Kind: TvglScrollBarKind read FKind write SetKind default sbHorizontal; property LargeChange: TvglScrollBarInc read FLargeChange write FLargeChange default 10; property Max: Integer read FMax write SetMax default 100; property Min: Integer read FMin write SetMin default 0; property SmallChange: TvglScrollBarInc read FSmallChange write FSmallChange default 1; property Position: Integer read FPosition write SetPosition default 0; property PageSize: Integer read FPageSize write SetPageSize; property OnChange: TNotifyEvent read FOnChange write FOnChange; property OnScroll: TvglScrollEvent read FOnScroll write FOnScroll; property Color :TColor read FColor write FColor; property PageAlpha :Single read FPageAlpha write FPageAlpha; end; TvglSimpleListBox = class(TvglComponent) private FScrollBar: TvglScrollBar; procedure ScrollBarChanged(Sender: TObject); procedure ScrollBarScrolled(Sender: TObject; ScrollCode: TvglScrollCode; var ScrollPos: Integer); procedure ItemsChanged(Sender: TObject); procedure UpdateScrollBar; protected FSelFgColor: TColor; FSorted: Boolean; FItemHeight: Integer; FItemIndex: Integer; //FGLTexts: TStringList; FGLText :TGLText; // for efficiancy reasons now holds all items FItems: TStringList; FColor: TColor; FTranslucency: Single; FScrollBars: TvglScrollStyle; FSelBgTranslulency: Single; FSelBgColor: TColor; procedure SetItemHeight(const Value: Integer); procedure SetItemIndex(const Value: Integer); procedure SetItems(const Value: TStringList); procedure SetSorted(const Value: Boolean); procedure SetColor(const Value: TColor); function GetComponentType: string; override; procedure SetWidth(const Value: integer); override; procedure SetHeight(const Value: integer); override; procedure SetTranslucency(const Value: Single); procedure SetBounds(const Value: TRect); override; procedure SetScrollBars(const Value: TvglScrollStyle); procedure SetSelBgColor(const Value: TColor); procedure SetSelBgTranslulency(const Value: Single); procedure DrawClient(where: TRect); // background f.e. procedure DrawItems(where: TRect); // the items procedure DoOnMouseClick(x, y: Integer); override; procedure SetSelFgColor(const Value: TColor); public // TODO keyboard input - as soon as this and focusing will implemented into // the system - very easy only need to call FScrollBar.Trigger(...) constructor Create(aName:string; AOwner:TvglComponent); destructor Destroy; override ; procedure DrawSelf(where:TRect); override ; function ItemIndexAt(X, Y: Integer): Integer; published property ScrollBars: TvglScrollStyle read FScrollBars write SetScrollBars; // TODO : Horizontal scrollbar property Translucency: Single read FTranslucency write SetTranslucency; property SelBgTranslulency: Single read FSelBgTranslulency write SetSelBgTranslulency; property Color: TColor read FColor write SetColor; property SelBgColor: TColor read FSelBgColor write SetSelBgColor; property SelFgColor: TColor read FSelFgColor write SetSelFgColor; property Items: TStringList read FItems write SetItems; property ItemIndex: Integer read FItemIndex write SetItemIndex; property ItemHeight: Integer read FItemHeight write SetItemHeight; property Sorted: Boolean read FSorted write SetSorted; end; implementation uses Consts, Math; const vglSB_BtnSizeX = 19; vglSB_BtnSizeY = 13; vglSB_TimerInterval = 100; vglSB_TimerIntervalFirst = 500; { TvglScrollbar } function TvglScrollBar.CheckPart(X, Y: Integer): Integer; var tempr, pgr: TRect; begin Result := -1; tempr := ScreenBounds; if PointInRect(GetMinBtnRect(tempr), X, Y) then Result := 0 else if PointInRect(GetMaxBtnRect(tempr), X, Y) then Result := 1 else begin PGR := GetPageRect(tempr); if PointInRect(PGR, X, Y) then Result := 4 else if PointInRect(GetBodyRect(tempr), X, Y) then begin case FKind of sbHorizontal: if X <= pgr.Left then Result := 2 else Result := 3; sbVertical: if Y <= pgr.Top then Result := 2 else Result := 3; end; end; end; end; constructor TvglScrollBar.Create(aName: string; AOwner: TvglComponent); begin inherited Create(aName, AOwner); FAcceptsChildren := False; FTiming := False; TimerReset; FColor := clBlue; FPageAlpha := 0.5; FMin := 0; FMax := 100; FSmallChange := 1; FLargeChange := 10; FPageSize := 10; FPosition := 0; FScrollingPos := 0; FOnChange := nil; FOnScroll := nil; FKind := sbHorizontal; FMousePart := -1; OldMousePart := -1; FImage := TGLBitmap(Manager.GetResource(VGL_SKIN_1)); end; destructor TvglScrollBar.Destroy; begin // inherited Destroy; end; procedure TvglScrollBar.DoChange; begin if Assigned(FOnChange) then FOnChange(Self); end; procedure TvglScrollBar.DoOnMouseDown(mb, x, y: integer); var PGR: TRect; begin inherited; if mb <> VGL_MOUSE_LEFT then Exit; FMouseDown := True; FMousePart := CheckPart(X, Y); if FMousePart < 0 then Exit; if FMousePart < 4 then begin FMouseDwnC := True; TimerReset; FTiming := True; TimerPass; if FMousePart in [2, 3] then FHighlightPaging := True; end; if FMousePart = 4 then begin PGR := GetPageRect(ScreenBounds); FMousePositioning := True; case FKind of sbHorizontal: FMousePosConst := x - PGR.Left; sbVertical: FMousePosConst := y - PGR.Top; end; end; OldMousePart := FMousePart; end; procedure TvglScrollBar.DoOnMouseEntry; begin inherited; FMouseOver := True; if FMouseDwnC then begin FTiming := True; end; end; procedure TvglScrollBar.DoOnMouseExit; begin inherited; FMouseOver := False; FTiming := False; FScrollingPos := Position; end; procedure TvglScrollBar.DoOnMouseMove(X, Y: integer); var NewMousePart: Integer; begin inherited; if FMousePositioning then begin HandleMousePositioning(X, Y); end else begin NewMousePart := CheckPart(X, Y); if NewMousePart <> OldMousePart then FMousePart := -1 else FMousePart := NewMousePart; end; end; procedure TvglScrollBar.DoOnMouseUp(mb, X, Y: integer); begin inherited; FMousePart := -1; FMouseDwnC := False; FMouseDown := False; FTiming := False; FHighLightPaging := False; if FMousePositioning then begin DoScroll(scPosition, FScrollingPos); Position := FScrollingPos; FMousePositioning := False; end; end; procedure TvglScrollBar.DoScroll(ScrollCode: TvglScrollCode; var ScrollPos: Integer); begin if Assigned(FOnScroll) then FOnScroll(Self, ScrollCode, ScrollPos); end; procedure TvglScrollBar.DrawSelf(where: TRect); var TempR, HP: TRect; procedure DrawButtons; begin tempr := GetMinBtnRect(where); if Kind = sbHorizontal then begin FCanvas.DrawBitmapSubRect(tempr.Left,tempr.Top,VGL_SKINRECT_SCROLLBUTTON_RIGHT,FImage); FCanvas.SetClipping(FOwner.ChildClipRect); //FCanvas.Rectangle(tempr.Left, tempr.Top, tempr.Right, tempr.Bottom); tempr := GetMaxBtnRect(where); FCanvas.DrawBitmapSubRect(tempr.Left,tempr.Top,VGL_SKINRECT_SCROLLBUTTON_LEFT,FImage); FCanvas.SetClipping(FOwner.ChildClipRect); //FCanvas.Rectangle(tempr.Left, tempr.Top, tempr.Right, tempr.Bottom); end else if Kind = sbVertical then begin FCanvas.DrawBitmapSubRect(tempr.Left,tempr.Top,VGL_SKINRECT_SCROLLBUTTON_UP,FImage); FCanvas.SetClipping(FOwner.ChildClipRect); //FCanvas.Rectangle(tempr.Left, tempr.Top, tempr.Right, tempr.Bottom); tempr := GetMaxBtnRect(where); FCanvas.DrawBitmapSubRect(tempr.Left,tempr.Top,VGL_SKINRECT_SCROLLBUTTON_DOWN,FImage); FCanvas.SetClipping(FOwner.ChildClipRect); //FCanvas.Rectangle(tempr.Left, tempr.Top, tempr.Right, tempr.Bottom); end; end; // DrawButtons; procedure DrawBody; begin FCanvas.Solid := True; FCanvas.CurrentColor := FColor; FCanvas.FillAlpha := FPageAlpha; tempr := GetBodyRect(where); FCanvas.Rectangle(tempr.Left, tempr.Top, tempr.Right, tempr.Bottom); end; // DrawBody procedure DrawPage; begin FCanvas.Solid := True; FCanvas.CurrentColor := clNavy; FCanvas.FillAlpha := 0.5; tempr := GetPageRect(where); FCanvas.Rectangle(tempr.Left, tempr.Top, tempr.Right, tempr.Bottom); FCanvas.Solid := false; FCanvas.FillAlpha := 1.0; FCanvas.Rectangle(tempr.Left, tempr.Top+1, tempr.Right, tempr.Bottom); if FHighLightPaging and FMouseOver then begin case FMousePart of 2: HP := Rect(tempr.Left, where.Top + vglSB_BtnSizeY, tempr.Right, tempr.Top); 3: HP := Rect(tempr.Left, tempr.Bottom, tempr.Right, where.Bottom - vglSB_BtnSizeY); end; FCanvas.CurrentColor := clBlack; FCanvas.FillAlpha := 1; FCanvas.Rectangle(HP.Left, HP.Top, HP.Right, HP.Bottom); end; end; begin inherited; DrawBody; DrawButtons; DrawPage; end; function TvglScrollBar.GetBodyRect(where: TRect): TRect; begin if Kind = sbHorizontal then begin where.Left := where.Left+ (VGL_SKINRECT_SCROLLBUTTON_LEFT.Right-VGL_SKINRECT_SCROLLBUTTON_LEFT.Left); where.Right := where.Right-(VGL_SKINRECT_SCROLLBUTTON_LEFT.Right-VGL_SKINRECT_SCROLLBUTTON_LEFT.Left); end else if Kind = sbVertical then begin where.Top := where.Top + (VGL_SKINRECT_SCROLLBUTTON_UP.Bottom-VGL_SKINRECT_SCROLLBUTTON_UP.Top); where.Bottom := where.Bottom - (VGL_SKINRECT_SCROLLBUTTON_DOWN.Bottom-VGL_SKINRECT_SCROLLBUTTON_DOWN.Top); where.Right := where.Right - ((VGL_SKINRECT_SCROLLBUTTON_DOWN.Right-VGL_SKINRECT_SCROLLBUTTON_DOWN.Left) div 2); // why? dunno end; Result := where; end; function TvglScrollBar.GetClientBounds: TRect; begin Result := inherited GetClientBounds; end; function TvglScrollBar.GetComponentType: string; begin Result := 'ScrollBar'; end; function TvglScrollBar.GetMaxBtnRect(where: TRect): TRect; begin case FKind of sbHorizontal: Result := Rect(where.Right - vglSB_BtnSizeX + 1, where.Top, where.Right, where.Top + vglSB_BtnSizeY - 1); sbVertical: Result := Rect(where.Left, where.Bottom - vglSB_BtnSizeX + 1, where.Left + vglSB_BtnSizeX - 1, where.Bottom); end; end; function TvglScrollBar.GetMinBtnRect(where: TRect): TRect; begin case FKind of sbHorizontal: Result := Rect(where.Left, where.Top, where.Left + vglSB_BtnSizeX - 1, where.Top + vglSB_BtnSizeY - 1); sbVertical: Result := Rect(where.Left, where.Top, where.Left + vglSB_BtnSizeY - 1, where.Top + vglSB_BtnSizeY - 1); end; end; function TvglScrollBar.GetPageRect(where: TRect): TRect; var L, T, W, H: Integer; a, b, c: Single; begin c := 0; case FKind of sbHorizontal: c := Abs(where.Right - where.Left + 1) - 2*vglSB_BtnSizeX; sbVertical: c := Abs(where.Bottom - where.Top + 1) - 2*vglSB_BtnSizeY; end; if c <= 0 then Exit; b := c / ((FMax - FMin + 1) / FPageSize); // size of the tab a := (c - b + 1) / (FMax - FMin + 1); // x pixels per one scrolling measure - positional L := 0; T := 0; if FKind = sbHorizontal then begin W := vglSB_BtnSizeX; H := vglSB_BtnSizeY; end else begin W := vglSB_BtnSizeY; H := vglSB_BtnSizeX; end; case FKind of sbHorizontal: begin L := vglSB_BtnSizeX + Math.Min(Math.Max(Round(FScrollingPos * a), 0), Round(c - b + 1)); W := Round(b); end; sbVertical: begin T := vglSB_BtnSizeY + Math.Min(Math.Max(Round(FScrollingPos * a), 0), Round(c - b + 1)); H := Round(b); end; end; Result := Rect(where.Left + L, where.Top + T, where.Left + L +W, where.Top + T + H); end; procedure TvglScrollBar.HandleMousePositioning(X, Y: Integer); var a, b, c, d: Single; OldPos: Integer; begin OldPos := FScrollingPos; if FKind = sbVertical then begin c := Abs(ScreenBounds.Bottom - ScreenBounds.Top + 1) - 2*vglSB_BtnSizeY; d := c / ((FMax - FMin + 1) / FPageSize); // size of the tab b := (c - d + 1) / (FMax - FMin + 1); // x pixels per one scrolling measure - positional a := Y - ScreenBounds.Top - vglSB_BtnSizeY - FMousePosConst; // Top of the tab (page) c := a / b; // c -> FPosition FScrollingPos := Math.Max(Math.Min(Trunc(c), FMax), FMin); end else if FKind = sbHorizontal then begin c := Abs(ScreenBounds.Right - ScreenBounds.Left + 1) - 2*vglSB_BtnSizeX; b := c / (FMax - FMin + 1); // x pixels per one scrolling measure - positional a := X - ScreenBounds.Left - vglSB_BtnSizeX - FMousePosConst; // Top of the tab (page) c := a / b; // c -> FPosition FScrollingPos := Math.Max(Math.Min(Trunc(c), FMax), FMin); end; if OldPos <> FScrollingPos then DoScroll(scTrack, FScrollingPos); end; procedure TvglScrollBar.SetHeight(const Value: Integer); var AValue: Integer; begin AValue := Value; case FKind of sbHorizontal: begin if AValue < vglSB_BtnSizeY then AValue := vglSB_BtnSizeY; end; sbVertical: begin if AValue < 2*vglSB_BtnSizeY then AValue := 2*vglSB_BtnSizeY; end; end; inherited SetHeight(AValue); end; procedure TvglScrollBar.SetKind(const Value: TvglScrollBarKind); begin FKind := Value; end; procedure TvglScrollBar.SetMax(const Value: Integer); begin SetParams(FPosition, FMin, Value); end; procedure TvglScrollBar.SetMin(const Value: Integer); begin SetParams(FPosition, Value, FMax); end; procedure TvglScrollBar.SetPageSize(const Value: Integer); begin FPageSize := Value; end; procedure TvglScrollBar.SetParams(APosition, AMin, AMax: Integer); begin if AMax < AMin then raise EInvalidOperation.Create(SScrollBarRange); if APosition < AMin then APosition := AMin; if APosition > AMax then APosition := AMax; FMin := AMin; FMax := AMax; FPosition := APosition; FScrollingPos := FPosition; end; procedure TvglScrollBar.SetPosition(const Value: Integer); begin SetParams(Value, FMin, FMax); DoChange; end; procedure TvglScrollBar.SetWidth(const Value: integer); var AValue: Integer; begin AValue := Value; case FKind of sbVertical: begin if AValue < vglSB_BtnSizeY then AValue := vglSB_BtnSizeY; end; sbHorizontal: begin if AValue < 2*vglSB_BtnSizeX then AValue := 2*vglSB_BtnSizeX; end; end; inherited SetWidth(AValue); end; procedure TvglScrollBar.TimerPass; begin if (FMousePart >= 0) and (FMousePart < 4) then Trigger(TvglScrollCode(FMousePart)); end; procedure TvglScrollBar.TimerReset; begin FTimerLast := FElapsedTime; FTimerInterval := vglSB_TimerIntervalFirst; FTimingFirst := True; end; procedure TvglScrollBar.Trigger(ScrollCode: TvglScrollCode); var TempI: Integer; begin TempI := Position; if ScrollCode = scLineUp then begin TempI := Position - FSmallChange; DoScroll(scLineUp, TempI); Position := TempI; end else if ScrollCode = scLineDown then begin TempI := Position + FSmallChange; DoScroll(scLineDown, TempI); Position := TempI; end else if ScrollCode = scPageUp then begin TempI := Position - FLargeChange; DoScroll(scPageUp, TempI); Position := TempI; end else if ScrollCode = scPageDown then begin TempI := Position + FLargeChange; DoScroll(scPageDown, TempI); Position := TempI; end; end; procedure TvglScrollBar.Update(const ElapsedTime: Cardinal); begin inherited; // this will handle everything, what TTimer should handle, but does not... FElapsedTime := ElapsedTime; if FTiming then begin FTimerDiff := ElapsedTime - FTimerLast; if FTimerDiff >= FTimerInterval then begin if FTimingFirst then begin FTimingFirst := False; FTimerInterval := vglSB_TimerInterval; Exit; end; FTimerLast := ElapsedTime; TimerPass; end; end; end; { TvglSimpleListBox } constructor TvglSimpleListBox.Create(aName: string; AOwner: TvglComponent); begin inherited Create(aName, AOwner); FAcceptsChildren := True; Width := 100; Height := 250; FScrollBar := TvglScrollBar.Create(aName + '_ScrollBarInternal', Self); FScrollBar.Min := 0; FScrollBar.Max := 0; FScrollBar.OnChange := ScrollBarChanged; FScrollBar.OnScroll := ScrollBarScrolled; FScrollBar.Kind := sbVertical; FScrollBar.Width := 13; // force auto-size FScrollBar.Height := Height; FScrollBar.Top := 0; FScrollBar.Left := FBounds.Right - 13{FScrollBar.Width} + 1; FScrollBar.Color := clAqua; FItems := TStringList.Create; FItems.OnChange := ItemsChanged; //FGLTexts := TStringList.Create; FGLText := TGLText.Create('Arial'); FAcceptsChildren := False; FItemHeight := 25; SetScrollBars(ssBoth); FSelBgTranslulency := 0; FSelBgColor := clNavy; FSelFgColor := clWhite; end; destructor TvglSimpleListBox.Destroy; begin FItems.Free; FGLText.Free; inherited Destroy; end; procedure TvglSimpleListBox.DoOnMouseClick(x, y: Integer); begin inherited; ItemIndex := ItemIndexAt(X, Y); end; procedure TvglSimpleListBox.DrawClient(where: TRect); begin FCanvas.CurrentColor := FColor; FCanvas.FillAlpha := 1 - Translucency; FCanvas.Solid := True; FCanvas.Rectangle(where.Left, where.Top, where.Right, where.Bottom); end; procedure TvglSimpleListBox.DrawItems(where: TRect); var i, j, k: Integer; CC, NC, DC: TRect; procedure DrawItem(NO: Integer); var SavedC: array[0..2] of Byte; begin if No < FGLText.Lines.Count then begin if FItemIndex = NO then begin FCanvas.CurrentColor := FSelBgColor; FCanvas.FillAlpha := 1 - FSelBgTranslulency; FCanvas.Solid := True; FCanvas.Rectangle(DC.Left, DC.Top, DC.Right, DC.Bottom); with FGLText do begin SavedC[0] := Red; SavedC[1] := Green; SavedC[2] := Blue; SetColor(FSelFgColor); end; end; FCanvas.DrawTextLine(DC.Left + 2, DC.Top + 2, No, FGLText); if FItemIndex = NO then with FGLText do begin Red := SavedC[0]; Green := SavedC[1]; Blue := SavedC[2]; end; end; end; begin CC := where; k := FScrollBar.FScrollingPos; j := (Height div FItemHeight); FCanvas.CancelClipping; for i := 0 to j do begin NC := Rect(CC.Left, CC.Top + i*FItemHeight, CC.Left + Width - FScrollBar.Width, CC.Top + (i+1)*FItemHeight-1); DC := FitRectToRect(CC, NC); FCanvas.SetClipping(DC); DrawItem(i + k); FCanvas.CancelClipping; end; FCanvas.SetClipping(CC); end; function TvglSimpleListBox.ItemIndexAt(X, Y: Integer): Integer; begin Result := FScrollBar.FScrollingPos + (Y - ScreenBounds.Top) div FItemHeight; end; procedure TvglSimpleListBox.DrawSelf(where: TRect); begin inherited; DrawClient(where); DrawItems(where); end; function TvglSimpleListBox.GetComponentType: string; begin Result := 'SimpleListBox'; end; procedure TvglSimpleListBox.ItemsChanged(Sender: TObject); var i: Integer; TT: TGLText; begin if FScrollBar = nil then Exit; UpdateScrollBar; { for i := 0 to FGLTexts.Count - 1 do begin if FGLTexts.Objects[i] <> nil then FGLTexts.Objects[i].Free; end;} FGLText.Lines.Clear; for i := 0 to FItems.Count - 1 do begin {TT := TGLText.Create(FItems[i], FGLTexttmpl.FontName, FGLTexttmpl.TextType, GLC_DEFAULT_FONT_DATA); with TGLText(TT) do begin GLFFontHandle := FGLTexttmpl.GLFFontHandle; QT := FGLTexttmpl.QT; Red := FGLTexttmpl.Red; Blue := FGLTexttmpl.Blue; Green := FGLTexttmpl.Green; Size := FGLTexttmpl.Size; Precache := FGLTexttmpl.Precache; end; FGLTexts.AddObject(FItems[i], TT);} FGLText.Lines.Add(FItems[i]); end; end; procedure TvglSimpleListBox.ScrollBarChanged(Sender: TObject); begin // end; procedure TvglSimpleListBox.ScrollBarScrolled(Sender: TObject; ScrollCode: TvglScrollCode; var ScrollPos: Integer); begin end; procedure TvglSimpleListBox.SetBounds(const Value: TRect); begin inherited; UpdateScrollBar; end; procedure TvglSimpleListBox.SetColor(const Value: TColor); begin FColor := Value; end; procedure TvglSimpleListBox.SetHeight(const Value: integer); begin inherited SetHeight(Value); UpdateScrollBar; end; procedure TvglSimpleListBox.SetItemHeight(const Value: Integer); begin FItemHeight := Max(Value, 1); end; procedure TvglSimpleListBox.SetItemIndex(const Value: Integer); var i: Integer; begin FItemIndex := Value; i := Height div FItemHeight + FScrollBar.Position - 1; if i < FItemIndex then FScrollBar.Position := FItemIndex; end; procedure TvglSimpleListBox.SetItems(const Value: TStringList); begin FItems := Value; end; procedure TvglSimpleListBox.SetScrollBars(const Value: TvglScrollStyle); begin FScrollBars := Value; if Value = ssBoth then begin FScrollBar.Visible := True; end else if Value = ssVertical then begin FScrollBar.Visible := True; end else if Value = ssHorizontal then begin FScrollBar.Visible := False; end else begin FScrollBar.Visible := False; end; end; procedure TvglSimpleListBox.SetSelBgColor(const Value: TColor); begin FSelBgColor := Value; end; procedure TvglSimpleListBox.SetSelBgTranslulency(const Value: Single); begin FSelBgTranslulency := Max(Min(Value, 1), 0); end; procedure TvglSimpleListBox.SetSelFgColor(const Value: TColor); begin FSelFgColor := Value; end; procedure TvglSimpleListBox.SetSorted(const Value: Boolean); begin FSorted := Value; FItems.BeginUpdate; FItems.Sorted := Value; FItems.EndUpdate; end; procedure TvglSimpleListBox.SetTranslucency(const Value: Single); begin FTranslucency := Max(Min(Value, 1), 0); end; procedure TvglSimpleListBox.SetWidth(const Value: integer); begin inherited SetWidth(Value); UpdateScrollBar; end; procedure TvglSimpleListBox.UpdateScrollBar; begin if FScrollBar = nil then Exit; FScrollBar.Top := 1; FScrollBar.Left := Width - FScrollBar.Width; FScrollBar.Width := vglSB_BtnSizeX; FScrollBar.Height := Height - 1; FScrollBar.PageSize := (Height div FItemHeight); FScrollBar.Min := 0; FScrollBar.Max := FItems.Count - FScrollBar.PageSize; FScrollBar.LargeChange := FScrollBar.PageSize; end; end. |
From: Michael H. <mh...@us...> - 2000-12-12 20:40:40
|
Update of /cvsroot/pythianproject/Prototypes/GLCanvas In directory slayer.i.sourceforge.net:/tmp/cvs-serv533/GLCanvas Modified Files: glCanvas.pas Log Message: can't remember exact changes, just got cooler that's all -mike Index: glCanvas.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/glCanvas.pas,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** glCanvas.pas 2000/12/11 19:15:12 1.10 --- glCanvas.pas 2000/12/12 20:40:36 1.11 *************** *** 214,219 **** procedure SetPrecache(const Value: boolean); ! procedure UpdateDisplayList; virtual ; ! procedure DrawInternal; virtual; function MatchFontName(name:string; tt:Integer):TGLCanvasFontData; --- 214,219 ---- procedure SetPrecache(const Value: boolean); ! procedure UpdateDisplayList(line:integer); virtual ; ! procedure DrawInternal(line:integer); virtual; function MatchFontName(name:string; tt:Integer):TGLCanvasFontData; *************** *** 233,237 **** property Lines:TStringList read FLines; property Text:string read GetText write SetText; - property Width[index:integer]:integer read GetWidth; --- 233,236 ---- *************** *** 249,253 **** constructor Create(aFontName:string); overload; // auto creates with no text, and quadtext selected destructor Destroy; override ; ! procedure Draw; virtual ; procedure SetColor(const Value: TColor); end; --- 248,252 ---- constructor Create(aFontName:string); overload; // auto creates with no text, and quadtext selected destructor Destroy; override ; ! procedure Draw(Line:integer); virtual ; procedure SetColor(const Value: TColor); end; *************** *** 294,297 **** --- 293,297 ---- // text routines here procedure DrawText(X,Y:Integer; text:TGLText); virtual ; + procedure DrawTextLine(X,Y,Line:integer; Text:TGLText); virtual ; procedure DrawString(X,Y:integer; str:String; FontName:string; aFontType:integer); virtual ; // WARNING: inefficient, don't use except for testing *************** *** 559,585 **** procedure TGLCanvas.DrawText(X, Y: Integer; text: TGLText); begin ! if text.TextType = GLCANVAS_TEXT_GLF then ! begin ! glPushAttrib(GL_TEXTURE_2D); ! glDisable(GL_TEXTURE_2d); ! glMatrixMode(GL_MODELVIEW); ! glLoadIdentity; ! // change co-ordinate system to 1:1 pixel mapping ! glScalef(2.0 / Width, 2.0 / Height, 1.0); ! glTranslatef(-(Width / 2), (Height / 2), 0); ! glTranslatef(X,-Y,0); ! glPopAttrib; ! end else if text.TextType = GLCANVAS_TEXT_QUADTEXT then ! begin ! glMatrixMode(GL_MODELVIEW); ! glLoadIdentity; ! // change co-ordinate system to 1:1 pixel mapping ! glScalef(2.0 / Width, -2.0 / Height, 1.0); ! glTranslatef(-(Width / 2), -(Height / 2), 0); ! ! glTranslatef(X,Y,0); ! end; ! ! text.Draw; end; --- 559,563 ---- procedure TGLCanvas.DrawText(X, Y: Integer; text: TGLText); begin ! DrawTextLine(X,Y,-1,text); end; *************** *** 668,671 **** --- 646,677 ---- end; + procedure TGLCanvas.DrawTextLine(X, Y, Line: integer; Text: TGLText); + begin + // line = -1 means all lines + if text.TextType = GLCANVAS_TEXT_GLF then + begin + glPushAttrib(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_2d); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity; + // change co-ordinate system to 1:1 pixel mapping + glScalef(2.0 / Width, 2.0 / Height, 1.0); + glTranslatef(-(Width / 2), (Height / 2), 0); + glTranslatef(X,-Y,0); + glPopAttrib; + end else if text.TextType = GLCANVAS_TEXT_QUADTEXT then + begin + glMatrixMode(GL_MODELVIEW); + glLoadIdentity; + // change co-ordinate system to 1:1 pixel mapping + glScalef(2.0 / Width, -2.0 / Height, 1.0); + glTranslatef(-(Width / 2), -(Height / 2), 0); + + glTranslatef(X,Y,0); + end; + + text.Draw(Line); + end; + { TGLText } *************** *** 685,689 **** LoadFont; if Precache then ! UpdateDisplayList; SetColor(clWhite); end; --- 691,695 ---- LoadFont; if Precache then ! UpdateDisplayList(-1); SetColor(clWhite); end; *************** *** 703,714 **** end; ! procedure TGLText.Draw; begin if Precache then glCallList(FDisplayList) ! else DrawInternal; end; ! procedure TGLText.DrawInternal; var a:integer; minx,miny,maxx,maxy:single; --- 709,720 ---- end; ! procedure TGLText.Draw(Line:integer); begin if Precache then glCallList(FDisplayList) ! else DrawInternal(Line); end; ! procedure TGLText.DrawInternal(line:integer); var a:integer; minx,miny,maxx,maxy:single; *************** *** 720,731 **** glPushMatrix; glScalef(Size,Size,1); ! for a := 0 to FLines.Count-1 do ! begin ! glPushMatrix; ! glfGetStringBoundsF(glfFontHandle,FLines[a],minx,miny,maxx,maxy); ! glfDrawSolidStringF(GLFFontHandle,FLines[a]); ! glPopMatrix; ! glTranslatef(0,-2,0); // move down a line ! end; glPopMatrix; end else if TextType = GLCANVAS_TEXT_QUADTEXT then --- 726,739 ---- glPushMatrix; glScalef(Size,Size,1); ! if line = -1 then ! for a := 0 to FLines.Count-1 do ! begin ! glPushMatrix; ! glfGetStringBoundsF(glfFontHandle,FLines[a],minx,miny,maxx,maxy); ! glfDrawSolidStringF(GLFFontHandle,FLines[a]); ! glPopMatrix; ! glTranslatef(0,-2,0); // move down a line ! end ! else glfDrawSolidStringF(GLFFontHandle,FLines[line]); // UNTESTED!!!! glPopMatrix; end else if TextType = GLCANVAS_TEXT_QUADTEXT then *************** *** 734,738 **** qtStart; glPushMatrix; ! qtDrawGridString(QT,FLines.Text); glPopMatrix; qtStop; --- 742,748 ---- qtStart; glPushMatrix; ! if Line = -1 then ! qtDrawGridString(QT,FLines.Text) ! else qtDrawGridString(QT,FLines.Strings[Line]); glPopMatrix; qtStop; *************** *** 752,756 **** procedure TGLText.LinesOnChange(Sender: TObject); begin ! if Precache then UpdateDisplayList; end; --- 762,766 ---- procedure TGLText.LinesOnChange(Sender: TObject); begin ! if Precache then UpdateDisplayList(-1); end; *************** *** 812,816 **** begin FBlue := Value; ! UpdateDisplayList; end; --- 822,826 ---- begin FBlue := Value; ! UpdateDisplayList(-1); end; *************** *** 820,824 **** FGreen := (Value and $00FF00) SHR 8; FBlue := (Value and $FF0000) SHR 16; ! UpdateDisplayList; end; --- 830,834 ---- FGreen := (Value and $00FF00) SHR 8; FBlue := (Value and $FF0000) SHR 16; ! UpdateDisplayList(-1); end; *************** *** 827,831 **** FFontName := Value; LoadFont; ! UpdateDisplayList; end; --- 837,841 ---- FFontName := Value; LoadFont; ! UpdateDisplayList(-1); end; *************** *** 833,837 **** begin FGreen := Value; ! UpdateDisplayList; end; --- 843,847 ---- begin FGreen := Value; ! UpdateDisplayList(-1); end; *************** *** 839,843 **** begin FPrecache := Value; ! UpdateDisplayList; end; --- 849,853 ---- begin FPrecache := Value; ! UpdateDisplayList(-1); end; *************** *** 845,849 **** begin FRed := Value; ! UpdateDisplayList; end; --- 855,859 ---- begin FRed := Value; ! UpdateDisplayList(-1); end; *************** *** 851,855 **** begin FSize := Value; ! UpdateDisplayList; end; --- 861,865 ---- begin FSize := Value; ! UpdateDisplayList(-1); end; *************** *** 857,864 **** begin FLines.Text := Value; ! UpdateDisplayList; end; ! procedure TGLText.UpdateDisplayList; begin if Precache then --- 867,874 ---- begin FLines.Text := Value; ! UpdateDisplayList(-1); end; ! procedure TGLText.UpdateDisplayList(line:integer); begin if Precache then *************** *** 867,871 **** FDisplayList := glGenLists(1); glNewList(FDisplayList,GL_COMPILE); ! DrawInternal; glEndList; end; --- 877,881 ---- FDisplayList := glGenLists(1); glNewList(FDisplayList,GL_COMPILE); ! DrawInternal(line); glEndList; end; |
From: Michael H. <mh...@us...> - 2000-12-12 20:40:40
|
Update of /cvsroot/pythianproject/Prototypes/GUISystem In directory slayer.i.sourceforge.net:/tmp/cvs-serv533/GUISystem Modified Files: StartupForm.pas Log Message: can't remember exact changes, just got cooler that's all -mike Index: StartupForm.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/StartupForm.pas,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** StartupForm.pas 2000/12/12 19:45:47 1.5 --- StartupForm.pas 2000/12/12 20:40:37 1.6 *************** *** 22,25 **** --- 22,26 ---- Label1:TvglTextBox; SB :TvglScrollbar; + LB: TvglSimpleListBox; CB: TvglCheckBox; *************** *** 121,124 **** --- 122,126 ---- procedure TfrmStartup.go; + var i:integer; begin GLForm := TGLForm.Create; *************** *** 199,208 **** SB := TvglScrollBar.Create('ScrollBar1', InterfaceManager.Desktop); SB.Kind := sbHorizontal; ! SB.Left := 260; ! SB.Top := 60; SB.Height := 13; ! SB.Width := 200; SB.Position := 15; SB.PageSize := 10; Hide; --- 201,223 ---- SB := TvglScrollBar.Create('ScrollBar1', InterfaceManager.Desktop); SB.Kind := sbHorizontal; ! SB.Left := 60; ! SB.Top := 260; SB.Height := 13; ! SB.Width := 150; SB.Position := 15; SB.PageSize := 10; + + LB := TvglSimpleListBox.Create('SimpleListBoxTest', InterfaceManager.Desktop); + LB.Items.BeginUpdate; + LB.Items.Clear; + for i := 0 to 100 do + begin + LB.Items.Add('Item '+IntToStr(i)); + end; + LB.Items.EndUpdate; + LB.Color := clBlue; + LB.Translucency := 0.5; + LB.Bounds := Rect(260, 30, 450, 280); + LB.ScrollBars := ssBoth; Hide; |
From: Kamil K. <kkr...@us...> - 2000-12-12 19:45:51
|
Update of /cvsroot/pythianproject/Prototypes/GUISystem In directory slayer.i.sourceforge.net:/tmp/cvs-serv27918 Modified Files: skin1.png StartupForm.pas Added Files: vglCheckBox.pas Log Message: added TvglCheckBox component --- NEW FILE --- unit vglCheckBox; interface uses Windows, Classes, Graphics, GLCanvas, vglClasses; const VGL_SKINRECT_CHECKBOXSET: TRect = (Left: 0; Top: 205; Right: 13; Bottom: 217); VGL_SKINRECT_CHECKBOXUNSET: TRect = (Left: 12; Top: 205; Right: 25; Bottom: 217); vglCheckOver_Intensity = 220; vglCheckUp_Intensity = 255; vglCheckDown_Intensity = 200; type TvglCheckBox = class(TvglComponent) private procedure SetColor(const Value: TColor); protected FChecked: Boolean; FOnChanged: TNotifyEvent; FImage: TGLBitmap; FCaptionText: TGLText; FMouseMarkDown: Boolean; FMouseMarkOver: Boolean; FMouseOver: Boolean; procedure SetCaption(const Value: string); function GetCaption: string; procedure SetOnChanged(const Value: TNotifyEvent); procedure SetChecked(const Value: Boolean); procedure DoChanged; dynamic; function GetComponentType: string; override ; procedure DoOnMouseEntry; override ; procedure DoOnMouseExit; override ; procedure DoOnMouseDown(mb, x, y: Integer); override; procedure DoOnMouseClick(x, y: Integer); override; procedure DoOnMouseUp(mb, x, y: Integer); override; procedure DoOnMouseMove(X,Y:integer); override; procedure UpdateBounds; function GetCheckMarkBounds(where: TRect): TRect; virtual; function GetCheckMarkSkinRect: TRect; procedure CheckMarkOver(X, Y: Integer); public constructor Create(aName:string; AOwner:TvglComponent); destructor Destroy; override ; procedure DrawSelf(where:TRect); override ; published property Checked: Boolean read FChecked write SetChecked default False; property Color :TColor write SetColor; property Caption: string read GetCaption write SetCaption; property OnChanged: TNotifyEvent read FOnChanged write SetOnChanged; end; implementation uses Math; { TvglCheckBox } procedure TvglCheckBox.CheckMarkOver(X, Y: Integer); begin FMouseMarkOver := PointInRect(GetCheckMarkBounds(ScreenBounds), X, Y); end; constructor TvglCheckBox.Create(aName: string; AOwner: TvglComponent); begin inherited Create(aName, AOwner); FImage := TGLBitmap(Manager.GetResource(VGL_SKIN_1)); // FCaptionText := TGLText.Create('Courier New'); FCaptionText := TGLText.Create('Arial'); FCaptionText.Text := aName; FCaptionText.SetColor(clBlack); FMouseMarkDown := False; FMouseOver := False; FChecked := False; FOnChanged := nil; UpdateBounds; end; destructor TvglCheckBox.Destroy; begin FImage := nil; inherited Destroy; end; procedure TvglCheckBox.DoChanged; begin if Assigned(FOnChanged) then FOnChanged(Self); end; procedure TvglCheckBox.DoOnMouseClick(x, y: Integer); begin inherited DoOnMouseClick(x, y); if PointInRect(GetCheckMarkBounds(ScreenBounds), X, Y) then begin FChecked := not FChecked; DoChanged; end; end; procedure TvglCheckBox.DoOnMouseDown(mb, x, y: Integer); begin inherited DoOnMouseDown(mb, x, y); if mb <> VGL_MOUSE_LEFT then Exit; if PointInRect(GetCheckMarkBounds(ScreenBounds), X, Y) then FMouseMarkDown := True; end; procedure TvglCheckBox.DoOnMouseEntry; begin inherited DoOnMouseEntry; FMouseOver := True; end; procedure TvglCheckBox.DoOnMouseExit; begin inherited DoOnMouseExit; FMouseOver := False; FMouseMarkOver := False; end; procedure TvglCheckBox.DoOnMouseMove(X, Y: integer); begin inherited DoOnMouseMove(X, Y); CheckMarkOver(X, Y); end; procedure TvglCheckBox.DoOnMouseUp(mb, x, y: Integer); begin inherited DoOnMouseUp(mb, x, y); FMouseMarkDown := False; end; procedure TvglCheckBox.DrawSelf(where: TRect); var MarkRect,SkinRect: TRect; begin inherited DrawSelf(where); if (FMouseMarkDown) and (FMouseMarkOver) then FImage.Intensity := vglCheckDown_Intensity else if FMouseMarkOver then FImage.Intensity := vglCheckOver_Intensity else FImage.Intensity := vglCheckUp_Intensity; SkinRect := GetCheckMarkSkinRect; MarkRect := GetCheckMarkBounds(where); if FCaptionText.Text <> '' then Canvas.DrawText(where.Left + SkinRect.Right - SkinRect.Left + 5, where.Top, FCaptionText); Canvas.DrawBitmapSubRect(MarkRect.Left, MarkRect.Top, SkinRect, FImage); FImage.Intensity := 255; end; function TvglCheckBox.GetCaption: string; begin Result := FCaptionText.Text; end; function TvglCheckBox.GetCheckMarkBounds(where: TRect): TRect; var SkinRect: TRect; begin SkinRect := GetCheckMarkSkinRect; Result.Left := where.Left; Result.Top := where.Top + (((where.Bottom - where.Top) - (SkinRect.Bottom - SkinRect.TOP)) div 2); Result.Right := Result.Left + SkinRect.Right - SkinRect.Left; Result.Bottom := Result.Top + SkinRect.Bottom - SkinRect.Top; end; function TvglCheckBox.GetCheckMarkSkinRect: TRect; begin if FChecked then Result := VGL_SKINRECT_CHECKBOXSET else Result := VGL_SKINRECT_CHECKBOXUNSET; end; function TvglCheckBox.GetComponentType: string; begin Result := 'CheckBox'; end; procedure TvglCheckBox.SetCaption(const Value: string); begin FCaptionText.Text := Value; UpdateBounds; end; procedure TvglCheckBox.SetChecked(const Value: Boolean); begin FChecked := Value; end; procedure TvglCheckBox.SetColor(const Value: TColor); begin FCaptionText.SetColor(Value); end; procedure TvglCheckBox.SetOnChanged(const Value: TNotifyEvent); begin FOnChanged := Value; end; procedure TvglCheckBox.UpdateBounds; var i:integer; longest:integer; SKINRECT: TRect; begin SKINRECT := GetCheckMarkSkinRect; // locate longest line longest := 0; for i := 0 to FCaptionText.Lines.Count-1 do if FCaptionText.Width[i] > longest then longest := FCaptionText.Width[i]; Width := longest + (SKINRECT.Right - SKINRECT.Left) + 5; Height := Math.Max(Math.Max(FCaptionText.Lines.Count*FCaptionText.QT.GridSquareHeight, SKINRECT.Bottom - SKINRECT.TOP + 1), Height); end; end. Index: skin1.png =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/skin1.png,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 Binary files /tmp/cvsAIM9xd and /tmp/cvsMR191f differ Index: StartupForm.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/StartupForm.pas,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** StartupForm.pas 2000/12/11 19:15:12 1.4 --- StartupForm.pas 2000/12/12 19:45:47 1.5 *************** *** 7,11 **** uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ! StdCtrls, GLForms, GLCanvas, OpenGL, vglClasses, vglStdCtrls; type --- 7,11 ---- uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ! StdCtrls, GLForms, GLCanvas, OpenGL, vglClasses, vglStdCtrls, vglCheckBox; type *************** *** 22,25 **** --- 22,26 ---- Label1:TvglTextBox; SB :TvglScrollbar; + CB: TvglCheckBox; Elapsed,FirstTime:Cardinal; *************** *** 52,56 **** InterfaceManager :TvglInterfaceManager; ! function timeGetTime: Integer; external 'winmm.dll' name 'timeGetTime'; implementation --- 53,57 ---- InterfaceManager :TvglInterfaceManager; ! function timeGetTime: Cardinal; external 'winmm.dll' name 'timeGetTime'; implementation *************** *** 122,127 **** begin GLForm := TGLForm.Create; ! GLForm.FullScreen := false; ! //GLForm.SetBounds(0,0,800,600); GLForm.SetBounds(0,0,640,480); GLForm.Caption := 'VGL Demo 1'; --- 123,128 ---- begin GLForm := TGLForm.Create; ! GLForm.FullScreen := False; ! // GLForm.SetBounds(0,0,800,600); GLForm.SetBounds(0,0,640,480); GLForm.Caption := 'VGL Demo 1'; *************** *** 148,152 **** Panel1 := TvglPanel.Create('Panel1',InterfaceManager.Desktop); Panel1.Bounds := Rect(50,50,250,250); ! Panel1.Textured := true; Panel1.OnMouseDown := Panel1OnMouseDown; Panel1.OnMouseEntry := Panel1OnMouseEntry; --- 149,153 ---- Panel1 := TvglPanel.Create('Panel1',InterfaceManager.Desktop); Panel1.Bounds := Rect(50,50,250,250); ! Panel1.Textured := True; Panel1.OnMouseDown := Panel1OnMouseDown; Panel1.OnMouseEntry := Panel1OnMouseEntry; *************** *** 163,166 **** --- 164,175 ---- Image1.Bounds := Rect(500,20,0,0); + CB := TvglCheckBox.Create('CheckBox1', InterfaceManager.Desktop); + CB.Left := 10; + CB.Top := 410; + CB.Height := 0; + CB.Checked := True; + CB.Color := clWhite; + CB.Caption := 'This is a checkbox'; + Button := TvglButton.Create('Button',Panel1); Button.Caption := 'hide image'; *************** *** 183,189 **** Label1 := TvglTextBox.Create('Label1',InterfaceManager.Desktop); ! Label1.Top := 200; Label1.Left := 60; ! Label1.Color := clWhite; Label1.Caption := 'Hello World'#13'This is Mike speaking to you'; --- 192,198 ---- Label1 := TvglTextBox.Create('Label1',InterfaceManager.Desktop); ! Label1.Top := 250; Label1.Left := 60; ! Label1.Color := clBlack; Label1.Caption := 'Hello World'#13'This is Mike speaking to you'; |
From: Michael H. <mh...@us...> - 2000-12-11 19:15:15
|
Update of /cvsroot/pythianproject/Prototypes/GUISystem In directory slayer.i.sourceforge.net:/tmp/cvs-serv2707/GUISystem Modified Files: StartupForm.pas VGLDemo1.dpr skin1.png vglClasses.pas Log Message: vgl update: scrollbars etc. -mike Index: StartupForm.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/StartupForm.pas,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** StartupForm.pas 2000/12/09 22:13:38 1.3 --- StartupForm.pas 2000/12/11 19:15:12 1.4 *************** *** 7,11 **** uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ! StdCtrls, GLForms, GLCanvas, OpenGL, vglClasses; type --- 7,11 ---- uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ! StdCtrls, GLForms, GLCanvas, OpenGL, vglClasses, vglStdCtrls; type *************** *** 20,24 **** --- 20,28 ---- Button :TvglButton; Panel1:TvglPanel; + Label1:TvglTextBox; + SB :TvglScrollbar; + Elapsed,FirstTime:Cardinal; + ClipTestP1,ClipTestP2,ClipTestP3,ClipTestP4 :TvglPanel; public *************** *** 48,51 **** --- 52,57 ---- InterfaceManager :TvglInterfaceManager; + function timeGetTime: Integer; external 'winmm.dll' name 'timeGetTime'; + implementation *************** *** 60,66 **** begin glClear(GL_DEPTH_BUFFER_BIT); - GLC.InitMatrix; GLC.DrawBitmap(0,0,Wallpaper); InterfaceManager.DrawAll; end; --- 66,73 ---- begin glClear(GL_DEPTH_BUFFER_BIT); GLC.InitMatrix; GLC.DrawBitmap(0,0,Wallpaper); + Elapsed := timeGetTime - FirstTime; // elapsed time from beginning - GLForm.Run + InterfaceManager.Update(Elapsed); InterfaceManager.DrawAll; end; *************** *** 130,139 **** if not GLForm.FullScreen then GLC := TGLCanvas.Create(GLForm.Width-6,GLForm.Height-25) // must take into account window borders ! else GLC := TGLCanvas.Create(638,480); Wallpaper := TGLBitmap.Create; Wallpaper.LoadFromBitmap('..\GLCanvas\scene.png'); ! //##InterfaceManager := TvglInterfaceManager.Create(Rect(0,0,634,455)); ! InterfaceManager := TvglInterfaceManager.Create(GLC); // create test components --- 137,147 ---- if not GLForm.FullScreen then GLC := TGLCanvas.Create(GLForm.Width-6,GLForm.Height-25) // must take into account window borders ! else GLC := TGLCanvas.Create(638,478); Wallpaper := TGLBitmap.Create; Wallpaper.LoadFromBitmap('..\GLCanvas\scene.png'); ! if GLForm.FullScreen then ! InterfaceManager := TvglInterfaceManager.Create(GLForm.Handle, GLC) ! else InterfaceManager := TvglInterfaceManager.Create(GLForm.Handle, GLC); // create test components *************** *** 174,180 **** --- 182,203 ---- ClipTestP3.Bounds := Rect(-60,-60,60,60); + Label1 := TvglTextBox.Create('Label1',InterfaceManager.Desktop); + Label1.Top := 200; + Label1.Left := 60; + Label1.Color := clWhite; + Label1.Caption := 'Hello World'#13'This is Mike speaking to you'; + + SB := TvglScrollBar.Create('ScrollBar1', InterfaceManager.Desktop); + SB.Kind := sbHorizontal; + SB.Left := 260; + SB.Top := 60; + SB.Height := 13; + SB.Width := 200; + SB.Position := 15; + SB.PageSize := 10; Hide; ShowCursor(false); + FirstTime := timeGetTime; GLForm.Run; ShowCursor(true); Index: VGLDemo1.dpr =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/VGLDemo1.dpr,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** VGLDemo1.dpr 2000/12/08 19:21:41 1.1 --- VGLDemo1.dpr 2000/12/11 19:15:12 1.2 *************** *** 3,8 **** uses Forms, ! StartupForm in 'StartupForm.pas' {frmStartup}, ! vglClasses in 'vglClasses.pas'; {$R *.RES} --- 3,7 ---- uses Forms, ! StartupForm in 'StartupForm.pas' {frmStartup}; {$R *.RES} Index: skin1.png =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/skin1.png,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 Binary files /tmp/cvsuqJGGW and /tmp/cvsKIyesO differ Index: vglClasses.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/vglClasses.pas,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** vglClasses.pas 2000/12/09 22:13:38 1.3 --- vglClasses.pas 2000/12/11 19:15:12 1.4 *************** *** 108,111 **** --- 108,112 ---- private procedure SetOwner(const Value: TvglComponent); + function GetChildClipRect: TRect; protected FAcceptsChildren :boolean; *************** *** 117,120 **** --- 118,122 ---- FManager :TvglInterfaceManager; FClickGetReady :boolean; // set to true when mouse is down, reset to false when mouse goes up (triggers a click), reset to false when mouse moves + FSavedMouseDown :TvglComponent; // events here *************** *** 144,147 **** --- 146,151 ---- function GetComponentType:string; virtual ; abstract ; + procedure Update(const ElapsedTime: Cardinal); virtual; // good for implementing timer etc. + // events procedure DoOnMouseMove(X,Y:integer); virtual ; *************** *** 156,159 **** --- 160,164 ---- property Manager :TvglInterfaceManager read FManager write FManager; property ClientBounds :TRect read GetClientBounds; + property ChildClipRect :TRect read GetChildClipRect; property AcceptsChildren :boolean read FAcceptsChildren; property ComponentType :string read GetComponentType; *************** *** 267,270 **** --- 272,300 ---- end; + TvglTextBox = class(TvglComponent) + private + function GetFont: string; + procedure SetFont(const Value: string); + procedure SetColor(const Value: TColor); + protected + FText :TGLText; + function GetCaption: string; + procedure SetCaption(const Value: string); + function GetComponentType:string; override ; + function GetLines: TStringList; + + procedure LinesOnChange(Sender:TObject); + procedure UpdateBounds; + public + property Lines:TStringList read GetLines; + property Caption:string read GetCaption write SetCaption; + property Font :string read GetFont write SetFont; + property Color :TColor write SetColor; + + constructor Create(aName:string; aOwner:TVGLComponent); + destructor Destroy; override ; + procedure DrawSelf(where:TRect); override ; + end; + TvglMouseCursor = class(TvglComponent) protected *************** *** 293,297 **** FResources :TStringList; FMouseCursor :TvglMouseCursor; ! // these are used to generate onMouseEntry, onMouseExit events NewMouseList, OldMouseList, TempMouseList :TvglObjList; --- 323,329 ---- FResources :TStringList; FMouseCursor :TvglMouseCursor; ! FLeft: integer; ! FTop: integer; ! FWinHandle: HWND; // these are used to generate onMouseEntry, onMouseExit events NewMouseList, OldMouseList, TempMouseList :TvglObjList; *************** *** 307,315 **** property Canvas :TGLCanvas read FCanvas; property Desktop :TvglDesktop read FDesktop; // the root component the VGL uses ! constructor Create(aScreenBounds:TRect); overload; ! constructor Create(aCanvas:TGLCanvas); overload; destructor Destroy; override ; procedure DrawAll; virtual ; --- 339,349 ---- property Canvas :TGLCanvas read FCanvas; property Desktop :TvglDesktop read FDesktop; // the root component the VGL uses + property WinHandle :HWND read FWinHandle write FWinHandle; ! constructor Create(aWinHandle:HWND; aScreenBounds:TRect); overload; ! constructor Create(aWinHandle:HWND; aCanvas:TGLCanvas); overload; destructor Destroy; override ; + procedure Update(Elapsed:Cardinal); procedure DrawAll; virtual ; *************** *** 348,351 **** --- 382,386 ---- FName := aName; FClickGetReady := false; + FSavedMouseDown := nil; if AOwner <> nil then begin *************** *** 385,391 **** if not CompareRect(Bounds,Rect(0,0,0,0)) and Visible then begin ! // setup clipping here for client area if assigned(FOwner) then ! Canvas.SetClipping(FOwner.ClientBounds) else Canvas.CancelClipping; --- 420,426 ---- if not CompareRect(Bounds,Rect(0,0,0,0)) and Visible then begin ! // setup clipping here for the owners ChildClipRect if assigned(FOwner) then ! Canvas.SetClipping(FOwner.ChildClipRect) else Canvas.CancelClipping; *************** *** 403,407 **** begin if assigned(FOwner) then ! Canvas.SetClipping(FOwner.ClientBounds); FChildren[i].Draw; end; --- 438,442 ---- begin if assigned(FOwner) then ! Canvas.SetClipping(FOwner.ChildClipRect); FChildren[i].Draw; end; *************** *** 494,497 **** --- 529,533 ---- // if point X,Y is in child then forward event c := GetComponentAt(X,Y); + FSavedMouseDown := c; if (c <> nil) and (c <> self) then c.DoOnMouseDown(mb, X,Y); *************** *** 512,524 **** procedure TvglComponent.DoOnMouseUp(mb, X, Y: integer); ! var c:TvglComponent; begin // if point X,Y is in child then forward event ! c := GetComponentAt(X,Y); if (c <> nil) and (c <> self) then c.DoOnMouseUp(mb,X,Y); ! if assigned(FOnMouseUp) then OnMouseUp(mb,X,Y); ! if FClickGetReady then begin DoOnMouseClick(X,Y); FClickGetReady := false; --- 548,565 ---- procedure TvglComponent.DoOnMouseUp(mb, X, Y: integer); ! var ! c: TvglComponent; begin // if point X,Y is in child then forward event ! c := FSavedMouseDown; if (c <> nil) and (c <> self) then c.DoOnMouseUp(mb,X,Y); ! if assigned(FOnMouseUp) then ! OnMouseUp(mb,X,Y); ! if FClickGetReady and PointInRect(ScreenBounds, X, Y) then begin + c := GetComponentAt(X, Y); + if (c <> nil) and (c <> Self) then + Exit; DoOnMouseClick(X,Y); FClickGetReady := false; *************** *** 623,626 **** --- 664,684 ---- end; + function TvglComponent.GetChildClipRect: TRect; + begin + // this is formed by fitting the clientbounds into the parents cliprect + if assigned(FOwner) then + Result := FitRectToRect(ClientBounds,FOwner.ChildClipRect) + else Result := ClientBounds; + end; + + procedure TvglComponent.Update(const ElapsedTime: Cardinal); + var + i: Integer; + begin + for i := 0 to FChildren.Count - 1 do + if FChildren[i] <> nil then + FChildren[i].Update(ElapsedTime); + end; + { TvglObjList } *************** *** 640,644 **** { ************************************************************************** } ! constructor TvglInterfaceManager.Create(aScreenBounds:TRect); begin inherited Create; --- 698,702 ---- { ************************************************************************** } ! constructor TvglInterfaceManager.Create(aWinHandle:HWND; aScreenBounds:TRect); begin inherited Create; *************** *** 647,650 **** --- 705,711 ---- OldMouseList := TvglObjList.Create; TempMouseList := TvglObjList.Create; + WinHandle := aWinHandle; + + FLeft := 0; FTop := 0; if FCanvas = nil then *************** *** 660,667 **** end; ! constructor TvglInterfaceManager.Create(aCanvas: TGLCanvas); begin FCanvas := aCanvas; ! Create(Rect(0,0,aCanvas.Width,aCanvas.Height)); end; --- 721,728 ---- end; ! constructor TvglInterfaceManager.Create(aWinHandle:HWND; aCanvas: TGLCanvas); begin FCanvas := aCanvas; ! Create(aWinHandle, Rect(0,0,aCanvas.Width,aCanvas.Height)); end; *************** *** 739,744 **** begin // update the cursor - FMouseCursor.Left := X; - FMouseCursor.Top := Y; // send event --- 800,803 ---- *************** *** 789,792 **** --- 848,867 ---- end; + procedure TvglInterfaceManager.Update(Elapsed: Cardinal); + var x,y:integer; + p:TPoint; + begin + Desktop.Update(Elapsed); + // update mouse cursor position + GetCursorPos(p); + ScreenToClient(WinHandle,p); + x := p.X; y := p.Y; + x := x - FLeft; + y := y - FTop; + if x > FCanvas.Width-1 then x := FCanvas.Width; // window borders + if y > FCanvas.Height then y := FCanvas.Height; + FMouseCursor.Left := x; FMouseCursor.Top := y; + end; + { TvglDesktop } *************** *** 1033,1036 **** --- 1108,1186 ---- begin Result := 'MouseCursor'; + end; + + { TvglTextBox } + + constructor TvglTextBox.Create(aName: string; aOwner: TVGLComponent); + begin + inherited Create(aName,aOwner); + FText := TGLText.Create('Arial'); + FText.Lines.OnChange := LinesOnChange; + end; + + destructor TvglTextBox.Destroy; + begin + FText.Free; + inherited Destroy; + end; + + procedure TvglTextBox.DrawSelf(where: TRect); + begin + inherited DrawSelf(where); + Canvas.DrawText(where.Left,where.Top,FText); + end; + + function TvglTextBox.GetCaption: string; + begin + Result := Lines.Text; + end; + + function TvglTextBox.GetComponentType: string; + begin + Result := 'Label'; + end; + + function TvglTextBox.GetFont: string; + begin + Result := FText.FontName; + end; + + function TvglTextBox.GetLines: TStringList; + begin + Result := FText.Lines; + end; + + procedure TvglTextBox.LinesOnChange(Sender: TObject); + begin + // update bounds + UpdateBounds; + end; + + procedure TvglTextBox.SetCaption(const Value: string); + begin + Lines.Text := Value; + end; + + procedure TvglTextBox.SetColor(const Value: TColor); + begin + FText.SetColor(Value); + end; + + procedure TvglTextBox.SetFont(const Value: string); + begin + FText.FontName := Value; + end; + + procedure TvglTextBox.UpdateBounds; + var + i:integer; + longest:integer; + begin + // locate longest line + longest := 0; + for i := 0 to FText.Lines.Count-1 do + if FText.Width[i] > longest then longest := FText.Width[i]; + Width := longest; + Height := FText.Lines.Count*FText.QT.GridSquareHeight; end; |
From: Michael H. <mh...@us...> - 2000-12-11 19:15:15
|
Update of /cvsroot/pythianproject/Prototypes/GLCanvas In directory slayer.i.sourceforge.net:/tmp/cvs-serv2707/GLCanvas Modified Files: QuadTextUnit.pas glCanvas.pas Log Message: vgl update: scrollbars etc. -mike Index: QuadTextUnit.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/QuadTextUnit.pas,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** QuadTextUnit.pas 2000/12/09 19:52:04 1.4 --- QuadTextUnit.pas 2000/12/11 19:15:11 1.5 *************** *** 52,55 **** --- 52,64 ---- 12, 5, 7, 2, 8, 8, 2, 2, 4, 4, 12, 15, 15); + VINERHAND_WIDTHS :TQuadTextWidthsArray = ( + 14, 11, 10, 12, 10, 10, 8, 13, 7, 8, 14, 11, + 20, 20, 20, 20, 20, 20, 20, 11, 10, 10, 16, 10, + 10, 10, 8, 8, 8, 8, 8, 5, 8, 8, 2, 3, + 8, 2, 12, 8, 8, 8, 8, 5, 8, 5, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 4, 6, 7, 2, 2, 3, 3, 2, 13, 14, + 12, 5, 7, 2, 8, 8, 2, 2, 4, 4, 12, 15, + 15); type TQuadText = record Index: glCanvas.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/glCanvas.pas,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** glCanvas.pas 2000/12/09 19:52:04 1.9 --- glCanvas.pas 2000/12/11 19:15:12 1.10 *************** *** 5,9 **** { GLCanvas } { } ! { Copyright (c) 1999 The Pythian Project } { } {*******************************************************} --- 5,9 ---- { GLCanvas } { } ! { Copyright (c) 2000- The Pythian Project } { } {*******************************************************} *************** *** 84,88 **** GLCANVAS_BMP_TEXTURED = 2; ! GLC_MAXFONTS = 4; GLC_MAXTEXIDS = 256; --- 84,88 ---- GLCANVAS_BMP_TEXTURED = 2; ! GLC_MAXFONTS = 5; GLC_MAXTEXIDS = 256; *************** *** 122,125 **** --- 122,129 ---- FileName: 'Arial Grid.bmp'; FontType: GLCANVAS_TEXT_QUADTEXT; + ), + (Name: 'VinerHand ITC'; + FileName: 'VinerHand ITC Grid.bmp'; + FontType: GLCANVAS_TEXT_QUADTEXT; ) ); *************** *** 800,804 **** result := ARIAL_WIDTHS else if UpperCase(f.Name) = 'COURIER NEW' then ! Result := COURIERNEW_WIDTHS; end; --- 804,810 ---- result := ARIAL_WIDTHS else if UpperCase(f.Name) = 'COURIER NEW' then ! Result := COURIERNEW_WIDTHS ! else if UpperCase(f.Name) = 'VINERHAND ITC' then ! Result := VINERHAND_WIDTHS; end; |
From: Michael H. <mh...@us...> - 2000-12-09 22:13:41
|
Update of /cvsroot/pythianproject/Prototypes/GUISystem In directory slayer.i.sourceforge.net:/tmp/cvs-serv836/GUISystem Modified Files: StartupForm.pas skin1.png vglClasses.pas Log Message: GUI system update : now has mouse cursor fixed clipping/window size bug clipping test -mike Index: StartupForm.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/StartupForm.pas,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** StartupForm.pas 2000/12/09 19:52:04 1.2 --- StartupForm.pas 2000/12/09 22:13:38 1.3 *************** *** 3,6 **** --- 3,8 ---- interface + { bug: Doesn't work in fullscreen mode - probably because of fault in GLForms } + uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, *************** *** 18,21 **** --- 20,25 ---- Button :TvglButton; Panel1:TvglPanel; + + ClipTestP1,ClipTestP2,ClipTestP3,ClipTestP4 :TvglPanel; public { Public declarations } *************** *** 33,36 **** --- 37,42 ---- procedure Panel1OnMouseExit(Sender:TObject); procedure ButtonOnclick(Sender:TObject); + + procedure go; end; *************** *** 48,102 **** procedure TfrmStartup.GoButtonClick(Sender: TObject); begin ! GLForm := TGLForm.Create; ! GLForm.FullScreen := false; ! GLForm.SetBounds(0,0,640,480); ! GLForm.Caption := 'VGL Demo 1'; ! GLForm.OnPaint := GLFormPaint; ! GLForm.OnKeyPress := GLKeypress; ! GLForm.OnMouseButton := GLMousebutton; ! GLForm.OnMouseMove := GLMouseMove; ! ! // run the program ! GLForm.Open; ! ! FontsDirectory := '..\GLCanvas\'; ! GLC := TGLCanvas.Create(634,455); // must take into account window borders ! Wallpaper := TGLBitmap.Create; ! Wallpaper.LoadFromBitmap('..\GLCanvas\scene.png'); ! ! InterfaceManager := TvglInterfaceManager.Create(Rect(0,0,634,455)); ! ! // create test components ! Panel1 := TvglPanel.Create('Panel1',InterfaceManager.Desktop); ! Panel1.Bounds := Rect(50,50,250,250); ! Panel1.Textured := true; ! Panel1.OnMouseDown := Panel1OnMouseDown; ! Panel1.OnMouseEntry := Panel1OnMouseEntry; ! Panel1.OnMouseExit := Panel1OnMouseExit; ! ! c := TvglPanel.Create('Panel2',Panel1); ! TvglPanel(c).Color := clYellow; ! TvglPanel(c).Textured := false; ! c.Top := 0; c.Left := 30; // this shows a panel being clipped to its owner ! c.Width := 50; c.Height := 50; ! ! Image1 := TvglImage.Create('Image1',InterfaceManager.Desktop); ! Image1.LoadImage('olog.png'); ! Image1.Bounds := Rect(500,20,0,0); ! ! Button := TvglButton.Create('Button',Panel1); ! Button.Caption := 'hide image'; ! Button.Bounds := Rect(10,60,0,0); ! Button.OnClick := ButtonOnClick; ! ! Hide; ! GLForm.Run; ! ! // clear up ! GLForm.Close; ! GLForm.Free; ! InterfaceManager.Free; ! ! Close; end; --- 54,58 ---- procedure TfrmStartup.GoButtonClick(Sender: TObject); begin ! Go; end; *************** *** 154,157 **** --- 110,189 ---- if Image1.Visible then Button.Caption := 'hide image' else Button.Caption := 'show image'; + end; + + procedure TfrmStartup.go; + begin + GLForm := TGLForm.Create; + GLForm.FullScreen := false; + //GLForm.SetBounds(0,0,800,600); + GLForm.SetBounds(0,0,640,480); + GLForm.Caption := 'VGL Demo 1'; + GLForm.OnPaint := GLFormPaint; + GLForm.OnKeyPress := GLKeypress; + GLForm.OnMouseButton := GLMousebutton; + GLForm.OnMouseMove := GLMouseMove; + + // run the program + GLForm.Open; + + FontsDirectory := '..\GLCanvas\'; + if not GLForm.FullScreen then + GLC := TGLCanvas.Create(GLForm.Width-6,GLForm.Height-25) // must take into account window borders + else GLC := TGLCanvas.Create(638,480); + Wallpaper := TGLBitmap.Create; + Wallpaper.LoadFromBitmap('..\GLCanvas\scene.png'); + + //##InterfaceManager := TvglInterfaceManager.Create(Rect(0,0,634,455)); + InterfaceManager := TvglInterfaceManager.Create(GLC); + + // create test components + Panel1 := TvglPanel.Create('Panel1',InterfaceManager.Desktop); + Panel1.Bounds := Rect(50,50,250,250); + Panel1.Textured := true; + Panel1.OnMouseDown := Panel1OnMouseDown; + Panel1.OnMouseEntry := Panel1OnMouseEntry; + Panel1.OnMouseExit := Panel1OnMouseExit; + + c := TvglPanel.Create('Panel2',Panel1); + TvglPanel(c).Color := clYellow; + TvglPanel(c).Textured := false; + c.Top := 0; c.Left := 30; // this shows a panel being clipped to its owner + c.Width := 50; c.Height := 50; + + Image1 := TvglImage.Create('Image1',InterfaceManager.Desktop); + Image1.LoadImage('olog.png'); + Image1.Bounds := Rect(500,20,0,0); + + Button := TvglButton.Create('Button',Panel1); + Button.Caption := 'hide image'; + Button.Bounds := Rect(10,60,0,0); + Button.OnClick := ButtonOnClick; + + // now for clipping test panels + ClipTestP1 := TvglPanel.Create('ClipTest1',InterfaceManager.Desktop); + ClipTestp1.Color := clRed; + ClipTestp1.Bounds := Rect(270,290,580,450); + ClipTestP4 := TvglPanel.Create('ClipTest4',ClipTestP1); + ClipTestP4.Textured := true; + ClipTestP4.Bounds := Rect(80,80,150,150); + ClipTestP2 := TvglPanel.Create('ClipTest2',ClipTestP1); + ClipTestP2.Color := clBlue; + ClipTestP2.Bounds := Rect(10,10,100,100); + ClipTestP3 := TvglPanel.Create('ClipTest3',ClipTestP2); + ClipTestP3.Color := clGreen; + ClipTestP3.Bounds := Rect(-60,-60,60,60); + + + Hide; + ShowCursor(false); + GLForm.Run; + ShowCursor(true); + + // clear up + GLForm.Close; + GLForm.Free; + InterfaceManager.Free; + + Close; end; Index: skin1.png =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/skin1.png,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 Binary files /tmp/cvsOiSEKO and /tmp/cvsqMB82s differ Index: vglClasses.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/vglClasses.pas,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** vglClasses.pas 2000/12/09 19:52:04 1.2 --- vglClasses.pas 2000/12/09 22:13:38 1.3 *************** *** 77,80 **** --- 77,81 ---- VGL_SKINRECT_BACKGROUND :TRect = (Left:0;Top:48;Right:131;Bottom:172); VGL_SKINRECT_BUTTON :TRect = (Left:0;Top:0;Right:150;Bottom:45); + VGL_SKINRECT_MOUSECURSOR :TRect = (Left:0;Top:172;Right:32;Bottom:204); type *************** *** 101,112 **** TVGLMouseButtonEvent = procedure(mb,x,y:integer) of object; TVGLMouseMoveEvent = procedure(x,y:integer) of object; // an abstract class from which other components are derived TvglComponent = class(TvglBase) private ! function GetLeft: integer; ! function GetTop: integer; ! procedure SetLeft(const Value: integer); ! procedure SetTop(const Value: integer); protected FAcceptsChildren :boolean; --- 102,111 ---- TVGLMouseButtonEvent = procedure(mb,x,y:integer) of object; TVGLMouseMoveEvent = procedure(x,y:integer) of object; + TVGLChildEvent = procedure(Child:TvglComponent) of object; // an abstract class from which other components are derived TvglComponent = class(TvglBase) private ! procedure SetOwner(const Value: TvglComponent); protected FAcceptsChildren :boolean; *************** *** 124,127 **** --- 123,127 ---- FOnMouseMove :TVGLMouseMoveEvent; FOnMouseEntry,FOnMouseExit,FOnMouseClick :TNotifyEvent; + FOnChildAdd:TVGLChildEvent; FVisible :boolean; *************** *** 137,140 **** --- 137,144 ---- function GetHeight: integer; virtual ; procedure SetHeight(const Value: integer); virtual ; + function GetLeft: integer; + function GetTop: integer; + procedure SetLeft(const Value: integer); + procedure SetTop(const Value: integer); function GetClientBounds: TRect; virtual ; function GetComponentType:string; virtual ; abstract ; *************** *** 148,152 **** procedure DoOnMouseClick(x,y:integer); virtual ; public ! property Owner :TvglComponent read FOwner; property Canvas :TGLCanvas read FCanvas write FCanvas; property Manager :TvglInterfaceManager read FManager write FManager; --- 152,156 ---- procedure DoOnMouseClick(x,y:integer); virtual ; public ! property Owner :TvglComponent read FOwner write SetOwner; property Canvas :TGLCanvas read FCanvas write FCanvas; property Manager :TvglInterfaceManager read FManager write FManager; *************** *** 189,192 **** --- 193,197 ---- property OnMouseExit :TNotifyEvent read FOnMouseExit write FOnMouseExit; property OnClick :TNotifyEvent read FOnMouseClick write FOnMouseClick; + property OnChildAdd :TVGLChildEvent read FOnChildAdd write FOnChildAdd; end; *************** *** 262,265 **** --- 267,280 ---- end; + TvglMouseCursor = class(TvglComponent) + protected + FImage :TGLBitmap; + function GetComponentType:string; override ; + public + constructor Create(aName:string; aOwner:TvglComponent); + + procedure DrawSelf(where:TRect); override ; + end; + { ********************************************************************** } { Interface Manager } *************** *** 277,280 **** --- 292,296 ---- FCanvas: TGLCanvas; FResources :TStringList; + FMouseCursor :TvglMouseCursor; // these are used to generate onMouseEntry, onMouseExit events *************** *** 292,296 **** property Desktop :TvglDesktop read FDesktop; // the root component the VGL uses ! constructor Create(aScreenBounds:TRect); destructor Destroy; override ; --- 308,313 ---- property Desktop :TvglDesktop read FDesktop; // the root component the VGL uses ! constructor Create(aScreenBounds:TRect); overload; ! constructor Create(aCanvas:TGLCanvas); overload; destructor Destroy; override ; *************** *** 323,326 **** --- 340,344 ---- if not AcceptsChildren then raise EVGLException.Create('TvglComponent.AddChild: Adding children to this component is not allowed'); Result := FChildren.Add(child); + if assigned(FOnChildAdd) then OnChildAdd(child); end; *************** *** 345,348 **** --- 363,368 ---- FOnMouseExit := nil; FOnMouseMove := nil; + FOnMouseClick := nil; + FOnChildAdd := nil; FChildren := TvglObjList.Create; *************** *** 517,526 **** var r:TRect; begin ! // get the parents rect and add ! if assigned(Owner) then r := Owner.ClientBounds ! else r := Manager.ScreenBounds; ! ! Result := Rect(r.left+Bounds.Left,r.Top+Bounds.Top,r.left+Bounds.Left+Width,r.Top+Bounds.Top+Height); end; --- 537,549 ---- var r:TRect; begin ! // get the parents rect and add, thanks to kk here for reformatting ! if Assigned(Owner) then r := Owner.ClientBounds ! else ! r := Manager.ScreenBounds; ! Result := Rect(r.left + Bounds.Left, ! r.Top + Bounds.Top, ! r.left + Bounds.Left + Width, ! r.Top + Bounds.Top + Height); end; *************** *** 592,595 **** --- 615,626 ---- end; + procedure TvglComponent.SetOwner(const Value: TvglComponent); + begin + // remove from old owner + FOwner.RemoveChild(self); + FOwner := Value; + if assigned(Fowner) then Fowner.AddChild(self); + end; + { TvglObjList } *************** *** 616,621 **** OldMouseList := TvglObjList.Create; TempMouseList := TvglObjList.Create; ! ! FCanvas := TGLCanvas.Create(aScreenBounds.Right-aScreenBounds.left,aScreenBounds.Bottom-aScreenBounds.Top); FResources := TStringList.Create; // build the desktop now --- 647,653 ---- OldMouseList := TvglObjList.Create; TempMouseList := TvglObjList.Create; ! ! if FCanvas = nil then ! FCanvas := TGLCanvas.Create(aScreenBounds.Right-aScreenBounds.left,aScreenBounds.Bottom-aScreenBounds.Top); FResources := TStringList.Create; // build the desktop now *************** *** 624,627 **** --- 656,667 ---- FDesktop.Canvas := Canvas; FDesktop.Manager := Self; + + FMouseCursor := TvglMouseCursor.Create('MouseCursor',Desktop); + end; + + constructor TvglInterfaceManager.Create(aCanvas: TGLCanvas); + begin + FCanvas := aCanvas; + Create(Rect(0,0,aCanvas.Width,aCanvas.Height)); end; *************** *** 644,647 **** --- 684,688 ---- Canvas.InitMatrix; FDesktop.Draw; + FMouseCursor.Draw; end; *************** *** 697,700 **** --- 738,746 ---- t:integer; begin + // update the cursor + FMouseCursor.Left := X; + FMouseCursor.Top := Y; + + // send event Desktop.DoOnMouseMove(X,Y); *************** *** 824,828 **** begin Result := inherited GetClientBounds; - Result.Top := Result.Top+10; end; --- 870,873 ---- *************** *** 969,972 **** --- 1014,1036 ---- begin FCaptionText.Text := Value; + end; + + { TvglMouseCursor } + + constructor TvglMouseCursor.Create(aName: string; aOwner: TvglComponent); + begin + inherited Create(aName,aOwner); + FImage := TGLBitmap(Manager.GetResource(VGL_SKIN_1)); + end; + + procedure TvglMouseCursor.DrawSelf(where: TRect); + begin + inherited DrawSelf(where); + Canvas.DrawBitmapSubRect(where.Left,where.Top,VGL_SKINRECT_MOUSECURSOR,FImage); + end; + + function TvglMouseCursor.GetComponentType: string; + begin + Result := 'MouseCursor'; end; |
From: Michael H. <mh...@us...> - 2000-12-09 20:22:28
|
Update of /cvsroot/pythianproject/Prototypes/GLCanvas In directory slayer.i.sourceforge.net:/tmp/cvs-serv21625 Removed Files: fixed.bmf Log Message: removed fixed.bmf GLF bitmapped font file -mike --- fixed.bmf DELETED --- |
From: Michael H. <mh...@us...> - 2000-12-09 20:18:07
|
Update of /cvsroot/pythianproject/Prototypes/GUISystem In directory slayer.i.sourceforge.net:/tmp/cvs-serv20894 Added Files: olog.png Log Message: no message --- NEW FILE --- PNG -×L ("AEE×ÕÝÅ´kØÃ>]º«OÑuÁQa30¹§s¬®nÝÞïÖì¾õ½úæë¯§úÖ½çüÃ/{n»÷îjµÍV#JÁ²,A©º!·. ų.áDñp$èRd>_°;S«j2 rÝ#)]×ñf2K¤SG¹ayvÿêU J}üäT2Vz±ïíí.J]]C¡`x|êÜú «/Ù»ûôéÓ³çDŦ,/ÎD"ÒÎëO9yâX£Ñì_£´M×%*B4.z G ÍG<+Ôê¶^ï駺2å5·°ë/-Ï·r,Û²qã¸GS}ÃØæz½~æÔéh,x-L¢D¦Ò¬"`yµåÒ$!p,7m§(:(Úk7[ÃpW«¶ñ,·ygºÑª¤eR ñÅ ÇqZ$I´ZP0"¢©x§Ú¨Ó4-¢¢(´c;±x<U*v(D)î2-ÛrmÛójÍz©\r<' çzûʵZ«-óãYö-¥Vo$ÓÝÔ²Ý]vãOOþIÕÔÑQUפHè¢5kh% 78rsiy¦ÝÐ-K[©©³Ë$Aò]åëX$é¶Z½qlÀ´\f1Iç,Û¤HR7ÔB¾há}GRw=R¢¸´ã}}½¡pxvnnyyÙv¤ã±x04Lݶu^diÆ5mË2¢ÛrN%c$ź6Ís'Ò$ÍQÀß Ë4ëͺ¡éÜV)Âi[rËó\¦d¹U«×ºº7«^«6uÏu-Ó6eYÓ4ÂÃ$IÙ¦E14ÆÓá` a%1(ðC71 Á0X,ËñÈ <h+× Z#Ë]´vLò²&Ó<KfÂñèÈêÕåZ¹.Wr=µëÖ¸qêô¹³ãç5£ÅÒäé'gg¦9òSØ®tJUT&{H×X\%<ǵçIMEIÄÃÀÛºmê~!¤© HÅ3H{,ci:XÒ4ÓÃTaÁxæuËËvggç§tC£Yå9I ÒC¾á b5«i$Ï´L1òHbxÕªX"n:®¬è¶Cªp4¦Èmpè) éÈÃçâñøÀ`?Ëqr»å¸n íh,ê"QÀ1,Ë$?Q($Zq'ý2qá'*Þ´q£®+èôN" iÊ% ÍХ¢Kºt26ÛMÝ2(i´UçÚÓ-£ÄÕusüüx&@àJå¢çétFàÃøÅÐÌAii}=½ÙTªZ.GQãà@?*£éD4Ú¬6åf¢µÝâY:Á4=IÖª%Ë0hiµÚC0,Æp*×sR Ý/¬¨º* ¢¸z$èAUB'²ÃÒ²bIбXéeÚèËD¸,Ó ã¸T¹Ò 6i:òÓiè.ªÆ´Lró¦uKPLeÚmuq9_kÔr}].ax*>9=cX¸¤'ªõº`QµJ°7<²>ë®VKÅÒ2ª ÂÑ4-c>îq¦å¨[[Ü9L¤Q¬ @ªÚZ³aжÍJYF¹ÇbI¶Q¯ÑxªV«QoA%[\.±4Gz{úC¡p©ZÑu-Nz{q)à£øl$êÇØò++§Ï'ÓºJ L$cHUÕ)J%Ò½½½^Àå&µR*HÇB¾3é>^6ê-À¤A½Q±1q¨)¡ X=Móºª(¡HívË´h4¬¶LW*× ²Â¥UUADÑ#cÃûÀAI±X\QÔf+++´©é¡PHmµV WëéX8(p(7× Úõ6CChÕZ¹$7*Ùlfóúõ Öññ3PplTk.$=ÌeºÒéd¹¸Ð%¥)¥àº5kkåR(9'Ù¦Ç|<°t»Uoq´âà6ÃS)\K%£¡¦PÚZ[@Hé²j讪©Xª/×§´dµÝΦ2`ÉñsÝÌ@o¯¥>ré¡¶YìïîEUÕÊU¥ ÉIEA¨ ´3;==1y~õèh& ér£p,ÆFW!7 ¸®tÆÒMfÂRÄPµÙ¹H0Nü@Ï0és3ó=¹îÞÞZµ*òÌä3Ѹ$7ë'NãX¼ÄuÅ ¡ó'&~dx¤TÈ~ùÌâÔ"Á@aÂa=rq~õä(0+ ÅE1mh¨ U{zrÕJEäy`È !C+:¶\ÇÃxÉEÇxÝjÕCa>â5µeÛDobâÚàÐGgD#Qtè¡;×24vX"*ÙÛjí48Ø ùxÃõ×\ý5ǽ_öÐ`Rnå£À _ÉVâ© ìS4\ÿ2-èdÛGór½ÑjÕD x ìW^ölÓà6kmÏv!+ÀKh jyeqéL¶È±6ÏÁ¨m-%ÅüÂÂùj¥N¦mÃ]èÎöi²©iúW]98>~¸É&"I CR¤¡ËRcõ#orSº@@y.X½^J¥Â3³SIíÚµ³§773333|@¤)ÖÐ!áIÈ68^4¶ M!»($ªb!®¬,CÆ+e¼æfÐôk¥R ÂuÏ <ÕCàã u&é50b`G1dY5ºsñ[Sâ¡ßýoè¤A¸ °ùÂ,ÇQ07<\)¬°Ë^ÿ`¢4=®Ö²¬Ì/̪z¶`rr¡Z©z¡§ú»ñ`"&N;]ÌuÅÖduÃ2T»´5ÍPV£}L$2,Ún" jb êÀ,ÃùÒ àä]¨QÓ`YHáYÝháé]J_®--ósÕ« Ãz^¤Vñ*%MõÜÓg7o8öì3¯F¢I²BWV¹c¬Cè$ÓDϯãl0$rxZ(¦á(úÖ%°±$ÜßߥCRF¢çU[4«aåEZ\æ,%ôïÞ××7´qýèEõ.ÎáÒÆÏ=·aó |}rò|_oaÜW^ܺ·ÑÓÝï9\~±& äÝ>ü7ïþýG!Kp<uæÜñz32Þ³gòP¢*^QÃ?6ºEm[¯¾|òÌã{öy0F+ JipµV=ë\é(8ÃqPK0<¡éð$º¢..-/JÐ| AN8ð° Åbqü¢W¸dtÇ ¡Hr`>,çC!J×Ë B xEÅ hT×Ý?{¸PPÜß|ôæLWL7¼W_>ûÄ£¼ôoØÿÆÍáX¯7<Õ¿yóE v&d¥nÙhT)(×O;rè5Ê ;°Y6Á² XÂvô?>þÈå~ð;ßù(?ý8tø¡×_ÿÕÎ]k!^MµF}&ÝÔ=hµe&$2iË%ÕZ6C¬j¾þ¬ªë¬¬TXÆæXÉ5ìT4YZiõöúz)JaÝtl[òÜ`.××HÊáöbXQfÒ¹å|¨BRÐG p²Li+ ½g«ª®dº´@oß³caf!<¶ÛÅ öÚñsÿþã»oû¿üÅÿùÚ׿;Ð×û©Ïüa TUÚΦµë53á:$Z³»»iÑxá¹ą̃ͮ¦®}ÇÛ8©on©.æª ÂÊ&|=â,Æ´eÙ¬;- ¸hÍð£<j[m<ä¦AÌÍ-¦Óñ`h7ÿhø ±f}ÁxØÄ )p]þ¼Znôöå DcPÙ´mûr~%ÛÕÜÎBôÙêØEkóù¸ïÑ«µªâ¹5ÓÔ)Ò£ýûPá£Ç^]5°Zn©SÓl@`T~¹ðÇ'ùeºVÙ±û¢ýû·@Wé[«ËÉf(þôcw|û{>+Q N<(A¹ ù¢¡{·æ|±ækÕH(¬ª:ì[µÒ´LgíÚx¶ÖX¾çî?ö«¶ï\ó§'7¨FÅE%Â~Û35=oy1ðPÃáP&ëÔ[Két¢Z fhn~Qã«óµÓÕÛ3:4m¿½IRÀs !h ©8¡E×2)ÛÂØ6,eÐ4¦hÛ.ÏC\Ê\)æ»{{jU9^8¦$éש$mWD"HwgGN9iÛV6Êkg{ IÔ4È!á¡)aìá¡Ô ,Ïà º¯Yã©ÁZÙ Âðq±DCåÒP¼À ¬ª¦®^+ré©E¯áôö4"¡t N"µû/¹xz¾s¦Sòd£¤ßÒ* ¶cCÐ`Wçß?üÓ»QQXìº _?ôýH$ÈÚ_°%*Ĺ6#P¢(¢ Ñè-0³bñLYiÇ"¢ÔÎ]»gæfÛдV¸óêêÊâ[·n¥rn²FFES,MZ¦25yzfz<@`ãß ¼h41,ød t&¦¨mÃTHÕ`0Åòn&Îu'vïÙR.--/Íöt§³ÙHO.eZÆòò f °²K1FW.âê.Ûjxé¥ff§ èÓ]AE[KK¸4äÀ¡ÃÏëfM£)\Çøáhh*(,C?þØG©Õ+¦¥R¬g{vÿp¢Ö(Åe5Ô=ª¥9ÆÈ°DK"Írt0ÄQ´¥©.þþjÔ0BirPB×XÒè*' OXT¼)n'þ4Ï `MèlËòñÇG!8âv÷uS,宩D*ÙÓ×µÁÉrã´b±}lÚ´uçÎK*eyxhM.CÑ)ªl[F©T£7l×T'HÙn·ÍÌØêµ¶E÷tg³ÙZ¶zlðþþáõë7òÀ èÿøGÿ®Ùu W sóSÿ¨'HD¶mÝå9üèª ðq¥R'X»nô²K÷ÃÌÎN[H4¥ÕÓ=äXLww/¢ó§?=1¿0HFâðJaytdtñXߨÚ5[wlÞ¼u#(¡hRS]Ý0íûr="- p7uye~.ª¹j`ÔµXسû ͺùö«®O%üe7 Åf½îJ îEÖÁìrA«Ô×_;%°VSÉæâÛwÄ8Ô¼Ü2~}ïãtù/ÌjFb¸RŹ޸qP p̲ͪb@µä,áàáW:-ò ÿ GwwÖsÜýÕ{å)¸6m=;??>7¼j \tµVìëén+uVVpsÝýÕZdød:ñÊ᮹æê@8<¿¸²w×Þj±äÊëG_nԫغ}_&Û{ðÐó8íʤ¥ |r¨QoWkV[^\^G âjÕf±X¦HzÕÈêv[[Y)÷õõs733ãµpfjj®ÕÔ¶nÙ Gip°KVZ :«C<ϼzôúD¤+¯¹"F¥ªët|¤übxÎ1LÒÚÕE#1Iôïòú»Õy¾¯wñI¨*6nܹc;\ö<ñÔSÎæºä¶Ül6<rêô©k®~Ç2W\ñ¦ßüú׸<ÇrGW)4~fÜ2Ìx<æºþZrkdxU2CVÚrÃÐ5üÉ6-\wjrº¯o°¿o BVàó³KjÀ¸Dqph¨Øj«</¡@kÅEÒÔ'O³5}Ê¿O@ºN:d·cDlçÑ%i8Û/pðw$ºÎ{n~Ïûßÿ¾{~~ìwgòCªß*JÛ ;Ç£(<ÛZ³s³ÇÑb$ð¡"¡PçºâiCÖj+ÕɳÏ?÷¢UjÕJ¥Hñ351^.ÚªÝÖl7ýѬ¢ÙmÕ(UjÃA°JAá÷¿øWBïÈùäÊRynrQmèPZ6K'º¢ÁX"Ô½\¬,ÌÏF#¡üò"J'oÙ´¥Qm |a4Tb7#ÙÛ·§ÉD417ªj³¦=}kp` (yÿ{ᤦ¦&1«7ÎÌÌÞyç~øaÛ¶V¯^-à·Tr2]Éjµ«®_^ZÇà-A!¡íÛ·_ñ·¦ÙfÝ Eé.È&E@ (Neà²IBmVgÎxýXw_¯çbÖ- Jo÷Àm_üÒî½»úú34Ç-Ï->ýäSúÓ:tÅß:22òo}Ë_ -à~oO?>ëXÅÑ®¿0CB=?n,)7ÈÆú=;FÖ¯±ô±'×UZ2ªÀDÄ Pg ?(ýÀj>é[åF« a^×½ýmóçÆúÍo 4cÀ°¶ Ø´ÀÿäOþJH0÷ 2t@kPæÈPX$EýMgbçQ Ç l/w^C«æçç??wvüØñWþùûî_þòÛ_|¾PÌã³pèp4w|ûß.¾øâ¯ýëÏ=÷,®»°°Ãw 9 £eX=ºmçÎÉéé^zi|| +¢Dn»í6K0ºeò¢pøÈ?þñ1ø ®lR`¡`X*×ÊÝô®];3Pù4iõz µ û{ûÁ ^±¸ »WÂÜòKþBÞGé¡,Û"²³íTþél±WÐøèú·¼åÍÀ> á¯ýk´rй+>cbÈ0üe]#0ÆúÔg¡¸iÛè ªþ&ød[×xè·c°4 E¨áwüGcñ8"Â2,: (`»wïÆ Ü÷(H:N^5JÏ>ùä®=»1ÍpH´tS@|¯{Çõ@óV«þÚëÇý;Ð$ãßqI_pø7³Èb Þ¯ÕàÄH¥ôè£OMM!yHóªU«?HÛØèêéüR%dÁÀ¢..æú²f6¹N§¯¸üò£/Fâ jªVÈÀåvîÜOuvtù:Â_÷¼É)]Óüb7T0ÒS «ÅþÐ Mµð>B !PÈö÷¬Gã1]Qý(xËt2ÇRôÛtU«ª¨øh,.ÇZZÃBd^°<lyß}÷Vke $Ù£þ'%{úô JâàïÚV'+ެűhæ¡X˱Á£,ºE`uÐÙh«KRè§9ã@ réCåÇåÿüÙSOÿ±T(uÂJìôäÌÔäL,ôàZPä¿« uürᦦ¶oÈÿº¡øÿWÇy]Øq!dg¿:ËS0TÝݹd:º»³Ç^{5JôtL áX5 ¤¶oßg ×%1T_¥ZDCá²ÜBÕ dYgc?Ï,EDZàÉP¶MÛ¾ÌýNÑÿ AÚx²¸_ã /üÝ´\RôJuKBP8<`í Y`*ä "ÀSð¨(í äRçöSbûöí(!êÆI!:Â<ÎP\"Fs![¶¿¿8 B_Pz8Þê¼|EÑ?8Õ½÷Þûä,ÇÝpã;AÅHèBaBÔ 11P1g@+à³333@Ħ Ä@=w×-ù[Ìõë×½õÍWúëÅ ?°ôby~tÈõë×N5-ÿA6G_BSåÅÒëÇ^óßrx`Ð2Gé³@6£#¢¿Ñê¬p¿l ÿ§HfýãFÇF8 ]Î/í ¯ µ]«1 ÀÎd¤H:?qåü #¾árlTêdèoõ¡i @á# ȤөPål×nu6àHZ°P©øOõw6$âMÚßÐðíÜܾò¯T+ÿÓþY½zõà`?tþ ²ÅGGG/¤cì-8 d©º°èÊ@×áwÈA\è422ö²Nà2® X¡;t{¡ þèpî_j"6 4ÛÍ¥%«tQ ÇÃN&3HßùñIÔȾ/®TJP,àÞD, -ÝN))îìf9']Ô( ¤_XÎÖêT:Ñ×Û])ûÐ4@p4ì &:<ûÂS?ÿù=hµ÷¼ç=iתuüõm¿ò IR{wïöl/M¬_»s.k¸ôæ apöîÚ8<ôÀÃPÉ;·ï¨ÁõÖjÀ];÷¨Z¨Q¯»CXÞPÿ3zíɦ2iÉ$UÝA&8tlâÆn^Ȳ?¼óÇ¿+þ«|¬!ÛKÝyeÎÑ$ÛùÆ@%þ/"\ª³*Ó!'°u÷F gç§!¡R+#ôýC=¢ÿyàüäÄÔÌ´ßʱøÆ5ÆVv4bY>×ÓlQUÐQôh¿9]ç Ûõ KÅ¢mZ>Ç:®aèr«eÛ¤$ü]yaûEo/ªúU*£¬PG¼¿K¸À«ï{ßûßòæ+AITU¶°RGB 9ùØc^²ÿÞýû÷9ò2: É;tè8ê]ïz×5kQ¶80¸zlôÿ<ÜÜÇný»_|þÊ+¯h4+ý½L¢gpeeÚÛ~ø¿¿û391^*ã±ØEccûöíG"¨§®L((å2];wì¼dß>õ÷üú×þeõM§NúÁdIHgù#¿8( »vm÷»oºx÷N!7m¸hû¶íûØGoÿêWþå߸ë®ÿíÈ£#£·Ür˵׽¹ôÂÒüÂâ\,éèïëïõ l«YU-.±jlµítî0;G2þ·¥ÜôÏ·ø7dë,ñÂÉ×^"þóIb<sú²úÑ¿½§smµIºþW !8ÕÄÄÄë'CÐ"í¬ÎÏ/^qÅèzó7TE·LX-úç?¿é¼jþʸûüd÷îÝjýü$(Z!£µoz×;wnϤk~iùG{àxVغm3ôÜÛOÑ.À jzêÀçÆÏB# òK.}ÓÞ÷3,d'püÙ3g\ÿ{K·¶I|]VÊÇ^?ñ»GcxAñ·V¸ Ïñ¶lZwëG>¼}ÛFÇäVcyaé©gù÷»þ£ÚlÕ*/ªé,ÍßöÅÛ }½ÉXbÆ0u¸ç!Q uR©ð ®5Á²¢*_yåÕ¹¹àRǦ98¦§§ttòä ((¹ÕÄ'øºñsç>´eóƽû.Ù³w÷äÔ¤ih`FI'ÏÒÄny¯e¨{öìdYÿËQgÏ:|èÈÕcÐ^R Ø¥ù_vdqæô`2Ç"¢Àa%ïïɤ»ªå¿`àëUGÿm¥ñpa¹@GÖ³º³¹ÞW;,mh6¿óÊßѹßY. âÄCñt¹µkÇuÓ2rsphÐqíÎÝMjÍÚµÃC3Ó.àOðoN%Û´i`ËoS¿<úúÀG}Tói¯;ËFR¹ìp,n ¶ ò ·)èY<1ÀYsH@R-ç84ò.{ËMÛ àKýgÓ Ò "@ úýïsY<R.³ØßûßÎ¥ãc#«FçûÒ; fåÀ:pãdcüõtV¡`ð#Áe>åøR$yÞá´7-"/äÃá 5 |ÿÓ¿þW©dÔ¨W߸~Åf3ß»wûÊåKû|¾{ǽÍ/Ì!vw·NO|>rfµR÷2JÈÌÁé¶i$§Ã^*+%Q6§âðÔPTø¢t¾¤øosÊÌgÖSù'¸¼%ÒÁå;½B-ãÄÁ+j`(h0±Di OMÌ¥¯Õë¬TPV+Õ ?2 ÌXÁ}ÀAi~¿×ëÁÖ³YºR¯Ó!_ Ô³719RrVÊNË×èÿ$ëK«ð?ÃõúZ8³\Öîõu¬º/ïÕ ÁèLÀì²FNMeÞJìÊÊ}ø~¥VQë4Ó³Ó¡P¨ÐÅZ-à<«òd&M;Àò9p^à_ú׿| #°"É\* 2©Ýnw»P0~§±Íå¨J9ë§GÕJß ýE KJe©D ȧmß©\· ¯ùAP¬j æÁC@Ca¼³)µCÖ¯\¹üW²ô·¾õuèQûµå+gç!ãêÕr©EîU©iÝØ¢Ó{}±'àåieêðÉÚãï|ç/VîÝ7,õzS£Öf²{CµÚí(CUÅ ó@-dñ'»Qðd_ü]¢þÑR¦´¹·/U¨ÁD\Óá±&rõ§o.+4Þ`1OO@ét´LîõùlG<¼uç>¨ " zÐö¼ÃL0´ZãPrÿoKîAÿ"pÍv·\©ÈVßüÊMA!ò}:ÐÆlvnföúµk`Û»;¾43L ò+-ÿ³ÀD6³eùÊÕ füâ#¹ÃfkK-_ápL à%2èõ-A¿¯Þ¨gSiD),ÖAÅ~*5 ])sv ñu°¿_oT!0j¸}ÀU j5Úéé4É,5-r ^¸]¥\O%Ê Üþþ»±cPÏÂòµåZ«asºd*u¿ÕÔtëw>"6z̪Õñx»Ñª*AÏÆÆ%FY®ÕRÿ-°Rø´L®æh¾AÖª«ú8¡§¡}[NWÔªáæHH ^Mõz4ɦ3}à¾LD´ØAuMB_ÐõVùæW^M3¥jirvY÷Öí[GÉZ«Mg±8.ÊÏ>ü +ô®\]Æ0@<z²íâQ!¿~ãÆaôîoì½÷séÅËÀt@ e(àGÂýÁÄ.ͽt[à 0ÉT«åùù9ܦJ¥bSÇb1 ?x¢Ä@ôK"K«ÆÀMF¥RI§#! ^¡¹åH¬ik{»UoÀåãÔ©UÿåÿþÓÛ Dþ nú#a/DÕ¿n ï?¸ïìk6¥bd(t¼¿·ñäVËK³Í14<233s?AG3ŰNÔiÙb±¥Rk¹6/HÕyð±@ìjÚ\G´Ì²*£Ê>¤¶à4×PH 5 p ë3r`|_!«·¸¡±p¶ëÉÄ©¹©`nnÔ:nA ÃÓ-..®on`4÷îß¿_¯Ö&¨¹Éj ½ùöÛQã"Xb/3K_8DÀ ¿ 9ã¡÷ ò Ë@祼WhÚ$Nö@²<¼É`PkTíV³'ö¡0¶^)û½ÎoÿöoXìôìglVئË#Ù@þÏÿéÝr1çv:ÇÇÆ×lÄ-ÿøüY$°;±A:îçóE¹\Ýh´òU^E;He)iÇbÐ!ßBpé´ÔdLK«ÊF£)Yð^~òPõäë!²hq[+ócS£Vu}c½T."!sON@ÅhÃL.kµÚè¿òÎ;'ÍàA9 ,÷{;6·î Ó¤Ê-PfñÙ3:½ OÀC¡p!÷z<6ÌZDþn$½NkÒôTnÅ#"¦¤`¬Ä0j>Âó@°{¿/xxxLä@£jår¹Áåv´u£AÇÈÿá÷ÿÔ¦JÑÛÙÚt;,8A±T>sZ ßé·îÝðð°KÚ«º{ehdD«c©ÔîÎÅbbäre<¦¢¹° ÍÆ¡däHjÕjÖjäo¥JA--ú"n ¥ ¥o|ã.§;b|ÁÙ777FGGKÃÃC -xeÇa: "6A`ôú¸-Ëí¦î¼ %ÌjfaýÈXTþVÏe2££C°þúãÃÈjü^÷ãµGKW¯Ú¡Ñphg{{|z¶[.)I®ÈMÓ'¼Båtzr¹R¥ÖÚØÞÿý¶¶w <ZkPJïAÆ÷úòl¦Úíôiá·Oΰ³P8O¤À÷ujÂZÙ;ÍØd]~;¥6c=aø+µúUÊêm±ùö%/NɧªÍÚù^¿jèy>Ïïïà'ÜJ»Íuô:=ôÏëS«4Ènö©6ÃccO=ÿl½Ù'Sf:ÂBq||ÂDÎSɦß:J%Yëû{{0^¬UëÉdBGe£ ïdN+ý0±4S¤@QÄ`² Úm@sbôf_Öbµ04« ðx&4M®V«ÕT&}åʻݱººê´Ù<^o4/תxAE9.+@ygýøGv¨ªR %Üô6;éÞÝ»±h¼ÓáRé4tÃé8:94@;Ë!Í#jaf"©ÃÿÑ6LFU)W 'éPd?=ü÷¿ÿûÞ?³´h1¶¶Öº~µX(lîl±Óåf6Ò§a£®äò:íýøRúÞþÙbçùÑï·©%UB ÷äÉ×îPm:Ài5 ®Ó=;?»¶±<G\HÎ o³Ù·ÿ»¯@µãN$ÄÙ¥3zÞb6CþI«+VÜ9`g||:eôR]x¶oôO+Åñ:²:B)Ï4==CÝao< !ùíßûõõ'¯¿òrkvA|L3ÓSv+NÛNyo@]A¡VìlWRV£NgÌfØo卑: Li¾¿ZS¸=~ª¾2Ö+dc½½}¸¯bT´c£Æ¥b8¾Z£À9AB'¥â5@~ç@9èðrµtáâ9½"X¥QÇ1d`µZsAÙѤ٠S;av~þøäøàà º³snõÙÝÙ4juæÆ bÆMa5t6z}í H}1W¿»\n¸^¯÷ù¼°3ih ¹âøøâF©D¶ PCCCHð¾ôÁf³"N5jfnzjq~Ïî´[ÚõÕbJ%Á¿^«òõ+Ñ(ôЦËuÛ´LÀCYZ:<8SÙ¶¿ÿÞ÷oß¹GE´ÆB¾¨æª J¥F¡Ay±tÞÛAmA^u¹xÓ§íÒzj¦¨Ñ¥Tc½~¯+zÛõ+ÍæÒù¥×Ìru®a¶f[íetl j*ûN6CdonnÑq^ÍÞÞÝööN©\ËH{Zv+åb¾×¬Öj|O·8ì -So×Yë>t;uZ]6Q÷1ðût&;91n0CÔQÊït:©)^©VzáÂ\srr)oõñpøÑѱñ ä"ÅÌeryÚZA° c ÙzªÕ ôÿ¾ÂPQ¡aP²{ûûvóÊS×ø~hD»»%óÂ/¿^*C±ÅBâpltüøè^sBaðéi®Ë!ð¡§qÇ90mª?à @0àñ¸ ÅBï\¼tÉj%Ù .Ô°;\¥Bî¹å+\j4èæçNÈÂñÉúF©Xäs ÑÑÑýÃ#0?Nì=|ô0Â<2'mªûÑãèý{÷Wî=¸{çn£ZFãZ¶2²jEæó8+>H¥N B60´:=°ÀáºôN£¥ygQ3¤`zA.Ò´ ¯Nyå©KZùáÇNC 6ûA]ó w°ïÊû.£T.nïlÍÌÌ ¼;89²¸ì#ã#ÐÇÈ%HíPZÌKß|ëÊÕePf½ä úøðJ ^z«TæK;`&À:40¢¸d¦#õè×"gJÕÈ»Ý&mÚ>ÿônôäÐÀ²o¿ýÖÝÛ·~÷·~sûÉêkËåJytltogg||üäºTô*ÏÂØUëuÄÐÈØh0ìpmÅÏñ 3íäWAÍk5tò4ͲT*²áÁ´ºº tc` Bþô°¤LÔëW©ÏREÝÂNº]¡O¿\©Q.Ãñ¼ÑÂÂ!PÜa«Õ:#a, n¡ ÁúÅRz.NãHû.$K¥¢5¦i¸ÖôÌÞ?91jµ nç¥^@6Ë&Àî]¾O£×Åâq0¿x,þæßü!zÀ¬Ýn7L¯¤ÅfÎpõÊ{÷îïííB¿óÎ;¬JÛEÚÚEÅX²ñÑ1ðn»Ý?9Id´'D¿ZINÒétRË$:gJ Ï(¨_:\-W©º¨7 ¨h-÷hjO=wfÉêM¥ºBP6óæ¿ü¼Jh: ~ïÎ:ç»ÛqÏ=J§\Nw¡PÐz<J¥i4?Â:Uðÿ÷×xäX§Ãn1æç¦ëõò£{}VÁ1ºÑxlv~áÁêCÕöÑY©Ì Närdu Ja°Z|ûêµ+åZe ×å><:Ü|².`¨²L* ¿³Ó å`úóóóûûû:ÇKíÕ[ͶÏçÕ¨5[Û[Ýçv;¡¥Y&ä÷Õêe®Õ úc£#¸!9£XXXB´Ì-ÏgR~_`ssý©§fõº½ý=ìPí=ü)g}s}rbÄcsksii pËuÇi'¡Õ¾rÿ1ÁdRѹ"}F¦RSõ9@«WÒRïºBrQ£DµL·ÏõùÂÓ¥Z ¿Û\¶v·¢mÒH£IOKÍiðìlZ,õ«_ÝÞÞ>>>ÿüóZ©½ÒôôÌþéæü9VZî.«TpªÖj §Ýjn5Hß x¼Í,COÀÉèü¬8 )Fÿâ¯Gѱáá¡ô8rÑÂü"r8XS&ù^ÃOúׯ_Íf2à¦F ½Uo ~Ç'Æa`Øñþèð¥ÔOk~¹Q©K¥Î@ÞSÐü¾?.'ð=¥¤§(Jnô'HÌ1rdV=vïó±È2[ÍõVkkk½%-ndïð(D 5:m&ûþ÷¿ÛÆàà+µhÛÞÞY}RwU%ÀÇçóA¯JK1È&Üa&fJàE\·ü?¦JÍOj0©ÓnÍå/ßTHýN»´ÛÛÙ-ÐiPRðß.ÕS#)¯wl||jzIüñÚb4vk©úC ¤ ibQiàûyHÎ.¡õúU «+eÕÄËäð·b¹2}æÌY¨$Òb¡óò+¯_þô½÷á6»Ñ¨c0Æ'&õ,ø¦ZcÖ°±±u:íCmy'ð¡Í j1ë«UhdÓnòO9mvð`x<þ±Ù`d®ÌàMR6l¡¶ âR8<èO}Y¥n`¨:m0ö^ÓîͱøÉùgßyç«N§Þ196a2Ú&³uzvæ?ü!¸ ¾báÜyIßjÖARúO?özÜWÌÎN#àrëÀíóÏ?ßß-,ÌX-¶Ó`HDB¤6é´(*4¥¶ÊjT)ûÏ¡Âð]E(jMÞ`RW[½KW3ùl¡Ó©IL*I¤ÒÁphqqW¾sçöðÐ0°Ñ¬a÷Û.'/ÕZeaajàÑ£G Æã »Ó¡×ënß¹Ýå;SSíNÇît¯ï´[-ÐbèVè¡Ép$b·9Ûm>vàñxÁûyzTC!rÖ^¿VcÈ[\Û d_æíõ Úxþa\ç[·h_§/ÁÑn¯Á i´ÚKízÔkY93V»Ät®ñÜËv#Sȸ|Nß×>_ÀæÀ9E[&hîääÄñÑÙlÝ]^÷òµ«¹bîÞ½;p$Ã._¾ÌÏ ¹`qÉ`GeµZOÓ$²«ÑdÒKÍ ¤T5×Çͧ³Y¥^+2յǧ-`:¶V£aÆ9¾A/íFG¶66z°+òâévPu`@±ð ×¥©Y:0Pbù\nfjÚdD$u0\cAýÓü¯LöàÑÝí'ÕR)|':©UËÙ|fff¢T)AñŢѩGWÓÌïüöÿ¼¶öÕS?jüàÔ*2(>dV©2´S8mI$J§G!b`|©#-JÅz³O7ÍVÝìÂ(ïù>ÃÜàê¼È7dl ;:>¶|íl·ò`åÇ?~®óÔkÙlæöÏáûc£àxv½)õÜô cÖI-fl0ʰÔëA Ãܺu?aÔÔqllxÐæ81tý¹sÞfAJ;ØÝKÄã{>B{Ò292Çé F2éìë$þv|Þlê%5-ÖÓ D:Èd2ArR ìFÍy:Àh4Cá>£[XPë¨dwn£:"ðø-4M0'"·Óõû` ½ÿ£ÇçÖY¾ßt¸&L?4ÑèÔx Ò¯¼f·:3ñLÈ3$Îð £Òñd2ÎDÂCPJÑãh_è'â \z°Ãópc°´?`ufôʲ BÕhJNOLfÓipÏ>þ\urbÂlµÔjÕQó1fÐãÁÙOâ1ØY¡\,ù<Þ_~ëZ=k1Ц%µt(ej¤ÃD"î°å21=¶XCræYà ÞØèTÀ?ôËÿòØ^yôÁ?{íµ×ßþÒ7|'øh¥V¶Ù,}jëâù©×Ø£Þ¢H%Jm»)6ÛB£Õ4eëSÏ\QêuÇV»Íåó@©ÄÑ`Ð'v+×áðDRYÀ¢ÑjÕ5Ê :/µÛ³ÅÒ̰t¨øÞ_.W ˳é<»T¤ÆhU:»ÕRn&à»u&3³µùØçw=ÏW,5,Ïs¯}ͬ1ýè»ß»xé|:}ÿX,F &(½êHF¹Qoé´zD$°²Ö*µF§TéB£g+õ¦/hgMÑ$E6=9:ÓsOjXèp_ PÄ.gï"µ½àÎeÔ´'õVèGc±Gߺ}·R«zÜnÍ͵¿¿§ B´e°¼UÒ±Éd&Kàj©t#Qg)kÌKO&gMÆÉ¹Yðª§*T$G lVCs³ÜP*iêå yȹ§®ß0êMâ«®éUµB V2jx(5+b BeuG3ã?øþ.^yÆueÍz+81úüÕ_ýõÞ(W¢8Ã-®xá ÚÄ)ØöiGjé¬Rüu¤\ð!l;ýg_¸¯ULfK ¶ßÇÑyY ^/rԨРgïMBÄ2°ígv3ÝÑ99JµÓíºsç l ì A»³»{pxX,y?Zx(Pp!?hh<ÇWgÏG|@u¡j|ªT)ûÊe .uúîõ9w¸Ý5ªr¦Z¡4ë ̹WoP§L Øwج«Ý]ÝF»gärľ©EÇ87UjU¡ iuгÙR*<.Éh9S1%£¥ý(âNæPй&L L§¯\}Q&c¹ZCedÕõ»ßûópK»ÕÁZáh¥V©.±©ù¶CY2Öh)U[*!«NÌL\~êú~üHWÃÅrÑôË}HY¼ÿèøhgg°KGWJf«y|brãÁkUóKðýã¨ËãF¬ÀÜ''ÑR±lw9³f³U©T_^^VÐYðEÈ1 V:{òd=L(5jÑé¤ ÀJ$ÀH(kº¼ÞÉÉ)õå¤`FvzÀ$ `\Y¸H®Óhl¬\⯽~:½áÖ2ùöæËî´YÌ>¯:ɹÝnD£È'~^hLFØhïäøx÷ sSC£Ã6#|áæóHm©Ûdµ@+ÁO6K«Ãݽ/'UQZ,W_}5CUÄ <þñññ¿a8=ÃH]juÅb O4©éiàië^,p¹©®I!G.áyá´É¤¥8Úþ§Ñ5ZMÅÖKFè 0Hg`###´·W&wXmj¹²É1ã×Ïmnl´E oÕh´Hí~üÉ` \ÐëÁi'R½Çëjs [M'|$J$¼Ýh¿üâ+à´Û_ê¶ döÿ7 õUÔ:ñ2 ب¬o|^(8¬V«[ÓQyq»£Qi¨eQ/ÝÓ6ÍQÔèLùRM£·Ä`¨Ò¤m,øÎd6ݺjztdØl1.²ùl³Ýè ZF2 e¡Osx7ÍjïËY6ÂÁ!pt F:'ÂsÁüÕF4{²Ííù)¹Zcó¸µÐïMNOÄâñ»øwïÞêGÇǧãêòÕlÄ=ô2M°oo@»z:j oëuiS亵RY|á´Ü,{ùåW2éTôäDEë8päd½VQMïÔú¯Ùª·»mÀ_³Õ~¦6WøìÏæ¦R¡$è6ù}Ú½(¨pP®Àhð=yu /+tÍÝûZ&ðñÚÍ(ôAÞR© jµFÑJ¦S&¹ ¦Ã5 JëÕ/¾°t~Z¡ÖÌ]Ò°º¾¼ÊÄ¡¼>ÿ(-ÀÈTç³òðA$v¸]3³ó]`73dÏç½sï5Æj³ºAÝ@æ V³íözlv^v ãÍ&f0Ñd2 X7,çÎ;ÆNOèøHHÅjmw: 3B\6âuà©*M÷K±zd¹¼Û¥Ó@D©íFËh0t[NÍ¢>S ´UÀ©QàÜ óp)ËËåA(^¯oog?Jz¼nÜ!'ýë÷dÐ1M®]o4ôÄ÷ÔÇÇ'R§rY(ó©ÖêÀ+¯@³ãÖÖ6~æ©ñm¥FæôµÔ>XMlNSmP)HÖerøQ1Wð{½v»ÝçóAê6ëb._/RÝsùõ/`XÂáîÀõEqdh¸@ìããU2ÓÙ`§S(m:¤W qÇ6« ¯Ëñ_çë*!£9í+Û£®Ör©ç(NáEZò } ³r¥æ½| /^<88ØÚÜõÑh\©böö÷i\£N»¢#ñPÒAPGp|¦ æí(ä¤ÀaxññÚÓáĬ¬¬`Á8ÔRç0üÃ;IÐàli8û`Àw»fSàº\½ á`¨V©"-#1¦Éz©bÐèå7^eínÆZ®È Aò$QLeÚF·ÍýÃþAÇê|¡@¹Z Eà³ w×úÝßüöò¥k]ÀÈT¢Lýçdí2Wþ?úw?¿ýÑ@Û¯vK~»ÁWÝ~{¥Q§c¸õÓ¤ÇµÛ Bn{k;ÎÞ¹÷H¥µ¨T® ¬·-N¡0 ɤT)µzµÔê¸pt´Ëw;2iÊÎ866Y*U·ööGF'¾ù+ßÚ=<ØØÚÒQÉ&Ë·Zm@QèÇííã;@$¸` Ω¯ÕÚ@8þ<0è "@¦^ÔkÕr©¨`¨ÇµZ@%âIVwþÜù{÷îÁ¡ÈP¹R¢RÙj£ÐAâ½ÃB:RÉåZµR)w¹¶ÕGAÈ,N,årN± h·É"$eõÅt¦Ïó¯×d6Ù=ö'[él äÁér|ûÛÿË3×ÄKÕ!ê6¼Vè䪹?ÿÎÿûÁÇ?Ë2\púí¦Wk fþG##C cñXrI÷ü K`9ÑhríÉöõ|Þé=dEøN«½uûdÚùóg34øxÎÁÁᣵµb©DÛ½@Ø:ÝO>ÿàDc15¡ªVîòåËo¼ñ»ZáIëÁ`X$OEÝÓÓåJeЧTÅ ¦ïAÂ:ù×HíîK ¡FÖ EtTY¥Y*ͳ¹Øï%cqÔB¬Ï¬V )H;¶ÛMi-Ðæñ'pÉíímÓ onµéÀ¯.qÒÖ*ÈÚKtÒÝ6>9p¦6¥.W±T4`TpQÔÝÎëq7¥©PÒ¨o¯ßÎ`ýÀ¥Ëð PiSÓS7,¡7°ñDbåÁJ6´\§KñRÓ î"£Óá«0J£qÚóW%íDy" ¢U«vú4/904RhA FÇé|Úás)Ôª·¿úå_þæ7GáÅ*¹¢Þ®ç ÙJ½òáïÿøÇï¦Ó©x*Ψ£ã£W¯MÄñO?ý¤\«E"._¹òàÊu$C`4ØÅãÇkVê~Û ]¸xñÎíÛÙBO ×ÃàñÎ=[®Nµz¬?¼»: àÚÜÜVÌæÑ±ÉÓÓ.O+ï Áऱ4Úíâ=< :ÛÙÞáãþñç0t£Õ fѬî ~ôáßÿ׿ûǼ;=3uõú²ÍFû¶~øÃDán±·w¸¶¶vûֱѱ·¾ôÖññ!Ò`0ÄÏåëË¥jy{g )W(@¬©Zç"Åõ¤&|%Àj ¦Ý! 4 AT©Té* ç¡Áhêð|³Ýî =¸943¦_]{{k¿pr×¼:ÀR(ð½á¡Çkël³³³ÓSàÀ@اg]|8+ôD±P{=ûìsb·S§Õ2êSMZ¨?éiG{±3KóA©¯Ó©@Rd/\°9Zñ¼ÇuZ{{¥rþùþæós³à%×3©L³Vûã?úC<¾ßïãéXKÜ´®ñhíR<d2ÒÑñÁöîhëÓO=ýî?¼»Ã+K¸1FÁôDñ`vnÞêp:{>|(íÇ5lxÂu}5ð)-v+þÓÎàFÚ¢NíH+å*Þ DA4`áTPì«W¯ÎLOÈít® ÖÔîÅŨÍHó9µj¿H*^NÇñi@Fm07"² Û骵ׯÀHCñ):ºJ~qÚìn¸Ïs¸9ô¢ªVô,ih2A¤³\¥B Yþåßû¶L%çú\Í8V§Ý,ùÇ9 ¹\û« 4ÚN½V³è ?y÷GHD+J>ÒAZÀûÁ~póÅ3³SsßùÎw©8UsVKW.\ùêÛ_EÀ4Î=[¯Kç±Ò;·n¿ýöÛ^¯ÿoþæoÀ&6Ë9K9 tvs¿O&E¤&ÇwrqO§$ Ô§sdÔp ÷èt:> $ÀÍqq è/:Ex0;AÎGrZoÖ B!äà»÷ÄdïDF oܸƵîÞÛÝÙÊŵrµÛâ>þðçk+«½`Ö²µÛÙÝUʰB.[ ù¢e¹f©N^3h@m|ð(¬ÙdøøvÛFUkb¹º99=ùðïß{ï§~·ûÃ÷ÞÖ¥÷ó XÐëwZ¥Ònd i÷züxh,q¨¢ÆbüÇ|²ö÷£Í:ú@¥ÕC+RYàqû@"©MµjL>°Yië³Ålo"ðý>»õ9 ¨ «Z§wãu:þÖéD ÃXöèI¾óRë5È©6" ÕªO*ø._¯ÕÁ26+(dÆ Bi|||jjëÂqdü(áóÒ,è o4ú¹ñô3áP¡E&&§,V«Xy5vÛíöML QCú2YU.`îÐÙÛr¨ø @Y:ÃQ¡±¹µY(Ò.l¶ÓDZÌ`Á4>9I½%ú}&óùxÒD"n2T »S]a«d·**àTñWp¹lár¹Xé`5ø"Uâ:Ô°hxq±7kZ lTjxµJCðÈz©ñ °´pJÁ ö1Ápø(zìöy &6wvþ¿®´¹më H¸û".ÖfKr*õã¤í¤éÇí×6ý§mgÒN¾8q,Y²,q÷} Z1ÐhÊòú«×h9ÕREÀèm¢ÉÐöO7íV^U5 7MÓ¶gáYrÕgçç@wï~~ýßC|út¿aÛ»R¥IÇ+UªkÒpãu0öCí.e  |í>ÒræåØ^¦%û0'´znÏc ¯lÁ-BèNO¡N»¶Ü^×ÔÀÊnب¯$7-¹Êm=6á àÑH俦¤(^J~«Ð°Îa ®¿üð·þû_[ÛCA¿¬VKÅ2öÁä)ÑÏgTüÅë¡ìT¹ZCæEUJ2 h¯ìý>jãè× ê|2õk¡Þhg²v»Z³áR¼áxÇ_<ow»Açðé|öäüéÍÃÝx1qyùþú*Ø$Ò)PìµmågÆFs´&%WÌï 6'Slj:[m6å*pI Gvë¥îóJºÏ·Ä¹é÷hÚÒ$ Äï`¶e»rG`Ö¨?´L_SYvIB{+ªÏëyÎy,uª¢M9:P$åfÌex·ÆEzúààï?ü£Ò¨ëÐeON§ÒÃÉX¨Àe<¥?DôFx@¤éP wµz¸Eqð mKªdµAôÇÛ |¾),)Ä÷p0Øí¶c±¨#?þø¯è9vnƯWÒ6uRðÃWÊåÊd6/Õªf;12X5 ®»àHáÛÛOPßÿñûX:¾\깨ïh<FÛ%SIgGKÃÙîJ¡X¼¼¼D@£ Ô l©Õª {aZù£/h%Å.Ïqv¦<G"Ñ£ã0¸x·|¦zS,ó~ФƴhïÍØlÀ a¥ÒÃcÆzR|"KÞõj´¯ãØ,ìt46Öp{³\®õ¹:j°ÙOn_õ× Îß§d}Â~)ZÃ?,âÝü hÒÀÀr°ãhÎÙ±|iÙMu \ôA ý~\*! s"bÆ÷ 3Ù,åBâ¸t*à ßZnÚ|;ͧtñ·ÆÑèÚB!ÇÁðÀvh!ÔaÃó´-Z{ÃqÙ`XSÒG¦e ¸H« 8Ù@ÕjuÐ Ü ê`ipæcT¤ÙjC£¢E®®®qäÙÙ ª`þàÀÙæc³;P:o{·¡ÅÓó³ð¥ÕTªS`½MÆþ(OʲXèÎÐxÜ|± иa 'XRCJB?<! ÉfèI³:^ïÿ |
From: Michael H. <mh...@us...> - 2000-12-09 19:52:07
|
Update of /cvsroot/pythianproject/Prototypes/GUISystem In directory slayer.i.sourceforge.net:/tmp/cvs-serv18050/GUISystem Modified Files: StartupForm.dfm StartupForm.pas vglClasses.pas Log Message: GUI system update -mike Index: StartupForm.dfm =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/StartupForm.dfm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 Binary files /tmp/cvsCwYbG2 and /tmp/cvsSkgwiV differ Index: StartupForm.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/StartupForm.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** StartupForm.pas 2000/12/08 19:21:40 1.1 --- StartupForm.pas 2000/12/09 19:52:04 1.2 *************** *** 10,13 **** --- 10,14 ---- TfrmStartup = class(TForm) GoButton: TButton; + Memo1: TMemo; procedure GoButtonClick(Sender: TObject); private *************** *** 31,34 **** --- 32,36 ---- procedure Panel1OnMouseEntry(Sender:TObject); procedure Panel1OnMouseExit(Sender:TObject); + procedure ButtonOnclick(Sender:TObject); end; *************** *** 67,71 **** // create test components Panel1 := TvglPanel.Create('Panel1',InterfaceManager.Desktop); ! Panel1.Bounds := Rect(50,50,350,350); Panel1.Textured := true; Panel1.OnMouseDown := Panel1OnMouseDown; --- 69,73 ---- // create test components Panel1 := TvglPanel.Create('Panel1',InterfaceManager.Desktop); ! Panel1.Bounds := Rect(50,50,250,250); Panel1.Textured := true; Panel1.OnMouseDown := Panel1OnMouseDown; *************** *** 79,89 **** c.Width := 50; c.Height := 50; ! Image1 := TvglImage.Create('Image1',Panel1); ! Image1.Bounds := Rect(200,100,500,400); ! Image1.LoadImage('group_ai.png'); Button := TvglButton.Create('Button',Panel1); ! Button.Caption := 'click me!'; Button.Bounds := Rect(10,60,0,0); Hide; --- 81,92 ---- c.Width := 50; c.Height := 50; ! Image1 := TvglImage.Create('Image1',InterfaceManager.Desktop); ! Image1.LoadImage('olog.png'); ! Image1.Bounds := Rect(500,20,0,0); Button := TvglButton.Create('Button',Panel1); ! Button.Caption := 'hide image'; Button.Bounds := Rect(10,60,0,0); + Button.OnClick := ButtonOnClick; Hide; *************** *** 144,147 **** --- 147,157 ---- begin if Panel1.Color = clBlue then Panel1.Color := clGreen else Panel1.Color := clBlue; + end; + + procedure TfrmStartup.ButtonOnclick(Sender: TObject); + begin + Image1.Visible := not Image1.Visible; + if Image1.Visible then + Button.Caption := 'hide image' else Button.Caption := 'show image'; end; Index: vglClasses.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/vglClasses.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** vglClasses.pas 2000/12/08 19:21:41 1.1 --- vglClasses.pas 2000/12/09 19:52:04 1.2 *************** *** 117,120 **** --- 117,121 ---- FChildren :TvglObjList; FManager :TvglInterfaceManager; + FClickGetReady :boolean; // set to true when mouse is down, reset to false when mouse goes up (triggers a click), reset to false when mouse moves // events here *************** *** 122,126 **** FOnMouseUp, FOnMouseDown :TVGLMouseButtonEvent; FOnMouseMove :TVGLMouseMoveEvent; ! FOnMouseEntry,FOnMouseExit :TNotifyEvent; FVisible :boolean; --- 123,127 ---- FOnMouseUp, FOnMouseDown :TVGLMouseButtonEvent; FOnMouseMove :TVGLMouseMoveEvent; ! FOnMouseEntry,FOnMouseExit,FOnMouseClick :TNotifyEvent; FVisible :boolean; *************** *** 138,141 **** --- 139,150 ---- function GetClientBounds: TRect; virtual ; function GetComponentType:string; virtual ; abstract ; + + // events + procedure DoOnMouseMove(X,Y:integer); virtual ; + procedure DoOnMouseDown(mb, X,Y:integer); virtual ; + procedure DoOnMouseUp(mb, X,Y:integer); virtual ; + procedure DoOnMouseEntry; virtual ; // unlike the above events these do not recurse + procedure DoOnMouseExit; virtual ; + procedure DoOnMouseClick(x,y:integer); virtual ; public property Owner :TvglComponent read FOwner; *************** *** 162,171 **** function ScreenBounds :TRect; // converts the relative position into a screen based position - // events - procedure DoOnMouseMove(X,Y:integer); virtual ; - procedure DoOnMouseDown(mb, X,Y:integer); virtual ; - procedure DoOnMouseUp(mb, X,Y:integer); virtual ; - procedure DoOnMouseEntry; virtual ; // unlike the above events these do not recurse - procedure DoOnMouseExit; virtual ; published property Name :string read FName write SetName; --- 171,174 ---- *************** *** 185,188 **** --- 188,192 ---- property OnMouseEntry :TNotifyEvent read FOnMouseEntry write FOnMouseEntry; property OnMouseExit :TNotifyEvent read FOnMouseExit write FOnMouseExit; + property OnClick :TNotifyEvent read FOnMouseClick write FOnMouseClick; end; *************** *** 222,225 **** --- 226,230 ---- FImage :TGLBitmap; procedure SetImage(const Value: TGLBitmap); + procedure SetBounds(const Value: TRect); override ; function GetComponentType:string; override ; public *************** *** 233,240 **** --- 238,247 ---- end; + TvglButtonState = (vglbsUp, vglbsDown, vglbsOver); TvglButton = class(TvglComponent) protected FImage :TGLBitmap; FCaptionText :TGLText; + FButtonState :TvglButtonState; procedure SetCaption(const Value: string); procedure SetBounds(const Value: TRect); override ; *************** *** 242,245 **** --- 249,256 ---- function GetComponentType:string; override ; + + procedure DoOnMouseEntry; override ; + procedure DoOnMouseExit; override ; + procedure DoOnMouseDown(mb,x,y:integer); override ; public property Caption :string read GetCaption write SetCaption; *************** *** 318,321 **** --- 329,333 ---- inherited Create; FName := aName; + FClickGetReady := false; if AOwner <> nil then begin *************** *** 416,428 **** c:TvglComponent; begin ! i := 0; c := nil; Result := nil; if not PointInRect(ScreenBounds,X,Y) then exit; if FChildren.Count > 0 then ! while not assigned(c) and (i < FChildren.Count) do begin if PointInRect(FChildren[i].ScreenBounds,X,Y) and PointInRect(ClientBounds,X,Y) and FChildren[i].Visible then // this child may contain the final component so ask it c := FChildren[i].GetComponentAt(X,Y); ! inc(i); end; if c = nil then result := self else result := c; --- 428,441 ---- c:TvglComponent; begin ! // we want the topmost component so work backwards ! i := FChildren.Count-1; c := nil; Result := nil; if not PointInRect(ScreenBounds,X,Y) then exit; if FChildren.Count > 0 then ! while not assigned(c) and (i >= 0) do begin if PointInRect(FChildren[i].ScreenBounds,X,Y) and PointInRect(ClientBounds,X,Y) and FChildren[i].Visible then // this child may contain the final component so ask it c := FChildren[i].GetComponentAt(X,Y); ! dec(i); end; if c = nil then result := self else result := c; *************** *** 465,468 **** --- 478,483 ---- if assigned(FOnMouseDown) then OnMouseDown(mb, X,Y); + if mb = VGL_MOUSE_LEFT then + FClickGetReady := true; end; *************** *** 484,487 **** --- 499,507 ---- c.DoOnMouseUp(mb,X,Y); if assigned(FOnMouseUp) then OnMouseUp(mb,X,Y); + if FClickGetReady then + begin + DoOnMouseClick(X,Y); + FClickGetReady := false; + end; end; *************** *** 567,570 **** --- 587,595 ---- end; + procedure TvglComponent.DoOnMouseClick(x,y:integer); + begin + if assigned(FOnMouseClick) then OnClick(Self); + end; + { TvglObjList } *************** *** 858,861 **** --- 883,898 ---- end; + procedure TvglImage.SetBounds(const Value: TRect); + var tmp:TRect; + begin + tmp := Value; + if assigned(FImage) then + begin + if tmp.Right = 0 then tmp.Right := FImage.Width+tmp.Left; + if tmp.Bottom = 0 then tmp.Bottom := FImage.Height+tmp.Top; + end else if (tmp.right = 0) or (tmp.bottom = 0) then raise EVGLException.Create('TvglImage.SetBounds: Autosizing can only occur once an image is loaded'); + inherited SetBounds(tmp); + end; + { TvglButton } *************** *** 866,869 **** --- 903,907 ---- FCaptionText := TGLText.Create('Arial'); FCaptionText.SetColor(clBlack); + FButtonState := vglbsUp; end; *************** *** 874,883 **** end; procedure TvglButton.DrawSelf(where: TRect); begin inherited DrawSelf(where); ! //@@todo - text centering Canvas.DrawBitmapSubRect(where.Left,where.Top,VGL_SKINRECT_BUTTON,FImage); ! if FCaptionText.Text <> '' then Canvas.DrawText(where.Left+10,where.Top+12,FCaptionText); end; --- 912,948 ---- end; + procedure TvglButton.DoOnMouseDown(mb, x, y: integer); + begin + inherited DoOnMouseDown(mb,x,y); + FButtonState := vglbsDown; + end; + + procedure TvglButton.DoOnMouseEntry; + begin + inherited DoOnMouseEntry; + FButtonState := vglbsOver; + end; + + procedure TvglButton.DoOnMouseExit; + begin + inherited DoOnMouseExit; + FButtonState := vglbsUp; + end; + procedure TvglButton.DrawSelf(where: TRect); + var tw:integer; begin inherited DrawSelf(where); ! //@@todo - text centreing ! case FButtonState of ! vglbsUp: FImage.Intensity := 255; ! vglbsOver: FImage.Intensity := 200; ! vglbsDown: FImage.Intensity := 200; ! end; Canvas.DrawBitmapSubRect(where.Left,where.Top,VGL_SKINRECT_BUTTON,FImage); ! FImage.Intensity := 255; // remember to reset!!! ! tw := FCaptionText.Width[0]; ! if FCaptionText.Text <> '' then ! Canvas.DrawText( ((where.Right-where.Left-16))-(tw div 2), where.top+12,FCaptionText); end; *************** *** 896,900 **** begin tmp := Value; ! tmp.Right := FImage.Width+tmp.Right; tmp.Bottom := tmp.Top+FImage.Height; inherited SetBounds(tmp); end; --- 961,966 ---- begin tmp := Value; ! tmp.Right := (VGL_SKINRECT_BUTTON.Right-VGL_SKINRECT_BUTTON.Left)+tmp.Left; ! tmp.Bottom := tmp.Top+(VGL_SKINRECT_BUTTON.Bottom-VGL_SKINRECT_BUTTON.Top); inherited SetBounds(tmp); end; |
From: Michael H. <mh...@us...> - 2000-12-09 19:52:07
|
Update of /cvsroot/pythianproject/Prototypes/TextureDemo In directory slayer.i.sourceforge.net:/tmp/cvs-serv18050/TextureDemo Modified Files: QuadTextUnit.pas Log Message: GUI system update -mike Index: QuadTextUnit.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/TextureDemo/QuadTextUnit.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** QuadTextUnit.pas 2000/11/17 20:32:59 1.1 --- QuadTextUnit.pas 2000/12/09 19:52:04 1.2 *************** *** 11,15 **** ! Todo - } --- 11,17 ---- ! Todo - all data packaged into a file? ! - antialiasing? ! - scaling } *************** *** 36,39 **** --- 38,42 ---- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 6, 7, 2, 2, 3, 3); + ARIAL_WIDTHS :TQuadTextWidthsArray = ( 9, 10, 10, 10, 10, 9, 10, 10, 2, 9, 10, 9, *************** *** 117,120 **** --- 120,128 ---- o,a:integer; begin + glMatrixMode(GL_TEXTURE); // modify texture matrix; + glLoadIdentity; + glScalef(1/256,1/256,1); + + glMatrixMode(GL_MODELVIEW); glPushMatrix; glPushMatrix; *************** *** 130,134 **** glTranslatef(0,QT.GridSquareHeight,0); // translate down glPushMatrix; ! end else begin o := qtDrawGridChar(QT,s[a]); if o <> -1 then --- 138,142 ---- 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 *************** *** 140,143 **** --- 148,154 ---- glPopMatrix; glPopMatrix; + glMatrixMode(GL_TEXTURE); + glLoadIdentity; + glMatrixMode(GL_MODELVIEW); end; *************** *** 146,149 **** --- 157,161 ---- glGetBooleanv(GL_DEPTH_TEST,@dtstore); glDisable(GL_DEPTH_TEST); + glEnable(GL_TEXTURE_2D); end; |
From: Michael H. <mh...@us...> - 2000-12-09 19:52:06
|
Update of /cvsroot/pythianproject/Prototypes/GLCanvas In directory slayer.i.sourceforge.net:/tmp/cvs-serv18050/GLCanvas Modified Files: QuadTextUnit.pas glCanvas.pas glcanvas.htm Log Message: GUI system update -mike Index: QuadTextUnit.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/QuadTextUnit.pas,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** QuadTextUnit.pas 2000/12/03 22:57:21 1.3 --- QuadTextUnit.pas 2000/12/09 19:52:04 1.4 *************** *** 12,15 **** --- 12,18 ---- Todo - antialiasing + + Changed - + 5th December 2000: changed blending algorithm selected to fix bug. } *************** *** 46,50 **** 8, 2, 12, 8, 8, 8, 8, 5, 8, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, ! 12, 8, 4, 6, 7, 2, 2, 3, 3, 2, 13, 14, 12, 5, 7, 2, 8, 8, 2, 2, 4, 4, 12, 15, 15); --- 49,53 ---- 8, 2, 12, 8, 8, 8, 8, 5, 8, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, ! 8, 8, 4, 6, 7, 2, 2, 3, 3, 2, 13, 14, 12, 5, 7, 2, 8, 8, 2, 2, 4, 4, 12, 15, 15); *************** *** 65,68 **** --- 68,72 ---- function qtDrawGridSquare(QT:TQuadText; X,Y:integer):integer; procedure qtDrawGridString(QT:TQuadText; s:String); + function qtGetStringWidth(QT:TQuadText; s:string):integer; // in pixels implementation *************** *** 74,77 **** --- 78,98 ---- txStore :TGLBoolean; + function qtGetStringWidth(QT:TQuadText; s:string):integer; // in pixels + var total,offset,i,j:integer; + begin + total := 0; + for i := 1 to Length(s) do + begin + offset := -1; + for j := 1 to NUMCHARS do + if TEX_CHARS[j] = s[i] then + offset := j; + if offset <> -1 then + total := total + QT.TexWidths[offset] + QT.GridCharSpacing + else total := total + QT.SpaceWidth; + end; + result := total; + end; + function qtDrawGridChar(QT:TQuadText; C:Char):integer; var *************** *** 166,170 **** glGetBooleanv(GL_BLEND,@blStore); glEnable(GL_BLEND); ! glBlendFunc(GL_SRC_ALPHA,GL_ONE); end; --- 187,192 ---- glGetBooleanv(GL_BLEND,@blStore); glEnable(GL_BLEND); ! // glBlendFunc(GL_SRC_ALPHA,GL_ONE); ! glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); end; Index: glCanvas.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/glCanvas.pas,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** glCanvas.pas 2000/12/03 22:57:21 1.8 --- glCanvas.pas 2000/12/09 19:52:04 1.9 *************** *** 32,40 **** Michael Hearn (mh...@su...) Darryl Long (d_...@sy...) To do- - Add GLF bitmap fonts code - later - Add shapes code - QuadText fonts - cell widths are specified in a different part of the program to the rest of the data. messy. fix it. --- 32,39 ---- Michael Hearn (mh...@su...) Darryl Long (d_...@sy...) + Kamil Krauspe + Ilkka Tuomioja To do- QuadText fonts - cell widths are specified in a different part of the program to the rest of the data. messy. fix it. *************** *** 42,48 **** --- 41,54 ---- Texbmp drawing - add alpha blending, scissor box combining + Bugs- + Doesn't like not being created from a form + Bitmaps don't work with UseTransparency = false :( + Fixed- Color bug all better (darryl) + New- + TRGB, ColorToRGB + Notes- To add a new QuadText font *************** *** 64,68 **** up, where 22 is the height of a titlebar. I have no idea why this should be so, probably a bug in Microsofts code, but ! you have been warned. } --- 70,75 ---- up, where 22 is the height of a titlebar. I have no idea why this should be so, probably a bug in Microsofts code, but ! you have been warned. (fixed: only problem with engine template ! code, GLForms works fine :) } *************** *** 122,125 **** --- 129,136 ---- type + TRGB = record + r,g,b:byte; + end; + // we use this to store the pixel data from a bitmap TPixelData = TByteArray; *************** *** 141,144 **** --- 152,159 ---- FTexData :TTexBMPData; + FRed: byte; + FGreen: byte; + FBlue: byte; + procedure SetIntensity(const Value: byte); public UseTransparency :boolean; *************** *** 155,158 **** --- 170,178 ---- property TexData :TTexBMPData read FTexData; + property Red:byte read FRed write FRed; + property Green:byte read FGreen write FGreen; + property Blue:byte read FBlue write FBlue; + property Intensity:byte write SetIntensity; + constructor Create(aType:integer); overload ; constructor Create; overload; *************** *** 164,169 **** end; - - TGLText = class private --- 184,187 ---- *************** *** 173,177 **** FLines :TStringList; FFontName :string; ! FRed, FGreen, FBlue: Single; FSize :real; --- 191,195 ---- FLines :TStringList; FFontName :string; ! FRed, FGreen, FBlue: byte; FSize :real; *************** *** 186,192 **** procedure LoadFont; virtual ; ! procedure SetBlue(const Value: Single); ! procedure SetGreen(const Value: Single); ! procedure SetRed(const Value: Single); procedure SetSize(const Value: Real); procedure SetPrecache(const Value: boolean); --- 204,210 ---- procedure LoadFont; virtual ; ! procedure SetBlue(const Value: byte); ! procedure SetGreen(const Value: byte); ! procedure SetRed(const Value: byte); procedure SetSize(const Value: Real); procedure SetPrecache(const Value: boolean); *************** *** 199,202 **** --- 217,221 ---- procedure LinesOnChange(Sender:TObject); + function GetWidth(index: integer): integer; public *************** *** 211,218 **** property Text:string read GetText write SetText; ! property Red: Single read FRed write SetRed; ! property Green: Single read FGreen write SetGreen; ! property Blue: Single read FBlue write SetBlue; property Size :Real read FSize write SetSize; --- 230,239 ---- property Text:string read GetText write SetText; ! property Width[index:integer]:integer read GetWidth; + property Red: byte read FRed write SetRed; + property Green: byte read FGreen write SetGreen; + property Blue: byte read FBlue write SetBlue; + property Size :Real read FSize write SetSize; *************** *** 233,236 **** --- 254,258 ---- FFillR,FFillG,FFillB :Single; FFillAlpha: Single; + FClipRect:TRect; function GetColor: TColor; procedure SetColor(const Value: TColor); *************** *** 244,247 **** --- 266,270 ---- property CurrentColor :TColor read GetColor write SetColor; property FillAlpha:Single read FFillAlpha write FFillAlpha; + property ClipRect :TRect read FClipRect; // misc. object routines *************** *** 258,264 **** procedure DrawBitmapEx(X,Y,aWidth,aHeight,OffsetX,OffsetY:integer; bmp:TGLBitmap); virtual ; procedure DrawBitmap(X,Y:integer; bmp:TGLBitmap); virtual ; // other ! procedure SetClipping(Left,Top,Right,Bottom:integer); procedure CancelClipping; --- 281,289 ---- procedure DrawBitmapEx(X,Y,aWidth,aHeight,OffsetX,OffsetY:integer; bmp:TGLBitmap); virtual ; procedure DrawBitmap(X,Y:integer; bmp:TGLBitmap); virtual ; + procedure DrawBitmapSubRect(X,Y:integer; SubRect:TRect; bmp:TGLBitmap); virtual ; // other ! procedure SetClipping(Left,Top,Right,Bottom:integer); overload; ! procedure SetClipping(R:TRect); overload ; procedure CancelClipping; *************** *** 270,275 **** --- 295,305 ---- // shape routines here - will standardise on the american spelling of colo(u)r procedure Rectangle(Left, Top, Right, Bottom:integer); virtual ; + + function ColorToRGB(c:TColor):TRGB; end; + var + FontsDirectory :string; + function MakeTexturesFromBmp(var aBMP:TFastDIB; useTransparency:boolean; transparentColor:TFColor):TTexBMPData; // returns display list procedure DeleteTexBMP(bmp:TTexBMPData); *************** *** 279,284 **** --- 309,339 ---- procedure DrawTexBMP(offsetx,offsety,width,height:integer; bmp:TTexBMPData); + function PointInRect(r:TRect; X,Y:integer):boolean; + function CompareRect(r1,r2:TRect):boolean; + // returns a rect that is src resized so it fits insides dest + function FitRectToRect(src,dest:TRect):TRect; + implementation + function CompareRect(r1,r2:TRect):boolean; + begin + Result := (r1.Left = r2.Left) and (r1.Top = r2.Top) and (r1.Right = r2.Right) and (r1.Bottom = r2.Bottom); + end; + + function PointInRect(r:TRect; X,Y:integer):boolean; + begin + Result := (X >= r.Left) and (X <= r.Right) and (Y >= r.Top) and (Y <= r.Bottom); + end; + + function FitRectToRect(src,dest:TRect):TRect; + var t,l,r,b:integer; + begin + if src.top >= dest.top then t := src.top else t := dest.top; + if src.left >= dest.left then l := src.left else l := dest.left; + if src.right <= dest.right then r := src.right else r := dest.right; + if src.Bottom <= dest.bottom then b := src.bottom else b := dest.bottom; + result := rect(l,t,r,b); + end; + { TGLBitmap } *************** *** 292,297 **** FWidth := -1; FHeight := -1; FBMPType := aType; ! UseTransparency:=false; TransparentColor := FRGB(0,0,0); end; --- 347,353 ---- FWidth := -1; FHeight := -1; FBMPType := aType; ! UseTransparency:=true; TransparentColor := FRGB(0,0,0); + Intensity := 255; end; *************** *** 406,409 **** --- 462,470 ---- end; + procedure TGLBitmap.SetIntensity(const Value: byte); + begin + Red := Value; Green := Value; Blue := Value; + end; + { TGLCanvas } *************** *** 426,430 **** glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); FillAlpha := 1.0; ! CurrentColor := clWhite; end; --- 487,492 ---- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); FillAlpha := 1.0; ! CurrentColor := clWhite; ! FClipRect := Rect(0,0,0,0); end; *************** *** 435,438 **** --- 497,501 ---- procedure TGLCanvas.DrawBitmapEx(X,Y,aWidth,aHeight,OffsetX,OffsetY:integer;bmp: TGLBitmap); + var r:TRect; begin glPushAttrib(GL_DEPTH_TEST); *************** *** 454,462 **** glTranslatef(x,y,0); ! glEnable(GL_SCISSOR_TEST); ! // @@todo - add scissor box saving/combining ! glScissor(x,Height-y-aHeight,aWidth-1,aHeight); ! DrawTexBmp(offsetx,offsety,aWidth,aHeight,bmp.TexData); ! glDisable(GL_SCISSOR_TEST); end; --- 517,537 ---- glTranslatef(x,y,0); ! if CompareRect(FClipRect,Rect(0,0,0,0)) then ! begin ! glEnable(GL_SCISSOR_TEST); ! glColor3ub(bmp.Red,bmp.Green,bmp.Blue); ! glScissor(x,Height-y-aHeight,aWidth-1,aHeight); ! DrawTexBmp(offsetx,offsety,aWidth,aHeight,bmp.TexData); ! glDisable(GL_SCISSOR_TEST); ! end else ! begin ! // we already have a clipping rectangle so combine them ! r := FitRectToRect(Rect(x,y,x+aWidth,y+aHeight),FClipRect); ! glPushAttrib(GL_SCISSOR_TEST); ! glColor3ub(bmp.Red,bmp.Green,bmp.Blue); ! glScissor(r.left,Height-r.bottom,r.right-r.left-1,r.bottom-r.top); ! DrawTexBmp(offsetx,offsety,aWidth,aHeight,bmp.TexData); ! glPopAttrib; ! end; end; *************** *** 567,570 **** --- 642,665 ---- glEnable(GL_SCISSOR_TEST); glScissor(Left,Height-Bottom,Right-Left,Bottom-Top); + FClipRect := Rect(Left,Top,Right,Bottom); + end; + + function TGLCanvas.ColorToRGB(c: TColor): TRGB; + begin + result.r := (c and $0000FF); + result.g := (c and $00FF00) SHR 8; + result.b := (c and $FF0000) SHR 16; + end; + + procedure TGLCanvas.SetClipping(R: TRect); + begin + SetClipping(r.left,r.top,r.right,r.bottom); + FClipRect := r; + end; + + procedure TGLCanvas.DrawBitmapSubRect(X, Y: integer; SubRect: TRect; + bmp: TGLBitmap); + begin + DrawBitmapEx(X,Y,SubRect.Right-SubRect.Left,subRect.Bottom-SubRect.Top,SubRect.Left,SubRect.Top,bmp); end; *************** *** 618,622 **** if TextType = GLCANVAS_TEXT_GLF then begin ! glColor3f(FRed, FGreen, FBlue); glPushMatrix; glScalef(Size,Size,1); --- 713,717 ---- if TextType = GLCANVAS_TEXT_GLF then begin ! glColor3ub(FRed, FGreen, FBlue); glPushMatrix; glScalef(Size,Size,1); *************** *** 632,636 **** end else if TextType = GLCANVAS_TEXT_QUADTEXT then begin ! glColor3f(FRed, FGreen, FBlue); qtStart; glPushMatrix; --- 727,731 ---- end else if TextType = GLCANVAS_TEXT_QUADTEXT then begin ! glColor3ub(FRed, FGreen, FBlue); qtStart; glPushMatrix; *************** *** 646,649 **** --- 741,749 ---- end; + function TGLText.GetWidth(index: integer): integer; + begin + Result := qtGetStringWidth(QT,Lines[index]); + end; + procedure TGLText.LinesOnChange(Sender: TObject); begin *************** *** 659,671 **** if ExtractFileExt(f.FileName) = '.glf' then begin ! GLFFontHandle := glfLoadFont(f.FileName); if GLFFontHandle = GLF_ERROR then raise Exception.Create('Could not load font'); end else if ExtractFileExt(f.FileName) = '.bmf' then ! glfLoadBMFFont(f.FileName); end else if TextType = GLCANVAS_TEXT_QUADTEXT then begin if assigned(FTexture) then FTexture.Free; FTexture := TTexture.Create; ! FTexture.LoadFromFile(f.FileName); QT.TextureID := FTexture.TexID; QT.GridSquareWidth := 20; --- 759,771 ---- if ExtractFileExt(f.FileName) = '.glf' then begin ! GLFFontHandle := glfLoadFont(FontsDirectory + f.FileName); if GLFFontHandle = GLF_ERROR then raise Exception.Create('Could not load font'); end else if ExtractFileExt(f.FileName) = '.bmf' then ! glfLoadBMFFont(FontsDirectory + f.FileName); end else if TextType = GLCANVAS_TEXT_QUADTEXT then begin if assigned(FTexture) then FTexture.Free; FTexture := TTexture.Create; ! FTexture.LoadFromFile(FontsDirectory + f.FileName); QT.TextureID := FTexture.TexID; QT.GridSquareWidth := 20; *************** *** 703,707 **** end; ! procedure TGLText.SetBlue(const Value: Single); begin FBlue := Value; --- 803,807 ---- end; ! procedure TGLText.SetBlue(const Value: byte); begin FBlue := Value; *************** *** 724,728 **** end; ! procedure TGLText.SetGreen(const Value: Single); begin FGreen := Value; --- 824,828 ---- end; ! procedure TGLText.SetGreen(const Value: byte); begin FGreen := Value; *************** *** 736,740 **** end; ! procedure TGLText.SetRed(const Value: Single); begin FRed := Value; --- 836,840 ---- end; ! procedure TGLText.SetRed(const Value: byte); begin FRed := Value; *************** *** 959,963 **** glBegin(GL_QUADS); ! glColor4f(1.0,1.0,1.0,1.0); // going anti-clockwise // top left --- 1059,1063 ---- glBegin(GL_QUADS); ! // (so we can control colour earlier) glColor4f(1.0,1.0,1.0,1.0); // going anti-clockwise // top left *************** *** 977,980 **** --- 1077,1082 ---- end; + initialization + FontsDirectory := ''; // is appended to font file name end. Index: glcanvas.htm =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/glcanvas.htm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** glcanvas.htm 2000/12/03 22:57:21 1.1 --- glcanvas.htm 2000/12/09 19:52:04 1.2 *************** *** 9,12 **** --- 9,14 ---- <hr align="Left" width="100%" size="2"><a href="mailto:mh...@su...">Michael + + Hearn</a><br> <a href="mailto:d_...@sy...">Darryl Long</a><br> *************** *** 14,25 **** --- 16,39 ---- <br> <hr align="Left" width="100%" size="2"><br> + Change Log:<br> + <br> + - 4th December 2000: Add info about InitMatrix (doh!)<br> + <hr align="Left" width="100%" size="2"><br> This file describes the GLCanvas objects suite and how to use it to make + + drawing 2D graphics onto an OpenGL canvas much easier than it would otherwise + + be. The algorithms used in the canvas have been designed for speed and ease + + of use, not necessarily simplicity. This is why some operations with it + + may seem a strange way of doing things. Anyway, let's go.<br> <br> *************** *** 36,39 **** --- 50,55 ---- All this is done using simple commands like Rectangle(), DrawBitmap() and + + DrawText().<br> <br> *************** *** 41,74 **** --- 57,116 ---- <br> Images in OpenGL are not directly supported unless you use the glDrawPixels() + command which directly copies pixel data from system memory to the pixel + buffer. This would be ideal but unfortunately this is a <b>very</b>slow + operation, and I mean slow. Drawing a 640x480 image in this way on my machine + takes almost half a second :(<br> Nevertheless, the Canvas supports this method for when performance is not + + the be all and end all for your app.<br> <br> However, there is a better, although significantly more complex way of doing + + things that results in much better framerates (ie. about 120fps on my machine + + for a 640x480 image :) This system breaks the image you want to draw into + + multiple textures and then uses polygons to display them. Because these + + images are hardware accellerated things move along much better. Why multiple + + textures? Well, most hardware cards have a limit of 256x256 pixels for textures + + due to the internals of their engines. So the canvas breaks an image into + + multiple textures when the image is loaded.<br> <br> So how do you use this then? Well, all bitmaps in the GLCanvas are represented + + by objects, in this case the TGLBitmap class is used. To use a bitmap it + + must be loaded into one of these objects, which can then be passed to the + + DrawBitmap() method of the GLCanvas. Here's an example:<br> <br> *************** *** 77,82 **** <br> <code>begin</code><br> ! <code> GLC := TGLCanvas.Create;</code><br> ! <code> </code><br> <code> Picture := TGLBitmap.Create;</code><br> <code> Picture.LoadFromFile("logo.png");</code><br> --- 119,126 ---- <br> <code>begin</code><br> ! <code> GLC := TGLCanvas.Create;<br> ! <br> ! GLC.InitMatrix;</code><br> ! <br> <code> Picture := TGLBitmap.Create;</code><br> <code> Picture.LoadFromFile("logo.png");</code><br> *************** *** 85,99 **** <code>end;</code><br> <br> ! This example would display "logo.png"at location 50,50 from the top left ! of the window. As you can see, there is nothing to it. However, we can do ! more than this! The GLBitmap class supports transparency using a transparent ! colour: if we set the transparent colour to black then any black pixels ! in the picture will be see-through, meaning you can draw non-rectangular ! bitmaps. This is done by setting the <code>UseTransparency</code>property ! to true and setting the TransparentColor property to the colour you want ! (it defaults to black). Because the GLCanvas is based partly on the FastDIB ! library you must specify the colour as RGB data, not a Delphi colour constant. ! Although in some places you can use constants like clBlack or clAqua in ! this instance that's not allowed. You create a colour for this property using the FRGB function:<br> <br> --- 129,144 ---- <code>end;</code><br> <br> ! Note that before any GLCanvas methods can be called you must call InitMatrix, ! this initializes the co-ordinate systems. This example would display "logo.png"at ! location 50,50 from the top left of the window. As you can see, there is ! nothing to it. However, we can do more than this! The GLBitmap class supports ! transparency using a transparent colour: if we set the transparent colour ! to black then any black pixels in the picture will be see-through, meaning ! you can draw non-rectangular bitmaps. This is done by setting the <code>UseTransparency</code>property ! to true and setting the TransparentColor property to the colour you want ! (it defaults to black). Because the GLCanvas is based partly on the FastDIB ! library you must specify the colour as RGB data, not a Delphi colour constant. ! Although in some places you can use constants like clBlack or clAqua in ! this instance that's not allowed. You create a colour for this property using the FRGB function:<br> <br> *************** *** 101,108 **** --- 146,155 ---- Picture.UseTransparency := true;<br> Picture.TransparentColor := FRGB(0,0,255); // blue is our transparent + colour<br> Picture.LoadFromFile("logo.png");</code><br> <br> Notice that you <i>must</i>set the transparency properties before loading + the file. If you want you can use direct drawing by using a different constructor:<br> <br> *************** *** 110,113 **** --- 157,161 ---- <br> However, this isn't really supported very well - for instance transparency + doesn't work with this method. Also, it's slow so it's best to avoid this.<br> <br> *************** *** 115,138 **** --- 163,203 ---- <br> Again, OpenGL has no direct support for drawing text. There are many, many + different ways of drawing text (for more information on this subject check + out NeHe's excellent <a href="http://nehe.gamedev.net/opengl/">tutorial pages</a>) and the Canvas + offers you two which should combine the best of both worlds - bitmapped + text which looks nice at small sizes, and vector text which can be resized + to any area needed without losing resolution. Vector fonts are drawn using + the <a href="http://romka.demonews.com">GLF library</a>written by Romka, who is a seriously + cool guy. You can get more fonts from his website.<br> <br> Bitmapped fonts are drawn using my own system that uses a 256x256 bitmap + with letters arranged in a grid formation. Textured polygons are drawn that + use this and this means <i>fast fast fast!</i><br> <br> This also means that fonts are very easy to make, although it does take some + time. You can use the included "20x20grid.bmp" file to help you create new + fonts. To use the text facility you can use the TGLText object. The reason + that text is represented by objects too is for performance reasons, when + you use an object something called pre-caching becomes available which stores + the commands for drawing the text in the hardware accellerator itself, meaning + - yep, you've guessed it, faster execution! Of course, if this isn't important + to you it's possible to use the DrawString() command for simplicity but + it's really designed to use an object. Here's a simple example of it:<br> <br> *************** *** 150,156 **** --- 215,225 ---- <br> As you can see, this is quite easy, but you can do more :) Text objects can + have multiple lines (accessed through the Lines property), and of course + this can be used to load text files. The demo program shows this in action. + This uses textured quads to draw bitmapped text. To use the GLF vector based + text:<br> <br> *************** *** 160,165 **** --- 229,236 ---- Text2 := TGLText.Create("Hello World","Arial",GLCANVAS_TEXT_GLF,GLC_DEFAULT_FONT_DATA);<br> // here we have used the other overloaded constructor to select GLF text. + you can ignore<br> // the last parameter, it selects a font data array, the default one will + do for now.<br> Text2.Size := 20;<br> *************** *** 167,175 **** --- 238,260 ---- end;</code><br> <br> + If you want to change the directory fonts are loaded from (the default is + for the current directory) you can set the FontsDirectory variable in the + unit. This is a string that is appended to the start of the font filenames + before they are loaded, and therefore they <b>must</b>have a / at the end. + For instance:<br> + <br> + <code>FontsDirectory := "..\Data\Fonts\" // is OK<br> + FontsDirectory := "..\Data\Fonts" // is not!</code><br> + <br> How you add new fonts depends on the system you use. If you're drawing vector + text you can simply download more GLF fonts from Romkas website but I'm + not sure how you can make your own. Then you add the entry for it to the + GLC_DEFAULT_FONT_DATA array as shown below. For bitmap text it's more complex + (i'm afraid the canvas only comes with Arial and Courier New) but everything + can be done using Paint Shop Pro or a similar program.<br> <br> *************** *** 178,198 **** --- 263,295 ---- <li>Create a new 256x256 bitmap with a black background</li> <li>Paste the "20x20 Grid.bmp" file over the top. This will show you where + to place characters. If you want you can place the grid over the fonts that + come with the canvas to see how it's done.</li> <li>For each character place the letter (in white) in each square aligned + to the left of each grid square.</li> <li>Once this is done for every character (well, every character that is + in the font set, you can see them in the other font grids) save it and change + the GLCanvas.pas file in the following way:</li> <li>Add a new entry to the GLC_DEFAULT_FONT_DATA array. The fields are + fairly self-explanatory, just make sure you set FontType to be GLCANVAS_TEXT_QUADTEXT.</li> <li>You also need to add a widths array to the QuadTextUnit.pas file. This + array specifies the width of each character and is how the system support + variable width fonts. See the code for examples of how to do this.</li> <li>Finally, you need to add an entry to the MatchFontWidths method of + the TGLText class. This just returns the array given a font name.</li> <li>That's it! I know it's long winded, some time I may automate it but + for now that's the way to do it. If you want to add some sort of exotic + character not already in the font set add it to the array and set the rest + of the widths in the other arrays to 0.</li> </ol> *************** *** 201,204 **** --- 298,302 ---- <br> You can draw rectangles using the Rectangle() method. This takes 4 coordinates, + X1, X2, Y1 and Y2. It draws a rectangle based on the:<br> <br> *************** *** 208,212 **** --- 306,312 ---- <br> properties. If solid is true then the rectangle will be filled with the colour + and at the opacity specified with FillAlpha. If solid is false then the + outline is all that is drawn.<br> <br> |
From: Michael H. <mh...@us...> - 2000-12-09 19:52:06
|
Update of /cvsroot/pythianproject/Prototypes/GLBitmapDemo In directory slayer.i.sourceforge.net:/tmp/cvs-serv18050/GLBitmapDemo Modified Files: frmMain.dfm Log Message: GUI system update -mike Index: frmMain.dfm =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLBitmapDemo/frmMain.dfm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 Binary files /tmp/cvsJLMROs and /tmp/cvsAuoRqL differ |
From: Michael H. <mh...@us...> - 2000-12-09 19:52:06
|
Update of /cvsroot/pythianproject/Prototypes/GLForm In directory slayer.i.sourceforge.net:/tmp/cvs-serv18050/GLForm Modified Files: GLFormTest.cfg GLFormTest.dof GLFormTest.res Main.dfm Log Message: GUI system update -mike Index: GLFormTest.cfg =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLForm/GLFormTest.cfg,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** GLFormTest.cfg 2000/11/06 23:07:07 1.1 --- GLFormTest.cfg 2000/12/09 19:52:04 1.2 *************** *** 32,35 **** -$M16384,1048576 -K$00400000 ! -LE"c:\program files\borland\delphi5\Projects\Bpl" ! -LN"c:\program files\borland\delphi5\Projects\Bpl" --- 32,37 ---- -$M16384,1048576 -K$00400000 ! -U"..\..\PythianProject\Source\Units" ! -O"..\..\PythianProject\Source\Units" ! -I"..\..\PythianProject\Source\Units" ! -R"..\..\PythianProject\Source\Units" Index: GLFormTest.dof =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLForm/GLFormTest.dof,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** GLFormTest.dof 2000/11/06 23:07:07 1.1 --- GLFormTest.dof 2000/12/09 19:52:04 1.2 *************** *** 46,50 **** PackageDLLOutputDir= PackageDCPOutputDir= ! SearchPath= Packages=VCL50;VCLX50;VCLSMP50;QRPT50;VCLDB50;VCLBDE50;ibevnt50;VCLDBX50;TEEUI50;TEEDB50;TEE50;TEEQR50;VCLIB50;VCLIE50;INETDB50;INET50;NMFAST50;dclocx50;dclaxserver50 Conditionals= --- 46,50 ---- PackageDLLOutputDir= PackageDCPOutputDir= ! SearchPath=..\..\PythianProject\Source\Units Packages=VCL50;VCLX50;VCLSMP50;QRPT50;VCLDB50;VCLBDE50;ibevnt50;VCLDBX50;TEEUI50;TEEDB50;TEE50;TEEQR50;VCLIB50;VCLIE50;INETDB50;INET50;NMFAST50;dclocx50;dclaxserver50 Conditionals= *************** *** 56,64 **** HostApplication= - [Language] - ActiveLang= - ProjectLang=$00000409 - RootDir= - [Version Info] IncludeVerInfo=0 --- 56,59 ---- *************** *** 88,91 **** --- 83,89 ---- Comments= + [Excluded Packages] + $(DELPHI)\Components\Indy\dclIndy40.bpl=Internet Direct "Indy" for D4 Property and Component Editors + [HistoryLists\hlUnitAliases] Count=1 *************** *** 93,100 **** [HistoryLists\hlSearchPath] ! Count=3 ! Item0=..\Units ! Item1=$(DELPHI)\Projects\Pythian\GameProject\Units;$(DELPHI)\Projects\Pythian\GLPanel ! Item2=$(DELPHI)\Projects\Pythian\GameProject\Units;$(DELPHI)\Projects\Pythian\GLPanel;$(DELPHI)\Projects\Pythian\GameProject\Picking [HistoryLists\hlUnitOutputDirectory] --- 91,100 ---- [HistoryLists\hlSearchPath] ! Count=5 ! Item0=..\..\PythianProject\Source\Units ! Item1=..\..\PythianProject\Units\ ! Item2=..\Units ! Item3=$(DELPHI)\Projects\Pythian\GameProject\Units;$(DELPHI)\Projects\Pythian\GLPanel ! Item4=$(DELPHI)\Projects\Pythian\GameProject\Units;$(DELPHI)\Projects\Pythian\GLPanel;$(DELPHI)\Projects\Pythian\GameProject\Picking [HistoryLists\hlUnitOutputDirectory] Index: GLFormTest.res =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLForm/GLFormTest.res,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 Binary files /tmp/cvsuLThHP and /tmp/cvsOC1Bgv differ Index: Main.dfm =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLForm/Main.dfm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 Binary files /tmp/cvsrZXdQQ and /tmp/cvsG1Cdux differ |
From: Michael H. <mh...@us...> - 2000-12-08 19:17:08
|
Update of /cvsroot/pythianproject/Prototypes/GUISystem In directory slayer.i.sourceforge.net:/tmp/cvs-serv28705/GUISystem Log Message: Directory /cvsroot/pythianproject/Prototypes/GUISystem added to the repository |
From: Michael H. <mh...@us...> - 2000-12-03 22:57:24
|
Update of /cvsroot/pythianproject/Prototypes/GLCanvas In directory slayer.i.sourceforge.net:/tmp/cvs-serv22979 Modified Files: Arial Grid.bmp CourierNew Grid.bmp EngMain.pas MyDraw.pas QuadTextUnit.pas glCanvas.pas Added Files: 20x20grid.bmp Data.txt glcanvas.htm scene.png Removed Files: RPG.png gadgetcollage.bmp Log Message: final update --- NEW FILE --- BM6 ÿ --- NEW FILE --- GLCanvas Demo v1.0 ¯¯¯¯¯¯¯¯¯¯ Use the up and down arrow keys to scroll this text box. The GLCanvas allows you to easily program OpenGL for bitmaps and text using very fast algorithms. Bitmap drawing breaks the picture into multiple textures for speed, and bitmapped text uses textured quads (this is an example of that) The GLCanvas is also very easy to use. You can use commands like DrawText(), DrawBitmap() and SetClipping() to simplify coding. The Canvas is object oriented too, and it makes use of display lists to speed up execution of code. The GLCanvas was made for the Pythian Project, an open source effort to create a 3D realtime role playing game set in a fantasy world of our creation. It's a big project and your help is needed. So mosy on over to: http://www.pythianproject.org and check us out. Any Delphi developers are welcomed and as this demo shows, you don't have to be an expert at OpenGL programming! Credits ¯¯¯ Michael Hearn (mh...@su...) Darryl Long (d_...@sy...) Kamil Krauspe --- NEW FILE --- <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><meta name="GENERATOR" content="Microsoft FrontPage 4.0"><meta name="ProgId" content="FrontPage.Editor.Document"> <title>GLCanvas Documentation</title> </head> <body> <div align="Left"> <h4>GLCanvas v1.0 Documentation</h4> <hr align="Left" width="100%" size="2"><a href="mailto:mh...@su...">Michael Hearn</a><br> <a href="mailto:d_...@sy...">Darryl Long</a><br> <a href="mailto:kr...@gm...">Kamil Krauspe</a><br> <br> <hr align="Left" width="100%" size="2"><br> This file describes the GLCanvas objects suite and how to use it to make drawing 2D graphics onto an OpenGL canvas much easier than it would otherwise be. The algorithms used in the canvas have been designed for speed and ease of use, not necessarily simplicity. This is why some operations with it may seem a strange way of doing things. Anyway, let's go.<br> <br> <u>What it can do</u><br> <ul> <li>Images (fast)</li> <li>Bitmapped text (fast)</li> <li>Vector text (via the GLF lib)</li> <li>PNG image support</li> <li>Clipping</li> <li>Rectangle drawing<br> </li> </ul> All this is done using simple commands like Rectangle(), DrawBitmap() and DrawText().<br> <br> <u>Drawing Images</u><br> <br> Images in OpenGL are not directly supported unless you use the glDrawPixels() command which directly copies pixel data from system memory to the pixel buffer. This would be ideal but unfortunately this is a <b>very</b>slow operation, and I mean slow. Drawing a 640x480 image in this way on my machine takes almost half a second :(<br> Nevertheless, the Canvas supports this method for when performance is not the be all and end all for your app.<br> <br> However, there is a better, although significantly more complex way of doing things that results in much better framerates (ie. about 120fps on my machine for a 640x480 image :) This system breaks the image you want to draw into multiple textures and then uses polygons to display them. Because these images are hardware accellerated things move along much better. Why multiple textures? Well, most hardware cards have a limit of 256x256 pixels for textures due to the internals of their engines. So the canvas breaks an image into multiple textures when the image is loaded.<br> <br> So how do you use this then? Well, all bitmaps in the GLCanvas are represented by objects, in this case the TGLBitmap class is used. To use a bitmap it must be loaded into one of these objects, which can then be passed to the DrawBitmap() method of the GLCanvas. Here's an example:<br> <br> <code>GLC: TGLCanvas;</code><br> <code>Picture :TGLBitmap;</code><br> <br> <code>begin</code><br> <code> GLC := TGLCanvas.Create;</code><br> <code> </code><br> <code> Picture := TGLBitmap.Create;</code><br> <code> Picture.LoadFromFile("logo.png");</code><br> <br> <code> GLC.DrawBitmap(50,50,Picture);</code><br> <code>end;</code><br> <br> This example would display "logo.png"at location 50,50 from the top left of the window. As you can see, there is nothing to it. However, we can do more than this! The GLBitmap class supports transparency using a transparent colour: if we set the transparent colour to black then any black pixels in the picture will be see-through, meaning you can draw non-rectangular bitmaps. This is done by setting the <code>UseTransparency</code>property to true and setting the TransparentColor property to the colour you want (it defaults to black). Because the GLCanvas is based partly on the FastDIB library you must specify the colour as RGB data, not a Delphi colour constant. Although in some places you can use constants like clBlack or clAqua in this instance that's not allowed. You create a colour for this property using the FRGB function:<br> <br> <code>Picture := TGLBitmap.Create;<br> Picture.UseTransparency := true;<br> Picture.TransparentColor := FRGB(0,0,255); // blue is our transparent colour<br> Picture.LoadFromFile("logo.png");</code><br> <br> Notice that you <i>must</i>set the transparency properties before loading the file. If you want you can use direct drawing by using a different constructor:<br> <br> <code>Picture := TGLBitmap.Create(GLCANVAS_BMP_DIRECT);</code><br> <br> However, this isn't really supported very well - for instance transparency doesn't work with this method. Also, it's slow so it's best to avoid this.<br> <br> <u>Drawing Text</u><br> <br> Again, OpenGL has no direct support for drawing text. There are many, many different ways of drawing text (for more information on this subject check out NeHe's excellent <a href="http://nehe.gamedev.net/opengl/">tutorial pages</a>) and the Canvas offers you two which should combine the best of both worlds - bitmapped text which looks nice at small sizes, and vector text which can be resized to any area needed without losing resolution. Vector fonts are drawn using the <a href="http://romka.demonews.com">GLF library</a>written by Romka, who is a seriously cool guy. You can get more fonts from his website.<br> <br> Bitmapped fonts are drawn using my own system that uses a 256x256 bitmap with letters arranged in a grid formation. Textured polygons are drawn that use this and this means <i>fast fast fast!</i><br> <br> This also means that fonts are very easy to make, although it does take some time. You can use the included "20x20grid.bmp" file to help you create new fonts. To use the text facility you can use the TGLText object. The reason that text is represented by objects too is for performance reasons, when you use an object something called pre-caching becomes available which stores the commands for drawing the text in the hardware accellerator itself, meaning - yep, you've guessed it, faster execution! Of course, if this isn't important to you it's possible to use the DrawString() command for simplicity but it's really designed to use an object. Here's a simple example of it:<br> <br> <code>var<br> Text1 :TGLText;<br> GLC :TGLCanvas;<br> <br> begin<br> Text1 := TGLText.Create("Arial");<br> Text1.SetColor(clYellow);<br> Text1.Text := "Hello World";<br> <br> GLC.DrawText(30,30,Text1);<br> end;</code><br> <br> As you can see, this is quite easy, but you can do more :) Text objects can have multiple lines (accessed through the Lines property), and of course this can be used to load text files. The demo program shows this in action. This uses textured quads to draw bitmapped text. To use the GLF vector based text:<br> <br> <code>var Text2: TGLText;<br> <br> begin<br> Text2 := TGLText.Create("Hello World","Arial",GLCANVAS_TEXT_GLF,GLC_DEFAULT_FONT_DATA);<br> // here we have used the other overloaded constructor to select GLF text. you can ignore<br> // the last parameter, it selects a font data array, the default one will do for now.<br> Text2.Size := 20;<br> GLC.DrawText(30,30,Text2);<br> end;</code><br> <br> How you add new fonts depends on the system you use. If you're drawing vector text you can simply download more GLF fonts from Romkas website but I'm not sure how you can make your own. Then you add the entry for it to the GLC_DEFAULT_FONT_DATA array as shown below. For bitmap text it's more complex (i'm afraid the canvas only comes with Arial and Courier New) but everything can be done using Paint Shop Pro or a similar program.<br> <br> To create a new bitmapped font:<br> <ol> <li>Create a new 256x256 bitmap with a black background</li> <li>Paste the "20x20 Grid.bmp" file over the top. This will show you where to place characters. If you want you can place the grid over the fonts that come with the canvas to see how it's done.</li> <li>For each character place the letter (in white) in each square aligned to the left of each grid square.</li> <li>Once this is done for every character (well, every character that is in the font set, you can see them in the other font grids) save it and change the GLCanvas.pas file in the following way:</li> <li>Add a new entry to the GLC_DEFAULT_FONT_DATA array. The fields are fairly self-explanatory, just make sure you set FontType to be GLCANVAS_TEXT_QUADTEXT.</li> <li>You also need to add a widths array to the QuadTextUnit.pas file. This array specifies the width of each character and is how the system support variable width fonts. See the code for examples of how to do this.</li> <li>Finally, you need to add an entry to the MatchFontWidths method of the TGLText class. This just returns the array given a font name.</li> <li>That's it! I know it's long winded, some time I may automate it but for now that's the way to do it. If you want to add some sort of exotic character not already in the font set add it to the array and set the rest of the widths in the other arrays to 0.</li> </ol> <br> <u>Drawing shapes</u><br> <br> You can draw rectangles using the Rectangle() method. This takes 4 coordinates, X1, X2, Y1 and Y2. It draws a rectangle based on the:<br> <br> <i>CurrentColor</i><br> <i>Solid</i><br> and <i>FillAlpha</i><br> <br> properties. If solid is true then the rectangle will be filled with the colour and at the opacity specified with FillAlpha. If solid is false then the outline is all that is drawn.<br> <br> <hr align="Left" width="100%" size="2"><br> Phew! Hopefully that clears up how to use the object. I hope you like it!<br> <br> This object was designed and built for the <a href="http://www.pythianproject.org/">Pythian Project</a><br> </div> </body> </html> --- NEW FILE --- PNG É0ØÚ¶n[Ùu` *¾v²í ôÅË7eQ5RmÖµ(fUµ~|Ü@>p×r¾èH ÔÃ@-dÐù¢ì'«ñhö£ïÄO#-ò$Ó,f`ÑÄJúÕCp¦3· P4M2 £-Ïàö´R,Î$F2»Ü«IØ,È $þÑt Òö %¬íú®kâͧNRßs8¯/> 6ÆàeQrJ ·v&R17¡Bôþ¼ú(æ;êp·¤*LLaÅGí<åW.ît|°(SKüüdêó2Ä!V&1ûô7&Ü xøì¯±ì¿éX)5¸Wë>13Õ³DÚ7õçñ]¦R ÑS%|È <:*7c¿N¦£]3XFÐlés8À'§n·µ-ÿüG+»§0£1̼'VÒ|XtWüªÏÌÀÎá~¿áXéèI/C,QBE²37ì K7§ÓñTTUIMpò¸õùísØõãjµ®¹)"!¾AáBa.¹eØ$EPÒO.¹¨¹ÿuâdç´Fð¦<¶}3^qPÚ¥Vù¼<dÆèÁîàyÈýíö7#X³ÕéÚ(g½ø=G¬eÁHb=¬oÞ¶9°åBÛ&d;÷ à?Y§2y2A^Á\Ñ0¸õ¨õÎápüù·¦&öO½z](âv `ÆÑøûoî?¬v»óåH¬Ql,¢ÍG ¦ÆRZuÌd=Ø_ L ¬yÃõç4z(O2^ÔCÅ"ÐoúN9$êÊÀX&ɨv(§Ï3ïa)N<ÚAOIþë~ úiOû#en§½ëðÄRÊðÎ!J`ÌÞßßg<¯5þ9Ã9Lúáqmç8tÿ-" q4&VÕè=EÎÁB·%¸ÝbIæWë5VÕjEÓI=à²Óð@BtFFKiTtqÜ|GR2Ç#Ï`g½Ü;óÄd×U/Z³¡IÕAs:\pklJÙ3óö¿ºÄ!>÷NÐyNìÿûÑÚÎöV¸Þf;ô<&ß°J=¯l¡Ò&¹ì$ÎGùéjÙòZµÎRZc2âùãFÞÏéÉÐïV¥Å#ßnEGóttбN«æÑüQPcR p²Û®6·¬ëc4Ø ""!¥uÇ·~ù%Ügö?Vý§ÓÄAíýõÉÕÉ ¹¾¿ò[ýÙÇÞx?Úпp¬HVÈ/ötáÈòhu:ÙnGÖ×au0 !öí$9SÒ¨Fí°YLe(vf³°3Eq£:#m´T²ÙÎæúòòæß¾4³N»FýíÿOkÞµºnZ%¥aàExÔ(YoybM\¹/oó18!A^ROjñZ»ÖIaZòþ/Ñ^Ë»q¦eK"c<ª¼Ì¯3ûQ9í Ñûî:mø®üé 3ÑàBÁ»ÝÞ¼*onn...àòÍ7Íãåååv»5¶µ¯Sý½¨*bVÒÖª+äùÜtcçpÚpîßçÄÛßi¢.ËYU¶m+ÍJ°mÝ«h·1Õ7åªæ¶+ÑGØê2µ#(kÜÀ"̳º«9°t2"èàÌ!ó²h%ÙlëíÖåPÈAIÝUn¤´EÙW#^éëØ³W/{$®ã£×zwÓÓ1è :0¹ ð§× L÷$.ÍnIükó|²x:ö(>9jJ'ÒÓÌi(gü¸dĤHC;¨þaqºé0B¼oê?h.cºº!<(ûN5½ÈQ$ñmÛív{qqiÇ®·&Ó°^¯·¸¬gÀäWú¾0 ð_º`¿ó þü窪ÒD¾¾~ýz>¯`¼X^ÿôîÉm[C¢ù¬¸¾¾¾¹¹YRÀdt§kUÛÕ[Õph)pr¦\Üá1rÂ-ÿf+1r&DÁ`Kíº»ñqhRðj.$©Ì4¡éÍ# µ`!Ò=X5³>±!^z.µ:ê% ñí$à)É3¥:O¿'°tîLå9ó£*VëZ ®ñÆÍ¶ ÷ÂÈ~ò)iha½ ¶¯·.Ö1.ÆÂäPòã"u» #÷dÊ6ö¸!Uæ5 'ªSÈóKNÉ¿üó?%®_ëíFï¬*,¬'%B/î´Í¨Âm± ñãããÏ?¿ ã|1{qscͲ`:0@z½^¯6; ƲZcʨ·.úÙSæ=ì¥y7$ܯѦ«çUy}¹¸}yµúp§d] þó·@o_}cÖ`¼SúÍoqç; ãζ%dyòÂ{{ÇBg^PE§üõøy6Å®`ú%ÛçKÝf[ò|W¤ðÑOÕñè%|r?ÝcÃ8Ò/Ù|ñï©öbØP¡]µñW±þÝ tÍÂbú?þóa=|¨îÞÎnr±Þà´ g73gi>//Q¢ò¸(ç˺én·ír9 h?B©d:bÌF (ï øöøªý¦7fGtwiåÀ}ãrÍá´Mnúøäí&1ðr]]½øððêæáýï¾ýïííË?¾¾Y.÷÷÷ål~÷°úëÿüiÛ ©DW»ÝnµÙt];ÇN 3Ã'l®_×ÖúùÆ9<Ç0)R~f!Çï¢×ãÒnÆ×îöq½ÝåϳÂ|Q iþª~"hß¶$ýV+Þ` WjÀR°®TKw«w·¸Þl~¹½¹®w._Þ@æ0B/¯¯U¹üþïÞþôËfÛ¼¿û [...1016 lines suppressed...] ÝÐ2ÕèEo;ô9i.Z_~d²!ðyéÇQùÕÃ_Û{Ñä·OBqzÆ÷`Æþ¼Ú(Ø|¿ú ì}W«VÉÙûï*þ&ìòµºË¾GXíHg'b3ÂÖÉ1bôïµÔ#hãàOÌs?bÚj1ËO;jÜ%_½'\ Z( áý{$qU³fÁ7H"áBÚ4mNV)_ãlìÖÆÁ-U0ÈêÜ_üPuùççg,ÊþðÜXöSòÇóï¿|ù´Ù,£°ô5,1I/>ùOezqÕC5u¶¾P4®Ý°èkîKê½5\eSd¨·Ê=W ½6¨°ã¯ÏO[ sþ"[~<̬kàùëtgêJ=ÀÁÈÅxtñß}§5Î@ÞIgØ5O ¼ ÓLC&Ë@µ´ô¸ÿÙ¢%~#Æ&¾¾¾îAé"Z&<0Ì(bdé;]@ØÒaËQÇQ ;¸&«4¸>XTe*_4_1e#M߯jC bPúbN¸Í/Øßȧf+ fªÔut'½øã±FÁÛÄÒ7#xIÖG÷ú]ì{&ZYIr¾*P¤K;) j°7£%/bB/ªýÕlÉ»a}¬}É\R ½ »^@Þë}!9~µ^j}£ä¤Ë÷½ë¦q6!'% _ÄuÔ±óB+dT0 çaóÛ50аYÂÅê]xÁ½§<5¹¶8V°RPЬóWg#dÔUpb*Ñ´ÿoþ<«ùÔ(6©Æx èC¥æOþúå3ªÐ/óü#oZýöäó§²1C7íPÑG ¿Eq üº -YLTÓq: R(A¯i9ºÆQú¨ôµf'/2ã¼Öú*óiïyøÑq¼ìQ.9ÝBôÁrX »f¾©þuóßæêÖêê DXÅ}²*úpL7ÐEXû¢Gµ=NBF¥´Çü¢$-ÿÂõð ½Ô|QAà~8®ñ Ä©ø]êüéÀ#n|9ÙQÒθ^"hcxFôÙ'c:ð¹Ô¨îÓÅÔ`Ní:¿7 «"×S!n×gã<áS©K4¶ iî$röí{_d*GE¡ÇNÆ¡áQGù)wxÐáSë®»÷ÕèßìBÅ[?8I°¨h- ç»qçþµî¨.5ÕØoS;7á&çÛSÿ~ dS<8K1¨·7I§¢ÔEºwrwbø¾xm°å ËvænÂ.¦[Rýù=?Þ!×7âº6®N Ã3A:ßY¶1Ð ùus<&¬Z²îS=iÇSàòdZ);jïLZm.8qçm}!*Õ°ãÍ"<Õ)\,,Þ5ÂAr@fÀê&'wÈSGܺÚÿþéò¥~üñG_Y¨XÃÍPRâIJ[6ØjM("k®Òrå67#Z}&írÍ`D©?*9ó+Ì0s~|oàC %°¡lðuFâ¥D .!+¥S2 ÛÁQjáT¡+¡ !BÇÃSA ˨D[¬Î*SQºzIèQ4üêû3úQ·çü`üYòͱÑ%ö¥@Q^Ü2Ößã'\9ɰWGÉK6G5&ï-{9X¥ ¼ëI^B¤Æñûgà8D¢eÌBkHAÂ÷©¯Ã]½»bUÙªÓuÑ¡z Cïë¦÷0ÉL6hÔ]¼¥!& À/òRdäð âz× ®¶<Ü ¤Ïâ":Ü.ì»{ñ;Ì÷1úpA~þÕ×÷ÞûZ°$5Þi Wy°èß3Àüì÷ÂôÁ#ñ»x×ÈúÉ|è3©sIÉ¡§E«7È<O4ÕK%Mü·ú;t ¶=Ëô§O¾_ÕOr÷±ÄébOÒ§È«×h¢ YSç???ó±Ù0«µ±okqRuâxÁYg*³Ã OÛyµBG×ÊKBÎmcrz'Êø&<Æ£Ëið(À¼yµ(´¾¸ÝµI Ë«=KÖ¿ÈafrBÖ7±z|Uz=÷¯Áò{¼QN.V[ îZ´êïå*BC±¡GJeÅÛ}EÒ»j6µ|Q?ÿÍõ1U¯ >³âêÉ(üTAUR]øàl´y?-ðíÝU婯$z×·pï!Eüê»7{ÿª%Ö7ì#ÎAgõî7úï#Ýî8ãö®þó½õºóä%EµØl->à$ôÍóÛõì» õ*U¤8¿/¥ xÏüøÜs¾ ¡hø½%°ùÔù¯üãWc }YéRvÈ¿aýöòòõé)ßÉÍmm>®íÂ9Ø¥ a£ÓM¤W³2P¬ùdd6'.¾"?¬ÅÁo Ï6L±Å¨$ÐðÂõU¸Áðû°|ð%A¡óÎU0és DéV0 T¹1|Rî:dùgth/®y°W´jygÿCÀÔð³]ZQCº½W¡[£¿$|Ûµ~§÷¦T!ÖA jL`Mùmß¾}ÁÅÅ8#¨s&dÇ/%¬w q©$ÏoNÄKúöí|{§®æÝiã]í\¾â·:.ðöîîÞ>u¾^ÎooÙ+H5ÓVTa½ÛK%W¹=ÙßlU.%èmôòZÉ@Ð ¢ÚDY 9Ç"ïÏT¦ð)ãõ-t[ã¾×G^bZ¦Ùïï)MS )Í?ç#`ë#OUPQ2zÍq>õêDlVDÏ<AzÍqÒá`=×jà 7Ç2ÂÙßÝÝ6Ïo'Òâ µNÂÇ¢ó55%±nzªpMï *âÖédÔYeB0Ç~qREýÍK+f·êoMø9égMWçzpçi´pÛ±9©©VÕ°×[JY>z<óêæá£1.DÎë9Btø¢7v}ÞDx'kUòÒ@E&sIBý ***** Bogus filespec: Arial ***** Bogus filespec: CourierNew Index: EngMain.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/EngMain.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** EngMain.pas 2000/11/04 22:07:47 1.1 --- EngMain.pas 2000/12/03 22:57:21 1.2 *************** *** 48,78 **** procedure CheckKeys; - - function Min(Val1,Val2: Single): Single; - begin - if (Val1 < Val2) then - Result := Val1 - else - Result := Val2; - end; - - const - BaseTurn = 10; - BaseStep = 0.1; - var - VA: TAngle3D; - Step,Turn: Single; begin - // This returns a vector pointing in the direction of the Camera - VA := Camera.AngleVector; - - // This code regulates the speed of movement such that the - // movement speed is independent of the frame rate - if TimeDiff > 0 then - Step := BaseStep * TimeDiff * 0.1 - else - Step := BaseStep; - Step := Min(Step,BaseStep*2); - Turn := BaseTurn * Step; if GetKeyState(vk_Escape) < 0 then --- 48,52 ---- *************** *** 81,100 **** end; - // These are the movements is each direction if GetKeyState(vk_Up) < 0 then // Up begin ! Camera.Move(+VA.X*Step,0,+VA.Z*Step); end; if GetKeyState(vk_Down) < 0 then // Down - begin - Camera.Move(-VA.X*Step,0,-VA.Z*Step); - end; - if GetKeyState(vk_Left) < 0 then // Left - begin - Camera.Rotate(0,-Turn,0); - end; - if GetKeyState(vk_Right) < 0 then // Right begin ! Camera.Rotate(0,+Turn,0); end; end; --- 55,67 ---- end; if GetKeyState(vk_Up) < 0 then // Up begin ! TextScroll := TextScroll - TextMovement; ! if TextScroll < 0 then TextScroll := 0; end; if GetKeyState(vk_Down) < 0 then // Down begin ! TextScroll := TextScroll + TextMovement; ! if TextScroll < 0 then TextScroll := 0; end; end; Index: MyDraw.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/MyDraw.pas,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** MyDraw.pas 2000/12/01 18:31:22 1.7 --- MyDraw.pas 2000/12/03 22:57:21 1.8 *************** *** 29,37 **** GLRC: hGLRC; GLC :TGLCanvas; ! InspectorGadget :TGLBitmap; ! SampleText :TGLText; ! QuadTextSample :TGLText; ! Text2 :TGLText; // You need to implement these three procedures procedure MyInit; --- 29,39 ---- GLRC: hGLRC; GLC :TGLCanvas; ! Scene :TGLBitmap; ! WelcomeText :TGLtext; ! VectorText :TGLText; + TextScroll :integer; + TextMovement:integer; + // You need to implement these three procedures procedure MyInit; *************** *** 48,95 **** // creates a canvas object with the width and height of the window; GLC := TGLCanvas.Create(Width,Height); ! InspectorGadget := TGLBitmap.Create(GLCANVAS_BMP_TEXTURED); ! InspectorGadget.UseTransparency := true; ! InspectorGadget.LoadFromBitmap('rpg.png'); ! ! SampleText := TGLText.Create('Hello World', 'Arial', GLCANVAS_TEXT_GLF, GLC_DEFAULT_FONT_DATA); ! SampleText.Precache := true; ! ! Sampletext.Lines.Add('Long live the Project'); ! SampleText.Lines.Add('These are lines of text drawn by the GLCanvas in GLF mode'); ! ! QuadTextSample := TGLText.Create('This is a sample of QuadText drawing.','Arial',GLCANVAS_TEXT_QUADTEXT,GLC_DEFAULT_FONT_DATA); ! QuadTextSample.Lines.Add('Compare to the GLF drawing and see which is better at small sizes.'); ! QuadTextSample.SetColor(clGreen); ! ! {SampleText.Lines.Add('----------------------------'); ! SampleText.Lines.Add('ABCDEFGHIJKLMNOPQRSTUVWXYZ'); ! SampleText.Lines.Add('1234567890'); ! SampleText.Lines.Add('-----------------------------'); ! SampleText.Lines.Add('You know, the problem with GLF is that'); ! SampleText.Lines.Add('it doesn''t display small text sizes very well'); ! SampleText.Lines.Add('Also, I have this really wierd bug - if text is'); ! SampleText.Lines.Add('drawn below 11 pixels a total lockup happens'); ! SampleText.Lines.Add('on my machine. Wierd or what?'); ! SampleText.Lines.Add('============================='); ! SampleText.Lines.Add('askldfjkasdjgkljgklfjakgljdfklgjkldfjgkldsfjgksd'); ! SampleText.Lines.Add('akdsjfkadsjfkdjg h,gmhgfopowt ajkdf asdjghrtjlkf;d'); ! SampleText.Lines.Add('i just want lots of text dwtasdgfdhfdhadfhfdafhfdh'); ! SampleText.Lines.Add('ajjjjjjfdkajskdfjdkjalksertujireooeiaudklfakjgdkas'); ! SampleText.Lines.Add('kfldqpptioreptQUITRJAKSjkdlsakjdbtathylayklt=-29'); ! SampleText.Lines.Add('askldfjkasdjgkljgklfjakgljdfklgjkldfjgkldsfjgksd'); ! SampleText.Lines.Add('akdsjfkadsjfkdjg h,gmhgfopowt ajkdf asdjghrtjlkf;d'); ! SampleText.Lines.Add('i just want lots of text dwtasdgfdhfdhadfhfdafhfdh'); ! SampleText.Lines.Add('ajjjjjjfdkajskdfjdkjalksertujireooeiaudklfakjgdkas'); ! SampleText.Lines.Add('kfldqpptioreptQUITRJAKSjkdlsakjdbtathylayklt=-29'); ! SampleText.Lines.Add('askldfjkasdjgkljgklfjakgljdfklgjkldfjgkldsfjgksd'); ! SampleText.Lines.Add('akdsjfkadsjfkdjg h,gmhgfopowt ajkdf asdjghrtjlkf;d'); ! SampleText.Lines.Add('i just want lots of text dwtasdgfdhfdhadfhfdafhfdh'); ! SampleText.Lines.Add('ajjjjjjfdkajskdfjdkjalksertujireooeiaudklfakjgdkas'); ! SampleText.Lines.Add('kfldqpptioreptQUITRJAKSjkdlsakjdbtathylayklt=-29');} ! ! SampleText.SetColor(clYellow); ! SampleText.Size := 10.0; ! Text2 := TGLText.Create('Test2','Arial',GLCANVAS_TEXT_QUADTEXT,GLC_DEFAULT_FONT_DATA); end; --- 50,67 ---- // creates a canvas object with the width and height of the window; GLC := TGLCanvas.Create(Width,Height); ! Scene := TGLBitmap.Create(GLCANVAS_BMP_TEXTURED); ! Scene.UseTransparency := true; ! Scene.LoadFromBitmap('Scene.png'); ! ! WelcomeText := TGLText.Create('','Arial',GLCANVAS_TEXT_QUADTEXT,GLC_DEFAULT_FONT_DATA); ! WelcomeText.Precache := true; ! WelcomeText.Lines.LoadFromFile('data.txt'); ! ! VectorText := TGLText.Create('GLCanvas Demo','Arial',GLCANVAS_TEXT_GLF,GLC_DEFAULT_FONT_DATA); ! VectorText.SetColor(clBlack); ! VectorText.Size := 30; ! TextScroll := 0; ! TextMovement := 2; end; *************** *** 97,104 **** begin // Free all your objects here ! InspectorGadget.Free; ! SampleText.Free; ! QuadTextSample.Free; ! Text2.Free; GLC.Free; end; --- 69,73 ---- begin // Free all your objects here ! Scene.Free; GLC.Free; end; *************** *** 124,144 **** // this draws the GL bitmap object at these coordinates ! // draw the RPG system part of the bmp ! //GLC.DrawBitmapEx(20,80,256,44,55,272,InspectorGadget); ! GLC.DrawBitmap(100,250,InspectorGadget); ! GLC.DrawBitmap(20,80,InspectorGadget); ! ! GLC.DrawText(100,100,Text2); ! // this draws the text objects ! GLC.DrawText(25,400,QuadTextSample); ! GLC.DrawText(25,100,SampleText); // this draws a rectangle ! GLC.CurrentRed := 1; ! GLC.CurrentBlue := 1; ! GLC.CurrentGreen := 1; ! GLC.FillAlpha := 0.5; ! GLC.Solid := true; ! GLC.Rectangle(300,40,400,100); end; --- 93,114 ---- // this draws the GL bitmap object at these coordinates ! // draw the pretty scene here ! GLC.DrawBitmap(0,26,Scene); // this draws a rectangle ! GLC.CurrentColor := clBlue; ! GLC.FillAlpha := 0.3; // we want 30% opacity ! GLC.Solid := true; // we want it solid ! GLC.Rectangle(350,240,620,460); // now draw it here! ! // now draw its border ! GLC.Solid := false; ! GLC.Rectangle(350,240,620,460); ! ! GLC.SetClipping(350,240,620,455); // set the clipping rect to the blue box ! GLC.DrawText(355,245-TextScroll,WelcomeText); ! GLC.CancelClipping; ! ! // now draw the logo text ! GLC.DrawText(200,70,VectorText); end; Index: QuadTextUnit.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/QuadTextUnit.pas,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** QuadTextUnit.pas 2000/11/26 20:30:04 1.2 --- QuadTextUnit.pas 2000/12/03 22:57:21 1.3 *************** *** 15,19 **** const ! NUMCHARS = 69; type --- 15,19 ---- const ! NUMCHARS = 85; type *************** *** 27,31 **** 'k','l','m','n','o','p','q','r','s','t','u','v', 'w','x','y','z','1','2','3','4','5','6','7','8', ! '9','0','!','"','?','.','''','(',')'); COURIERNEW_WIDTHS :TQuadTextWidthsArray = ( --- 27,33 ---- 'k','l','m','n','o','p','q','r','s','t','u','v', 'w','x','y','z','1','2','3','4','5','6','7','8', ! '9','0','!','"','?','.','''','(',')',',','£','$', ! '&','=','+','-','<','>',':',';','/','\','#','@', ! '¯'); COURIERNEW_WIDTHS :TQuadTextWidthsArray = ( *************** *** 35,39 **** 8, 3, 12, 8, 8, 8, 8, 5, 8, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, ! 8, 8, 4, 6, 7, 2, 2, 3, 3); ARIAL_WIDTHS :TQuadTextWidthsArray = ( 9, 10, 10, 10, 10, 9, 10, 10, 2, 9, 10, 9, --- 37,43 ---- 8, 3, 12, 8, 8, 8, 8, 5, 8, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, ! 8, 8, 4, 6, 7, 2, 2, 3, 3, 3, 6, 6, ! 6, 8, 7, 7, 8, 8, 2, 3, 6, 6, 8, 7, ! 20); ARIAL_WIDTHS :TQuadTextWidthsArray = ( 9, 10, 10, 10, 10, 9, 10, 10, 2, 9, 10, 9, *************** *** 42,46 **** 8, 2, 12, 8, 8, 8, 8, 5, 8, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, ! 12, 8, 4, 6, 7, 2, 2, 3, 3); type TQuadText = record --- 46,52 ---- 8, 2, 12, 8, 8, 8, 8, 5, 8, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, ! 12, 8, 4, 6, 7, 2, 2, 3, 3, 2, 13, 14, ! 12, 5, 7, 2, 8, 8, 2, 2, 4, 4, 12, 15, ! 15); type TQuadText = record Index: glCanvas.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GLCanvas/glCanvas.pas,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** glCanvas.pas 2000/12/01 18:31:22 1.7 --- glCanvas.pas 2000/12/03 22:57:21 1.8 *************** *** 155,159 **** property TexData :TTexBMPData read FTexData; ! constructor Create(aType:integer); destructor Destroy; override ; function BitmapToPixData(B :TFastDIB):pointer; --- 155,160 ---- property TexData :TTexBMPData read FTexData; ! constructor Create(aType:integer); overload ; ! constructor Create; overload; destructor Destroy; override ; function BitmapToPixData(B :TFastDIB):pointer; *************** *** 197,200 **** --- 198,202 ---- function MatchFontWidths(f:TGLCanvasFontData):TQuadTextWidthsArray; + procedure LinesOnChange(Sender:TObject); public *************** *** 219,223 **** property DisplayList :integer read FDisplayList; ! constructor Create(aText, aFontName:string; aPreferredTextType:integer; FontData:TArrayOfGLCanvasFontData); destructor Destroy; override ; procedure Draw; virtual ; --- 221,226 ---- property DisplayList :integer read FDisplayList; ! constructor Create(aText, aFontName:string; aPreferredTextType:integer; FontData:TArrayOfGLCanvasFontData); overload; ! constructor Create(aFontName:string); overload; // auto creates with no text, and quadtext selected destructor Destroy; override ; procedure Draw; virtual ; *************** *** 256,259 **** --- 259,265 ---- procedure DrawBitmap(X,Y:integer; bmp:TGLBitmap); virtual ; + // other + procedure SetClipping(Left,Top,Right,Bottom:integer); + procedure CancelClipping; // text routines here *************** *** 263,267 **** // shape routines here - will standardise on the american spelling of colo(u)r - procedure Rectangle(Left, Top, Right, Bottom:integer); virtual ; end; --- 269,272 ---- *************** *** 377,387 **** function TGLBitmap.LoadFromBitmap(B: TBitmap): integer; - type - TBArray = array[Word] of byte; - PBarray = ^TBArray; var tmpdib:TFastDIB; ! x,y:integer; ! scanline :PBarray; begin // load into a TFastDIB --- 382,388 ---- function TGLBitmap.LoadFromBitmap(B: TBitmap): integer; var tmpdib:TFastDIB; ! y:integer; begin // load into a TFastDIB *************** *** 397,400 **** --- 398,407 ---- LoadFromBitmap(tmpDib); tmpDib.Free; + Result := 0; + end; + + constructor TGLBitmap.Create; + begin + Create(GLCANVAS_BMP_TEXTURED); end; *************** *** 551,554 **** --- 558,572 ---- end; + procedure TGLCanvas.CancelClipping; + begin + glDisable(GL_SCISSOR_TEST); + end; + + procedure TGLCanvas.SetClipping(Left, Top, Right, Bottom: integer); + begin + glEnable(GL_SCISSOR_TEST); + glScissor(Left,Height-Bottom,Right-Left,Bottom-Top); + end; + { TGLText } *************** *** 561,564 **** --- 579,583 ---- FLines.Text := aText; FDisplayList := -1; + Lines.OnChange := LinesOnChange; TextType := aPreferredTextType; FFontName := aFontName; *************** *** 571,574 **** --- 590,598 ---- end; + constructor TGLText.Create(aFontName: string); + begin + Create('',aFontName,GLCANVAS_TEXT_QUADTEXT,GLC_DEFAULT_FONT_DATA); + end; + destructor TGLText.Destroy; begin *************** *** 622,625 **** --- 646,654 ---- end; + procedure TGLText.LinesOnChange(Sender: TObject); + begin + if Precache then UpdateDisplayList; + end; + procedure TGLText.LoadFont; var f:TGLCanvasFontData; *************** *** 745,749 **** x,y:integer; r:TRect; - id:Cardinal; t:TTexture; ac:TByteColor; --- 774,777 ---- *************** *** 753,758 **** buffer := nil; - t := nil; - Result.cellsWidth := cellsX; Result.cellsHeight := cellsY; --- 781,784 ---- --- RPG.png DELETED --- --- gadgetcollage.bmp DELETED --- |
From: Michael H. <mh...@us...> - 2000-12-01 18:35:00
|
Update of /cvsroot/pythianproject/PythianProject/Source/Units In directory slayer.i.sourceforge.net:/tmp/cvs-serv7247 Modified Files: Textures.pas Log Message: rearranged code. now supports PNG loading, FastDIB loading and TBitmap loading Index: Textures.pas =================================================================== RCS file: /cvsroot/pythianproject/PythianProject/Source/Units/Textures.pas,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** Textures.pas 2000/11/20 20:38:57 1.8 --- Textures.pas 2000/12/01 18:34:56 1.9 *************** *** 22,25 **** --- 22,26 ---- + // -Can load data from a TBitmap, a TFastDIB, a BMP file (direct), or a PNG file (untested) // -Checks if it is a bitmap. // -Gets bitmap size from offset $12. *************** *** 36,40 **** interface ! uses BaseObjects, OpenGL, Points, TaggedStreams; type --- 37,42 ---- interface ! uses BaseObjects, OpenGL, Points, TaggedStreams, ! FastDIB, FastFiles, PNGImage, SysUtils, Graphics; // added -mike type *************** *** 42,45 **** --- 44,51 ---- PTextureData = ^TTextureData; + // we use this to store the pixel data from a bitmap -mike + TPixelData = TByteArray; + PPixelData = ^TPixelData; + TBitDepth = (bd16bits, bd24bits, bd32bits); *************** *** 60,63 **** --- 66,71 ---- procedure SetUseAlpha(const Value: Boolean); procedure SetBitDepth(const Value: TBitDepth); + + procedure GenTexFromBMP(BMP:TFastDIB; useTransparency:boolean; transparentColor:TFColor); public constructor Create; override; *************** *** 67,70 **** --- 75,80 ---- procedure LoadFromFile(const FileName: string); override; procedure LoadFromStream(Stream: TTaggedStream); override; + procedure LoadFromBitmap(B:TFastDIB); overload; + procedure LoadFromBitmap(B:Graphics.TBitmap); overload ; property AlphaColor: TByteColor read FAlphaColor write SetAlphaColor; *************** *** 76,80 **** property UseMipmaps: Boolean read FUseMipmaps write SetMipmap; property Width: Integer read FWidth; ! property TexID: TGLuInt read FTexID; end; --- 86,90 ---- property UseMipmaps: Boolean read FUseMipmaps write SetMipmap; property Width: Integer read FWidth; ! property TexID: TGLuInt read FTexID write FTexID; end; *************** *** 83,87 **** implementation ! uses Windows, SysUtils, Profiler; var --- 93,97 ---- implementation ! uses Windows, Profiler; var *************** *** 314,320 **** var TestColor: TByteColor; // Main loader routine: begin ! // Result := False; // Try to open file --- 324,341 ---- var TestColor: TByteColor; + Picture :TPicture; // Main loader routine: begin ! ! // decide whether file is a bitmap (open directly) ! // or a PNG image (open using a TPicture) ! if ExtractFileExt(FileName) = '.png' then ! begin ! Picture := TPicture.Create; ! Picture.LoadFromFile(FileName); ! LoadFromBitmap(Picture.Bitmap); ! Picture.Free; ! exit; ! end; // Try to open file *************** *** 404,407 **** --- 425,516 ---- FUseAlpha := Value; end; + + procedure TTexture.GenTexFromBMP(BMP: TFastDIB; + useTransparency: boolean; transparentColor: TFColor); + var + pd :PPixelData; + x,y:integer; + c:TFColor; + pxWidth, pxHeight,os:integer; + + function XYToOffset(ox,oy:integer):integer; + var pxoffset:integer; + begin + { + 0 1 2 3 4 5 6 7 8 9 PxWidth=10 + 0 X X X X X X X X X X PxHeight=3 + 1 X X X X X X X X X X + 2 X X X X X X X X X X } + oy := (PxHeight-1) - oy; // now y is OK + pxoffset := ox; + if oy > 0 then + begin + pxoffset := pxoffset + (oy*(PxWidth){-1}) {+ 1}; + end; + pxoffset := pxoffset * 4; // move into position for RGBA data + Result := pxoffset; + end; + + begin + if bmp.Bpp <> 24 then raise Exception.Create('TTexture.GenTexFromBMP: Don''t support non 24bit pixel formats! (image is '+IntToStr(bmp.bpp)+')'); + pxWidth := bmp.Width; + pxHeight := bmp.Height; + // allocate memory for it, assume RGBA data (4 components) + pd := AllocMem( (bmp.Width*bmp.Height)*4 ); + for y := 0 to pxHeight-1 do + begin + for x := 0 to pxWidth-1 do + begin + c := bmp.Pixels24[y,x]; + os := XYToOffset(x,y); + + pd^[ os + 0 ] := c.r; + pd^[ os + 1 ] := c.g; + pd^[ os + 2 ] := c.b; + // alpha transparency here + if useTransparency = false then + pd^[ os + 3 ] := 255 + else if (c.r = transparentColor.r) and + (c.g = transparentColor.g) and + (c.b = transparentColor.b) then + pd^[ os + 3 ] := 0 else pd^[ os + 3 ] := 255; + end; + end; + + // now we have pixel data generate the texture + Pointer(FImage) := pd; + FWidth := bmp.Width; + FHeight := bmp.Height; + Initialize; + end; + + procedure TTexture.LoadFromBitmap(B: TFastDIB); + begin + GenTexFromBMP(B,FUseAlpha,FRGB(FAlphaColor[0],FAlphaColor[1],FAlphaColor[2])); + end; + + procedure TTexture.LoadFromBitmap(B: Graphics.TBitmap); + type + TBArray = array[Word] of byte; + PBarray = ^TBArray; + var + tmpdib:TFastDIB; + x,y:integer; + scanline :PBarray; + begin + // load into a TFastDIB + tmpdib := TFastDIB.Create; + case b.PixelFormat of + pf8bit:tmpdib.SetSize(b.width,b.height,8,0); + pf16bit:tmpdib.SetSize(b.width,b.height,16,0); + pf24bit:tmpdib.SetSize(b.width,b.height,24,0); + end; + + for y := 0 to B.Height-1 do + CopyMemory(tmpDib.Scanlines[y],b.ScanLine[y],(b.width*tmpdib.bpp) div 8); + LoadFromBitmap(tmpDib); + tmpDib.Free; + end; + end. |