{***************************************************************************}
{ TMS IntraWeb Component Pack Pro                                           }
{ for Delphi & C++Builder                                                   }
{                                                                           }
{ written by TMS Software                                                   }
{            copyright © 2002 - 2007                                        }
{            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,
{$IFNDEF LINUX}
  IWHTMLDE, IWLBLDE, IWHTMLListDE, IWHTMLColDE, IWHotSpotEditorDE, IWTMSBase,
  IWTMSImgCtrls, IWTMSImgDE, IWHotSpotImage, IWTMSImg, IWTMSPopup, IWPlannerDE,
  IWGallery, IWPropPersist, IWGIFPreview, IWHelpTip, IWAdvToolButton, IWColorComboBox,
{$ENDIF}
  {$IFNDEF BCB}
  {$IFNDEF DELPHI9_LVL}
  IWDsnHTMLMgr,
  {$ENDIF}
  {$ENDIF}
//  IWDsnPaint, IWDsnPaintHandlers,
{$IFDEF TMSIW51}
  IWBaseControl,
{$ENDIF}
{$IFDEF TMSIW7}
  IWDsnColor,
  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;


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

procedure Register;

implementation

uses
  SysUtils;


{$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;
  st: TStringList;
  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;

  st := TStringList.Create;
  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(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, 'SubMenuGlyph', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWMainMenu, 'BackgroundImage', TTIWAdvImageProperty);  
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWSideMenu, 'SubMenuGlyph', TTIWAdvImageProperty);
  RegisterPropertyEditor(TypeInfo(TIPicture), TTIWSideMenu, 'BackgroundImage', 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);

  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, '', TIWColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TSideNavBarDivider, '', TIWColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TSideNavBarItemDisplay, '', TIWColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TSideNavBarPanel, '' , TIWColorEditor);

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

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

  { AutoFormFill }
  RegisterPropertyEditor(TypeInfo(TIWColor), TIWAFFDropDown, '', TIWColorEditor);
  RegisterPropertyEditor(TypeInfo(TIWColor), TIWAFFHighLight, '', TIWColorEditor);  
  {$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;

end.

