From 98e56176e20f2cd61db22afeab6ef7ab444a22ca Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 30 Apr 2024 19:36:45 +0000 Subject: Backport [https://core.tcl-lang.org/tcl/timeline?r=argx_rejig|argx_rejig] branch from Tk 8.7 --- generic/tkMain.c | 58 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/generic/tkMain.c b/generic/tkMain.c index 9268e93..47bb044 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -68,14 +68,16 @@ NewNativeObj( { Tcl_Obj *obj; Tcl_DString ds; + const char *str; #if defined(_WIN32) && defined(UNICODE) Tcl_DStringInit(&ds); Tcl_WCharToUtfDString(string, wcslen(string), &ds); + str = Tcl_DStringValue(&ds); #else - Tcl_ExternalToUtfDString(NULL, (char *)string, -1, &ds); + str = Tcl_ExternalToUtfDString(NULL, (char *)string, strlen(string), &ds); #endif - obj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); + obj = Tcl_NewStringObj(str, Tcl_DStringLength(&ds)); Tcl_DStringFree(&ds); return obj; } @@ -139,7 +141,7 @@ typedef struct { */ static void Prompt(Tcl_Interp *interp, InteractiveState *isPtr); -static void StdinProc(ClientData clientData, int mask); +static void StdinProc(void *clientData, int mask); /* *---------------------------------------------------------------------- @@ -170,12 +172,18 @@ Tk_MainEx( * but before starting to execute commands. */ Tcl_Interp *interp) { + int i=0; /* argv[i] index */ Tcl_Obj *path, *argvPtr, *appName; const char *encodingName; int code, nullStdin = 0; Tcl_Channel chan; InteractiveState is; + if (0 < argc) { + --argc; /* "consume" argv[0] */ + ++i; + } + /* * Ensure that we are getting a compatible version of Tcl. */ @@ -198,11 +206,12 @@ Tk_MainEx( if (Tcl_GetVar2(interp, "env", "DISPLAY", TCL_GLOBAL_ONLY)) { loadCygwinTk: TkCygwinMainEx(argc, argv, appInitProc, interp); + /* Only returns when Tk_MainEx() was not found */ } else { - int i; + int j; - for (i = 1; i < argc; ++i) { - if (!_tcscmp(argv[i], TEXT("-display"))) { + for (j = 1; j < argc; ++j) { + if (!strcmp(argv[j], "-display")) { goto loadCygwinTk; } } @@ -248,23 +257,24 @@ Tk_MainEx( * -file FILENAME (ancient history support only) */ - if ((argc > 3) && (0 == _tcscmp(TEXT("-encoding"), argv[1])) + /* mind argc is being adjusted as we proceed */ + if ((argc >= 3) && (0 == _tcscmp(TEXT("-encoding"), argv[1])) && ('-' != argv[3][0])) { Tcl_Obj *value = NewNativeObj(argv[2]); Tcl_SetStartupScript(NewNativeObj(argv[3]), Tcl_GetString(value)); Tcl_DecrRefCount(value); argc -= 3; - argv += 3; - } else if ((argc > 1) && ('-' != argv[1][0])) { + i += 3; + } else if ((argc >= 1) && ('-' != argv[1][0])) { Tcl_SetStartupScript(NewNativeObj(argv[1]), NULL); argc--; - argv++; - } else if ((argc > 2) && (length = _tcslen(argv[1])) + i++; + } else if ((argc >= 2) && (length = _tcslen(argv[1])) && (length > 1) && (0 == _tcsncmp(TEXT("-file"), argv[1], length)) && ('-' != argv[2][0])) { Tcl_SetStartupScript(NewNativeObj(argv[2]), NULL); argc -= 2; - argv += 2; + i += 2; } } @@ -275,14 +285,12 @@ Tk_MainEx( appName = path; } Tcl_SetVar2Ex(interp, "argv0", NULL, appName, TCL_GLOBAL_ONLY); - argc--; - argv++; Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc), TCL_GLOBAL_ONLY); argvPtr = Tcl_NewListObj(0, NULL); while (argc--) { - Tcl_ListObjAppendElement(NULL, argvPtr, NewNativeObj(*argv++)); + Tcl_ListObjAppendElement(NULL, argvPtr, NewNativeObj(argv[i++])); } Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY); @@ -305,7 +313,7 @@ Tk_MainEx( } #endif Tcl_SetVar2Ex(interp, "tcl_interactive", NULL, - Tcl_NewIntObj(!path && (is.tty || nullStdin)), TCL_GLOBAL_ONLY); + Tcl_NewBooleanObj(!path && (is.tty || nullStdin)), TCL_GLOBAL_ONLY); /* * Invoke application-specific initialization. @@ -400,7 +408,7 @@ Tk_MainEx( static void StdinProc( - ClientData clientData, /* The state of interactive cmd line */ + void *clientData, /* The state of interactive cmd line */ int mask) /* Not used. */ { char *cmd; @@ -415,10 +423,15 @@ StdinProc( if ((length < 0) && !isPtr->gotPartial) { if (isPtr->tty) { + /* + * Would be better to find a way to exit the mainLoop? Or perhaps + * evaluate [exit]? Leaving as is for now due to compatibility + * concerns. + */ + Tcl_Exit(0); - } else { - Tcl_DeleteChannelHandler(chan, StdinProc, isPtr); } + Tcl_DeleteChannelHandler(chan, StdinProc, isPtr); return; } @@ -440,10 +453,9 @@ StdinProc( Tcl_CreateChannelHandler(chan, 0, StdinProc, isPtr); code = Tcl_RecordAndEval(interp, cmd, TCL_EVAL_GLOBAL); - - isPtr->input = Tcl_GetStdChannel(TCL_STDIN); - if (isPtr->input) { - Tcl_CreateChannelHandler(isPtr->input, TCL_READABLE, StdinProc, isPtr); + isPtr->input = chan = Tcl_GetStdChannel(TCL_STDIN); + if (chan != NULL) { + Tcl_CreateChannelHandler(chan, TCL_READABLE, StdinProc, isPtr); } Tcl_DStringFree(&isPtr->command); if (Tcl_GetString(Tcl_GetObjResult(interp))[0] != '\0') { -- cgit v0.12 From 07290679b626a091bd19a007106a28f5447a56d0 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 30 Apr 2024 19:57:08 +0000 Subject: Backport more error-handling in tkMain.c from 8.7: Tk 8.6 could be run with Tcl 8.7, while stdout/stderr could be set to -profile strict --- generic/tkMain.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/generic/tkMain.c b/generic/tkMain.c index 47bb044..3174499 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -25,6 +25,7 @@ MODULE_SCOPE void TkCygwinMainEx(int, char **, Tcl_AppInitProc *, Tcl_Interp *); */ static const char DEFAULT_PRIMARY_PROMPT[] = "% "; +static const char ENCODING_ERROR[] = "\n\t(encoding error in stderr)"; /* * This file can be compiled on Windows in UNICODE mode, as well as on all @@ -84,7 +85,7 @@ NewNativeObj( /* * Declarations for various library functions and variables (don't want to - * include tkInt.h or tkPort.h here, because people might copy this file out + * include tclInt.h or tclPort.h here, because people might copy this file out * of the Tk source directory to make their own modified versions). Note: do * not declare "exit" here even though a declaration is really needed, because * it will conflict with a declaration elsewhere on some systems. @@ -458,14 +459,28 @@ StdinProc( Tcl_CreateChannelHandler(chan, TCL_READABLE, StdinProc, isPtr); } Tcl_DStringFree(&isPtr->command); - if (Tcl_GetString(Tcl_GetObjResult(interp))[0] != '\0') { - if ((code != TCL_OK) || (isPtr->tty)) { - chan = Tcl_GetStdChannel((code != TCL_OK) ? TCL_STDERR : TCL_STDOUT); - if (chan) { - Tcl_WriteObj(chan, Tcl_GetObjResult(interp)); - Tcl_WriteChars(chan, "\n", 1); + if (code != TCL_OK) { + chan = Tcl_GetStdChannel(TCL_STDERR); + + if (chan != NULL) { + if (Tcl_WriteObj(chan, Tcl_GetObjResult(interp)) < 0) { + Tcl_WriteChars(chan, ENCODING_ERROR, -1); + } + Tcl_WriteChars(chan, "\n", 1); + } + } else if (isPtr->tty) { + Tcl_Obj *resultPtr = Tcl_GetObjResult(interp); + chan = Tcl_GetStdChannel(TCL_STDOUT); + + Tcl_IncrRefCount(resultPtr); + (void)Tcl_GetStringFromObj(resultPtr, &length); + if ((length > 0) && (chan != NULL)) { + if (Tcl_WriteObj(chan, resultPtr) < 0) { + Tcl_WriteChars(chan, "\n\t(encoding error in stdout)", -1); } + Tcl_WriteChars(chan, "\n", 1); } + Tcl_DecrRefCount(resultPtr); } /* @@ -521,12 +536,12 @@ Prompt( if (code != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (script that generates prompt)"); - if (Tcl_GetString(Tcl_GetObjResult(interp))[0] != '\0') { - chan = Tcl_GetStdChannel(TCL_STDERR); - if (chan != NULL) { - Tcl_WriteObj(chan, Tcl_GetObjResult(interp)); - Tcl_WriteChars(chan, "\n", 1); - } + chan = Tcl_GetStdChannel(TCL_STDERR); + if (chan != NULL) { + if (Tcl_WriteObj(chan, Tcl_GetObjResult(interp)) < 0) { + Tcl_WriteChars(chan, ENCODING_ERROR, -1); + } + Tcl_WriteChars(chan, "\n", 1); } goto defaultPrompt; } -- cgit v0.12 From ca1def5d1884fefe3076aad47004b801ff54ff6e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 1 May 2024 09:23:10 +0000 Subject: Backout [15e322ca]: Eliminate the use of Tcl_GetPathType(), somehow doesn't work correctly --- win/tkWinDialog.c | 69 ++++++++++++++++++++++--------------------------------- 1 file changed, 27 insertions(+), 42 deletions(-) diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index b0dd617..a9bf863 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -590,8 +590,7 @@ static UINT APIENTRY OFNHookProc(HWND hdlg, UINT uMsg, WPARAM wParam, static LRESULT CALLBACK MsgBoxCBTProc(int nCode, WPARAM wParam, LPARAM lParam); static void SetTkDialog(void *clientData); static const char *ConvertExternalFilename(LPCWSTR, Tcl_DString *); -static Tcl_Obj *ConvertExternalFilenameObj(LPCWSTR); - + /* *------------------------------------------------------------------------- * @@ -1405,12 +1404,15 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, hr = itemIf->lpVtbl->GetDisplayName(itemIf, SIGDN_FILESYSPATH, &wstr); if (SUCCEEDED(hr)) { - Tcl_Obj *fnds; + Tcl_DString fnds; - fnds = ConvertExternalFilenameObj(wstr); + ConvertExternalFilename(wstr, &fnds); CoTaskMemFree(wstr); Tcl_ListObjAppendElement( - interp, multiObj, fnds); + interp, multiObj, + Tcl_NewStringObj(Tcl_DStringValue(&fnds), + Tcl_DStringLength(&fnds))); + Tcl_DStringFree(&fnds); } itemIf->lpVtbl->Release(itemIf); if (FAILED(hr)) @@ -1430,8 +1432,13 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr, hr = resultIf->lpVtbl->GetDisplayName(resultIf, SIGDN_FILESYSPATH, &wstr); if (SUCCEEDED(hr)) { - resultObj = ConvertExternalFilenameObj(wstr); + Tcl_DString fnds; + + ConvertExternalFilename(wstr, &fnds); + resultObj = Tcl_NewStringObj(Tcl_DStringValue(&fnds), + Tcl_DStringLength(&fnds)); CoTaskMemFree(wstr); + Tcl_DStringFree(&fnds); } resultIf->lpVtbl->Release(resultIf); } @@ -1682,17 +1689,18 @@ static int GetFileNameXP(Tcl_Interp *interp, OFNOpts *optsPtr, enum OFNOper oper files++; if (*files != '\0') { Tcl_Obj *fullnameObj; - Tcl_Obj *filenameObj; + Tcl_DString filenameBuf; count++; - filenameObj = ConvertExternalFilenameObj(files); + ConvertExternalFilename(files, &filenameBuf); fullnameObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_AppendToObj(fullnameObj, "/", TCL_INDEX_NONE); - Tcl_AppendObjToObj(fullnameObj, filenameObj); + Tcl_AppendToObj(fullnameObj, Tcl_DStringValue(&filenameBuf), + Tcl_DStringLength(&filenameBuf)); gotFilename = 1; - Tcl_DecrRefCount(filenameObj); + Tcl_DStringFree(&filenameBuf); Tcl_ListObjAppendElement(NULL, returnList, fullnameObj); } } @@ -1941,9 +1949,10 @@ OFNHookProc( * but only if not an absolute path. */ - Tcl_Obj *tmpfile = ConvertExternalFilenameObj(buffer); + Tcl_DString tmpfile; + ConvertExternalFilename(buffer, &tmpfile); if (TCL_PATH_ABSOLUTE == - Tcl_FSGetPathType(tmpfile)) { + Tcl_GetPathType(Tcl_DStringValue(&tmpfile))) { /* re-get the full path to the start of the buffer */ buffer = ofnData->dynFileBuffer; SendMessageW(hdlg, CDM_GETSPEC, selsize, (LPARAM) buffer); @@ -1951,7 +1960,7 @@ OFNHookProc( *(buffer-1) = '\\'; } buffer[selsize] = '\0'; /* Second NULL terminator. */ - Tcl_DecrRefCount(tmpfile); + Tcl_DStringFree(&tmpfile); } } else { /* @@ -2519,7 +2528,11 @@ Tk_ChooseDirectoryObjCmd( Tcl_ResetResult(interp); if (*path) { - Tcl_SetObjResult(interp, ConvertExternalFilenameObj(path)); + Tcl_DString ds; + + Tcl_SetObjResult(interp, Tcl_NewStringObj( + ConvertExternalFilename(path, &ds), TCL_INDEX_NONE)); + Tcl_DStringFree(&ds); } CleanupOFNOptions(&ofnOpts); @@ -2981,34 +2994,6 @@ ConvertExternalFilename( } return Tcl_DStringValue(dsPtr); } - -static Tcl_Obj * -ConvertExternalFilenameObj( - LPCWSTR filename) -{ - char *p; - int len = wcslen(filename) * 3; - Tcl_Obj *r = Tcl_NewObj(); - - Tcl_SetObjLength(r, len); - p = Tcl_GetString(r); - - len = WideCharToMultiByte(CP_UTF8, 0, filename, -1, p, len, NULL, NULL); - - for (; *p != '\0'; p++) { - /* - * Change the pathname to the Tcl "normalized" pathname, where back - * slashes are used instead of forward slashes - */ - - if (*p == '\\') { - *p = '/'; - } - } - Tcl_SetObjLength(r, len); - return r; -} - /* * ---------------------------------------------------------------------- -- cgit v0.12 From 6932490dd91ce76f8470a6ffccc99622250d264c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 1 May 2024 09:39:39 +0000 Subject: Backport ttk documentation from Tk 9.0 --- doc/ttk_Geometry.3 | 3 +- doc/ttk_button.n | 6 +- doc/ttk_checkbutton.n | 4 +- doc/ttk_combobox.n | 12 +++- doc/ttk_entry.n | 26 +++++++- doc/ttk_frame.n | 2 +- doc/ttk_image.n | 34 ++++++---- doc/ttk_intro.n | 20 +++--- doc/ttk_label.n | 2 +- doc/ttk_labelframe.n | 2 +- doc/ttk_menubutton.n | 2 +- doc/ttk_notebook.n | 38 ++++++++--- doc/ttk_panedwindow.n | 22 ++++++- doc/ttk_progressbar.n | 14 ++-- doc/ttk_radiobutton.n | 4 +- doc/ttk_scale.n | 6 ++ doc/ttk_scrollbar.n | 29 ++++++--- doc/ttk_separator.n | 2 +- doc/ttk_sizegrip.n | 8 +-- doc/ttk_spinbox.n | 2 +- doc/ttk_style.n | 64 ++++++++++++------ doc/ttk_treeview.n | 175 +++++++++++++++++++++++++++++++++++++++----------- doc/ttk_vsapi.n | 12 ++-- doc/ttk_widget.n | 76 +++++++++++----------- 24 files changed, 402 insertions(+), 163 deletions(-) diff --git a/doc/ttk_Geometry.3 b/doc/ttk_Geometry.3 index 0f8a171..20295d1 100644 --- a/doc/ttk_Geometry.3 +++ b/doc/ttk_Geometry.3 @@ -100,7 +100,8 @@ A bitmask containing one or more of the bits \fBTTK_STICK_E\fR (east, or right), \fBTTK_STICK_N\fR (north, or top), and \fBTTK_STICK_S\fR (south, or bottom). -\fBTTK_FILL_X\fR is defined as a synonym for (\fBTTK_STICK_W\fR|\fBTTK_STICK_E\fR), +\fBTTK_FILL_X\fR is defined as a synonym for +(\fBTTK_STICK_W\fR|\fBTTK_STICK_E\fR), \fBTTK_FILL_Y\fR is a synonym for (\fBTTK_STICK_N\fR|\fBTTK_STICK_S\fR), and \fBTTK_FILL_BOTH\fR is a synonym for (\fBTTK_FILL_X\fR|\fBTTK_FILL_Y\fR). diff --git a/doc/ttk_button.n b/doc/ttk_button.n index 896432f..4c24a45 100644 --- a/doc/ttk_button.n +++ b/doc/ttk_button.n @@ -10,7 +10,7 @@ .SH NAME ttk::button \- Widget that issues a command when pressed .SH SYNOPSIS -\fBttk::button\fR \fIpathName \fR?\fIoptions\fR? +\fBttk::button\fI pathName \fR?\fIoptions\fR? .BE .SH DESCRIPTION A \fBttk::button\fR widget displays a textual label and/or image, @@ -52,8 +52,10 @@ In addition to the standard \fBstate\fR and \fBstyle\fR commands (see \fBttk::widget\fR), button widgets support the following additional commands: +.\" METHOD: invoke .TP \fIpathName \fBinvoke\fR +. Invokes the command associated with the button. .SH "STANDARD STYLES" .PP @@ -103,7 +105,7 @@ are: .RS \fB\-shiftrelief\fP specifies how far the button contents are shifted down and right in the \fIpressed\fP state. -This action provides additional skeumorphic feedback. +This action provides additional skeuomorphic feedback. .RE \fB\-width\fP \fIamount\fP .PP diff --git a/doc/ttk_checkbutton.n b/doc/ttk_checkbutton.n index d78b7fc..e49b414 100644 --- a/doc/ttk_checkbutton.n +++ b/doc/ttk_checkbutton.n @@ -10,7 +10,7 @@ .SH NAME ttk::checkbutton \- On/off widget .SH SYNOPSIS -\fBttk::checkbutton\fR \fIpathName \fR?\fIoptions\fR? +\fBttk::checkbutton\fI pathName \fR?\fIoptions\fR? .BE .SH DESCRIPTION A \fBttk::checkbutton\fR widget is used to show or change a setting. @@ -41,8 +41,10 @@ In addition to the standard \fBstate\fR and \fBstyle\fR commands (see \fBttk::widget\fR), checkbutton widgets support the following additional commands: +.\" METHOD: invoke .TP \fIpathname\fB invoke\fR +. Toggles between the selected and deselected states and evaluates the associated \fB\-command\fR. If the widget is currently selected, sets the \fB\-variable\fR diff --git a/doc/ttk_combobox.n b/doc/ttk_combobox.n index fdc51af..3c88f84 100644 --- a/doc/ttk_combobox.n +++ b/doc/ttk_combobox.n @@ -10,7 +10,7 @@ .SH NAME ttk::combobox \- text field with popdown selection list .SH SYNOPSIS -\fBttk::combobox\fR \fIpathName \fR?\fIoptions\fR? +\fBttk::combobox\fI pathName \fR?\fIoptions\fR? .BE .SH DESCRIPTION .PP @@ -60,8 +60,10 @@ In addition to the standard \fBstate\fR and \fBstyle\fR commands (see \fBttk::widget\fR), combobox widgets support the following additional commands: +.\" METHOD: current .TP \fIpathName \fBcurrent\fR ?\fInewIndex\fR? +. If \fInewIndex\fR is supplied, sets the combobox value to the element at position \fInewIndex\fR in the list of \fB\-values\fR (in addition to integers, the \fBend\fR index is supported and indicates @@ -69,12 +71,16 @@ the last element of the list, moreover the same simple interpretation as for the command \fBstring index\fR is supported, with simple integer index arithmetic and indexing relative to \fBend\fR). Otherwise, returns the index of the current value in the list of -\fB\-values\fR or \fB\-1\fR if the current value does not appear in the list. +\fB\-values\fR or \fB{}\fR if the current value does not appear in the list. +.\" METHOD: get .TP \fIpathName \fBget\fR +. Returns the current value of the combobox. +.\" METHOD: set .TP -\fIpathName \fBset\fR \fIvalue\fR +\fIpathName \fBset\fI value\fR +. Sets the value of the combobox to \fIvalue\fR. .PP The combobox widget also supports the following \fBttk::entry\fR diff --git a/doc/ttk_entry.n b/doc/ttk_entry.n index e71bd01..c4176ec 100644 --- a/doc/ttk_entry.n +++ b/doc/ttk_entry.n @@ -12,7 +12,7 @@ .SH NAME ttk::entry \- Editable text field widget .SH SYNOPSIS -\fBttk::entry\fR \fIpathName \fR?\fIoptions\fR? +\fBttk::entry\fI pathName \fR?\fIoptions\fR? .BE .SH DESCRIPTION .PP @@ -147,8 +147,10 @@ In addition to the standard \fBstate\fR, \fBstyle\fR and \fBxview\fR commands (see \fBttk::widget\fR), entry widgets support the following additional commands: +.\" METHOD: bbox .TP \fIpathName \fBbbox \fIindex\fR +. Returns a list of four numbers describing the bounding box of the character given by \fIindex\fR. The first two elements of the list give the x and y coordinates of @@ -157,8 +159,10 @@ the upper-left corner of the screen area covered by the character the width and height of the character, in pixels. The bounding box may refer to a region outside the visible area of the window. +.\" METHOD: delete .TP \fIpathName \fBdelete \fIfirst \fR?\fIlast\fR? +. Delete one or more elements of the entry. \fIFirst\fR is the index of the first character to delete, and \fIlast\fR is the index of the character just after the last @@ -166,44 +170,59 @@ one to delete. If \fIlast\fR is not specified it defaults to \fIfirst\fR+1, i.e. a single character is deleted. This command returns the empty string. +.\" METHOD: get .TP \fIpathName \fBget\fR +. Returns the entry's string. +.\" METHOD: icursor .TP \fIpathName \fBicursor \fIindex\fR +. Arrange for the insert cursor to be displayed just before the character given by \fIindex\fR. Returns the empty string. +.\" METHOD: index .TP \fIpathName \fBindex\fI index\fR +. Returns the numerical index corresponding to \fIindex\fR. +.\" METHOD: insert .TP \fIpathName \fBinsert \fIindex string\fR +. Insert \fIstring\fR just before the character indicated by \fIindex\fR. Returns the empty string. +.\" METHOD: selection .TP \fIpathName \fBselection \fIoption arg\fR +. This command is used to adjust the selection within an entry. It has several forms, depending on \fIoption\fR: .RS .TP \fIpathName \fBselection clear\fR +. Clear the selection if it is currently in this widget. If the selection is not in this widget then the command has no effect. Returns the empty string. .TP \fIpathName \fBselection present\fR +. Returns 1 if there is are characters selected in the entry, 0 if nothing is selected. .TP -\fIpathName \fBselection range \fIstart\fR \fIend\fR +\fIpathName \fBselection range \fIstart end\fR +. Sets the selection to include the characters starting with the one indexed by \fIstart\fR and ending with the one just before \fIend\fR. If \fIend\fR refers to the same character as \fIstart\fR or an earlier one, then the entry's selection is cleared. .RE +.\" METHOD: validate .TP \fIpathName \fBvalidate\fR +. Force revalidation, independent of the conditions specified by the \fB\-validate\fR option. Returns 0 if validation fails, 1 if it succeeds. @@ -423,7 +442,8 @@ value is specified for \fB\-fieldbackground\fP. Otherwise it is ignored. .br \fB\-fieldbackground\fP \fIcolor\fP .RS -Some themes use a graphical background and their field background colors cannot be changed. +Some themes use a graphical background and their field background colors +cannot be changed. .RE \fB\-foreground\fP \fIcolor\fP .br diff --git a/doc/ttk_frame.n b/doc/ttk_frame.n index 607e7ad..8095016 100644 --- a/doc/ttk_frame.n +++ b/doc/ttk_frame.n @@ -10,7 +10,7 @@ .SH NAME ttk::frame \- Simple container widget .SH SYNOPSIS -\fBttk::frame\fR \fIpathName \fR?\fIoptions\fR? +\fBttk::frame\fI pathName \fR?\fIoptions\fR? .BE .SH DESCRIPTION .PP diff --git a/doc/ttk_image.n b/doc/ttk_image.n index 34dbabb..09cf1f8 100644 --- a/doc/ttk_image.n +++ b/doc/ttk_image.n @@ -10,7 +10,7 @@ .SH NAME ttk_image \- Define an element based on an image .SH SYNOPSIS -\fBttk::style element create \fIname\fR \fBimage\fR \fIimageSpec\fR ?\fIoptions\fR? +\fBttk::style element create \fIname \fBimage\fI imageSpec\fR ?\fIoptions\fR? .BE .SH DESCRIPTION .PP @@ -25,24 +25,30 @@ in a particular state or combination of states. .SH OPTIONS .PP Valid \fIoptions\fR are: +.\" OPTION: -border .TP -\fB\-border\fR \fIpadding\fR +\fB\-border\fI padding\fR +. \fIpadding\fR is a list of up to four integers, specifying the left, top, right, and bottom borders, respectively. If fewer than four elements are specified, \fIbottom\fR defaults to \fItop\fR, \fIright\fR defaults to \fIleft\fR, and \fItop\fR defaults to \fIleft\fR. -In other words, a list of three numbers specify the left, vertical, and right border; -a list of two numbers specify the horizontal and the vertical border; +In other words, a list of three numbers specify the left, vertical, and right +border; a list of two numbers specify the horizontal and the vertical border; a single number specifies the same border all the way around the element. See \fBIMAGE STRETCHING\fR, below. +.\" OPTION: -height .TP \fB\-height \fIheight\fR +. Specifies a minimum height for the element. If less than zero, the base image's height is used as a default. +.\" OPTION: -padding .TP -\fB\-padding\fR \fIpadding\fR +\fB\-padding\fI padding\fR +. Specifies the element's interior padding. The padding is a list of up to four length specifications \fIleft top right bottom\fR. @@ -50,12 +56,14 @@ If fewer than four elements are specified, \fIbottom\fR defaults to \fItop\fR, \fIright\fR defaults to \fIleft\fR, and \fItop\fR defaults to \fIleft\fR. -In other words, a list of three numbers specify the left, vertical, and right padding; -a list of two numbers specify the horizontal and the vertical padding; +In other words, a list of three numbers specify the left, vertical, and right +padding; a list of two numbers specify the horizontal and the vertical padding; a single number specifies the same padding all the way around the widget. Defaults to \fB\-border\fR if not specified. +.\" OPTION: -sticky .TP -\fB\-sticky\fR \fIspec\fR +\fB\-sticky\fI spec\fR +. Specifies how the image is placed within the final parcel. \fIspec\fR contains zero or more characters .QW n , @@ -63,8 +71,10 @@ Specifies how the image is placed within the final parcel. .QW w , or .QW e . +.\" OPTION: -width .TP \fB\-width \fIwidth\fR +. Specifies a minimum width for the element. If less than zero, the base image's width is used as a default. .SH "IMAGE STRETCHING" @@ -85,12 +95,12 @@ as a background image) should use \fB\-width 0\fR and \fB\-height 0\fR. .SH "EXAMPLE" .PP .CS -set img1 [image create photo \-file button.png] -set img2 [image create photo \-file button-pressed.png] -set img3 [image create photo \-file button-active.png] +set img1 [image create photo -file button.png] +set img2 [image create photo -file button-pressed.png] +set img3 [image create photo -file button-active.png] ttk::style element create Button.button image \e [list $img1 pressed $img2 active $img3] \e - \-border {2 4} \-sticky we + -border {2 4} -sticky we .CE .SH "SEE ALSO" ttk::intro(n), ttk::style(n), ttk_vsapi(n), image(n), photo(n) diff --git a/doc/ttk_intro.n b/doc/ttk_intro.n index c146dd1..783ebb6 100644 --- a/doc/ttk_intro.n +++ b/doc/ttk_intro.n @@ -83,10 +83,10 @@ For example, the layout for a horizontal scrollbar is: .PP .CS ttk::\fBstyle layout\fR Horizontal.TScrollbar { - Scrollbar.trough \-children { - Scrollbar.leftarrow \-side left \-sticky w - Scrollbar.rightarrow \-side right \-sticky e - Scrollbar.thumb \-sticky ew + Scrollbar.trough -children { + Scrollbar.leftarrow -side left -sticky w + Scrollbar.rightarrow -side right -sticky e + Scrollbar.thumb -sticky ew } } .CE @@ -151,9 +151,9 @@ For example: .PP .CS ttk::\fBstyle configure\fR TButton \e - \-background #d9d9d9 \e - \-foreground black \e - \-relief raised \e + -background #d9d9d9 \e + -foreground black \e + -relief raised \e ; .CE .PP @@ -165,9 +165,9 @@ for a particular style: .PP .CS ttk::\fBstyle map\fR TButton \e - \-background [list disabled #d9d9d9 active #ececec] \e - \-foreground [list disabled #a3a3a3] \e - \-relief [list {pressed !disabled} sunken] \e + -background [list disabled #d9d9d9 active #ececec] \e + -foreground [list disabled #a3a3a3] \e + -relief [list {pressed !disabled} sunken] \e ; .CE .SH "SEE ALSO" diff --git a/doc/ttk_label.n b/doc/ttk_label.n index 803eab4..149ef9b 100644 --- a/doc/ttk_label.n +++ b/doc/ttk_label.n @@ -10,7 +10,7 @@ .SH NAME ttk::label \- Display a text string and/or image .SH SYNOPSIS -\fBttk::label\fR \fIpathName \fR?\fIoptions\fR? +\fBttk::label\fI pathName \fR?\fIoptions\fR? .BE .SH DESCRIPTION .PP diff --git a/doc/ttk_labelframe.n b/doc/ttk_labelframe.n index b4940bd..8423da3 100644 --- a/doc/ttk_labelframe.n +++ b/doc/ttk_labelframe.n @@ -10,7 +10,7 @@ .SH NAME ttk::labelframe \- Container widget with optional label .SH SYNOPSIS -\fBttk::labelframe\fR \fIpathName \fR?\fIoptions\fR? +\fBttk::labelframe\fI pathName \fR?\fIoptions\fR? .BE .SH DESCRIPTION .PP diff --git a/doc/ttk_menubutton.n b/doc/ttk_menubutton.n index b9b716f..5578835 100644 --- a/doc/ttk_menubutton.n +++ b/doc/ttk_menubutton.n @@ -10,7 +10,7 @@ .SH NAME ttk::menubutton \- Widget that pops down a menu when pressed .SH SYNOPSIS -\fBttk::menubutton\fR \fIpathName \fR?\fIoptions\fR? +\fBttk::menubutton\fI pathName \fR?\fIoptions\fR? .BE .SH DESCRIPTION .PP diff --git a/doc/ttk_notebook.n b/doc/ttk_notebook.n index 84b6495..b7844a7 100644 --- a/doc/ttk_notebook.n +++ b/doc/ttk_notebook.n @@ -11,10 +11,10 @@ ttk::notebook \- Multi-paned container widget .SH SYNOPSIS .nf -\fBttk::notebook\fR \fIpathname \fR?\fIoptions...\fR? +\fBttk::notebook\fI pathname \fR?\fIoptions...\fR? .br -\fIpathname \fBadd\fR \fIwindow\fR ?\fIoptions...\fR? -\fIpathname \fBinsert\fR \fIindex\fR \fIwindow\fR ?\fIoptions...\fR? +\fIpathname \fBadd\fI window\fR ?\fIoptions...\fR? +\fIpathname \fBinsert\fI index window\fR ?\fIoptions...\fR? .fi .BE .SH DESCRIPTION @@ -41,8 +41,8 @@ If fewer than four elements are specified, \fIbottom\fR defaults to \fItop\fR, \fIright\fR defaults to \fIleft\fR, and \fItop\fR defaults to \fIleft\fR. -In other words, a list of three numbers specify the left, vertical, and right padding; -a list of two numbers specify the horizontal and the vertical padding; +In other words, a list of three numbers specify the left, vertical, and right +padding; a list of two numbers specify the horizontal and the vertical padding; a single number specifies the same padding all the way around the widget. .OP \-width width Width If present and greater than zero, @@ -112,57 +112,75 @@ In addition to the standard \fBstate\fR and \fBstyle\fR commands (see \fBttk::widget\fR), notebook widgets support the following additional commands: +.\" METHOD: add .TP \fIpathname \fBadd \fIwindow\fR ?\fIoptions...\fR? +. Adds a new tab to the notebook. See \fBTAB OPTIONS\fR for the list of available \fIoptions\fR. If \fIwindow\fR is currently managed by the notebook but hidden, it is restored to its previous position. +.\" METHOD: forget .TP \fIpathname \fBforget \fItabid\fR +. Removes the tab specified by \fItabid\fR, unmaps and unmanages the associated window. +.\" METHOD: hide .TP \fIpathname \fBhide \fItabid\fR +. Hides the tab specified by \fItabid\fR. The tab will not be displayed, but the associated window remains managed by the notebook and its configuration remembered. Hidden tabs may be restored with the \fBadd\fR command. +.\" METHOD: identify .TP \fIpathname \fBidentify\fI component x y\fR +. Returns the name of the element under the point given by \fIx\fR and \fIy\fR, or the empty string if no component is present at that location. The following subcommands are supported: .RS .TP -\fIpathname \fBidentify element\fR \fIx y\fR +\fIpathname \fBidentify element\fI x y\fR +. Returns the name of the element at the specified location. .TP -\fIpathname \fBidentify tab\fR \fIx y\fR +\fIpathname \fBidentify tab\fI x y\fR +. Returns the index of the tab at the specified location. .RE +.\" METHOD: index .TP \fIpathname \fBindex \fItabid\fR +. Returns the numeric index of the tab specified by \fItabid\fR, or the total number of tabs if \fItabid\fR is the string .QW \fBend\fR . +.\" METHOD: insert .TP \fIpathname \fBinsert \fIpos subwindow options...\fR +. Inserts a pane at the specified position. \fIpos\fR is either the string \fBend\fR, an integer index, or the name of a managed subwindow. If \fIsubwindow\fR is already managed by the notebook, moves it to the specified position. See \fBTAB OPTIONS\fR for the list of available options. +.\" METHOD: select .TP \fIpathname \fBselect\fR ?\fItabid\fR? +. Selects the specified tab. The associated content window will be displayed, and the previously-selected window (if different) is unmapped. If \fItabid\fR is omitted, returns the widget name of the currently selected pane. +.\" METHOD: tab .TP \fIpathname \fBtab \fItabid\fR ?\fI\-option \fR?\fIvalue ...\fR +. Query or modify the options of the specific tab. If no \fI\-option\fR is specified, returns a dictionary of the tab option values. @@ -170,8 +188,10 @@ If one \fI\-option\fR is specified, returns the value of that \fIoption\fR. Otherwise, sets the \fI\-option\fRs to the corresponding \fIvalue\fRs. See \fBTAB OPTIONS\fR for the available options. +.\" METHOD: tabs .TP \fIpathname \fBtabs\fR +. Returns the list of windows managed by the notebook, in the index order of their associated tabs. .SH "KEYBOARD TRAVERSAL" @@ -201,8 +221,8 @@ virtual event after a new tab is selected. .SH "EXAMPLE" .CS pack [\fBttk::notebook\fR .nb] -\&.nb add [frame .nb.f1] \-text "First tab" -\&.nb add [frame .nb.f2] \-text "Second tab" +\&.nb add [frame .nb.f1] -text "First tab" +\&.nb add [frame .nb.f2] -text "Second tab" \&.nb select .nb.f2 ttk::notebook::enableTraversal .nb .CE diff --git a/doc/ttk_panedwindow.n b/doc/ttk_panedwindow.n index 20a2717..d834ecb 100644 --- a/doc/ttk_panedwindow.n +++ b/doc/ttk_panedwindow.n @@ -11,10 +11,10 @@ ttk::panedwindow \- Multi-pane container window .SH SYNOPSIS .nf -\fBttk::panedwindow\fR \fIpathname \fR?\fIoptions\fR? +\fBttk::panedwindow\fI pathname \fR?\fIoptions\fR? .br -\fIpathname \fBadd\fR \fIwindow\fR ?\fIoptions...\fR? -\fIpathname \fBinsert\fR \fIindex\fR \fIwindow\fR ?\fIoptions...\fR? +\fIpathname \fBadd\fI window\fR ?\fIoptions...\fR? +\fIpathname \fBinsert\fI index window\fR ?\fIoptions...\fR? .fi .BE .SH DESCRIPTION @@ -54,16 +54,22 @@ In addition to the standard \fBstate\fR and \fBstyle\fR commands (see \fBttk::widget\fR), panedwindow widgets support the following additional commands: +.\" METHOD: add .TP \fIpathname \fBadd \fIsubwindow options...\fR +. Adds a new pane to the window. See \fBPANE OPTIONS\fR for the list of available options. +.\" METHOD: forget .TP \fIpathname \fBforget \fIpane\fR +. Removes the specified subpane from the widget. \fIpane\fR is either an integer index or the name of a managed subwindow. +.\" METHOD: identify .TP \fIpathname \fBidentify \fIcomponent x y\fR +. Returns the name of the element under the point given by \fIx\fR and \fIy\fR, or the empty string if no component is present at that location. If \fIcomponent\fR is omitted, it defaults to \fBsash\fR. @@ -71,33 +77,43 @@ The following subcommands are supported: .RS .TP \fIpathname \fBidentify element \fIx y\fR +. Returns the name of the element at the specified location. .TP \fIpathname \fBidentify sash \fIx y\fR +. Returns the index of the sash at the specified location. .RE +.\" METHOD: insert .TP \fIpathname \fBinsert \fIpos subwindow options...\fR +. Inserts a pane at the specified position. \fIpos\fR is either the string \fBend\fR, an integer index, or the name of a managed subwindow. If \fIsubwindow\fR is already managed by the paned window, moves it to the specified position. See \fBPANE OPTIONS\fR for the list of available options. +.\" METHOD: pane .TP \fIpathname \fBpane \fIpane \-option \fR?\fIvalue \fR?\fI\-option value...\fR +. Query or modify the options of the specified \fIpane\fR, where \fIpane\fR is either an integer index or the name of a managed subwindow. If no \fI\-option\fR is specified, returns a dictionary of the pane option values. If one \fI\-option\fR is specified, returns the value of that \fIoption\fR. Otherwise, sets the \fI\-option\fRs to the corresponding \fIvalue\fRs. +.\" METHOD: panes .TP \fIpathname \fBpanes\fR +. Returns the list of all windows managed by the widget, in the index order of their associated panes. +.\" METHOD: sashpos .TP \fIpathname \fBsashpos \fIindex\fR ?\fInewpos\fR? +. If \fInewpos\fR is specified, sets the position of sash number \fIindex\fR. May adjust the positions of adjacent sashes diff --git a/doc/ttk_progressbar.n b/doc/ttk_progressbar.n index 0673ca6..aae3f46 100644 --- a/doc/ttk_progressbar.n +++ b/doc/ttk_progressbar.n @@ -10,7 +10,7 @@ .SH NAME ttk::progressbar \- Provide progress feedback .SH SYNOPSIS -\fBttk::progressbar\fR \fIpathName \fR?\fIoptions\fR? +\fBttk::progressbar\fI pathName \fR?\fIoptions\fR? .BE .SH DESCRIPTION .PP @@ -20,10 +20,10 @@ amount completed relative to the total amount of work to be done, and \fIindeterminate\fR mode provides an animated display to let the user know that something is happening. .PP -If the value of \fB-orient\fR is \fBhorizontal\fR a text string can be +If the value of \fB\-orient\fR is \fBhorizontal\fR a text string can be displayed inside the progressbar. This string can be configured using -the \fB-anchor\fR, \fB-font\fR, \fB-foreground\fR, \fB-justify\fR, -\fB-text\fR and \fB-wraplength\fR options. If the value of \fB-orient\fR +the \fB\-anchor\fR, \fB\-font\fR, \fB\-foreground\fR, \fB\-justify\fR, +\fB\-text\fR and \fB\-wraplength\fR options. If the value of \fB\-orient\fR is \fBvertical\fR then these options are ignored. .SO ttk_widget \-anchor \-class \-cursor @@ -71,18 +71,24 @@ In addition to the standard \fBstate\fR and \fBstyle\fR commands (see \fBttk::widget\fR), progressbar widgets support the following additional commands: +.\" METHOD: start .TP \fIpathName \fBstart\fR ?\fIinterval\fR? +. Begin autoincrement mode: schedules a recurring timer event that calls \fBstep\fR every \fIinterval\fR milliseconds. If omitted, \fIinterval\fR defaults to 50 milliseconds (20 steps/second). +.\" METHOD: step .TP \fIpathName \fBstep\fR ?\fIamount\fR? +. Increments the \fB\-value\fR by \fIamount\fR. \fIamount\fR defaults to 1.0 if omitted. +.\" METHOD: stop .TP \fIpathName \fBstop\fR +. Stop autoincrement mode: cancels any recurring timer event initiated by \fIpathName \fBstart\fR. .SH "STYLING OPTIONS" diff --git a/doc/ttk_radiobutton.n b/doc/ttk_radiobutton.n index 45be7df..74777dc 100644 --- a/doc/ttk_radiobutton.n +++ b/doc/ttk_radiobutton.n @@ -10,7 +10,7 @@ .SH NAME ttk::radiobutton \- Mutually exclusive option widget .SH SYNOPSIS -\fBttk::radiobutton\fR \fIpathName \fR?\fIoptions\fR? +\fBttk::radiobutton\fI pathName \fR?\fIoptions\fR? .BE .SH DESCRIPTION .PP @@ -41,8 +41,10 @@ In addition to the standard \fBstate\fR and \fBstyle\fR commands (see \fBttk::widget\fR), radiobutton widgets support the following additional commands: +.\" METHOD: invoke .TP \fIpathname\fB invoke\fR +. Sets the \fB\-variable\fR to the \fB\-value\fR, selects the widget, and evaluates the associated \fB\-command\fR. Returns the result of the \fB\-command\fR, or the empty diff --git a/doc/ttk_scale.n b/doc/ttk_scale.n index c0c351b..c9f0298 100644 --- a/doc/ttk_scale.n +++ b/doc/ttk_scale.n @@ -56,21 +56,27 @@ In addition to the standard \fBstate\fR and \fBstyle\fR commands (see \fBttk::widget\fR), scale widgets support the following additional commands: +.\" METHOD: get .TP \fIpathName \fBget \fR?\fIx y\fR? +. Get the current value of the \fB\-value\fR option, or the value corresponding to the coordinates \fIx,y\fR if they are specified. \fIX\fR and \fIy\fR are pixel coordinates relative to the scale widget origin. +.\" METHOD: see .TP \fIpathName \fBset \fIvalue\fR +. Set the value of the widget (i.e. the \fB\-value\fR option) to \fIvalue\fR. The value will be clipped to the range given by the \fB\-from\fR and \fB\-to\fR options. Note that setting the linked variable (i.e. the variable named in the \fB\-variable\fR option) does not cause such clipping. .SH "INTERNAL COMMANDS" .PP +.\" METHOD: coords .TP \fIpathName \fBcoords \fR?\fIvalue\fR? +. Get the coordinates corresponding to \fIvalue\fR, or the coordinates corresponding to the current value of the \fB\-value\fR option if \fIvalue\fR is omitted. diff --git a/doc/ttk_scrollbar.n b/doc/ttk_scrollbar.n index 948c6eb..406d70d 100644 --- a/doc/ttk_scrollbar.n +++ b/doc/ttk_scrollbar.n @@ -11,7 +11,7 @@ .SH NAME ttk::scrollbar \- Control the viewport of a scrollable widget .SH SYNOPSIS -\fBttk::scrollbar\fR \fIpathName \fR?\fIoptions...\fR? +\fBttk::scrollbar\fI pathName \fR?\fIoptions...\fR? .BE .SH DESCRIPTION .PP @@ -52,12 +52,16 @@ In addition to the standard \fBstate\fR and \fBstyle\fR commands (see \fBttk::widget\fR), scrollbar widgets support the following additional commands: +.\" METHOD: get .TP \fIpathName \fBget\fR +. Returns the scrollbar settings in the form of a list whose elements are the arguments to the most recent \fBset\fR widget command. +.\" METHOD: set .TP \fIpathName \fBset \fIfirst last\fR +. This command is normally invoked by the scrollbar's associated widget from an \fB\-xscrollcommand\fR or \fB\-yscrollcommand\fR callback. Specifies the visible range to be displayed. @@ -66,8 +70,10 @@ Specifies the visible range to be displayed. .PP The following widget commands are used internally by the \fBTScrollbar\fP widget class bindings. +.\" METHOD: delta .TP \fIpathName \fBdelta \fIdeltaX deltaY\fR +. Returns a real number indicating the fractional change in the scrollbar setting that corresponds to a given change in thumb position. For example, if the scrollbar is horizontal, @@ -77,8 +83,10 @@ ignored in this case). If the scrollbar is vertical, the result indicates how much the scrollbar setting must change to move the thumb \fIdeltaY\fR pixels down. The arguments and the result may be zero or negative. +.\" METHOD: fraction .TP \fIpathName \fBfraction \fIx y\fR +. Returns a real number between 0 and 1 indicating where the point given by \fIx\fR and \fIy\fR lies in the trough area of the scrollbar, where 0.0 corresponds to the top or left of the trough @@ -99,6 +107,7 @@ In each case, \fIprefix\fR is the contents of the \fB\-command\fR option, which usually has a form like \fB.t yview\fR .TP \fIprefix \fBmoveto \fIfraction\fR +. \fIFraction\fR is a real number between 0 and 1. The widget should adjust its view so that the point given by \fIfraction\fR appears at the beginning of the widget. @@ -108,6 +117,7 @@ refers to a point one-third of the way through the document, and so on. .TP \fIprefix \fBscroll \fInumber \fBpages\fR +. The widget should adjust its view by \fInumber\fR pages. It is up to the widget to define the meaning of a page; typically it is slightly less than what fits in the window, so that there @@ -117,6 +127,7 @@ become visible, or \-1, which means that the previous page should become visible. .TP \fIprefix \fBscroll \fInumber \fBunits\fR +. The widget should adjust its view by \fInumber\fR units. The units are defined in whatever way makes sense for the widget, such as characters or lines in a text widget. @@ -134,14 +145,14 @@ of individual elements, based on the position and state of the mouse pointer. .PP .CS set f [frame .f] -ttk::scrollbar $f.hsb \-orient horizontal \-command [list $f.t xview] -ttk::scrollbar $f.vsb \-orient vertical \-command [list $f.t yview] -text $f.t \-xscrollcommand [list $f.hsb set] \-yscrollcommand [list $f.vsb set] -grid $f.t \-row 0 \-column 0 \-sticky nsew -grid $f.vsb \-row 0 \-column 1 \-sticky nsew -grid $f.hsb \-row 1 \-column 0 \-sticky nsew -grid columnconfigure $f 0 \-weight 1 -grid rowconfigure $f 0 \-weight 1 +\fBttk::scrollbar\fR $f.hsb -orient horizontal -command [list $f.t xview] +\fBttk::scrollbar\fR $f.vsb -orient vertical -command [list $f.t yview] +text $f.t -xscrollcommand [list $f.hsb set] -yscrollcommand [list $f.vsb set] +grid $f.t -row 0 -column 0 -sticky nsew +grid $f.vsb -row 0 -column 1 -sticky nsew +grid $f.hsb -row 1 -column 0 -sticky nsew +grid columnconfigure $f 0 -weight 1 +grid rowconfigure $f 0 -weight 1 pack $f .CE .SH "STYLING OPTIONS" diff --git a/doc/ttk_separator.n b/doc/ttk_separator.n index 5331f3e..dacd10e 100644 --- a/doc/ttk_separator.n +++ b/doc/ttk_separator.n @@ -10,7 +10,7 @@ .SH NAME ttk::separator \- Separator bar .SH SYNOPSIS -\fBttk::separator\fR \fIpathName \fR?\fIoptions\fR? +\fBttk::separator\fI pathName \fR?\fIoptions\fR? .BE .SH DESCRIPTION .PP diff --git a/doc/ttk_sizegrip.n b/doc/ttk_sizegrip.n index fda8d07..050d0bf 100644 --- a/doc/ttk_sizegrip.n +++ b/doc/ttk_sizegrip.n @@ -10,7 +10,7 @@ .SH NAME ttk::sizegrip \- Bottom-right corner resize widget .SH SYNOPSIS -\fBttk::sizegrip\fR \fIpathName \fR?\fIoptions\fR? +\fBttk::sizegrip\fI pathName \fR?\fIoptions\fR? .BE .SH DESCRIPTION .PP @@ -37,14 +37,14 @@ the built-in grip will just mask the widget. .PP Using pack: .CS -pack [ttk::frame $top.statusbar] \-side bottom \-fill x -pack [\fBttk::sizegrip\fR $top.statusbar.grip] \-side right \-anchor se +pack [ttk::frame $top.statusbar] -side bottom -fill x +pack [\fBttk::sizegrip\fR $top.statusbar.grip] -side right -anchor se .CE .PP Using grid: .CS grid [\fBttk::sizegrip\fR $top.statusbar.grip] \e - \-row $lastRow \-column $lastColumn \-sticky se + -row $lastRow -column $lastColumn -sticky se # ... optional: add vertical scrollbar in $lastColumn, # ... optional: add horizontal scrollbar in $lastRow .CE diff --git a/doc/ttk_spinbox.n b/doc/ttk_spinbox.n index 4f45ccf..4c7d23a 100644 --- a/doc/ttk_spinbox.n +++ b/doc/ttk_spinbox.n @@ -10,7 +10,7 @@ .SH NAME ttk::spinbox \- Selecting text field widget .SH SYNOPSIS -\fBttk::spinbox\fR \fIpathName \fR?\fIoptions\fR? +\fBttk::spinbox\fI pathName \fR?\fIoptions\fR? .BE .SH DESCRIPTION .PP diff --git a/doc/ttk_style.n b/doc/ttk_style.n index 7763336..85d6a06 100644 --- a/doc/ttk_style.n +++ b/doc/ttk_style.n @@ -10,7 +10,7 @@ .SH NAME ttk::style \- Manipulate style database .SH SYNOPSIS -\fBttk::style\fR \fIoption\fR ?\fIargs\fR? +\fBttk::style\fI option\fR ?\fIargs\fR? .BE .SH NOTES .PP @@ -33,19 +33,23 @@ style is the theme root style on which derived styles are based. .SH DESCRIPTION .PP The \fBttk::style\fR command takes the following arguments: +.\" METHOD: configure .TP \fBttk::style configure \fIstyle\fR ?\fI\-option\fR ?\fIvalue option value...\fR? ? +. Sets the default value of the specified option(s) in \fIstyle\fR. If \fIstyle\fR does not exist, it is created. -If only \fIstyle\fR and \fI-option\fR are specified, get the default value -for option \fI-option\fR of style \fIstyle\fR. +If only \fIstyle\fR and \fI\-option\fR are specified, get the default value +for option \fI\-option\fR of style \fIstyle\fR. If only \fIstyle\fR is specified, get the default value for all options of style \fIstyle\fR. +.\" METHOD: element .TP -\fBttk::style element\fR \fIargs\fR +\fBttk::style element\fI args\fR .RS .TP -\fBttk::style element create\fR \fIelementName\fR \fItype\fR ?\fIargs...\fR? +\fBttk::style element create\fI elementName type\fR ?\fIargs...\fR? +. Creates a new element in the current theme of type \fItype\fR. The only cross-platform built-in element type is \fIimage\fR (see \fBttk_image\fR(n)) but themes may define other element types @@ -54,19 +58,25 @@ an element factory is registered to create Windows theme elements (see \fBttk_vsapi\fR(n)). .TP \fBttk::style element names\fR +. Returns the list of elements defined in the current theme. .TP \fBttk::style element options \fIelement\fR +. Returns the list of \fIelement\fR's options. .RE +.\" METHOD: layout .TP \fBttk::style layout \fIstyle\fR ?\fIlayoutSpec\fR? +. Define the widget layout for style \fIstyle\fR. See \fBLAYOUTS\fR below for the format of \fIlayoutSpec\fR. If \fIlayoutSpec\fR is omitted, return the layout specification for style \fIstyle\fR. +.\" METHOD: lookup .TP -\fBttk::style lookup \fIstyle\fR \fI\-option \fR?\fIstate \fR?\fIdefault\fR?? +\fBttk::style lookup \fIstyle \-option \fR?\fIstate \fR?\fIdefault\fR?? +. Returns the value specified for \fI\-option\fR in style \fIstyle\fR in state \fIstate\fR, using the standard lookup rules for element options. \fIstate\fR is a list of state names; if omitted, @@ -77,22 +87,26 @@ If the \fIdefault\fR argument is present, it is used as a fallback value in case no specification for \fI\-option\fR is found. .\" Otherwise -- signal error? return empty string? Leave unspecified for now. If \fIstyle\fR does not exist, it is created. +.\" METHOD: map .TP \fBttk::style map \fIstyle\fR ?\fI\-option\fB { \fIstatespec value...\fB }\fR? +. Sets dynamic (state dependent) values of the specified option(s) in \fIstyle\fR. Each \fIstatespec / value\fR pair is examined in order; the value corresponding to the first matching \fIstatespec\fR is used. If \fIstyle\fR does not exist, it is created. -If only \fIstyle\fR and \fI-option\fR are specified, get the dynamic values -for option \fI-option\fR of style \fIstyle\fR. +If only \fIstyle\fR and \fI\-option\fR are specified, get the dynamic values +for option \fI\-option\fR of style \fIstyle\fR. If only \fIstyle\fR is specified, get the dynamic values for all options of style \fIstyle\fR. +.\" METHOD: theme .TP -\fBttk::style theme\fR \fIargs\fR +\fBttk::style theme\fI args\fR .RS .TP -\fBttk::style theme create\fR \fIthemeName\fR ?\fB\-parent \fIbasedon\fR? ?\fB\-settings \fIscript...\fR ? +\fBttk::style theme create\fI themeName\fR ?\fB\-parent \fIbasedon\fR? ?\fB\-settings \fIscript...\fR ? +. Creates a new theme. It is an error if \fIthemeName\fR already exists. If \fB\-parent\fR is specified, the new theme will inherit styles, elements, and layouts from the parent theme \fIbasedon\fR. @@ -100,19 +114,23 @@ If \fB\-settings\fR is present, \fIscript\fR is evaluated in the context of the new theme as per \fBttk::style theme settings\fR. .TP \fBttk::style theme names\fR +. Returns a list of all known themes. .TP -\fBttk::style theme settings \fIthemeName\fR \fIscript\fR +\fBttk::style theme settings \fIthemeName script\fR +. Temporarily sets the current theme to \fIthemeName\fR, evaluate \fIscript\fR, then restore the previous theme. Typically \fIscript\fR simply defines styles and elements, though arbitrary Tcl code may appear. .TP \fBttk::style theme styles\fR ?\fIthemeName\fR? +. Returns a list of all styles in \fIthemeName\fR. If \fIthemeName\fR is omitted, the current theme is used. .TP \fBttk::style theme use\fR ?\fIthemeName\fR? +. Without an argument the result is the name of the current theme. Otherwise this command sets the current theme to \fIthemeName\fR, and refreshes all widgets. @@ -129,18 +147,25 @@ the allocated parcel. Valid options are: .\" -border should remain undocumented for now (dubious usefulness) .\" .TP -.\" \fB\-border\fR \fIboolean\fR +.\" \fB\-border\fI boolean\fR +.\" . .\" Specifies whether the element is drawn after its children. Defaults to 0. +.\" OPTION: -children .TP \fB\-children { \fIsublayout...\fB }\fR +. Specifies a list of elements to place inside the element. +.\" OPTION: -expand .TP -\fB\-expand\fR \fIboolean\fR +\fB\-expand\fI boolean\fR +. Specifies whether the allocated parcel is the entire cavity. If so, simultaneous specification of \fB\-side\fR is ignored. Defaults to 0. +.\" OPTION: -side .TP \fB\-side \fIside\fR +. Specifies which side of the cavity to place the element; one of \fBleft\fR, \fBright\fR, \fBtop\fR, or \fBbottom\fR. For instance, \fB\-side top\fR allocates the parcel along the top of @@ -148,24 +173,27 @@ the cavity having width and height respectively the width of the cavity and the height of the element. If omitted, the allocated parcel is the entire cavity (same effect as \fB\-expand\fR 1). +.\" OPTION: -sticky .TP \fB\-sticky\fR \fB[\fInswe\fB]\fR +. Specifies the actual parcel position and size inside the allocated parcel. If specified as an empty string then the actual parcel is centered in the allocated parcel. Default is \fBnswe\fR. .\" -unit should remain undocumented for now (dubious usefulness) .\" .TP -.\" \fB\-unit\fR \fIboolean\fR +.\" \fB\-unit\fI boolean\fR +.\" . .\" Specifies whether the element propagates its state to its children. .\" Defaults to 0. .PP For example: .CS ttk::style layout Horizontal.TScrollbar { - Scrollbar.trough \-children { - Scrollbar.leftarrow \-side left - Scrollbar.rightarrow \-side right - Horizontal.Scrollbar.thumb \-side left \-sticky ew + Scrollbar.trough -children { + Scrollbar.leftarrow -side left + Scrollbar.rightarrow -side right + Horizontal.Scrollbar.thumb -side left -sticky ew } } .CE diff --git a/doc/ttk_treeview.n b/doc/ttk_treeview.n index 757be86..8ff0091 100644 --- a/doc/ttk_treeview.n +++ b/doc/ttk_treeview.n @@ -62,7 +62,7 @@ If set to \fB#all\fP (the default), all columns are shown in the order given. .OP \-height height Height Specifies the number of rows which should be visible. -Note: +Note that the requested width is determined from the sum of the column widths. .OP \-selectmode selectMode SelectMode Controls how the built-in class bindings manage the selection. @@ -95,13 +95,13 @@ even if \fB\-show tree\fR is not specified. .RE .OP \-striped striped Striped Boolean specifying zebra striped item coloring. -Note: -Striped items uses the \fB\-stripedbackground\fR option if set by the theme or a tag. -If not supported by the current theme, it will not show. +Note that +striped items uses the \fB\-stripedbackground\fR option if set by the theme or +a tag. If not supported by the current theme, it will not show. .OP \-titlecolumns titleColumns TitleColumns -Number of display columns at the left that should not be scrolled. The tree column counts, even -if \fB\-show tree\fR is not specified. Thus for value N of this option, column #N is -the first one that is scrollable. Default is 0. +Number of display columns at the left that should not be scrolled. The tree +column counts, even if \fB\-show tree\fR is not specified. Thus for value N of +this option, column #N is the first one that is scrollable. Default is 0. .OP \-titleitems titleItems TitleItems Number of items at the top that should not be vertically scrolled. Default is 0. .SH "WIDGET COMMAND" @@ -111,19 +111,22 @@ In addition to the standard \fBstate\fR, \fBstyle\fR, \fBxview\fR and \fByview\fR commands (see \fBttk::widget\fR), treeview widgets support the following additional commands: +.\" METHOD: bbox .TP \fIpathname \fBbbox \fIitem\fR ?\fIcolumn\fR? +. Returns the bounding box (relative to the treeview widget's window) -of the specified \fIitem\fR -in the form \fIx y width height\fR. +of the specified \fIitem\fR in the form \fIx y width height\fR. If the \fIitem\fR is not visible -(i.e., if it is a descendant of a closed item or is vertically scrolled offscreen), -returns the empty list. -If \fIcolumn\fR is specified and is not hidden (by the \fB\-displaycolumns\fR option), -returns the bounding box of that cell within \fIitem\fR (even if the cell -is horizontally scrolled offscreen). +(i.e., if it is a descendant of a closed item or is vertically scrolled +offscreen), returns the empty list. +If \fIcolumn\fR is specified and is not hidden (by the \fB\-displaycolumns\fR +option), returns the bounding box of that cell within \fIitem\fR +(even if the cell is horizontally scrolled offscreen). +.\" METHOD: cellselection .TP \fIpathname \fBcellselection\fR ?\fIselop arg ...\fR? +. Manages cell selection. Cell selection is independent from item selection handled by the \fBselection\fR command. A cell is given by a list of two elements, item and column. @@ -135,31 +138,41 @@ Otherwise, \fIselop\fR is one of the following: .RS .TP \fIpathname \fBcellselection set \fIcellList\fR +. \fIcellList\fR becomes the new cell selection. .TP -\fIpathname \fBcellselection set \fIfirstCell\fR \fIlastCell\fR +\fIpathname \fBcellselection set \fIfirstCell lastCell\fR +. The rectangle defined becomes the new cell selection. .TP \fIpathname \fBcellselection add \fIcellList\fR -Add \fIcellList\fR to the cell selection +. +Add \fIcellList\fR to the cell selection. .TP -\fIpathname \fBcellselection add \fIfirstCell\fR \fIlastCell\fR +\fIpathname \fBcellselection add \fIfirstCell lastCell\fR +. The rectangle defined is added to the cell selection. .TP \fIpathname \fBcellselection remove \fIcellList\fR -Remove \fIcellList\fR from the cell selection +. +Remove \fIcellList\fR from the cell selection. .TP -\fIpathname \fBcellselection remove \fIfirstCell\fR \fIlastCell\fR +\fIpathname \fBcellselection remove \fIfirstCell lastCell\fR +. The rectangle defined is removed from the cell selection. .TP \fIpathname \fBcellselection toggle \fIcellList\fR +. Toggle the cell selection state of each cell in \fIcellList\fR. .TP -\fIpathname \fBcellselection toggle \fIfirstCell\fR \fIlastCell\fR +\fIpathname \fBcellselection toggle \fIfirstCell lastCell\fR +. Toggle the cell selection state of each cell in the rectangle defined. .RE +.\" METHOD: children .TP \fIpathname \fBchildren \fIitem\fR ?\fInewchildren\fR? +. If \fInewchildren\fR is not specified, returns the list of children belonging to \fIitem\fR. .RS @@ -171,8 +184,10 @@ are detached from the tree. None of the items in \fInewchildren\fR may be an ancestor of \fIitem\fR. .RE +.\" METHOD: column .TP \fIpathname \fBcolumn \fIcolumn\fR ?\fI\-option \fR?\fIvalue \-option value...\fR? +. Query or modify the options for the specified \fIcolumn\fR. If no \fI\-option\fR is specified, returns a dictionary of option/value pairs. @@ -181,50 +196,66 @@ returns the value of that option. Otherwise, the options are updated with the specified values. The following options may be set on each column: .RS +.\" OPTION: -id .TP \fB\-id \fIname\fR +. The column name. This is a read-only option. For example, [\fI$pathname \fBcolumn #\fIn \fB\-id\fR] -returns the data column associated with display column #\fIn\fR. -The tree column has -id \fB#0\fR. +returns the data column associated with display column \fIn\fR. +The tree column has \fB\-id #0\fR. +.\" OPTION: -anchor .TP \fB\-anchor \fIanchor\fR +. Specifies how the text in this column should be aligned with respect to the cell. \fIAnchor\fR is one of \fBn\fR, \fBne\fR, \fBe\fR, \fBse\fR, \fBs\fR, \fBsw\fR, \fBw\fR, \fBnw\fR, or \fBcenter\fR. +.\" OPTION: -minwidth .TP \fB\-minwidth \fIminwidth\fR +. The minimum width of the column in pixels. The treeview widget will not make the column any smaller than \fB\-minwidth\fR when the widget is resized or the user drags a heading column separator. Default is 20 pixels. +.\" OPTION: -separator .TP \fB\-separator \fIboolean\fR +. Specifies whether or not a column separator should be drawn to the right of the column. Default is false. +.\" OPTION: -stretch .TP \fB\-stretch \fIboolean\fR +. Specifies whether or not the column width should be adjusted when the widget is resized or the user drags a heading column separator. \fIBoolean\fR may have any of the forms accepted by \fBTcl_GetBoolean\fR. By default columns are stretchable. +.\" OPTION: -width .TP \fB\-width \fIwidth\fR +. The width of the column in pixels. Default is 200 pixels. The specified column width may be changed by Tk in order to honor \fB\-stretch\fR and/or \fB\-minwidth\fR, or when the widget is resized or the user drags a heading column separator. .PP -Use \fIpathname column #0\fR to configure the tree column. +Use \fIpathname fBcolumn #0\fR to configure the tree column. .RE +.\" METHOD: delete .TP \fIpathname \fBdelete \fIitemList\fR +. Deletes each of the items in \fIitemList\fR and all of their descendants. The root item may not be deleted. See also: \fBdetach\fR. +.\" METHOD: detach .TP \fIpathname \fBdetach \fIitemList\fR +. Unlinks all of the specified items in \fIitemList\fR from the tree. The items and all of their descendants are still present and may be reinserted at another point in the tree @@ -232,38 +263,63 @@ with the \fBmove\fR operation, but will not be displayed until that is done. The root item may not be detached. See also: \fBdelete\fR. +.\" METHOD: detached +.TP +\fIpathname \fBdetached \fR?\fIitem\fR? +. +If \fIitem\fR is provided, returns a boolean value indicating whether it is +the name of a detached item (see \fBdetach\fR). Otherwise, returns a list of +all the detached items (in an arbitrary order). The root item is never +detached. +.\" METHOD: exists .TP \fIpathname \fBexists \fIitem\fR +. Returns 1 if the specified \fIitem\fR is present in the tree, 0 otherwise. +.\" METHOD: focus .TP \fIpathname \fBfocus \fR?\fIitem\fR? +. If \fIitem\fR is specified, sets the focus item to \fIitem\fR. Otherwise, returns the current focus item, or \fB{}\fR if there is none. .\" Need: way to clear the focus item. {} works for this... +.\" +.\" METHOD: heading .TP \fIpathname \fBheading \fIcolumn\fR ?\fI\-option \fR?\fIvalue \-option value...\fR? +. Query or modify the heading options for the specified \fIcolumn\fR. Valid options are: .RS +.\" OPTION: -text .TP \fB\-text \fItext\fR +. The text to display in the column heading. +.\" OPTION: -image .TP \fB\-image \fIimageName\fR +. Specifies an image to display to the right of the column heading. +.\" OPTION: -anchor .TP \fB\-anchor \fIanchor\fR +. Specifies how the heading text should be aligned. One of the standard Tk anchor values. +.\" OPTION: -command .TP \fB\-command \fIscript\fR +. A script to evaluate when the heading label is pressed. .PP Use \fIpathname heading #0\fR to configure the tree column heading. .RE +.\" METHOD: identify .TP \fIpathname \fBidentify \fIcomponent x y\fR +. Returns a description of the specified \fIcomponent\fR under the point given by \fIx\fR and \fIy\fR, or the empty string if no such \fIcomponent\fR is present at that position. @@ -289,30 +345,39 @@ A data cell. .RE .TP \fIpathname \fBidentify item \fIx y\fR +. Returns the item ID of the item at position \fIy\fR. .TP \fIpathname \fBidentify column \fIx y\fR +. Returns the display column identifier of the cell at position \fIx\fR. The tree column has ID \fB#0\fR. .TP \fIpathname \fBidentify cell \fIx y\fR +. Returns the cell identifier of the cell at position \fIx y\fR. A cell identifier is a list of item ID and column ID. .TP \fIpathname \fBidentify element \fIx y\fR +. The element at position \fIx,y\fR. .TP \fIpathname \fBidentify row \fIx y\fR +. Obsolescent synonym for \fIpathname \fBidentify item\fR. .PP See \fBCOLUMN IDENTIFIERS\fR for a discussion of display columns and data columns. .RE +.\" METHOD: index .TP \fIpathname \fBindex \fIitem\fR +. Returns the integer index of \fIitem\fR within its parent's list of children. +.\" METHOD: insert .TP \fIpathname \fBinsert \fIparent index\fR ?\fB\-id \fIid\fR? \fIoptions...\fR +. Creates a new item. \fIparent\fR is the item ID of the parent item, or the empty string \fB{}\fR @@ -332,8 +397,10 @@ Otherwise, a new unique identifier is generated. newly created item. See \fBITEM OPTIONS\fR for the list of available options. .RE +.\" METHOD: item .TP \fIpathname \fBitem \fIitem\fR ?\fI\-option \fR?\fIvalue \-option value...\fR? +. Query or modify the options for the specified \fIitem\fR. If no \fI\-option\fR is specified, returns a dictionary of option/value pairs. @@ -341,8 +408,10 @@ If a single \fI\-option\fR is specified, returns the value of that option. Otherwise, the item's options are updated with the specified values. See \fBITEM OPTIONS\fR for the list of available options. +.\" METHOD: move .TP \fIpathname \fBmove \fIitem parent index\fR +. Moves \fIitem\fR to position \fIindex\fR in \fIparent\fR's list of children. It is illegal to move an item under one of its descendants. .RS @@ -351,26 +420,36 @@ If \fIindex\fR is less than or equal to zero, \fIitem\fR is moved to the beginning; if greater than or equal to the number of children, it is moved to the end. .RE +.\" METHOD: next .TP \fIpathname \fBnext \fIitem\fR +. Returns the identifier of \fIitem\fR's next sibling, or \fB{}\fR if \fIitem\fR is the last child of its parent. +.\" METHOD: parent .TP \fIpathname \fBparent \fIitem\fR +. Returns the ID of the parent of \fIitem\fR, or \fB{}\fR if \fIitem\fR is at the top level of the hierarchy. +.\" METHOD: prev .TP \fIpathname \fBprev \fIitem\fR +. Returns the identifier of \fIitem\fR's previous sibling, or \fB{}\fR if \fIitem\fR is the first child of its parent. +.\" METHOD: see .TP \fIpathname \fBsee \fIitem\fR +. Ensure that \fIitem\fR is visible: sets all of \fIitem\fR's ancestors to \fB\-open true\fR, and scrolls the widget if necessary so that \fIitem\fR is within the visible portion of the tree. +.\" METHOD: selection .TP \fIpathname \fBselection\fR ?\fIselop itemList\fR? +. Manages item selection. Item selection is independent from cell selection handled by the \fBcellselection\fR command. If \fIselop\fR is not specified, returns the list of selected items. @@ -378,27 +457,35 @@ Otherwise, \fIselop\fR is one of the following: .RS .TP \fIpathname \fBselection set \fIitemList\fR +. \fIitemList\fR becomes the new selection. .TP \fIpathname \fBselection add \fIitemList\fR -Add \fIitemList\fR to the selection +. +Add \fIitemList\fR to the selection. .TP \fIpathname \fBselection remove \fIitemList\fR -Remove \fIitemList\fR from the selection +. +Remove \fIitemList\fR from the selection. .TP \fIpathname \fBselection toggle \fIitemList\fR +. Toggle the selection state of each item in \fIitemList\fR. .RE +.\" METHOD: set .TP \fIpathname \fBset \fIitem\fR ?\fIcolumn\fR? ?\fIvalue\fR? +. With one argument, returns a dictionary of column/value pairs for the specified \fIitem\fR. With two arguments, returns the current value of the specified \fIcolumn\fR. With three arguments, sets the value of column \fIcolumn\fR in item \fIitem\fR to the specified \fIvalue\fR. See also \fBCOLUMN IDENTIFIERS\fR. +.\" METHOD: tag .TP \fIpathName \fBtag \fIargs...\fR +. Manages tags. Tags can be set on items as well as on cells. The set of tags is shared between items and cells. However item tagging is independent from cell tagging (for instance adding a tag on an item does @@ -408,11 +495,13 @@ The following subcommands are supported: .RS .TP \fIpathName \fBtag add \fItag items\fR +. Adds the specified \fItag\fR to each of the listed \fIitems\fR. If \fItag\fR is already present for a particular item, then the \fB\-tags\fR for that item are unchanged. .TP \fIpathName \fBtag bind \fItagName \fR?\fIsequence\fR? ?\fIscript\fR? +. Add a Tk binding script for the event sequence \fIsequence\fR to the tag \fItagName\fR. When an X event is delivered to an item, binding scripts for each of the item's \fB\-tags\fR are evaluated @@ -428,31 +517,36 @@ are sent to the item under the mouse pointer. No other event types are supported. .PP The binding \fIscript\fR undergoes \fB%\fR-substitutions before -evaluation; see \fBbind(n)\fR for details. +evaluation; see \fBbind\fR(n) for details. .RE .TP -\fIpathName \fBtag cell \fIsubcmd...\fR +\fIpathName \fBtag cell \fIsubcommand...\fR +. Manages tags on individual cells. A \fIcellList\fR argument may be a single cell or a list of cells. .RS .TP \fIpathName \fBtag cell add \fItag cellList\fR +. Adds the specified \fItag\fR to each of the listed \fIcellList\fR. If \fItag\fR is already present for a particular cell, then the tag list for that cell is unchanged. .TP \fIpathName \fBtag cell has \fItagName\fR ?\fIcell\fR? +. If \fIcell\fR is specified, returns 1 or 0 depending on whether the specified cell has the named tag. Otherwise, returns a list of all cells which have the specified tag. .TP \fIpathName \fBtag cell remove \fItag\fR ?\fIcellList\fR? +. Removes the specified \fItag\fR from each of the listed \fIcellList\fR. If \fIcellList\fR is omitted, removes \fItag\fR from each cell in the tree. .RE .TP \fIpathName \fBtag configure \fItagName\fR ?\fIoption\fR? ?\fIvalue option value...\fR? +. Query or modify the options for the specified \fItagName\fR. If one or more \fIoption/value\fR pairs are specified, sets the value of those options for the specified tag. @@ -464,21 +558,25 @@ returns a dictionary of the option settings for \fItagName\fR. See \fBTAG OPTIONS\fR for the list of available options. .TP \fIpathName \fBtag delete \fItagName\fR -Deletes all tag information for the \fItagName\fR argument. The -command removes the tag from all items and cells in the widget and also deletes any +. +Deletes all tag information for the \fItagName\fR argument. The command +removes the tag from all items and cells in the widget and also deletes any other information associated with the tag, such as bindings and display information. The command returns an empty string. .TP \fIpathName \fBtag has \fItagName\fR ?\fIitem\fR? +. If \fIitem\fR is specified, returns 1 or 0 depending on whether the specified item has the named tag. Otherwise, returns a list of all items which have the specified tag. .TP \fIpathName \fBtag names\fR +. Returns a list of all tags used by the widget. .TP \fIpathName \fBtag remove \fItag\fR ?\fIitems\fR? +. Removes the specified \fItag\fR from each of the listed \fIitems\fR. If \fIitems\fR is omitted, removes \fItag\fR from each item in the tree. If \fItag\fR is not present for a particular item, @@ -493,10 +591,11 @@ The textual label to display for the item in the tree column. .IP \fB\-height\fR The height for the item, in integer multiples of \fB\-rowheight\fP. Default is 1. .IP \fB\-image\fR -A Tk image, displayed next to the label in the tree column, placed according to \fB-imageanchor\fR. +A Tk image, displayed next to the label in the tree column, placed according +to \fB\-imageanchor\fR. .IP \fB\-imageanchor\fR -Specifies how the \fB-image\fR is displayed relative to the text. Default is \fBw\fR. -One of the standard Tk anchor values. +Specifies how the \fB\-image\fR is displayed relative to the text. +Default is \fBw\fR. One of the standard Tk anchor values. .IP \fB\-values\fR The list of values associated with the item. .RS @@ -533,17 +632,19 @@ Specifies the cell or item image anchor. .IP \fB\-padding\fR Specifies the cell padding. A data cell will have a default padding of {4 0} .IP \fB\-stripedbackground\fR -Specifies the cell or item background color for alternate lines, if \fB\-striped\fR is true. +Specifies the cell or item background color for alternate lines, +if \fB\-striped\fR is true. .PP .\" .PP .\" \fI(@@@ TODO: sort out order of precedence for options)\fR .PP Tags on cells have precedence over tags on items. Then, tag priority is decided by the creation order: tags created first receive higher priority. -An item's options, like \fB\-image\fR and \fB\-imageanchor\fR, have priority over tags. +An item's options, like \fB\-image\fR and \fB\-imageanchor\fR, have priority +over tags. .SH "IMAGES" -The -image option on an item, and on an item tag, controls the image next to the label -in the tree column. +The -image option on an item, and on an item tag, controls the image next to +the label in the tree column. Other cells can have images through the cell tag -image option. .SH "COLUMN IDENTIFIERS" .PP @@ -635,7 +736,7 @@ way to how the default value is set: .PP .CS ttk::style configure Treeview \\ - \-rowheight [expr {[font metrics \fIfont\fP \-linespace] + 2}] + -rowheight [expr {[font metrics \fIfont\fP -linespace] + 2}] .CE .br \fB\-stripedbackground\fP \fIcolor\fP diff --git a/doc/ttk_vsapi.n b/doc/ttk_vsapi.n index af63c39..4b7e3cc 100644 --- a/doc/ttk_vsapi.n +++ b/doc/ttk_vsapi.n @@ -10,7 +10,7 @@ .SH NAME ttk_vsapi \- Define a Microsoft Visual Styles element .SH SYNOPSIS -\fBttk::style element create \fIname\fR \fBvsapi\fR \fIclassName\fR \fIpartId\fR ?\fIstateMap\fR? ?\fIoptions\fR? +\fBttk::style element create \fIname \fBvsapi\fI className partId\fR ?\fIstateMap\fR? ?\fIoptions\fR? .BE .SH DESCRIPTION .PP @@ -21,13 +21,14 @@ on Windows XP and Vista. This factory permits any of the Visual Styles parts to be declared as Ttk elements that can then be included in a style layout to modify the appearance of Ttk widgets. .PP -\fIclassName\fR and \fIpartId\fR are required parameters and specify +The \fIclassName\fR and \fIpartId\fR are required parameters and specify the Visual Styles class and part as given in the Microsoft documentation. The \fIstateMap\fR may be provided to map Ttk states to Visual Styles API states (see \fBSTATE MAP\fR). .SH "OPTIONS" .PP Valid \fIoptions\fR are: +.\" OPTION: -padding .TP \fB\-padding \fIpadding\fR . @@ -38,10 +39,11 @@ If fewer than four elements are specified, \fIbottom\fR defaults to \fItop\fR, \fIright\fR defaults to \fIleft\fR, and \fItop\fR defaults to \fIleft\fR. -In other words, a list of three numbers specify the left, vertical, and right padding; -a list of two numbers specify the horizontal and the vertical padding; +In other words, a list of three numbers specify the left, vertical, and right +padding; a list of two numbers specify the horizontal and the vertical padding; a single number specifies the same padding all the way around the widget. This option may not be mixed with any other options. +.\" OPTION: -margins .TP \fB\-margins \fIpadding\fR . @@ -49,6 +51,7 @@ Specifies the elements exterior padding. \fIpadding\fR is a list of up to four integers specifying the left, top, right and bottom padding quantities respectively. This option may not be mixed with any other options. +.\" OPTION: -width .TP \fB\-width \fIwidth\fR . @@ -57,6 +60,7 @@ the Visual Styles API will not be queried for the recommended size or the part. If this option is set then \fB\-height\fR should also be set. The \fB\-width\fR and \fB\-height\fR options cannot be mixed with the \fB\-padding\fR or \fB\-margins\fR options. +.\" OPTION: -height .TP \fB\-height \fIheight\fR . diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index 7605260..03d45c1 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -125,12 +125,12 @@ If fewer than four elements are specified, \fIbottom\fR defaults to \fItop\fR, \fIright\fR defaults to \fIleft\fR, and \fItop\fR defaults to \fIleft\fR. -In other words, a list of three numbers specify the left, vertical, and right padding; -a list of two numbers specify the horizontal and the vertical padding; +In other words, a list of three numbers specify the left, vertical, and right +padding; a list of two numbers specify the horizontal and the vertical padding; a single number specifies the same padding all the way around the widget. .OP \-text text Text -Specifies a text string to be displayed inside the widget -(unless overridden by \fB\-textvariable\fR for the widgets supporting this option). +Specifies a text string to be displayed inside the widget (unless overridden +by \fB\-textvariable\fR for the widgets supporting this option). .OP \-textvariable textVariable Variable Specifies the name of a global variable whose value will be used in place of the \fB\-text\fR resource. @@ -173,12 +173,16 @@ setting it changes the widget state, but the \fBstate\fR widget command does not affect the \fB\-state\fR option. .SH COMMANDS +.\" METHOD: cget .TP \fIpathName \fBcget \fIoption\fR +. Returns the current value of the configuration option given by \fIoption\fR. +.\" METHOD: configure .TP \fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? +. Query or modify the configuration options of the widget. If one or more \fIoption\-value\fR pairs are specified, then the command modifies the given widget option(s) @@ -192,16 +196,20 @@ and current value. .\" Note: Ttk widgets don't use TK_OPTION_SYNONYM. If no \fIoption\fR is specified, returns a list describing all of the available options for \fIpathName\fR. +.\" METHOD: identify .TP \fIpathName \fBidentify element \fIx y\fR +. Returns the name of the element under the point given by \fIx\fR and \fIy\fR, or an empty string if the point does not lie within any element. \fIx\fR and \fIy\fR are pixel coordinates relative to the widget. Some widgets accept other \fBidentify\fR subcommands described in these widgets documentation. +.\" METHOD: instate .TP \fIpathName \fBinstate \fIstatespec\fR ?\fIscript\fR? +. Test the widget's state. If \fIscript\fR is not specified, returns 1 if the widget state matches \fIstatespec\fR and 0 otherwise. @@ -209,8 +217,10 @@ If \fIscript\fR is specified, equivalent to .CS if {[\fIpathName\fR instate \fIstateSpec\fR]} \fIscript\fR .CE +.\" METHOD: state .TP \fIpathName \fBstate\fR ?\fIstateSpec\fR? +. Modify or inquire widget state. If \fIstateSpec\fR is present, sets the widget state: for each flag in \fIstateSpec\fR, sets the corresponding flag @@ -225,17 +235,22 @@ will restore \fIpathName\fR to the original state. If \fIstateSpec\fR is not specified, returns a list of the currently-enabled state flags. .RE +.\" METHOD: style .TP \fIpathName \fBstyle\fR +. Return the style used by the widget. +.\" METHOD: xview .TP \fIpathName \fBxview \fIargs\fR +. This command is used to query and change the horizontal position of the content in the widget's window. It can take any of the following forms: .RS .TP \fIpathName \fBxview\fR +. Returns a list containing two elements. Each element is a real fraction between 0 and 1; together they describe the horizontal span that is visible in the window. @@ -245,16 +260,19 @@ in the window, and 40% of the content is off-screen to the right. These are the same values passed to scrollbars via the \fB\-xscrollcommand\fR option. .TP -\fIpathName \fBxview\fR \fIindex\fR +\fIpathName \fBxview\fI index\fR +. Adjusts the view in the window so that the content given by \fIindex\fR is displayed at the left edge of the window. .TP \fIpathName \fBxview moveto\fI fraction\fR +. Adjusts the view in the window so that the character \fIfraction\fR of the way through the content appears at the left edge of the window. \fIFraction\fR must be a fraction between 0 and 1. .TP \fIpathName \fBxview scroll \fInumber what\fR +. This command shifts the view in the window left or right according to \fInumber\fR and \fIwhat\fR. \fINumber\fR must be an integer or a float, but if it is a float then @@ -269,14 +287,17 @@ become visible. If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by \fInumber\fR average-width characters on the display. .RE +.\" METHOD: yview .TP \fIpathName \fByview \fIargs\fR +. This command is used to query and change the vertical position of the content in the widget's window. It can take any of the following forms: .RS .TP \fIpathName \fByview\fR +. Returns a list containing two elements. Each element is a real fraction between 0 and 1; together they describe the vertical span that is visible in the window. @@ -286,16 +307,19 @@ in the window, and 40% of the content is off-screen to the bottom. These are the same values passed to scrollbars via the \fB\-yscrollcommand\fR option. .TP -\fIpathName \fByview\fR \fIindex\fR +\fIpathName \fByview\fI index\fR +. Adjusts the view in the window so that the content given by \fIindex\fR is displayed at the top edge of the window. .TP \fIpathName \fByview moveto\fI fraction\fR +. Adjusts the view in the window so that the item \fIfraction\fR of the way through the content appears at the top edge of the window. \fIFraction\fR must be a fraction between 0 and 1. .TP \fIpathName \fByview scroll \fInumber what\fR +. This command shifts the view in the window up or down according to \fInumber\fR and \fIwhat\fR. \fINumber\fR must be an integer or a float, but if it is a float then @@ -313,9 +337,7 @@ If \fIwhat\fR is \fBunits\fR, the view adjusts up or down by .SH "WIDGET STATES" The widget state is a bitmap of independent state flags. Widget state flags include: -.TP -\fBactive\fR -. +.IP \fBactive\fR The mouse cursor is over the widget and pressing a mouse button will cause some action to occur. (aka .QW prelight @@ -323,60 +345,42 @@ and pressing a mouse button will cause some action to occur. (aka .QW hot (Windows), .QW hover ). -.TP -\fBdisabled\fR -. +.IP \fBdisabled\fR Widget is disabled under program control (aka .QW unavailable , .QW inactive ). -.TP -\fBfocus\fR -. +.IP \fBfocus\fR Widget has keyboard focus. -.TP -\fBpressed\fR -. +.IP \fBpressed\fR Widget is being pressed (aka .QW armed in Motif). -.TP -\fBselected\fR -. +.IP \fBselected\fR .QW On , .QW true , or .QW current for things like checkbuttons and radiobuttons. -.TP -\fBbackground\fR -. +.IP \fBbackground\fR Windows and the Mac have a notion of an .QW active or foreground window. The \fBbackground\fR state is set for widgets in a background window, and cleared for those in the foreground window. -.TP -\fBreadonly\fR -. +.IP \fBreadonly\fR Widget should not allow user modification. -.TP -\fBalternate\fR -. +.IP \fBalternate\fR A widget-specific alternate display format. For example, used for checkbuttons and radiobuttons in the .QW tristate or .QW mixed state, and for buttons with \fB\-default active\fR. -.TP -\fBinvalid\fR -. +.IP \fBinvalid\fR The widget's value is invalid. (Potential uses: scale widget value out of bounds, entry widget value failed validation.) -.TP -\fBhover\fR -. +.IP \fBhover\fR The mouse cursor is within the widget. This is similar to the \fBactive\fP state; it is used in some themes for widgets that -- cgit v0.12 From 6f3197009bc5fb6139a0fbee324b215ab0ae174d Mon Sep 17 00:00:00 2001 From: csaba Date: Wed, 1 May 2024 16:39:46 +0000 Subject: Fix for [e306996882]: a few issues related to the arrows in Ttk widgets (scaling-agnostic backport from Tk 9 and 8.7). --- generic/ttk/ttkClamTheme.c | 133 +++++++++++++++++++++++++++----------- generic/ttk/ttkDefaultTheme.c | 145 ++++++++++++++++++++++++++++++++++-------- generic/ttk/ttkElements.c | 138 ++++++++++++++++++++++++++++++++++------ 3 files changed, 330 insertions(+), 86 deletions(-) diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c index 1081c4b..6dbe315 100644 --- a/generic/ttk/ttkClamTheme.c +++ b/generic/ttk/ttkClamTheme.c @@ -198,7 +198,6 @@ static Ttk_ElementSpec BorderElementSpec = { typedef struct { Tcl_Obj *borderColorObj; Tcl_Obj *lightColorObj; - Tcl_Obj *darkColorObj; Tcl_Obj *backgroundObj; } FieldElement; @@ -207,8 +206,6 @@ static Ttk_ElementOptionSpec FieldElementOptions[] = { Tk_Offset(FieldElement,borderColorObj), DARKEST_COLOR }, { "-lightcolor", TK_OPTION_COLOR, Tk_Offset(FieldElement,lightColorObj), LIGHT_COLOR }, - { "-darkcolor", TK_OPTION_COLOR, - Tk_Offset(FieldElement,darkColorObj), DARK_COLOR }, { "-fieldbackground", TK_OPTION_BORDER, Tk_Offset(FieldElement,backgroundObj), "white" }, { NULL, TK_OPTION_BOOLEAN, 0, NULL } @@ -778,27 +775,37 @@ static Ttk_ElementSpec PbarElementSpec = { static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT }; static void ArrowElementSize( - void *dummy, void *elementRecord, Tk_Window tkwin, + void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { ScrollbarElement *sb = (ScrollbarElement *)elementRecord; + ArrowDirection direction = *(ArrowDirection*)clientData; + Ttk_Padding padding = Ttk_UniformPadding(3); int size = SCROLLBAR_THICKNESS; - (void)dummy; (void)tkwin; (void)paddingPtr; Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &size); - *widthPtr = *heightPtr = size; + size -= Ttk_PaddingWidth(padding); + TtkArrowSize(size/2, direction, widthPtr, heightPtr); + *widthPtr += Ttk_PaddingWidth(padding); + *heightPtr += Ttk_PaddingHeight(padding); + if (*widthPtr < *heightPtr) { + *widthPtr = *heightPtr; + } else { + *heightPtr = *widthPtr; + } } static void ArrowElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned state) { - ArrowDirection direction = *(ArrowDirection*)clientData; ScrollbarElement *sb = (ScrollbarElement *)elementRecord; - GC gc = Ttk_GCForColor(tkwin,sb->arrowColorObj, d); - int h, cx, cy; + ArrowDirection direction = *(ArrowDirection*)clientData; + Ttk_Padding padding = Ttk_UniformPadding(3); + int cx, cy; + GC gc = Ttk_GCForColor(tkwin, sb->arrowColorObj, d); DrawSmoothBorder(tkwin, d, b, sb->borderColorObj, sb->lightColorObj, sb->darkColorObj); @@ -807,9 +814,25 @@ static void ArrowElementDraw( Tk_Display(tkwin), d, BackgroundGC(tkwin, sb->backgroundObj), b.x+2, b.y+2, b.width-4, b.height-4); - b = Ttk_PadBox(b, Ttk_UniformPadding(3)); - h = b.width < b.height ? b.width : b.height; - TtkArrowSize(h/2, direction, &cx, &cy); + b = Ttk_PadBox(b, padding); + + switch (direction) { + case ARROW_UP: + case ARROW_DOWN: + TtkArrowSize(b.width/2, direction, &cx, &cy); + if ((b.height - cy) % 2 == 1) { + ++cy; + } + break; + case ARROW_LEFT: + case ARROW_RIGHT: + TtkArrowSize(b.height/2, direction, &cx, &cy); + if ((b.width - cx) % 2 == 1) { + ++cx; + } + break; + } + b = Ttk_AnchorBox(b, cx, cy, TK_ANCHOR_CENTER); TtkFillArrow(Tk_Display(tkwin), d, gc, b, direction); @@ -823,6 +846,36 @@ static Ttk_ElementSpec ArrowElementSpec = { ArrowElementDraw }; +/* + * Modified arrow element for spinboxes: + * The width and height are different. + */ + +static void SpinboxArrowElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) +{ + ScrollbarElement *sb = (ScrollbarElement *)elementRecord; + ArrowDirection direction = *(ArrowDirection*)clientData; + Ttk_Padding padding = Ttk_UniformPadding(3); + int size = 10; + (void)tkwin; + (void)paddingPtr; + + Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &size); + size -= Ttk_PaddingWidth(padding); + TtkArrowSize(size/2, direction, widthPtr, heightPtr); + *widthPtr += Ttk_PaddingWidth(padding); + *heightPtr += Ttk_PaddingHeight(padding); +} + +static Ttk_ElementSpec SpinboxArrowElementSpec = { + TK_STYLE_VERSION_2, + sizeof(ScrollbarElement), + ScrollbarElementOptions, + SpinboxArrowElementSize, + ArrowElementDraw +}; /*------------------------------------------------------------------------ * +++ Notebook elements. @@ -1083,31 +1136,37 @@ TtkClamTheme_Init(Tcl_Interp *interp) return TCL_ERROR; } - Ttk_RegisterElement(interp, - theme, "border", &BorderElementSpec, NULL); - Ttk_RegisterElement(interp, - theme, "field", &FieldElementSpec, NULL); - Ttk_RegisterElement(interp, - theme, "Combobox.field", &ComboboxFieldElementSpec, NULL); - Ttk_RegisterElement(interp, - theme, "trough", &TroughElementSpec, NULL); - Ttk_RegisterElement(interp, - theme, "thumb", &ThumbElementSpec, NULL); - Ttk_RegisterElement(interp, - theme, "uparrow", &ArrowElementSpec, &ArrowElements[0]); - Ttk_RegisterElement(interp, - theme, "downarrow", &ArrowElementSpec, &ArrowElements[1]); - Ttk_RegisterElement(interp, - theme, "leftarrow", &ArrowElementSpec, &ArrowElements[2]); - Ttk_RegisterElement(interp, - theme, "rightarrow", &ArrowElementSpec, &ArrowElements[3]); - - Ttk_RegisterElement(interp, - theme, "Radiobutton.indicator", &RadioIndicatorElementSpec, NULL); - Ttk_RegisterElement(interp, - theme, "Checkbutton.indicator", &CheckIndicatorElementSpec, NULL); - Ttk_RegisterElement(interp, - theme, "Menubutton.indicator", &MenuIndicatorElementSpec, NULL); + Ttk_RegisterElement(interp, theme, "border", + &BorderElementSpec, NULL); + Ttk_RegisterElement(interp, theme, "field", + &FieldElementSpec, NULL); + Ttk_RegisterElement(interp, theme, "Combobox.field", + &ComboboxFieldElementSpec, NULL); + Ttk_RegisterElement(interp, theme, "trough", + &TroughElementSpec, NULL); + Ttk_RegisterElement(interp, theme, "thumb", + &ThumbElementSpec, NULL); + Ttk_RegisterElement(interp, theme, "uparrow", + &ArrowElementSpec, &ArrowElements[0]); + Ttk_RegisterElement(interp, theme, "Spinbox.uparrow", + &SpinboxArrowElementSpec, &ArrowElements[0]); + Ttk_RegisterElement(interp, theme, "downarrow", + &ArrowElementSpec, &ArrowElements[1]); + Ttk_RegisterElement(interp, theme, "Spinbox.downarrow", + &SpinboxArrowElementSpec, &ArrowElements[1]); + Ttk_RegisterElement(interp, theme, "leftarrow", + &ArrowElementSpec, &ArrowElements[2]); + Ttk_RegisterElement(interp, theme, "rightarrow", + &ArrowElementSpec, &ArrowElements[3]); + Ttk_RegisterElement(interp, theme, "arrow", + &ArrowElementSpec, &ArrowElements[0]); + + Ttk_RegisterElement(interp, theme, "Checkbutton.indicator", + &CheckIndicatorElementSpec, NULL); + Ttk_RegisterElement(interp, theme, "Radiobutton.indicator", + &RadioIndicatorElementSpec, NULL); + Ttk_RegisterElement(interp, theme, "Menubutton.indicator", + &MenuIndicatorElementSpec, NULL); Ttk_RegisterElement(interp, theme, "tab", &TabElementSpec, NULL); Ttk_RegisterElement(interp, theme, "client", &ClientElementSpec, NULL); diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c index e4bfeca..b551a83 100644 --- a/generic/ttk/ttkDefaultTheme.c +++ b/generic/ttk/ttkDefaultTheme.c @@ -255,7 +255,7 @@ static Ttk_ElementOptionSpec BorderElementOptions[] = { STRINGIFY(BORDERWIDTH) }, { "-relief", TK_OPTION_RELIEF, Tk_Offset(BorderElement,reliefObj), "flat" }, - { NULL, 0, 0, NULL } + { NULL, 0, 0, NULL } }; static void BorderElementSize( @@ -480,7 +480,7 @@ static Ttk_ElementOptionSpec IndicatorElementOptions[] = { Tk_Offset(IndicatorElement,borderColorObj), "black" }, { "-indicatormargin", TK_OPTION_STRING, Tk_Offset(IndicatorElement,marginObj), "0 2 4 2" }, - { NULL, 0, 0, NULL } + { NULL, 0, 0, NULL } }; static void IndicatorElementSize( @@ -644,25 +644,26 @@ static Ttk_ElementSpec IndicatorElementSpec = { */ static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT }; + typedef struct { Tcl_Obj *sizeObj; + Tcl_Obj *colorObj; /* Arrow color */ Tcl_Obj *borderObj; Tcl_Obj *borderColorObj; /* Extra color for borders */ Tcl_Obj *reliefObj; - Tcl_Obj *colorObj; /* Arrow color */ } ArrowElement; static Ttk_ElementOptionSpec ArrowElementOptions[] = { { "-arrowsize", TK_OPTION_PIXELS, Tk_Offset(ArrowElement,sizeObj), STRINGIFY(SCROLLBAR_WIDTH) }, + { "-arrowcolor", TK_OPTION_COLOR, + Tk_Offset(ArrowElement,colorObj),"black"}, { "-background", TK_OPTION_BORDER, Tk_Offset(ArrowElement,borderObj), DEFAULT_BACKGROUND }, { "-bordercolor", TK_OPTION_COLOR, Tk_Offset(ArrowElement,borderColorObj), "black" }, { "-relief", TK_OPTION_RELIEF, Tk_Offset(ArrowElement,reliefObj),"raised"}, - { "-arrowcolor", TK_OPTION_COLOR, - Tk_Offset(ArrowElement,colorObj),"black"}, { NULL, 0, 0, NULL } }; @@ -679,35 +680,61 @@ static void ArrowElementSize( { ArrowElement *arrow = elementRecord; int direction = *(int *)clientData; - int width = SCROLLBAR_WIDTH; + int size = SCROLLBAR_WIDTH; - Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &width); - width -= Ttk_PaddingWidth(ArrowPadding); - TtkArrowSize(width/2, direction, widthPtr, heightPtr); + Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size); + size -= Ttk_PaddingWidth(ArrowPadding); + TtkArrowSize(size/2, direction, widthPtr, heightPtr); *widthPtr += Ttk_PaddingWidth(ArrowPadding); *heightPtr += Ttk_PaddingHeight(ArrowPadding); + if (*widthPtr < *heightPtr) { + *widthPtr = *heightPtr; + } else { + *heightPtr = *widthPtr; + } } static void ArrowElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { - int direction = *(int *)clientData; ArrowElement *arrow = elementRecord; + int direction = *(int *)clientData; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj); XColor *borderColor = Tk_GetColorFromObj(tkwin, arrow->borderColorObj); + int borderWidth = 2, relief = TK_RELIEF_RAISED; + int cx = 0, cy = 0; XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj); - int relief = TK_RELIEF_RAISED; - int borderWidth = 2; + GC gc = Tk_GCForColor(arrowColor, d); Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief); Tk_Fill3DRectangle( tkwin, d, border, b.x, b.y, b.width, b.height, 0, TK_RELIEF_FLAT); - DrawBorder(tkwin,d,border,borderColor,b,borderWidth,relief); + DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief); + + b = Ttk_PadBox(b, ArrowPadding); - TtkFillArrow(Tk_Display(tkwin), d, Tk_GCForColor(arrowColor, d), - Ttk_PadBox(b, ArrowPadding), direction); + switch (direction) { + case ARROW_UP: + case ARROW_DOWN: + TtkArrowSize(b.width/2, direction, &cx, &cy); + if ((b.height - cy) % 2 == 1) { + ++cy; + } + break; + case ARROW_LEFT: + case ARROW_RIGHT: + TtkArrowSize(b.height/2, direction, &cx, &cy); + if ((b.width - cx) % 2 == 1) { + ++cx; + } + break; + } + + b = Ttk_AnchorBox(b, cx, cy, TK_ANCHOR_CENTER); + + TtkFillArrow(Tk_Display(tkwin), d, gc, b, direction); } static Ttk_ElementSpec ArrowElementSpec = { @@ -718,6 +745,69 @@ static Ttk_ElementSpec ArrowElementSpec = { ArrowElementDraw }; +/* + * Modified arrow element for comboboxes and spinboxes: + * The width and height are different, and the left edge is drawn in the + * same color as the inner part of the right one. + */ + +static void BoxArrowElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) +{ + ArrowElement *arrow = elementRecord; + int direction = *(int *)clientData; + int size = SCROLLBAR_WIDTH; + + Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size); + size -= Ttk_PaddingWidth(ArrowPadding); + TtkArrowSize(size/2, direction, widthPtr, heightPtr); + *widthPtr += Ttk_PaddingWidth(ArrowPadding); + *heightPtr += Ttk_PaddingHeight(ArrowPadding); +} + +static void BoxArrowElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) +{ + ArrowElement *arrow = elementRecord; + int direction = *(int *)clientData; + Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj); + XColor *borderColor = Tk_GetColorFromObj(tkwin, arrow->borderColorObj); + int borderWidth = 2, relief = TK_RELIEF_RAISED; + Display *disp = Tk_Display(tkwin); + GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC); + int w = WIN32_XDRAWLINE_HACK; + int cx = 0, cy = 0; + XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj); + GC arrowGC = Tk_GCForColor(arrowColor, d); + + Tk_Fill3DRectangle( + tkwin, d, border, b.x, b.y, b.width, b.height, 0, TK_RELIEF_FLAT); + DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief); + + XDrawLine(disp, d, darkGC, b.x, b.y+1, b.x, b.y+b.height-2+w); + + b = Ttk_PadBox(b, ArrowPadding); + + TtkArrowSize(b.width/2, direction, &cx, &cy); + if ((b.height - cy) % 2 == 1) { + ++cy; + } + + b = Ttk_AnchorBox(b, cx, cy, TK_ANCHOR_CENTER); + + TtkFillArrow(disp, d, arrowGC, b, direction); +} + +static Ttk_ElementSpec BoxArrowElementSpec = { + TK_STYLE_VERSION_2, + sizeof(ArrowElement), + ArrowElementOptions, + BoxArrowElementSize, + BoxArrowElementDraw +}; + /*---------------------------------------------------------------------- * +++ Menubutton indicator: * Draw an arrow in the direction where the menu will be posted. @@ -974,7 +1064,6 @@ static Ttk_ElementSpec ThumbElementSpec = { */ typedef struct { - Tcl_Obj *lengthObj; /* Long axis dimension */ Tcl_Obj *thicknessObj; /* Short axis dimension */ Tcl_Obj *reliefObj; /* Relief for this object */ Tcl_Obj *borderObj; /* Border / background color */ @@ -984,18 +1073,16 @@ typedef struct { } SliderElement; static Ttk_ElementOptionSpec SliderElementOptions[] = { - { "-sliderlength", TK_OPTION_PIXELS, Tk_Offset(SliderElement,lengthObj), - "15" }, { "-sliderthickness",TK_OPTION_PIXELS,Tk_Offset(SliderElement,thicknessObj), "15" }, { "-sliderrelief", TK_OPTION_RELIEF, Tk_Offset(SliderElement,reliefObj), "raised" }, - { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(SliderElement,borderWidthObj), - STRINGIFY(BORDERWIDTH) }, { "-background", TK_OPTION_BORDER, Tk_Offset(SliderElement,borderObj), DEFAULT_BACKGROUND }, - { "-bordercolor", TK_OPTION_COLOR, Tk_Offset(ThumbElement,borderColorObj), + { "-bordercolor", TK_OPTION_COLOR, Tk_Offset(SliderElement,borderColorObj), "black" }, + { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(SliderElement,borderWidthObj), + STRINGIFY(BORDERWIDTH) }, { "-orient", TK_OPTION_ANY, Tk_Offset(SliderElement,orientObj), "horizontal" }, { NULL, 0, 0, NULL } @@ -1006,12 +1093,11 @@ static void SliderElementSize( int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { SliderElement *slider = elementRecord; - int orient, length, thickness, borderWidth; + int orient, thickness, borderWidth; Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient); - Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth); - Tk_GetPixelsFromObj(NULL, tkwin, slider->lengthObj, &length); Tk_GetPixelsFromObj(NULL, tkwin, slider->thicknessObj, &thickness); + Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth); switch (orient) { case TTK_ORIENT_VERTICAL: @@ -1083,8 +1169,8 @@ static void TreeitemIndicatorSize( int diameter = 0; Ttk_Padding margins; - Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins); Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter); + Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins); *widthPtr = diameter + Ttk_PaddingWidth(margins); *heightPtr = diameter + Ttk_PaddingHeight(margins); } @@ -1158,8 +1244,14 @@ MODULE_SCOPE int TtkAltTheme_Init(Tcl_Interp *interp) Ttk_RegisterElement(interp, theme, "uparrow", &ArrowElementSpec, &ArrowElements[0]); + Ttk_RegisterElement(interp, theme, "Spinbox.uparrow", + &BoxArrowElementSpec, &ArrowElements[0]); Ttk_RegisterElement(interp, theme, "downarrow", &ArrowElementSpec, &ArrowElements[1]); + Ttk_RegisterElement(interp, theme, "Spinbox.downarrow", + &BoxArrowElementSpec, &ArrowElements[1]); + Ttk_RegisterElement(interp, theme, "Combobox.downarrow", + &BoxArrowElementSpec, &ArrowElements[1]); Ttk_RegisterElement(interp, theme, "leftarrow", &ArrowElementSpec, &ArrowElements[2]); Ttk_RegisterElement(interp, theme, "rightarrow", @@ -1167,9 +1259,6 @@ MODULE_SCOPE int TtkAltTheme_Init(Tcl_Interp *interp) Ttk_RegisterElement(interp, theme, "arrow", &ArrowElementSpec, &ArrowElements[0]); - Ttk_RegisterElement(interp, theme, "arrow", - &ArrowElementSpec, &ArrowElements[0]); - Ttk_RegisterElement(interp, theme, "Treeitem.indicator", &TreeitemIndicatorElementSpec, 0); diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c index 2520ced..beb3225 100644 --- a/generic/ttk/ttkElements.c +++ b/generic/ttk/ttkElements.c @@ -704,29 +704,30 @@ static Ttk_ElementSpec MenuIndicatorElementSpec = { */ static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT }; + typedef struct { + Tcl_Obj *sizeObj; + Tcl_Obj *colorObj; Tcl_Obj *borderObj; Tcl_Obj *borderWidthObj; Tcl_Obj *reliefObj; - Tcl_Obj *sizeObj; - Tcl_Obj *colorObj; } ArrowElement; static Ttk_ElementOptionSpec ArrowElementOptions[] = { + { "-arrowsize", TK_OPTION_PIXELS, + Tk_Offset(ArrowElement,sizeObj), "14" }, + { "-arrowcolor",TK_OPTION_COLOR, + Tk_Offset(ArrowElement,colorObj),"black"}, { "-background", TK_OPTION_BORDER, Tk_Offset(ArrowElement,borderObj), DEFAULT_BACKGROUND }, - { "-relief",TK_OPTION_RELIEF, - Tk_Offset(ArrowElement,reliefObj),"raised"}, { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(ArrowElement,borderWidthObj), "1" }, - { "-arrowcolor",TK_OPTION_COLOR, - Tk_Offset(ArrowElement,colorObj),"black"}, - { "-arrowsize", TK_OPTION_PIXELS, - Tk_Offset(ArrowElement,sizeObj), "14" }, + { "-relief",TK_OPTION_RELIEF, + Tk_Offset(ArrowElement,reliefObj),"raised"}, { NULL, 0, 0, NULL } }; -static Ttk_Padding ArrowMargins = { 3,3,3,3 }; +static Ttk_Padding ArrowPadding = { 3,3,3,3 }; static void ArrowElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, @@ -734,33 +735,60 @@ static void ArrowElementSize( { ArrowElement *arrow = elementRecord; int direction = *(int *)clientData; - int width = 14; - - Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &width); - width -= Ttk_PaddingWidth(ArrowMargins); - TtkArrowSize(width/2, direction, widthPtr, heightPtr); - *widthPtr += Ttk_PaddingWidth(ArrowMargins); - *heightPtr += Ttk_PaddingWidth(ArrowMargins); + int size = 14; + + Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size); + size -= Ttk_PaddingWidth(ArrowPadding); + TtkArrowSize(size/2, direction, widthPtr, heightPtr); + *widthPtr += Ttk_PaddingWidth(ArrowPadding); + *heightPtr += Ttk_PaddingWidth(ArrowPadding); + if (*widthPtr < *heightPtr) { + *widthPtr = *heightPtr; + } else { + *heightPtr = *widthPtr; + } } static void ArrowElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { - int direction = *(int *)clientData; ArrowElement *arrow = elementRecord; + int direction = *(int *)clientData; Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj); + int borderWidth = 1, relief = TK_RELIEF_RAISED; + int cx = 0, cy = 0; XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj); - int relief = TK_RELIEF_RAISED; - int borderWidth = 1; + GC gc = Tk_GCForColor(arrowColor, d); + Tk_GetPixelsFromObj(NULL, tkwin, arrow->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief); Tk_Fill3DRectangle( tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, relief); - TtkFillArrow(Tk_Display(tkwin), d, Tk_GCForColor(arrowColor, d), - Ttk_PadBox(b, ArrowMargins), direction); + b = Ttk_PadBox(b, ArrowPadding); + + switch (direction) { + case ARROW_UP: + case ARROW_DOWN: + TtkArrowSize(b.width/2, direction, &cx, &cy); + if ((b.height - cy) % 2 == 1) { + ++cy; + } + break; + case ARROW_LEFT: + case ARROW_RIGHT: + TtkArrowSize(b.height/2, direction, &cx, &cy); + if ((b.width - cx) % 2 == 1) { + ++cx; + } + break; + } + + b = Ttk_AnchorBox(b, cx, cy, TK_ANCHOR_CENTER); + + TtkFillArrow(Tk_Display(tkwin), d, gc, b, direction); } static Ttk_ElementSpec ArrowElementSpec = { @@ -771,6 +799,68 @@ static Ttk_ElementSpec ArrowElementSpec = { ArrowElementDraw }; +/* + * Modified arrow element for comboboxes and spinboxes: + * The width and height are different, and the left edge is drawn in the + * same color as the right one. + */ + +static void BoxArrowElementSize( + void *clientData, void *elementRecord, Tk_Window tkwin, + int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) +{ + ArrowElement *arrow = elementRecord; + int direction = *(int *)clientData; + int size = 14; + + Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size); + size -= Ttk_PaddingWidth(ArrowPadding); + TtkArrowSize(size/2, direction, widthPtr, heightPtr); + *widthPtr += Ttk_PaddingWidth(ArrowPadding); + *heightPtr += Ttk_PaddingWidth(ArrowPadding); +} + +static void BoxArrowElementDraw( + void *clientData, void *elementRecord, Tk_Window tkwin, + Drawable d, Ttk_Box b, unsigned int state) +{ + ArrowElement *arrow = elementRecord; + int direction = *(int *)clientData; + Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj); + int borderWidth = 1, relief = TK_RELIEF_RAISED; + Display *disp = Tk_Display(tkwin); + GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC); + int w = WIN32_XDRAWLINE_HACK; + int cx = 0, cy = 0; + XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj); + GC arrowGC = Tk_GCForColor(arrowColor, d); + + Tk_Fill3DRectangle( + tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, relief); + + XDrawLine(disp, d, darkGC, b.x, b.y+1, b.x, b.y+b.height-1+w); + + b = Ttk_PadBox(b, ArrowPadding); + + TtkArrowSize(b.width/2, direction, &cx, &cy); + if ((b.height - cy) % 2 == 1) { + ++cy; + } + + b = Ttk_AnchorBox(b, cx, cy, TK_ANCHOR_CENTER); + + TtkFillArrow(disp, d, arrowGC, b, direction); +} + +static Ttk_ElementSpec BoxArrowElementSpec = { + TK_STYLE_VERSION_2, + sizeof(ArrowElement), + ArrowElementOptions, + BoxArrowElementSize, + BoxArrowElementDraw +}; + + /*---------------------------------------------------------------------- * +++ Trough element. * @@ -1343,8 +1433,14 @@ void TtkElements_Init(Tcl_Interp *interp) Ttk_RegisterElement(interp, theme, "uparrow", &ArrowElementSpec, &ArrowElements[0]); + Ttk_RegisterElement(interp, theme, "Spinbox.uparrow", + &BoxArrowElementSpec, &ArrowElements[0]); Ttk_RegisterElement(interp, theme, "downarrow", &ArrowElementSpec, &ArrowElements[1]); + Ttk_RegisterElement(interp, theme, "Spinbox.downarrow", + &BoxArrowElementSpec, &ArrowElements[1]); + Ttk_RegisterElement(interp, theme, "Combobox.downarrow", + &BoxArrowElementSpec, &ArrowElements[1]); Ttk_RegisterElement(interp, theme, "leftarrow", &ArrowElementSpec, &ArrowElements[2]); Ttk_RegisterElement(interp, theme, "rightarrow", -- cgit v0.12 From 280afa1e07cb7f084bfd041f2035deb5c5761420 Mon Sep 17 00:00:00 2001 From: csaba Date: Wed, 1 May 2024 17:20:51 +0000 Subject: Widget Demo: added demo script for ttk::spinbox widgets. --- library/demos/spin.tcl | 12 ++---------- library/demos/ttkspin.tcl | 49 +++++++++++++++++++++++++++++++++++++++++++++++ library/demos/widget | 1 + 3 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 library/demos/ttkspin.tcl diff --git a/library/demos/spin.tcl b/library/demos/spin.tcl index d897e6d..891f5be 100644 --- a/library/demos/spin.tcl +++ b/library/demos/spin.tcl @@ -38,16 +38,8 @@ set australianCities { } spinbox $w.s1 -from 1 -to 10 -width 10 -validate key \ - -vcmd {string is integer %P} + -validatecommand {string is integer %P} spinbox $w.s2 -from 0 -to 3 -increment .5 -format %05.2f -width 10 spinbox $w.s3 -values $australianCities -width 10 -#entry $w.e1 -#entry $w.e2 -#entry $w.e3 -pack $w.s1 $w.s2 $w.s3 -side top -pady 5 -padx 10 ;#-fill x - -#$w.e1 insert 0 "Initial value" -#$w.e2 insert end "This entry contains a long value, much too long " -#$w.e2 insert end "to fit in the window at one time, so long in fact " -#$w.e2 insert end "that you'll have to scan or scroll to see the end." +pack $w.s1 $w.s2 $w.s3 -side top -pady 5 -padx 10 diff --git a/library/demos/ttkspin.tcl b/library/demos/ttkspin.tcl new file mode 100644 index 0000000..ce5925d --- /dev/null +++ b/library/demos/ttkspin.tcl @@ -0,0 +1,49 @@ +# ttkspin.tcl -- +# +# This demonstration script creates several Ttk spinbox widgets. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .ttkspin +catch {destroy $w} +toplevel $w +wm title $w "Themed Spinbox Demonstration" +wm iconname $w "ttkspin" +positionWindow $w + +label $w.msg -font $font -wraplength 5i -justify left -text "Three different\ + themed spin-boxes are displayed below. You can add characters by\ + pointing, clicking and typing. The normal Motif editing characters\ + are supported, along with many Emacs bindings. For example, Backspace\ + and Control-h delete the character to the left of the insertion\ + cursor and Delete and Control-d delete the chararacter to the right\ + of the insertion cursor. For values that are too large to fit in the\ + window all at once, you can scan through the value by dragging with\ + mouse button2 pressed. Note that the first spin-box will only permit\ + you to type in integers, and the third selects from a list of\ + Australian cities." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +set australianCities { + Canberra Sydney Melbourne Perth Adelaide Brisbane + Hobart Darwin "Alice Springs" +} + +ttk::spinbox $w.s1 -from 1 -to 10 -width 10 -validate key \ + -validatecommand {string is integer %P} +ttk::spinbox $w.s2 -from 0 -to 3 -increment .5 -format %05.2f -width 10 +ttk::spinbox $w.s3 -values $australianCities -width 10 + +$w.s1 set 1 +$w.s2 set 00.00 +$w.s3 set Canberra + +pack $w.s1 $w.s2 $w.s3 -side top -pady 5 -padx 10 diff --git a/library/demos/widget b/library/demos/widget index b37c70c..59a8d34 100644 --- a/library/demos/widget +++ b/library/demos/widget @@ -342,6 +342,7 @@ addFormattedText { @@demo entry2 Entries with scrollbars @@demo entry3 Validated entries and password fields @@demo spin Spin-boxes + @@demo ttkspin Themed spin-boxes @@demo combo Combo-boxes @@demo form Simple Rolodex-like form -- cgit v0.12 From 1c045c9af99ef4e4a27f4391091dfde1b39d07b5 Mon Sep 17 00:00:00 2001 From: csaba Date: Wed, 1 May 2024 17:23:59 +0000 Subject: Widget Demo: added demo script for ttk::spinbox widgets. --- library/demos/spin.tcl | 10 +--------- library/demos/ttkspin.tcl | 49 +++++++++++++++++++++++++++++++++++++++++++++++ library/demos/widget | 1 + 3 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 library/demos/ttkspin.tcl diff --git a/library/demos/spin.tcl b/library/demos/spin.tcl index b08ed16..b9a7ac1 100644 --- a/library/demos/spin.tcl +++ b/library/demos/spin.tcl @@ -42,12 +42,4 @@ spinbox $w.s1 -from 1 -to 10 -width 10 -validate key \ spinbox $w.s2 -from 0 -to 3 -increment .5 -format %05.2f -width 10 spinbox $w.s3 -values $australianCities -width 10 -#entry $w.e1 -#entry $w.e2 -#entry $w.e3 -pack $w.s1 $w.s2 $w.s3 -side top -pady 3p -padx 7.5p ;#-fill x - -#$w.e1 insert 0 "Initial value" -#$w.e2 insert end "This entry contains a long value, much too long " -#$w.e2 insert end "to fit in the window at one time, so long in fact " -#$w.e2 insert end "that you'll have to scan or scroll to see the end." +pack $w.s1 $w.s2 $w.s3 -side top -pady 3p -padx 7.5p diff --git a/library/demos/ttkspin.tcl b/library/demos/ttkspin.tcl new file mode 100644 index 0000000..83e5449 --- /dev/null +++ b/library/demos/ttkspin.tcl @@ -0,0 +1,49 @@ +# ttkspin.tcl -- +# +# This demonstration script creates several Ttk spinbox widgets. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .ttkspin +catch {destroy $w} +toplevel $w +wm title $w "Themed Spinbox Demonstration" +wm iconname $w "ttkspin" +positionWindow $w + +label $w.msg -font $font -wraplength 5i -justify left -text "Three different\ + themed spin-boxes are displayed below. You can add characters by\ + pointing, clicking and typing. The normal Motif editing characters\ + are supported, along with many Emacs bindings. For example, Backspace\ + and Control-h delete the character to the left of the insertion\ + cursor and Delete and Control-d delete the chararacter to the right\ + of the insertion cursor. For values that are too large to fit in the\ + window all at once, you can scan through the value by dragging with\ + mouse button2 pressed. Note that the first spin-box will only permit\ + you to type in integers, and the third selects from a list of\ + Australian cities." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +set australianCities { + Canberra Sydney Melbourne Perth Adelaide Brisbane + Hobart Darwin "Alice Springs" +} + +ttk::spinbox $w.s1 -from 1 -to 10 -width 10 -validate key \ + -validatecommand {string is integer %P} +ttk::spinbox $w.s2 -from 0 -to 3 -increment .5 -format %05.2f -width 10 +ttk::spinbox $w.s3 -values $australianCities -width 10 + +$w.s1 set 1 +$w.s2 set 00.00 +$w.s3 set Canberra + +pack $w.s1 $w.s2 $w.s3 -side top -pady 3p -padx 7.5p diff --git a/library/demos/widget b/library/demos/widget index 51ef220..9e7c234 100644 --- a/library/demos/widget +++ b/library/demos/widget @@ -386,6 +386,7 @@ addFormattedText { @@demo entry2 Entries with scrollbars @@demo entry3 Validated entries and password fields @@demo spin Spin-boxes + @@demo ttkspin Themed spin-boxes @@demo combo Combo-boxes @@demo form Simple Rolodex-like form -- cgit v0.12