LCL: started MDI support. Added needed routines and properties.

git-svn-id: trunk@33323 -
This commit is contained in:
zeljko 2011-11-05 08:17:56 +00:00
parent 9874a2fe96
commit 4628bd06d0
3 changed files with 230 additions and 3 deletions

View File

@ -404,6 +404,7 @@ type
THelpEvent = function(Command: Word; Data: PtrInt; var CallHelp: Boolean): Boolean of object;
TShortCutEvent = procedure (var Msg: TLMKey; var Handled: Boolean) of object;
TCustomForm = class(TScrollingWinControl)
private
FActive: Boolean;
@ -452,6 +453,7 @@ type
FRestoredHeight: integer;
FShowInTaskbar: TShowInTaskbar;
FWindowState: TWindowState;
function GetClientHandle: HWND;
function GetEffectiveShowInTaskBar: TShowInTaskBar;
function GetMonitor: TMonitor;
function GetPixelsPerInch: Longint;
@ -570,6 +572,11 @@ type
function DoExecuteAction(ExeAction: TBasicAction): boolean;
function DoUpdateAction(TheAction: TBasicAction): boolean;
procedure UpdateActions; virtual;
protected
{MDI implementation}
{returns handle of MDIForm client handle (container for mdi children this
is not Handle of form itself !)}
property ClientHandle: HWND read GetClientHandle;
public
constructor Create(AOwner: TComponent); override;
constructor CreateNew(AOwner: TComponent; Num: Integer = 0); virtual;
@ -604,6 +611,7 @@ type
function SetFocusedControl(Control: TWinControl): Boolean ; virtual;
procedure SetRestoredBounds(ALeft, ATop, AWidth, AHeight: integer);
procedure Show;
function ShowModal: Integer; virtual;
procedure ShowOnTop;
function SmallIconHandle: HICON;
@ -619,6 +627,12 @@ type
procedure RemoveHandlerClose(OnCloseHandler: TCloseEvent);
procedure AddHandlerCreate(OnCreateHandler: TNotifyEvent; AsFirst: Boolean=true);
procedure RemoveHandlerCreate(OnCreateHandler: TNotifyEvent);
public
{MDI implementation}
function ActiveMDIChild: TCustomForm; virtual;
function GetMDIChildren(AIndex: Integer): TCustomForm; virtual;
function MDIChildCount: Integer; virtual;
public
// drag and dock
procedure Dock(NewDockSite: TWinControl; ARect: TRect); override;
@ -648,6 +662,7 @@ type
property HelpFile: string read FHelpFile write FHelpFile;
property Icon: TIcon read FIcon write SetIcon stored IsIconStored;
property KeyPreview: Boolean read FKeyPreview write FKeyPreview default False;
property MDIChildren[I: Integer]: TCustomForm read GetMDIChildren;
property Menu : TMainMenu read FMenu write SetMenu;
property ModalResult : TModalResult read FModalResult write FModalResult;
property Monitor: TMonitor read GetMonitor;
@ -690,7 +705,6 @@ type
TForm = class(TCustomForm)
private
FClientHandle: HWND;
FLCLVersion: string;
function LCLVersionIsStored: boolean;
protected
@ -698,7 +712,18 @@ type
procedure Loaded; override;
public
constructor Create(TheOwner: TComponent); override;
property ClientHandle: HWND read FClientHandle;
{ mdi related routine}
procedure Cascade;
{ mdi related routine}
procedure Next;
{ mdi related routine}
procedure Previous;
{ mdi related routine}
procedure Tile;
{ mdi related property}
property ClientHandle;
property DockManager;
published
property Action;

View File

@ -2611,6 +2611,81 @@ begin
FFormHandlers[fhtFirstShow].CallNotifyEvents(Self);
end;
{------------------------------------------------------------------------------
Method: TCustomForm.GetClientHandle
Params: None
Returns: Nothing
Returns handle of fsMdiForm container for mdi children.
This is not same as Handle of form.
Result is valid only if form FormStyle = fsMDIForm or FormStyle = fsMDIChild.
In case when FormStyle = fsMDIChild it'll return handle of it's container
(fsMDIForm).
------------------------------------------------------------------------------}
function TCustomForm.GetClientHandle: HWND;
begin
Result := 0;
if not (FormStyle in [fsMDIForm, fsMDIChild]) then
exit;
if HandleAllocated and not (csDesigning in ComponentState) then
Result := TWSCustomFormClass(WidgetSetClass).GetClientHandle(Self);
end;
{------------------------------------------------------------------------------
Method: TCustomForm.ActiveMDIChild
Params: None
Returns: Nothing
Returns currently active MDI child form of self.
Valid result is returned only when Self FormStyle = fsMDIForm or fsMDIChild,
otherwise Result is nil.
------------------------------------------------------------------------------}
function TCustomForm.ActiveMDIChild: TCustomForm;
begin
Result := nil;
if not (FormStyle in [fsMDIForm, fsMDIChild]) then
exit;
if HandleAllocated and not (csDesigning in ComponentState) then
Result := TWSCustomFormClass(WidgetSetClass).ActiveMDIChild(Self);
end;
{------------------------------------------------------------------------------
Method: TCustomForm.MDIChildCount
Params: None
Returns: Nothing
Returns count of MDIChild forms.
Result is returned only when Self FormStyle = fsMDIForm or fsMDIChild (can
be 0 ... number of mdichild forms).
If Result is -1 then caller isn't mdi or handle is not allocated.
------------------------------------------------------------------------------}
function TCustomForm.MDIChildCount: Integer;
begin
Result := -1;
if not (FormStyle in [fsMDIForm, fsMDIChild]) then
exit;
if HandleAllocated and not (csDesigning in ComponentState) then
Result := TWSCustomFormClass(WidgetSetClass).MDIChildCount(Self);
end;
{------------------------------------------------------------------------------
Method: TCustomForm.MDIChildCount
Params: AIndex: Integer;
Returns: TCustomForm with FormStyle = fsMDIChild
Returns MDI child (fsMDIChild) of parent mdi form (fsMDIForm) at index
AIndex in list of mdi children.
Result can be nil if caller isn't an mdi type or handle isn't allocated.
------------------------------------------------------------------------------}
function TCustomForm.GetMDIChildren(AIndex: Integer): TCustomForm;
begin
Result := nil;
if not (FormStyle in [fsMDIForm, fsMDIChild]) then
exit;
if HandleAllocated and not (csDesigning in ComponentState) then
Result := TWSCustomFormClass(WidgetSetClass).GetMDIChildren(Self, AIndex);
end;
{------------------------------------------------------------------------------
TCustomForm ShowModal
------------------------------------------------------------------------------}
@ -2866,6 +2941,78 @@ begin
inherited Create(TheOwner);
end;
{------------------------------------------------------------------------------
Method: TForm.Cascade
Params: None
Returns: Nothing
Arranges MDI child forms so they overlap.
Use Cascade to arrange MDI child forms so they overlap.
Cascade works only if the form is an MDI parent form (FormStyle=fsMDIForm).
------------------------------------------------------------------------------}
procedure TForm.Cascade;
begin
if (FormStyle <> fsMDIForm) then
exit;
if HandleAllocated and not (csDesigning in ComponentState) then
TWSCustomFormClass(WidgetSetClass).Cascade(Self);
end;
{------------------------------------------------------------------------------
Method: TForm.Next
Params: None
Returns: Nothing
Activates the next child MDI form (fsMDIChild) in the form sequence.
Use Next to change the active child form of an MDI parent.
If calling of Next comes to the end of count it restarts and activates
first dsMDIChild in sequence.
The Next method applies only to forms with FormStyle = fsMDIForm.
------------------------------------------------------------------------------}
procedure TForm.Next;
begin
if (FormStyle <> fsMDIForm) then
exit;
if HandleAllocated and not (csDesigning in ComponentState) then
TWSCustomFormClass(WidgetSetClass).Next(Self);
end;
{------------------------------------------------------------------------------
Method: TForm.Previous
Params: None
Returns: Nothing
Activates the previous MDI child form in the form sequence.
Behaviour is vice-versa of TForm.Next.
The Previous method can be called only for forms with FormStyle = fsMDIForm
------------------------------------------------------------------------------}
procedure TForm.Previous;
begin
if (FormStyle <> fsMDIForm) then
exit;
if HandleAllocated and not (csDesigning in ComponentState) then
TWSCustomFormClass(WidgetSetClass).Previous(Self);
end;
{------------------------------------------------------------------------------
Method: TForm.Tile
Params: None
Returns: Nothing
Arranges MDI child forms so that they are all the same size.
Use Tile to arrange MDI child forms so that they are all the same size.
Tiled forms completely fill up the client area of the parent form.
How the forms arrange themselves depends upon the values of
their TileMode properties, and it depends on widgetset.
Tile works only if the form FormStyle = fsMDIForm.
------------------------------------------------------------------------------}
procedure TForm.Tile;
begin
if (FormStyle <> fsMDIForm) then
exit;
if HandleAllocated and not (csDesigning in ComponentState) then
TWSCustomFormClass(WidgetSetClass).Tile(Self);
end;
//==============================================================================
{ TFormPropertyStorage }

View File

@ -96,6 +96,16 @@ type
class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); virtual;
class procedure SetZPosition(const AWinControl: TWinControl; const APosition: TWSZPosition); virtual;
class function GetDefaultColor(const AControl: TControl; const ADefaultColorType: TDefaultColorType): TColor; override;
{mdi support}
class function ActiveMDIChild(const AForm: TCustomForm): TCustomForm; virtual;
class function Cascade(const AForm: TCustomForm): Boolean; virtual;
class function GetClientHandle(const AForm: TCustomForm): HWND; virtual;
class function GetMDIChildren(const AForm: TCustomForm; AIndex: Integer): TCustomForm; virtual;
class function Next(const AForm: TCustomForm): Boolean; virtual;
class function Previous(const AForm: TCustomForm): Boolean; virtual;
class function Tile(const AForm: TCustomForm): Boolean; virtual;
class function MDIChildCount(const AForm: TCustomForm): Integer; virtual;
end;
TWSCustomFormClass = class of TWSCustomForm;
@ -189,7 +199,7 @@ const
begin
Result := DefColors[ADefaultColorType];
end;
class procedure TWSCustomForm.ShowModal(const ACustomForm: TCustomForm);
begin
end;
@ -204,6 +214,51 @@ class procedure TWSCustomForm.SetAlphaBlend(const ACustomForm: TCustomForm;
begin
end;
{ mdi support }
class function TWSCustomForm.ActiveMDIChild(const AForm: TCustomForm
): TCustomForm;
begin
Result := nil;
end;
class function TWSCustomForm.Cascade(const AForm: TCustomForm): Boolean;
begin
Result := False;
end;
class function TWSCustomForm.GetClientHandle(const AForm: TCustomForm): HWND;
begin
Result := 0;
end;
class function TWSCustomForm.GetMDIChildren(const AForm: TCustomForm;
AIndex: Integer): TCustomForm;
begin
Result := nil;
end;
class function TWSCustomForm.MDIChildCount(const AForm: TCustomForm): Integer;
begin
Result := 0;
end;
class function TWSCustomForm.Next(const AForm: TCustomForm): Boolean;
begin
Result := False;
end;
class function TWSCustomForm.Previous(const AForm: TCustomForm): Boolean;
begin
Result := False;
end;
class function TWSCustomForm.Tile(const AForm: TCustomForm): Boolean;
begin
Result := False;
end;
{ WidgetSetRegistration }
procedure RegisterScrollingWinControl;