Files
lazarus-ccr/components/jvcllaz/design/JvCustomControls/jvoutlookbareditors.pas

330 lines
8.5 KiB
ObjectPascal

{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvOutlookBarEditors.PAS, released on 2002-05-26.
The Initial Developer of the Original Code is John Doe.
Portions created by John Doe are Copyright (C) 2003 John Doe.
All Rights Reserved.
Contributor(s):
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.delphi-jedi.org
Known Issues:
-----------------------------------------------------------------------------}
// $Id$
unit JvOutlookBarEditors;
{$mode objfpc}{$H+}
interface
uses
// LazLogger,
SysUtils, Classes, Controls, Forms, Menus, ActnList, ComCtrls, ImgList,
PropEdits, GraphPropEdits, ComponentEditors,
JvOutlookBar;
type
TJvOutlookBarActivePageProperty = class(TIntegerProperty)
private
function GetOutlookBar: TJvCustomOutlookBar;
public
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure SetValue(const Value: string); override;
procedure GetValues(Proc: TGetStrProc); override;
end;
TJvOutlookBarCaptionProperty = class(TStringProperty)
public
procedure SetValue(const Value: string); override;
end;
(*
TJvOutlookBarPagesProperty = class(TPropertyEditor)
private
function GetOutlookBar: TJvCustomOutlookBar;
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
end;
*)
TJvOutlookBarButtonImageIndexProperty = class(TImageIndexPropertyEditor)
private
function GetPage: TJvOutlookBarPage;
function GetBar: TJvCustomOutlookBar;
protected
function GetImageList: TCustomImageList; override;
end;
TJvOutlookBarPageImageIndexProperty = class(TImageIndexPropertyEditor)
protected
function GetImageList: TCustomImageList; override;
end;
TJvOutlookBarEditor = class(TComponentEditor)
protected
function GetOutlookBar: TJvCustomOutlookBar;
procedure OpenEditor;
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
implementation
uses
JvDsgnConsts, JvOutlookBarForm;
type
THackOutlookBar = class(TJvCustomOutlookBar);
THackPages = class(TJvOutlookBarPages);
THackButtons = class(TJvOutlookBarButtons);
var
EditWindow: TFrmOLBEditor;
procedure ShowEditor(ADesigner: TComponentEditorDesigner;
AOutlookBar: TJvCustomOutlookBar);
begin
if AOutlookBar = nil then
exit;
if EditWindow = nil then
EditWindow := TFrmOLBEditor.Create(Application);
EditWindow.SetData(AOutlookBar, ADesigner);
EditWindow.Show;
end;
(*
procedure ShowEditor(Designer: TIDesigner; OutlookBar: TJvCustomOutlookBar);
var
I: Integer;
AEditor: TFrmOLBEditor;
begin
AEditor := nil;
for I := 0 to Screen.FormCount - 1 do
if Screen.Forms[I] is TFrmOLBEditor then
if TFrmOLBEditor(Screen.Forms[I]).OutlookBar = OutlookBar then
begin
AEditor := TFrmOLBEditor(Screen.Forms[I]);
Break;
end;
// Show the editor
if Assigned(AEditor) then
begin
AEditor.Show;
if AEditor.WindowState = wsMinimized then
AEditor.WindowState := wsNormal;
end
else
begin
AEditor := TFrmOLBEditor.Create(Application);
try
AEditor.Designer := Designer;
AEditor.OutlookBar := OutlookBar;
AEditor.Show;
except
AEditor.Free;
raise;
end;
end;
end;
*)
//=== { TJvOutlookBarPagesProperty } =========================================
(*
procedure TJvOutlookBarPagesProperty.Edit;
begin
// !!!!!!!!!!!! HOW DO I GET THE DESIGNER HERE ???????????????
//ShowEditor(Designer, GetOutlookBar);
end;
function TJvOutlookBarPagesProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
function TJvOutlookBarPagesProperty.GetOutlookBar: TJvCustomOutlookBar;
begin
if GetComponent(0) is TJvCustomOutlookBar then
Result := TJvCustomOutlookBar(GetComponent(0))
else
if GetComponent(0) is TJvOutlookBarPage then
Result := THackOutlookBar(THackPages(TJvOutlookBarPage(GetComponent(0)).Collection).GetOwner)
else
Result := nil;
end;
function TJvOutlookBarPagesProperty.GetValue: string;
begin
Result := Format('(%s)', [GetPropType^.Name]);
end;
*)
//=== { TJvOutlookBarEditor } ================================================
procedure TJvOutlookBarEditor.ExecuteVerb(Index: Integer);
begin
case Index of
0: OpenEditor;
else inherited ExecuteVerb(Index);
end;
end;
function TJvOutlookBarEditor.GetOutlookBar: TJvCustomOutlookBar;
var
lComponent: TComponent;
begin
lComponent := Self.GetComponent;
if (lComponent is TJvCustomOutlookBar) then
Result := TJvCustomOutlookBar(lComponent)
else
Result := nil;
end;
function TJvOutlookBarEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := RsOLBditor;
else Result := inherited GetVerb(Index);
end;
end;
function TJvOutlookBarEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
procedure TJvOutlookBarEditor.OpenEditor;
begin
ShowEditor(Designer, GetOutlookBar);
end;
//=== TJvOutlookBarActivePageProperty ==========================================
function TJvOutlookBarActivePageProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paSortList, paRevertable];
end;
function TJvOutlookBarActivePageProperty.GetOutlookBar: TJvCustomOutlookBar;
begin
if GetComponent(0) is TJvCustomOutlookBar then
Result := TJvCustomOutlookBar(GetComponent(0))
else
Result := nil;
end;
function TJvOutlookBarActivePageProperty.GetValue: string;
var
I: Integer;
olb: THackOutlookBar;
begin
Result := '';
olb := THackOutlookBar(GetOutlookBar);
if olb = nil then
exit;
I := GetOrdValue;
if (I >= 0) and (I < olb.Pages.Count) then
Result := olb.Pages[I].Caption
else
Result := inherited GetValue;
end;
procedure TJvOutlookBarActivePageProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
olb: THackOutlookBar;
begin
olb := THackOutlookBar(GetOutlookBar);
for I := 0 to olb.Pages.Count - 1 do
Proc(olb.Pages[I].Caption);
end;
procedure TJvOutlookBarActivePageProperty.SetValue(const Value: string);
var
I: Integer;
olb: THackOutlookBar;
begin
I := StrToIntDef(Value, -1);
if I < 0 then
begin
olb := THackOutlookBar(GetOutlookBar);
for I := 0 to olb.Pages.Count - 1 do
if AnsiSameText(olb.Pages[I].Caption, Value) then
begin
SetOrdValue(I);
Modified;
Break;
end;
end
else
inherited SetValue(Value);
end;
//=== TJvOutlookBarCaptionEditor ===============================================
procedure TJvOutlookBarCaptionProperty.SetValue(const Value: string);
begin
inherited;
if EditWindow <> nil then
EditWindow.RefreshNames;
end;
//=== TJvOutlookBarButtonImageIndexProperty ====================================
function TJvOutlookBarButtonImageIndexProperty.GetBar: TJvCustomOutlookBar;
begin
Result := THackPages(GetPage.Collection).GetOwner as TJvCustomOutlookBar;
end;
function TJvOutlookBarButtonImageIndexProperty.GetPage: TJvOutlookBarPage;
begin
Result := TJvOutlookBarPage(THackButtons((GetComponent(0) as TJvOutlookBarButton).Collection).GetOwner);
end;
function TJvOutlookBarButtonImageIndexProperty.GetImageList: TCustomImageList;
begin
if GetPage.ButtonSize = olbsLarge then
Result := THackOutlookBar(GetBar).LargeImages
else
Result := THackOutlookBar(GetBar).SmallImages;
end;
//=== TJvOutlookBarPageImageIndexProperty ======================================
function TJvOutlookBarPageImageIndexProperty.GetImageList: TCustomImageList;
var
page: TJvOutlookBarPage;
pages: TJvOutlookBarPages;
olb: TJvCustomOutlookBAr;
begin
page := TJvOutlookBarPage(GetComponent(0));
pages := THackPages(page.Collection);
olb := TJvCustomOutlookBar(pages.Owner);
Result := THackOutlookBar(olb).PageImages;
// Result := THackOutlookBar(THackPages(TJvOutlookBarPage(GetComponent(0)).Collection).Owner).PageImages;
// Result := THackOutlookBar(GetOutlookBar).PageImages;
end;
end.