KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

KiXforms 2.3.0 R.C. 2 Tips and Tricks

 
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon May 03, 2004 1:08 pm    Post subject: KiXforms 2.3.0 R.C. 2 Tips and Tricks Reply with quote

Lots of new stuff in the latest release. Kixforms now sports Treeviews and Splitters and an important new docking framework. TreeViews im sure you are all familiar with. Splitters are those invisible handles that usually can be found between TreeViews and ListViews, that you can click and drag to dynamicall resize the controls relative to one another. And the new docking framework allows controls to be easily positioned with the form, relative to one another ...

Having said that, lets talk about docking and splitters. When you dock a control, you are basically "moving" and "resizing" it to a location relative to its parent container (form) in one statement. The supported Dock values are

1 = Top
2 = Bottom
3 = Left
4 = Right
5 = Fill

So - if you dock (for example) a GroupBox to the TOP of your form, the GroupBox will automatically "shift" to the top of the form, and increase in size to fit the form fully from left to right. The HEIGHT of the control will remain the same. If you dock a control to the LEFT of a form, the control will move flush with the left for the form, and increase in size to fit the form from top to bottom - the WIDTH of the control will remain the same. If a control is already docked to the side of the form, the control being docked will nuzzle itself NEXT to the other control. Docking a control as FILL means "use whatever space is left-over and fill that.

I really like docking and think its a very intuitive and quick way to layout a form. But it does take some getting used to. Now - the dock property should only be used to initially create a form, there is very little support for moving and resizing controls (via the script) that are already docked. This will come in a latter release. Docked controls are however tied-in to the over-all form resizing framework.

Splitters are those familiar resizing handles that you can grab with the mouse, to resize controls embedded within a container (like a form) - like when you resize the TreeView and ListView in Windows Explorer. Splitters work hand-in-hand with docking, in fact - splitters must be docked to a control for the resizing to work. A new splitter - when its first created - is initially docked to the LEFT. You can adjust the docking afterwards. If you dock a splitter to the LEFT or RIGHT, the splitter automatically becomes a VERTICAL splitter. If you dock a splitter to the TOP or BOTTOM, the splitter automatically changes into a HORIZONTAL splitter. You can have as many splitters in your form, docked to as many controls as you want. Some of the permutations can be quite amusing. As the splitter moves, depending on how its docked, it will resize the control its attached to on one side, and it will shift all the other controls on the other side.

Best thing to do to describe docking and splitting is by example, lets say you wanted to build a GUI like the MMC snapin window. When laying-out the form, I find it best to work from the outside inward, so start with the absolute outer controls (the toolbar and statusbar) which docks fully at the top and bottom respectively, the dock the treeview to the right, then fill the remaining space with a listview. I added a single TreeNode to the listview, just like in the real MMC, but will be talking about TreeViews seperately.

Heres the code for a MMC look-alike. Looks very different than what you may be accustomed to but (imho) its short, sweet, intuitive and to-the-point:

Code:

Break On

$System = CreateObject("Kixtart.System")

$Form = $System.Form()
$Form.Size = 640,480
$Form.Center()
$Form.Font = $System.Font("Courier New",10)

$Toolbar = $Form.GroupBox()
$Toolbar.Height = 30
$Toolbar.Dock = 1

$StatusBar = $Form.GroupBox()
$StatusBar.Height = 20
$StatusBar.Dock = 2

$TreeView = $Form.TreeView()
$TreeView.Dock = 3
$TreeView.ImageList = $System.BuiltinImageList
$TreeView.ShowRootLines = 0

$Splitter = $Form.Splitter()
$Splitter.Dock = 3

$ListView = $Form.ListView()
$ListView.Dock = 5
$NameColumn = $ListView.Columns.Add("Name")

$RootNode = $TreeView.Nodes.Add("Console Root",45,46)

$Form.Show
While $Form.Visible
 $=Execute($System.Application.DoEvents)
Loop

Exit 1


-Shawn
Back to top
View user's profile Send private message
Stevie
KiXforms Supporter
KiXforms Supporter


Joined: 04 Jun 2003
Posts: 109

PostPosted: Mon May 03, 2004 1:54 pm    Post subject: No Docking Reply with quote

0 = No Docking?
-Or-
If you don't want to use docking then don't use the Dock property?
________
Michigan Dispensaries


Last edited by Stevie on Fri Feb 18, 2011 8:52 am; edited 1 time in total
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon May 03, 2004 3:49 pm    Post subject: Reply with quote

ja, if you dont want to use docking then dont use docking ... nothing else is effected by it - the form is only aware of docking if and when you use it - pre-existing scripts won't be effected in anyway. having said that, I wouldn't bend over backwards to convert existing scripts to docking - but it does make writing new scripts a joy.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon May 03, 2004 3:59 pm    Post subject: Reply with quote

Here's an amusing script:

Code:

Break On

$System = CreateObject("Kixtart.System")

$Form = Form()

$Form.Show
While $Form.Visible
 $=Execute($System.Application.DoEvents)
Loop

Exit 1

Function Form()

 dim $this, $button, $splitter, $dock, $rtb

 $this = $System.Form()
 $this.Size = 640,480
 $this.Center

 $dock = 1

 for $i = 0 to 20
  $button = $this.Controls.Button()
  $button.Text = $button.Name
  $button.Width = 20
  $button.Height = 20
  $button.Dock = $dock
  $splitter = $this.Controls.Splitter()
  $splitter.Dock = $dock
  $dock = $dock + 1
  if $dock = 5
   $dock = 1
  endif
 next

 $rtb = $this.Controls.RichTextBox()
 $rtb.Dock = 5
 $rtb.BackColor = "BurlyWood"
 $rtb.Html = "<br><br><center><h1>Whats up Dock ?!</h1>"+
   "<br><h2><font color=IndianRed>Splitters on Steroids</font></h2></center>"

 $form = $this

EndFunction


-Shawn
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group