Difference between revisions of "Lua:Class:PageControl"

From Cheat Engine
Jump to navigation Jump to search
m (Methods)
m (Returns)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''PageControl Class''': (Inheritence: ''[[WinControl]]'' > ''[[Control]]'' > ''[[Component]]'' > ''[[Object]]'')
+
{{Class|'''class''' Pagecontrol ''':''' WinControl}}
  
<span style="color:red; font-weight:bold; font-style:italic;">WARNING: This page is unfinished.</span>
+
The Pagecontrol class represents a control that can hold multiple pages.
  
== Description ==
+
Each page is represented by a [[Lua:Class:TabSheet|TabSheet]]. A Pagecontrol can be created with [[Lua:createPageControl|createPageControl]].
  
This is an tabbed interface that can hold multiple pages.
+
===Inheritance===
 +
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Class
 +
!align="left"|Inherits From
 +
!style="width: 80%;background-color:white;" align="left"|Description
 +
|-
 +
|Pagecontrol
 +
|WinControl
 +
|Represents a multi-page tab control.
 +
|-
 +
|WinControl
 +
|Control
 +
|Base class for controls that can receive focus and contain child controls.
 +
|-
 +
|Control
 +
|Component
 +
|Base class for visible GUI controls.
 +
|-
 +
|Component
 +
|Object
 +
|Base class for components.
 +
|-
 +
|Object
 +
|None
 +
|Base class for Lua-exposed objects.
 +
|}
  
 
== Creation ==
 
== Creation ==
  
; createPageControl(''owner'') &#58; ''PageControl''
+
{{CodeBox|'''function''' createPageControl(''owner'') ''':''' Pagecontrol}}
: Returns a newly created PageControl.
+
 
 +
Creates a Pagecontrol object that belongs to the given owner.
 +
 
 +
===Function Parameters===
 +
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Parameter
 +
!align="left"|Type
 +
!style="width: 80%;background-color:white;" align="left"|Description
 +
|-
 +
|owner
 +
|[[Lua:Class:WinControl|WinControl]]
 +
|The owner of the page control.
 +
|}
 +
 
 +
===Returns===
 +
[[Lua:Class:PageControl|PageControl]] — The created page control object.
  
 
== Properties ==
 
== Properties ==
  
; ShowTabs &#58; ''boolean''
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
: Tabs are shown if ''true'', hidden if ''false''.
+
!align="left"|Property
: Default: ''true''
+
!align="left"|Type
 +
!style="width: 80%;background-color:white;" align="left"|Description
 +
|-
 +
|ShowTabs
 +
|Boolean
 +
|Determines whether the tabs are shown.
 +
|-
 +
|TabIndex
 +
|Integer
 +
|Gets or sets the currently selected tab index.
 +
|-
 +
|ActivePage
 +
|[[Lua:Class:TabSheet|TabSheet]]
 +
|Returns the currently active tab sheet.
 +
|-
 +
|PageCount
 +
|Integer
 +
|Returns the number of pages.
 +
|-
 +
|Page[index]
 +
|[[Lua:Class:TabSheet|TabSheet]]
 +
|Returns the page at the specified index.
 +
|}
  
; TabPosition &#58; ''string''
+
== Methods ==
: Defines along which edge tabs are located.
 
: Options: ''tpTop'', ''tpBottom'', ''tpLeft'', ''tpRight''.
 
: Default: ''"tpTop"''
 
  
; TabIndex &#58; ''integer''
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
: Index of the currently selected tab (beginning at ''0'').
+
!align="left"|Method
: Default: ''0''
+
!align="left"|Return Type
 +
!style="width: 80%;background-color:white;" align="left"|Description
 +
|-
 +
|addTab()
 +
|[[Lua:Class:TabSheet|TabSheet]]
 +
|Creates a new TabSheet and adds it to the page control.
 +
|-
 +
|tabRect(index)
 +
|Rect
 +
|Returns a Rect table describing the position of the specified tab.
 +
|}
  
; TabOrder &#58; ''integer''
+
== Rect Table ==
: Default: ''0''
 
  
; TabStop &#58; ''boolean''
+
<code>tabRect(index)</code> returns a Rect table.
: Default: true
 
  
; ActivePage &#58; ''TabSheet''
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
: Contains the currently selected tab.
+
!align="left"|Field
 +
!align="left"|Type
 +
!style="width: 80%;background-color:white;" align="left"|Description
 +
|-
 +
|Left
 +
|Integer
 +
|The left coordinate of the tab rectangle.
 +
|-
 +
|Top
 +
|Integer
 +
|The top coordinate of the tab rectangle.
 +
|-
 +
|Right
 +
|Integer
 +
|The right coordinate of the tab rectangle.
 +
|-
 +
|Bottom
 +
|Integer
 +
|The bottom coordinate of the tab rectangle.
 +
|}
  
; PageCount &#58; ''integer''
+
== Examples ==
: The total number of pages.
 
  
; Page &#58; ''table''
+
===Create a Pagecontrol===
: Table of current TabSheets.
+
<syntaxhighlight lang="lua" line highlight="2">
 +
local form = createForm(false)
 +
local pageControl = createPageControl(form)
  
== Methods ==
+
pageControl.Left = 10
 +
pageControl.Top = 10
 +
pageControl.Width = 300
 +
pageControl.Height = 200
 +
 
 +
form.show()
 +
</syntaxhighlight>
 +
 
 +
===Add pages===
 +
<syntaxhighlight lang="lua" line highlight="2,4,7">
 +
local form = createForm(false)
 +
local pageControl = createPageControl(form)
 +
 
 +
local firstPage = pageControl.addTab()
 +
firstPage.Caption = "General"
 +
 
 +
local secondPage = pageControl.addTab()
 +
secondPage.Caption = "Advanced"
 +
 
 +
form.show()
 +
</syntaxhighlight>
 +
 
 +
===Select a tab by index===
 +
<syntaxhighlight lang="lua" line highlight="2,4,5,7">
 +
local form = createForm(false)
 +
local pageControl = createPageControl(form)
 +
 
 +
pageControl.addTab().Caption = "First"
 +
pageControl.addTab().Caption = "Second"
 +
 
 +
pageControl.TabIndex = 1
 +
 
 +
form.show()
 +
</syntaxhighlight>
 +
 
 +
===Read the active page===
 +
<syntaxhighlight lang="lua" line highlight="2,4,5,8">
 +
local form = createForm(false)
 +
local pageControl = createPageControl(form)
 +
 
 +
pageControl.addTab().Caption = "First"
 +
pageControl.addTab().Caption = "Second"
 +
 
 +
pageControl.TabIndex = 0
 +
local activePage = pageControl.ActivePage
 +
 
 +
print(activePage.Caption)
 +
 
 +
form.show()
 +
</syntaxhighlight>
 +
 
 +
===Hide the tabs===
 +
<syntaxhighlight lang="lua" line highlight="2,4">
 +
local form = createForm(false)
 +
local pageControl = createPageControl(form)
 +
 
 +
pageControl.ShowTabs = false
 +
 
 +
pageControl.addTab().Caption = "Hidden Tab"
 +
 
 +
form.show()
 +
</syntaxhighlight>
 +
 
 +
===Enumerate pages===
 +
<syntaxhighlight lang="lua" line highlight="2,4,5,7,8">
 +
local form = createForm(false)
 +
local pageControl = createPageControl(form)
 +
 
 +
pageControl.addTab().Caption = "Page A"
 +
pageControl.addTab().Caption = "Page B"
 +
 
 +
for i = 0, pageControl.PageCount - 1 do
 +
  local page = pageControl.Page[i]
 +
 
 +
  print(i .. ": " .. tostring(page.Caption))
 +
end
 +
 
 +
form.show()
 +
</syntaxhighlight>
 +
 
 +
===Add controls to a TabSheet===
 +
<syntaxhighlight lang="lua" line highlight="2,4,8">
 +
local form = createForm(false)
 +
local pageControl = createPageControl(form)
 +
 
 +
local page = pageControl.addTab()
 +
page.Caption = "Settings"
  
; addTab() &#58; ''TabSheet''
+
local label = createLabel(page)
: Creates & returns new TabSheet.
+
label.Caption = "This label belongs to the tab sheet"
 +
label.Left = 10
 +
label.Top = 10
  
; getPageCount() &#58; ''integer''
+
form.show()
: ''Not available?''
+
</syntaxhighlight>
  
; getPage()
+
===Get a tab rectangle===
: ''Not currently available?''
+
<syntaxhighlight lang="lua" line highlight="2,4,7">
 +
local form = createForm(false)
 +
local pageControl = createPageControl(form)
  
== Events ==
+
pageControl.addTab().Caption = "General"
  
; OnChange()
+
local rect = pageControl.tabRect(0)
: Action executed when selected tab changes.
 
  
; OnCloseTabClicked()
+
print("Left: " .. tostring(rect.Left))
: ''Not currently available?''
+
print("Top: " .. tostring(rect.Top))
 +
print("Right: " .. tostring(rect.Right))
 +
print("Bottom: " .. tostring(rect.Bottom))
  
== Examples ==
+
form.show()
 +
</syntaxhighlight>
  
<pre>
+
===Switch to the next tab===
-- main window
+
<syntaxhighlight lang="lua" line highlight="2,4,5,7,8,9">
local form = createForm()
+
local form = createForm(false)
 +
local pageControl = createPageControl(form)
  
-- create tabbed interface
+
pageControl.addTab().Caption = "First"
local tabs = createPageControl(form)
+
pageControl.addTab().Caption = "Second"
tabs.Align = alClient
 
  
-- add tabs
+
if pageControl.PageCount > 0 then
local tabMain = tabs.addTab()
+
  pageControl.TabIndex = (pageControl.TabIndex + 1) % pageControl.PageCount
tabMain.setCaption("Main")
+
end
local tabSec = tabs.addTab()
 
tabSec.setCaption("Secondary")
 
  
-- put tabs at bottom of interface
+
form.show()
tabs.TabPosition = "tpBottom"
+
</syntaxhighlight>
</pre>
 
  
 
{{LuaSeeAlso}}
 
{{LuaSeeAlso}}
  
=== Related Functions ===
+
{{Forms}}
* [[Lua:createPageControl|createPageControl]]
 
 
 
=== Related Classes ===
 
* [[Lua:Class:Panel|Panel]]
 
* [[Lua:Class:TabSheet|TabSheet]]
 

Latest revision as of 20:42, 26 June 2026

{} Class

class Pagecontrol : WinControl

The Pagecontrol class represents a control that can hold multiple pages.

Each page is represented by a TabSheet. A Pagecontrol can be created with createPageControl.

Inheritance[edit]

Class Inherits From Description
Pagecontrol WinControl Represents a multi-page tab control.
WinControl Control Base class for controls that can receive focus and contain child controls.
Control Component Base class for visible GUI controls.
Component Object Base class for components.
Object None Base class for Lua-exposed objects.

Creation[edit]

<> Lua API Reference

function createPageControl(owner) : Pagecontrol

Creates a Pagecontrol object that belongs to the given owner.

Function Parameters[edit]

Parameter Type Description
owner WinControl The owner of the page control.

Returns[edit]

PageControl — The created page control object.

Properties[edit]

Property Type Description
ShowTabs Boolean Determines whether the tabs are shown.
TabIndex Integer Gets or sets the currently selected tab index.
ActivePage TabSheet Returns the currently active tab sheet.
PageCount Integer Returns the number of pages.
Page[index] TabSheet Returns the page at the specified index.

Methods[edit]

Method Return Type Description
addTab() TabSheet Creates a new TabSheet and adds it to the page control.
tabRect(index) Rect Returns a Rect table describing the position of the specified tab.

Rect Table[edit]

tabRect(index) returns a Rect table.

Field Type Description
Left Integer The left coordinate of the tab rectangle.
Top Integer The top coordinate of the tab rectangle.
Right Integer The right coordinate of the tab rectangle.
Bottom Integer The bottom coordinate of the tab rectangle.

Examples[edit]

Create a Pagecontrol[edit]

1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3 
4 pageControl.Left = 10
5 pageControl.Top = 10
6 pageControl.Width = 300
7 pageControl.Height = 200
8 
9 form.show()

Add pages[edit]

 1 local form = createForm(false)
 2 local pageControl = createPageControl(form)
 3 
 4 local firstPage = pageControl.addTab()
 5 firstPage.Caption = "General"
 6 
 7 local secondPage = pageControl.addTab()
 8 secondPage.Caption = "Advanced"
 9 
10 form.show()

Select a tab by index[edit]

1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3 
4 pageControl.addTab().Caption = "First"
5 pageControl.addTab().Caption = "Second"
6 
7 pageControl.TabIndex = 1
8 
9 form.show()

Read the active page[edit]

 1 local form = createForm(false)
 2 local pageControl = createPageControl(form)
 3 
 4 pageControl.addTab().Caption = "First"
 5 pageControl.addTab().Caption = "Second"
 6 
 7 pageControl.TabIndex = 0
 8 local activePage = pageControl.ActivePage
 9 
10 print(activePage.Caption)
11 
12 form.show()

Hide the tabs[edit]

1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3 
4 pageControl.ShowTabs = false
5 
6 pageControl.addTab().Caption = "Hidden Tab"
7 
8 form.show()

Enumerate pages[edit]

 1 local form = createForm(false)
 2 local pageControl = createPageControl(form)
 3 
 4 pageControl.addTab().Caption = "Page A"
 5 pageControl.addTab().Caption = "Page B"
 6 
 7 for i = 0, pageControl.PageCount - 1 do
 8   local page = pageControl.Page[i]
 9 
10   print(i .. ": " .. tostring(page.Caption))
11 end
12 
13 form.show()

Add controls to a TabSheet[edit]

 1 local form = createForm(false)
 2 local pageControl = createPageControl(form)
 3 
 4 local page = pageControl.addTab()
 5 page.Caption = "Settings"
 6 
 7 local label = createLabel(page)
 8 label.Caption = "This label belongs to the tab sheet"
 9 label.Left = 10
10 label.Top = 10
11 
12 form.show()

Get a tab rectangle[edit]

 1 local form = createForm(false)
 2 local pageControl = createPageControl(form)
 3 
 4 pageControl.addTab().Caption = "General"
 5 
 6 local rect = pageControl.tabRect(0)
 7 
 8 print("Left: " .. tostring(rect.Left))
 9 print("Top: " .. tostring(rect.Top))
10 print("Right: " .. tostring(rect.Right))
11 print("Bottom: " .. tostring(rect.Bottom))
12 
13 form.show()

Switch to the next tab[edit]

 1 local form = createForm(false)
 2 local pageControl = createPageControl(form)
 3 
 4 pageControl.addTab().Caption = "First"
 5 pageControl.addTab().Caption = "Second"
 6 
 7 if pageControl.PageCount > 0 then
 8   pageControl.TabIndex = (pageControl.TabIndex + 1) % pageControl.PageCount
 9 end
10 
11 form.show()

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Form Related Classes