TIP #71 Version 1.7: Tk Bitmap Improvements

This is not necessarily the current version of this TIP.


TIP:71
Title:Tk Bitmap Improvements
Version:$Revision: 1.7 $
Authors: Chris Nelson <chris at pinebush dot com>
Kevin Kenny <kennykb at acm dot org>
Eric Melski <ericm at interwoven dot com>
State:Draft
Type:Project
Tcl-Version:8.4
Vote:In progress
Created:Friday, 26 October 2001

Abstract

This TIP improves handling of bitmaps in Tk.

Background

Tk has a number of pre-defined bitmaps (10 on all platforms, and 16 more on Macs) but it lacks a number of useful bitmaps and there is no way to programmatically list the predefined bitmaps. This TIP adds a number of useful, basic bitmaps and provides for introspection of bitmap names.

New Bitmaps

Many complex widgets like comboboxes, spinboxes, etc. require arrows bitmaps on buttons. While newer releases of Tk have added more widgets, there will always be some unforeseen need for new or customized widgets. One example is a menubutton which, according to the Microsoft Windows User Experience (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/welcome.asp), should have a downward arrow on the right side. With compound buttons, it is not hard to do:

   button .mb -text Tools -bitmap downarrow -compound right

but there is no stock down-arrow bitmap.

I propose to add 12 bitmaps providing all four directions (up, down, left, and right) in three sizes (3x2, 5x3, and 7x4). The down arrows would look something like:

   @@@@@@@   @@@@@      @@@
   .@@@@@.   .@@@.      .@.
   ..@@@..   ..@..    
   ...@...

I propose the following names:

   u7x4      u5x3      u3x2
   d7x4      d5x3      d3x2
   l7x4      l5x3      l3x2
   r7x4      r5x3      r3x2

I'm considering adding arrow_ at the start of each name. I'm mindful of the fact that adding new predefined bitmaps has the potential to collide with application-defined bitmaps but unsure of the workaround for that.

Introspection

Many (most?) parts of Tcl/Tk can be inspected. You can list font names and families, list windows and find their children, etc., etc. but you need a manual to determine which bitmaps are predefined. I propose to add a [tk bitmaps] command which lists the predefined bitmaps.

Reference Implementation

SourceForge patch 475332 provides a reference implementation of [tk bitmaps] and a draft of the 12 arrow bitmaps.

https://sourceforge.net/tracker/index.php?func=detail&aid=475332&group_id=12997&atid=312997

Copyright

This document has been placed in the public domain.


Comments

Given that Chris implements his own suggestion about adding 'arrow_' at the end of the bitmap names, I find this a fine idea. - KBK <kennykb at acm dot org>

As discussed on tcl-core, I've created a simple Tcl script to convert ASCII art diagrams like those included in this TIP into XBM format data suitable for passing into [image create bitmap -data ...]. The script and sample usage are attached in the following patch: https://sourceforge.net/tracker/?func=detail&aid=516751&group_id=12997&atid=312997 - Eric Melski <ericm at interwoven dot com>

(Summary of objections)

KBK: Several TCT members posted comments to the tcl-core list, essentially regretting that the TIP doesn't go far enough; many wanted named bitmaps to be extensible from the Tcl script. The sponsor of the TIP (KBK) believes that the extension proposed here is small and useful, irrespective of how we address the larger issues of bitmap management, and that this TIP ought not to be blocked on those issues.


Powered by TclThis is not necessarily the current version of this TIP.

TIP AutoGenerator - written by Donal K. Fellows