[JEDI.NET-commits] dev/ahuser/WinFormsVCL Jedi.WinForms.VCL.Buttons.pas,1.1,1.2 Jedi.WinForms.VCL.Co
Status: Pre-Alpha
Brought to you by:
jedi_mbe
From: Andreas H. <ah...@us...> - 2005-05-12 14:56:46
|
Update of /cvsroot/jedidotnet/dev/ahuser/WinFormsVCL In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19210/ahuser/WinFormsVCL Modified Files: Jedi.WinForms.VCL.Buttons.pas Jedi.WinForms.VCL.Controls.pas Jedi.WinForms.VCL.Forms.pas Jedi.WinForms.VCL.Graphics.pas Jedi.WinForms.VCL.ImgList.pas Jedi.WinForms.VCL.Menus.pas Log Message: Fixed virtual constructor call Fixed empty bitmap.canvas Added DrawButtonFace Index: Jedi.WinForms.VCL.Buttons.pas =================================================================== RCS file: /cvsroot/jedidotnet/dev/ahuser/WinFormsVCL/Jedi.WinForms.VCL.Buttons.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.WinForms.VCL.Buttons.pas 26 Dec 2004 15:58:41 -0000 1.1 --- Jedi.WinForms.VCL.Buttons.pas 12 May 2005 14:56:37 -0000 1.2 *************** *** 30,37 **** uses System.Drawing, System.Windows.Forms, ! Borland.Vcl.Classes, Borland.Vcl.Messages, Jedi.WinForms.VCL.Controls, Jedi.WinForms.VCL.Graphics; type { Quick & Dirty, simply uses a WinForms Button which has too many features for a TSpeedButton like "Focus". } --- 30,39 ---- uses System.Drawing, System.Windows.Forms, ! Borland.Vcl.Types, Borland.Vcl.Classes, Jedi.WinForms.VCL.Controls, Jedi.WinForms.VCL.Graphics; type + TButtonStyle = (bsAutoDetect, bsWin31, bsNew); + { Quick & Dirty, simply uses a WinForms Button which has too many features for a TSpeedButton like "Focus". } *************** *** 69,74 **** --- 71,101 ---- end; + function DrawButtonFace(Canvas: TCanvas; const Client: TRect; + BevelWidth: Integer; Style: TButtonStyle; IsRounded, IsDown, + IsFocused: Boolean): TRect; + implementation + function DrawButtonFace(Canvas: TCanvas; const Client: TRect; + BevelWidth: Integer; Style: TButtonStyle; IsRounded, IsDown, + IsFocused: Boolean): TRect; + var + State: ButtonState; + begin + Result := Client; + OffsetRect(Result, -1, 0); + + State := ButtonState.Normal; + if IsDown then + State := ButtonState.Pushed; + if IsFocused then + State := State or ButtonState.Checked; + ControlPaint.DrawButton(Canvas.Handle, ToNETRectangle(Result), State); + Dec(Result.Right); + Dec(Result.Bottom); + if Style = bsWin31 then + Canvas.Handle.DrawRectangle(Pen.Create(Color.Black), ToNETRectangle(Result)); + end; + { TSpeedButton } Index: Jedi.WinForms.VCL.Graphics.pas =================================================================== RCS file: /cvsroot/jedidotnet/dev/ahuser/WinFormsVCL/Jedi.WinForms.VCL.Graphics.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.WinForms.VCL.Graphics.pas 26 Dec 2004 15:58:41 -0000 1.1 --- Jedi.WinForms.VCL.Graphics.pas 12 May 2005 14:56:37 -0000 1.2 *************** *** 57,60 **** --- 57,61 ---- clBlack = $00000000; clRed = $000000FF; + clBlue = $00FF0000; clWhite = $00FFFFFF; clBtnFace = clSystemColor or $00000001; *************** *** 248,251 **** --- 249,256 ---- TBitmap = class(TGraphic) + strict private + class var + FEmptyBitmap: TBitmap; + class function GetEmptyBitmap: TBitmap; static; private FHandle: System.Drawing.Bitmap; *************** *** 534,539 **** if Value <> FHandle then begin ! if FHandle <> nil then ! FHandle.Free; // dispose FHandle := Value; end; --- 539,544 ---- if Value <> FHandle then begin ! if Assigned(FHandle) then ! FHandle.Dispose; FHandle := Value; end; *************** *** 604,608 **** else begin ! raise Exception.Create('Source Canvas not supported. Must be a associated with an image/bitmap.'); (* dstDC := Handle.GetHdc; --- 609,613 ---- else begin ! raise Exception.Create('Source Canvas not supported. Must be associated with an image/bitmap.'); (* dstDC := Handle.GetHdc; *************** *** 810,814 **** finally Handle.Clip := ClipRegion; ! TextClip.Free; // dispose end; finally --- 815,819 ---- finally Handle.Clip := ClipRegion; ! TextClip.Dispose; end; finally *************** *** 852,856 **** Result := FromNETColor(Bmp.GetPixel(0, 0)); finally ! Bmp.Free; // dispose end; end; --- 857,861 ---- Result := FromNETColor(Bmp.GetPixel(0, 0)); finally ! Bmp.Dispose; end; end; *************** *** 866,870 **** Handle.DrawLine(P, X, Y, X, Y); finally ! P.Free; // dispose end; finally --- 871,875 ---- Handle.DrawLine(P, X, Y, X, Y); finally ! P.Dispose; end; finally *************** *** 889,893 **** begin if HandleAllocated then ! ImageHandle.Free; // dispose inherited Destroy; end; --- 894,898 ---- begin if HandleAllocated then ! ImageHandle.Dispose; // dispose inherited Destroy; end; *************** *** 962,966 **** end; end; ! FHandle.Free; FHandle := NewHandle; end; --- 967,972 ---- end; end; ! if Assigned(FHandle) then ! FHandle.Dispose; FHandle := NewHandle; end; *************** *** 1008,1017 **** Graphics.FillRectangle(Canvas.Brush.Handle, 0, Handle.Height, FWidth, FHeight - Handle.Height); finally ! Graphics.Free; end; end; InternalSetHandle(NewImg); if not KeepImage then Graphics.FillRectangle(Canvas.Brush.Handle, 0, 0, FWidth, FHeight); end else --- 1014,1027 ---- Graphics.FillRectangle(Canvas.Brush.Handle, 0, Handle.Height, FWidth, FHeight - Handle.Height); finally ! Graphics.Dispose; end; end; InternalSetHandle(NewImg); if not KeepImage then + begin + Graphics := System.Drawing.Graphics.FromImage(NewImg); Graphics.FillRectangle(Canvas.Brush.Handle, 0, 0, FWidth, FHeight); + Graphics.Dispose; + end; end else *************** *** 1056,1059 **** --- 1066,1074 ---- FCanvas.Handle := Graphics.FromImage(Handle); FCanvas.AssignedObject := Handle; + end + else + begin + Result := GetEmptyBitmap.Canvas; + Exit; end; end *************** *** 1061,1065 **** if Empty then begin ! FCanvas.Free; // dispose FCanvas := nil; end; --- 1076,1080 ---- if Empty then begin ! FCanvas.Free; FCanvas := nil; end; *************** *** 1167,1171 **** InternalSetHandle(Bmp); finally ! Graphics.Free; end; end; --- 1182,1186 ---- InternalSetHandle(Bmp); finally ! Graphics.Dispose; end; end; *************** *** 1183,1186 **** --- 1198,1212 ---- end; + class function TBitmap.GetEmptyBitmap: TBitmap; + begin + if not Assigned(FEmptyBitmap) then + begin + FEmptyBitmap := TBitmap.Create; + FEmptyBitmap.Width := 1; + FEmptyBitmap.Height := 1; + end; + Result := FEmptyBitmap; + end; + { TGraphicsObject } *************** *** 1206,1210 **** destructor TGraphicsObject.Destroy; begin ! FHandle.Free; // GDI objects need finalization inherited Destroy; end; --- 1232,1236 ---- destructor TGraphicsObject.Destroy; begin ! FHandle.Free; // GDI objects need finalization inherited Destroy; end; *************** *** 1385,1390 **** Changed; end; ! end; ! inherited Assign(Source); end; --- 1411,1417 ---- Changed; end; ! end ! else ! inherited Assign(Source); end; *************** *** 1497,1501 **** destructor TFont.Destroy; begin ! FBrush.Free; inherited Destroy; end; --- 1524,1528 ---- destructor TFont.Destroy; begin ! FBrush.Dispose; inherited Destroy; end; *************** *** 1523,1532 **** end else ! inherited Assign(Source); end; procedure TFont.Changed; begin ! FBrush.Free; FBrush := nil; inherited Changed; --- 1550,1560 ---- end else ! inherited Assign(Source); end; procedure TFont.Changed; begin ! if Assigned(FBrush) then ! FBrush.Dispose; FBrush := nil; inherited Changed; Index: Jedi.WinForms.VCL.Controls.pas =================================================================== RCS file: /cvsroot/jedidotnet/dev/ahuser/WinFormsVCL/Jedi.WinForms.VCL.Controls.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.WinForms.VCL.Controls.pas 26 Dec 2004 15:58:41 -0000 1.1 --- Jedi.WinForms.VCL.Controls.pas 12 May 2005 14:56:37 -0000 1.2 *************** *** 29,32 **** --- 29,33 ---- uses + System.Reflection, System.Drawing, System.Collections, System.ComponentModel, System.Windows.Forms, System.Windows.Forms.Design, *************** *** 77,81 **** --- 78,85 ---- procedure OnMouseUp(e: MouseEventArgs); override; procedure OnMouseDown(e: MouseEventArgs); override; + procedure OnVisibleChanged(e: EventArgs); override; protected + procedure DoShow; virtual; + procedure DoHide; virtual; procedure Click; virtual; procedure DblClick; virtual; *************** *** 84,92 **** procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer); virtual; procedure MouseMove(Shift: TShiftState; X: Integer; Y: Integer); virtual; - procedure DragDrop(Source: TObject; X, Y: Integer); virtual; procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); virtual; procedure WndProc(var Message: TMessage); virtual; public ! function Perform(Msg: Cardinal; WParam, LParam: Integer): Integer; end; --- 88,96 ---- procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer); virtual; procedure MouseMove(Shift: TShiftState; X: Integer; Y: Integer); virtual; procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); virtual; procedure WndProc(var Message: TMessage); virtual; public ! function Perform(Msg: Cardinal; WParam, LParam: Integer): Integer; ! procedure DragDrop(Source: TObject; X, Y: Integer); virtual; end; *************** *** 133,141 **** procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer); override; procedure MouseMove(Shift: TShiftState; X: Integer; Y: Integer); override; - procedure DragDrop(Source: TObject; X, Y: Integer); override; procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); override; property ControlStyle: TControlStyle read FControlStyle write SetControlStyle; property Caption: string read GetCaption write SetCaption; public function GetClientRect: TRect; --- 137,147 ---- procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X: Integer; Y: Integer); override; procedure MouseMove(Shift: TShiftState; X: Integer; Y: Integer); override; procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); override; + procedure DragCanceled; virtual; property ControlStyle: TControlStyle read FControlStyle write SetControlStyle; property Caption: string read GetCaption write SetCaption; + + class function Bounds(Left, Top, Width, Height: Integer): TRect; static; public function GetClientRect: TRect; *************** *** 145,153 **** class constructor Create; constructor Create(AOwner: TComponent); overload; virtual; ! constructor Create; overload; function ClientToScreen(const Pt: TPoint): TPoint; function ScreenToClient(const Pt: TPoint): TPoint; // Events property OnMouseDown: TMouseEvent read FOnMouseDown write FOnMouseDown; --- 151,164 ---- class constructor Create; constructor Create(AOwner: TComponent); overload; virtual; ! constructor Create; overload; ! ! procedure DragDrop(Source: TObject; X, Y: Integer); override; function ClientToScreen(const Pt: TPoint): TPoint; function ScreenToClient(const Pt: TPoint): TPoint; + procedure Repaint; + procedure BeginDrag(Immediately: Boolean; Threshold: Integer = 0); + // Events property OnMouseDown: TMouseEvent read FOnMouseDown write FOnMouseDown; *************** *** 205,208 **** --- 216,221 ---- function GetShiftState(Buttons: System.Windows.Forms.MouseButtons): TShiftState; + procedure InflateRect(var R: TRect; X, Y: Integer); + implementation *************** *** 235,238 **** --- 248,264 ---- end; + procedure InflateRect(var R: TRect; X, Y: Integer); + begin + R := Rect(R.Left + X, R.Top + Y, R.Right - X, R.Bottom - Y); + end; + + class function TWinControl.Bounds(Left, Top, Width, Height: Integer): TRect; + begin + Result.Left := Left; + Result.Top := Top; + Result.Right := Left + Width - 1; + Result.Bottom := Top + Height - 1; + end; + { TEventHelperControl } *************** *** 299,302 **** --- 325,329 ---- Resize; inherited OnResize(e); + Invalidate; end; *************** *** 374,377 **** --- 401,423 ---- end; + procedure TEventHelperControl.DoShow; + begin + + end; + + procedure TEventHelperControl.DoHide; + begin + + end; + + procedure TEventHelperControl.OnVisibleChanged(e: EventArgs); + begin + if Visible then + DoShow; + inherited OnVisibleChanged(e); + if not Visible then + DoHide; + end; + { TWinControl } *************** *** 382,387 **** constructor TWinControl.Create; begin ! Create(nil); end; --- 428,439 ---- constructor TWinControl.Create; + var + M: ConstructorInfo; begin ! inherited Create; ! FOwner := nil; ! M := GetType.GetConstructor(BindingFlags.InvokeMethod or BindingFlags.Instance or BindingFlags.&Public, nil, [TypeOf(TComponent)], nil); ! if Assigned(M) then ! M.Invoke(Self, [nil]); end; *************** *** 434,437 **** --- 486,494 ---- end; + procedure TWinControl.DragCanceled; + begin + DoDragDrop(Self, DragDropEffects.None); + end; + procedure TWinControl.SetAlign(const Value: TAlign); begin *************** *** 604,607 **** --- 661,674 ---- end; + procedure TWinControl.Repaint; + begin + Refresh; + end; + + procedure TWinControl.BeginDrag(Immediately: Boolean; Threshold: Integer); + begin + DoDragDrop(Self, DragDropEffects.All); + end; + { TCustomControl } |