Unnamed Fossil Project

Check-in [c210c26edf]
Login

Check-in [c210c26edf]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added 'readonly' state
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: c210c26edff71ee3854cc0f9288f4f6c25b614347fa9febec29112e8d7e285d5
User & Date: jenglish 2004-06-11 18:36:19.000
Context
2004-06-11
23:08
* configure, configure.in: add MACOSX build variant info * Makefile.in: add fonts.tcl to PKG_TCL_SOURCES and aquaTheme.c for MACOSX builds. check-in: 819ac7dc2c user: hobbs tags: master, trunk
18:36
Added 'readonly' state check-in: c210c26edf user: jenglish tags: master, trunk
13:58
Ignore accidental mismatches caused by prefix-matching in TkGetOptionSpec (e.g. "-textvariable" matching "-text") check-in: a7160444b1 user: jenglish tags: master, trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to ChangeLog.




1
2
3
4
5
6
7




2004-06-10  Joe English  <jenglish@users.sourceforge.net>
	* tkTheme.c, tkElements.c: TTK_GetTheme(interp, NULL) no longer 
	returns default theme.  Use TTK_GetDefaultTheme() instead.
	* tkTheme.c: Factored BuildResourceMap() out of NewElementInstance()
	* tkTheme.c(BuildResourceMap): Ignore accidental mismatches caused 
	by prefix-matching in TkGetOptionSpec (e.g. "-textvariable" matching
	"-text").
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
2004-06-11  Joe English  <jenglish@users.sourceforge.net>
	* generic/tkTheme.h, generic/tkstate.c, generic/tile.c,
	demos/demo.tcl, tests/tile.test: Added 'readonly' state

2004-06-10  Joe English  <jenglish@users.sourceforge.net>
	* tkTheme.c, tkElements.c: TTK_GetTheme(interp, NULL) no longer 
	returns default theme.  Use TTK_GetDefaultTheme() instead.
	* tkTheme.c: Factored BuildResourceMap() out of NewElementInstance()
	* tkTheme.c(BuildResourceMap): Ignore accidental mismatches caused 
	by prefix-matching in TkGetOptionSpec (e.g. "-textvariable" matching
	"-text").
Changes to demos/demo.tcl.
1
2
3
4
5
6
7
8
9
#
# $Id: demo.tcl,v 1.61 2004/05/10 16:03:22 jenglish Exp $
#
# Demo for 'tile' package.
#

variable demodir [file dirname [info script]]
lappend auto_path . $demodir
package require tile

|







1
2
3
4
5
6
7
8
9
#
# $Id: demo.tcl,v 1.62 2004/05/30 03:06:13 jenglish Exp $
#
# Demo for 'tile' package.
#

variable demodir [file dirname [info script]]
lappend auto_path . $demodir
package require tile
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
# Widget state demo:
#

variable Widget .tbar_styled.tb1

bind all <Control-Shift-ButtonPress-1> { set ::Widget %W ; UpdateStates; break }
variable states [list \
    active disabled focus pressed selected \
    background indeterminate invalid default]

proc trackStates {} {
    variable states
    set t .states
    destroy $t; toplevel $t ; wm title $t "Widget states"








|







581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
# Widget state demo:
#

variable Widget .tbar_styled.tb1

bind all <Control-Shift-ButtonPress-1> { set ::Widget %W ; UpdateStates; break }
variable states [list \
    active disabled focus pressed selected readonly \
    background indeterminate invalid default]

proc trackStates {} {
    variable states
    set t .states
    destroy $t; toplevel $t ; wm title $t "Widget states"

Changes to generic/tile.c.
1
2
3
4
5
6
7
8
/* $Id: tile.c,v 1.43 2004/04/01 02:32:47 jenglish Exp $
 * Copyright (c) 2003, Joe English
 *
 * Tile package: initialization routine and miscellaneous utilities.
 */

#include <tk.h>
#include "tkTheme.h"
|







1
2
3
4
5
6
7
8
/* $Id: tile.c,v 1.44 2004/04/23 21:10:14 jenglish Exp $
 * Copyright (c) 2003, Joe English
 *
 * Tile package: initialization routine and miscellaneous utilities.
 */

#include <tk.h>
#include "tkTheme.h"
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93



94
95
96
97
98
99
100
    *resultPtr = TTK_ORIENT_HORIZONTAL;
    return Tcl_GetIndexFromObj(interp, objPtr,
	    TTKOrientStrings, "orientation", 0, resultPtr);
}

/*
 * Recognized values for the -state compatibility option.
 * Other options (e.g., "readonly", whatever else gets added)
 * are accepted and interpreted as synonyms for "normal".
 */
static const char *TTKStateStrings[] = {
    "normal", "disabled", "active", NULL
};
enum { 
    TTK_COMPAT_STATE_NORMAL,

    TTK_COMPAT_STATE_DISABLED,
    TTK_COMPAT_STATE_ACTIVE
};

/* CheckStateOption -- 
 * 	Handle -state compatibility option.
 *
 *	NOTE: setting -state disabled / -state enabled affects the 
 *	widget state, but the internal widget state does *not* affect 
 *	the value of the -state option.
 *	This option is present for compatibility only.
 */
void CheckStateOption(WidgetCore *corePtr, Tcl_Obj *objPtr)
{
    int stateOption = TTK_COMPAT_STATE_NORMAL;
    unsigned all = TTK_STATE_DISABLED|TTK_STATE_ACTIVE;
#   define SETFLAGS(f) WidgetChangeState(corePtr, f, all^f)

    (void)Tcl_GetIndexFromObj(NULL,objPtr,TTKStateStrings,"",0,&stateOption);
    switch (stateOption) {
	case TTK_COMPAT_STATE_NORMAL:
	default:
	    SETFLAGS(0);
	    break;



	case TTK_COMPAT_STATE_DISABLED:
	    SETFLAGS(TTK_STATE_DISABLED);
	    break;
	case TTK_COMPAT_STATE_ACTIVE:
	    SETFLAGS(TTK_STATE_ACTIVE);
	    break;
    }







<
|


|



>















|








>
>
>







55
56
57
58
59
60
61

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
    *resultPtr = TTK_ORIENT_HORIZONTAL;
    return Tcl_GetIndexFromObj(interp, objPtr,
	    TTKOrientStrings, "orientation", 0, resultPtr);
}

/*
 * Recognized values for the -state compatibility option.

 * Other options are accepted and interpreted as synonyms for "normal".
 */
static const char *TTKStateStrings[] = {
    "normal", "readonly", "disabled", "active", NULL
};
enum { 
    TTK_COMPAT_STATE_NORMAL,
    TTK_COMPAT_STATE_READONLY,
    TTK_COMPAT_STATE_DISABLED,
    TTK_COMPAT_STATE_ACTIVE
};

/* CheckStateOption -- 
 * 	Handle -state compatibility option.
 *
 *	NOTE: setting -state disabled / -state enabled affects the 
 *	widget state, but the internal widget state does *not* affect 
 *	the value of the -state option.
 *	This option is present for compatibility only.
 */
void CheckStateOption(WidgetCore *corePtr, Tcl_Obj *objPtr)
{
    int stateOption = TTK_COMPAT_STATE_NORMAL;
    unsigned all = TTK_STATE_DISABLED|TTK_STATE_READONLY|TTK_STATE_ACTIVE;
#   define SETFLAGS(f) WidgetChangeState(corePtr, f, all^f)

    (void)Tcl_GetIndexFromObj(NULL,objPtr,TTKStateStrings,"",0,&stateOption);
    switch (stateOption) {
	case TTK_COMPAT_STATE_NORMAL:
	default:
	    SETFLAGS(0);
	    break;
	case TTK_COMPAT_STATE_READONLY:
	    SETFLAGS(TTK_STATE_READONLY);
	    break;
	case TTK_COMPAT_STATE_DISABLED:
	    SETFLAGS(TTK_STATE_DISABLED);
	    break;
	case TTK_COMPAT_STATE_ACTIVE:
	    SETFLAGS(TTK_STATE_ACTIVE);
	    break;
    }
Changes to generic/tkTheme.h.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
 * tkTheme.h --
 *      Declarations for Tk style engine.
 *
 * Copyright (c) 2003 Joe English.  Freely redistributable.
 *
 * $Id: tkTheme.h,v 1.63 2004/04/06 02:19:46 jenglish Exp $
 */

#ifndef TKTHEME_H
#define TKTHEME_H 1

#define TILE_VERSION_MAJOR "0"
#define TILE_VERSION_MINOR "4"






|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
 * tkTheme.h --
 *      Declarations for Tk style engine.
 *
 * Copyright (c) 2003 Joe English.  Freely redistributable.
 *
 * $Id: tkTheme.h,v 1.64 2004/06/08 03:35:47 jenglish Exp $
 */

#ifndef TKTHEME_H
#define TKTHEME_H 1

#define TILE_VERSION_MAJOR "0"
#define TILE_VERSION_MINOR "4"
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#define TTK_STATE_FOCUS		(1<<2)
#define TTK_STATE_PRESSED	(1<<3)
#define TTK_STATE_SELECTED	(1<<4)
#define TTK_STATE_BACKGROUND	(1<<5)
#define TTK_STATE_INDETERMINATE	(1<<6)
#define TTK_STATE_INVALID	(1<<7)
#define TTK_STATE_DEFAULT	(1<<8)
#define TTK_STATE_USER7		(1<<9)
#define TTK_STATE_USER6		(1<<10)
#define TTK_STATE_USER5		(1<<11)
#define TTK_STATE_USER4		(1<<12)
#define TTK_STATE_USER3		(1<<13)
#define TTK_STATE_USER2		(1<<14)
#define TTK_STATE_USER1		(1<<15)








|







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#define TTK_STATE_FOCUS		(1<<2)
#define TTK_STATE_PRESSED	(1<<3)
#define TTK_STATE_SELECTED	(1<<4)
#define TTK_STATE_BACKGROUND	(1<<5)
#define TTK_STATE_INDETERMINATE	(1<<6)
#define TTK_STATE_INVALID	(1<<7)
#define TTK_STATE_DEFAULT	(1<<8)
#define TTK_STATE_READONLY	(1<<9)
#define TTK_STATE_USER6		(1<<10)
#define TTK_STATE_USER5		(1<<11)
#define TTK_STATE_USER4		(1<<12)
#define TTK_STATE_USER3		(1<<13)
#define TTK_STATE_USER2		(1<<14)
#define TTK_STATE_USER1		(1<<15)

Changes to generic/tkstate.c.
1
2
3
4
5
6
7
8
9
/*
 * $Id: tkstate.c,v 1.4 2004/02/19 02:42:41 jenglish Exp $
 *
 * Tk widget state utilities.
 *
 * Copyright (c) 2003 Joe English.  Freely redistributable.
 *
 */


|







1
2
3
4
5
6
7
8
9
/*
 * $Id: tkstate.c,v 1.5 2004/03/28 16:56:21 jenglish Exp $
 *
 * Tk widget state utilities.
 *
 * Copyright (c) 2003 Joe English.  Freely redistributable.
 *
 */

23
24
25
26
27
28
29

30
31
32
33
34
35
36
    "focus",		/* Widget has keyboard focus */
    "pressed",		/* Pressed or "armed" */
    "selected",		/* "on", "true", "current", etc. */
    "background",	/* Top-level window lost focus (Mac,Win "inactive") */
    "indeterminate",	/* "tri-state" or "mixed" for check/radiobuttons */
    "invalid",		/* Bad value */
    "default",		/* Default buttons */

    NULL
};

/*------------------------------------------------------------------------
 * +++ WidgetStateSpec object type:
 *
 * The string representation consists of a list of state names,







>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
    "focus",		/* Widget has keyboard focus */
    "pressed",		/* Pressed or "armed" */
    "selected",		/* "on", "true", "current", etc. */
    "background",	/* Top-level window lost focus (Mac,Win "inactive") */
    "indeterminate",	/* "tri-state" or "mixed" for check/radiobuttons */
    "invalid",		/* Bad value */
    "default",		/* Default buttons */
    "readonly",		/* Editing/modification disabled */
    NULL
};

/*------------------------------------------------------------------------
 * +++ WidgetStateSpec object type:
 *
 * The string representation consists of a list of state names,
Changes to tests/tile.test.
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413





414
415
416
417
418
419
420
} -result 1

test tile-11.3 "-state test, reenable" -body {
    .b configure -state normal
    .b instate disabled
} -result 0

test tile-11.4 "-state test, unrecognized options" -body {
    .b configure -state readonly
    .b state
} -result [list]

test tile-11.5 "-state test, 'active'" -body {
    .b configure -state active
    .b state
} -result [list active]

test tile-11.6 "-state test, cleanup" -body {





    destroy .b
}

test tile-12.1 "-cursor option" -body {
    tbutton .b
    .b cget -cursor
} -result {}







|
|






|

|
>
>
>
>
>







396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
} -result 1

test tile-11.3 "-state test, reenable" -body {
    .b configure -state normal
    .b instate disabled
} -result 0

test tile-11.4 "-state test, unrecognized -state value" -body {
    .b configure -state bogus
    .b state
} -result [list]

test tile-11.5 "-state test, 'active'" -body {
    .b configure -state active
    .b state
} -result [list active] -cleanup  { .b state !active }

test tile-11.6 "-state test, 'readonly'" -body {
    .b configure -state readonly
    .b state
} -result [list readonly] -cleanup { .b state !readonly }

test tile-11.7 "-state test, cleanup" -body {
    destroy .b
}

test tile-12.1 "-cursor option" -body {
    tbutton .b
    .b cget -cursor
} -result {}