summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/gui/widgettest/widgettest.pas52
-rw-r--r--gui/layouts.inc16
-rw-r--r--gui/menus.inc72
3 files changed, 36 insertions, 104 deletions
diff --git a/examples/gui/widgettest/widgettest.pas b/examples/gui/widgettest/widgettest.pas
index a8f9a010..0e144ae1 100644
--- a/examples/gui/widgettest/widgettest.pas
+++ b/examples/gui/widgettest/widgettest.pas
@@ -186,12 +186,13 @@ type
end;
+ { TMenuForm }
+
TMenuForm = class(TTestForm)
private
- FLayout: TBoxLayout;
+ procedure CloseMenuClicked(Sender: TObject);
public
constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
published
BoxLayout: TBoxLayout;
MainMenu: TMenuBar;
@@ -257,6 +258,12 @@ end;
{ TMenuForm }
+procedure TMenuForm.CloseMenuClicked(Sender: TObject);
+begin
+ writeln('...Close menu clicked');
+ Close;
+end;
+
constructor TMenuForm.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
@@ -268,44 +275,13 @@ begin
MainMenu := TMenuBar.Create(self);
BoxLayout.InsertChild(MainMenu);
- FLayout := TBoxLayout.Create(self);
- FLayout.Spacing := 0;
- FLayout.BorderSpacing := 6;
- FLayout.HorzAlign := horzLeft;
-// MainMenu.InsertChild(FLayout);
-
-{
- MainMenu.AddMenu('File');
+
+ MainMenu.AddMenu('Close', 'C', @CloseMenuClicked);
+// MainMenu.AddMenu('File');
MainMenu.AddMenu('Edit');
MainMenu.AddMenu('Options');
MainMenu.AddMenu('Windows');
MainMenu.AddMenu('Help');
-}
-
- FLayout.InsertChild(TPanel.Create('File', self));
- FLayout.InsertChild(TPanel.Create('Edit', self));
-
- MenuBox := TBoxLayout.Create(self);
- MenuBox.HorzAlign := horzLeft;
- MenuBox.Spacing := 0;
- BoxLayout.InsertChild(MenuBox);
- p1 := TPanel.Create('File', self);
- p1.BevelStyle := bsPlain;
- p2 := TPanel.Create('Edit', self);
- p2.BevelStyle := bsPlain;
- p3 := TPanel.Create('Options', self);
- p3.BevelStyle := bsPlain;
- p4 := TPanel.Create('Windows', self);
- p4.BevelStyle := bsPlain;
- p5 := TPanel.Create('Help', self);
- p5.BevelStyle := bsPlain;
- MenuBox.InsertChild(p1);
- MenuBox.InsertChild(p2);
- MenuBox.InsertChild(p3);
- MenuBox.InsertChild(p4);
- MenuBox.InsertChild(p5);
-// MenuBox.InsertChild(TPanel.Create('Testing', self));
-
Title := TLabel.Create(self);
Title.CanExpandWidth := True;
@@ -317,10 +293,6 @@ begin
Child := BoxLayout;
end;
-destructor TMenuForm.Destroy;
-begin
- inherited Destroy;
-end;
{ TPanelForm }
diff --git a/gui/layouts.inc b/gui/layouts.inc
index d26cd4b2..786ae9cd 100644
--- a/gui/layouts.inc
+++ b/gui/layouts.inc
@@ -52,7 +52,6 @@ type
IsRecalcingLayout: Boolean;
function GetChildCount: Integer; override;
function GetChild(Index: Integer): TWidget; override;
- procedure AddFixedChild(AChild: TWidget);
property BorderSpacing: Integer read FBorderSpacing write FBorderSpacing;
public
constructor Create(AOwner: TComponent); override;
@@ -75,6 +74,8 @@ type
{ TFixedLayout }
TFixedLayout = class(TLayout)
+ private
+ procedure AddFixedChild(AChild: TWidget);
protected
procedure CalcSizes; override;
public
@@ -344,10 +345,6 @@ end;
// protected methods
-procedure TLayout.AddFixedChild(AChild: TWidget);
-begin
-end;
-
function TLayout.GetChildCount: Integer;
begin
Result := FWidgets.Count;
@@ -401,6 +398,11 @@ begin
raise ELayoutError.Create(SLayoutWidgetNotFound);
end;
+procedure TFixedLayout.AddFixedChild(AChild: TWidget);
+begin
+ // todo
+end;
+
procedure TFixedLayout.CalcSizes;
var
i: Integer;
@@ -581,7 +583,7 @@ begin
item := TDockingItem(FWidgets.Add);
item.Widget := AWidget;
item.DockingMode := ADockingMode;
- AddFixedChild(AWidget);
+// AddFixedChild(AWidget);
end;
procedure TDockingLayout.AddWidget(AWidget: TWidget; ALeft, ATop: Integer);
@@ -594,7 +596,7 @@ begin
item.DockingMode := dmUndocked;
item.Left := ALeft;
item.Top := ATop;
- AddFixedChild(AWidget);
+// AddFixedChild(AWidget);
end;
diff --git a/gui/menus.inc b/gui/menus.inc
index 30986548..f2cbc8e7 100644
--- a/gui/menus.inc
+++ b/gui/menus.inc
@@ -29,7 +29,7 @@
FHotKeyDef: string;
FSeparator: boolean;
protected
- function ProcessEvent(pEvent: TEventObj): Boolean; override;
+ procedure Paint(Canvas: TFCanvas); override;
public
constructor Create(const pText: string; pOwner: TComponent); overload;
published
@@ -40,20 +40,17 @@
property Enabled;
end;
-
+
{ TMenuBar }
- TMenuBar = class(TBinWidget)
+ TMenuBar = class(TCustomBoxLayout)
private
protected
- procedure Paint(Canvas: TFCanvas); override;
public
constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
function AddMenu(const pTitle: string): TMenuItem;
function AddMenu(const pTitle: string; const pHotKeyDef: string; pHandlerProc: TNotifyEvent): TMenuItem;
published
-// FLayout: TBoxLayout;
end;
{$ENDIF read_interface}
@@ -64,78 +61,42 @@
{ TMenuItem }
-function TMenuItem.ProcessEvent(pEvent: TEventObj): Boolean;
+procedure TMenuItem.Paint(Canvas: TFCanvas);
begin
- if pEvent.InheritsFrom(TMouseMoveEventObj) then
- Writeln('MenuItem ' + Text
- + ' X=' + IntToStr(TMouseMoveEventObj(pEvent).Position.X)
- + ',Y=' + IntToStr(TMouseMoveEventObj(pEvent).Position.Y));
+ if (wsClicked in WidgetState) and (wsMouseInside in WidgetState) then
+ FBevelStyle := bsLowered
+ else
+ FBevelStyle := bsPlain;
- Result := inherited ProcessEvent(pEvent);
+ inherited Paint(Canvas);
end;
constructor TMenuItem.Create(const pText: string; pOwner: TComponent);
begin
inherited Create(pText, pOwner);
+ WidgetStyle := WidgetStyle + [wsCaptureMouse, wsClickable, wsOpaque];
FBevelStyle := bsPlain;
end;
-
-procedure TMenuBar.Paint(Canvas: TFCanvas);
-{var
- i: integer; }
-begin
- inherited Paint(Canvas);
- Style.DrawWindowBackground(Canvas, ClientRect);
-// FLayout.Paint(Canvas);
-{
-
- for i := 1 to VisibleCount do
- begin
- DrawColumn(Canvas, i, i = FFocusItem);
- end;
-
- Style.DrawSeparator(
- Canvas,
- Rect(0, ClientRect.Bottom - 4, ClientRect.Right, ClientRect.Bottom),
- Horizontal);
- }
-end;
-
constructor TMenuBar.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
-// WidgetStyle := WidgetStyle + [wsCaptureMouse, wsClickable, wsOpaque];
- FCanExpandWidth := True;
-{
- FLayout := TBoxLayout.Create(nil);
- FLayout.Spacing := 0;
- FLayout.BorderSpacing := 6;
- FLayout.HorzAlign := horzLeft;
-
- InsertChild(FLayout);
-}
+ WidgetStyle := WidgetStyle + [wsCaptureMouse, wsClickable, wsOpaque];
+ FCanExpandHeight := False;
+ Spacing := 0;
end;
-destructor TMenuBar.Destroy;
-begin
-// RemoveChild(FLayout);
-// FLayout.Free;
- inherited Destroy;
-end;
-
-
function TMenuBar.AddMenu(const pTitle: string): TMenuItem;
begin
Result := TMenuItem.Create(pTitle, self);
-// FLayout.InsertChild(Result);
+ InsertChild(Result);
end;
function TMenuBar.AddMenu(const pTitle: string; const pHotKeyDef: string;
pHandlerProc: TNotifyEvent): TMenuItem;
begin
- Result := TMenuItem.Create(self);
+ Result := AddMenu(pTitle);
if pTitle <> '-' then
begin
Result.Text := pTitle;
@@ -143,10 +104,7 @@ begin
Result.OnClick := pHandlerProc;
end
else
- begin
Result.Separator := True;
- end;
-// FLayout.InsertChild(Result);
end;