Difference between revisions of "ATTabs"

From Lazarus wiki
Jump to navigationJump to search
Line 22: Line 22:
  
 
* Add tabs OnChange event handler.
 
* Add tabs OnChange event handler.
* In this event handler make a) hiding all frames, b) showing frame, which is assigned to current TabIndex.
+
* In this event handler: a) hide all frames, b) show frame, which is assigned to current TabIndex.
  
When you create a new tab, you can set its TabObject property. Set TabObject to a frame. When OnChage occurs, get TabIndex, call GetTabData for this index, and read TabObject for this tab. Show frame, which is stored in this TabObject, hide all others.
+
When you create a new tab, you can set its TabObject property. Set TabObject to a frame. When OnChange is called, get TabIndex, call GetTabData() for this index, and read TabObject for this tab. Show the frame, which is stored in this TabObject, hide all others.
  
 
<syntaxhighlight>
 
<syntaxhighlight>

Revision as of 15:50, 24 October 2017

Deutsch (de) English (en) русский (ru)

About

ATTabs is a tab-control component for Delphi and Lazarus. It's not replacement for standard tab control, but is alternative one, it has different API. It paints tabs OS-indenendant, using custom drawing on canvas.

Screenshot:

ATTabs demo.png

Author: Alexey Torgashin

Help

GitHub page has help files, which describe most of events/properties. It also shows sample code how to create tabs at runtime. https://github.com/Alexey-T/ATTabs/tree/master/wiki

How to use it like TPageControl

Make some new panel, which will be like TPageControl. Place ATTabs on it, make Align=alTop. Now you create several Forms or Frames onto this panel (they have Parent:=Panel1; Align:=alClient;). How to switch these frames on changing tabs?

  • Add tabs OnChange event handler.
  • In this event handler: a) hide all frames, b) show frame, which is assigned to current TabIndex.

When you create a new tab, you can set its TabObject property. Set TabObject to a frame. When OnChange is called, get TabIndex, call GetTabData() for this index, and read TabObject for this tab. Show the frame, which is stored in this TabObject, hide all others.

  var
    d: TATTabData;
  begin
    d:= t.GetTabData(t.TabIndex);
    if Assigned(d) then
      (d.TabObject as TMyFrame).Show;
  end;

License

License: MPL 2.0. Also you can use it under LGPL.

Download

Latest version, with demo app, is always at https://github.com/Alexey-T/ATTabs

  • Download the zip file from Github using "Download zip" button.
  • No installation into Lazarus needed, just unpack file ATTabs.pas to any folder.

Requirements

Lazarus: 1.2.0+

Tested on: Win32 (Windows 7), Linux GTK2 or QT (Ubuntu 14.04), macOS (10.8).