Changeset 20
- Timestamp:
- May 6, 2013, 12:16:30 AM (12 years ago)
- Location:
- branches/Xvcl
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Xvcl
- Property svn:ignore
-
old new 2 2 *.local 3 3 Win32 4 __history
-
- Property svn:ignore
-
branches/Xvcl/Drivers
-
Property svn:ignore
set to
__history
-
Property svn:ignore
set to
-
branches/Xvcl/Drivers/Driver.MouseVCL.pas
r19 r20 24 24 Shift: TShiftState; X, Y: Integer); 25 25 begin 26 Kernel.Mouse.Handle Click(TPoint.Create(X, Y));26 Kernel.Mouse.HandleDown(TPoint.Create(X, Y)); 27 27 end; 28 28 … … 30 30 Shift: TShiftState; X, Y: Integer); 31 31 begin 32 32 Kernel.Mouse.HandleUp(TPoint.Create(X, Y)); 33 33 end; 34 34 -
branches/Xvcl/Drivers/Driver.VideoVCL.pas
r19 r20 4 4 5 5 uses 6 Vcl.Forms, Vcl.Graphics, UFormMain, Xvcl.Classes, Xvcl.Kernel, Xvcl.Graphics; 6 Vcl.Forms, Vcl.Graphics, System.Types, UFormMain, Xvcl.Classes, Xvcl.Kernel, 7 Xvcl.Graphics; 7 8 8 9 type … … 16 17 CanvasVCL: Vcl.Graphics.TCanvas; 17 18 function ColorToVCL(Color: TColor): Vcl.Graphics.TColor; 19 procedure FillRect(Rect: TRectangle; Color: TColor); override; 18 20 procedure Line(Pos1, Pos2: TPoint; Color: TColor); override; 19 21 procedure TextOut(Position: TPoint; Text: string); override; … … 62 64 end; 63 65 66 procedure TVideoDeviceVCL.FillRect(Rect: TRectangle; Color: TColor); 67 begin 68 inherited; 69 CanvasVCL.Brush.Color := ColorToVCL(Color); 70 CanvasVCL.FillRect(System.Types.Rect(Rect.Left, Rect.Top, Rect.Right, Rect.Bottom)); 71 end; 72 64 73 function TVideoDeviceVCL.GetTextSize(Text: string): TPoint; 65 74 begin … … 76 85 procedure TVideoDeviceVCL.TextOut(Position: TPoint; Text: string); 77 86 begin 87 CanvasVCL.Brush.Color := clNone; 78 88 CanvasVCL.TextOut(Position.X, Position.Y, Text); 79 89 end; -
branches/Xvcl/Xvcl.Classes.pas
r19 r20 21 21 function GetBottomLeft: TPoint; 22 22 function GetBottomRight: TPoint; 23 function GetLeftTop: TPoint; 24 function GetRightTop: TPoint; 23 function GetTopLeft: TPoint; 24 function GetTopRight: TPoint; 25 procedure SetTopLeft(const Value: TPoint); 26 procedure SetBottomRight(const Value: TPoint); 27 procedure SetBottom(const Value: Integer); 28 procedure SetRight(const Value: Integer); 29 procedure SetTopRight(const Value: TPoint); 25 30 public 26 31 Left: Integer; … … 28 33 Width: Integer; 29 34 Height: Integer; 30 property Right: Integer read GetRight ;31 property Bottom: Integer read GetBottom ;35 property Right: Integer read GetRight write SetRight; 36 property Bottom: Integer read GetBottom write SetBottom; 32 37 property Size: TPoint read GetSize; 33 38 property Position: TPoint read GetPosition; 34 property LeftTop: TPoint read GetLeftTop;35 property BottomRight: TPoint read GetBottomRight ;36 property RightTop: TPoint read GetRightTop;39 property TopLeft: TPoint read GetTopLeft write SetTopLeft; 40 property BottomRight: TPoint read GetBottomRight write SetBottomRight; 41 property TopRight: TPoint read GetTopRight write SetTopRight; 37 42 property BottomLeft: TPoint read GetBottomLeft; 38 43 constructor Create(Left, Top, Width, Height: Integer); … … 86 91 end; 87 92 88 function TRectangle.Get LeftTop: TPoint;93 function TRectangle.GetTopLeft: TPoint; 89 94 begin 90 95 Result := TPoint.Create(Left, Top); … … 101 106 end; 102 107 103 function TRectangle.Get RightTop: TPoint;108 function TRectangle.GetTopRight: TPoint; 104 109 begin 105 110 Result := TPoint.Create(Right, Top); 111 end; 112 113 procedure TRectangle.SetBottom(const Value: Integer); 114 begin 115 Height := Value - Top; 116 end; 117 118 procedure TRectangle.SetBottomRight(const Value: TPoint); 119 begin 120 Right := Value.X; 121 Bottom := Value.Y; 122 end; 123 124 procedure TRectangle.SetRight(const Value: Integer); 125 begin 126 Width := Value - Left; 127 end; 128 129 procedure TRectangle.SetTopLeft(const Value: TPoint); 130 begin 131 Left := Value.X; 132 Top := Value.Y; 133 end; 134 135 procedure TRectangle.SetTopRight(const Value: TPoint); 136 begin 137 Top := Value.X; 138 Right := Value.Y; 106 139 end; 107 140 -
branches/Xvcl/Xvcl.Controls.pas
r19 r20 9 9 TControl = class; 10 10 TWinControl = class; 11 12 TMessage = class 13 Number: Integer; 14 Handled: Boolean; 15 end; 16 17 TMouseButton = (mbLeft, mbRight, mbMiddle); 18 TMouseButtonSet = set of TMouseButton; 19 TMessageMouse = class(TMessage) 20 Position: TPoint; 21 Buttons: TMouseButtonSet; 22 end; 23 TMessageMouseDown = class(TMessageMouse); 24 TMessageMouseUp = class(TMessageMouse); 25 26 TKeyState = (ksShift, ksAlt, ksOS); 27 TKeyStateSet = set of TKeyState; 28 TMessageKeyboard = class(TMessage) 29 KeyCode: Integer; 30 States: TKeyStateSet; 31 end; 11 32 12 33 TControlCanvas = class(TCanvas) … … 25 46 FBounds: TRectangle; 26 47 FOnClick: TNotifyEvent; 48 FColor: TColor; 49 FOnMouseDown: TNotifyEvent; 50 FOnMouseUp: TNotifyEvent; 27 51 function GetCanvas: TCanvas; 28 52 procedure SetParent(const Value: TWinControl); virtual; 53 procedure SetColor(const Value: TColor); 29 54 protected 30 55 function GetVideoDevice: TVideoDevice; virtual; 31 56 public 32 57 Controls: TList<TControl>; 58 function HandleMessage(Message: TMessage): Boolean; virtual; 33 59 function ClientToScreen(Position: TPoint): TPoint; virtual; 60 function ScreenToClient(Position: TPoint): TPoint; virtual; 34 61 procedure Paint; virtual; 35 62 constructor Create; override; … … 40 67 property Parent: TWinControl read FParent write SetParent; 41 68 property VideoDevice: TVideoDevice read GetVideoDevice; 69 property Color: TColor read FColor write SetColor; 42 70 property OnClick: TNotifyEvent read FOnClick write FOnClick; 71 property OnMouseDown: TNotifyEvent read FOnMouseDown write FOnMouseDown; 72 property OnMouseUp: TNotifyEvent read FOnMouseUp write FOnMouseUp; 43 73 end; 44 74 45 75 TWinControl = class(TControl) 76 protected 77 public 46 78 Controls: TList<TControl>; 47 function Handle Click(Position: TPoint): Boolean;79 function HandleMessage(Message: TMessage): Boolean; override; 48 80 constructor Create; override; 49 81 destructor Destroy; override; … … 56 88 public 57 89 procedure Paint; override; 90 constructor Create; override; 58 91 property Caption: string read FCaption write SetCaption; 59 92 end; … … 75 108 function TControl.ClientToScreen(Position: TPoint): TPoint; 76 109 begin 77 Result := TPoint.Create(Bounds.Left + Position.X, Bounds.Top + Position.Y);110 Result := Position.Add(Bounds.TopLeft); 78 111 if Assigned(Parent) then Result := Parent.ClientToScreen(Result); 79 112 end; … … 107 140 end; 108 141 142 function TControl.HandleMessage(Message: TMessage): Boolean; 143 begin 144 if Message is TMessageMouseDown then begin 145 if Assigned(FOnMouseDown) then FOnMouseDown(Self); 146 Color := clGray; 147 Paint; 148 end else 149 if Message is TMessageMouseUp then begin 150 if Assigned(FOnMouseUp) then FOnMouseUp(Self); 151 Color := clSilver; 152 Paint; 153 if Assigned(FOnClick) then FOnClick(Self); 154 end; 155 end; 156 109 157 procedure TControl.Paint; 110 158 var … … 112 160 begin 113 161 for C in Controls do C.Paint; 162 end; 163 164 function TControl.ScreenToClient(Position: TPoint): TPoint; 165 begin 166 Result := Position.Substract(Bounds.TopLeft); 167 if Assigned(Parent) then Result := Parent.ClientToScreen(Result); 168 end; 169 170 procedure TControl.SetColor(const Value: TColor); 171 begin 172 if FColor <> Value then begin 173 FColor := Value; 174 Paint; 175 end; 114 176 end; 115 177 … … 125 187 { TButton } 126 188 189 constructor TButton.Create; 190 begin 191 inherited; 192 FColor := clSilver; 193 end; 194 127 195 procedure TButton.Paint; 128 196 begin 129 197 inherited; 130 198 with Canvas do begin 199 Brush.Color := Color; 200 FillRect(TRectangle.Create(0, 0, Bounds.Width, Bounds.Height)); 131 201 MoveTo(TPoint.Create(0, 0)); 132 202 LineTo(TPoint.Create(Bounds.Width - 1, 0)); … … 176 246 end; 177 247 178 function TWinControl.Handle Click(Position: TPoint): Boolean;248 function TWinControl.HandleMessage(Message: TMessage): Boolean; 179 249 var 180 250 Control: TControl; … … 182 252 Result := False; 183 253 for Control in Controls do begin 184 if Control.Bounds.Contains(Position) then begin 185 if Control is TWinControl then begin 186 if TWinControl(Control).HandleClick(Position.Substract(Bounds.LeftTop)) then begin 187 Result := True; 188 Break; 189 end; 190 end else 191 if Assigned(Control.OnClick) then begin 192 Control.OnClick(Self); 254 if Message is TMessageMouse then 255 with TMessageMouse(Message) do begin 256 if Control.Bounds.Contains(ScreenToClient(Position)) then begin 257 if TWinControl(Control).HandleMessage(Message) then begin 193 258 Result := True; 194 259 Break; … … 196 261 end; 197 262 end; 263 end; 198 264 end; 199 265 -
branches/Xvcl/Xvcl.Graphics.pas
r19 r20 25 25 TVideoDevice = class 26 26 Size: TPoint; 27 procedure FillRect(Rect: TRectangle; Color: TColor); virtual; 27 28 procedure Line(Pos1, Pos2: TPoint; Color: TColor); virtual; 28 29 procedure SetPixel(Position: TPoint; Color: TColor); virtual; … … 49 50 procedure SetPixel(Position: TPoint; Color: TColor); 50 51 function GetPixel(Position: TPoint): TColor; 52 procedure FillRect(Rect: TRectangle); 51 53 constructor Create; 52 54 destructor Destroy; override; … … 90 92 FPen.Destroy; 91 93 inherited; 94 end; 95 96 procedure TCanvas.FillRect(Rect: TRectangle); 97 begin 98 Rect.TopLeft := AdjustPos(Rect.TopLeft); 99 if Assigned(VideoDevice) then VideoDevice.FillRect(Rect, Brush.Color); 92 100 end; 93 101 … … 152 160 { TVideoDevice } 153 161 162 procedure TVideoDevice.FillRect(Rect: TRectangle; Color: TColor); 163 begin 164 165 end; 166 154 167 function TVideoDevice.GetPixel(Position: TPoint): TColor; 155 168 begin -
branches/Xvcl/Xvcl.Kernel.pas
r19 r20 45 45 TMouse = class 46 46 Kernel: TKernel; 47 procedure HandleClick(Position: TPoint); 47 procedure HandleDown(Position: TPoint); 48 procedure HandleUp(Position: TPoint); 48 49 end; 49 50 … … 199 200 { TMouse } 200 201 201 procedure TMouse.Handle Click(Position: TPoint);202 procedure TMouse.HandleDown(Position: TPoint); 202 203 var 203 204 Form: TForm; 204 begin 205 for Form in Kernel.Screen.Forms do begin 206 Form.HandleClick(Position.Substract(Form.Bounds.LeftTop)); 205 NewMessage: TMessageMouse; 206 begin 207 NewMessage := TMessageMouseDown.Create; 208 NewMessage.Position := Position; 209 try 210 for Form in Kernel.Screen.Forms do begin 211 if Form.HandleMessage(NewMessage) then begin 212 Break; 213 end; 214 end; 215 finally 216 NewMessage.Destroy; 217 end; 218 end; 219 220 procedure TMouse.HandleUp(Position: TPoint); 221 var 222 Form: TForm; 223 NewMessage: TMessageMouse; 224 begin 225 NewMessage := TMessageMouseUp.Create; 226 NewMessage.Position := Position; 227 try 228 for Form in Kernel.Screen.Forms do begin 229 if Form.HandleMessage(NewMessage) then begin 230 Break; 231 end; 232 end; 233 finally 234 NewMessage.Destroy; 207 235 end; 208 236 end;
Note:
See TracChangeset
for help on using the changeset viewer.