summaryrefslogtreecommitdiffstats
path: root/generic/ttk/ttkWidget.c
diff options
context:
space:
mode:
authorjenglish <jenglish@flightlab.com>2009-11-01 18:12:44 (GMT)
committerjenglish <jenglish@flightlab.com>2009-11-01 18:12:44 (GMT)
commit0c58d63813ddb8805d9b12b877a47e2d66027897 (patch)
tree82d1b223559ec164d9a4b29d63dac1acfbaf507e /generic/ttk/ttkWidget.c
parent0f2aa87192cc95c6095ccce0e517004664c2061f (diff)
downloadtk-0c58d63813ddb8805d9b12b877a47e2d66027897.zip
tk-0c58d63813ddb8805d9b12b877a47e2d66027897.tar.gz
tk-0c58d63813ddb8805d9b12b877a47e2d66027897.tar.bz2
Uniform, extensible syntax for [$w identify] methods:
[$w identify $component $x $y]. All ttk::* widgets support [$w identify element $x $y]; widgets with other identifiable parts may have additional subcommands. Notebook widgets support [$nb identify tab], Panedwindow widgets support [$w identify sash]. Older 2-argument form [$w identify $x $y] still supported, though it does different things depending on the widget.
Diffstat (limited to 'generic/ttk/ttkWidget.c')
-rw-r--r--generic/ttk/ttkWidget.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/generic/ttk/ttkWidget.c b/generic/ttk/ttkWidget.c
index a21125f..e64f1f1 100644
--- a/generic/ttk/ttkWidget.c
+++ b/generic/ttk/ttkWidget.c
@@ -1,4 +1,4 @@
-/* $Id: ttkWidget.c,v 1.21 2009/02/08 19:35:35 jenglish Exp $
+/* $Id: ttkWidget.c,v 1.22 2009/11/01 18:12:44 jenglish Exp $
* Copyright (c) 2003, Joe English
*
* Core widget utilities.
@@ -769,6 +769,7 @@ int TtkWidgetInstateCommand(
}
/* $w identify $x $y
+ * $w identify element $x $y
* Returns: name of element at $x, $y
*/
int TtkWidgetIdentifyCommand(
@@ -776,16 +777,27 @@ int TtkWidgetIdentifyCommand(
{
WidgetCore *corePtr = recordPtr;
Ttk_Element element;
- int x, y;
+ static const char *whatTable[] = { "element", NULL };
+ int x, y, what;
- if (objc != 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "x y");
+ if (objc < 4 || objc > 5) {
+ Tcl_WrongNumArgs(interp, 2, objv, "?what? x y");
return TCL_ERROR;
}
+ if (objc == 5) {
+ /* $w identify element $x $y */
+ if (Tcl_GetIndexFromObj(interp,objv[2],whatTable,"option",0,&what)
+ != TCL_OK)
+ {
+ return TCL_ERROR;
+ }
+ }
- if (Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK
- || Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)
+ if ( Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK
+ || Tcl_GetIntFromObj(interp, objv[objc-1], &y) != TCL_OK
+ ) {
return TCL_ERROR;
+ }
element = Ttk_IdentifyElement(corePtr->layout, x, y);
if (element) {