Difference between revisions of "ATTabs"

From Free Pascal wiki
Jump to navigationJump to search
(history link)
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{ATTabs}}
 
{{ATTabs}}
  
= About =
+
== 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.
 
''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.
Line 11: Line 11:
 
Author: Alexey Torgashin
 
Author: Alexey Torgashin
  
= How to use it like TPageControl=
+
== History ==
  
Make some new panel, which will be like TPageControl. Place ATTabs on it, make Align=alTop.
+
GitHub repo has the [https://github.com/Alexey-T/ATFlatControls/blob/master/history.txt history.txt file] which lists all major changes.
Now you create several Forms or Frames onto this panel (they will have Parent:=Panel1).
 
How to switch these frames on changing tabs?
 
  
= License =
+
== Requirements ==
  
License: MPL 2.0.
+
* Lazarus: 1.8+.
Also if your project needs it, you can use it under LGPL.
+
* Tested on: Windows, Linux GTK2/Qt, macOS.
  
= Download =
+
== How to use it like TPageControl ==
  
Latest version, with demo app, is always at https://github.com/Alexey-T/ATTabs
+
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;).
* Download the zip file from Github using "Download zip" button.
+
How to switch these frames on changing tabs?
* No installation into Lazarus needed, just unpack file ATTabs.pas to any folder.
 
  
= Requirements =
+
* Add tabs OnChange event handler.
 +
* In this event handler: a) hide all frames, b) show frame, which is assigned to current TabIndex.
  
Lazarus: 1.2.0+
+
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.
  
Tested on: Win32 (Windows 7), Linux GTK2 or QT (Ubuntu 14.04), macOS (10.8).
+
<syntaxhighlight lang="Pascal">
 +
  var
 +
    d: TATTabData;
 +
  begin
 +
    d:= t.GetTabData(t.TabIndex);
 +
    if Assigned(d) then
 +
      (d.TabObject as TMyFrame).Show;
 +
  end;
 +
</syntaxhighlight>
  
= Usage =
+
== License ==
  
Component doesn't support Lazarus designer, you need to create TATTabs objects at runtime.
+
License: MPL 2.0. Also you can use it under LGPL.
See API documentation at "Wiki" page of Github page.
 
  
 +
== Download ==
  
[[Category:Components]]
+
ATTabs is merged into ATFlatControls repo: https://github.com/Alexey-T/ATFlatControls/ .
 +
Some wiki documentation is in the "wiki" subfolder of that repo.

Latest revision as of 17:10, 26 March 2021

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

History

GitHub repo has the history.txt file which lists all major changes.

Requirements

  • Lazarus: 1.8+.
  • Tested on: Windows, Linux GTK2/Qt, macOS.

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

ATTabs is merged into ATFlatControls repo: https://github.com/Alexey-T/ATFlatControls/ . Some wiki documentation is in the "wiki" subfolder of that repo.