summaryrefslogtreecommitdiffstats
path: root/generic/tkTreeColumn.c
diff options
context:
space:
mode:
authortreectrl <treectrl>2006-11-19 23:35:42 (GMT)
committertreectrl <treectrl>2006-11-19 23:35:42 (GMT)
commite39173d0d1fe65e90631600151d7bab711628f09 (patch)
tree1107cbb0ccffb70cf71f2ee21f9cd9a1248079af /generic/tkTreeColumn.c
parentcf436c12cdc13de9e5e3bbe5b8d546e3a14169e5 (diff)
downloadtktreectrl-e39173d0d1fe65e90631600151d7bab711628f09.zip
tktreectrl-e39173d0d1fe65e90631600151d7bab711628f09.tar.gz
tktreectrl-e39173d0d1fe65e90631600151d7bab711628f09.tar.bz2
Fixed drawing of the drag indicator so it does not appear over columns with a different -lock option.
Changed the -background option to use DEF_BUTTON_ACTIVE_BG_COLOR when the mouse is over a column header.
Diffstat (limited to 'generic/tkTreeColumn.c')
-rw-r--r--generic/tkTreeColumn.c98
1 files changed, 73 insertions, 25 deletions
diff --git a/generic/tkTreeColumn.c b/generic/tkTreeColumn.c
index 710d288..0265173 100644
--- a/generic/tkTreeColumn.c
+++ b/generic/tkTreeColumn.c
@@ -7,7 +7,7 @@
* Copyright (c) 2002-2003 Christian Krone
* Copyright (c) 2003 ActiveState Corporation
*
- * RCS: @(#) $Id: tkTreeColumn.c,v 1.66 2006/11/18 04:34:50 treectrl Exp $
+ * RCS: @(#) $Id: tkTreeColumn.c,v 1.67 2006/11/19 23:35:42 treectrl Exp $
*/
#include "tkTreeCtrl.h"
@@ -304,7 +304,7 @@ static Tk_OptionSpec columnSpecs[] = {
/* NOTE: -background is a per-state option, so DEF_BUTTON_BG_COLOR
* must be a list of one element */
{TK_OPTION_CUSTOM, "-background", (char *) NULL, (char *) NULL,
- DEF_BUTTON_BG_COLOR,
+ (char *) NULL /* initialized later */,
Tk_Offset(TreeColumn_, border.obj), Tk_Offset(TreeColumn_, border),
0, (ClientData) NULL, COLU_CONF_DISPLAY},
{TK_OPTION_BITMAP, "-bitmap", (char *) NULL, (char *) NULL,
@@ -4617,6 +4617,52 @@ SetImageForColumn(
}
static void
+DrawDragIndicator(
+ TreeCtrl *tree, /* Widget info. */
+ Drawable drawable, /* Where to draw. */
+ int lock
+ )
+{
+ TreeColumn column = tree->columnDrag.indColumn;
+ int x, y, w, h;
+ int minX = 0, maxX = 0;
+ GC gc;
+
+ if ((column == NULL) || (column->lock != lock))
+ return;
+
+ switch (lock) {
+ case COLUMN_LOCK_LEFT:
+ minX = Tree_HeaderLeft(tree);
+ maxX = Tree_ContentLeft(tree);
+ break;
+ case COLUMN_LOCK_NONE:
+ minX = Tree_ContentLeft(tree);
+ maxX = Tree_ContentRight(tree);
+ break;
+ case COLUMN_LOCK_RIGHT:
+ minX = Tree_ContentRight(tree);
+ maxX = Tree_HeaderRight(tree);
+ break;
+ }
+
+ if (TreeColumn_Bbox(column, &x, &y, &w, &h) == 0) {
+ if (tree->columnDrag.indSide == SIDE_LEFT) {
+ x -= 1;
+ if (x == minX - 1)
+ x += 1;
+ } else {
+ x += w - 1;
+ if (x == maxX - 1)
+ x -= 1;
+ }
+ gc = Tk_GCForColor(tree->columnDrag.indColor, Tk_WindowId(tree->tkwin));
+ XFillRectangle(tree->display, drawable, gc,
+ x, y, 2, tree->headerHeight);
+ }
+}
+
+static void
DrawHeaderLeft(
TreeCtrl *tree, /* Widget info. */
Drawable drawable /* Where to draw. */
@@ -4638,6 +4684,8 @@ DrawHeaderLeft(
column = column->next;
}
+ DrawDragIndicator(tree, pixmap, COLUMN_LOCK_LEFT);
+
XCopyArea(tree->display, pixmap, drawable,
tree->copyGC, Tree_HeaderLeft(tree), y,
x - Tree_HeaderLeft(tree), tree->headerHeight,
@@ -4654,7 +4702,7 @@ DrawHeaderRight(
{
TreeColumn column = tree->columnLockRight;
Tk_Window tkwin = tree->tkwin;
- int x = 0, y = Tree_HeaderTop(tree);
+ int x = Tree_ContentRight(tree), y = Tree_HeaderTop(tree);
Drawable pixmap;
pixmap = Tk_GetPixmap(tree->display, Tk_WindowId(tkwin),
@@ -4668,9 +4716,11 @@ DrawHeaderRight(
column = column->next;
}
+ DrawDragIndicator(tree, pixmap, COLUMN_LOCK_RIGHT);
+
XCopyArea(tree->display, pixmap, drawable,
- tree->copyGC, 0, y,
- x, tree->headerHeight,
+ tree->copyGC, Tree_ContentRight(tree), y,
+ x - Tree_ContentRight(tree), tree->headerHeight,
Tree_ContentRight(tree), y);
Tk_FreePixmap(tree->display, pixmap);
@@ -4748,31 +4798,14 @@ Tree_DrawHeader(
}
}
+ if (minX < maxX)
+ DrawDragIndicator(tree, pixmap, COLUMN_LOCK_NONE);
+
if (Tree_WidthOfLeftColumns(tree) > 0)
DrawHeaderLeft(tree, pixmap);
if (Tree_WidthOfRightColumns(tree) > 0)
DrawHeaderRight(tree, pixmap);
- if (tree->columnDrag.indColumn != NULL) {
- int x, y, w, h;
- GC gc;
-
- if (TreeColumn_Bbox(tree->columnDrag.indColumn, &x, &y, &w, &h) == 0) {
- if (tree->columnDrag.indSide == SIDE_LEFT) {
- x -= 1;
- if (x == Tree_HeaderLeft(tree) - 1)
- x += 1;
- } else {
- x += w - 1;
- if (x == Tree_HeaderRight(tree) - 1)
- x -= 1;
- }
- gc = Tk_GCForColor(tree->columnDrag.indColor, Tk_WindowId(tree->tkwin));
- XFillRectangle(tree->display, pixmap, gc,
- x, y, 2, tree->headerHeight);
- }
- }
-
if (tree->columnDrag.column != NULL) {
Tk_Image image;
int x, y, w, h;
@@ -5611,6 +5644,21 @@ TreeColumn_InitInterp(
Tcl_Interp *interp /* Current interpreter. */
)
{
+ Tk_OptionSpec *specPtr;
+ Tcl_DString dString;
+
+ specPtr = OptionSpec_Find(columnSpecs, "-background");
+ if (specPtr->defValue == NULL) {
+ Tcl_DStringInit(&dString);
+ Tcl_DStringAppendElement(&dString, DEF_BUTTON_BG_COLOR);
+ Tcl_DStringAppendElement(&dString, "normal");
+ Tcl_DStringAppendElement(&dString, DEF_BUTTON_ACTIVE_BG_COLOR);
+ Tcl_DStringAppendElement(&dString, "");
+ specPtr->defValue = ckalloc(Tcl_DStringLength(&dString) + 1);
+ strcpy(specPtr->defValue, Tcl_DStringValue(&dString));
+ Tcl_DStringFree(&dString);
+ }
+
PerStateCO_Init(columnSpecs, "-arrowbitmap", &pstBitmap, ColumnStateFromObj);
PerStateCO_Init(columnSpecs, "-arrowimage", &pstImage, ColumnStateFromObj);
PerStateCO_Init(columnSpecs, "-background", &pstBorder, ColumnStateFromObj);