unit comp_browser_main; {$mode objfpc}{$H+} interface uses Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, Menus, Buttons, StdCtrls, ExtCtrls, ActnList, MaskEdit, grids, CheckLst, PairSplitter, ColorBox, ValEdit, SynHighlighterPosition, strutils, SynEdit, typinfo; type TPalettePage = (ppStandard, ppAdditional, ppOtherPagesNotListedHere); { TForm1 } TForm1 = class(TForm) seViewer: TSynEdit; tvComps: TTreeView; procedure FormCreate(Sender: TObject); private compClass: TComponentClass; procedure LoadTreeView; function GetComponentClass(aPage: TPalettePage; anIndex: word): TComponentClass; public end; const MaxComponentsOnAPage = 21; // AdditionalPage PageNames : array[TPalettePage] of shortstring = ('Standard', 'Additional', 'Other unlisted pages'); var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject); begin LoadTreeView; end; procedure TForm1.LoadTreeView; var aNode: TTreeNode; palPage: TPalettePage; i: integer; begin tvComps.BeginUpdate; for palPage := High(TPalettePage) downto Low(TPalettePage) do begin aNode := tvComps.Items.AddFirst(nil, PageNames[palPage]); for i := 1 to MaxComponentsOnAPage do begin compClass := GetComponentClass(palPage, i); if Assigned(compClass) then tvComps.Items.AddChildObject( aNode, compClass.ClassName, TObject(compClass) ); end; end; tvComps.EndUpdate; tvComps.Selected := tvComps.Items[0]; end; function TForm1.GetComponentClass( aPage: TPalettePage; anIndex: word ): TComponentClass; begin case aPage of ppStandard: case anIndex of 1: result := TMainMenu; 2: result := TPopupMenu; 3: result := TButton; 4: result := TLabel; 5: result := TEdit; 6: result := TMemo; 7: result := TToggleBox; 8: result := TCheckBox; 9: result := TRadioButton; 10: result := TListBox; 11: result := TComboBox; 12: result := TScrollBar; 13: result := TGroupBox; 14: result := TRadioGroup; 15: result := TCheckGroup; 16: result := TPanel; 17: result := TFrame; 18: result := TActionList; else result := nil; end; ppAdditional: case anIndex of 1: result := TBitBtn; 2: result := TSpeedbutton; 3: result := TStaticText; 4: result := TImage; 5: result := TShape; 6: result := TBevel; 7: result := TPaintBox; 8: result := TNotebook; 9: result := TlabeledEdit; 10: result := TSplitter; 11: result := TTrayIcon; 12: result := TMaskEdit; 13: result := TCheckListBox; 14: result := TScrollBox; 15: result := TApplicationProperties; 16: result := TStringGrid; 17: result := TDrawGrid; 18: result := TPairSplitter; 19: result := TColorBox; 20: result := TColorListBox; 21: result := TValueListEditor; else result := nil; end; else result := nil; end; end; end.