Changeset 22 for branches/overos
- Timestamp:
- Dec 30, 2018, 1:01:14 AM (6 years ago)
- Location:
- branches/overos
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/overos/UControls.pas
r21 r22 14 14 TControl = class 15 15 private 16 FOnClick: TNotifyEvent; 16 17 FParentControl: TControl; 18 FRectangle: TRectangle; 17 19 FVisible: Boolean; 20 function GetPosition: TPosition; 21 function GetSize: TSize; 18 22 procedure SetParentControl(AValue: TControl); 19 procedure SetVisible(AValue: Boolean); 23 procedure SetPosition(AValue: TPosition); 24 procedure SetSize(AValue: TSize); 25 protected 26 procedure SetRectangle(AValue: TRectangle); virtual; 27 procedure SetVisible(AValue: Boolean); virtual; 20 28 public 21 29 Canvas: TCanvas; 22 Rectangle: TRectangle;23 30 Controls: TFPGObjectList<TControl>; 24 31 procedure MouseButtonDown(Pos: TPosition; Button: TMouseButton); virtual; … … 30 37 property ParentControl: TControl read FParentControl write SetParentControl; 31 38 property Visible: Boolean read FVisible write SetVisible; 39 property Position: TPosition read GetPosition write SetPosition; 40 property Size: TSize read GetSize write SetSize; 41 property Rectangle: TRectangle read FRectangle write SetRectangle; 42 property OnClick: TNotifyEvent read FOnClick write FOnClick; 32 43 end; 33 44 … … 39 50 procedure DrawArea(Rect: TRectangle; Color: TColor); override; 40 51 procedure DrawText(P: TPosition; Color: TColor; Text: string); override; 52 function GetTextSize(Text: string): TSize; override; 41 53 end; 42 54 … … 47 59 FClicked: Boolean; 48 60 FTitle: string; 49 procedure MouseButtonDown(Pos: TPosition; Button: TMouseButton); override;50 procedure MouseButtonUp(Pos: TPosition; Button: TMouseButton); override;51 61 procedure SetClicked(AValue: Boolean); 52 62 procedure SetTitle(AValue: string); 53 63 public 64 procedure MouseButtonDown(Pos: TPosition; Button: TMouseButton); override; 65 procedure MouseButtonUp(Pos: TPosition; Button: TMouseButton); override; 54 66 procedure Paint; override; 55 67 property Clicked: Boolean read FClicked write SetClicked; … … 85 97 procedure TCanvasControl.DrawLine(P1, P2: TPosition; Color: TColor); 86 98 begin 87 Control.ParentControl.Canvas.DrawLine(P1 + Control.Rectangle.Position, P2 + Control.Rectangle.Position, Color); 99 if Assigned(Control) and Assigned(Control.ParentControl) then 100 Control.ParentControl.Canvas.DrawLine(P1 + Control.Rectangle.Position, P2 + Control.Rectangle.Position, Color); 88 101 end; 89 102 90 103 procedure TCanvasControl.DrawArea(Rect: TRectangle; Color: TColor); 91 104 begin 92 Control.ParentControl.Canvas.DrawArea(TRectangle.Create(Rect.Position + Control.Rectangle.Position, 93 Rect.Size), Color); 105 if Assigned(Control) and Assigned(Control.ParentControl) then 106 Control.ParentControl.Canvas.DrawArea(TRectangle.Create(Rect.Position + Control.Rectangle.Position, 107 Rect.Size), Color); 94 108 end; 95 109 96 110 procedure TCanvasControl.DrawText(P: TPosition; Color: TColor; Text: string); 97 111 begin 98 Control.ParentControl.Canvas.DrawText(P + Control.Rectangle.Position, Color, Text); 112 if Assigned(Control) and Assigned(Control.ParentControl) then 113 Control.ParentControl.Canvas.DrawText(P + Control.Rectangle.Position, Color, Text); 114 end; 115 116 function TCanvasControl.GetTextSize(Text: string): TSize; 117 begin 118 if Assigned(Control) and Assigned(Control.ParentControl) then 119 Result := Control.ParentControl.Canvas.GetTextSize(Text); 99 120 end; 100 121 … … 105 126 if FVisible = AValue then Exit; 106 127 FVisible := AValue; 107 Paint; 128 if not FVisible then begin 129 if Assigned(ParentControl) then ParentControl.Paint; 130 end else Paint; 108 131 end; 109 132 … … 128 151 Break; 129 152 end; 153 if Assigned(FOnClick) then 154 FOnClick(Self); 130 155 end; 131 156 … … 151 176 end; 152 177 178 function TControl.GetPosition: TPosition; 179 begin 180 Result := FRectangle.Position; 181 end; 182 183 function TControl.GetSize: TSize; 184 begin 185 Result := FRectangle.Size; 186 end; 187 188 procedure TControl.SetPosition(AValue: TPosition); 189 begin 190 Rectangle := TRectangle.Create(AValue, FRectangle.Size); 191 end; 192 193 procedure TControl.SetSize(AValue: TSize); 194 begin 195 Rectangle := TRectangle.Create(FRectangle.Position, AValue); 196 end; 197 198 procedure TControl.SetRectangle(AValue: TRectangle); 199 begin 200 if FRectangle = AValue then Exit; 201 FRectangle := AValue; 202 end; 203 153 204 procedure TControl.Paint; 154 205 var 155 206 I: Integer; 156 207 begin 157 for I := 0 to Controls.Count - 1 do 158 Controls[I].Paint; 208 if FVisible then begin 209 for I := 0 to Controls.Count - 1 do 210 Controls[I].Paint; 211 end; 159 212 end; 160 213 … … 168 221 169 222 destructor TControl.Destroy; 170 begin 223 var 224 I: Integer; 225 begin 226 for I := 0 to Controls.Count - 1 do 227 Controls[I].Free; 228 ParentControl := nil; 171 229 Canvas.Free; 172 230 Controls.Free; … … 185 243 procedure TEdit.Paint; 186 244 begin 187 Canvas.DrawArea(TRectangle.Create(TPosition.Create(0, 0), Rectangle.Size), clBlack); 188 Canvas.DrawFrame(TRectangle.Create(TPosition.Create(0, 0), Rectangle.Size), clWhite); 189 Canvas.DrawText(TPosition.Create(4, 4), clWhite, FText); 245 if FVisible then begin 246 Canvas.DrawArea(TRectangle.Create(TPosition.Create(0, 0), Rectangle.Size), clBlack); 247 Canvas.DrawFrame(TRectangle.Create(TPosition.Create(0, 0), Rectangle.Size), clWhite); 248 Canvas.DrawText(TPosition.Create(4, 4), clWhite, FText); 249 end; 190 250 inherited; 191 251 end; … … 202 262 procedure TLabel.Paint; 203 263 begin 204 Canvas.DrawText(TPosition.Create(0, 0), clWhite, FTitle); 264 if FVisible then begin 265 Canvas.DrawText(TPosition.Create(0, 0), clWhite, FTitle); 266 end; 205 267 inherited; 206 268 end; … … 237 299 var 238 300 Color: TColor; 239 begin 240 if Clicked then Color := clBlack 241 else Color := clGray; 242 Canvas.DrawArea(TRectangle.Create(TPosition.Create(0, 0), Rectangle.Size), Color); 243 Canvas.DrawFrame(TRectangle.Create(TPosition.Create(0, 0), Rectangle.Size), clWhite); 244 Canvas.DrawText(TPosition.Create(8, 8), clWhite, FTitle); 301 TextSize: TSize; 302 begin 303 if FVisible then begin 304 if Clicked then Color := clBlack 305 else Color := clGray; 306 Canvas.DrawArea(TRectangle.Create(TPosition.Create(0, 0), Rectangle.Size), Color); 307 Canvas.DrawFrame(TRectangle.Create(TPosition.Create(0, 0), Rectangle.Size), clWhite); 308 TextSize := Canvas.GetTextSize(FTitle); 309 Canvas.DrawText(TPosition.Create((Size.Width - TextSize.Width) div 2, 310 (Size.Height - TextSize.Height) div 2), clWhite, FTitle); 311 end; 245 312 inherited; 246 313 end; -
branches/overos/UFormMain.lfm
r20 r22 21 21 OnMouseUp = Image1MouseUp 22 22 end 23 object Timer1: TTimer 24 Interval = 10 25 OnTimer = Timer1Timer 26 left = 303 27 top = 201 28 end 23 29 end -
branches/overos/UFormMain.pas
r21 r22 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, 9 UWindow, USystem, UTypes, UMouse, UGraphics, UControls;9 Types, UWindow, USystem, UTypes, UMouse, UGraphics, UControls, UApplication; 10 10 11 11 type … … 16 16 TFormMain = class(TForm) 17 17 Image1: TImage; 18 Timer1: TTimer; 18 19 procedure Image1MouseDown(Sender: TObject; Button: TControlsMouseButton; 19 20 Shift: TShiftState; X, Y: Integer); … … 23 24 procedure FormResize(Sender: TObject); 24 25 procedure FormShow(Sender: TObject); 26 procedure Timer1Timer(Sender: TObject); 25 27 private 26 28 27 29 public 30 App: TApplication; 28 31 System: TSystem; 29 32 end; … … 36 39 procedure DrawArea(Rect: TRectangle; Color: TColor); override; 37 40 procedure DrawText(P: TPosition; Color: TColor; Text: string); override; 41 function GetTextSize(Text: string): TSize; override; 38 42 end; 39 43 … … 66 70 procedure TCanvasScreen.DrawText(P: TPosition; Color: TColor; Text: string); 67 71 begin 72 Canvas.Brush.Style := bsClear; 68 73 Canvas.Font.Color := Color; 69 74 Canvas.TextOut(P.Left, P.Top, Text); 75 end; 76 77 function TCanvasScreen.GetTextSize(Text: string): TSize; 78 var 79 Size: Types.TSize; 80 begin 81 Size := Canvas.TextExtent(Text); 82 Result := TSize.Create(Size.cx, Size.cy); 70 83 end; 71 84 … … 125 138 System.Screen.Size := TSize.Create(Width, Height); 126 139 140 App := TApplication.Create; 141 127 142 Window := System.Screen.CreateWindow('Test'); 143 Window.Application := App; 128 144 129 145 Window := System.Screen.CreateWindow('Commander'); 130 Window.Rectangle.Position := TPosition.Create(100, 50); 131 Window.Rectangle.Size := TSize.Create(400, 200); 146 Window.Position := TPosition.Create(100, 50); 147 Window.Size := TSize.Create(400, 200); 148 Window.Application := App; 132 149 Button := TButton.Create; 133 150 Button.Rectangle := TRectangle.Create(TPosition.Create(10, 50), TSize.Create(100, 32)); … … 137 154 138 155 Window := System.Screen.CreateWindow('Calculator'); 139 Window.Rectangle.Position := TPosition.Create(200, 100); 140 Window.Rectangle.Size := TSize.Create(300, 200); 156 Window.Application := App; 157 Window.Position := TPosition.Create(200, 100); 158 Window.Size := TSize.Create(300, 200); 141 159 142 160 System.Screen.Paint; 143 161 end; 144 162 163 procedure TFormMain.Timer1Timer(Sender: TObject); 164 begin 165 App.ProcessMessages; 166 end; 167 145 168 end. 146 169 -
branches/overos/UGraphics.pas
r21 r22 18 18 procedure DrawArea(Rect: TRectangle; Color: TColor); virtual; 19 19 procedure DrawText(P: TPosition; Color: TColor; Text: string); virtual; 20 function GetTextSize(Text: string): TSize; virtual; 20 21 end; 21 22 … … 51 52 end; 52 53 54 function TCanvas.GetTextSize(Text: string): TSize; 55 begin 56 Result := TSize.Create(0, 0); 57 end; 58 53 59 54 60 end. -
branches/overos/UTypes.pas
r21 r22 18 18 class operator Add(A, B: TSize): TSize; 19 19 class operator Subtract(A, B: TSize): TSize; 20 class operator Equal(A, B: TSize): Boolean; 20 21 end; 21 22 … … 28 29 class operator Add(A, B: TPosition): TPosition; 29 30 class operator Subtract(A, B: TPosition): TPosition; 31 class operator Equal(A, B: TPosition): Boolean; 30 32 end; 31 33 … … 37 39 function Create(Position: TPosition; Size: TSize): TRectangle; 38 40 function Contains(Position: TPosition): Boolean; 41 class operator Equal(A, B: TRectangle): Boolean; 42 end; 43 44 TMessage = class 45 Handle: TObject; 39 46 end; 40 47 … … 56 63 (Self.Position.Left + Self.Size.Width >= Position.Left) and 57 64 (Self.Position.Top + Self.Size.Height >= Position.Top); 65 end; 66 67 class operator TRectangle.Equal(A, B: TRectangle): Boolean; 68 begin 69 Result := (A.Position = B.Position) and (A.Size = B.Size); 58 70 end; 59 71 … … 78 90 end; 79 91 92 class operator TPosition.Equal(A, B: TPosition): Boolean; 93 begin 94 Result := (A.Left = B.Left) and (A.Top = B.Top); 95 end; 96 80 97 { TSize } 81 98 … … 98 115 end; 99 116 117 class operator TSize.Equal(A, B: TSize): Boolean; 118 begin 119 Result := (A.Width = B.Width) and (A.Height = B.Height); 120 end; 121 100 122 101 123 end. -
branches/overos/UWindow.pas
r21 r22 19 19 procedure DrawArea(Rect: TRectangle; Color: TColor); override; 20 20 procedure DrawText(P: TPosition; Color: TColor; Text: string); override; 21 function GetTextSize(Text: string): TSize; override; 21 22 end; 22 23 23 24 TWindowSide = (wsNone, wsLeft, wsTop, wsRight, wsBottom); 24 25 25 { TWindow } 26 27 TWindow = class(TControl) 26 { TTitleBar } 27 28 TTitleBar = class(TControl) 29 private 30 FWindow: TWindow; 31 procedure SetWindow(AValue: TWindow); 32 procedure ButtonCloseClick(Sender: TObject); 33 procedure ButtonMaximizeClick(Sender: TObject); 34 procedure ButtonMinimizeClick(Sender: TObject); 35 protected 36 procedure SetRectangle(AValue: TRectangle); override; 28 37 public 29 38 const 30 39 TitleHeight = 32; 40 var 41 ButtonClose: TButton; 42 ButtonMaximize: TButton; 43 ButtonMinimize: TButton; 44 constructor Create; override; 45 destructor Destroy; override; 46 property Window: TWindow read FWindow write SetWindow; 47 end; 48 49 TMessageWindowClose = class(TMessage); 50 51 { TWindow } 52 53 TWindow = class(TControl) 54 private 55 FScreen: TScreen; 56 procedure SetScreen(AValue: TScreen); 57 protected 58 procedure SetRectangle(AValue: TRectangle); override; 59 procedure SetVisible(AValue: Boolean); override; 60 public 61 const 31 62 BorderGrabWidth = 15; 32 63 var 64 TitleBar: TTitleBar; 33 65 Title: string; 34 Screen: TScreen; 66 Application: TObject; // TApplication 67 procedure MouseButtonDown(Pos: TPosition; Button: TMouseButton); override; 68 procedure MouseButtonUp(Pos: TPosition; Button: TMouseButton); override; 69 procedure Close; 35 70 procedure Focus; 36 71 procedure Paint; override; … … 38 73 constructor Create; override; 39 74 destructor Destroy; override; 75 property Screen: TScreen read FScreen write SetScreen; 40 76 end; 41 77 … … 68 104 implementation 69 105 106 uses 107 UApplication; 108 109 { TTitleBar } 110 111 procedure TTitleBar.SetWindow(AValue: TWindow); 112 begin 113 if FWindow = AValue then Exit; 114 Canvas.Free; 115 FWindow := AValue; 116 Canvas := TCanvasWindow.Create; 117 TCanvasWindow(Canvas).Window := FWindow; 118 end; 119 120 procedure TTitleBar.ButtonCloseClick(Sender: TObject); 121 begin 122 Window.Close; 123 end; 124 125 procedure TTitleBar.ButtonMaximizeClick(Sender: TObject); 126 begin 127 Rectangle := TRectangle.Create(TPosition.Create(0, 0), Window.Screen.Size); 128 Paint; 129 end; 130 131 procedure TTitleBar.ButtonMinimizeClick(Sender: TObject); 132 begin 133 134 end; 135 136 procedure TTitleBar.SetRectangle(AValue: TRectangle); 137 begin 138 inherited; 139 ButtonClose.Rectangle := TRectangle.Create(TPosition.Create(Size.Width - TitleHeight, 4), 140 TSize.Create(TitleHeight - 8, TitleHeight - 8)); 141 ButtonMaximize.Rectangle := TRectangle.Create(TPosition.Create(Size.Width - 2 * TitleHeight, 4), 142 TSize.Create(TitleHeight - 8, TitleHeight - 8)); 143 ButtonMinimize.Rectangle := TRectangle.Create(TPosition.Create(Size.Width - 3 * TitleHeight, 4), 144 TSize.Create(TitleHeight - 8, TitleHeight - 8)); 145 end; 146 147 constructor TTitleBar.Create; 148 begin 149 inherited; 150 151 ButtonClose := TButton.Create; 152 ButtonClose.Title := 'X'; 153 ButtonClose.ParentControl := Self; 154 ButtonClose.OnClick := ButtonCloseClick; 155 ButtonClose.Visible := True; 156 157 ButtonMaximize := TButton.Create; 158 ButtonMaximize.Title := '^'; 159 ButtonMaximize.ParentControl := Self; 160 ButtonMaximize.OnClick := ButtonMaximizeClick; 161 ButtonMaximize.Visible := True; 162 163 ButtonMinimize := TButton.Create; 164 ButtonMinimize.Title := '_'; 165 ButtonMinimize.ParentControl := Self; 166 ButtonMinimize.OnClick := ButtonMinimizeClick; 167 ButtonMinimize.Visible := True; 168 end; 169 170 destructor TTitleBar.Destroy; 171 begin 172 ButtonClose.Free; 173 ButtonMaximize.Free; 174 ButtonMinimize.Free; 175 inherited Destroy; 176 end; 177 70 178 { TCanvasWindow } 71 179 72 180 procedure TCanvasWindow.DrawLine(P1, P2: TPosition; Color: TColor); 73 181 begin 74 Window.Screen.Canvas.DrawLine(P1 + Window.Rectangle.Position, P2 + Window.Rectangle.Position, Color); 182 if Assigned(Window) and Assigned(Window.Screen) then 183 Window.Screen.Canvas.DrawLine(P1 + Window.Position, P2 + Window.Position, Color); 75 184 end; 76 185 77 186 procedure TCanvasWindow.DrawArea(Rect: TRectangle; Color: TColor); 78 187 begin 79 Window.Screen.Canvas.DrawArea(TRectangle.Create(Rect.Position + Window.Rectangle.Position, 80 Rect.Size), Color); 188 if Assigned(Window) and Assigned(Window.Screen) then 189 Window.Screen.Canvas.DrawArea(TRectangle.Create(Rect.Position + Window.Position, 190 Rect.Size), Color); 81 191 end; 82 192 83 193 procedure TCanvasWindow.DrawText(P: TPosition; Color: TColor; Text: string); 84 194 begin 85 Window.Screen.Canvas.DrawText(P + Window.Rectangle.Position, Color, Text); 195 if Assigned(Window) and Assigned(Window.Screen) then 196 Window.Screen.Canvas.DrawText(P + Window.Position, Color, Text); 197 end; 198 199 function TCanvasWindow.GetTextSize(Text: string): TSize; 200 begin 201 if Assigned(Window) and Assigned(Window.Screen) then 202 Result := Window.Screen.Canvas.GetTextSize(Text); 86 203 end; 87 204 88 205 { TWindow } 206 207 procedure TWindow.SetScreen(AValue: TScreen); 208 begin 209 if FScreen = AValue then Exit; 210 if Assigned(FScreen) then 211 FScreen.Windows.Remove(Self); 212 FScreen := AValue; 213 if Assigned(FScreen) then 214 FScreen.Windows.Add(Self); 215 end; 216 217 procedure TWindow.SetRectangle(AValue: TRectangle); 218 begin 219 inherited; 220 TitleBar.Rectangle := TRectangle.Create(Position, TSize.Create(Size.Width, TitleBar.TitleHeight)); 221 end; 222 223 procedure TWindow.SetVisible(AValue: Boolean); 224 begin 225 inherited; 226 if not Visible and Assigned(Screen) then 227 Screen.Paint; 228 end; 229 230 procedure TWindow.MouseButtonDown(Pos: TPosition; Button: TMouseButton); 231 begin 232 inherited; 233 TitleBar.MouseButtonDown(Pos, Button); 234 end; 235 236 procedure TWindow.MouseButtonUp(Pos: TPosition; Button: TMouseButton); 237 begin 238 inherited; 239 TitleBar.MouseButtonUp(Pos, Button); 240 end; 241 242 procedure TWindow.Close; 243 begin 244 TApplication(Application).MessageQueue.PostMessage(Self, TMessageWindowClose.Create); 245 end; 89 246 90 247 procedure TWindow.Focus; … … 98 255 procedure TWindow.Paint; 99 256 begin 100 Canvas.DrawArea(TRectangle.Create(TPosition.Create(0, 0), Rectangle.Size), clGray); 101 Canvas.DrawFrame(TRectangle.Create(TPosition.Create(0, 0), Rectangle.Size), clWhite); 102 Canvas.DrawLine(TPosition.Create(0, TitleHeight), 103 TPosition.Create(Rectangle.Size.Width, TitleHeight), clWhite); 104 Canvas.DrawText(TPosition.Create(8, 4), clWhite, Title); 257 if Visible then begin 258 Canvas.DrawArea(TRectangle.Create(TPosition.Create(0, 0), Size), clGray); 259 Canvas.DrawFrame(TRectangle.Create(TPosition.Create(0, 0), Size), clWhite); 260 Canvas.DrawLine(TPosition.Create(0, TitleBar.TitleHeight), 261 TPosition.Create(Size.Width, TitleBar.TitleHeight), clWhite); 262 Canvas.DrawText(TPosition.Create(8, 4), clWhite, Title); 263 TitleBar.Paint; 264 end; 105 265 inherited; 106 266 end; … … 117 277 Canvas := TCanvasWindow.Create; 118 278 TCanvasWindow(Canvas).Window := Self; 279 TitleBar := TTitleBar.Create; 280 TitleBar.Window := Self; 281 TitleBar.Visible := True; 119 282 end; 120 283 121 284 destructor TWindow.Destroy; 122 285 begin 286 Visible := False; 287 TitleBar.Free; 288 Screen := nil; 123 289 inherited Destroy; 124 290 end; … … 133 299 for I := Windows.Count - 1 downto 0 do begin 134 300 Window := Windows[I]; 135 if TRectangle.Create(Window. Rectangle.Position - TPosition.Create(Window.BorderGrabWidth div 2, 0),136 TSize.Create(Window.BorderGrabWidth, Window. Rectangle.Size.Height)).Contains(Pos) then begin301 if TRectangle.Create(Window.Position - TPosition.Create(Window.BorderGrabWidth div 2, 0), 302 TSize.Create(Window.BorderGrabWidth, Window.Size.Height)).Contains(Pos) then begin 137 303 GrabMousePosition := Pos; 138 304 GrabWindowRectangle := Window.Rectangle; … … 141 307 GrabActive := True; 142 308 end else 143 if TRectangle.Create(Window. Rectangle.Position - TPosition.Create(0, Window.BorderGrabWidth div 2),144 TSize.Create(Window. Rectangle.Size.Width, Window.BorderGrabWidth)).Contains(Pos) then begin309 if TRectangle.Create(Window.Position - TPosition.Create(0, Window.BorderGrabWidth div 2), 310 TSize.Create(Window.Size.Width, Window.BorderGrabWidth)).Contains(Pos) then begin 145 311 GrabMousePosition := Pos; 146 312 GrabWindowRectangle := Window.Rectangle; … … 149 315 GrabActive := True; 150 316 end else 151 if TRectangle.Create(Window. Rectangle.Position + TPosition.Create(Window.Rectangle.Size.Width, 0) - TPosition.Create(Window.BorderGrabWidth div 2, 0),152 TSize.Create(Window.BorderGrabWidth, Window. Rectangle.Size.Height)).Contains(Pos) then begin317 if TRectangle.Create(Window.Position + TPosition.Create(Window.Size.Width, 0) - TPosition.Create(Window.BorderGrabWidth div 2, 0), 318 TSize.Create(Window.BorderGrabWidth, Window.Size.Height)).Contains(Pos) then begin 153 319 GrabMousePosition := Pos; 154 320 GrabWindowRectangle := Window.Rectangle; … … 157 323 GrabActive := True; 158 324 end else 159 if TRectangle.Create(Window. Rectangle.Position + TPosition.Create(0, Window.Rectangle.Size.Height) - TPosition.Create(0, Window.BorderGrabWidth div 2),160 TSize.Create(Window. Rectangle.Size.Width, Window.BorderGrabWidth)).Contains(Pos) then begin325 if TRectangle.Create(Window.Position + TPosition.Create(0, Window.Size.Height) - TPosition.Create(0, Window.BorderGrabWidth div 2), 326 TSize.Create(Window.Size.Width, Window.BorderGrabWidth)).Contains(Pos) then begin 161 327 GrabMousePosition := Pos; 162 328 GrabWindowRectangle := Window.Rectangle; … … 165 331 GrabActive := True; 166 332 end else 167 if TRectangle.Create(Window. Rectangle.Position, TSize.Create(Window.Rectangle.Size.Width, Window.TitleHeight)).Contains(Pos) then begin333 if TRectangle.Create(Window.Position, TSize.Create(Window.Size.Width, Window.TitleBar.TitleHeight)).Contains(Pos) then begin 168 334 GrabMousePosition := Pos; 169 335 GrabWindowRectangle := Window.Rectangle; … … 174 340 if Window.Rectangle.Contains(Pos) then begin 175 341 Window.Focus; 176 Window.MouseButtonDown(Pos - Window. Rectangle.Position, Button);342 Window.MouseButtonDown(Pos - Window.Position, Button); 177 343 Break; 178 344 end; … … 192 358 Window := Windows[I]; 193 359 if Window.Rectangle.Contains(Pos) then begin 194 Window.MouseButtonUp(Pos - Window. Rectangle.Position, Button);360 Window.MouseButtonUp(Pos - Window.Position, Button); 195 361 Break; 196 362 end; … … 204 370 if GrabActive then begin 205 371 if GrabWindowSide = wsNone then 206 GrabWindow. Rectangle.Position := GrabWindowRectangle.Position + (Pos - GrabMousePosition)372 GrabWindow.Position := GrabWindowRectangle.Position + (Pos - GrabMousePosition) 207 373 else if GrabWindowSide = wsLeft then 208 374 GrabWindow.Rectangle := TRectangle.Create(GrabWindowRectangle.Position + TPosition.Create(Pos.Left - GrabMousePosition.Left, 0), … … 221 387 for I := Windows.Count - 1 downto 0 do begin 222 388 if Windows[I].Rectangle.Contains(Pos) then begin 223 Windows[I].MouseMove(Pos - Windows[I]. Rectangle.Position);389 Windows[I].MouseMove(Pos - Windows[I].Position); 224 390 Break; 225 391 end; … … 255 421 begin 256 422 Result := TWindow.Create; 257 Windows.Add(Result);258 423 Result.Screen := Self; 259 424 Result.Title := Title; … … 265 430 begin 266 431 Windows := TFPGObjectList<TWindow>.Create; 432 Windows.FreeObjects := False; 267 433 Canvas := TCanvas.Create; 268 434 end; 269 435 270 436 destructor TScreen.Destroy; 271 begin 437 var 438 I: Integer; 439 begin 440 for I := 0 to Windows.Count - 1 do 441 Windows[I].Free; 272 442 Windows.Free; 273 443 Canvas.Free; -
branches/overos/overos.lpi
r21 r22 11 11 <Icon Value="0"/> 12 12 </General> 13 <BuildModes Count="1"> 14 <Item1 Name="Default" Default="True"/> 13 <BuildModes Count="2"> 14 <Item1 Name="Debug" Default="True"/> 15 <Item2 Name="Release"> 16 <CompilerOptions> 17 <Version Value="11"/> 18 <Target> 19 <Filename Value="overos"/> 20 </Target> 21 <SearchPaths> 22 <IncludeFiles Value="$(ProjOutDir)"/> 23 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/> 24 </SearchPaths> 25 <Parsing> 26 <SyntaxOptions> 27 <SyntaxMode Value="Delphi"/> 28 <CStyleOperator Value="False"/> 29 <AllowLabel Value="False"/> 30 <CPPInline Value="False"/> 31 </SyntaxOptions> 32 </Parsing> 33 <CodeGeneration> 34 <SmartLinkUnit Value="True"/> 35 <Optimizations> 36 <OptimizationLevel Value="3"/> 37 </Optimizations> 38 </CodeGeneration> 39 <Linking> 40 <Debugging> 41 <GenerateDebugInfo Value="False"/> 42 </Debugging> 43 <LinkSmart Value="True"/> 44 <Options> 45 <Win32> 46 <GraphicApplication Value="True"/> 47 </Win32> 48 </Options> 49 </Linking> 50 </CompilerOptions> 51 </Item2> 15 52 </BuildModes> 16 53 <PublishOptions> … … 27 64 </Item1> 28 65 </RequiredPackages> 29 <Units Count=" 8">66 <Units Count="9"> 30 67 <Unit0> 31 68 <Filename Value="overos.lpr"/> … … 63 100 <IsPartOfProject Value="True"/> 64 101 </Unit7> 102 <Unit8> 103 <Filename Value="UApplication.pas"/> 104 <IsPartOfProject Value="True"/> 105 </Unit8> 65 106 </Units> 66 107 </ProjectOptions> … … 72 113 <SearchPaths> 73 114 <IncludeFiles Value="$(ProjOutDir)"/> 74 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS) "/>115 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/> 75 116 </SearchPaths> 76 117 <Parsing> 77 118 <SyntaxOptions> 78 119 <SyntaxMode Value="Delphi"/> 120 <CStyleOperator Value="False"/> 121 <IncludeAssertionCode Value="True"/> 122 <AllowLabel Value="False"/> 123 <CPPInline Value="False"/> 79 124 </SyntaxOptions> 80 125 </Parsing> 126 <CodeGeneration> 127 <Checks> 128 <IOChecks Value="True"/> 129 <RangeChecks Value="True"/> 130 <OverflowChecks Value="True"/> 131 <StackChecks Value="True"/> 132 </Checks> 133 <VerifyObjMethodCallValidity Value="True"/> 134 </CodeGeneration> 81 135 <Linking> 136 <Debugging> 137 <UseHeaptrc Value="True"/> 138 </Debugging> 82 139 <Options> 83 140 <Win32> -
branches/overos/overos.lpr
r21 r22 8 8 {$ENDIF}{$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, UFormMain, UWindow, UMouse, USystem, UTypes, UControls, UGraphics 10 Forms, UFormMain, UWindow, UMouse, USystem, UTypes, UControls, UGraphics, 11 UApplication 11 12 { you can add units after this }; 12 13
Note:
See TracChangeset
for help on using the changeset viewer.