home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kolekce / d6 / RX275D6.ZIP / Units / DUALLIST.PAS < prev    next >
Pascal/Delphi Source File  |  1999-10-12  |  5KB  |  178 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {         Delphi VCL Extensions (RX)                    }
  4. {                                                       }
  5. {         Copyright (c) 1995, 1996 AO ROSNO             }
  6. {                                                       }
  7. {*******************************************************}
  8.  
  9. unit DualList;
  10.  
  11. interface
  12.  
  13. {$I RX.INC}
  14.  
  15. uses Classes, Controls;
  16.  
  17. type
  18.  
  19. { TDualListDialog }
  20.  
  21.   TDualListDialog = class(TComponent)
  22.   private
  23.     FCtl3D: Boolean;
  24.     FSorted: Boolean;
  25.     FTitle: PString;
  26.     FLabel1Caption: TCaption;
  27.     FLabel2Caption: TCaption;
  28.     FOkBtnCaption: TCaption;
  29.     FCancelBtnCaption: TCaption;
  30.     FHelpBtnCaption: TCaption;
  31.     FHelpContext: THelpContext;
  32.     FList1: TStrings;
  33.     FList2: TStrings;
  34.     FShowHelp: Boolean;
  35.     function GetTitle: string;
  36.     procedure SetTitle(const ATitle: string);
  37.     procedure SetList1(Value: TStrings);
  38.     procedure SetList2(Value: TStrings);
  39.     function IsLabel1Custom: Boolean;
  40.     function IsLabel2Custom: Boolean;
  41.     function IsOkBtnCustom: Boolean;
  42.     function IsCancelBtnCustom: Boolean;
  43.     function IsHelpBtnCustom: Boolean;
  44.   public
  45.     constructor Create(AOwner: TComponent); override;
  46.     destructor Destroy; override;
  47.     function Execute: Boolean;
  48.   published
  49.     property Ctl3D: Boolean read FCtl3D write FCtl3D default True;
  50.     property Sorted: Boolean read FSorted write FSorted;
  51.     property Title: string read GetTitle write SetTitle;
  52.     property Label1Caption: TCaption read FLabel1Caption write FLabel1Caption
  53.       stored IsLabel1Custom;
  54.     property Label2Caption: TCaption read FLabel2Caption write FLabel2Caption
  55.       stored IsLabel2Custom;
  56.     property OkBtnCaption: TCaption read FOkBtnCaption write FOkBtnCaption
  57.       stored IsOkBtnCustom;
  58.     property CancelBtnCaption: TCaption read FCancelBtnCaption write FCancelBtnCaption
  59.       stored IsCancelBtnCustom;
  60.     property HelpBtnCaption: TCaption read FHelpBtnCaption write FHelpBtnCaption
  61.       stored IsHelpBtnCustom;
  62.     property HelpContext: THelpContext read FHelpContext write FHelpContext;
  63.     property List1: TStrings read FList1 write SetList1;
  64.     property List2: TStrings read FList2 write SetList2;
  65.     property ShowHelp: Boolean read FShowHelp write FShowHelp default True;
  66.   end;
  67.  
  68. implementation
  69.  
  70. uses SysUtils, Forms, FDualLst, Consts, RxTConst, VCLUtils;
  71.  
  72. { TDualListDialog }
  73.  
  74. constructor TDualListDialog.Create(AOwner: TComponent);
  75. begin
  76.   inherited Create(AOwner);
  77.   FCtl3D := True;
  78.   FShowHelp := True;
  79.   FTitle := NullStr;
  80.   FList1 := TStringList.Create;
  81.   FList2 := TStringList.Create;
  82.   FLabel1Caption := LoadStr(SDualListSrcCaption);
  83.   FLabel2Caption := LoadStr(SDualListDestCaption);
  84.   OkBtnCaption := ResStr(SOKButton);
  85.   CancelBtnCaption := ResStr(SCancelButton);
  86.   HelpBtnCaption := ResStr(SHelpButton);
  87. end;
  88.  
  89. destructor TDualListDialog.Destroy;
  90. begin
  91.   List1.Free;
  92.   List2.Free;
  93.   DisposeStr(FTitle);
  94.   inherited Destroy;
  95. end;
  96.  
  97. function TDualListDialog.GetTitle: string;
  98. begin
  99.   Result := FTitle^;
  100. end;
  101.  
  102. procedure TDualListDialog.SetTitle(const ATitle: string);
  103. begin
  104.   AssignStr(FTitle, ATitle);
  105. end;
  106.  
  107. procedure TDualListDialog.SetList1(Value: TStrings);
  108. begin
  109.   FList1.Assign(Value);
  110. end;
  111.  
  112. procedure TDualListDialog.SetList2(Value: TStrings);
  113. begin
  114.   FList2.Assign(Value);
  115. end;
  116.  
  117. function TDualListDialog.IsLabel1Custom: Boolean;
  118. begin
  119.   Result := CompareStr(Label1Caption, LoadStr(SDualListSrcCaption)) <> 0;
  120. end;
  121.  
  122. function TDualListDialog.IsLabel2Custom: Boolean;
  123. begin
  124.   Result := CompareStr(Label2Caption, LoadStr(SDualListDestCaption)) <> 0;
  125. end;
  126.  
  127. function TDualListDialog.IsOkBtnCustom: Boolean;
  128. begin
  129.   Result := CompareStr(OkBtnCaption, ResStr(SOKButton)) <> 0;
  130. end;
  131.  
  132. function TDualListDialog.IsCancelBtnCustom: Boolean;
  133. begin
  134.   Result := CompareStr(CancelBtnCaption, ResStr(SCancelButton)) <> 0;
  135. end;
  136.  
  137. function TDualListDialog.IsHelpBtnCustom: Boolean;
  138. begin
  139.   Result := CompareStr(HelpBtnCaption, ResStr(SHelpButton)) <> 0;
  140. end;
  141.  
  142. function TDualListDialog.Execute: Boolean;
  143. var
  144.   Form: TDualListForm;
  145. begin
  146.   Form := TDualListForm.Create(Application);
  147.   try
  148.     with Form do begin
  149.       Ctl3D := Self.Ctl3D;
  150. {$IFDEF WIN32}
  151.       if NewStyleControls then Font.Style := [];
  152. {$ENDIF}
  153.       ShowHelp := Self.ShowHelp;
  154.       SrcList.Sorted := Sorted;
  155.       DstList.Sorted := Sorted;
  156.       SrcList.Items := List1;
  157.       DstList.Items := List2;
  158.       if Self.Title <> '' then Form.Caption := Self.Title;
  159.       if Label1Caption <> '' then SrcLabel.Caption := Label1Caption;
  160.       if Label2Caption <> '' then DstLabel.Caption := Label2Caption;
  161.       OkBtn.Caption := OkBtnCaption;
  162.       CancelBtn.Caption := CancelBtnCaption;
  163.       HelpBtn.Caption := HelpBtnCaption;
  164.       HelpContext := Self.HelpContext;
  165.       HelpBtn.HelpContext := HelpContext;
  166.     end;
  167.     Result := (Form.ShowModal = mrOk);
  168.     if Result then begin
  169.       List1 := Form.SrcList.Items;
  170.       List2 := Form.DstList.Items;
  171.     end;
  172.   finally
  173.     Form.Free;
  174.   end;
  175. end;
  176.  
  177. end.
  178.