[plt-scheme] On MRED questions

From: Robby Findler (robby at cs.uchicago.edu)
Date: Wed Oct 22 07:21:59 EDT 2008

On Wed, Oct 22, 2008 at 3:03 AM, eko hermiyanto
<eko.hermiyanto at gmail.com> wrote:
> Dear PLT Schemers,
> 1. In DRScheme, there are four buttons which so beautiful; debug
> button, check syntax button, run button, and stop button. I am not
> quite sure whether they are button% because there is no such style for
> button. Are they in fact just merely button% or are they other widget?
> Or perhaps, they are button% but using techniques which are explained
> on drawing and editor toolbox sections on the MRED manual? I am very
> sorry because it is my second days of my MRED learning, and I am not
> yet read those sections of the manual.

They are not button% objects. They are switchable-button% objects
(which uses canvas% and do all the drawing at the Scheme level).

> 2. Below menubar, there are two choice-like widgets. But, they are
> more beautiful than choice%. What is the name of the widget?

They use name-message%.

> 3. Is there any standard icon in DRScheme which I can use? For example
> a floppy disk icon to be used on a button with the purpose to save a
> file.

The icons drscheme use are in plt/collects/icons/. See
plt/collects/drscheme/private/unit.ss, the definition of save-bitmap
for how they are used.

> 4. How to create horizontal line in frame? For example I want to make
> a frame, the top one for viewing a given data, and the bottom one to
> edit the data. And I want to create separation line between them, is
> it possible? I have tried to emulate such line using message% with
> label "----" but the result is extremelly ugly.

The editor-canvas% object already has a builtin line around its edge.
Is that enough? If not, you probably are going to have to use canvas%
and make up your own drawing procedure.

> 5. For example, I want to create several text-field% vertically in the
> same vertical panel. Because the labels of those text-field% are
> different in length, the field of those text-field% are not vertically
> in line. I have tried to emulate with giving more spaces on the
> labels, and so far, it is work good enough. Nevertheless, is there a
> way to do that without giving more spaces on the label?

The easiest way is to use message% objects instead of the text-field%s
label and then figure out the width of the widest one and then set all
of their widths to the width of the widest one. You will want to use
the reflow-container method and do this computation before calling the
show method of the frame.

> 6. I want to create a message% with bold label. I know I must create
> font% object in order to manipulate the label to be bold. I have tried
> to create the font% object with instantiate and make-object, but, both
> of them failed.
> My failed definitions are:
> (define bold-message-font-object (make-object font% () (size 12)
> (family '(default)) (style '(normal)) (weight '(bold))))
> and
> (define bold-message-font-object (make-object font% (size 12) (family
> '(default)) (style '(normal)) (weight '(bold))))
> and
> (define bold-message-font-object (instantiate font% () (size 12)
> (family '(default)) (style '(normal)) (weight '(bold))))

#lang scheme/gui
(define f (new frame% [label ""]))
(define msg
  (new message%
       [label "A bold message"]
       [parent f]
       [font (send the-font-list
                   (send normal-control-font get-point-size)
                   (send normal-control-font get-family)
                   (send normal-control-font get-style)
                   (send normal-control-font get-underlined)
                   (send normal-control-font get-smoothing))]))
(define gb (new grow-box-spacer-pane% [parent f]))
(send f show #t)

> 7. As far as I read on MRED manual, there is no table widget. Is there
> any standard way to emulate such widget? For example, I have created a
> program to record books(well, I am quite a good book reader, you
> know). When I want to search all of my books with certain criteria, I
> think it is quite useful if I could represent the result with the
> following order:
> books name | Author | ISDN | Publisher | printed on year

No, sorry. For now, you have to simulate that using the widths
technique I suggest above, or if you want something more
sophisticated, you're back to the very low-level canvas%.

> By the way, How to design program is very great and beautiful literary
> work. My brother and I enjoy it very much as we enjoy Victor Hugo's
> Les Miserables. Even, HTDP is easier to understand than many
> discourses in Les Miserables(with part on Generative Recursion as the
> only exception).

A great pairing! :)


Posted on the users mailing list.