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

~ 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.
