TIP #213: A Standard Dialog for Font Selection


TIP:213
Title:A Standard Dialog for Font Selection
Version:$Revision: 1.7 $
Authors: Donal K. Fellows <donal dot k dot fellows at man dot ac dot uk>
Pat Thoyts <patthoyts at users dot sourceforge dot net>
State:Withdrawn
Type:Project
Tcl-Version:8.6
Vote:Pending
Created:Saturday, 21 August 2004
Obsoleted-By:TIP #324
Keywords:Tk

Abstract

This TIP proposes a new command that pops up a dialog box that allows the selection of a font. Where possible, this dialog will be implemented using the host platform's standard dialogs.

Rationale

A number of platforms (Windows and MacOSX) have standard dialogs for common user-oriented tasks, and Tk provides an interface to these dialogs through commands such as tk_getOpenFile and tk_chooseColor. However, another dialog that they provide and which some programs would find useful is a font selector. This TIP proposes adding a command to do just that; where a platform does not provide such a standard dialog, one implemented using a Tcl script will be used instead.

Proposed Change

Tk shall have a new command, tk_chooseFont, with the syntax described below (which should be recognizably similar to tk_chooseColor). The dialog will not return a result as on some platforms (MacOSX) this is required to be modeless while on others (Windows) it must be modal. Therefore all actions will be done via an -apply command. In the modal case clicking either the Apply button (if present) or the OK button will cause the -apply command to be called with the font specification appended as an additional argument. If Cancel is chosen then this is not called. For the modeless (MacOSX) case calling the tk_chooseFont command will cause the dialog to be displayed and closing the dialog will just withdraw it.

tk_chooseFont ?-option value -option value ...?

Permitted options are:

-parent

This specifies the parent window of the dialog (similarly to the -parent option to other dialogs).

-title

This specifies the title of the dialog. If the platform specific dialog cannot support this then the option is ignored.

-initialfont

This specifies the initial font in any form given on the font(n) manual page (section "FONT DESCRIPTION"). Provided it is supported by the platform implementation this font will be selected when the dialog is displayed.

-apply

This specifies a command prefix to be called when a font selection has been made by the user. The command will have the font specification appended as the final parameter and is then evaluated in the global namespace. The font specification will be a list of the form described on the font(n) manual page under "FONT DESCRIPTION" section 3. That is a list of {family size style ?style ...?}

Whenever a platform provides a suitable font dialog in its own API, Tk should not use a script-based alternative, even if this means missing out on features like the title or dynamic updating of the font during the selection process.

User code should not expect to receive a result from tk_chooseFont and may not assume that the dialog has been withdrawn or closed when the command returns.

Reference Implementation

http://sourceforge.net/support/tracker.php?aid=1477426

Copyright

This document has been placed in the public domain.


Powered by Tcl[Index] [History] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]

TIP AutoGenerator - written by Donal K. Fellows