GRIDPLUS - Window | ![]() |
||||||
|
GRIDPLUS Toplevel Windows |
In order to simplify creation of screen layouts, GRIDPLUS provides a GRIDPLUS window command mode.
Example |
This section contains an example which illustrates the main GRIDPLUS Groups facility features.
The following example assumes that the reader is familiar with the contents of the Grid/Layout page. Information given on that page will not be duplicated here.
Note: The example assumes that the GRIDPLUS package has already been "required" and the commands imported.
Window:
When the "Display Child Window" button is pressed the following toplevel (child)
window is also displayed:-
Note: If the "Child Window/Modal?/Yes" radiobutton is selected a modal toplevel
window is created.
Source Code:
Comments:
The procedure named in the -deletewindow option
is executed when the child window receives a "WM_DELETE_WINDOW" event, which occurs
when the window is closed. It is strongly recommended that this option be used, and that
it references a procedure which calls "gridplus clear" for the toplevel window. This
will ensure that the necessary housekeeping (clearing values in the null array etc.) are performed.
The "gridplus window" command returns "1" if the window already exists, otherwise
it returns "0". The "if" check in this example skips the rest of this procedure
if the window already exists.
Note: If the window already exists the -deletewindow
option is still actioned. This allows this command to set a deletewindow
procedure for the root (parent) window.
Example: gridplus window . -deletewindow myproc
Note: The GRIDPLUS Grid/Layout names are prefixed with the name of the toplevel window.
The values of the two entry fields will be in the null array as
".child.data,field1" and ".child.data,field2" respectively.
This procedure uses the clear command mode to make sure that all
references to the ".child" window are cleared from GRIDPLUS.
Window Example
#======================#
# Display Child Window #
#======================#
proc action,display_child {} {
global {}
if {! [gridplus window .child -modal $(.modal) -deletewindow child:action,close]} {
return
}
gridplus grid .child.text -pad 30 -relief groove {
{"^This Is The Child Window"}
}
gridplus entry .child.data -size 20 {
{"Field One " .field1}
{"Field Two " .field2}
}
gridplus button .child.action {
{"Close Child Window" .close 25}
}
gridplus layout .child.main -title "Child Window" {
.child.text
.child.data:c
.child.action:c
}
pack .child.main
}
#====================#
# Close Child Window #
#====================#
proc child:action,close {} {
gridplus clear .child
destroy .child
}
#==============================#
# Display Main (Parent) Window #
#==============================#
gridplus grid .text -pad 30 -relief groove {
{"^This Is The Parent Window"}
}
gridplus button .action {
{"Display Child Window" .display_child 25}
}
gridplus radiobutton .modal -title "Child Window" {
{"^Modal?"} {.no "No" +0} {.yes "Yes" -1}
}
gridplus layout .main -title "Parent Window" {
.text
.modal:c
.action:c
}
pack .main
#======================#
# Display Child Window #
#======================#
proc action,display_child {} {
global {}
if {! [gridplus window .child -modal $(.modal) -deletewindow child:action,close]} {
return
}
gridplus grid .child.text -pad 30 -relief groove {
{"^This Is The Child Window"}
}
gridplus entry .child.data -size 20 {
{"Field One " .field1}
{"Field Two " .field2}
}
gridplus button .child.action {
{"Close Child Window" .close 25}
}
gridplus layout .child.main -title "Child Window" {
.child.text
.child.data:c
.child.action:c
}
pack .child.main
}
#====================#
# Close Child Window #
#====================#
proc child:action,close {} {
gridplus clear .child
destroy .child
}
#==============================#
# Display Root (Parent) Window #
#==============================#
gridplus grid .text -pad 30 -relief groove {
{"^This Is The Parent Window"}
}
gridplus button .action {
{"Display Child Window" .display_child 25}
}
gridplus radiobutton .modal -title "Child Window" {
{"^Modal?"} {.no "No" +0} {.yes "Yes" -1}
}
gridplus layout .main -title "Parent Window" {
.text
.modal:c
.action:c
}
pack .main
Copyright © 2004 Adrian Davis.