home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 26 / CD_ASCQ_26_1295.iso / vrac / ctrlkit.zip / TABBOX.INT < prev    next >
Text File  |  1995-09-16  |  5KB  |  177 lines

  1. unit TabBox;
  2.  
  3. interface
  4.  
  5. uses
  6.   Classes, Controls, Forms, Graphics, Menus, Messages, StdCtrls, SysUtils,
  7.   WinTypes, WinProcs;
  8.  
  9. const
  10.   MIN_COL = 1;
  11.  
  12. type
  13.   TWidthCalc = (lbPixels, lbAverageChar, lbMaxChar);
  14.  
  15.   TTabComboBox = class(TCustomComboBox)
  16.   private
  17.     FTabs       : PWordArray;
  18.     FNumTabs    : Integer;
  19.     FCol        : Integer;
  20.     FColumns    : Integer;
  21.     FWidthCalc  : TWidthCalc;
  22.  
  23.     procedure AllocTabs;
  24.     procedure CMFontChanged(var Msg: TMessage); message CM_FONTCHANGED;
  25.     procedure ConvertUnits(NewUnits : TWidthCalc);
  26.     procedure FreeTabs;
  27.     function  GetAverageCharWidth: Double;
  28.     function  GetColWidth: Integer;
  29.     function  GetMaxCharWidth: Integer;
  30.     procedure SetCol(AColumn : Integer);
  31.     procedure SetColumns(AValue : Integer);
  32.     procedure SetColWidth(AWidth : Integer);
  33.     procedure SetWidthCalc(AMethod : TWidthCalc);
  34.     procedure ReadWidths(Reader: TReader);
  35.     procedure WriteWidths(Writer: TWriter);
  36.  
  37.   protected
  38.     procedure DrawItem(Index: Integer;
  39.                        Rect: TRect;
  40.                        State: TOwnerDrawState); override;
  41.     procedure DefineProperties(Filer: TFiler); override;
  42.     procedure Loaded; override;
  43.  
  44.   public
  45.     constructor Create(AOwner : TComponent); override;
  46.     destructor  Destroy; virtual;
  47.  
  48.   published
  49.     property Color;
  50.     property Ctl3D;
  51.     property DragMode;
  52.     property DragCursor;
  53.     property DropDownCount;
  54.     property Enabled;
  55.     property Font;
  56.     property ItemHeight;
  57.     property Items;
  58.     property MaxLength;
  59.     property ParentColor;
  60.     property ParentCtl3D;
  61.     property ParentFont;
  62.     property ParentShowHint;
  63.     property PopupMenu;
  64.     property ShowHint;
  65.     property Sorted;
  66.     property TabOrder;
  67.     property TabStop;
  68.     property Text;
  69.     property Visible;
  70.     property OnChange;
  71.     property OnClick;
  72.     property OnDblClick;
  73.     property OnDragDrop;
  74.     property OnDragOver;
  75.     property OnDrawItem;
  76.     property OnDropDown;
  77.     property OnEndDrag;
  78.     property OnEnter;
  79.     property OnExit;
  80.     property OnKeyDown;
  81.     property OnKeyPress;
  82.     property OnKeyUp;
  83.     property OnMeasureItem;
  84.  
  85.     property Column: Integer read FCol write SetCol stored False;
  86.     property Columns: Integer read FColumns write SetColumns default MIN_COL;
  87.     property ColWidth: Integer read GetColWidth write SetColWidth stored False;
  88.     property ColWidthCalc: TWidthCalc read FWidthCalc write SetWidthCalc;
  89.   end;
  90.  
  91.   TTabListBox = Class(TCustomListBox)
  92.   private
  93.     FTabs       : PWordArray;
  94.     FNumTabs    : Integer;
  95.     FCol        : Integer;
  96.     FColumns    : Integer;
  97.     FWidthCalc  : TWidthCalc;
  98.  
  99.   private
  100.     procedure AllocTabs;
  101.     procedure CMFontChanged(var Msg: TMessage); message CM_FONTCHANGED;
  102.     procedure ConvertUnits(NewUnits : TWidthCalc);
  103.     procedure FreeTabs;
  104.     function  GetColWidth: Integer;
  105.     procedure SetCol(AColumn : Integer);
  106.     procedure SetColumns(AValue : Integer);
  107.     procedure SetColWidth(AWidth : Integer);
  108.     procedure SetWidthCalc(AMethod : TWidthCalc);
  109.     procedure ReadWidths(Reader: TReader);
  110.     procedure WriteWidths(Writer: TWriter);
  111.  
  112.   protected
  113.     procedure CreateParams(var Params : TCreateParams); override;
  114.     procedure DrawItem(Index: Integer;
  115.                        Rect: TRect;
  116.                        State: TOwnerDrawState); override;
  117.     procedure DefineProperties(Filer: TFiler); override;
  118.     procedure Loaded; override;
  119.  
  120.   public
  121.     constructor Create(AOwner : TComponent); override;
  122.     destructor  Destroy; virtual;
  123.  
  124.     function  GetAverageCharWidth: Double;
  125.     function  GetMaxCharWidth: Integer;
  126.  
  127.   published
  128.     property Align;
  129.     property BorderStyle;
  130.     property Color;
  131.     {property Columns;}
  132.     property Ctl3D;
  133.     property DragCursor;
  134.     property DragMode;
  135.     property Enabled;
  136.     property ExtendedSelect;
  137.     property Font;
  138.     property IntegralHeight;
  139.     property ItemHeight;
  140.     property Items;
  141.     {property MultiSelect;}
  142.     property ParentColor;
  143.     property ParentCtl3D;
  144.     property ParentFont;
  145.     property ParentShowHint;
  146.     property PopupMenu;
  147.     property ShowHint;
  148.     property Sorted;
  149.     {property Style;}
  150.     property TabOrder;
  151.     property TabStop;
  152.     property Visible;
  153.     property OnClick;
  154.     property OnDblClick;
  155.     property OnDragDrop;
  156.     property OnDragOver;
  157.     {property OnDrawItem;}
  158.     property OnEndDrag;
  159.     property OnEnter;
  160.     property OnExit;
  161.     property OnKeyDown;
  162.     property OnKeyPress;
  163.     property OnKeyUp;
  164.     property OnMeasureItem;
  165.     property OnMouseDown;
  166.     property OnMouseMove;
  167.     property OnMouseUp;
  168.  
  169.     property Column: Integer read FCol write SetCol stored False;
  170.     property Columns: Integer read FColumns write SetColumns default MIN_COL;
  171.     property ColWidth: Integer read GetColWidth write SetColWidth stored False;
  172.     property ColWidthCalc: TWidthCalc read FWidthCalc write SetWidthCalc;
  173.   end;
  174.  
  175.  
  176. implementation
  177. end.