{***************************************************************************}
{ TMS IntraWeb Component Pack Pro                                           }
{ for Delphi & C++Builder                                                   }
{                                                                           }
{ written by TMS Software                                                   }
{            copyright © 2002 - 2010                                        }
{            Email : info@tmssoftware.com                                   }
{            Web : http://www.tmssoftware.com                               }
{                                                                           }
{ The source code is given as is. The author is not responsible             }
{ for any possible damage done due to the use of this code.                 }
{ The component can be freely used in any application. The complete         }
{ source code remains property of the author and may not be distributed,    }
{ published, given or sold in any form as such. No parts of the source      }
{ code can be included in any other component or application without        }
{ written authorization of the author.                                      }
{***************************************************************************}

unit IWTMSDEREG;

{$I TMSDEFS.INC}

interface

uses
  Classes, Forms, IWTMSCtrls, IWDBTMSCtrls, IWTMSMenus, IWTMSCal,
  IWScrollPanel, IWTickerPanel, IWOutlookBar,
  IWDBSmartPanel, IWDBScrollPanel, DB, IWControl,
  IWTMSButton, IWTMSCC, IWTMSPLAN, 
  IWSideNavBar, IWSideNavBarDE, IWExchangeBar, IWExchangeBarDE, IWColor, IWAutoFormFill,
  IWListEditor, IWResponsiveList,
  IWHTMLDE, IWLBLDE, IWHTMLListDE, IWHTMLColDE, IWHotSpotEditorDE, IWTMSBase,
  IWTMSImgCtrls, IWTMSImgDE, IWHotSpotImage, IWTMSImg, IWTMSPopup, IWPlannerDE,
  IWGallery, IWPropPersist, IWGIFPreview, IWHelpTip, IWAdvToolButton, IWColorComboBox,
  IWTMSEdit, IWContinuousScroll,
  {$IFNDEF BCB}
  {$IFNDEF DELPHI9_LVL}
  IWDsnHTMLMgr,
  {$ENDIF}
  {$ENDIF}
//  IWDsnPaint, IWDsnPaintHandlers,
{$IFDEF TMSIW51}
  IWBaseControl,
{$ENDIF}
{$IFDEF TMSIW7}
  {$IFNDEF TMSIW14}
  IWDsnColor,
  {$ENDIF}
  {$IFDEF TMSIW14}
  IWTMSPCKDsnColor,
  {$ENDIF}
  IWMultiColumnComboBox,
{$ENDIF}
{$IFDEF DELPHI6_LVL}
  DesignIntf, DesignEditors
{$ELSE}
  DsgnIntf
{$ENDIF}
  ;

type
  TIWDBFieldNameProperty = class(TStringProperty)
  public
    function GetAttributes:TPropertyAttributes; override;
    procedure GetValues(Proc:TGetStrProc); override;
  end;

  TOutlookBarEditor = class(TDefaultEditor)
  protected
  {$IFNDEF DELPHI6_LVL}
    procedure EditProperty(PropertyEditor: TPropertyEditor;
      var Continue, FreeEditor: Boolean); override;
  {$ELSE}
    procedure EditProperty(const PropertyEditor: IProperty; var Continue: Boolean); override;
  {$ENDIF}
  public
  end;

  TIWClientCodeEditor = class(TDefaultEditor)
  protected
  {$IFNDEF DELPHI6_LVL}
    procedure EditProperty(PropertyEditor: TPropertyEditor;
      var Continue, FreeEditor: Boolean); override;
  {$ELSE}
    procedure EditProperty(const PropertyEditor: IProperty; var Continue: Boolean); override;
  {$ENDIF}
  public
  end;

  TIWMainMenuEditor = class(TDefaultEditor)
  protected
  public
    function GetVerb(index:integer):string; override;
    function GetVerbCount:integer; override;
    procedure ExecuteVerb(Index:integer); override;
  end;

  TIWResponsiveListItemStyleEditor = class(TStringProperty)
  public
    function GetAttributes:TPropertyAttributes; override;
    procedure GetValues(Proc:TGetStrProc); override;
  end;


{$R IWTMSCtrlsReg.dcr}
{$R IWDBTMSCtrlsReg.dcr}

procedure Register;

implementation

uses
  SysUtils
  {$IFDEF DELPHI2006_LVL}
  , WideStrings
  {$ENDIF}
  ;

{$IFNDEF TMSIW14}
type
  TIWTMSPCKColorEditor = class(TIWColorEditor);
{$ENDIF}


{$IFDEF DELPHI6_LVL}
procedure TOutlookBarEditor.EditProperty(const PropertyEditor: IProperty; var Continue: Boolean);
{$ELSE}
procedure TOutlookBarEditor.EditProperty(PropertyEditor: TPropertyEditor;
  var Continue, FreeEditor: Boolean);
{$ENDIF}
var
  PropName: string;
begin
  PropName := PropertyEditor.GetName;
  if (CompareText(PropName, 'PANELS') = 0) then
  begin
    PropertyEditor.Edit;
    Continue := False;
  end;
end;

function TIWDBFieldNameProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList,paSortList];
end;

procedure TIWDBFieldNameProperty.GetValues(Proc:TGetStrProc);
var
  FDataSource: TDataSource;
  FDataSet: TDataSet;
  {$IFDEF DELPHIXE5_LVL}
  st: TStringList;
  {$ElSE}
    {$IFNDEF DELPHI2006_LVL}
    st: TStringList;
    {$ENDIF}
    {$IFDEF DELPHI2006_LVL}
    st: TWideStringList;
    {$ENDIF}
  {$ENDIF}
  i: Integer;
begin
  FDataSource := nil;

  if GetComponent(0) is TTIWDBSmartPanel then
  begin
    FDataSource := (GetComponent(0) as TTIWDBSmartPanel).DataSource;
  end;

  if not Assigned(FDataSource) then
    Exit;

  FDataSet := FDataSource.DataSet;

  if not Assigned(FDataSet) then
    Exit;

  {$IFDEF DELPHIXE5_LVL}
  st := TStringList.Create;
  {$ELSE}
    {$IFNDEF DELPHI2006_LVL}
    st := TStringList.Create;
    {$ENDIF}
    {$IFDEF DELPHI2006_LVL}
    st := TWideStringList.Create;
    {$ENDIF}
  {$ENDIF}

  FDataSet.GetFieldNames(st);
  for i := 1 to st.Count do Proc(st.Strings[i - 1]);
  st.Free;
end;


{$IFDEF DELPHI6_LVL}
procedure TIWClientCodeEditor.EditProperty(const PropertyEditor: IProperty; var Continue: Boolean);
{$ELSE}
procedure TIWClientCodeEditor.EditProperty(PropertyEditor: TPropertyEditor;
  var Continue, FreeEditor: Boolean);
{$ENDIF}
var
  PropName: string;
begin
  PropName := PropertyEditor.GetName;
  if (CompareText(PropName, 'CODE') = 0) then
  begin
    PropertyEditor.Edit;
    Continue := False;
  end;
end;



procedure Register;
begin
  //RegisterComponents('TMS IW',[TTIWGIFPreview, TIWPropertyPersister]);
  {$IFNDEF LINUX}
  RegisterPropertyEditor(TypeInfo(THotSpots), TTIWHotSpotImage, 'HOTSPOTS', TTIWHotSpotEditor);
  RegisterComponentEditor(TTIWHotSpotImage, TTIWHotSpotImageEditor);

  RegisterPropertyEditor(TypeInfo(string), TTIWHTMLLabel, 'HTMLText', TIWHTMLStringProperty);
  RegisterPropertyEditor(TypeInfo(string), TTIWHTMLCheckBox, 'HTMLText', TIWHTMLStringProperty);

  RegisterPropertyEditor(TypeInfo(TStrings), TTIWHTMLList, 'Items', TIWHTMLStringListProperty);
  RegisterPropertyEditor(TypeInfo(TStrings), TTIWHTMLRadioGroup, 'Items', TIWHTMLStringListProperty);

  RegisterPropertyEditor(TypeInfo(string), TTIWContinuousScroll, 'ItemTemplate', TIWHTMLStringProperty);

  RegisterPropertyEditor(TypeInfo(TTIWStaticMenuItems), TTIWStaticMenu, 'Items', TIWHTMLCollectionProperty);

  RegisterComponentEditor(TTIWHTMLLabel, TIWHTMLDefaultEditor);
  RegisterComponentEditor(TTIWHTMLCheckBox, TIWHTMLDefaultEditor);

  RegisterComponentEditor(TTIWHTMLList,TIWHTMLListDefaultEditor);
  RegisterComponentEditor(TTIWHTMLRadioGroup,TIWHTMLListDefaultEditor);
  RegisterComponentEditor(TTIWStaticMenu,TIWHTMLListDefaultEditor);

  RegisterComponentEditor(TTIWClientCode,TIWClientCodeEditor);

  RegisterComponentEditor(TTIWMainMenu,TIWMainMenuEditor);
  RegisterComponentEditor(TTIWSideMenu,TIWMainMenuEditor);  

  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWCalendar, 'BackgroundImage', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWPopupMenuButton, 'BackgroundImage', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWPopupMenuLabel, 'BackgroundImage', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWDocumentPopupMenu, 'BackgroundImage', TTIWAdvImageProperty);

  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWCustomDatePicker, 'BackgroundImage', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWCustomDatePicker, 'DropDownImage', TTIWAdvImageProperty);

  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWHelpTip, 'Image', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvToolButton, 'Glyph', TTIWAdvImageProperty);

  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvImage, 'Picture', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvImage, 'HotPicture', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWFadeImage, 'Picture', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWHotSpotImage, 'Picture', TTIWAdvImageProperty);

  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWMainMenu, 'ItemCheckedGlyph', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWMainMenu, 'SubMenuGlyph', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWMainMenu, 'BackgroundImage', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWSideMenu, 'ItemCheckedGlyph', TTIWAdvImageProperty);  
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWSideMenu, 'SubMenuGlyph', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWSideMenu, 'BackgroundImage', TTIWAdvImageProperty);

  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWPopupMenuButton, 'ItemCheckedGlyph', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWPopupMenuLabel, 'ItemCheckedGlyph', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWDocumentPopupMenu, 'ItemCheckedGlyph', TTIWAdvImageProperty);  

  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWPopupMenuButton, 'SubMenuGlyph', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWPopupMenuLabel, 'SubMenuGlyph', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWDocumentPopupMenu, 'SubMenuGlyph', TTIWAdvImageProperty);

  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWPopupMenuButton, 'BackgroundImage', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWPopupMenuLabel, 'BackgroundImage', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWDocumentPopupMenu, 'BackgroundImage', TTIWAdvImageProperty);

  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvImageButton, 'Picture', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvImageButton, 'HotPicture', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvImageButton, 'DownPicture', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvImageButton, 'DisabledPicture', TTIWAdvImageProperty);

  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWMonthPlanner, 'BackgroundImage', TTIWAdvImageProperty);

  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvTimeEdit, 'ButtonDownImage', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvTimeEdit, 'ButtonUpImage', TTIWAdvImageProperty);

  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvDateEdit, 'ButtonDownImage', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvDateEdit, 'ButtonUpImage', TTIWAdvImageProperty);

  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvSpinEdit, 'ButtonDownImage', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWAdvSpinEdit, 'ButtonUpImage', TTIWAdvImageProperty);

  RegisterComponentEditor(TTIWMonthPlanner,TIWMonthPlannerEditor);
  {$ENDIF}

  RegisterPropertyEditor(TypeInfo(string),TTIWDBSmartPanel,'CaptionField',TIWDBFieldNameProperty);

  RegisterComponentEditor(TTIWOutlookBar,TOutlookBarEditor);

  RegisterComponentEditor(TTIWSideNavBar,TIWSideNavBarEditor);
  RegisterComponentEditor(TTIWExchangeBar,TIWExchangeBarEditor);

  {$IFDEF TMSIW7}
  { SideNavBar }
  RegisterPropertyEditor(TypeInfo(TIWColor), TSideNavBarButton, '', TIWTMSPCkColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TSideNavBarDivider, '', TIWTMSPCkColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TSideNavBarItemDisplay, '', TIWTMSPCkColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TSideNavBarPanel, '' , TIWTMSPCkColorEditor);

  { ExchangeBar }
  RegisterPropertyEditor(TypeInfo(TIWColor), TExchangeBarButton, '', TIWTMSPCkColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TExchangeBarItemDisplay, '', TIWTMSPCkColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TExchangeBarDivider, '', TIWTMSPCkColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TExchangeBarPanel, '' , TIWTMSPCkColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TTIWColumnTitles, '', TIWTMSPCkColorEditor);

  RegisterPropertyEditor(TypeInfo(TIWColor), TIWComboBoxColor, '', TIWTMSPCkColorEditor);

  { AutoFormFill }
  RegisterPropertyEditor(TypeInfo(TIWColor), TIWAFFDropDown, '', TIWTMSPCkColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TIWAFFHighLight, '', TIWTMSPCkColorEditor);

  { TIWListEditor }
  RegisterPropertyEditor(TypeInfo(TIWColor), TIWAppearance, '', TIWTMSPCkColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TIWItemAppearance, '', TIWTMSPCkColorEditor);

  { TIWResponsiveList }
  RegisterPropertyEditor(TypeInfo(TIWColor), TIWItemStyle, '', TIWTMSPCkColorEditor);
  RegisterPropertyEditor(TypeInfo(String), TIWListItem, 'ItemStyle', TIWResponsiveListItemStyleEditor);
  {$ENDIF}

//  IWRegisterPaintHandler('TTIWCountryComboBox',TIWPaintHandlerComboBox);
//  IWRegisterPaintHandler('TTIWPersistentEdit',TIWPaintHandlerEdit);
//  IWRegisterPaintHandler('TTIWEmailEdit',TIWPaintHandlerEdit);
//  IWRegisterPaintHandler('TTIWCCNumEdit',TIWPaintHandlerEdit);


  {$IFNDEF TMSIW51}
  {$IFNDEF BCB}
  IWRegisterHTMLComponents('TMS IW',HInstance,[TTIWAdvEdit,TTIWAdvLUEdit, TTIWDateSelector,TTIWEmailEdit]);
  IWRegisterHTMLComponents('TMS IW',HInstance,[TTIWHTMLLabel,TTIWDateLabel, TTIWClock, TTIWHTMLCheckBox,TTIWHTMLList,TTIWHTMLRadioGroup]);

  IWRegisterHTMLComponents('TMS IW',HInstance,[TTIWFilePicker,TTIWStaticMenu, TTIWMainMenu,TTIWSideMenu]);

  IWRegisterHTMLComponents('TMS IW',HInstance,[TTIWCalendar,TTIWDatePicker]);

  {$IFNDEF LINUX}
  IWRegisterHTMLComponents('TMS IW',HInstance,[TTIWAdvImage,TTIWFadeImage,TTIWHotSpotImage]);
  IWRegisterHTMLComponents('TMS IW',HInstance,[TTIWPaintBox,TTIWCountryComboBox,TTIWPersistentEdit]);
  {$ENDIF}

  IWRegisterHTMLComponents('TMS IW',HInstance,[TTIWDBAdvEdit,TTIWDBAdvLUEdit, TTIWDBDatePicker, TTIWDBCalendar, TTIWDBHTMLLabel]);

  IWRegisterHTMLComponents('TMS IW',HInstance,[TTIWScrollPanel,TTIWSmartPanel, TTIWTickerPanel]);
  {$ENDIF}


  {$ENDIF}
end;

{ TIWMainMenuEditor }


procedure TIWMainMenuEditor.ExecuteVerb(Index: integer);
begin
  inherited;
  if Index = 0 then
  begin
    ForceDirectories(GetProgramFiles + '\tmssoftware\TMSIWPRO\Preferences\Menus\');
    Gallery := TGallery.Create(Application);
    Gallery.Component := Component;
    Gallery.FilePath := GetProgramFiles + '\tmssoftware\TMSIWPRO\Preferences\Menus\';
    Gallery.FillList;
    Gallery.ShowModal;
    Gallery.Free;
    Designer.Modified;
  end;
end;

function TIWMainMenuEditor.GetVerb(index: integer): string;
begin
  if Index = 0 then
    Result := 'Gallery';
end;

function TIWMainMenuEditor.GetVerbCount: integer;
begin
  Result := 1;
end;

{ TIWResponsiveListItemStyleEditor }

function TIWResponsiveListItemStyleEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList, paSortList];
end;

procedure TIWResponsiveListItemStyleEditor.GetValues(Proc: TGetStrProc);
var
  FIWResList: TTIWCustomResponsiveList;
  i: Integer;
begin
  if GetComponent(0) is TIWListItem then
    FIWReslist := TTIWCustomResponsiveList(TIWListItems((GetComponent(0) as TIWListItem).GetOwner).GetOwner)
  else
    Exit;

  for I := 0 to FIWResList.ItemStyles.Count - 1 do
    Proc(FIWResList.ItemStyles[I].Name);
end;

end.

