Back: BLOX.BContainer-accessing Up: BLOX package Forward: BLOX.BDialog class-instance creation   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document

1.11 BLOX.BDialog

Defined in namespace BLOX
Superclass: BLOX.BForm
Category: Graphics-Windows
I am a facility for implementing dialogs with many possible choices and requests. In addition I provide support for a few platform native common dialog boxes, such as choose-a-file and choose-a-color.

1.11.1 BLOX.BDialog class: instance creation  (class)
1.11.2 BLOX.BDialog class: prompters  (class)
1.11.3 BLOX.BDialog: accessing  (instance)
1.11.4 BLOX.BDialog: widget protocol  (instance)


1.11.1 BLOX.BDialog class: instance creation

new: parent
Answer a new dialog handler (containing a label widget and some button widgets) laid out within the given parent window. The label widget, when it is created, is empty.

new: parent label: aLabel
Answer a new dialog handler (containing a label widget and some button widgets) laid out within the given parent window. The label widget, when it is created, contains aLabel.

new: parent label: aLabel prompt: aString
Answer a new dialog handler (containing a label widget, some button widgets, and an edit window showing aString by default) laid out within the given parent window. The label widget, when it is created, contains aLabel.


1.11.2 BLOX.BDialog class: prompters

chooseColor: parent label: aLabel default: color
Prompt for a color. The dialog box is created with the given parent window and with aLabel as its title bar text, and initially it selects the color given in the color parameter.

If the dialog box is canceled, nil is answered, else the selected color is returned as a String with its RGB value.

chooseFileToOpen: parent label: aLabel default: name defaultExtension: ext types: typeList
Pop up a dialog box for the user to select a file to open. Its purpose is for the user to select an existing file only. If the user enters an non-existent file, the dialog box gives the user an error prompt and requires the user to give an alternative selection or to cancel the selection. If an application allows the user to create new files, it should do so by providing a separate New menu command.

If the dialog box is canceled, nil is answered, else the selected file name is returned as a String.

The dialog box is created with the given parent window and with aLabel as its title bar text. The name parameter indicates which file is initially selected, and the default extension specifies a string that will be appended to the filename if the user enters a filename without an extension.

The typeList parameter is an array of arrays, like #(('Text files' '.txt' '.diz') ('Smalltalk files' '.st')), and is used to construct a listbox of file types. When the user chooses a file type in the listbox, only the files of that type are listed. Each item in the array contains a list of strings: the first one is the name of the file type described by a particular file pattern, and is the text string that appears in the File types listbox, while the other ones are the possible extensions that belong to this particular file type.

chooseFileToSave: parent label: aLabel default: name defaultExtension: ext types: typeList
Pop up a dialog box for the user to select a file to save; this differs from the file open dialog box in that non-existent file names are accepted and existing file names trigger a confirmation dialog box, asking the user whether the file should be overwritten or not.

If the dialog box is canceled, nil is answered, else the selected file name is returned as a String.

The dialog box is created with the given parent window and with aLabel as its title bar text. The name parameter indicates which file is initially selected, and the default extension specifies a string that will be appended to the filename if the user enters a filename without an extension.

The typeList parameter is an array of arrays, like #(('Text files' '.txt' '.diz') ('Smalltalk files' '.st')), and is used to construct a listbox of file types. When the user chooses a file type in the listbox, only the files of that type are listed. Each item in the array contains a list of strings: the first one is the name of the file type described by a particular file pattern, and is the text string that appears in the File types listbox, while the other ones are the possible extensions that belong to this particular file type.


1.11.3 BLOX.BDialog: accessing

addButton: aLabel receiver: anObject index: anInt
Add a button to the dialog box that, when clicked, will cause the #dispatch: method to be triggered in anObject, passing anInt as the argument of the callback. The caption of the button is set to aLabel.

addButton: aLabel receiver: anObject message: aSymbol
Add a button to the dialog box that, when clicked, will cause the aSymbol unary selector to be sent to anObject. The caption of the button is set to aLabel.

addButton: aLabel receiver: anObject message: aSymbol argument: arg
Add a button to the dialog box that, when clicked, will cause the aSymbol one-argument selector to be sent to anObject, passing arg as the argument of the callback. The caption of the button is set to aLabel.

contents
Answer the text that is displayed in the entry widget associated to the dialog box.

contents: newText
Display newText in the entry widget associated to the dialog box.


1.11.4 BLOX.BDialog: widget protocol

center
Center the dialog box's parent window in the screen

centerIn: view
Center the dialog box's parent window in the given widget

destroyed
Private - The receiver has been destroyed, clear the corresponding Tcl variable to avoid memory leaks.

invokeCallback: index
Generate a synthetic callback corresponding to the index-th button being pressed, and destroy the parent window (triggering its callback if one was established).

loop
Map the parent window modally. In other words, an event loop is started that ends only after the window has been destroyed. For more information on the treatment of events for modal windows, refer to BWindow>>#modalMap.



Back: BLOX.BDialog-accessing Up: BLOX.BDialog Forward: BLOX.BDropDown   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document


This document was generated on July, 23 2009 using texi2html