Changeset 14
- Timestamp:
- Feb 29, 2016, 5:23:37 PM (9 years ago)
- Location:
- os/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
os/trunk/Applications/TestApplication.pas
r8 r14 38 38 Form1.Caption := 'Test application'; 39 39 Form1.Screen := Screen; 40 Form1.Application := Self; 40 41 Form2 := TForm.Create; 41 42 Form2.Owner := Self; … … 44 45 Form2.Caption := 'Some form'; 45 46 Form2.Screen := Screen; 47 Form2.Application := Self; 46 48 Timer1 := TTimer.Create; 47 49 Timer1.Interval := 1000; -
os/trunk/Applications/UDesktop.pas
r8 r14 83 83 MainBar.Caption := 'fdfdfd'; 84 84 MainBar.Screen := Screen; 85 MainBar.Application := Self; 85 86 TaskBar := TPanel.Create; 86 87 TaskBar.Parent := MainBar; -
os/trunk/Drivers/Driver.VideoVCL.pas
r6 r14 95 95 inherited; 96 96 CanvasVCL.Brush.Color := ColorToVCL(Color); 97 CanvasVCL.Brush.Style := bsSolid; 97 98 CanvasVCL.FillRect(System.Types.Rect(Rect.Left, Rect.Top, Rect.Right, Rect.Bottom)); 98 99 end; -
os/trunk/System/LDOS.Kernel.pas
r13 r14 63 63 Forms: TList<TForm>; 64 64 VideoDevice: TVideoDevice; 65 FormMove: TControlMove; 65 66 procedure HandleResize; 66 67 procedure Paint; … … 80 81 TMouse = class 81 82 Kernel: TKernel; 82 MovedForm: TForm;83 83 procedure HandleMove(Position: TPoint); 84 84 procedure HandleDown(Position: TPoint); … … 226 226 Canvas := TScreenCanvas.Create; 227 227 Canvas.Screen := Self; 228 FormMove := TControlMove.Create; 228 229 end; 229 230 230 231 destructor TScreen.Destroy; 231 232 begin 233 FormMove.Free; 232 234 Canvas.Destroy; 233 235 Forms.Destroy; … … 371 373 for Form in Kernel.Screen.Forms do 372 374 if Form.Bounds.Contains(Position) then begin 373 MovedForm := Form;374 375 if Form.HandleMessage(NewMessage) then begin 375 376 Break; … … 389 390 NewMessage.Position := Position; 390 391 try 392 with Kernel.Screen.FormMove do 393 if Active then begin 394 TForm(Control).Bounds.TopLeft := StartControlPos + (Position - StartMousePos); 395 Kernel.Screen.Paint; 396 end; 391 397 for Form in Kernel.Screen.Forms do 392 398 if Form.Bounds.Contains(Position) then begin … … 410 416 NewMessage.Position := Position; 411 417 try 418 Kernel.Screen.FormMove.Active := False; 412 419 for Form in Kernel.Screen.Forms do 413 420 if Form.Bounds.Contains(Position) then begin … … 416 423 end; 417 424 end; 418 if Assigned(Kernel.Screen.FocusedForm) then419 Kernel.Screen.FocusedForm.HandleMessage(NewMessage);425 // if Assigned(Kernel.Screen.FocusedForm) then 426 // Kernel.Screen.FocusedForm.HandleMessage(NewMessage); 420 427 finally 421 428 NewMessage.Destroy; -
os/trunk/Xvcl/Xvcl.Classes.pas
r7 r14 168 168 constructor TComponent.Create; 169 169 begin 170 FName := ClassName; 170 171 FComponents := TObjectList<TComponent>.Create; 171 172 end; -
os/trunk/Xvcl/Xvcl.Controls.pas
r13 r14 33 33 States: TKeyStateSet; 34 34 end; 35 36 TMouseNotifyEvent = procedure (Sender: TObject; Position: TPoint; 37 Buttons: TMouseButtonSet) of object; 35 38 36 39 TControlCanvas = class(TCanvas) … … 57 60 FOnClick: TNotifyEvent; 58 61 FColor: TColor; 59 FOnMouseDown: TNotifyEvent; 60 FOnMouseUp: TNotifyEvent; 62 FOnMouseDown: TMouseNotifyEvent; 63 FOnMouseUp: TMouseNotifyEvent; 64 FOnMouseMove: TMouseNotifyEvent; 61 65 FOnKeyPress: TNotifyEvent; 62 66 FFocused: Boolean; … … 69 73 function HandleMessage(Message: TMessage): Boolean; virtual; 70 74 public 71 Move: TControlMove;72 75 function ClientToScreen(Position: TPoint): TPoint; virtual; 73 76 function ScreenToClient(Position: TPoint): TPoint; virtual; … … 83 86 property Focused: Boolean read FFocused write SetFocused; 84 87 property OnClick: TNotifyEvent read FOnClick write FOnClick; 85 property OnMouseDown: TNotifyEvent read FOnMouseDown write FOnMouseDown; 86 property OnMouseUp: TNotifyEvent read FOnMouseUp write FOnMouseUp; 88 property OnMouseDown: TMouseNotifyEvent read FOnMouseDown write FOnMouseDown; 89 property OnMouseUp: TMouseNotifyEvent read FOnMouseUp write FOnMouseUp; 90 property OnMouseMove: TMouseNotifyEvent read FOnMouseMove write FOnMouseMove; 87 91 property OnKeyPress: TNotifyEvent read FOnKeyPress write FOnKeyPress; 88 92 end; … … 119 123 procedure Paint; override; 120 124 property Caption: string read FCaption write SetCaption; 125 constructor Create; override; 121 126 end; 122 127 … … 147 152 begin 148 153 inherited; 149 Move := TControlMove.Create;150 154 FColor := clWhite; 151 155 end; … … 153 157 destructor TControl.Destroy; 154 158 begin 155 Move.Destroy;156 159 if Assigned(FCanvas) then FCanvas.Destroy; 157 160 inherited; … … 176 179 begin 177 180 Result := False; 181 if Message is TMessageMouseDown then 182 with TMessageMouseDown(Message) do begin 183 if Assigned(FOnMouseDown) then begin 184 FOnMouseDown(Self, Position, Buttons); 185 Result := True; 186 end; 187 end else 188 if Message is TMessageMouseUp then 189 with TMessageMouseUp(Message) do begin 190 if Assigned(FOnMouseUp) then begin 191 FOnMouseUp(Self, Position, Buttons); 192 Result := True; 193 end; 194 end else 195 if Message is TMessageMouseMove then 196 with TMessageMouseMove(Message) do begin 197 if Assigned(FOnMouseMove) then begin 198 FOnMouseMove(Self, Position, Buttons); 199 Result := True; 200 end; 201 end; 178 202 end; 179 203 180 204 procedure TControl.Paint; 181 205 begin 206 if Color <> clNone then 182 207 with Canvas do begin 183 208 Brush.Color := Color; … … 189 214 begin 190 215 Result := Position.Substract(Bounds.TopLeft); 191 if Assigned(Parent) then Result := Parent. ClientToScreen(Result);216 if Assigned(Parent) then Result := Parent.ScreenToClient(Result); 192 217 end; 193 218 … … 220 245 begin 221 246 Result := False; 222 if Message is TMessageMouseDown then begin 223 if Assigned(FOnMouseDown) then FOnMouseDown(Self); 247 if Message is TMessageMouseDown then 248 with TMessageMouseDown(Message) do begin 249 if Assigned(FOnMouseDown) then FOnMouseDown(Self, Position, Buttons); 224 250 Color := clGray; 225 251 Paint; 226 252 Result := True; 227 253 end else 228 if Message is TMessageMouseUp then begin 229 if Assigned(FOnMouseUp) then FOnMouseUp(Self); 254 if Message is TMessageMouseUp then 255 with TMessageMouseUp(Message) do begin 256 if Assigned(FOnMouseUp) then FOnMouseUp(Self, Position, Buttons); 230 257 Color := clSilver; 231 258 Paint; … … 321 348 end; 322 349 end; 350 if not Result then inherited; 323 351 end; 324 352 … … 332 360 333 361 { TLabel } 362 363 constructor TLabel.Create; 364 begin 365 inherited; 366 Color := clNone; 367 end; 334 368 335 369 procedure TLabel.Paint; -
os/trunk/Xvcl/Xvcl.Forms.pas
r13 r14 8 8 type 9 9 TBorderStyle = (bsNormal, bsNone); 10 TPanel = class; 11 TForm = class; 12 TApplication = class; 13 14 TFormTitleBar = class 15 private 16 function GetForm: TForm; 17 procedure SetForm(const Value: TForm); 18 procedure DoMaximize(Sender: TObject); 19 procedure DoClose(Sender: TObject); 20 procedure DoMouseDown(Sender: TObject; Position: TPoint; Buttons: TMouseButtonSet); 21 public 22 const 23 TitleBarHeight = 24; 24 var 25 MainLabel: TLabel; 26 Panel: TPanel; 27 MaximizeButton: TButton; 28 MinimizeButton: TButton; 29 CloseButton: TButton; 30 procedure Paint; 31 constructor Create; 32 destructor Destroy; override; 33 property Form: TForm read GetForm write SetForm; 34 end; 10 35 11 36 TForm = class(TWinControl) … … 18 43 function GetVideoDevice: TVideoDevice; override; 19 44 public 20 const21 TitleBarHeight = 24;22 45 var 23 46 Screen: TObject; // TScreen; 47 Application: TApplication; 24 48 Caption: string; 49 TitleBar: TFormTitleBar; 25 50 function HandleMessage(Message: TMessage): Boolean; override; 26 51 procedure Paint; override; 52 procedure Close; 53 constructor Create; override; 54 destructor Destroy; override; 27 55 property Focused: Boolean read FFocused write SetFocused; 28 56 property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle; … … 30 58 31 59 TPanel = class(TWinControl) 60 protected 61 function HandleMessage(Message: TMessage): Boolean; override; 62 public 32 63 Caption: string; 33 64 procedure Paint; override; … … 41 72 Forms: TList<TForm>; 42 73 MainForm: TForm; 74 Terminated: Boolean; 43 75 function HandleMessage(Message: TMessage): Boolean; virtual; 44 76 procedure Run; virtual; … … 66 98 procedure TApplication.Terminate; 67 99 begin 68 100 Terminated := True; 69 101 end; 70 102 71 103 { TForm } 104 105 procedure TForm.Close; 106 begin 107 if Application.MainForm = Self then 108 Application.Terminate; 109 end; 110 111 constructor TForm.Create; 112 begin 113 inherited; 114 TitleBar := TFormTitleBar.Create; 115 end; 116 117 destructor TForm.Destroy; 118 begin 119 TitleBar.Free; 120 inherited; 121 end; 72 122 73 123 function TForm.GetVideoDevice: TVideoDevice; … … 78 128 79 129 function TForm.HandleMessage(Message: TMessage): Boolean; 80 var 81 TitleBarBounds: TRectangle; 82 begin 83 Result := False; 84 if Message is TMessageMouseDown then 85 with TMessageMouseDown(Message) do begin 86 TitleBarBounds := TRectangle.Create(0, 0, Bounds.Width, TitleBarHeight); 87 Focused := True; 88 if (BorderStyle = bsNormal) and TitleBarBounds.Contains(ScreenToClient(Position)) then begin 89 Move.StartControlPos := Bounds.TopLeft; 90 Move.StartMousePos := Position; 91 Move.Active := True; 92 Result := True; 93 end; 94 end else 95 if Message is TMessageMouseUp then 96 with TMessageMouseUp(Message) do begin 97 Move.Active := False; 98 end else 99 if Message is TMessageMouseMove then 100 with TMessageMouseUp(Message) do begin 101 if Move.Active then begin 102 Bounds.TopLeft := Move.StartControlPos + (Position - Move.StartMousePos); 103 TScreen(Screen).Paint; 104 end; 105 end; 106 if not Result then inherited; 130 begin 131 inherited; 107 132 end; 108 133 109 134 procedure TForm.Paint; 110 135 begin 136 if BorderStyle = bsNormal then begin 137 TitleBar.Form := Self; 138 TitleBar.Paint; 139 end; 111 140 inherited; 112 141 with Canvas do begin 113 142 if BorderStyle = bsNormal then begin 114 if Focused then Brush.Color := clLightBlue else115 Brush.Color := clSilver;116 FillRect(TRectangle.Create(0, 0, Bounds.Width - 1, TitleBarHeight));117 143 MoveTo(TPoint.Create(0, 0)); 118 144 LineTo(TPoint.Create(Bounds.Width - 1, 0)); … … 120 146 LineTo(TPoint.Create(0, Bounds.Height - 1)); 121 147 LineTo(TPoint.Create(0, 0)); 122 MoveTo(TPoint.Create(0, TitleBarHeight));123 LineTo(TPoint.Create(Bounds.Width - 1, TitleBarHeight));124 TextOut(TPoint.Create((Bounds.Width - GetTextSize(Caption).X) div 2,125 (TitleBarHeight - GetTextSize(Caption).Y) div 2), Caption);126 148 end; 127 149 end; … … 142 164 143 165 { TPanel } 166 167 function TPanel.HandleMessage(Message: TMessage): Boolean; 168 begin 169 inherited; 170 end; 144 171 145 172 procedure TPanel.Paint; … … 152 179 LineTo(TPoint.Create(0, Bounds.Height - 1)); 153 180 LineTo(TPoint.Create(0, 0)); 154 TextOut(TPoint.Create((Bounds.Width - GetTextSize(Caption).X) div 2, 155 (Bounds.Height - GetTextSize(Caption).Y) div 2), Caption); 156 end; 181 if Caption <> '' then 182 TextOut(TPoint.Create((Bounds.Width - GetTextSize(Caption).X) div 2, 183 (Bounds.Height - GetTextSize(Caption).Y) div 2), Caption); 184 end; 185 end; 186 187 { TFormTitleBar } 188 189 constructor TFormTitleBar.Create; 190 begin 191 inherited; 192 Panel := TPanel.Create; 193 Panel.Visible := True; 194 Panel.OnMouseDown := DoMouseDown; 195 196 MainLabel := TLabel.Create; 197 MainLabel.Parent := Panel; 198 MainLabel.Visible := True; 199 200 CloseButton := TButton.Create; 201 CloseButton.Parent := Panel; 202 CloseButton.Caption := 'X'; 203 CloseButton.Visible := True; 204 CloseButton.OnClick := DoClose; 205 206 MaximizeButton := TButton.Create; 207 MaximizeButton.Parent := Panel; 208 MaximizeButton.Caption := 'M'; 209 MaximizeButton.Visible := True; 210 MaximizeButton.OnClick := DoMaximize; 211 212 MinimizeButton := TButton.Create; 213 MinimizeButton.Parent := Panel; 214 MinimizeButton.Caption := 'V'; 215 MinimizeButton.Visible := True; 216 end; 217 218 destructor TFormTitleBar.Destroy; 219 begin 220 MainLabel.Free; 221 MinimizeButton.Free; 222 MaximizeButton.Free; 223 CloseButton.Free; 224 Panel.Free; 225 inherited; 226 end; 227 228 procedure TFormTitleBar.DoClose(Sender: TObject); 229 begin 230 Form.Close; 231 end; 232 233 procedure TFormTitleBar.DoMaximize(Sender: TObject); 234 begin 235 Form.Bounds := TRectangle.Create(0, 0, TScreen(Form.Screen).Size.X, TScreen(Form.Screen).Size.Y); 236 Form.Paint; 237 end; 238 239 procedure TFormTitleBar.DoMouseDown(Sender: TObject; Position: TPoint; Buttons: TMouseButtonSet); 240 begin 241 Form.Focused := True; 242 if (Form.BorderStyle = bsNormal) then begin 243 TScreen(Form.Screen).FormMove.StartControlPos := Form.Bounds.TopLeft; 244 TScreen(Form.Screen).FormMove.StartMousePos := Position; 245 TScreen(Form.Screen).FormMove.Control := Form; 246 TScreen(Form.Screen).FormMove.Active := True; 247 end; 248 end; 249 250 function TFormTitleBar.GetForm: TForm; 251 begin 252 Result := TForm(Panel.Parent); 253 end; 254 255 procedure TFormTitleBar.Paint; 256 begin 257 if Assigned(Form) then begin 258 Panel.Bounds := TRectangle.Create(0, 0, Form.Bounds.Width, TitleBarHeight); 259 CloseButton.Bounds := TRectangle.Create(Panel.Bounds.Width - TitleBarHeight, 260 2, TitleBarHeight - 4, TitleBarHeight - 4); 261 MaximizeButton.Bounds := TRectangle.Create(Panel.Bounds.Width - 2 * TitleBarHeight, 262 2, TitleBarHeight - 4, TitleBarHeight - 4); 263 MinimizeButton.Bounds := TRectangle.Create(Panel.Bounds.Width - 3 * TitleBarHeight, 264 2, TitleBarHeight - 4, TitleBarHeight - 4); 265 if Form.Focused then Panel.Color := clLightBlue else 266 Panel.Color := clSilver; 267 MainLabel.Caption := Form.Caption; 268 MainLabel.Bounds := TRectangle.Create(0, 0, Panel.Bounds.Width, Panel.Bounds.Height); 269 end; 270 end; 271 272 procedure TFormTitleBar.SetForm(const Value: TForm); 273 begin 274 Panel.Parent := Value; 157 275 end; 158 276
Note:
See TracChangeset
for help on using the changeset viewer.