summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorhobbs <hobbs>2006-09-06 22:39:28 (GMT)
committerhobbs <hobbs>2006-09-06 22:39:28 (GMT)
commit76db84f0e28288ac0e6da5dc33d1a97626efcf54 (patch)
tree2ba9cc0bf93a726ed5be5bd91f8d50a43b16fb71 /generic
parent94edca83e594d771323cb9f0b5a4e1e0d03d8dc5 (diff)
downloadtk-76db84f0e28288ac0e6da5dc33d1a97626efcf54.zip
tk-76db84f0e28288ac0e6da5dc33d1a97626efcf54.tar.gz
tk-76db84f0e28288ac0e6da5dc33d1a97626efcf54.tar.bz2
* generic/tkEntry.c: move hard-coded ALWAYS_SHOW_SELECTION
* generic/tkInt.h: control of entry/text selection display * generic/tkText.c: based on focus to the Tcl level, * generic/tkWindow.c: controlled by ::tk::AlwaysShowSelection * library/tk.tcl: (boolean, private). [Bug 1553691] * macosx/tkMacOSXDefault.h: * unix/tkUnixDefault.h: * unix/tkUnixPort.h: * win/tkWinDefault.h:
Diffstat (limited to 'generic')
-rw-r--r--generic/tkEntry.c23
-rw-r--r--generic/tkInt.h5
-rw-r--r--generic/tkText.c43
-rw-r--r--generic/tkWindow.c41
4 files changed, 76 insertions, 36 deletions
diff --git a/generic/tkEntry.c b/generic/tkEntry.c
index 6f97c0c..1d9d084 100644
--- a/generic/tkEntry.c
+++ b/generic/tkEntry.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkEntry.c,v 1.39 2005/11/17 10:57:35 dkf Exp $
+ * RCS: @(#) $Id: tkEntry.c,v 1.40 2006/09/06 22:39:28 hobbs Exp $
*/
#include "tkInt.h"
@@ -1602,15 +1602,14 @@ DisplayEntry(
baseY = (Tk_Height(tkwin) + fm.ascent - fm.descent) / 2;
/*
- * On Windows and Mac, we need to hide the selection whenever we don't
- * have the focus.
+ * Hide the selection whenever we don't have the focus, unless we
+ * always want to show selection.
*/
-
-#ifdef ALWAYS_SHOW_SELECTION
- showSelection = 1;
-#else
- showSelection = (entryPtr->flags & GOT_FOCUS);
-#endif
+ if (TkpAlwaysShowSelection(entryPtr->tkwin)) {
+ showSelection = 1;
+ } else {
+ showSelection = (entryPtr->flags & GOT_FOCUS);
+ }
/*
* Draw the background in three layers. From bottom to top the layers are:
@@ -2790,15 +2789,15 @@ EntryLostSelection(
* On Windows and Mac systems, we want to remember the selection for the
* next time the focus enters the window. On Unix, we need to clear the
* selection since it is always visible.
+ * This is controlled by ::tk::AlwaysShowSelection.
*/
-#ifdef ALWAYS_SHOW_SELECTION
- if ((entryPtr->selectFirst >= 0) && entryPtr->exportSelection) {
+ if (TkpAlwaysShowSelection(entryPtr->tkwin)
+ && (entryPtr->selectFirst >= 0) && entryPtr->exportSelection) {
entryPtr->selectFirst = -1;
entryPtr->selectLast = -1;
EventuallyRedraw(entryPtr);
}
-#endif
}
/*
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 40d1272..3ad218e 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: $Id: tkInt.h,v 1.72 2006/08/18 10:24:41 dkf Exp $
+ * RCS: $Id: tkInt.h,v 1.73 2006/09/06 22:39:28 hobbs Exp $
*/
#ifndef _TKINT
@@ -651,6 +651,8 @@ typedef struct TkMainInfo {
* structures. Managed by tkImage.c. */
int strictMotif; /* This is linked to the tk_strictMotif global
* variable. */
+ int alwaysShowSelection; /* This is linked to the
+ * ::tk::AlwaysShowSelection variable. */
struct TkMainInfo *nextPtr; /* Next in list of all main windows managed by
* this process. */
} TkMainInfo;
@@ -1159,6 +1161,7 @@ MODULE_SCOPE void TkPrintPadAmount(Tcl_Interp *interp,
MODULE_SCOPE int TkParsePadAmount(Tcl_Interp *interp,
Tk_Window tkwin, Tcl_Obj *objPtr,
int *pad1Ptr, int *pad2Ptr);
+MODULE_SCOPE int TkpAlwaysShowSelection(Tk_Window tkwin);
MODULE_SCOPE void TkpDrawCharsInContext(Display * display,
Drawable drawable, GC gc, Tk_Font tkfont,
const char * source, int numBytes, int rangeStart,
diff --git a/generic/tkText.c b/generic/tkText.c
index aeb40bb..56e016f 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkText.c,v 1.68 2006/04/05 17:16:29 vincentdarley Exp $
+ * RCS: @(#) $Id: tkText.c,v 1.69 2006/09/06 22:39:28 hobbs Exp $
*/
#include "default.h"
@@ -160,11 +160,7 @@ static Tk_OptionSpec optionSpecs[] = {
Tk_Offset(TkText, highlightWidth), 0, 0, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_BORDER, "-inactiveselectbackground", "inactiveSelectBackground",
"Foreground",
-#ifdef ALWAYS_SHOW_SELECTION
- DEF_TEXT_SELECT_COLOR,
-#else
- NULL,
-#endif
+ DEF_TEXT_INACTIVE_SELECT_COLOR,
-1, Tk_Offset(TkText, inactiveSelBorder),
TK_OPTION_NULL_OK, (ClientData) DEF_TEXT_SELECT_MONO, 0},
{TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground",
@@ -3316,25 +3312,28 @@ TkTextLostSelection(clientData)
ClientData clientData; /* Information about text widget. */
{
register TkText *textPtr = (TkText *) clientData;
-#ifdef ALWAYS_SHOW_SELECTION
- TkTextIndex start, end;
- if (!textPtr->exportSelection) {
- return;
- }
+ if (TkpAlwaysShowSelection(textPtr->tkwin)) {
+ TkTextIndex start, end;
- /*
- * On Windows and Mac systems, we want to remember the selection for the
- * next time the focus enters the window. On Unix, just remove the "sel"
- * tag from everything in the widget.
- */
+ if (!textPtr->exportSelection) {
+ return;
+ }
- TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr, 0, 0, &start);
- TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr,
- TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), 0, &end);
- TkTextRedrawTag(NULL, textPtr, &start, &end, textPtr->selTagPtr, 1);
- TkBTreeTag(&start, &end, textPtr->selTagPtr, 0);
-#endif
+ /*
+ * On Windows and Mac systems, we want to remember the selection for
+ * the next time the focus enters the window. On Unix, just remove the
+ * "sel" tag from everything in the widget.
+ */
+
+ TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr,
+ 0, 0, &start);
+ TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr,
+ TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr),
+ 0, &end);
+ TkTextRedrawTag(NULL, textPtr, &start, &end, textPtr->selTagPtr, 1);
+ TkBTreeTag(&start, &end, textPtr->selTagPtr, 0);
+ }
/*
* Send an event that the selection changed. This is equivalent to:
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 324ed0c..e3c5295 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWindow.c,v 1.75 2006/07/14 18:25:14 andreas_kupries Exp $
+ * RCS: @(#) $Id: tkWindow.c,v 1.76 2006/09/06 22:39:28 hobbs Exp $
*/
#include "tkPort.h"
@@ -888,10 +888,19 @@ TkCreateMainWindow(interp, screenName, baseName)
mainPtr->optionRootPtr = NULL;
Tcl_InitHashTable(&mainPtr->imageTable, TCL_STRING_KEYS);
mainPtr->strictMotif = 0;
+ mainPtr->alwaysShowSelection = 0;
if (Tcl_LinkVar(interp, "tk_strictMotif", (char *) &mainPtr->strictMotif,
TCL_LINK_BOOLEAN) != TCL_OK) {
Tcl_ResetResult(interp);
}
+ if (Tcl_CreateNamespace(interp, "::tk", NULL, NULL) == NULL) {
+ Tcl_ResetResult(interp);
+ }
+ if (Tcl_LinkVar(interp, "::tk::AlwaysShowSelection",
+ (char *) &mainPtr->alwaysShowSelection,
+ TCL_LINK_BOOLEAN) != TCL_OK) {
+ Tcl_ResetResult(interp);
+ }
mainPtr->nextPtr = tsdPtr->mainWindowList;
tsdPtr->mainWindowList = mainPtr;
winPtr->mainPtr = mainPtr;
@@ -1502,6 +1511,8 @@ Tk_DestroyWindow(tkwin)
TkDeadAppCmd, (ClientData) NULL,
(void (*) _ANSI_ARGS_((ClientData))) NULL);
Tcl_UnlinkVar(winPtr->mainPtr->interp, "tk_strictMotif");
+ Tcl_UnlinkVar(winPtr->mainPtr->interp,
+ "::tk::AlwaysShowSelection");
}
Tcl_DeleteHashTable(&winPtr->mainPtr->nameTable);
@@ -2652,6 +2663,34 @@ Tk_GetNumMainWindows()
/*
*----------------------------------------------------------------------
*
+ * TkpAlwaysShowSelection --
+ *
+ * Indicates whether text/entry widgets should always display
+ * their selection, regardless of window focus.
+ *
+ * Results:
+ * The return value is 1 if always showing the selection has been
+ * requested for tkwin's application by setting the
+ * ::tk::AlwaysShowSelection variable in its interpreter to a true value.
+ * 0 is returned if it has a false value.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TkpAlwaysShowSelection(tkwin)
+ Tk_Window tkwin; /* Window whose application is
+ * to be checked. */
+{
+ return ((TkWindow *) tkwin)->mainPtr->alwaysShowSelection;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* DeleteWindowsExitProc --
*
* This function is invoked as an exit handler. It deletes all of the