From: Michael H. <mh...@us...> - 2001-01-12 21:10:11
|
Update of /cvsroot/pythianproject/Prototypes/GUISystem In directory usw-pr-cvs1:/tmp/cvs-serv10022/GUISystem Modified Files: StartupForm.pas VGLDemo1.dpr skin1.png vglClasses.pas vglStdCtrls.pas Added Files: vglConversation.pas Log Message: antialiased text, resized SLE, added vglConversation.pas -mike --- NEW FILE --- unit vglConversation; interface uses Windows,classes,Graphics,SysUtils, vglClasses,vglStdCtrls, glCanvas; const VGL_SKINRECT_NLEFT = 135; VGL_SKINRECT_NTOP = 50; VGL_SKINRECT_1 :TRect = (Left:VGL_SKINRECT_NLEFT; Top:VGL_SKINRECT_NTOP; Right:VGL_SKINRECT_NLEFT+22;Bottom:VGL_SKINRECT_NTOP+20); VGL_SKINRECT_2 :TRect = (Left:VGL_SKINRECT_NLEFT; Top:VGL_SKINRECT_NTOP+19;Right:VGL_SKINRECT_NLEFT+22;Bottom:VGL_SKINRECT_NTOP+(19*2)); type TvglConvOptionsPicker = class(TvglComponent) protected FOptions: TStringList; FImage :TGLBitmap; FText :TGLText; FAutoResize: boolean; function GetComponentType:string; override ; procedure DrawNumber(num,left,top:integer); procedure OnOptionsChange(Sender:TObject); procedure Update(const ElapsedTime: Cardinal); override ; procedure DoOnKeyDown(KeyCode, KeyData: Integer; KBMod: TVGLKBModifiers; var AllowHP: Boolean); override; // for focused obj only procedure SelectOption(num:integer); public property Options :TStringList read FOptions write FOptions; property AutoResize :boolean read FAutoResize write FAutoResize; constructor Create(aName:string; aOwner:TvglComponent); destructor Destroy; override ; procedure DrawSelf(where:TRect); override ; end; implementation { TvglConvOptionsPicker } constructor TvglConvOptionsPicker.Create(aName: string; aOwner: TvglComponent); begin inherited Create(aName,aOwner); FOptions := TStringList.Create; FOptions.OnChange := OnOptionsChange; FImage := TGLBitmap(Manager.GetResource(VGL_SKIN_1)); FText := TGLText.Create('VinerHand ITC'); FText.SetColor(clBlack); FAutoResize := true; end; destructor TvglConvOptionsPicker.Destroy; begin FOptions.Free; FText.Free; inherited; end; procedure TvglConvOptionsPicker.DoOnKeyDown(KeyCode, KeyData: Integer; KBMod: TVGLKBModifiers; var AllowHP: Boolean); begin case KeyCode of Ord('1') :SelectOption(1); Ord('2') :SelectOption(2); Ord('3') :SelectOption(3); Ord('4') :SelectOption(4); Ord('5') :SelectOption(5); Ord('6') :SelectOption(6); Ord('7') :SelectOption(7); Ord('8') :SelectOption(8); Ord('9') :SelectOption(9); end; end; procedure TvglConvOptionsPicker.DrawNumber(num, left, top: integer); begin case num of 1 :Canvas.DrawBitmapSubRect(left,top,VGL_SKINRECT_1,FImage); 2 :Canvas.DrawBitmapSubRect(left,top,VGL_SKINRECT_2,FImage); { 3 :Canvas.DrawBitmapSubRect(left,top,VGL_SKINRECT_3,FImage); 4 :Canvas.DrawBitmapSubRect(left,top,VGL_SKINRECT_4,FImage); 5 :Canvas.DrawBitmapSubRect(left,top,VGL_SKINRECT_5,FImage); 6 :Canvas.DrawBitmapSubRect(left,top,VGL_SKINRECT_6,FImage); 7 :Canvas.DrawBitmapSubRect(left,top,VGL_SKINRECT_7,FImage); 8 :Canvas.DrawBitmapSubRect(left,top,VGL_SKINRECT_8,FImage); 9 :Canvas.DrawBitmapSubRect(left,top,VGL_SKINRECT_9,FImage); } end; end; procedure TvglConvOptionsPicker.DrawSelf(where: TRect); var i:integer; begin Canvas.CurrentColor := clBlue; Canvas.Solid := false; Canvas.Rectangle(where.left,where.top,where.right,where.bottom+5); Canvas.Solid := true; Canvas.Rectangle(where.left,where.top,where.right,where.bottom+5); // display options for i := 0 to FOptions.Count-1 do begin // DrawNumber(i+1,where.left,where.top+i*22); Canvas.DrawTextLine(where.left+10,where.top+i*20,i,FText); end; end; function TvglConvOptionsPicker.GetComponentType: string; begin Result := 'ConvOptionsPicker'; end; procedure TvglConvOptionsPicker.OnOptionsChange(Sender: TObject); var i:integer; begin // update the text object and possibly resize here FText.Lines.Assign(FOptions); // add option numbers for i := 0 to FText.Lines.Count-1 do begin FText.Lines[i] := '|'+IntToStr(i+1)+'| '+ FText.Lines[i]; end; if FautoResize then Height := FText.Height; end; procedure TvglConvOptionsPicker.SelectOption(num: integer); begin // TODO end; procedure TvglConvOptionsPicker.Update(const ElapsedTime: Cardinal); begin inherited Update(ElapsedTime); end; end. Index: StartupForm.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/StartupForm.pas,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** StartupForm.pas 2001/01/07 16:19:27 1.14 --- StartupForm.pas 2001/01/12 21:10:35 1.15 *************** *** 9,13 **** uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ! StdCtrls, GLForms, GLCanvas, OpenGL, vglClasses, vglStdCtrls, vglEdits; type --- 9,14 ---- uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ! StdCtrls, GLForms, GLCanvas, OpenGL, vglClasses, vglStdCtrls, vglEdits, ! vglConversation; type *************** *** 18,21 **** --- 19,29 ---- private { Private declarations } + + MultiPage :TvglMultiPage; + SelectTestPage :TvglTextbox; + SelectConvPage :TvglTextbox; + + // test page + TestPage :TvglPage; c:TvglComponent; Image1:TvglDraggableImage; *************** *** 28,33 **** cc: TvglComponent; SLE :TvglSingleLineEdit; - DragBox :TvglDragBox; Elapsed,FirstTime:Cardinal; --- 36,43 ---- cc: TvglComponent; SLE :TvglSingleLineEdit; DragBox :TvglDragBox; + // conversation engine page + ConvPage :TvglPage; + ConvOptions :TvglConvOptionsPicker; Elapsed,FirstTime:Cardinal; *************** *** 51,54 **** --- 61,65 ---- procedure DragBoxOnDragOver(what:TvglDragObject; var Accept:boolean); procedure DragBoxOnDragDrop(what:TvglDragObject); + procedure SelectPage(Sender:TObject); procedure go; *************** *** 166,170 **** else GLC := TGLCanvas.Create(638,478); Wallpaper := TGLBitmap.Create; ! Wallpaper.LoadFromBitmap('..\GLCanvas\scene.png'); if GLForm.FullScreen then --- 177,185 ---- else GLC := TGLCanvas.Create(638,478); Wallpaper := TGLBitmap.Create; ! {$IFDEF DEVELOPMENT} ! Wallpaper.LoadFromBitmap('..\GLCanvas\scene.png'); ! {$ELSE} ! Wallpaper.LoadFromBitmap('scene.png'); ! {$ENDIF} if GLForm.FullScreen then *************** *** 175,179 **** // create test components ! Panel1 := TvglPanel.Create('Panel1',InterfaceManager.Desktop); Panel1.Bounds := Rect(10,30,460,400); Panel1.Textured := true; --- 190,218 ---- // create test components ! ! MultiPage := TvglMultipage.Create('Pages',InterfaceManager.Desktop); ! MultiPage.Bounds := InterfaceManager.Desktop.Bounds; ! MultiPage.Bounds := Rect(MultiPage.Bounds.Left,MultiPage.Bounds.Top +15,MultiPage.Bounds.Right,MultiPage.Bounds.Bottom); ! TestPage := MultiPage.AddPage; ! ConvPage := MultiPage.AddPage; ! MultiPage.CurrentPage := TestPage; ! ! SelectTestPage := TvglTextBox.Create('SelectTestPage',InterfaceManager.Desktop); ! SelectTestPage.Bounds := Rect(0,30,0,0); ! SelectTestPage.AutoSize := true; ! SelectTestPage.Lines.Add('|Test page|'); ! SelectTestPage.OnClick := SelectPage; ! SelectTestPage.Color := clBlue; ! ! SelectConvPage := TvglTextBox.Create('SelectConvPage',InterfaceManager.Desktop); ! SelectConvPage.Bounds := Rect(100,30,0,0); ! SelectConvPage.AutoSize := true; ! SelectConvPage.Lines.Add('|Conversation page|'); ! SelectConvPage.OnClick := SelectPage; ! SelectConvPage.Color := clBlue; ! ! ! // test page ! Panel1 := TvglPanel.Create('Panel1',TestPage); Panel1.Bounds := Rect(10,30,460,400); Panel1.Textured := true; *************** *** 191,200 **** c.Cached := True; } ! Image1 := TvglDraggableImage.Create('Image1',InterfaceManager.Desktop); Image1.LoadImage('olog.png'); Image1.Bounds := Rect(500,20,0,0); Image1.Cached := True; ! CB := TvglCheckBox.Create('CheckBox1', InterfaceManager.Desktop); CB.Left := 20; CB.Top := 210; --- 230,239 ---- c.Cached := True; } ! Image1 := TvglDraggableImage.Create('Image1',TestPage); Image1.LoadImage('olog.png'); Image1.Bounds := Rect(500,20,0,0); Image1.Cached := True; ! CB := TvglCheckBox.Create('CheckBox1', TestPage); CB.Left := 20; CB.Top := 210; *************** *** 202,206 **** CB.Checked := True; CB.Color := clBlack; ! CB.Caption := 'This is a checkbox'; CB.OnChanged := CB1OnChange; CB.Text.FontName := 'VinerHand ITC'; --- 241,245 ---- CB.Checked := True; CB.Color := clBlack; ! CB.Caption := 'Checkbox'; CB.OnChanged := CB1OnChange; CB.Text.FontName := 'VinerHand ITC'; *************** *** 215,219 **** Button.HasHotkey := True; ! Label1 := TvglTextBox.Create('Label1',InterfaceManager.Desktop); Label1.Top := 220; Label1.Left := 468; --- 254,258 ---- Button.HasHotkey := True; ! Label1 := TvglTextBox.Create('Label1',TestPage); Label1.Top := 220; Label1.Left := 468; *************** *** 222,226 **** Label1.Caption := 'FOCUS LOST!'; ! SB := TvglScrollBar.Create('ScrollBar1', InterfaceManager.Desktop); SB.Kind := sbHorizontal; SB.Left := 60; --- 261,265 ---- Label1.Caption := 'FOCUS LOST!'; ! SB := TvglScrollBar.Create('ScrollBar1', TestPage); SB.Kind := sbHorizontal; SB.Left := 60; *************** *** 235,239 **** SB.Cached := True; ! LB := TvglSimpleListBox.Create('SimpleListBoxTest', InterfaceManager.Desktop); LB.Items.BeginUpdate; LB.Items.Clear; --- 274,278 ---- SB.Cached := True; ! LB := TvglSimpleListBox.Create('SimpleListBoxTest', TestPage); LB.Items.BeginUpdate; LB.Items.Clear; *************** *** 255,268 **** Edit1.Bounds := Rect(20,300,220,400); Edit1.Lines.Add('Hello World 1'); ! Edit1.Lines.Add('Hello World 2'); } ! // SLE := TvglSingleLineEdit.Create('SLE1',InterfaceManager.Desktop); ! // SLE.Bounds := Rect(20,300,220,400); ! DragBox := TvglDragBox.Create('DragBox1',InterfaceManager.Desktop); ! DragBox.Bounds := Rect(500,400,550,450); DragBox.OnDragOver := DragBoxOnDragOver; DragBox.OnDragDrop := DragBoxOnDragDrop; DragBox.Cached := True; InterfaceManager.SetNewFocus(LB); Hide; --- 294,316 ---- Edit1.Bounds := Rect(20,300,220,400); Edit1.Lines.Add('Hello World 1'); ! Edit1.Lines.Add('Hello World 2'); ! Edit1.Text.FontName := 'VinerHand ITC'; } ! SLE := TvglSingleLineEdit.Create('SLE1',TestPage); ! SLE.Bounds := Rect(20,300,420,320); ! SLE.FontName := 'VinerHand ITC'; ! DragBox := TvglDragBox.Create('DragBox1',TestPage); ! DragBox.Bounds := Rect(500,350,550,400); DragBox.OnDragOver := DragBoxOnDragOver; DragBox.OnDragDrop := DragBoxOnDragDrop; DragBox.Cached := True; + // now for conversation engine mockups + ConvOptions := TvglConvOptionsPicker.Create('OptionsPicker',ConvPage); + ConvOptions.Bounds := Rect(10,60,630,200); + ConvOptions.Options.Add('Hello World!'); + ConvOptions.Options.Add('Second option'); + + InterfaceManager.SetNewFocus(LB); Hide; *************** *** 314,317 **** --- 362,373 ---- begin InterfaceManager.VGLAlert('You dropped object ['+what.from.Name+'] onto the draggable box! ABCDEFGHIJKLIMNOPQRSTUVWXYZ - this is a test message to force auto alert resizing'); + end; + + procedure TfrmStartup.SelectPage(Sender: TObject); + begin + if Sender = SelectTestPage then + MultiPage.CurrentPage := TestPage + else if Sender = SelectConvPage then + MultiPage.CurrentPage := ConvPage; end; Index: VGLDemo1.dpr =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/VGLDemo1.dpr,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** VGLDemo1.dpr 2000/12/11 19:15:12 1.2 --- VGLDemo1.dpr 2001/01/12 21:10:35 1.3 *************** *** 3,7 **** uses Forms, ! StartupForm in 'StartupForm.pas' {frmStartup}; {$R *.RES} --- 3,8 ---- uses Forms, ! StartupForm in 'StartupForm.pas' {frmStartup}, ! vglConversation in 'vglConversation.pas'; {$R *.RES} Index: skin1.png =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/skin1.png,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 Binary files /tmp/cvsSiW77g and /tmp/cvsAHyIIn differ Index: vglClasses.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/vglClasses.pas,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** vglClasses.pas 2001/01/07 16:19:27 1.12 --- vglClasses.pas 2001/01/12 21:10:35 1.13 *************** *** 398,404 **** TvglPanel = class(TvglComponent) protected - //FTextured: boolean; FColor: TColor; FTexture :TGLBitmap; procedure SetColor(const Value: TColor); function GetComponentType:string; override; --- 398,404 ---- TvglPanel = class(TvglComponent) protected FColor: TColor; FTexture :TGLBitmap; + FStyleShown: boolean; procedure SetColor(const Value: TColor); function GetComponentType:string; override; *************** *** 407,411 **** public property Color :TColor read FColor write SetColor; ! //property Textured :boolean read FTextured write FTextured; constructor Create(aName:string; AOwner:TvglComponent); --- 407,411 ---- public property Color :TColor read FColor write SetColor; ! property StyleShown :boolean read FStyleShown write FStyleShown; constructor Create(aName:string; AOwner:TvglComponent); *************** *** 1477,1480 **** --- 1477,1481 ---- inherited Create(aName,AOwner); Color := clBlue; + StyleShown := true; Textured := false; FFocusable := False; *************** *** 1493,1496 **** --- 1494,1499 ---- begin inherited DrawSelf(where); + if not StyleShown then exit; + if Textured then begin Index: vglStdCtrls.pas =================================================================== RCS file: /cvsroot/pythianproject/Prototypes/GUISystem/vglStdCtrls.pas,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** vglStdCtrls.pas 2001/01/07 16:19:27 1.11 --- vglStdCtrls.pas 2001/01/12 21:10:35 1.12 *************** *** 36,40 **** interface ! uses Windows, GLCanvas, Classes, vglClasses, Graphics, SysUtils{, Trace}; const --- 36,40 ---- interface ! uses Windows, GLCanvas, Classes, vglClasses, Graphics, SysUtils, Trace; const *************** *** 368,372 **** --- 368,397 ---- end; + { Allows multiple components to be collected and hidden/shown as a group } + TvglPage = class(TvglPanel) + constructor Create(aName:string; aOwner:TvglComponent); + end; + + TvglMultipage = class(TvglComponent) + protected + FCurrentPage: TvglPage; + procedure SetCurrentPage(const Value: TvglPage); + function GetPage(index: integer): TvglPage; + + function GetComponentType:string; override ; + procedure DrawChildren; override ; + function GetComponentAt(X, Y: integer): TvglComponent; + public + property Pages[index:integer] :TvglPage read GetPage; default; + property CurrentPage :TvglPage read FCurrentPage write SetCurrentPage; + + constructor Create(aName:string; AOwner:TvglComponent); + destructor Destroy; override ; + + function AddPage:TvglPage; + end; + + implementation uses *************** *** 1866,1869 **** --- 1891,1895 ---- FOKButton.Bounds := Rect((Width div 2) - (VGL_SKINRECT_BUTTON.Right-VGL_SKINRECT_BUTTON.Left) div 2,FBoxBounds.Bottom - 5 - (VGL_SKINRECT_BUTTON.Bottom-VGL_SKINRECT_BUTTON.Top),0,0); FTextBox.Bounds := Rect(FBoxBounds.Left+10,FBoxBounds.Top+10,FBoxBounds.Right-10,FBoxBounds.Bottom-FOKButton.Height-10); + FAcceptsChildren := false; end; *************** *** 1880,1884 **** // draw backpanel Canvas.CurrentColor := clBlack; ! Canvas.FillAlpha := 0.5; Canvas.Rectangle(Manager.Desktop.ScreenBounds); // draw "window" --- 1906,1910 ---- // draw backpanel Canvas.CurrentColor := clBlack; ! Canvas.FillAlpha := 0.5; // BUG: should be partially transparent, but isn't ? Canvas.Rectangle(Manager.Desktop.ScreenBounds); // draw "window" *************** *** 1904,1907 **** --- 1930,2004 ---- begin Visible := true; + end; + + { TvglMultipage } + + function TvglMultipage.AddPage: TvglPage; + var newpage :TvglPage; + begin + FAcceptsChildren := true; + newPage := TvglPage.Create(Name+'_Page'+IntToStr(FChildren.Count+1),self); + newPage.Bounds := Bounds; + FAcceptsChildren := false; + result := newPage; + if CurrentPage = nil then CurrentPage := newPage; + end; + + constructor TvglMultipage.Create(aName: string; AOwner: TvglComponent); + begin + inherited Create(aName,aOwner); + FAcceptsChildren := false; + FcurrentPage := nil; + end; + + destructor TvglMultipage.Destroy; + begin + inherited; + end; + + procedure TvglMultipage.DrawChildren; + var i:integer; + begin + if assigned(FOwner) then + Canvas.SetClipping(FOwner.ChildClipRect); + CurrentPage.Draw; + end; + + function TvglMultipage.GetComponentAt(X, Y: integer): TvglComponent; + begin + if assigned(CurrentPage) then + result := CurrentPage.GetComponentAt(x,y) + else result := self; + end; + + function TvglMultipage.GetComponentType: string; + begin + result := 'MultiPage'; + end; + + function TvglMultipage.GetPage(index: integer): TvglPage; + begin + Result := TvglPage(FChildren[index]); + end; + + procedure TvglMultipage.SetCurrentPage(const Value: TvglPage); + var i:integer; + begin + FCurrentPage := Value; + // make all but this one invisible + for i := 0 to FChildren.Count-1 do + begin + if TvglPage(FChildren[i]) = CurrentPage then + TvglPage(FChildren[i]).Visible := true + else TvglPage(FChildren[i]).Visible := false; + end; + end; + + { TvglPage } + + constructor TvglPage.Create(aName:string; aOwner: TvglComponent); + begin + inherited Create(aName,aOwner); + StyleShown := false; end; |