- Timestamp:
- Dec 29, 2018, 10:12:23 PM (6 years ago)
- Location:
- branches/overos
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/overos
-
Property svn:ignore
set to
overos
lib
overos.lps
overos.res
-
Property svn:ignore
set to
-
branches/overos/UFormMain.pas
r20 r21 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, 9 UWindow, USystem, UTypes, UMouse ;9 UWindow, USystem, UTypes, UMouse, UGraphics, UControls; 10 10 11 11 type … … 89 89 begin 90 90 Caption := IntToStr(X) + ',' + IntToStr(Y); 91 System.Mouse.Move(TPosition.Create( Mouse.CursorPos.X, Mouse.CursorPos.Y));91 System.Mouse.Move(TPosition.Create(X, Y)); 92 92 end; 93 93 … … 117 117 var 118 118 Window: TWindow; 119 Button: TButton; 119 120 begin 120 121 System := TSystem.Create; … … 129 130 Window.Rectangle.Position := TPosition.Create(100, 50); 130 131 Window.Rectangle.Size := TSize.Create(400, 200); 132 Button := TButton.Create; 133 Button.Rectangle := TRectangle.Create(TPosition.Create(10, 50), TSize.Create(100, 32)); 134 Button.ParentControl := Window; 135 Button.Title := 'Click'; 136 Button.Visible := True; 131 137 132 138 Window := System.Screen.CreateWindow('Calculator'); -
branches/overos/UTypes.pas
r20 r21 16 16 Height: Integer; 17 17 function Create(Width, Height: Integer): TSize; 18 class operator Add(A, B: TSize): TSize; 19 class operator Subtract(A, B: TSize): TSize; 18 20 end; 19 21 … … 36 38 function Contains(Position: TPosition): Boolean; 37 39 end; 38 39 TColor = Integer;40 40 41 41 … … 86 86 end; 87 87 88 class operator TSize.Add(A, B: TSize): TSize; 89 begin 90 Result.Width := A.Width + B.Width; 91 Result.Height := A.Height + B.Height; 92 end; 93 94 class operator TSize.Subtract(A, B: TSize): TSize; 95 begin 96 Result.Width := A.Width - B.Width; 97 Result.Height := A.Height - B.Height; 98 end; 99 88 100 89 101 end. -
branches/overos/UWindow.pas
r20 r21 6 6 7 7 uses 8 Classes, SysUtils, fgl, UTypes, UMouse ;8 Classes, SysUtils, fgl, UTypes, UMouse, UControls, UGraphics; 9 9 10 10 type 11 { TCanvas }12 13 TCanvas = class14 procedure DrawLine(P1, P2: TPosition; Color: TColor); virtual;15 procedure DrawFrame(Rect: TRectangle; Color: TColor); virtual;16 procedure DrawArea(Rect: TRectangle; Color: TColor); virtual;17 procedure DrawText(P: TPosition; Color: TColor; Text: string); virtual;18 end;19 20 11 TScreen = class; 21 12 TWindow = class; … … 30 21 end; 31 22 23 TWindowSide = (wsNone, wsLeft, wsTop, wsRight, wsBottom); 24 32 25 { TWindow } 33 26 34 TWindow = class 35 private 36 FVisible: Boolean; 37 procedure MouseButtonDown(Pos: TPosition; Button: TMouseButton); 38 procedure MouseButtonUp(Pos: TPosition; Button: TMouseButton); 39 procedure MouseMove(Pos: TPosition); 40 procedure SetVisible(AValue: Boolean); 27 TWindow = class(TControl) 41 28 public 42 Canvas: TCanvas; 29 const 30 TitleHeight = 32; 31 BorderGrabWidth = 15; 32 var 43 33 Title: string; 44 Rectangle: TRectangle;45 34 Screen: TScreen; 46 35 procedure Focus; 47 procedure Paint; 36 procedure Paint; override; 48 37 function Focused: Boolean; 49 property Visible: Boolean read FVisible write SetVisible; 50 constructor Create; 38 constructor Create; override; 51 39 destructor Destroy; override; 52 40 end; … … 57 45 private 58 46 FMouse: TMouse; 47 GrabActive: Boolean; 48 GrabWindow: TWindow; 49 GrabMousePosition: TPosition; 50 GrabWindowRectangle: TRectangle; 51 GrabWindowSide: TWindowSide; 59 52 procedure MouseButtonDown(Pos: TPosition; Button: TMouseButton); 60 53 procedure MouseButtonUp(Pos: TPosition; Button: TMouseButton); … … 72 65 end; 73 66 74 const75 clBlack = $000000;76 clGray = $808080;77 clWhite = $ffffff;78 67 79 68 implementation 80 81 { TCanvas }82 83 procedure TCanvas.DrawLine(P1, P2: TPosition; Color: TColor);84 begin85 end;86 87 procedure TCanvas.DrawFrame(Rect: TRectangle; Color: TColor);88 begin89 with Rect do begin90 DrawLine(Position, Position + TPosition.Create(Size.Width, 0), Color);91 DrawLine(Position + TPosition.Create(Size.Width, 0), Position + TPosition.Create(Size.Width, Size.Height), Color);92 DrawLine(Position + TPosition.Create(Size.Width, Size.Height), Position + TPosition.Create(0, Size.Height), Color);93 DrawLine(Position + TPosition.Create(0, Size.Height), Position, Color);94 end;95 end;96 97 procedure TCanvas.DrawArea(Rect: TRectangle; Color: TColor);98 begin99 end;100 101 procedure TCanvas.DrawText(P: TPosition; Color: TColor; Text: string);102 begin103 end;104 69 105 70 { TCanvasWindow } … … 122 87 123 88 { TWindow } 124 125 procedure TWindow.MouseButtonDown(Pos: TPosition; Button: TMouseButton);126 begin127 Focus;128 end;129 130 procedure TWindow.MouseButtonUp(Pos: TPosition; Button: TMouseButton);131 begin132 133 end;134 135 procedure TWindow.MouseMove(Pos: TPosition);136 begin137 138 end;139 140 procedure TWindow.SetVisible(AValue: Boolean);141 begin142 if FVisible = AValue then Exit;143 FVisible := AValue;144 Paint;145 end;146 89 147 90 procedure TWindow.Focus; … … 154 97 155 98 procedure TWindow.Paint; 156 const157 TitleHeight = 32;158 99 begin 159 100 Canvas.DrawArea(TRectangle.Create(TPosition.Create(0, 0), Rectangle.Size), clGray); … … 162 103 TPosition.Create(Rectangle.Size.Width, TitleHeight), clWhite); 163 104 Canvas.DrawText(TPosition.Create(8, 4), clWhite, Title); 105 inherited; 164 106 end; 165 107 … … 171 113 constructor TWindow.Create; 172 114 begin 115 inherited; 116 Canvas.Free; 173 117 Canvas := TCanvasWindow.Create; 174 118 TCanvasWindow(Canvas).Window := Self; … … 177 121 destructor TWindow.Destroy; 178 122 begin 179 Canvas.Free;180 123 inherited Destroy; 181 124 end; … … 188 131 Window: TWindow; 189 132 begin 133 for I := Windows.Count - 1 downto 0 do begin 134 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 begin 137 GrabMousePosition := Pos; 138 GrabWindowRectangle := Window.Rectangle; 139 GrabWindow := Window; 140 GrabWindowSide := wsLeft; 141 GrabActive := True; 142 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 begin 145 GrabMousePosition := Pos; 146 GrabWindowRectangle := Window.Rectangle; 147 GrabWindow := Window; 148 GrabWindowSide := wsTop; 149 GrabActive := True; 150 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 begin 153 GrabMousePosition := Pos; 154 GrabWindowRectangle := Window.Rectangle; 155 GrabWindow := Window; 156 GrabWindowSide := wsRight; 157 GrabActive := True; 158 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 begin 161 GrabMousePosition := Pos; 162 GrabWindowRectangle := Window.Rectangle; 163 GrabWindow := Window; 164 GrabWindowSide := wsBottom; 165 GrabActive := True; 166 end else 167 if TRectangle.Create(Window.Rectangle.Position, TSize.Create(Window.Rectangle.Size.Width, Window.TitleHeight)).Contains(Pos) then begin 168 GrabMousePosition := Pos; 169 GrabWindowRectangle := Window.Rectangle; 170 GrabWindow := Window; 171 GrabWindowSide := wsNone; 172 GrabActive := True; 173 end; 174 if Window.Rectangle.Contains(Pos) then begin 175 Window.Focus; 176 Window.MouseButtonDown(Pos - Window.Rectangle.Position, Button); 177 Break; 178 end; 179 end; 180 end; 181 182 procedure TScreen.MouseButtonUp(Pos: TPosition; Button: TMouseButton); 183 var 184 I: Integer; 185 Window: TWindow; 186 begin 187 if GrabActive then begin 188 GrabActive := False; 189 GrabWindow := nil; 190 end; 190 191 for I := Windows.Count - 1 downto 0 do begin 191 192 Window := Windows[I]; 192 193 if Window.Rectangle.Contains(Pos) then begin 193 Window.MouseButton Down(Pos - Window.Rectangle.Position, Button);194 Window.MouseButtonUp(Pos - Window.Rectangle.Position, Button); 194 195 Break; 195 196 end; … … 197 198 end; 198 199 199 procedure TScreen.MouseButtonUp(Pos: TPosition; Button: TMouseButton);200 var201 I: Integer;202 begin203 for I := Windows.Count - 1 downto 0 do begin204 if Windows[I].Rectangle.Contains(Pos) then begin205 Windows[I].MouseButtonUp(Pos - Windows[I].Rectangle.Position, Button);206 Break;207 end;208 end;209 end;210 211 200 procedure TScreen.MouseMove(Pos: TPosition); 212 201 var 213 202 I: Integer; 214 203 begin 204 if GrabActive then begin 205 if GrabWindowSide = wsNone then 206 GrabWindow.Rectangle.Position := GrabWindowRectangle.Position + (Pos - GrabMousePosition) 207 else if GrabWindowSide = wsLeft then 208 GrabWindow.Rectangle := TRectangle.Create(GrabWindowRectangle.Position + TPosition.Create(Pos.Left - GrabMousePosition.Left, 0), 209 GrabWindowRectangle.Size - TSize.Create(Pos.Left - GrabMousePosition.Left, 0)) 210 else if GrabWindowSide = wsTop then 211 GrabWindow.Rectangle := TRectangle.Create(GrabWindowRectangle.Position + TPosition.Create(0, Pos.Top - GrabMousePosition.Top), 212 GrabWindowRectangle.Size - TSize.Create(0, Pos.Top - GrabMousePosition.Top)) 213 else if GrabWindowSide = wsRight then 214 GrabWindow.Rectangle := TRectangle.Create(GrabWindowRectangle.Position, 215 GrabWindowRectangle.Size + TSize.Create(Pos.Left - GrabMousePosition.Left, 0)) 216 else if GrabWindowSide = wsBottom then 217 GrabWindow.Rectangle := TRectangle.Create(GrabWindowRectangle.Position, 218 GrabWindowRectangle.Size + TSize.Create(0, Pos.Top - GrabMousePosition.Top)); 219 Paint; 220 end; 215 221 for I := Windows.Count - 1 downto 0 do begin 216 222 if Windows[I].Rectangle.Contains(Pos) then begin -
branches/overos/overos.lpi
r20 r21 27 27 </Item1> 28 28 </RequiredPackages> 29 <Units Count=" 6">29 <Units Count="8"> 30 30 <Unit0> 31 31 <Filename Value="overos.lpr"/> … … 55 55 <IsPartOfProject Value="True"/> 56 56 </Unit5> 57 <Unit6> 58 <Filename Value="UControls.pas"/> 59 <IsPartOfProject Value="True"/> 60 </Unit6> 61 <Unit7> 62 <Filename Value="UGraphics.pas"/> 63 <IsPartOfProject Value="True"/> 64 </Unit7> 57 65 </Units> 58 66 </ProjectOptions> -
branches/overos/overos.lpr
r20 r21 8 8 {$ENDIF}{$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, UFormMain, UWindow, UMouse, USystem, UTypes 10 Forms, UFormMain, UWindow, UMouse, USystem, UTypes, UControls, UGraphics 11 11 { you can add units after this }; 12 12
Note:
See TracChangeset
for help on using the changeset viewer.