Autor Beitrag
Dezipaitor
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 220



BeitragVerfasst: Mi 24.01.07 19:23 
hi,

ich habe eine Komponente geschrieben, die es ermöglicht eine Liste von Checkboxen zu erstellen, die etwas schicker aussehen, als eine standard Checkboxlist.
Siehe die angehängten Bilder.

Die Units sind von mir (bis auf compilers.inc) und in ANSI und Unicode aufgeteilt.
So ziemlich alles ist auf englisch Kommentiert und auch mit Beispielen versehen.

Die verwendete Lizenz ist Creative Commons
# Namensnennung. Sie müssen den Namen des Autors/Rechtsinhabers nennen.
# Keine kommerzielle Nutzung. Dieser Inhalt darf nicht für kommerzielle Zwecke verwendet werden.
# Weitergabe unter gleichen Bedingungen. Wenn Sie diesen Inhalt bearbeiten oder in anderer Weise umgestalten, verändern oder als Grundlage für einen anderen Inhalt verwenden, dann dürfen Sie den neu entstandenen Inhalt nur unter Verwendung identischer Lizenzbedingungen weitergeben.

Zur Installation:
Erstelle oder verwende ein Package, in das du eine oder beide Units einträgst. Danach installierst du das Paket und so kannst du die Komponente(n) in der Standardkomponentenleiste auswählen.
Für die Unicodevariante muss der Source-Pfad zu den TNTControls in den Paketoptionen eingetragen sein.

Hier ein Überblick über die öffentlichen Teile:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
public
    { Public-Deklarationen }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;

    {Adjust labels if scrollbox width is beeing changed.}
    procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;

    {Updates all Items after a change has happend.
     This procedure is no more necessary to be called. }

    procedure UpdateItems;

    function GetCheckBoxNameIndex(Name : WideString) : Integer;

    {Sets or get checkbox check status.
     If index is not in bounds (< Items.Count) an Exception is raised.}

    property Checked[Index: Integer]: Boolean read GetChecked write SetChecked;

    {Sets or get checkbox enable status.
     If index is not in bounds (< Items.Count) an Exception is raised.}

    property ItemEnabled[Index: Integer]: Boolean read GetItemEnabled write SetItemEnabled;

    {Labels gives you direct access to a label and checkbox control in scrollbox.
     You can simypl access a checkbox by (Labels[1].FocusControl as TUCheckBox).
     Warning:
       You must not change Labels[1].FocusControl or results are unpredictable.
       Following events are used:

        TULabel.OnClick
        TUCheckBox.OnEnter
        TUCheckBox.OnExit
        TUCheckBox.OnClick

     Property Labels is readonly, however you can change properties of given label.
    }

    property Labels[Index : Integer] : TULabel read GeTULabelByIndex;

    property CheckBoxIndex[CheckBoxName : WideString] : Integer read GetCheckBoxIndex;

    {Margin contains values to add to left and top scrollbox borders.
     All checkboxes and labels are affected.}

    property Margin : TPoint read FMargin write FMargin;


    {contains label descriptions.
     Setting Items directly (by Items := myStringList) updates labels and checkboxes automatically.

     All types of direct manipulating Items are supported :
       Items[0] := '123';
       Items.Exchange(1,0);
       items.Add
       items.delete
       and so on...
     Add and Delete will erase all checked settings. 



     Be aware that all Objects (TUStringList.Objects) are used for
      internal operations. Changes leads to unpredictable results.

     }

    property Items : TUStrings read FItems write SetItems;

    {Renames checkbox names.
     If you enters invalid or duplicate names an EComponentError will be raised
      as soon as the checkboxes are created.
      Checkboxes will be removed and readded. 
    }

    property CheckBoxNames : TUStrings read FCheckBoxNames write SetCheckBoxNames;


    {Changes label background color.
     This color is beeing used if a checkbox gets focus.}

    property FocusLabelColor : TColor read FFocusLabelColor write FFocusLabelColor;

    {If a checkbox changes check state this event is called.
     More info see @link(TOnCheckBoxChecked)}

    property OnCheckBoxChecked : TOnCheckBoxChecked read FOnCheckBoxChecked write FOnCheckBoxChecked;

    {Sets or gets a hint of a checkbox given by index.
    }

    property CheckBoxHint[Index : Integer] : WideString read GetCheckBoxHint write SetCheckBoxHint;

    {**** If you adds new properties don't forget to add them to the published class underneath,
     otherwise the new property will not be visible within object inspector}

  end;
Einloggen, um Attachments anzusehen!