s c h e m a t i c s : c o o k b o o k

/ Cookbook.GUIWidgetAggregation

This Web


WebHome 
WebChanges 
TOC (with recipes)
NewRecipe 
WebTopicList 
WebStatistics 

Other Webs


Chicken
Cookbook
Erlang
Know
Main
Plugins
Sandbox
Scm
TWiki  

Schematics


Schematics Home
Sourceforge Page
SchemeWiki.org
Original Cookbook
RSS

Scheme Links


Schemers.org
Scheme FAQ
R5RS
SRFIs
Scheme Cross Reference
PLT Scheme SISC
Scheme48 SCM
MIT Scheme scsh
JScheme Kawa
Chicken Guile
Bigloo Tiny
Gambit LispMe
GaucheChez

Lambda the Ultimate
TWiki.org

Aggregating Widgets in a Single Widget

Problem

You would like to deal with many widgets as though they were a single widget.

Solution

500 Can't connect to 127.0.0.1:8778 (connect: Connection refused)

Discussion

GUI programming is non-standard. A PLT Solution has been given.

When designing a GUI, it is common to design widget groups that are reused. This is done by creating a subclass of the panel type and defining the widgets in that class.

The above sample displays a push button with the label "Push Me" above a Text Box with the label "Enter Text". Both widgets will be center justified and the enclosing window is as small as it can be while still showing the widgets in full.

The first thing to do when using MrEd and the PLT class library is to import the modules:

500 Can't connect to 127.0.0.1:8778 (connect: Connection refused)

Then, we would like to define a class and bind it to a name. It is customary in MrEd to suffix widgets with a % and interfaces with a <%>. This will be a subclass of the panel:single% widget which will provide layout geometry for child widgets. It will not implement any interface so we will give it an empty list for the interface-expression.

500 Can't connect to 127.0.0.1:8778 (connect: Connection refused)

Since panel widgets cannot be top level windows (frames in the MrEd and wxWidget nomenclature), we must give this widget a parent that must be set on instantiation. This is done with the init-field expression:

500 Can't connect to 127.0.0.1:8778 (connect: Connection refused)

If we wanted, we could set it to an initial value much the same way we set initial values in a let expression.

The next step is to define the widgets. This is quite straight forward: 500 Can't connect to 127.0.0.1:8778 (connect: Connection refused)

The final part is to initialize the superclass. As we mentioned before, panels cannot be top level windows, so they must have parents. That means we need to pass the parent parameter to the super-instantiate expression: 500 Can't connect to 127.0.0.1:8778 (connect: Connection refused)

Don't worry that the parent expression has the same name as the parameter. The values are resolved by position in the expression as well as name, so Scheme won't be confused.

Constructing and showing the window are straight forward: 500 Can't connect to 127.0.0.1:8778 (connect: Connection refused)


Comments about this recipe

If you meant for the widget to be a panel grouping the button and the text field, then the code for the above class should be:

500 Can't connect to 127.0.0.1:8778 (connect: Connection refused)

-- DanielSilva - 03 Jul 2005

Whats the difference?

-- StephenDeGabrielle - 21 Sep 2007

Here is another example - but but the widget is created from drawing toolkit elements, rather than existing widgets.

500 Can't connect to 127.0.0.1:8778 (connect: Connection refused)

-- StephenDeGabrielle - 21 Sep 2007

Contributors

-- EwanHiggs - 01 Sep 2004

CookbookForm
TopicType: Recipe
ParentTopic: GUIRecipes
TopicOrder: 030

 
 
Copyright © 2004 by the contributing authors. All material on the Schematics Cookbook web site is the property of the contributing authors.
The copyright for certain compilations of material taken from this website is held by the SchematicsEditorsGroup - see ContributorAgreement & LGPL.
Other than such compilations, this material can be redistributed and/or modified under the terms of the GNU Lesser General Public License (LGPL), version 2.1, as published by the Free Software Foundation.
Ideas, requests, problems regarding Schematics Cookbook? Send feedback.
/ You are Main.guest