2018-03-12 14:03:31 +00:00
|
|
|
{-----------------------------------------------------------------------------
|
|
|
|
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
|
2018-04-24 15:22:33 +00:00
|
|
|
// LazLogger,
|
2019-05-29 16:06:12 +00:00
|
|
|
SysUtils, Classes, Controls, Forms, Menus, ActnList, ComCtrls, ImgList,
|
2018-03-23 00:10:05 +00:00
|
|
|
PropEdits, GraphPropEdits, ComponentEditors,
|
2018-03-12 14:03:31 +00:00
|
|
|
JvOutlookBar;
|
|
|
|
|
|
|
|
type
|
|
|
|
TJvOutlookBarActivePageProperty = class(TIntegerProperty)
|
|
|
|
private
|
2018-04-24 15:22:33 +00:00
|
|
|
function GetOutlookBar: TJvCustomOutlookBar;
|
2018-03-12 14:03:31 +00:00
|
|
|
public
|
|
|
|
function GetAttributes: TPropertyAttributes; override;
|
|
|
|
function GetValue: string; override;
|
|
|
|
procedure SetValue(const Value: string); override;
|
|
|
|
procedure GetValues(Proc: TGetStrProc); override;
|
|
|
|
end;
|
2018-04-24 15:22:33 +00:00
|
|
|
|
|
|
|
TJvOutlookBarCaptionProperty = class(TStringProperty)
|
|
|
|
public
|
|
|
|
procedure SetValue(const Value: string); override;
|
|
|
|
end;
|
|
|
|
|
2018-04-25 17:39:48 +00:00
|
|
|
(*
|
2018-03-12 14:03:31 +00:00
|
|
|
TJvOutlookBarPagesProperty = class(TPropertyEditor)
|
|
|
|
private
|
|
|
|
function GetOutlookBar: TJvCustomOutlookBar;
|
|
|
|
public
|
|
|
|
procedure Edit; override;
|
|
|
|
function GetAttributes: TPropertyAttributes; override;
|
|
|
|
function GetValue: string; override;
|
2018-04-24 15:22:33 +00:00
|
|
|
end;
|
2018-04-25 17:39:48 +00:00
|
|
|
*)
|
2018-03-12 14:03:31 +00:00
|
|
|
|
2018-04-25 17:39:48 +00:00
|
|
|
TJvOutlookBarButtonImageIndexProperty = class(TImageIndexPropertyEditor)
|
2018-04-24 15:22:33 +00:00
|
|
|
private
|
2018-03-12 14:03:31 +00:00
|
|
|
function GetPage: TJvOutlookBarPage;
|
|
|
|
function GetBar: TJvCustomOutlookBar;
|
2018-04-24 15:22:33 +00:00
|
|
|
protected
|
2018-03-12 14:03:31 +00:00
|
|
|
function GetImageList: TCustomImageList; override;
|
|
|
|
end;
|
|
|
|
|
2018-04-25 17:39:48 +00:00
|
|
|
TJvOutlookBarPageImageIndexProperty = class(TImageIndexPropertyEditor)
|
2018-04-24 15:22:33 +00:00
|
|
|
protected
|
2018-03-12 14:03:31 +00:00
|
|
|
function GetImageList: TCustomImageList; override;
|
|
|
|
end;
|
|
|
|
|
2018-04-25 07:47:38 +00:00
|
|
|
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;
|
|
|
|
|
2018-03-12 14:03:31 +00:00
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
2018-04-24 15:22:33 +00:00
|
|
|
JvDsgnConsts, JvOutlookBarForm;
|
2018-03-12 14:03:31 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
THackOutlookBar = class(TJvCustomOutlookBar);
|
|
|
|
THackPages = class(TJvOutlookBarPages);
|
|
|
|
THackButtons = class(TJvOutlookBarButtons);
|
|
|
|
|
2018-04-24 15:22:33 +00:00
|
|
|
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;
|
|
|
|
|
2018-03-12 14:03:31 +00:00
|
|
|
(*
|
|
|
|
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;
|
|
|
|
*)
|
2018-04-24 15:22:33 +00:00
|
|
|
|
2018-03-12 14:03:31 +00:00
|
|
|
//=== { TJvOutlookBarPagesProperty } =========================================
|
2018-04-25 17:39:48 +00:00
|
|
|
(*
|
2018-03-12 14:03:31 +00:00
|
|
|
procedure TJvOutlookBarPagesProperty.Edit;
|
|
|
|
begin
|
2018-04-24 15:22:33 +00:00
|
|
|
// !!!!!!!!!!!! HOW DO I GET THE DESIGNER HERE ???????????????
|
|
|
|
//ShowEditor(Designer, GetOutlookBar);
|
2018-03-12 14:03:31 +00:00
|
|
|
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;
|
2018-04-25 17:39:48 +00:00
|
|
|
*)
|
2018-04-24 15:22:33 +00:00
|
|
|
|
2018-03-12 14:03:31 +00:00
|
|
|
//=== { TJvOutlookBarEditor } ================================================
|
|
|
|
|
|
|
|
procedure TJvOutlookBarEditor.ExecuteVerb(Index: Integer);
|
|
|
|
begin
|
|
|
|
case Index of
|
2018-04-24 15:22:33 +00:00
|
|
|
0: OpenEditor;
|
|
|
|
else inherited ExecuteVerb(Index);
|
2018-03-12 14:03:31 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-04-24 15:22:33 +00:00
|
|
|
function TJvOutlookBarEditor.GetOutlookBar: TJvCustomOutlookBar;
|
|
|
|
var
|
|
|
|
lComponent: TComponent;
|
|
|
|
begin
|
|
|
|
lComponent := Self.GetComponent;
|
|
|
|
if (lComponent is TJvCustomOutlookBar) then
|
|
|
|
Result := TJvCustomOutlookBar(lComponent)
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
2018-03-12 14:03:31 +00:00
|
|
|
function TJvOutlookBarEditor.GetVerb(Index: Integer): string;
|
|
|
|
begin
|
|
|
|
case Index of
|
2018-04-24 15:22:33 +00:00
|
|
|
0: Result := RsOLBditor;
|
|
|
|
else Result := inherited GetVerb(Index);
|
2018-03-12 14:03:31 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TJvOutlookBarEditor.GetVerbCount: Integer;
|
|
|
|
begin
|
|
|
|
Result := 1;
|
2018-04-24 15:22:33 +00:00
|
|
|
end;
|
2018-03-12 14:03:31 +00:00
|
|
|
|
2018-04-24 15:22:33 +00:00
|
|
|
procedure TJvOutlookBarEditor.OpenEditor;
|
2018-03-12 14:03:31 +00:00
|
|
|
begin
|
2018-04-24 15:22:33 +00:00
|
|
|
ShowEditor(Designer, GetOutlookBar);
|
2018-03-12 14:03:31 +00:00
|
|
|
end;
|
|
|
|
|
2018-04-24 15:22:33 +00:00
|
|
|
|
2018-04-25 17:39:48 +00:00
|
|
|
//=== TJvOutlookBarActivePageProperty ==========================================
|
2018-04-24 15:22:33 +00:00
|
|
|
|
2018-03-12 14:03:31 +00:00
|
|
|
function TJvOutlookBarActivePageProperty.GetAttributes: TPropertyAttributes;
|
|
|
|
begin
|
|
|
|
Result := [paValueList, paSortList, paRevertable];
|
|
|
|
end;
|
|
|
|
|
2018-04-24 15:22:33 +00:00
|
|
|
function TJvOutlookBarActivePageProperty.GetOutlookBar: TJvCustomOutlookBar;
|
2018-03-12 14:03:31 +00:00
|
|
|
begin
|
|
|
|
if GetComponent(0) is TJvCustomOutlookBar then
|
|
|
|
Result := TJvCustomOutlookBar(GetComponent(0))
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TJvOutlookBarActivePageProperty.GetValue: string;
|
|
|
|
var
|
|
|
|
I: Integer;
|
2018-04-24 15:22:33 +00:00
|
|
|
olb: THackOutlookBar;
|
2018-03-12 14:03:31 +00:00
|
|
|
begin
|
2018-04-24 15:22:33 +00:00
|
|
|
Result := '';
|
|
|
|
olb := THackOutlookBar(GetOutlookBar);
|
|
|
|
if olb = nil then
|
|
|
|
exit;
|
2018-03-12 14:03:31 +00:00
|
|
|
I := GetOrdValue;
|
2018-04-24 15:22:33 +00:00
|
|
|
if (I >= 0) and (I < olb.Pages.Count) then
|
|
|
|
Result := olb.Pages[I].Caption
|
2018-03-12 14:03:31 +00:00
|
|
|
else
|
|
|
|
Result := inherited GetValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvOutlookBarActivePageProperty.GetValues(Proc: TGetStrProc);
|
|
|
|
var
|
|
|
|
I: Integer;
|
2018-04-24 15:22:33 +00:00
|
|
|
olb: THackOutlookBar;
|
2018-03-12 14:03:31 +00:00
|
|
|
begin
|
2018-04-24 15:22:33 +00:00
|
|
|
olb := THackOutlookBar(GetOutlookBar);
|
|
|
|
for I := 0 to olb.Pages.Count - 1 do
|
|
|
|
Proc(olb.Pages[I].Caption);
|
2018-03-12 14:03:31 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvOutlookBarActivePageProperty.SetValue(const Value: string);
|
|
|
|
var
|
|
|
|
I: Integer;
|
2018-04-24 15:22:33 +00:00
|
|
|
olb: THackOutlookBar;
|
2018-03-12 14:03:31 +00:00
|
|
|
begin
|
|
|
|
I := StrToIntDef(Value, -1);
|
|
|
|
if I < 0 then
|
|
|
|
begin
|
2018-04-24 15:22:33 +00:00
|
|
|
olb := THackOutlookBar(GetOutlookBar);
|
|
|
|
for I := 0 to olb.Pages.Count - 1 do
|
|
|
|
if AnsiSameText(olb.Pages[I].Caption, Value) then
|
2018-03-12 14:03:31 +00:00
|
|
|
begin
|
|
|
|
SetOrdValue(I);
|
|
|
|
Modified;
|
|
|
|
Break;
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
inherited SetValue(Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2018-04-24 15:22:33 +00:00
|
|
|
//=== TJvOutlookBarCaptionEditor ===============================================
|
|
|
|
|
|
|
|
procedure TJvOutlookBarCaptionProperty.SetValue(const Value: string);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
if EditWindow <> nil then
|
|
|
|
EditWindow.RefreshNames;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
//=== TJvOutlookBarButtonImageIndexProperty ====================================
|
2018-03-12 14:03:31 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
2018-04-24 15:22:33 +00:00
|
|
|
//=== TJvOutlookBarPageImageIndexProperty ======================================
|
2018-03-12 14:03:31 +00:00
|
|
|
|
|
|
|
function TJvOutlookBarPageImageIndexProperty.GetImageList: TCustomImageList;
|
2018-04-24 15:22:33 +00:00
|
|
|
var
|
|
|
|
page: TJvOutlookBarPage;
|
|
|
|
pages: TJvOutlookBarPages;
|
|
|
|
olb: TJvCustomOutlookBAr;
|
2018-03-12 14:03:31 +00:00
|
|
|
begin
|
2018-04-24 15:22:33 +00:00
|
|
|
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;
|
2018-03-12 14:03:31 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|