Changeset 22 for branches/overos


Ignore:
Timestamp:
Dec 30, 2018, 1:01:14 AM (6 years ago)
Author:
chronos
Message:
  • Added: Close button to window title bar.
Location:
branches/overos
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/overos/UControls.pas

    r21 r22  
    1414  TControl = class
    1515  private
     16    FOnClick: TNotifyEvent;
    1617    FParentControl: TControl;
     18    FRectangle: TRectangle;
    1719    FVisible: Boolean;
     20    function GetPosition: TPosition;
     21    function GetSize: TSize;
    1822    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;
    2028  public
    2129    Canvas: TCanvas;
    22     Rectangle: TRectangle;
    2330    Controls: TFPGObjectList<TControl>;
    2431    procedure MouseButtonDown(Pos: TPosition; Button: TMouseButton); virtual;
     
    3037    property ParentControl: TControl read FParentControl write SetParentControl;
    3138    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;
    3243  end;
    3344
     
    3950    procedure DrawArea(Rect: TRectangle; Color: TColor); override;
    4051    procedure DrawText(P: TPosition; Color: TColor; Text: string); override;
     52    function GetTextSize(Text: string): TSize; override;
    4153  end;
    4254
     
    4759    FClicked: Boolean;
    4860    FTitle: string;
    49     procedure MouseButtonDown(Pos: TPosition; Button: TMouseButton); override;
    50     procedure MouseButtonUp(Pos: TPosition; Button: TMouseButton); override;
    5161    procedure SetClicked(AValue: Boolean);
    5262    procedure SetTitle(AValue: string);
    5363  public
     64    procedure MouseButtonDown(Pos: TPosition; Button: TMouseButton); override;
     65    procedure MouseButtonUp(Pos: TPosition; Button: TMouseButton); override;
    5466    procedure Paint; override;
    5567    property Clicked: Boolean read FClicked write SetClicked;
     
    8597procedure TCanvasControl.DrawLine(P1, P2: TPosition; Color: TColor);
    8698begin
    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);
    88101end;
    89102
    90103procedure TCanvasControl.DrawArea(Rect: TRectangle; Color: TColor);
    91104begin
    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);
    94108end;
    95109
    96110procedure TCanvasControl.DrawText(P: TPosition; Color: TColor; Text: string);
    97111begin
    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);
     114end;
     115
     116function TCanvasControl.GetTextSize(Text: string): TSize;
     117begin
     118  if Assigned(Control) and Assigned(Control.ParentControl) then
     119    Result := Control.ParentControl.Canvas.GetTextSize(Text);
    99120end;
    100121
     
    105126  if FVisible = AValue then Exit;
    106127  FVisible := AValue;
    107   Paint;
     128  if not FVisible then begin
     129    if Assigned(ParentControl) then ParentControl.Paint;
     130  end else Paint;
    108131end;
    109132
     
    128151      Break;
    129152    end;
     153  if Assigned(FOnClick) then
     154    FOnClick(Self);
    130155end;
    131156
     
    151176end;
    152177
     178function TControl.GetPosition: TPosition;
     179begin
     180  Result := FRectangle.Position;
     181end;
     182
     183function TControl.GetSize: TSize;
     184begin
     185  Result := FRectangle.Size;
     186end;
     187
     188procedure TControl.SetPosition(AValue: TPosition);
     189begin
     190  Rectangle := TRectangle.Create(AValue, FRectangle.Size);
     191end;
     192
     193procedure TControl.SetSize(AValue: TSize);
     194begin
     195  Rectangle := TRectangle.Create(FRectangle.Position, AValue);
     196end;
     197
     198procedure TControl.SetRectangle(AValue: TRectangle);
     199begin
     200  if FRectangle = AValue then Exit;
     201  FRectangle := AValue;
     202end;
     203
    153204procedure TControl.Paint;
    154205var
    155206  I: Integer;
    156207begin
    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;
    159212end;
    160213
     
    168221
    169222destructor TControl.Destroy;
    170 begin
     223var
     224  I: Integer;
     225begin
     226  for I := 0 to Controls.Count - 1 do
     227    Controls[I].Free;
     228  ParentControl := nil;
    171229  Canvas.Free;
    172230  Controls.Free;
     
    185243procedure TEdit.Paint;
    186244begin
    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;
    190250  inherited;
    191251end;
     
    202262procedure TLabel.Paint;
    203263begin
    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;
    205267  inherited;
    206268end;
     
    237299var
    238300  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;
     302begin
     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;
    245312  inherited;
    246313end;
  • branches/overos/UFormMain.lfm

    r20 r22  
    2121    OnMouseUp = Image1MouseUp
    2222  end
     23  object Timer1: TTimer
     24    Interval = 10
     25    OnTimer = Timer1Timer
     26    left = 303
     27    top = 201
     28  end
    2329end
  • branches/overos/UFormMain.pas

    r21 r22  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
    9   UWindow, USystem, UTypes, UMouse, UGraphics, UControls;
     9  Types, UWindow, USystem, UTypes, UMouse, UGraphics, UControls, UApplication;
    1010
    1111type
     
    1616  TFormMain = class(TForm)
    1717    Image1: TImage;
     18    Timer1: TTimer;
    1819    procedure Image1MouseDown(Sender: TObject; Button: TControlsMouseButton;
    1920      Shift: TShiftState; X, Y: Integer);
     
    2324    procedure FormResize(Sender: TObject);
    2425    procedure FormShow(Sender: TObject);
     26    procedure Timer1Timer(Sender: TObject);
    2527  private
    2628
    2729  public
     30    App: TApplication;
    2831    System: TSystem;
    2932  end;
     
    3639    procedure DrawArea(Rect: TRectangle; Color: TColor); override;
    3740    procedure DrawText(P: TPosition; Color: TColor; Text: string); override;
     41    function GetTextSize(Text: string): TSize; override;
    3842  end;
    3943
     
    6670procedure TCanvasScreen.DrawText(P: TPosition; Color: TColor; Text: string);
    6771begin
     72  Canvas.Brush.Style := bsClear;
    6873  Canvas.Font.Color := Color;
    6974  Canvas.TextOut(P.Left, P.Top, Text);
     75end;
     76
     77function TCanvasScreen.GetTextSize(Text: string): TSize;
     78var
     79  Size: Types.TSize;
     80begin
     81  Size := Canvas.TextExtent(Text);
     82  Result := TSize.Create(Size.cx, Size.cy);
    7083end;
    7184
     
    125138  System.Screen.Size := TSize.Create(Width, Height);
    126139
     140  App := TApplication.Create;
     141
    127142  Window := System.Screen.CreateWindow('Test');
     143  Window.Application := App;
    128144
    129145  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;
    132149  Button := TButton.Create;
    133150  Button.Rectangle := TRectangle.Create(TPosition.Create(10, 50), TSize.Create(100, 32));
     
    137154
    138155  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);
    141159
    142160  System.Screen.Paint;
    143161end;
    144162
     163procedure TFormMain.Timer1Timer(Sender: TObject);
     164begin
     165  App.ProcessMessages;
     166end;
     167
    145168end.
    146169
  • branches/overos/UGraphics.pas

    r21 r22  
    1818    procedure DrawArea(Rect: TRectangle; Color: TColor); virtual;
    1919    procedure DrawText(P: TPosition; Color: TColor; Text: string); virtual;
     20    function GetTextSize(Text: string): TSize; virtual;
    2021  end;
    2122
     
    5152end;
    5253
     54function TCanvas.GetTextSize(Text: string): TSize;
     55begin
     56  Result := TSize.Create(0, 0);
     57end;
     58
    5359
    5460end.
  • branches/overos/UTypes.pas

    r21 r22  
    1818    class operator Add(A, B: TSize): TSize;
    1919    class operator Subtract(A, B: TSize): TSize;
     20    class operator Equal(A, B: TSize): Boolean;
    2021  end;
    2122
     
    2829    class operator Add(A, B: TPosition): TPosition;
    2930    class operator Subtract(A, B: TPosition): TPosition;
     31    class operator Equal(A, B: TPosition): Boolean;
    3032  end;
    3133
     
    3739    function Create(Position: TPosition; Size: TSize): TRectangle;
    3840    function Contains(Position: TPosition): Boolean;
     41    class operator Equal(A, B: TRectangle): Boolean;
     42  end;
     43
     44  TMessage = class
     45    Handle: TObject;
    3946  end;
    4047
     
    5663    (Self.Position.Left + Self.Size.Width >= Position.Left) and
    5764    (Self.Position.Top + Self.Size.Height >= Position.Top);
     65end;
     66
     67class operator TRectangle.Equal(A, B: TRectangle): Boolean;
     68begin
     69  Result := (A.Position = B.Position) and (A.Size = B.Size);
    5870end;
    5971
     
    7890end;
    7991
     92class operator TPosition.Equal(A, B: TPosition): Boolean;
     93begin
     94  Result := (A.Left = B.Left) and (A.Top = B.Top);
     95end;
     96
    8097{ TSize }
    8198
     
    98115end;
    99116
     117class operator TSize.Equal(A, B: TSize): Boolean;
     118begin
     119  Result := (A.Width = B.Width) and (A.Height = B.Height);
     120end;
     121
    100122
    101123end.
  • branches/overos/UWindow.pas

    r21 r22  
    1919    procedure DrawArea(Rect: TRectangle; Color: TColor); override;
    2020    procedure DrawText(P: TPosition; Color: TColor; Text: string); override;
     21    function GetTextSize(Text: string): TSize; override;
    2122  end;
    2223
    2324  TWindowSide = (wsNone, wsLeft, wsTop, wsRight, wsBottom);
    2425
    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;
    2837  public
    2938  const
    3039    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
    3162    BorderGrabWidth = 15;
    3263  var
     64    TitleBar: TTitleBar;
    3365    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;
    3570    procedure Focus;
    3671    procedure Paint; override;
     
    3873    constructor Create; override;
    3974    destructor Destroy; override;
     75    property Screen: TScreen read FScreen write SetScreen;
    4076  end;
    4177
     
    68104implementation
    69105
     106uses
     107  UApplication;
     108
     109{ TTitleBar }
     110
     111procedure TTitleBar.SetWindow(AValue: TWindow);
     112begin
     113  if FWindow = AValue then Exit;
     114  Canvas.Free;
     115  FWindow := AValue;
     116  Canvas := TCanvasWindow.Create;
     117  TCanvasWindow(Canvas).Window := FWindow;
     118end;
     119
     120procedure TTitleBar.ButtonCloseClick(Sender: TObject);
     121begin
     122  Window.Close;
     123end;
     124
     125procedure TTitleBar.ButtonMaximizeClick(Sender: TObject);
     126begin
     127  Rectangle := TRectangle.Create(TPosition.Create(0, 0), Window.Screen.Size);
     128  Paint;
     129end;
     130
     131procedure TTitleBar.ButtonMinimizeClick(Sender: TObject);
     132begin
     133
     134end;
     135
     136procedure TTitleBar.SetRectangle(AValue: TRectangle);
     137begin
     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));
     145end;
     146
     147constructor TTitleBar.Create;
     148begin
     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;
     168end;
     169
     170destructor TTitleBar.Destroy;
     171begin
     172  ButtonClose.Free;
     173  ButtonMaximize.Free;
     174  ButtonMinimize.Free;
     175  inherited Destroy;
     176end;
     177
    70178{ TCanvasWindow }
    71179
    72180procedure TCanvasWindow.DrawLine(P1, P2: TPosition; Color: TColor);
    73181begin
    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);
    75184end;
    76185
    77186procedure TCanvasWindow.DrawArea(Rect: TRectangle; Color: TColor);
    78187begin
    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);
    81191end;
    82192
    83193procedure TCanvasWindow.DrawText(P: TPosition; Color: TColor; Text: string);
    84194begin
    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);
     197end;
     198
     199function TCanvasWindow.GetTextSize(Text: string): TSize;
     200begin
     201  if Assigned(Window) and Assigned(Window.Screen) then
     202    Result := Window.Screen.Canvas.GetTextSize(Text);
    86203end;
    87204
    88205{ TWindow }
     206
     207procedure TWindow.SetScreen(AValue: TScreen);
     208begin
     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);
     215end;
     216
     217procedure TWindow.SetRectangle(AValue: TRectangle);
     218begin
     219  inherited;
     220  TitleBar.Rectangle := TRectangle.Create(Position, TSize.Create(Size.Width, TitleBar.TitleHeight));
     221end;
     222
     223procedure TWindow.SetVisible(AValue: Boolean);
     224begin
     225  inherited;
     226  if not Visible and Assigned(Screen) then
     227    Screen.Paint;
     228end;
     229
     230procedure TWindow.MouseButtonDown(Pos: TPosition; Button: TMouseButton);
     231begin
     232  inherited;
     233  TitleBar.MouseButtonDown(Pos, Button);
     234end;
     235
     236procedure TWindow.MouseButtonUp(Pos: TPosition; Button: TMouseButton);
     237begin
     238  inherited;
     239  TitleBar.MouseButtonUp(Pos, Button);
     240end;
     241
     242procedure TWindow.Close;
     243begin
     244  TApplication(Application).MessageQueue.PostMessage(Self, TMessageWindowClose.Create);
     245end;
    89246
    90247procedure TWindow.Focus;
     
    98255procedure TWindow.Paint;
    99256begin
    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;
    105265  inherited;
    106266end;
     
    117277  Canvas := TCanvasWindow.Create;
    118278  TCanvasWindow(Canvas).Window := Self;
     279  TitleBar := TTitleBar.Create;
     280  TitleBar.Window := Self;
     281  TitleBar.Visible := True;
    119282end;
    120283
    121284destructor TWindow.Destroy;
    122285begin
     286  Visible := False;
     287  TitleBar.Free;
     288  Screen := nil;
    123289  inherited Destroy;
    124290end;
     
    133299  for I := Windows.Count - 1 downto 0 do begin
    134300    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
     301    if TRectangle.Create(Window.Position - TPosition.Create(Window.BorderGrabWidth div 2, 0),
     302    TSize.Create(Window.BorderGrabWidth, Window.Size.Height)).Contains(Pos) then begin
    137303      GrabMousePosition := Pos;
    138304      GrabWindowRectangle := Window.Rectangle;
     
    141307      GrabActive := True;
    142308    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
     309    if TRectangle.Create(Window.Position - TPosition.Create(0, Window.BorderGrabWidth div 2),
     310    TSize.Create(Window.Size.Width, Window.BorderGrabWidth)).Contains(Pos) then begin
    145311      GrabMousePosition := Pos;
    146312      GrabWindowRectangle := Window.Rectangle;
     
    149315      GrabActive := True;
    150316    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
     317    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
    153319      GrabMousePosition := Pos;
    154320      GrabWindowRectangle := Window.Rectangle;
     
    157323      GrabActive := True;
    158324    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
     325    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
    161327      GrabMousePosition := Pos;
    162328      GrabWindowRectangle := Window.Rectangle;
     
    165331      GrabActive := True;
    166332    end else
    167     if TRectangle.Create(Window.Rectangle.Position, TSize.Create(Window.Rectangle.Size.Width, Window.TitleHeight)).Contains(Pos) then begin
     333    if TRectangle.Create(Window.Position, TSize.Create(Window.Size.Width, Window.TitleBar.TitleHeight)).Contains(Pos) then begin
    168334      GrabMousePosition := Pos;
    169335      GrabWindowRectangle := Window.Rectangle;
     
    174340    if Window.Rectangle.Contains(Pos) then begin
    175341      Window.Focus;
    176       Window.MouseButtonDown(Pos - Window.Rectangle.Position, Button);
     342      Window.MouseButtonDown(Pos - Window.Position, Button);
    177343      Break;
    178344    end;
     
    192358    Window := Windows[I];
    193359    if Window.Rectangle.Contains(Pos) then begin
    194       Window.MouseButtonUp(Pos - Window.Rectangle.Position, Button);
     360      Window.MouseButtonUp(Pos - Window.Position, Button);
    195361      Break;
    196362    end;
     
    204370  if GrabActive then begin
    205371    if GrabWindowSide = wsNone then
    206       GrabWindow.Rectangle.Position := GrabWindowRectangle.Position + (Pos - GrabMousePosition)
     372      GrabWindow.Position := GrabWindowRectangle.Position + (Pos - GrabMousePosition)
    207373    else if GrabWindowSide = wsLeft then
    208374      GrabWindow.Rectangle := TRectangle.Create(GrabWindowRectangle.Position + TPosition.Create(Pos.Left - GrabMousePosition.Left, 0),
     
    221387  for I := Windows.Count - 1 downto 0 do begin
    222388    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);
    224390      Break;
    225391    end;
     
    255421begin
    256422  Result := TWindow.Create;
    257   Windows.Add(Result);
    258423  Result.Screen := Self;
    259424  Result.Title := Title;
     
    265430begin
    266431  Windows := TFPGObjectList<TWindow>.Create;
     432  Windows.FreeObjects := False;
    267433  Canvas := TCanvas.Create;
    268434end;
    269435
    270436destructor TScreen.Destroy;
    271 begin
     437var
     438  I: Integer;
     439begin
     440  for I := 0 to Windows.Count - 1 do
     441    Windows[I].Free;
    272442  Windows.Free;
    273443  Canvas.Free;
  • branches/overos/overos.lpi

    r21 r22  
    1111      <Icon Value="0"/>
    1212    </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>
    1552    </BuildModes>
    1653    <PublishOptions>
     
    2764      </Item1>
    2865    </RequiredPackages>
    29     <Units Count="8">
     66    <Units Count="9">
    3067      <Unit0>
    3168        <Filename Value="overos.lpr"/>
     
    63100        <IsPartOfProject Value="True"/>
    64101      </Unit7>
     102      <Unit8>
     103        <Filename Value="UApplication.pas"/>
     104        <IsPartOfProject Value="True"/>
     105      </Unit8>
    65106    </Units>
    66107  </ProjectOptions>
     
    72113    <SearchPaths>
    73114      <IncludeFiles Value="$(ProjOutDir)"/>
    74       <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
     115      <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    75116    </SearchPaths>
    76117    <Parsing>
    77118      <SyntaxOptions>
    78119        <SyntaxMode Value="Delphi"/>
     120        <CStyleOperator Value="False"/>
     121        <IncludeAssertionCode Value="True"/>
     122        <AllowLabel Value="False"/>
     123        <CPPInline Value="False"/>
    79124      </SyntaxOptions>
    80125    </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>
    81135    <Linking>
     136      <Debugging>
     137        <UseHeaptrc Value="True"/>
     138      </Debugging>
    82139      <Options>
    83140        <Win32>
  • branches/overos/overos.lpr

    r21 r22  
    88  {$ENDIF}{$ENDIF}
    99  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
    1112  { you can add units after this };
    1213
Note: See TracChangeset for help on using the changeset viewer.