AutoHotkey Community

It is currently May 26th, 2012, 9:01 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: September 23rd, 2007, 5:09 pm 
Offline

Joined: September 23rd, 2007, 4:16 pm
Posts: 140
This is a fully functional table layout manager. It is similar to GridBagLayout in Java or the <table> tag in HTML. It supports both horizontal and vertical alignment of controls in their cell, option to resize a control to the width, height, or both of its cell, spacing between cell, padding between cell edges and control edges as well as rowSpan and ColSpan to have a control span multiple "grid cells" in the table. A cell may be left empty or multiple overlapping controls can be placed in the same cell with the "n" option.

Usage and examples are provided in the AHK file.

Download: TableLayout.ahk

Changes:
  • Fixed bug where expanding a cell that spanned over a zero width/height column/row would not expand the cell to it's needed width or height.
  • Added more padding options. t# for top padding, b# for bottom padding, l# for left padding, e# for right padding (e is for east, r# is already taken by rowSpan). The previous p# can be used to specify a single padding for all directions, but if t# b# l# or e# is encountered, that value will be used in preference to p# for the specified direction.
  • Added f# option which is used in conjunction with w# and h#. Allows a cell's width or height to be specified without expanding the control within the cell to be resized to the cell size.


Last edited by Xander on September 29th, 2007, 5:19 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 27th, 2007, 7:33 pm 
Offline

Joined: September 23rd, 2007, 4:16 pm
Posts: 140
The following is an addon that will layout all the controls for a Tab control.

Code requires the TableLayout function linked above as well as List functions included here:
List.ahk

A simple example is provided in the code.

Code:
#Include List.ahk
#Include TableLayout.ahk

/*  Usage:
 *     Layout controls in a Tab control with TableLayout
 *
 *  Parameters:
 *     ctrls: A list of all controls, with the Tab control being the first in the list.
 *     ctrlCounts: Comma delimited list of the number of tabs in each control.
 *     rules: Comma delimited list of rules. The first rule in the list will be the default for all tabs.
 *        The second rule corresponds to the first tab.
 *        Only provide one set of rules (the default) if all tabs are to use the same rules.
 *     spacing, marginX, marginY, w, h: See TableLayout
 * 
 *  Example:
 *     Gui, +LastFound
 *     margin = 3
 *     Gui, Margin, %margin%, %margin%
 *     Gui, Add, Tab, , One|Two
 *     Gui, Tab, 1
 *     Gui, Add, Edit
 *     Gui, Add, Edit
 *     Gui, Add, Edit
 *     Gui, Add, Edit
 *     Gui, Add, Edit
 *     Gui, Tab, 2
 *     Gui, Add, Text, , One
 *     Gui, Add, Text, , Two
 *     Gui, Add, Text, , Three
 *     Gui, Add, Edit
 *     Gui, Add, Edit
 *     Gui, Add, Edit
 *     WinGet, ctrls, ControlList
 *     TabTableLayout(ctrls, "5,6", ",w100 h1 r2|w100_w100_w1 c2,a1|a1|a1_w200 c2|w100_w1 c3", 5, 5, 5, w, h)
 *     w += margin * 2
 *     h += margin * 2
 *     Gui, Show, w%w% h%h%
 */
TabTableLayout(ByRef ctrls, ctrlCounts, rules, spacing, marginX, marginY, ByRef w = "", ByRef h = "") {
   tab := ListGet(ctrls, 0, "`n")
   index := 1
   rDefault := ListGet(rules, 0)
   rSize := ListSize(rules)
   w := h := 0
   GuiControlGet, tabPos, Pos, %tab%
   Loop, Parse, ctrlCounts, `,
   {
      j := index
      tabCtrls := ListSegment(ctrls, j, index += A_LoopField, "`n")
      tabRules := A_Index < rSize ? ListGet(rules, A_Index) : ""
      tabW := tabH := ""
      TableLayout(tabCtrls, tabRules ? tabRules : rDefault, spacing, marginX, marginY, x, y, tabW, tabH)
      if (tabW > w)
         w := tabW
      if (tabH > h)
         h := tabH
   }
   x -= tabPosX
   y -= tabPosY
   w += x
   h += y
   GuiControl, Move, %tab%, w%w% h%h%
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject: table fixed columns
PostPosted: June 6th, 2008, 8:29 am 
Offline

Joined: March 18th, 2008, 4:04 am
Posts: 193
Hi xander,
I still didn't dived in, to see your table elements but just for more info:

1. is it possible to define 'fixed columns' means:
on scroll left-right the specific signed columns will not move ?

2. Treeview
I saw in the docs, , that it possible to define treeview elements
can we combine these treeview visual elenets in your table ?

3. style elemnts
does the style properies paralel more or less to html settings ?

3. scrolling 'row' cells
is it possible to define per row cells that are located in more then one 'line' ?

any info will be appreciated.

if these GUI elemnts are 'real working' ,means you actually by-passed all the developer environments (JS,MS Studio...,and other)

rgrds
ell


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 6th, 2008, 10:29 am 
Impressive! Needs some screenshots.

8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 6th, 2008, 10:45 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Thank you Xander.
Maybe some short tutorial would be nice to have.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2008, 3:19 pm 
n-l-i-d wrote:
Impressive! Needs some screenshots.

...yes, but remember to always check the post dates...(I never remember either)...

Xander wrote:
Posted: Sun Sep 23, 2007 5:09 pm

...so, however cool, this has been rotting in the forum for almost a year...(thx ell for bumping it!)...amazing how things are never noticed at 1st huh? Also, shockingly, minus the "table" element, this is similar to something I've wanted to do...(but of course mine could have a table option/mode)...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 7th, 2008, 4:23 pm 
Zomg. Well, apparently another good one slipped by unnoticed at the time.

:(


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 10th, 2008, 2:14 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Here is documentation for this function and modified include file with correct ndoc format.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject: freeze columns
PostPosted: July 11th, 2008, 7:48 pm 
Offline

Joined: March 18th, 2008, 4:04 am
Posts: 193
table layout

what is the command or property to make freeze column or first columns 1-n ?
this propery is neccary when scrolling left-right,
and we need to remain the columns we decide to 'hold' from scrolling

rgrds
Ell


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Stigg, tomoe_uehara and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group