| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#include "bltInt.h" |
| 32 |
|
| 33 |
#ifndef NO_TREEVIEW |
| 34 |
|
| 35 |
#include "bltTreeView.h" |
| 36 |
#include "bltList.h" |
| 37 |
#include <X11/Xutil.h> |
| 38 |
#include <X11/Xatom.h> |
| 39 |
|
| 40 |
#define STYLE_GAP 2 |
| 41 |
|
| 42 |
static Blt_OptionParseProc ObjToSticky; |
| 43 |
static Blt_OptionPrintProc StickyToObj; |
| 44 |
|
| 45 |
static Blt_OptionParseProc ObjToIcon; |
| 46 |
static Blt_OptionPrintProc IconToObj; |
| 47 |
static Blt_OptionFreeProc FreeIcon; |
| 48 |
Blt_CustomOption bltTreeViewIconOption = |
| 49 |
{ |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
ObjToIcon, IconToObj, FreeIcon, NULL, |
| 54 |
}; |
| 55 |
extern Blt_CustomOption bltTreeViewIconsOption; |
| 56 |
|
| 57 |
|
| 58 |
#define DEF_STYLE_HIGHLIGHT_BACKGROUND STD_NORMAL_BACKGROUND |
| 59 |
#define DEF_STYLE_HIGHLIGHT_FOREGROUND STD_NORMAL_FOREGROUND |
| 60 |
#ifdef WIN32 |
| 61 |
#define DEF_STYLE_ACTIVE_BACKGROUND RGB_GREY85 |
| 62 |
#else |
| 63 |
#define DEF_STYLE_ACTIVE_BACKGROUND RGB_GREY95 |
| 64 |
#endif |
| 65 |
#define DEF_STYLE_ACTIVE_FOREGROUND STD_ACTIVE_FOREGROUND |
| 66 |
#define DEF_STYLE_GAP "2" |
| 67 |
|
| 68 |
typedef struct { |
| 69 |
TREEVIEW_STYLE_COMMON |
| 70 |
|
| 71 |
|
| 72 |
Tcl_Obj *formatCmd; |
| 73 |
|
| 74 |
int iconside; |
| 75 |
|
| 76 |
int side; |
| 77 |
|
| 78 |
} TreeViewTextBox; |
| 79 |
|
| 80 |
#ifdef WIN32 |
| 81 |
#define DEF_TEXTBOX_CURSOR "arrow" |
| 82 |
#else |
| 83 |
#define DEF_TEXTBOX_CURSOR "hand2" |
| 84 |
#endif |
| 85 |
#define DEF_TEXTBOX_SIDE "left" |
| 86 |
|
| 87 |
#define CONF_STYLES \ |
| 88 |
{BLT_CONFIG_BORDER, "-activebackground", "activeBackground", \ |
| 89 |
"ActiveBackground", DEF_STYLE_ACTIVE_BACKGROUND, \ |
| 90 |
Blt_Offset(TreeViewStyle, activeBorder), BLT_CONFIG_NULL_OK}, \ |
| 91 |
{BLT_CONFIG_SYNONYM, "-activebg", (char *)NULL, \ |
| 92 |
(char *)NULL, (char *)NULL, 0, 0, (ClientData)"-activebackground"}, \ |
| 93 |
{BLT_CONFIG_SYNONYM, "-activefg", (char *)NULL, \ |
| 94 |
(char *)NULL, (char *)NULL, 0, 0, (ClientData)"-activeforeground"}, \ |
| 95 |
{BLT_CONFIG_COLOR, "-activeforeground", "activeForeground", \ |
| 96 |
"ActiveForeground", DEF_STYLE_ACTIVE_FOREGROUND, \ |
| 97 |
Blt_Offset(TreeViewStyle, activeFgColor), 0}, \ |
| 98 |
{BLT_CONFIG_BORDER, "-background", (char *)NULL, (char *)NULL, \ |
| 99 |
(char *)NULL, Blt_Offset(TreeViewStyle, border), \ |
| 100 |
BLT_CONFIG_NULL_OK|BLT_CONFIG_DONT_SET_DEFAULT}, \ |
| 101 |
{BLT_CONFIG_SYNONYM, "-bg", (char *)NULL, (char *)NULL, (char *)NULL, \ |
| 102 |
0, 0, (ClientData)"-background"}, \ |
| 103 |
{BLT_CONFIG_CURSOR, "-cursor", "cursor", "Cursor", \ |
| 104 |
DEF_TEXTBOX_CURSOR, Blt_Offset(TreeViewStyle, cursor), 0}, \ |
| 105 |
{BLT_CONFIG_BOOLEAN, "-readonly", "readOnly", "ReadOnly", \ |
| 106 |
"False", Blt_Offset(TreeViewStyle, noteditable), \ |
| 107 |
BLT_CONFIG_DONT_SET_DEFAULT},\ |
| 108 |
{BLT_CONFIG_STRING, "-editopts", "editOpts", "EditOpts", \ |
| 109 |
(char *)NULL, Blt_Offset(TreeViewStyle, editOpts), \ |
| 110 |
BLT_CONFIG_NULL_OK}, \ |
| 111 |
{BLT_CONFIG_SYNONYM, "-fg", (char *)NULL, (char *)NULL, (char *)NULL, \ |
| 112 |
0, 0, (ClientData)"-foreground"}, \ |
| 113 |
{BLT_CONFIG_FONT, "-font", (char *)NULL, (char *)NULL, \ |
| 114 |
(char *)NULL, Blt_Offset(TreeViewStyle, font), \ |
| 115 |
BLT_CONFIG_NULL_OK|BLT_CONFIG_DONT_SET_DEFAULT}, \ |
| 116 |
{BLT_CONFIG_COLOR, "-foreground", (char *)NULL, (char *)NULL, \ |
| 117 |
(char *)NULL, Blt_Offset(TreeViewStyle, fgColor), \ |
| 118 |
BLT_CONFIG_NULL_OK|BLT_CONFIG_DONT_SET_DEFAULT }, \ |
| 119 |
{BLT_CONFIG_DISTANCE, "-gap", "gap", "Gap", \ |
| 120 |
DEF_STYLE_GAP, Blt_Offset(TreeViewStyle, gap), \ |
| 121 |
BLT_CONFIG_DONT_SET_DEFAULT}, \ |
| 122 |
{BLT_CONFIG_BOOLEAN, "-hide", (char *)NULL, (char *)NULL, \ |
| 123 |
"False", Blt_Offset(TreeViewStyle, hidden), 0}, \ |
| 124 |
{BLT_CONFIG_BORDER, "-highlightbackground", "highlightBackground", \ |
| 125 |
"HighlightBackground", DEF_STYLE_HIGHLIGHT_BACKGROUND, \ |
| 126 |
Blt_Offset(TreeViewStyle, highlightBorder), \ |
| 127 |
BLT_CONFIG_COLOR_ONLY|BLT_CONFIG_NULL_OK}, \ |
| 128 |
{BLT_CONFIG_COLOR, "-highlightforeground", "highlightForeground", \ |
| 129 |
"HighlightForeground", DEF_STYLE_HIGHLIGHT_FOREGROUND, \ |
| 130 |
Blt_Offset(TreeViewStyle, highlightFgColor), BLT_CONFIG_NULL_OK}, \ |
| 131 |
{BLT_CONFIG_SYNONYM, "-highlightbg",(char *)NULL, \ |
| 132 |
(char *)NULL, (char *)NULL, 0, 0, (ClientData)"-highlightbackground"}, \ |
| 133 |
{BLT_CONFIG_SYNONYM, "-highlightfg", (char *)NULL, \ |
| 134 |
(char *)NULL, (char *)NULL, 0, 0, (ClientData)"-highlightforeground"}, \ |
| 135 |
{BLT_CONFIG_CUSTOM, "-icon", (char *)NULL, (char *)NULL, \ |
| 136 |
(char *)NULL, Blt_Offset(TreeViewStyle, icon), \ |
| 137 |
BLT_CONFIG_NULL_OK, &bltTreeViewIconOption}, \ |
| 138 |
{BLT_CONFIG_INT, "-priority", (char *)NULL, (char *)NULL, \ |
| 139 |
"0", Blt_Offset(TreeViewStyle, priority), 0}, \ |
| 140 |
{BLT_CONFIG_SHADOW, "-shadow", "Shadow", "Shadow", \ |
| 141 |
(char *)NULL, Blt_Offset(TreeViewStyle, shadow), 0}, \ |
| 142 |
{BLT_CONFIG_TILE, "-tile", (char *)NULL, (char *)NULL, \ |
| 143 |
(char *)NULL, Tk_Offset(TreeViewStyle, tile), BLT_CONFIG_NULL_OK, }, |
| 144 |
|
| 145 |
static Blt_ConfigSpec textBoxSpecs[] = |
| 146 |
{ |
| 147 |
CONF_STYLES |
| 148 |
{BLT_CONFIG_OBJCMD, "-formatcmd", "formatCmd", "FormatCmd", |
| 149 |
NULL, Blt_Offset(TreeViewTextBox, formatCmd), |
| 150 |
BLT_CONFIG_NULL_OK}, |
| 151 |
{BLT_CONFIG_SIDE, "-side", (char *)NULL, (char *)NULL, |
| 152 |
DEF_TEXTBOX_SIDE, Tk_Offset(TreeViewTextBox, side), |
| 153 |
BLT_CONFIG_DONT_SET_DEFAULT}, |
| 154 |
{BLT_CONFIG_SIDE, "-iconside", (char *)NULL, (char *)NULL, |
| 155 |
DEF_TEXTBOX_SIDE, Tk_Offset(TreeViewTextBox, iconside), |
| 156 |
BLT_CONFIG_DONT_SET_DEFAULT}, |
| 157 |
{BLT_CONFIG_END, (char *)NULL, (char *)NULL, (char *)NULL, |
| 158 |
(char *)NULL, 0, 0} |
| 159 |
}; |
| 160 |
|
| 161 |
typedef struct { |
| 162 |
TREEVIEW_STYLE_COMMON |
| 163 |
|
| 164 |
|
| 165 |
int size; |
| 166 |
int showValue; |
| 167 |
char *onValue; |
| 168 |
char *offValue; |
| 169 |
int lineWidth; |
| 170 |
GC bgGC; |
| 171 |
Tk_3DBorder checkBg; \ |
| 172 |
|
| 173 |
XColor *boxColor; |
| 174 |
XColor *fillColor; |
| 175 |
XColor *checkColor; |
| 176 |
|
| 177 |
GC boxGC; |
| 178 |
GC fillGC; |
| 179 |
GC checkGC; |
| 180 |
|
| 181 |
TextLayout *onPtr, *offPtr; |
| 182 |
TreeViewIcon *icons; |
| 183 |
int boxX, boxW, boxH; |
| 184 |
int halo; |
| 185 |
|
| 186 |
} TreeViewCheckBox; |
| 187 |
|
| 188 |
#define DEF_CHECKBOX_BOX_COLOR "black" |
| 189 |
#define DEF_CHECKBOX_CHECK_COLOR "darkblue" |
| 190 |
#define DEF_CHECKBOX_FILL_COLOR "white" |
| 191 |
#define DEF_CHECKBOX_OFFVALUE "0" |
| 192 |
#define DEF_CHECKBOX_ONVALUE "1" |
| 193 |
#define DEF_CHECKBOX_SHOWVALUE "yes" |
| 194 |
#define DEF_CHECKBOX_HALO "0" |
| 195 |
#define DEF_CHECKBOX_SIZE "11" |
| 196 |
#define DEF_CHECKBOX_LINEWIDTH "1" |
| 197 |
#define DEF_CHECKBOX_GAP "4" |
| 198 |
#ifdef WIN32 |
| 199 |
#define DEF_CHECKBOX_CURSOR "arrow" |
| 200 |
#else |
| 201 |
#define DEF_CHECKBOX_CURSOR "hand2" |
| 202 |
#endif |
| 203 |
|
| 204 |
static Blt_ConfigSpec checkBoxSpecs[] = |
| 205 |
{ |
| 206 |
CONF_STYLES |
| 207 |
{BLT_CONFIG_COLOR, "-boxcolor", "boxColor", "BoxColor", |
| 208 |
DEF_CHECKBOX_BOX_COLOR, Blt_Offset(TreeViewCheckBox, boxColor), 0}, |
| 209 |
{BLT_CONFIG_DISTANCE, "-boxsize", "boxSize", "BoxSize", |
| 210 |
DEF_CHECKBOX_SIZE, Blt_Offset(TreeViewCheckBox, size), |
| 211 |
BLT_CONFIG_DONT_SET_DEFAULT}, |
| 212 |
{BLT_CONFIG_BORDER, "-checkbg", "checkBg", "checkBg", |
| 213 |
(char *)NULL, Blt_Offset(TreeViewCheckBox, checkBg), BLT_CONFIG_NULL_OK}, |
| 214 |
{BLT_CONFIG_COLOR, "-checkcolor", "checkColor", "CheckColor", |
| 215 |
DEF_CHECKBOX_CHECK_COLOR, Blt_Offset(TreeViewCheckBox, checkColor), 0}, |
| 216 |
{BLT_CONFIG_CUSTOM, "-checkicons", "checkIcons", "CheckIcons", |
| 217 |
(char *)NULL, Blt_Offset(TreeViewCheckBox, icons), |
| 218 |
BLT_CONFIG_NULL_OK, &bltTreeViewIconsOption}, |
| 219 |
{BLT_CONFIG_COLOR, "-fillcolor", "fillColor", "FillColor", |
| 220 |
DEF_CHECKBOX_FILL_COLOR, Blt_Offset(TreeViewCheckBox, fillColor), 0}, |
| 221 |
{BLT_CONFIG_TILE, "-filltile", "fillTile", "FillTile", |
| 222 |
(char *)NULL, Blt_Offset(TreeViewCheckBox, fillTile), BLT_CONFIG_NULL_OK, }, |
| 223 |
{BLT_CONFIG_INT, "-halo", "halo", "Halo", |
| 224 |
DEF_CHECKBOX_HALO, Blt_Offset(TreeViewCheckBox, halo), |
| 225 |
0}, |
| 226 |
{BLT_CONFIG_DISTANCE, "-linewidth", "lineWidth", "LineWidth", |
| 227 |
DEF_CHECKBOX_LINEWIDTH, |
| 228 |
Blt_Offset(TreeViewCheckBox, lineWidth), |
| 229 |
BLT_CONFIG_DONT_SET_DEFAULT}, |
| 230 |
{BLT_CONFIG_STRING, "-offvalue", "offValue", "OffValue", |
| 231 |
DEF_CHECKBOX_OFFVALUE, Blt_Offset(TreeViewCheckBox, offValue), |
| 232 |
BLT_CONFIG_NULL_OK}, |
| 233 |
{BLT_CONFIG_STRING, "-onvalue", "onValue", "OnValue", |
| 234 |
DEF_CHECKBOX_ONVALUE, Blt_Offset(TreeViewCheckBox, onValue), |
| 235 |
BLT_CONFIG_NULL_OK}, |
| 236 |
{BLT_CONFIG_BOOLEAN, "-showvalue", "showValue", "ShowValue", |
| 237 |
DEF_CHECKBOX_SHOWVALUE, Blt_Offset(TreeViewCheckBox, showValue), |
| 238 |
BLT_CONFIG_DONT_SET_DEFAULT}, |
| 239 |
{BLT_CONFIG_END, (char *)NULL, (char *)NULL, (char *)NULL, |
| 240 |
(char *)NULL, 0, 0} |
| 241 |
}; |
| 242 |
|
| 243 |
typedef struct { |
| 244 |
TREEVIEW_STYLE_COMMON |
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
int borderWidth; |
| 249 |
|
| 250 |
char *choiceCmd; |
| 251 |
char *choices; |
| 252 |
char *choiceKey; |
| 253 |
int scrollWidth; |
| 254 |
int button; |
| 255 |
int buttonWidth; |
| 256 |
int buttonBorderWidth; |
| 257 |
int buttonRelief; |
| 258 |
TreeViewIcon *buttonIcons; |
| 259 |
|
| 260 |
} TreeViewComboBox; |
| 261 |
|
| 262 |
#define DEF_COMBOBOX_BORDERWIDTH "1" |
| 263 |
#define DEF_COMBOBOX_BUTTON_BORDERWIDTH "1" |
| 264 |
#define DEF_COMBOBOX_BUTTON_RELIEF "raised" |
| 265 |
#define DEF_COMBOBOX_RELIEF "flat" |
| 266 |
#ifdef WIN32 |
| 267 |
#define DEF_COMBOBOX_CURSOR "arrow" |
| 268 |
#else |
| 269 |
#define DEF_COMBOBOX_CURSOR "hand2" |
| 270 |
#endif |
| 271 |
|
| 272 |
|
| 273 |
static Blt_ConfigSpec comboBoxSpecs[] = |
| 274 |
{ |
| 275 |
CONF_STYLES |
| 276 |
{BLT_CONFIG_SYNONYM, "-bd", (char *)NULL, (char *)NULL, (char *)NULL, 0, |
| 277 |
0, (ClientData)"-borderwidth"}, |
| 278 |
{BLT_CONFIG_DISTANCE, "-borderwidth", (char *)NULL, (char *)NULL, |
| 279 |
DEF_COMBOBOX_BORDERWIDTH, Blt_Offset(TreeViewComboBox, borderWidth), |
| 280 |
BLT_CONFIG_DONT_SET_DEFAULT}, |
| 281 |
{BLT_CONFIG_DISTANCE, "-buttonborderwidth", "buttonBorderWidth", |
| 282 |
"ButtonBorderWidth", DEF_COMBOBOX_BUTTON_BORDERWIDTH, |
| 283 |
Blt_Offset(TreeViewComboBox, buttonBorderWidth), |
| 284 |
BLT_CONFIG_DONT_SET_DEFAULT}, |
| 285 |
{BLT_CONFIG_CUSTOM, "-buttonicons", "buttonIcons", "ButtonIcons", |
| 286 |
(char *)NULL, Blt_Offset(TreeViewComboBox, buttonIcons), |
| 287 |
BLT_CONFIG_NULL_OK, &bltTreeViewIconsOption}, |
| 288 |
{BLT_CONFIG_RELIEF, "-buttonrelief", "buttonRelief", "ButtonRelief", |
| 289 |
DEF_COMBOBOX_BUTTON_RELIEF, Blt_Offset(TreeViewComboBox, buttonRelief), |
| 290 |
BLT_CONFIG_DONT_SET_DEFAULT}, |
| 291 |
{BLT_CONFIG_STRING, "-choicecmd", "choiceCmd", "ChoiceCmd", |
| 292 |
(char *)NULL, Blt_Offset(TreeViewComboBox, choiceCmd), |
| 293 |
BLT_CONFIG_NULL_OK, 0}, |
| 294 |
{BLT_CONFIG_STRING, "-choicekey", "choiceKey", "ChoiceKey", |
| 295 |
(char *)NULL, Blt_Offset(TreeViewComboBox, choiceKey), |
| 296 |
BLT_CONFIG_NULL_OK, 0}, |
| 297 |
{BLT_CONFIG_STRING, "-choices", "choices", "Choices", |
| 298 |
(char *)NULL, Blt_Offset(TreeViewComboBox, choices), |
| 299 |
BLT_CONFIG_NULL_OK, 0}, |
| 300 |
{BLT_CONFIG_END, (char *)NULL, (char *)NULL, (char *)NULL, |
| 301 |
(char *)NULL, 0, 0} |
| 302 |
}; |
| 303 |
|
| 304 |
typedef struct { |
| 305 |
TREEVIEW_STYLE_COMMON |
| 306 |
|
| 307 |
int windowHeight; |
| 308 |
int windowWidth; |
| 309 |
char *windowCmd; |
| 310 |
int sticky; |
| 311 |
|
| 312 |
} TreeViewWindowBox; |
| 313 |
|
| 314 |
#define STICK_NORTH (1<<0) |
| 315 |
#define STICK_EAST (1<<1) |
| 316 |
#define STICK_SOUTH (1<<2) |
| 317 |
#define STICK_WEST (1<<3) |
| 318 |
|
| 319 |
static Blt_CustomOption bltStickyOption = { |
| 320 |
ObjToSticky, StickyToObj, NULL, NULL, |
| 321 |
}; |
| 322 |
|
| 323 |
#define DEF_COMBOBOX_BORDERWIDTH "1" |
| 324 |
#define DEF_COMBOBOX_BUTTON_BORDERWIDTH "1" |
| 325 |
#define DEF_COMBOBOX_BUTTON_RELIEF "raised" |
| 326 |
#define DEF_COMBOBOX_RELIEF "flat" |
| 327 |
#ifdef WIN32 |
| 328 |
#define DEF_COMBOBOX_CURSOR "arrow" |
| 329 |
#else |
| 330 |
#define DEF_COMBOBOX_CURSOR "hand2" |
| 331 |
#endif |
| 332 |
|
| 333 |
static Blt_ConfigSpec windowBoxSpecs[] = |
| 334 |
{ |
| 335 |
{BLT_CONFIG_STRING, "-windowcmd", "windowCmd", "windowCmd", |
| 336 |
(char *)NULL, Blt_Offset(TreeViewWindowBox, windowCmd), |
| 337 |
BLT_CONFIG_NULL_OK, 0}, |
| 338 |
{BLT_CONFIG_INT, "-minwidth", "WindowWidth", "WindowWidth", |
| 339 |
"0", Blt_Offset(TreeViewWindowBox, windowWidth), 0}, |
| 340 |
{BLT_CONFIG_INT, "-minheight", "WindowHeight", "WindowHeight", |
| 341 |
"0", Blt_Offset(TreeViewWindowBox, windowHeight), 0}, |
| 342 |
{BLT_CONFIG_CUSTOM, "-sticky", "sticky", "Sticky", |
| 343 |
"w", Tk_Offset(TreeViewWindowBox, sticky), |
| 344 |
0, &bltStickyOption}, |
| 345 |
|
| 346 |
{BLT_CONFIG_END, (char *)NULL, (char *)NULL, (char *)NULL, |
| 347 |
(char *)NULL, 0, 0} |
| 348 |
}; |
| 349 |
|
| 350 |
typedef struct { |
| 351 |
TREEVIEW_STYLE_COMMON |
| 352 |
|
| 353 |
|
| 354 |
GC bgGC; |
| 355 |
Tk_3DBorder barBg; \ |
| 356 |
|
| 357 |
int showValue; |
| 358 |
double minValue; |
| 359 |
double maxValue; |
| 360 |
int lineWidth; |
| 361 |
Tcl_Obj *formatCmd; |
| 362 |
|
| 363 |
XColor *boxColor; |
| 364 |
XColor *fillColor; |
| 365 |
|
| 366 |
GC boxGC; |
| 367 |
GC fillGC; |
| 368 |
|
| 369 |
int barWidth; |
| 370 |
int barHeight; |
| 371 |
|
| 372 |
} TreeViewBarBox; |
| 373 |
|
| 374 |
#define DEF_BARBOX_BOX_COLOR "black" |
| 375 |
#define DEF_BARBOX_FILL_COLOR "darkgreen" |
| 376 |
#define DEF_BARBOX_MINVALUE "0.0" |
| 377 |
#define DEF_BARBOX_MAXVALUE "100.0" |
| 378 |
#define DEF_BARBOX_WIDTH "80" |
| 379 |
#define DEF_BARBOX_HEIGHT "10" |
| 380 |
#define DEF_BARBOX_SHOWVALUE "yes" |
| 381 |
#define DEF_BARBOX_LINEWIDTH "1" |
| 382 |
#define DEF_BARBOX_GAP "4" |
| 383 |
#ifdef WIN32 |
| 384 |
#define DEF_BARBOX_CURSOR "arrow" |
| 385 |
#else |
| 386 |
#define DEF_BARBOX_CURSOR "hand2" |
| 387 |
#endif |
| 388 |
|
| 389 |
static Blt_ConfigSpec barBoxSpecs[] = |
| 390 |
{ |
| 391 |
CONF_STYLES |
| 392 |
{BLT_CONFIG_BORDER, "-barbg", "barBg", "BarBg", |
| 393 |
(char *)NULL, Blt_Offset(TreeViewBarBox, barBg), BLT_CONFIG_NULL_OK}, |
| 394 |
{BLT_CONFIG_COLOR, "-barfg", "barFg", "BarFg", |
| 395 |
DEF_BARBOX_FILL_COLOR, Blt_Offset(TreeViewBarBox, fillColor), 0}, |
| 396 |
{BLT_CONFIG_COLOR, "-boxcolor", "boxColor", "BoxColor", |
| 397 |
DEF_BARBOX_BOX_COLOR, Blt_Offset(TreeViewBarBox, boxColor), 0}, |
| 398 |
{BLT_CONFIG_INT, "-barwidth", "barWidth", "BarWidth", |
| 399 |
DEF_BARBOX_WIDTH, Blt_Offset(TreeViewBarBox, barWidth), 0}, |
| 400 |
{BLT_CONFIG_INT, "-barheight", "BarHeight", "BarHeight", |
| 401 |
DEF_BARBOX_HEIGHT, Blt_Offset(TreeViewBarBox, barHeight), 0}, |
| 402 |
{BLT_CONFIG_TILE, "-filltile", "fillTile", "FillTile", |
| 403 |
(char *)NULL, Tk_Offset(TreeViewBarBox, fillTile), BLT_CONFIG_NULL_OK, }, |
| 404 |
{BLT_CONFIG_OBJCMD, "-formatcmd", "formatCmd", "FormatCmd", |
| 405 |
NULL, Blt_Offset(TreeViewBarBox, formatCmd), |
| 406 |
BLT_CONFIG_NULL_OK}, |
| 407 |
{BLT_CONFIG_DISTANCE, "-linewidth", "lineWidth", "LineWidth", |
| 408 |
DEF_BARBOX_LINEWIDTH, |
| 409 |
Blt_Offset(TreeViewBarBox, lineWidth), |
| 410 |
BLT_CONFIG_DONT_SET_DEFAULT}, |
| 411 |
{BLT_CONFIG_DOUBLE, "-maxvalue", "maxValue", "MaxValue", |
| 412 |
DEF_BARBOX_MAXVALUE, Blt_Offset(TreeViewBarBox, maxValue), 0}, |
| 413 |
{BLT_CONFIG_DOUBLE, "-minvalue", "minValue", "MinValue", |
| 414 |
DEF_BARBOX_MINVALUE, Blt_Offset(TreeViewBarBox, minValue), 0}, |
| 415 |
{BLT_CONFIG_BOOLEAN, "-showvalue", "showValue", "ShowValue", |
| 416 |
DEF_BARBOX_SHOWVALUE, Blt_Offset(TreeViewBarBox, showValue), |
| 417 |
BLT_CONFIG_DONT_SET_DEFAULT}, |
| 418 |
{BLT_CONFIG_END, (char *)NULL, (char *)NULL, (char *)NULL, |
| 419 |
(char *)NULL, 0, 0} |
| 420 |
}; |
| 421 |
|
| 422 |
typedef union { |
| 423 |
TreeViewTextBox tb; |
| 424 |
TreeViewCheckBox cb; |
| 425 |
TreeViewComboBox cob; |
| 426 |
TreeViewBarBox bb; |
| 427 |
TreeViewWindowBox wb; |
| 428 |
} TreeViewAllStyles; |
| 429 |
|
| 430 |
typedef TreeViewStyle *(StyleCreateProc) _ANSI_ARGS_((TreeView *tvPtr, |
| 431 |
Blt_HashEntry *hPtr)); |
| 432 |
|
| 433 |
static StyleConfigProc ConfigureTextBox, ConfigureCheckBox, ConfigureComboBox, ConfigureWindowBox, ConfigureBarBox; |
| 434 |
static StyleCreateProc CreateTextBox, CreateCheckBox, CreateComboBox, CreateWindowBox, CreateBarBox; |
| 435 |
static StyleDrawProc DrawTextBox, DrawCheckBox, DrawComboBox, DrawWindowBox, DrawBarBox; |
| 436 |
static StyleEditProc EditTextBox, EditCheckBox, EditComboBox, EditWindowBox, EditBarBox; |
| 437 |
static StyleFreeProc FreeTextBox, FreeCheckBox, FreeComboBox, FreeWindowBox, FreeBarBox; |
| 438 |
static StyleMeasureProc MeasureTextBox, MeasureCheckBox, MeasureComboBox, MeasureWindowBox, MeasureBarBox; |
| 439 |
static StylePickProc PickComboBox; |
| 440 |
|
| 441 |
|
| 442 |
static Tcl_Obj * |
| 443 |
StickyToObj(clientData, interp, tkwin, widgRec, offset) |
| 444 |
ClientData clientData; |
| 445 |
Tcl_Interp *interp; |
| 446 |
Tk_Window tkwin; |
| 447 |
char *widgRec; |
| 448 |
int offset; |
| 449 |
{ |
| 450 |
int flags = *(int *)(widgRec + offset); |
| 451 |
|
| 452 |
int count = 0; |
| 453 |
char result[10]; |
| 454 |
|
| 455 |
if (flags&STICK_NORTH) result[count++] = 'n'; |
| 456 |
if (flags&STICK_EAST) result[count++] = 'e'; |
| 457 |
if (flags&STICK_SOUTH) result[count++] = 's'; |
| 458 |
if (flags&STICK_WEST) result[count++] = 'w'; |
| 459 |
|
| 460 |
result[count] = '\0'; |
| 461 |
return Tcl_NewStringObj(result, -1); |
| 462 |
} |
| 463 |
|
| 464 |
static int |
| 465 |
ObjToSticky(clientData, interp, tkwin, objPtr, widgRec, offset) |
| 466 |
ClientData clientData; |
| 467 |
Tcl_Interp *interp; |
| 468 |
Tk_Window tkwin; |
| 469 |
Tcl_Obj *objPtr; |
| 470 |
char *widgRec; |
| 471 |
int offset; |
| 472 |
{ |
| 473 |
|
| 474 |
int *stickyPtr = (int *)(widgRec + offset); |
| 475 |
int sticky = 0; |
| 476 |
char c; |
| 477 |
char *value; |
| 478 |
|
| 479 |
value = Tcl_GetString(objPtr); |
| 480 |
|
| 481 |
while ((c = *value++) != '\0') { |
| 482 |
switch (c) { |
| 483 |
case 'n': case 'N': sticky |= STICK_NORTH; break; |
| 484 |
case 'e': case 'E': sticky |= STICK_EAST; break; |
| 485 |
case 's': case 'S': sticky |= STICK_SOUTH; break; |
| 486 |
case 'w': case 'W': sticky |= STICK_WEST; break; |
| 487 |
case ' ': case ',': case '\t': case '\r': case '\n': break; |
| 488 |
default: |
| 489 |
Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), |
| 490 |
"bad sticky value \"", --value, |
| 491 |
"\": must contain n, s, e or w", |
| 492 |
(char *) NULL); |
| 493 |
return TCL_ERROR; |
| 494 |
} |
| 495 |
} |
| 496 |
*stickyPtr = sticky; |
| 497 |
return TCL_OK; |
| 498 |
} |
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
static int |
| 517 |
ObjToIcon(clientData, interp, tkwin, objPtr, widgRec, offset) |
| 518 |
ClientData clientData; |
| 519 |
Tcl_Interp *interp; |
| 520 |
Tk_Window tkwin; |
| 521 |
Tcl_Obj *objPtr; |
| 522 |
char *widgRec; |
| 523 |
int offset; |
| 524 |
{ |
| 525 |
TreeView *tvPtr = clientData; |
| 526 |
TreeViewIcon *iconPtr = (TreeViewIcon *)(widgRec + offset); |
| 527 |
TreeViewIcon icon; |
| 528 |
|
| 529 |
icon = Blt_TreeViewGetIcon(tvPtr, Tcl_GetString(objPtr)); |
| 530 |
if (icon == NULL) { |
| 531 |
return TCL_ERROR; |
| 532 |
} |
| 533 |
*iconPtr = icon; |
| 534 |
return TCL_OK; |
| 535 |
} |
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
static Tcl_Obj * |
| 550 |
IconToObj(clientData, interp, tkwin, widgRec, offset) |
| 551 |
ClientData clientData; |
| 552 |
Tcl_Interp *interp; |
| 553 |
Tk_Window tkwin; |
| 554 |
char *widgRec; |
| 555 |
int offset; |
| 556 |
{ |
| 557 |
TreeViewIcon icon = *(TreeViewIcon *)(widgRec + offset); |
| 558 |
|
| 559 |
return Tcl_NewStringObj(icon?Blt_NameOfImage((icon)->tkImage):"", -1); |
| 560 |
} |
| 561 |
|
| 562 |
|
| •563 |
|
| 564 |
int |
| 565 |
Blt_TreeViewTextbox(TreeView *tvPtr, |
| 566 |
TreeViewEntry *entryPtr, |
| 567 |
TreeViewColumn *columnPtr); |
| 568 |
static int |
| 569 |
FreeIcon(clientData, display, widgRec, offset, oldPtr) |
| 570 |
ClientData clientData; |
| 571 |
Display *display; |
| 572 |
char *widgRec; |
| 573 |
int offset; |
| 574 |
char *oldPtr; |
| 575 |
{ |
| 576 |
TreeViewIcon icon = (TreeViewIcon)(oldPtr); |
| 577 |
TreeView *tvPtr = clientData; |
| 578 |
|
| 579 |
Blt_TreeViewFreeIcon(tvPtr, icon); |
| 580 |
return TCL_OK; |
| 581 |
} |
| 582 |
|
| 583 |
static TreeViewStyleClass textBoxClass = { |
| 584 |
"TextBoxStyle", |
| 585 |
textBoxSpecs, |
| 586 |
ConfigureTextBox, |
| 587 |
MeasureTextBox, |
| 588 |
DrawTextBox, |
| 589 |
NULL, |
| 590 |
EditTextBox, |
| 591 |
FreeTextBox, |
| 592 |
}; |
| 593 |
|
| 594 |
static TreeViewStyleClass checkBoxClass = { |
| 595 |
"CheckBoxStyle", |
| 596 |
checkBoxSpecs, |
| 597 |
ConfigureCheckBox, |
| 598 |
MeasureCheckBox, |
| 599 |
DrawCheckBox, |
| 600 |
NULL, |
| 601 |
EditCheckBox, |
| 602 |
FreeCheckBox, |
| 603 |
}; |
| 604 |
|
| 605 |
static TreeViewStyleClass comboBoxClass = { |
| 606 |
"ComboBoxStyle", |
| 607 |
comboBoxSpecs, |
| 608 |
ConfigureComboBox, |
| 609 |
MeasureComboBox, |
| 610 |
DrawComboBox, |
| 611 |
PickComboBox, |
| 612 |
EditComboBox, |
| 613 |
FreeComboBox, |
| 614 |
}; |
| 615 |
|
| 616 |
static TreeViewStyleClass windowBoxClass = { |
| 617 |
"WindowBoxStyle", |
| 618 |
windowBoxSpecs, |
| 619 |
ConfigureWindowBox, |
| 620 |
MeasureWindowBox, |
| 621 |
DrawWindowBox, |
| 622 |
NULL, |
| 623 |
EditWindowBox, |
| 624 |
FreeWindowBox, |
| 625 |
}; |
| 626 |
|
| 627 |
static TreeViewStyleClass barBoxClass = { |
| 628 |
"BarBoxStyle", |
| 629 |
barBoxSpecs, |
| 630 |
ConfigureBarBox, |
| 631 |
MeasureBarBox, |
| 632 |
DrawBarBox, |
| 633 |
NULL, |
| 634 |
EditBarBox, |
| 635 |
FreeBarBox, |
| 636 |
}; |
| 637 |
|
| 638 |
int Blt_TreeViewStyleIsFmt (TreeView *tvPtr, |
| 639 |
TreeViewStyle *stylePtr) |
| 640 |
{ |
| 641 |
if (stylePtr->classPtr == &textBoxClass) { |
| 642 |
TreeViewTextBox *tbPtr; |
| 643 |
tbPtr = (TreeViewTextBox *)stylePtr; |
| 644 |
if (tbPtr->formatCmd != NULL && strlen(Tcl_GetString(tbPtr->formatCmd))) { |
| 645 |
return 1; |
| 646 |
} |
| 647 |
return 0; |
| 648 |
} |
| 649 |
if (stylePtr->classPtr == &barBoxClass) { |
| 650 |
TreeViewBarBox *bbPtr; |
| 651 |
bbPtr = (TreeViewBarBox *)stylePtr; |
| 652 |
if (bbPtr->formatCmd != NULL && strlen(Tcl_GetString(bbPtr->formatCmd))) { |
| 653 |
return 1; |
| 654 |
} |
| 655 |
return 0; |
| 656 |
} |
| 657 |
return 0; |
| 658 |
} |
| 659 |
|
| 660 |
|
| 661 |
static TreeViewStyle *newStyle(TreeView *tvPtr, Blt_HashEntry *hPtr, int size) { |
| 662 |
TreeViewStyle *stylePtr; |
| 663 |
stylePtr = Blt_Calloc(1, sizeof(TreeViewAllStyles)); |
| 664 |
|
| 665 |
assert(stylePtr); |
| 666 |
stylePtr->gap = STYLE_GAP; |
| 667 |
stylePtr->name = Blt_Strdup(Blt_GetHashKey(&tvPtr->styleTable, hPtr)); |
| 668 |
stylePtr->hashPtr = hPtr; |
| 669 |
stylePtr->refCount = 1; |
| 670 |
Blt_SetHashValue(hPtr, stylePtr); |
| 671 |
return stylePtr; |
| 672 |
} |
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
static TreeViewStyle * |
| 686 |
CreateTextBox(tvPtr, hPtr) |
| 687 |
TreeView *tvPtr; |
| 688 |
Blt_HashEntry *hPtr; |
| 689 |
{ |
| 690 |
TreeViewTextBox *tbPtr; |
| 691 |
|
| 692 |
tbPtr = (TreeViewTextBox *)newStyle(tvPtr, hPtr, sizeof(TreeViewTextBox)); |
| 693 |
tbPtr->classPtr = &textBoxClass; |
| 694 |
tbPtr->iconside = SIDE_LEFT; |
| 695 |
tbPtr->side = SIDE_TOP; |
| 696 |
tbPtr->flags = STYLE_TEXTBOX; |
| 697 |
return (TreeViewStyle *)tbPtr; |
| 698 |
} |
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
static void |
| 717 |
ConfigureTextBox(tvPtr, stylePtr) |
| 718 |
TreeView *tvPtr; |
| 719 |
TreeViewStyle *stylePtr; |
| 720 |
{ |
| 721 |
GC newGC; |
| 722 |
XColor *bgColor; |
| 723 |
XGCValues gcValues; |
| 724 |
unsigned long gcMask; |
| 725 |
|
| 726 |
gcMask = GCForeground | GCBackground | GCFont; |
| 727 |
gcValues.font = Tk_FontId(CHOOSE(tvPtr->font, stylePtr->font)); |
| 728 |
bgColor = Tk_3DBorderColor(CHOOSE(tvPtr->border, stylePtr->border)); |
| 729 |
|
| 730 |
gcValues.background = bgColor->pixel; |
| 731 |
gcValues.foreground = CHOOSE(tvPtr->fgColor, stylePtr->fgColor)->pixel; |
| 732 |
newGC = Tk_GetGC(tvPtr->tkwin, gcMask, &gcValues); |
| 733 |
if (stylePtr->gc != NULL) { |
| 734 |
Tk_FreeGC(tvPtr->display, stylePtr->gc); |
| 735 |
} |
| 736 |
stylePtr->gc = newGC; |
| 737 |
if (stylePtr->highlightBorder) { |
| 738 |
gcValues.background = Tk_3DBorderColor(stylePtr->highlightBorder)->pixel; |
| 739 |
} else { |
| 740 |
gcValues.background = bgColor->pixel; |
| 741 |
} |
| 742 |
if (stylePtr->highlightFgColor) { |
| 743 |
gcValues.foreground = stylePtr->highlightFgColor->pixel; |
| 744 |
} else { |
| 745 |
gcValues.foreground = CHOOSE(tvPtr->fgColor, stylePtr->fgColor)->pixel; |
| 746 |
} |
| 747 |
newGC = Tk_GetGC(tvPtr->tkwin, gcMask, &gcValues); |
| 748 |
if (stylePtr->highlightGC != NULL) { |
| 749 |
Tk_FreeGC(tvPtr->display, stylePtr->highlightGC); |
| 750 |
} |
| 751 |
stylePtr->highlightGC = newGC; |
| 752 |
|
| 753 |
if (stylePtr->activeBorder) { |
| 754 |
gcValues.background = Tk_3DBorderColor(stylePtr->activeBorder)->pixel; |
| 755 |
} else { |
| 756 |
gcValues.background = bgColor->pixel; |
| 757 |
} |
| 758 |
if (stylePtr->activeFgColor) { |
| 759 |
gcValues.foreground = stylePtr->activeFgColor->pixel; |
| 760 |
} else { |
| 761 |
gcValues.foreground = CHOOSE(tvPtr->fgColor, stylePtr->fgColor)->pixel; |
| 762 |
} |
| 763 |
newGC = Tk_GetGC(tvPtr->tkwin, gcMask, &gcValues); |
| 764 |
if (stylePtr->activeGC != NULL) { |
| 765 |
Tk_FreeGC(tvPtr->display, stylePtr->activeGC); |
| 766 |
} |
| 767 |
stylePtr->activeGC = newGC; |
| 768 |
stylePtr->flags |= STYLE_DIRTY; |
| 769 |
} |
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
static void |
| 791 |
MeasureTextBox(tvPtr, stylePtr, valuePtr) |
| 792 |
TreeView *tvPtr; |
| 793 |
TreeViewStyle *stylePtr; |
| 794 |
TreeViewValue *valuePtr; |
| 795 |
{ |
| 796 |
TreeViewTextBox *tbPtr = (TreeViewTextBox *)stylePtr; |
| 797 |
TreeViewColumn *columnPtr = valuePtr->columnPtr; |
| 798 |
int iconWidth, iconHeight; |
| 799 |
int textWidth, textHeight; |
| 800 |
int gap; |
| 801 |
TreeViewIcon icon; |
| 802 |
int rel = 0; |
| 803 |
|
| 804 |
textWidth = textHeight = 0; |
| 805 |
iconWidth = iconHeight = 0; |
| 806 |
valuePtr->width = valuePtr->height = 0; |
| 807 |
icon = (stylePtr->icon?stylePtr->icon:(columnPtr->stylePtr?columnPtr->stylePtr->icon:NULL)); |
| 808 |
if (icon != NULL && tvPtr->hideStyleIcons == 0) { |
| 809 |
iconWidth = TreeViewIconWidth(icon); |
| 810 |
iconHeight = TreeViewIconHeight(icon); |
| 811 |
} |
| 812 |
if (valuePtr->textPtr != NULL) { |
| 813 |
Blt_Free(valuePtr->textPtr); |
| 814 |
valuePtr->textPtr = NULL; |
| 815 |
} |
| 816 |
#define NotNullObj(p) ((p != NULL && strlen(Tcl_GetString(p))) ? p : NULL) |
| 817 |
|
| 818 |
if (valuePtr->string != NULL) { |
| 819 |
|
| 820 |
TextStyle ts; |
| 821 |
Tcl_Obj *fmtObj; |
| 822 |
|
| 823 |
fmtObj = NotNullObj(tbPtr->formatCmd); |
| 824 |
if (fmtObj == NULL) { |
| 825 |
fmtObj = NotNullObj(columnPtr->formatCmd); |
| 826 |
} |
| 827 |
if (fmtObj == NULL) { |
| 828 |
fmtObj = NotNullObj(tvPtr->formatCmd); |
| 829 |
} |
| 830 |
|
| 831 |
Blt_InitTextStyle(&ts); |
| 832 |
ts.font = CHOOSE3(tvPtr->font, columnPtr->font , stylePtr->font); |
| 833 |
ts.anchor = TK_ANCHOR_NW; |
| 834 |
ts.justify = columnPtr->justify; |
| 835 |
if (fmtObj != NULL) { |
| 836 |
Tcl_DString cmdString; |
| 837 |
char *string; |
| 838 |
int result; |
| 839 |
Tcl_Interp *interp = tvPtr->interp; |
| 840 |
|
| 841 |
Tcl_Preserve(valuePtr->entryPtr); |
| 842 |
rel = 1; |
| 843 |
Blt_TreeViewPercentSubst(tvPtr, valuePtr->entryPtr, columnPtr, Tcl_GetString(fmtObj), valuePtr->string, &cmdString); |
| 844 |
result = Tcl_GlobalEval(interp, Tcl_DStringValue(&cmdString)); |
| 845 |
Blt_TreeViewOptsInit(tvPtr); |
| 846 |
Tcl_DStringFree(&cmdString); |
| 847 |
if (result == TCL_OK) { |
| 848 |
string = Tcl_GetStringResult(interp); |
| 849 |
valuePtr->textPtr = Blt_GetTextLayoutStr(string, &ts); |
| 850 |
} |
| 851 |
} |
| 852 |
if (valuePtr->textPtr == NULL) { |
| 853 |
valuePtr->textPtr = Blt_GetTextLayoutStr(valuePtr->string, &ts); |
| 854 |
} |
| 855 |
} |
| 856 |
gap = 0; |
| 857 |
if (valuePtr->textPtr != NULL && tvPtr->hideStyleText == 0) { |
| 858 |
textWidth = valuePtr->textPtr->width; |
| 859 |
textHeight = valuePtr->textPtr->height; |
| 860 |
if (stylePtr->icon != NULL) { |
| 861 |
gap = stylePtr->gap; |
| 862 |
} |
| 863 |
} |
| 864 |
if (SIDE_VERTICAL(tbPtr->iconside)) { |
| 865 |
valuePtr->height = iconHeight + gap + textHeight; |
| 866 |
valuePtr->width = MAX(textWidth, iconWidth); |
| 867 |
} else { |
| 868 |
valuePtr->width = iconWidth + gap + textWidth; |
| 869 |
valuePtr->height = MAX(textHeight, iconHeight); |
| 870 |
} |
| 871 |
if (rel) { |
| 872 |
Tcl_Release(valuePtr->entryPtr); |
| 873 |
} |
| 874 |
} |
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
static void |
| 879 |
GetPriorityStyle( |
| 880 |
TreeView *tvPtr, |
| 881 |
TreeViewEntry *entryPtr, |
| 882 |
TreeViewValue *valuePtr, |
| 883 |
TreeViewStyle *inStylePtr, |
| 884 |
TreeViewStyle *stylePtr |
| 885 |
) { |
| 886 |
TreeViewStyle *s[4]; |
| 887 |
int i = -1, bgprio = -1, fgprio = -1, fntprio = -1; |
| 888 |
int disabled = (entryPtr->state == STATE_DISABLED); |
| 889 |
|
| 890 |
s[0] = valuePtr?valuePtr->stylePtr:NULL; |
| 891 |
s[1] = entryPtr?entryPtr->stylePtr:NULL; |
| 892 |
s[2] = valuePtr?valuePtr->columnPtr->stylePtr:NULL; |
| 893 |
s[3] = tvPtr->stylePtr; |
| 894 |
|
| 895 |
stylePtr->font = tvPtr->font; |
| 896 |
if (valuePtr != NULL && valuePtr->columnPtr->font) { |
| 897 |
stylePtr->font = valuePtr->columnPtr->font; |
| 898 |
stylePtr->gc = valuePtr->columnPtr->textGC; |
| 899 |
} else if (inStylePtr->font) { |
| 900 |
stylePtr->font = inStylePtr->font; |
| 901 |
stylePtr->gc = stylePtr->gc; |
| 902 |
} |
| 903 |
stylePtr->border = CHOOSE3(tvPtr->border, inStylePtr->border, entryPtr->border); |
| 904 |
if (disabled) { |
| 905 |
stylePtr->fgColor = tvPtr->disabledColor; |
| 906 |
} else if (valuePtr != NULL) { |
| 907 |
stylePtr->fgColor = CHOOSE4(tvPtr->fgColor, valuePtr->columnPtr->fgColor, inStylePtr->fgColor, entryPtr->color); |
| 908 |
} else { |
| 909 |
stylePtr->fgColor = CHOOSE3(tvPtr->fgColor, inStylePtr->fgColor, entryPtr->color); |
| 910 |
} |
| 911 |
while (++i<4) { |
| 912 |
if (s[i]) { |
| 913 |
if (s[i]->border && (s[i]->priority>bgprio||stylePtr->border==NULL)) { |
| 914 |
stylePtr->border = s[i]->border; |
| 915 |
bgprio = s[i]->priority; |
| 916 |
} |
| 917 |
if (disabled == 0 && s[i]->fgColor && (s[i]->priority>fgprio||stylePtr->fgColor==NULL)) { |
| 918 |
stylePtr->fgColor = s[i]->fgColor; |
| 919 |
fgprio = s[i]->priority; |
| 920 |
} |
| 921 |
if (s[i]->font && (s[i]->priority>fntprio||stylePtr->font==NULL)) { |
| 922 |
stylePtr->font = s[i]->font; |
| 923 |
stylePtr->gc = s[i]->gc; |
| 924 |
fntprio = s[i]->priority; |
| 925 |
} |
| 926 |
} |
| 927 |
} |
| 928 |
} |
| 929 |
|
| 930 |
|
| 931 |
void |
| 932 |
Blt_GetPriorityStyle( |
| 933 |
TreeViewStyle *stylePtr, |
| 934 |
TreeView *tvPtr, |
| 935 |
TreeViewColumn *columnPtr, |
| 936 |
TreeViewEntry *entryPtr, |
| 937 |
TreeViewValue *valuePtr, |
| 938 |
TreeViewStyle *inStylePtr, |
| 939 |
int flags |
| 940 |
) { |
| 941 |
TreeViewStyle *s[20]; |
| 942 |
int n = 0, i = -1; |
| 943 |
int bgprio = -1, fgprio = -1, fntprio = -1, shadprio = -1, tileprio = -1; |
| 944 |
int iconprio = -1; |
| 945 |
int disabled = (entryPtr->state == STATE_DISABLED); |
| 946 |
|
| 947 |
if ((flags&STYLEFLAG_NOCLEAR) == 0) { |
| 948 |
memset(stylePtr, 0, sizeof(*stylePtr)); |
| 949 |
} |
| 950 |
|
| 951 |
if ((flags&STYLEFLAG_SUBSTYLE) && tvPtr->subStylePtr) { |
| 952 |
s[n++] = tvPtr->subStylePtr; |
| 953 |
} |
| 954 |
|
| 955 |
if ((flags&STYLEFLAG_EMPTYSTYLE) && tvPtr->emptyStylePtr) { |
| 956 |
s[n++] = tvPtr->emptyStylePtr; |
| 957 |
} |
| 958 |
|
| 959 |
if ((flags&STYLEFLAG_ALTSTYLE) && tvPtr->altStylePtr) { |
| 960 |
s[n++] = tvPtr->altStylePtr; |
| 961 |
} |
| 962 |
|
| 963 |
if ((flags&STYLEFLAG_TITLESTYLE) && columnPtr && columnPtr->titleStylePtr) { |
| 964 |
s[n++] = columnPtr->titleStylePtr; |
| 965 |
} |
| 966 |
if (inStylePtr) s[n++] = inStylePtr; |
| 967 |
if (valuePtr && valuePtr->stylePtr) s[n++] = valuePtr->stylePtr; |
| 968 |
if (entryPtr && entryPtr->stylePtr) s[n++] = entryPtr->stylePtr; |
| 969 |
if (columnPtr && columnPtr->stylePtr) s[n++] = columnPtr->stylePtr; |
| 970 |
if (tvPtr->stylePtr) s[n++] = tvPtr->stylePtr; |
| 971 |
if (inStylePtr == NULL) inStylePtr = tvPtr->stylePtr; |
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
stylePtr->gc = (entryPtr?entryPtr->gc:NULL); |
| 980 |
|
| 981 |
if (valuePtr != NULL && valuePtr->columnPtr->font) { |
| 982 |
stylePtr->font = valuePtr->columnPtr->font; |
| 983 |
stylePtr->gc = valuePtr->columnPtr->textGC; |
| 984 |
} else if (inStylePtr->font) { |
| 985 |
stylePtr->font = inStylePtr->font; |
| 986 |
stylePtr->gc = stylePtr->gc; |
| 987 |
} else if (columnPtr && columnPtr->font) { |
| 988 |
stylePtr->font = columnPtr->font; |
| 989 |
stylePtr->gc = columnPtr->textGC; |
| 990 |
} |
| 991 |
stylePtr->border = CHOOSE3(tvPtr->border, inStylePtr->border, entryPtr->border); |
| 992 |
if (disabled) { |
| 993 |
stylePtr->fgColor = tvPtr->disabledColor; |
| 994 |
} else if (valuePtr != NULL) { |
| 995 |
stylePtr->fgColor = CHOOSE4(tvPtr->fgColor, valuePtr->columnPtr->fgColor, inStylePtr->fgColor, entryPtr->color); |
| 996 |
} else { |
| 997 |
stylePtr->fgColor = CHOOSE3(tvPtr->fgColor, inStylePtr->fgColor, entryPtr->color); |
| 998 |
} |
| 999 |
i = -1; |
| 1000 |
while (++i<n) { |
| 1001 |
if (s[i]->border && (s[i]->priority>bgprio||stylePtr->border==NULL)) { |
| 1002 |
stylePtr->border = s[i]->border; |
| 1003 |
bgprio = s[i]->priority; |
| 1004 |
} |
| 1005 |
if (disabled == 0 && s[i]->fgColor && (s[i]->priority>fgprio||stylePtr->fgColor==NULL)) { |
| 1006 |
stylePtr->fgColor = s[i]->fgColor; |
| 1007 |
fgprio = s[i]->priority; |
| 1008 |
} |
| 1009 |
if (s[i]->font && (s[i]->priority>fntprio||stylePtr->font==NULL)) { |
| 1010 |
stylePtr->font = s[i]->font; |
| 1011 |
fntprio = s[i]->priority; |
| 1012 |
stylePtr->gc = s[i]->gc; |
| 1013 |
} |
| 1014 |
if (s[i]->shadow.color && (s[i]->priority>shadprio||stylePtr->shadow.color==NULL)) { |
| 1015 |
stylePtr->shadow = s[i]->shadow; |
| 1016 |
shadprio = s[i]->priority; |
| 1017 |
} |
| 1018 |
if (s[i]->icon && (s[i]->priority>iconprio||stylePtr->icon==NULL)) { |
| 1019 |
stylePtr->icon = s[i]->icon; |
| 1020 |
iconprio = s[i]->priority; |
| 1021 |
} |
| 1022 |
if (s[i]->tile && (s[i]->priority>tileprio||stylePtr->tile==NULL)) { |
| 1023 |
stylePtr->tile = s[i]->tile; |
| 1024 |
tileprio = s[i]->priority; |
| 1025 |
} |
| 1026 |
} |
| 1027 |
if (entryPtr == NULL) { |
| 1028 |
if (stylePtr->font==NULL) stylePtr->font = tvPtr->font; |
| 1029 |
if (stylePtr->border==NULL) stylePtr->border = tvPtr->border; |
| 1030 |
if (stylePtr->fgColor==NULL) stylePtr->fgColor = tvPtr->fgColor; |
| 1031 |
} else { |
| 1032 |
if (stylePtr->font==NULL) stylePtr->font = CHOOSE3(tvPtr->font,(columnPtr?columnPtr->font:NULL),entryPtr->font); |
| 1033 |
if (stylePtr->border==NULL) stylePtr->border = CHOOSE(tvPtr->border,entryPtr->border); |
| 1034 |
if (stylePtr->fgColor==NULL) stylePtr->fgColor = CHOOSE(tvPtr->fgColor,entryPtr->color); |
| 1035 |
if (stylePtr->shadow.color==NULL) stylePtr->shadow = entryPtr->shadow; |
| 1036 |
} |
| 1037 |
if (stylePtr->tile==NULL) stylePtr->tile = tvPtr->tile; |
| 1038 |
} |
| 1039 |
|
| 1040 |
#define IFSET(var,val) var = (val?val:var) |
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
void |
| 1046 |
drawTextBox(tvPtr, drawable, entryPtr, valuePtr, stylePtr, icon, x, y, sRec) |
| 1047 |
TreeView *tvPtr; |
| 1048 |
Drawable drawable; |
| 1049 |
TreeViewEntry *entryPtr; |
| 1050 |
TreeViewValue *valuePtr; |
| 1051 |
TreeViewStyle *stylePtr; |
| 1052 |
TreeViewIcon icon; |
| 1053 |
int x, y; |
| 1054 |
TreeViewStyle *sRec; |
| 1055 |
{ |
| 1056 |
TreeViewColumn *columnPtr; |
| 1057 |
int altRow = (entryPtr->flags&ENTRY_ALTROW); |
| 1058 |
|
| 1059 |
columnPtr = valuePtr->columnPtr; |
| 1060 |
sRec->font = CHOOSE(tvPtr->font, columnPtr->font); |
| 1061 |
sRec->fgColor = CHOOSE(tvPtr->fgColor, columnPtr->fgColor); |
| 1062 |
sRec->border = tvPtr->border; |
| 1063 |
sRec->gc = tvPtr->stylePtr->gc; |
| 1064 |
GetPriorityStyle(tvPtr, entryPtr, valuePtr, stylePtr, sRec); |
| 1065 |
|
| 1066 |
if ((tvPtr->activeColumnPtr == valuePtr->columnPtr && tvPtr->actCol) || |
| 1067 |
(valuePtr == tvPtr->activeValuePtr) || |
| 1068 |
(tvPtr->activeButtonPtr == entryPtr && tvPtr->actEntry) || |
| 1069 |
(stylePtr->flags & STYLE_HIGHLIGHT)) { |
| 1070 |
IFSET(sRec->border, stylePtr->highlightBorder); |
| 1071 |
IFSET(sRec->fgColor, stylePtr->highlightFgColor); |
| 1072 |
} else if (valuePtr->stylePtr && valuePtr->stylePtr->border) { |
| 1073 |
sRec->border = valuePtr->stylePtr->border; |
| 1074 |
} else if (columnPtr->hasbg) { |
| 1075 |
sRec->border = columnPtr->border; |
| 1076 |
|
| 1077 |
} else if ((Blt_HasTile(tvPtr->tile) || Blt_HasTile(columnPtr->tile)) && Blt_HasTile(stylePtr->tile)==0) { |
| 1078 |
sRec->border = NULL; |
| 1079 |
} else if (altRow && tvPtr->altStylePtr && Blt_HasTile(tvPtr->altStylePtr->tile)) { |
| 1080 |
stylePtr = tvPtr->altStylePtr; |
| 1081 |
} |
| 1082 |
if (!Blt_TreeViewEntryIsSelected(tvPtr, entryPtr, columnPtr)) { |
| 1083 |
|
| 1084 |
|
| 1085 |
|
| 1086 |
|
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
if (sRec->border != NULL && (altRow==0 || |
| 1091 |
(altRow && stylePtr->tile && stylePtr == tvPtr->altStylePtr))) { |
| 1092 |
Blt_TreeViewFill3DTile(tvPtr, drawable, sRec->border, |
| 1093 |
x - columnPtr->pad.side1, y - tvPtr->leader/2, |
| 1094 |
columnPtr->width, entryPtr->height, |
| 1095 |
0, TK_RELIEF_FLAT, entryPtr->gc?NULL:stylePtr->tile, tvPtr->scrollTile, 1); |
| 1096 |
} |
| 1097 |
} |
| 1098 |
} |
| 1099 |
|
| 1100 |
|
| 1101 |
|
| 1102 |
|
| 1103 |
static void |
| 1104 |
GetColorPats(tvPtr, entryPtr, valuePtr, stylePtr, fgPtr) |
| 1105 |
TreeView *tvPtr; |
| 1106 |
TreeViewEntry *entryPtr; |
| 1107 |
TreeViewValue *valuePtr; |
| 1108 |
TreeViewStyle *stylePtr; |
| 1109 |
XColor **fgPtr; |
| 1110 |
{ |
| 1111 |
XColor *color = NULL; |
| 1112 |
Tcl_Interp *interp = tvPtr->interp; |
| 1113 |
int objc, i; |
| 1114 |
Tcl_Obj **objv, *objPtr = NULL; |
| 1115 |
TreeViewColumn *columnPtr = valuePtr->columnPtr; |
| 1116 |
|
| 1117 |
if (columnPtr->colorPats != NULL && strlen(Tcl_GetString(columnPtr->colorPats))) { |
| 1118 |
if (Tcl_ListObjGetElements(NULL, columnPtr->colorPats, &objc, &objv) != TCL_OK) return; |
| 1119 |
if (objc%2) return; |
| 1120 |
for (i = 0; i < objc; i += 2) { |
| 1121 |
if (Tcl_StringMatch(valuePtr->string, Tcl_GetString(objv[i]))) { |
| 1122 |
color = Tk_AllocColorFromObj(interp, tvPtr->tkwin, objv[i+1]); |
| 1123 |
if (color != NULL) { |
| 1124 |
*fgPtr = color; |
| 1125 |
return; |
| 1126 |
} |
| 1127 |
} |
| 1128 |
} |
| 1129 |
} |
| 1130 |
if (columnPtr->colorRegex != NULL && strlen(Tcl_GetString(columnPtr->colorRegex))) { |
| 1131 |
if (Tcl_ListObjGetElements(NULL, columnPtr->colorRegex, &objc, &objv) != TCL_OK) return; |
| 1132 |
if (objc%2) return; |
| 1133 |
for (i = 0; i < objc; i += 2) { |
| 1134 |
if (objPtr == NULL) { |
| 1135 |
objPtr = Tcl_NewStringObj(valuePtr->string,-1); |
| 1136 |
Tcl_IncrRefCount(objPtr); |
| 1137 |
} |
| 1138 |
if (Tcl_RegExpMatchObj(NULL, objPtr, objv[i]) == 1) { |
| 1139 |
color = Tk_AllocColorFromObj(interp, tvPtr->tkwin, objv[i+1]); |
| 1140 |
if (color != NULL) { |
| 1141 |
*fgPtr = color; |
| 1142 |
break; |
| 1143 |
} |
| 1144 |
} |
| 1145 |
} |
| 1146 |
if (objPtr != NULL) { |
| 1147 |
Tcl_DecrRefCount(objPtr); |
| 1148 |
} |
| 1149 |
} |
| 1150 |
} |
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
static void |
| 1169 |
DrawTextBox(tvPtr, drawable, entryPtr, valuePtr, stylePtr, icon, x, y) |
| 1170 |
TreeView *tvPtr; |
| 1171 |
Drawable drawable; |
| 1172 |
TreeViewEntry *entryPtr; |
| 1173 |
TreeViewValue *valuePtr; |
| 1174 |
TreeViewStyle *stylePtr; |
| 1175 |
TreeViewIcon icon; |
| 1176 |
int x, y; |
| 1177 |
{ |
| 1178 |
GC gc; |
| 1179 |
TreeViewColumn *columnPtr; |
| 1180 |
TreeViewTextBox *tbPtr = (TreeViewTextBox *)stylePtr; |
| 1181 |
int iconX, iconY, iconWidth, iconHeight; |
| 1182 |
int textX, textY, textWidth, textHeight; |
| 1183 |
int gap, columnWidth, ix = x; |
| 1184 |
TreeViewStyle sRec = *stylePtr; |
| 1185 |
int valWidth; |
| 1186 |
TextLayout *layPtr; |
| 1187 |
|
| 1188 |
layPtr = (tvPtr->hideStyleText?NULL:valuePtr->textPtr); |
| 1189 |
columnPtr = valuePtr->columnPtr; |
| 1190 |
valWidth = (layPtr?valuePtr->width:(icon?TreeViewIconWidth(icon):0)); |
| 1191 |
if (!stylePtr) return; |
| 1192 |
drawTextBox(tvPtr, drawable, entryPtr, valuePtr, stylePtr, icon, x, y, &sRec); |
| 1193 |
gc = sRec.gc; |
| 1194 |
columnWidth = columnPtr->width - |
| 1195 |
(2 * columnPtr->borderWidth + PADDING(columnPtr->pad)); |
| 1196 |
|
| 1197 |
textX = textY = iconX = iconY = 0; |
| 1198 |
|
| 1199 |
iconWidth = iconHeight = 0; |
| 1200 |
if (icon != NULL) { |
| 1201 |
iconWidth = TreeViewIconWidth(icon); |
| 1202 |
iconHeight = TreeViewIconHeight(icon); |
| 1203 |
} |
| 1204 |
textWidth = textHeight = 0; |
| 1205 |
if (layPtr != NULL) { |
| 1206 |
textWidth = layPtr->width; |
| 1207 |
textHeight = layPtr->height; |
| 1208 |
} |
| 1209 |
gap = 0; |
| 1210 |
if ((icon != NULL) && (layPtr != NULL)) { |
| 1211 |
gap = stylePtr->gap; |
| 1212 |
} |
| 1213 |
if (columnWidth >= valWidth) { |
| 1214 |
switch(columnPtr->justify) { |
| 1215 |
case TK_JUSTIFY_RIGHT: |
| 1216 |
ix = x + columnWidth - iconWidth; |
| 1217 |
x += (columnWidth - valWidth); |
| 1218 |
break; |
| 1219 |
case TK_JUSTIFY_CENTER: |
| 1220 |
ix = x + (columnWidth - iconWidth)/2; |
| 1221 |
x += (columnWidth - valWidth) / 2; |
| 1222 |
break; |
| 1223 |
case TK_JUSTIFY_LEFT: |
| 1224 |
break; |
| 1225 |
} |
| 1226 |
} |
| 1227 |
|
| 1228 |
switch (tbPtr->iconside) { |
| 1229 |
case SIDE_RIGHT: |
| 1230 |
textX = x; |
| 1231 |
textY = y + (entryPtr->height - textHeight) / 2; |
| 1232 |
iconX = textX + textWidth + gap; |
| 1233 |
iconY = y + (entryPtr->height - iconHeight) / 2; |
| 1234 |
break; |
| 1235 |
case SIDE_LEFT: |
| 1236 |
iconX = x; |
| 1237 |
iconY = y + (entryPtr->height - iconHeight) / 2; |
| 1238 |
textX = iconX + iconWidth + gap; |
| 1239 |
textY = y + (entryPtr->height - textHeight) / 2; |
| 1240 |
break; |
| 1241 |
case SIDE_TOP: |
| 1242 |
iconY = y; |
| 1243 |
if (tbPtr->side == SIDE_BOTTOM) { |
| 1244 |
iconY = y + (entryPtr->height - textHeight - iconHeight - gap*2); |
| 1245 |
} |
| 1246 |
iconX = ix; |
| 1247 |
textY = iconY + iconHeight + gap; |
| 1248 |
textX = x; |
| 1249 |
if (iconWidth>textWidth) { |
| 1250 |
textX = x + (iconWidth-textWidth)/2; |
| 1251 |
} |
| 1252 |
break; |
| 1253 |
case SIDE_BOTTOM: |
| 1254 |
textX = x; |
| 1255 |
textY = y; |
| 1256 |
if (tbPtr->side == SIDE_BOTTOM) { |
| 1257 |
textY = y + (entryPtr->height - textHeight - iconHeight - gap*2); |
| 1258 |
} |
| 1259 |
if (iconWidth>textWidth) { |
| 1260 |
textX = x + (iconWidth-textWidth)/2; |
| 1261 |
} |
| 1262 |
iconY = textY + textHeight + gap; |
| 1263 |
iconX = ix; |
| 1264 |
break; |
| 1265 |
} |
| 1266 |
valuePtr->iX = iconX; |
| 1267 |
valuePtr->iY = iconY; |
| 1268 |
valuePtr->iW = iconWidth; |
| 1269 |
valuePtr->iH = iconHeight; |
| 1270 |
valuePtr->tX = textX; |
| 1271 |
valuePtr->tY = textY; |
| 1272 |
valuePtr->tW = textWidth; |
| 1273 |
valuePtr->tH = textHeight; |
| 1274 |
if (icon != NULL) { |
| 1275 |
if (Blt_TreeViewRedrawIcon(tvPtr, entryPtr, columnPtr, icon, 0, 0, iconWidth, |
| 1276 |
iconHeight, drawable, iconX, iconY) != TCL_OK) return; |
| 1277 |
} |
| 1278 |
if (layPtr != NULL) { |
| 1279 |
TextStyle ts; |
| 1280 |
XColor *color; |
| 1281 |
int disabled = (entryPtr->state == STATE_DISABLED); |
| 1282 |
|
| 1283 |
if (disabled) { |
| 1284 |
color = tvPtr->disabledColor; |
| 1285 |
} else if (Blt_TreeViewEntryIsSelected(tvPtr, entryPtr, columnPtr)) { |
| 1286 |
color = SELECT_FG(tvPtr); |
| 1287 |
} else if (entryPtr->color != NULL) { |
| 1288 |
color = entryPtr->color; |
| 1289 |
} else { |
| 1290 |
color = sRec.fgColor; |
| 1291 |
GetColorPats(tvPtr, entryPtr, valuePtr, stylePtr, &color ); |
| 1292 |
} |
| 1293 |
XSetForeground(tvPtr->display, gc, color->pixel); |
| 1294 |
Blt_SetDrawTextStyle(&ts, sRec.font, gc, color, sRec.fgColor, |
| 1295 |
stylePtr->shadow.color, 0.0, |
| 1296 |
TK_ANCHOR_NW, columnPtr->justify, 0, stylePtr->shadow.offset); |
| 1297 |
Blt_DrawTextLayout(tvPtr->tkwin, drawable, layPtr, |
| 1298 |
&ts, textX, textY); |
| 1299 |
if (color != sRec.fgColor) { |
| 1300 |
XSetForeground(tvPtr->display, gc, sRec.fgColor->pixel); |
| 1301 |
} |
| 1302 |
} else { |
| 1303 |
valuePtr->tW = 0; |
| 1304 |
} |
| 1305 |
stylePtr->flags &= ~STYLE_DIRTY; |
| 1306 |
} |
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
static int |
| 1325 |
EditTextBox(tvPtr, entryPtr, valuePtr, stylePtr, x, y, retVal) |
| 1326 |
TreeView *tvPtr; |
| 1327 |
TreeViewEntry *entryPtr; |
| 1328 |
TreeViewValue *valuePtr; |
| 1329 |
TreeViewStyle *stylePtr; |
| 1330 |
int x; |
| 1331 |
int y; |
| 1332 |
int *retVal; |
| 1333 |
{ |
| 1334 |
int isTest = *retVal; |
| 1335 |
*retVal = 0; |
| 1336 |
if (isTest) { |
| 1337 |
return TCL_OK; |
| 1338 |
} |
| 1339 |
return Blt_TreeViewTextbox(tvPtr, entryPtr, valuePtr->columnPtr); |
| 1340 |
} |
| 1341 |
|
| 1342 |
|
| 1343 |
|
| 1344 |
|
| 1345 |
|
| 1346 |
|
| 1347 |
|
| 1348 |
|
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 |
|
| 1353 |
|
| 1354 |
|
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
|
| 1361 |
static void |
| 1362 |
FreeTextBox(tvPtr, stylePtr) |
| 1363 |
TreeView *tvPtr; |
| 1364 |
TreeViewStyle *stylePtr; |
| 1365 |
{ |
| 1366 |
if (!stylePtr) return; |
| 1367 |
if (stylePtr->highlightGC != NULL) { |
| 1368 |
Tk_FreeGC(tvPtr->display, stylePtr->highlightGC); |
| 1369 |
} |
| 1370 |
if (stylePtr->activeGC != NULL) { |
| 1371 |
Tk_FreeGC(tvPtr->display, stylePtr->activeGC); |
| 1372 |
} |
| 1373 |
if (stylePtr->gc != NULL) { |
| 1374 |
Tk_FreeGC(tvPtr->display, stylePtr->gc); |
| 1375 |
} |
| 1376 |
if (stylePtr->icon != NULL) { |
| 1377 |
Blt_TreeViewFreeIcon(tvPtr, stylePtr->icon); |
| 1378 |
} |
| 1379 |
|
| 1380 |
} |
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
|
| 1387 |
|
| 1388 |
|
| 1389 |
|
| 1390 |
|
| 1391 |
|
| 1392 |
|
| 1393 |
|
| 1394 |
|
| 1395 |
static TreeViewStyle * |
| 1396 |
CreateCheckBox(tvPtr, hPtr) |
| 1397 |
TreeView *tvPtr; |
| 1398 |
Blt_HashEntry *hPtr; |
| 1399 |
{ |
| 1400 |
TreeViewCheckBox *cbPtr; |
| 1401 |
|
| 1402 |
cbPtr = (TreeViewCheckBox *)newStyle(tvPtr, hPtr, sizeof(TreeViewCheckBox)); |
| 1403 |
cbPtr->classPtr = &checkBoxClass; |
| 1404 |
cbPtr->gap = 4; |
| 1405 |
cbPtr->size = 11; |
| 1406 |
cbPtr->lineWidth = 1; |
| 1407 |
cbPtr->showValue = TRUE; |
| 1408 |
cbPtr->flags = STYLE_CHECKBOX; |
| 1409 |
return (TreeViewStyle *)cbPtr; |
| 1410 |
} |
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
static void |
| 1429 |
ConfigureCheckBox(tvPtr, stylePtr) |
| 1430 |
TreeView *tvPtr; |
| 1431 |
TreeViewStyle *stylePtr; |
| 1432 |
{ |
| 1433 |
GC newGC; |
| 1434 |
TreeViewCheckBox *cbPtr = (TreeViewCheckBox *)stylePtr; |
| 1435 |
XColor *bgColor; |
| 1436 |
XGCValues gcValues; |
| 1437 |
unsigned long gcMask; |
| 1438 |
|
| 1439 |
bgColor = Tk_3DBorderColor(CHOOSE(tvPtr->border, stylePtr->border)); |
| 1440 |
|
| 1441 |
gcValues.background = bgColor->pixel; |
| 1442 |
gcValues.foreground = CHOOSE(tvPtr->fgColor, stylePtr->fgColor)->pixel; |
| 1443 |
ConfigureTextBox(tvPtr, stylePtr); |
| 1444 |
gcMask = GCForeground; |
| 1445 |
gcValues.foreground = cbPtr->fillColor->pixel; |
| 1446 |
newGC = Tk_GetGC(tvPtr->tkwin, gcMask, &gcValues); |
| 1447 |
if (cbPtr->fillGC != NULL) { |
| 1448 |
Tk_FreeGC(tvPtr->display, cbPtr->fillGC); |
| 1449 |
} |
| 1450 |
cbPtr->fillGC = newGC; |
| 1451 |
|
| 1452 |
gcMask = GCForeground | GCLineWidth; |
| 1453 |
gcValues.line_width = cbPtr->lineWidth; |
| 1454 |
gcValues.foreground = cbPtr->boxColor->pixel; |
| 1455 |
newGC = Tk_GetGC(tvPtr->tkwin, gcMask, &gcValues); |
| 1456 |
if (cbPtr->boxGC != NULL) { |
| 1457 |
Tk_FreeGC(tvPtr->display, cbPtr->boxGC); |
| 1458 |
} |
| 1459 |
cbPtr->boxGC = newGC; |
| 1460 |
|
| 1461 |
gcMask = GCForeground | GCLineWidth; |
| 1462 |
gcValues.line_width = 1; |
| 1463 |
gcValues.foreground = cbPtr->checkColor->pixel; |
| 1464 |
newGC = Tk_GetGC(tvPtr->tkwin, gcMask, &gcValues); |
| 1465 |
if (cbPtr->checkGC != NULL) { |
| 1466 |
Tk_FreeGC(tvPtr->display, cbPtr->checkGC); |
| 1467 |
} |
| 1468 |
cbPtr->checkGC = newGC; |
| 1469 |
if (cbPtr->checkBg) { |
| 1470 |
bgColor = Tk_3DBorderColor(cbPtr->checkBg); |
| 1471 |
gcValues.background = bgColor->pixel; |
| 1472 |
gcValues.foreground = bgColor->pixel; |
| 1473 |
newGC = Tk_GetGC(tvPtr->tkwin, gcMask, &gcValues); |
| 1474 |
if (cbPtr->bgGC != NULL) { |
| 1475 |
Tk_FreeGC(tvPtr->display, cbPtr->bgGC); |
| 1476 |
} |
| 1477 |
cbPtr->bgGC = newGC; |
| 1478 |
} |
| 1479 |
stylePtr->flags |= STYLE_DIRTY; |
| 1480 |
} |
| 1481 |
|
| 1482 |
|
| 1483 |
|
| 1484 |
|
| 1485 |
|
| 1486 |
|
| 1487 |
|
| 1488 |
|
| 1489 |
|
| 1490 |
|
| 1491 |
|
| 1492 |
|
| 1493 |
|
| 1494 |
|
| 1495 |
|
| 1496 |
|
| 1497 |
|
| 1498 |
|
| 1499 |
|
| 1500 |
|
| 1501 |
static void |
| 1502 |
MeasureCheckBox(tvPtr, stylePtr, valuePtr) |
| 1503 |
TreeView *tvPtr; |
| 1504 |
TreeViewStyle *stylePtr; |
| 1505 |
TreeViewValue *valuePtr; |
| 1506 |
{ |
| 1507 |
TreeViewCheckBox *cbPtr = (TreeViewCheckBox *)stylePtr; |
| 1508 |
TreeViewColumn *columnPtr = valuePtr->columnPtr; |
| 1509 |
int iconWidth, iconHeight; |
| 1510 |
int textWidth, textHeight; |
| 1511 |
int gap; |
| 1512 |
int boxWidth, boxHeight; |
| 1513 |
TreeViewIcon icon; |
| 1514 |
|
| 1515 |
boxWidth = boxHeight = ODD(cbPtr->size); |
| 1516 |
|
| 1517 |
if (cbPtr->icons) { |
| 1518 |
TreeViewIcon mIcon; |
| 1519 |
int i; |
| 1520 |
|
| 1521 |
for (i=0; i<2; i++) { |
| 1522 |
mIcon = cbPtr->icons[i]; |
| 1523 |
if (mIcon) { |
| 1524 |
int mwid = TreeViewIconWidth(mIcon); |
| 1525 |
int mhig = TreeViewIconHeight(mIcon); |
| 1526 |
if (mwid>boxWidth) { boxWidth = mwid; } |
| 1527 |
if (mhig>boxHeight) { boxHeight = mhig; } |
| 1528 |
} |
| 1529 |
} |
| 1530 |
} |
| 1531 |
textWidth = textHeight = iconWidth = iconHeight = 0; |
| 1532 |
valuePtr->width = valuePtr->height = 0; |
| 1533 |
icon = (stylePtr->icon?stylePtr->icon:(columnPtr->stylePtr?columnPtr->stylePtr->icon:NULL)); |
| 1534 |
if (icon != NULL && tvPtr->hideStyleIcons == 0) { |
| 1535 |
iconWidth = TreeViewIconWidth(icon); |
| 1536 |
iconHeight = TreeViewIconHeight(icon); |
| 1537 |
} |
| 1538 |
if (cbPtr->onPtr != NULL) { |
| 1539 |
Blt_Free(cbPtr->onPtr); |
| 1540 |
cbPtr->onPtr = NULL; |
| 1541 |
} |
| 1542 |
if (cbPtr->offPtr != NULL) { |
| 1543 |
Blt_Free(cbPtr->offPtr); |
| 1544 |
cbPtr->offPtr = NULL; |
| 1545 |
} |
| 1546 |
gap = 0; |
| 1547 |
if (cbPtr->showValue && tvPtr->hideStyleText == 0) { |
| 1548 |
TextStyle ts; |
| 1549 |
char *string; |
| 1550 |
|
| 1551 |
Blt_InitTextStyle(&ts); |
| 1552 |
ts.font = CHOOSE3(tvPtr->font, columnPtr->font, stylePtr->font); |
| 1553 |
ts.anchor = TK_ANCHOR_NW; |
| 1554 |
ts.justify = columnPtr->justify; |
| 1555 |
string = (cbPtr->onValue != NULL) ? cbPtr->onValue : valuePtr->string; |
| 1556 |
cbPtr->onPtr = Blt_GetTextLayout(string, &ts); |
| 1557 |
string = (cbPtr->offValue != NULL) ? cbPtr->offValue : valuePtr->string; |
| 1558 |
cbPtr->offPtr = Blt_GetTextLayout(string, &ts); |
| 1559 |
textWidth = MAX(cbPtr->offPtr->width, cbPtr->onPtr->width); |
| 1560 |
textHeight = MAX(cbPtr->offPtr->height, cbPtr->onPtr->height); |
| 1561 |
if (stylePtr->icon != NULL) { |
| 1562 |
gap = stylePtr->gap; |
| 1563 |
} |
| 1564 |
} |
| 1565 |
valuePtr->width = stylePtr->gap * 2 + boxWidth + iconWidth + gap + textWidth; |
| 1566 |
valuePtr->height = MAX3(boxHeight, textHeight, iconHeight); |
| 1567 |
} |
| 1568 |
|
| 1569 |
|
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
|
| 1578 |
|
| 1579 |
|
| 1580 |
|
| 1581 |
|
| 1582 |
|
| 1583 |
|
| 1584 |
|
| 1585 |
|
| 1586 |
static void |
| 1587 |
DrawCheckBox(tvPtr, drawable, entryPtr, valuePtr, stylePtr, icon, x, y) |
| 1588 |
TreeView *tvPtr; |
| 1589 |
Drawable drawable; |
| 1590 |
TreeViewEntry *entryPtr; |
| 1591 |
TreeViewValue *valuePtr; |
| 1592 |
TreeViewStyle *stylePtr; |
| 1593 |
TreeViewIcon icon; |
| 1594 |
int x, y; |
| 1595 |
{ |
| 1596 |
GC gc; |
| 1597 |
TreeViewColumn *columnPtr; |
| 1598 |
TreeViewCheckBox *cbPtr = (TreeViewCheckBox *)stylePtr; |
| 1599 |
int iconX, iconY, iconWidth, iconHeight; |
| 1600 |
int textX, textY, textHeight; |
| 1601 |
int gap, columnWidth, ttlWidth; |
| 1602 |
int bool; |
| •1603 |
|
| 1604 |
TextLayout *textPtr; |
| 1605 |
int boxX, boxY, boxWidth, boxHeight; |
| 1606 |
TreeViewStyle *csPtr, sRec = *stylePtr; |
| 1607 |
int valWidth = (valuePtr->textPtr?valuePtr->width:(icon?TreeViewIconWidth(icon):0)); |
| 1608 |
int showValue; |
| 1609 |
|
| 1610 |
showValue = (tvPtr->hideStyleText ? 0 : cbPtr->showValue); |
| 1611 |
|
| 1612 |
columnPtr = valuePtr->columnPtr; |
| 1613 |
csPtr = columnPtr->stylePtr; |
| 1614 |
|
| 1615 |
drawTextBox(tvPtr, drawable, entryPtr, valuePtr, stylePtr, icon, x, y, &sRec); |
| 1616 |
gc = sRec.gc; |
| 1617 |
|
| •1618 |
|
| 1619 |
|
| 1620 |
|
| 1621 |
|
| 1622 |
|
| 1623 |
|
| •1624 |
|
| 1625 |
|
| 1626 |
columnWidth = columnPtr->width - PADDING(columnPtr->pad); |
| 1627 |
if (!valuePtr->string) { |
| 1628 |
return; |
| 1629 |
} |
| 1630 |
|
| 1631 |
if (cbPtr->size) { |
| 1632 |
boxWidth = boxHeight = ODD(cbPtr->size); |
| 1633 |
} else { |
| 1634 |
boxWidth = boxHeight = 0; |
| 1635 |
} |
| 1636 |
ttlWidth = ( boxWidth + stylePtr->gap * 2); |
| 1637 |
if (showValue) { |
| 1638 |
ttlWidth += (valWidth + stylePtr->gap); |
| 1639 |
} |
| 1640 |
if (icon != NULL) { |
| 1641 |
iconWidth = TreeViewIconWidth(icon); |
| 1642 |
iconHeight = TreeViewIconHeight(icon); |
| 1643 |
ttlWidth += iconWidth + stylePtr->gap; |
| 1644 |
} |
| 1645 |
|
| 1646 |
if (columnWidth > ttlWidth) { |
| 1647 |
switch(columnPtr->justify) { |
| 1648 |
case TK_JUSTIFY_RIGHT: |
| 1649 |
x += (columnWidth - ttlWidth - stylePtr->gap*2); |
| 1650 |
break; |
| 1651 |
case TK_JUSTIFY_CENTER: |
| 1652 |
x += (columnWidth - ttlWidth) / 2; |
| 1653 |
break; |
| 1654 |
case TK_JUSTIFY_LEFT: |
| 1655 |
break; |
| 1656 |
} |
| 1657 |
} |
| 1658 |
|
| 1659 |
bool = (strcmp(valuePtr->string, cbPtr->onValue) == 0); |
| 1660 |
textPtr = (bool) ? cbPtr->onPtr : cbPtr->offPtr; |
| 1661 |
|
| 1662 |
cbPtr->boxW = cbPtr->boxH = 0; |
| 1663 |
cbPtr->boxX = boxX = x + stylePtr->gap; |
| 1664 |
boxY = y + (entryPtr->height - boxHeight) / 2; |
| 1665 |
|
| 1666 |
if (cbPtr->icons != NULL) { |
| 1667 |
TreeViewIcon mIcon; |
| 1668 |
mIcon = cbPtr->icons[bool]; |
| 1669 |
if (mIcon) { |
| 1670 |
int mwid = TreeViewIconWidth(mIcon); |
| 1671 |
int mhig = TreeViewIconHeight(mIcon); |
| 1672 |
cbPtr->boxW = mwid; |
| 1673 |
cbPtr->boxH = mhig; |
| 1674 |
boxY = y + (entryPtr->height - mhig) / 2; |
| 1675 |
if (Blt_TreeViewRedrawIcon(tvPtr, entryPtr, columnPtr, mIcon, 0, 0, mwid, |
| 1676 |
mhig, drawable, boxX, boxY) != TCL_OK) return; |
| 1677 |
} |
| 1678 |
|
| 1679 |
} else { |
| 1680 |
|
| 1681 |
|
| 1682 |
|
| 1683 |
|
| 1684 |
|
| 1685 |
|
| 1686 |
|
| 1687 |
|
| 1688 |
|
| 1689 |
|
| 1690 |
|
| 1691 |
|
| 1692 |
|
| 1693 |
if (boxWidth) { |
| 1694 |
if (cbPtr->checkBg) { |
| 1695 |
XFillRectangle(tvPtr->display, drawable, cbPtr->bgGC, boxX, boxY, |
| 1696 |
boxWidth, boxHeight); |
| 1697 |
} else { |
| 1698 |
if (Blt_HasTile(stylePtr->fillTile)) { |
| 1699 |
Blt_SetTileOrigin(tvPtr->tkwin, stylePtr->fillTile, -boxX, -boxY); |
| 1700 |
Blt_TileRectangle(tvPtr->tkwin, drawable, stylePtr->fillTile, |
| 1701 |
boxX, boxY, boxWidth, boxHeight ); |
| 1702 |
} else if (csPtr != NULL && Blt_HasTile(csPtr->fillTile)) { |
| 1703 |
Blt_SetTileOrigin(tvPtr->tkwin, csPtr->fillTile, -boxX, -boxY); |
| 1704 |
Blt_TileRectangle(tvPtr->tkwin, drawable, csPtr->fillTile, |
| 1705 |
boxX, boxY, boxWidth, boxHeight ); |
| 1706 |
} else { |
| 1707 |
XFillRectangle(tvPtr->display, drawable, cbPtr->fillGC, boxX, boxY, boxWidth, boxHeight); |
| 1708 |
|
| 1709 |
} |
| 1710 |
} |
| 1711 |
cbPtr->boxW = boxWidth; |
| 1712 |
cbPtr->boxH = boxHeight; |
| 1713 |
XDrawRectangle(tvPtr->display, drawable, cbPtr->boxGC, boxX, boxY, |
| 1714 |
boxWidth, boxHeight); |
| 1715 |
|
| 1716 |
if (bool) { |
| 1717 |
int midX, midY; |
| 1718 |
int i; |
| 1719 |
|
| 1720 |
for (i = 0; i < 3; i++) { |
| 1721 |
midX = boxX + 2 * boxWidth / 5; |
| 1722 |
midY = boxY + boxHeight - 5 + i; |
| 1723 |
XDrawLine(tvPtr->display, drawable, cbPtr->checkGC, |
| 1724 |
boxX + 2, boxY + boxHeight / 3 + 1 + i, midX, midY); |
| 1725 |
XDrawLine(tvPtr->display, drawable, cbPtr->checkGC, |
| 1726 |
midX, midY, boxX + boxWidth - 2, boxY + i + 1); |
| 1727 |
} |
| 1728 |
} |
| 1729 |
} |
| 1730 |
} |
| 1731 |
#ifdef notdef |
| 1732 |
textX = textY = iconX = iconY = 0; |
| 1733 |
#endif |
| 1734 |
iconWidth = iconHeight = 0; |
| 1735 |
if (icon != NULL) { |
| 1736 |
iconWidth = TreeViewIconWidth(icon); |
| 1737 |
iconHeight = TreeViewIconHeight(icon); |
| 1738 |
} |
| 1739 |
textHeight = 0; |
| 1740 |
gap = 0; |
| 1741 |
if (showValue) { |
| 1742 |
textHeight = textPtr->height; |
| 1743 |
if (icon != NULL) { |
| 1744 |
gap = stylePtr->gap; |
| 1745 |
} |
| 1746 |
} |
| 1747 |
x = boxX + boxWidth + stylePtr->gap; |
| 1748 |
|
| 1749 |
|
| 1750 |
iconX = x; |
| 1751 |
iconY = y + (entryPtr->height - iconHeight) / 2; |
| 1752 |
textX = iconX + iconWidth + gap; |
| 1753 |
textY = y + (entryPtr->height - textHeight) / 2; |
| 1754 |
|
| 1755 |
valuePtr->iX = iconX; |
| 1756 |
valuePtr->iY = iconY; |
| 1757 |
valuePtr->iW = iconWidth; |
| 1758 |
valuePtr->iH = iconHeight; |
| 1759 |
valuePtr->tX = textX; |
| 1760 |
valuePtr->tY = textY; |
| 1761 |
valuePtr->tW = (textPtr?textPtr->width:0); |
| 1762 |
valuePtr->tH = textHeight; |
| 1763 |
|
| 1764 |
if (icon != NULL) { |
| 1765 |
if (Blt_TreeViewRedrawIcon(tvPtr, entryPtr, columnPtr, icon, 0, 0, iconWidth, |
| 1766 |
iconHeight, drawable, iconX, iconY) != TCL_OK) return; |
| 1767 |
} else { |
| 1768 |
valuePtr->iW = 0; |
| 1769 |
} |
| 1770 |
if ((showValue) && (textPtr != NULL)) { |
| 1771 |
TextStyle ts; |
| 1772 |
XColor *color; |
| 1773 |
|
| 1774 |
int disabled = (entryPtr->state == STATE_DISABLED); |
| 1775 |
|
| 1776 |
if (disabled) { |
| 1777 |
color = tvPtr->disabledColor; |
| 1778 |
} else if (Blt_TreeViewEntryIsSelected(tvPtr, entryPtr, columnPtr)) { |
| 1779 |
color = SELECT_FG(tvPtr); |
| 1780 |
} else if (entryPtr->color != NULL) { |
| 1781 |
color = entryPtr->color; |
| 1782 |
} else { |
| 1783 |
color = sRec.fgColor; |
| 1784 |
GetColorPats(tvPtr, entryPtr, valuePtr, stylePtr, &color ); |
| 1785 |
} |
| 1786 |
XSetForeground(tvPtr->display, gc, color->pixel); |
| 1787 |
Blt_SetDrawTextStyle(&ts, sRec.font, gc, color, sRec.fgColor, |
| 1788 |
stylePtr->shadow.color, 0.0, |
| 1789 |
TK_ANCHOR_NW, columnPtr->justify, 0, stylePtr->shadow.offset); |
| 1790 |
Blt_DrawTextLayout(tvPtr->tkwin, drawable, textPtr, &ts, textX, textY); |
| 1791 |
if (color != sRec.fgColor) { |
| 1792 |
XSetForeground(tvPtr->display, gc, sRec.fgColor->pixel); |
| 1793 |
} |
| 1794 |
} else { |
| 1795 |
valuePtr->tW = 0; |
| 1796 |
} |
| 1797 |
stylePtr->flags &= ~STYLE_DIRTY; |
| 1798 |
} |
| 1799 |
|
| 1800 |
#if 0 |
| 1801 |
|
| 1802 |
|
| 1803 |
|
| 1804 |
|
| 1805 |
|
| 1806 |
|
| 1807 |
|
| 1808 |
|
| 1809 |
|
| 1810 |
|
| 1811 |
|
| 1812 |
|
| 1813 |
|
| 1814 |
|
| 1815 |
|
| 1816 |
|
| 1817 |
static int |
| 1818 |
PickCheckBox(entryPtr, valuePtr, stylePtr, worldX, worldY) |
| 1819 |
TreeViewEntry *entryPtr; |
| 1820 |
TreeViewValue *valuePtr; |
| 1821 |
TreeViewStyle *stylePtr; |
| 1822 |
int worldX, worldY; |
| 1823 |
{ |
| 1824 |
TreeViewColumn *columnPtr; |
| 1825 |
TreeViewCheckBox *cbPtr = (TreeViewCheckBox *)stylePtr; |
| 1826 |
int columnWidth; |
| 1827 |
int x, y, width, height; |
| 1828 |
|
| 1829 |
columnPtr = valuePtr->columnPtr; |
| 1830 |
columnWidth = columnPtr->width - |
| 1831 |
(2 * columnPtr->borderWidth + PADDING(columnPtr->pad)); |
| 1832 |
if (columnWidth > valuePtr->width) { |
| 1833 |
switch(columnPtr->justify) { |
| 1834 |
case TK_JUSTIFY_RIGHT: |
| 1835 |
worldX += (columnWidth - valuePtr->width); |
| 1836 |
break; |
| 1837 |
case TK_JUSTIFY_CENTER: |
| 1838 |
worldX += (columnWidth - valuePtr->width) / 2; |
| 1839 |
break; |
| 1840 |
case TK_JUSTIFY_LEFT: |
| 1841 |
break; |
| 1842 |
} |
| 1843 |
} |
| 1844 |
width = height = ODD(cbPtr->size) + 2 * cbPtr->lineWidth; |
| 1845 |
x = columnPtr->worldX + columnPtr->pad.side1 + stylePtr->gap - |
| 1846 |
cbPtr->lineWidth; |
| 1847 |
y = entryPtr->worldY + (entryPtr->height - height) / 2; |
| 1848 |
if ((worldX >= x) && (worldX < (x + width)) && |
| 1849 |
(worldY >= y) && (worldY < (y + height))) { |
| 1850 |
return TRUE; |
| 1851 |
} |
| 1852 |
return FALSE; |
| 1853 |
} |
| 1854 |
#endif |
| 1855 |
|
| 1856 |
|
| 1857 |
|
| 1858 |
|
| 1859 |
|
| 1860 |
|
| 1861 |
|
| 1862 |
|
| 1863 |
|
| 1864 |
|
| 1865 |
|
| 1866 |
|
| 1867 |
|
| 1868 |
|
| 1869 |
|
| 1870 |
static int |
| 1871 |
EditCheckBox(tvPtr, entryPtr, valuePtr, stylePtr, x, y, retVal) |
| 1872 |
TreeView *tvPtr; |
| 1873 |
TreeViewEntry *entryPtr; |
| 1874 |
TreeViewValue *valuePtr; |
| 1875 |
TreeViewStyle *stylePtr; |
| 1876 |
int x; |
| 1877 |
int y; |
| 1878 |
int *retVal; |
| 1879 |
{ |
| 1880 |
TreeViewColumn *columnPtr; |
| 1881 |
TreeViewCheckBox *cbPtr = (TreeViewCheckBox *)stylePtr; |
| 1882 |
Tcl_Obj *objPtr; |
| 1883 |
int boxY, isTest = *retVal; |
| 1884 |
TreeViewStyle *vsPtr; |
| 1885 |
|
| 1886 |
*retVal = 1; |
| 1887 |
columnPtr = valuePtr->columnPtr; |
| 1888 |
if (Blt_TreeGetValueByKey(tvPtr->interp, tvPtr->tree, |
| 1889 |
entryPtr->node, columnPtr->key, &objPtr) != TCL_OK) { |
| 1890 |
return TCL_ERROR; |
| 1891 |
} |
| 1892 |
vsPtr = valuePtr->stylePtr; |
| 1893 |
if (vsPtr && vsPtr->noteditable) { |
| 1894 |
*retVal = 0; |
| 1895 |
return TCL_OK; |
| 1896 |
} |
| 1897 |
boxY = SCREENY(tvPtr, entryPtr->worldY) + (entryPtr->height -cbPtr->boxH) / 2; |
| 1898 |
if (cbPtr->halo>=0) { |
| 1899 |
int h = cbPtr->halo; |
| 1900 |
|
| 1901 |
if (x < (cbPtr->boxX - h) || x > (cbPtr->boxX + cbPtr->boxW + h) || |
| 1902 |
y < (boxY - h) || y > (boxY + cbPtr->boxH + h)) { |
| 1903 |
*retVal = 0; |
| 1904 |
return TCL_OK; |
| 1905 |
} |
| 1906 |
} |
| 1907 |
if (isTest) { |
| 1908 |
return TCL_OK; |
| 1909 |
} |
| 1910 |
if (strcmp(Tcl_GetString(objPtr), cbPtr->onValue) == 0) { |
| 1911 |
objPtr = Tcl_NewStringObj(cbPtr->offValue, -1); |
| 1912 |
} else { |
| 1913 |
objPtr = Tcl_NewStringObj(cbPtr->onValue, -1); |
| 1914 |
} |
| 1915 |
entryPtr->flags |= ENTRY_DIRTY; |
| 1916 |
tvPtr->flags |= (TV_DIRTY | TV_LAYOUT | TV_SCROLL | TV_RESORT); |
| 1917 |
if (Blt_TreeSetValueByKey(tvPtr->interp, tvPtr->tree, |
| 1918 |
entryPtr->node, columnPtr->key, objPtr) != TCL_OK) { |
| 1919 |
return TCL_ERROR; |
| 1920 |
} |
| 1921 |
return TCL_OK; |
| 1922 |
} |
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
|
| 1927 |
|
| 1928 |
|
| 1929 |
|
| 1930 |
|
| 1931 |
|
| 1932 |
|
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
|
| 1937 |
|
| 1938 |
|
| 1939 |
|
| 1940 |
|
| 1941 |
|
| 1942 |
static void |
| 1943 |
FreeCheckBox(tvPtr, stylePtr) |
| 1944 |
TreeView *tvPtr; |
| 1945 |
TreeViewStyle *stylePtr; |
| 1946 |
{ |
| 1947 |
TreeViewCheckBox *cbPtr = (TreeViewCheckBox *)stylePtr; |
| 1948 |
|
| 1949 |
FreeTextBox(tvPtr, stylePtr); |
| 1950 |
if (cbPtr->fillGC != NULL) { |
| 1951 |
Tk_FreeGC(tvPtr->display, cbPtr->fillGC); |
| 1952 |
} |
| 1953 |
if (cbPtr->boxGC != NULL) { |
| 1954 |
Tk_FreeGC(tvPtr->display, cbPtr->boxGC); |
| 1955 |
} |
| 1956 |
if (cbPtr->checkGC != NULL) { |
| 1957 |
Tk_FreeGC(tvPtr->display, cbPtr->checkGC); |
| 1958 |
} |
| 1959 |
if (cbPtr->offPtr != NULL) { |
| 1960 |
Blt_Free(cbPtr->offPtr); |
| 1961 |
} |
| 1962 |
if (cbPtr->onPtr != NULL) { |
| 1963 |
Blt_Free(cbPtr->onPtr); |
| 1964 |
} |
| 1965 |
if (cbPtr->bgGC != NULL) { |
| 1966 |
Tk_FreeGC(tvPtr->display, cbPtr->bgGC); |
| 1967 |
} |
| 1968 |
} |
| 1969 |
|
| 1970 |
|
| 1971 |
|
| 1972 |
|
| 1973 |
|
| 1974 |
|
| 1975 |
|
| 1976 |
|
| 1977 |
|
| 1978 |
|
| 1979 |
|
| 1980 |
|
| 1981 |
|
| 1982 |
static TreeViewStyle * |
| 1983 |
CreateComboBox(tvPtr, hPtr) |
| 1984 |
TreeView *tvPtr; |
| 1985 |
Blt_HashEntry *hPtr; |
| 1986 |
{ |
| 1987 |
TreeViewComboBox *cbPtr; |
| 1988 |
|
| 1989 |
cbPtr = (TreeViewComboBox *)newStyle(tvPtr, hPtr, sizeof(TreeViewComboBox)); |
| 1990 |
cbPtr->classPtr = &comboBoxClass; |
| 1991 |
cbPtr->buttonRelief = TK_RELIEF_RAISED; |
| 1992 |
cbPtr->buttonBorderWidth = 1; |
| 1993 |
cbPtr->borderWidth = 1; |
| 1994 |
cbPtr->flags = STYLE_COMBOBOX; |
| 1995 |
return (TreeViewStyle *)cbPtr; |
| 1996 |
} |
| 1997 |
|
| 1998 |
|
| 1999 |
|
| 2000 |
|
| 2001 |
|
| 2002 |
|
| 2003 |
|
| 2004 |
|
| 2005 |
|
| 2006 |
|
| 2007 |
|
| 2008 |
|
| 2009 |
|
| 2010 |
|
| 2011 |
|
| 2012 |
|
| 2013 |
|
| 2014 |
static void |
| 2015 |
ConfigureComboBox(tvPtr, stylePtr) |
| 2016 |
TreeView *tvPtr; |
| 2017 |
TreeViewStyle *stylePtr; |
| 2018 |
{ |
| 2019 |
ConfigureTextBox(tvPtr, stylePtr); |
| 2020 |
} |
| 2021 |
|
| 2022 |
|
| 2023 |
|
| 2024 |
|
| 2025 |
|
| 2026 |
|
| 2027 |
|
| 2028 |
|
| 2029 |
|
| 2030 |
|
| 2031 |
|
| 2032 |
|
| 2033 |
|
| 2034 |
|
| 2035 |
|
| 2036 |
|
| 2037 |
|
| 2038 |
|
| 2039 |
|
| 2040 |
|
| 2041 |
static void |
| 2042 |
MeasureComboBox(tvPtr, stylePtr, valuePtr) |
| 2043 |
TreeView *tvPtr; |
| 2044 |
TreeViewStyle *stylePtr; |
| 2045 |
TreeViewValue *valuePtr; |
| 2046 |
{ |
| 2047 |
TreeViewComboBox *cbPtr = (TreeViewComboBox *)stylePtr; |
| 2048 |
TreeViewColumn *columnPtr = valuePtr->columnPtr; |
| 2049 |
int iconWidth, iconHeight, biconWidth, biconHeight; |
| 2050 |
int textWidth, textHeight; |
| 2051 |
int gap; |
| 2052 |
Tk_Font font; |
| 2053 |
TreeViewIcon icon, *butIcons; |
| 2054 |
|
| 2055 |
textWidth = textHeight = 0; |
| 2056 |
iconWidth = iconHeight = 0; |
| 2057 |
valuePtr->width = valuePtr->height = 0; |
| 2058 |
|
| 2059 |
butIcons = cbPtr->buttonIcons; |
| 2060 |
icon = (stylePtr->icon?stylePtr->icon:(columnPtr->stylePtr?columnPtr->stylePtr->icon:NULL)); |
| 2061 |
if (icon != NULL && tvPtr->hideStyleIcons == 0) { |
| 2062 |
iconWidth = TreeViewIconWidth(icon); |
| 2063 |
iconHeight = TreeViewIconHeight(icon); |
| 2064 |
} |
| 2065 |
if (valuePtr->textPtr != NULL) { |
| 2066 |
Blt_Free(valuePtr->textPtr); |
| 2067 |
valuePtr->textPtr = NULL; |
| 2068 |
} |
| 2069 |
font = CHOOSE3(tvPtr->font, columnPtr->font, stylePtr->font); |
| 2070 |
if (valuePtr->string != NULL) { |
| 2071 |
TextStyle ts; |
| 2072 |
|
| 2073 |
Blt_InitTextStyle(&ts); |
| 2074 |
ts.font = font; |
| 2075 |
ts.anchor = TK_ANCHOR_NW; |
| 2076 |
ts.justify = valuePtr->columnPtr->justify; |
| 2077 |
valuePtr->textPtr = Blt_GetTextLayoutStr(valuePtr->string, &ts); |
| 2078 |
} |
| 2079 |
gap = 0; |
| 2080 |
if (valuePtr->textPtr != NULL && tvPtr->hideStyleText == 0) { |
| 2081 |
textWidth = valuePtr->textPtr->width; |
| 2082 |
textHeight = valuePtr->textPtr->height; |
| 2083 |
if (stylePtr->icon != NULL) { |
| 2084 |
gap = stylePtr->gap; |
| 2085 |
} |
| 2086 |
} |
| 2087 |
if (butIcons != NULL) { |
| 2088 |
TreeViewIcon mIcon; |
| 2089 |
int i; |
| 2090 |
|
| 2091 |
biconWidth = 0; |
| 2092 |
biconHeight = 0; |
| 2093 |
for (i=0; i<2; i++) { |
| 2094 |
mIcon = butIcons[i]; |
| 2095 |
if (!mIcon) continue; |
| 2096 |
biconWidth = MAX(biconWidth,TreeViewIconWidth(mIcon)); |
| 2097 |
biconHeight = MAX(biconHeight,TreeViewIconHeight(mIcon)); |
| 2098 |
} |
| 2099 |
biconHeight = MAX(iconHeight,biconHeight); |
| 2100 |
} else { |
| 2101 |
biconWidth = STD_ARROW_WIDTH + 6; |
| 2102 |
biconHeight = iconHeight; |
| 2103 |
} |
| 2104 |
cbPtr->buttonWidth = biconWidth + 2 * cbPtr->buttonBorderWidth; |
| 2105 |
valuePtr->width = 2 * cbPtr->borderWidth + iconWidth + 4 * gap + |
| 2106 |
cbPtr->buttonWidth + textWidth; |
| 2107 |
valuePtr->height = MAX(textHeight, biconHeight) + 2 * cbPtr->borderWidth; |
| 2108 |
} |
| 2109 |
|
| 2110 |
|
| 2111 |
|
| 2112 |
|
| 2113 |
|
| 2114 |
|
| 2115 |
|
| 2116 |
|
| 2117 |
|
| 2118 |
|
| 2119 |
|
| 2120 |
|
| 2121 |
|
| 2122 |
|
| 2123 |
|
| 2124 |
|
| 2125 |
|
| 2126 |
static void |
| 2127 |
DrawComboBox(tvPtr, drawable, entryPtr, valuePtr, stylePtr, icon, x, y) |
| 2128 |
TreeView *tvPtr; |
| 2129 |
Drawable drawable; |
| 2130 |
TreeViewEntry *entryPtr; |
| 2131 |
TreeViewValue *valuePtr; |
| 2132 |
TreeViewStyle *stylePtr; |
| 2133 |
TreeViewIcon icon; |
| 2134 |
int x, y; |
| 2135 |
{ |
| 2136 |
GC gc; |
| 2137 |
TreeViewColumn *columnPtr; |
| 2138 |
TreeViewComboBox *cbPtr = (TreeViewComboBox *)stylePtr; |
| 2139 |
int iconX, iconY, iconWidth, iconHeight; |
| 2140 |
int textX, textY, textHeight; |
| 2141 |
int buttonX, buttonY; |
| 2142 |
int gap, columnWidth; |
| 2143 |
TreeViewStyle sRec; |
| 2144 |
int valWidth = (valuePtr->textPtr?valuePtr->width:(icon?TreeViewIconWidth(icon):0)); |
| 2145 |
TextLayout *layPtr; |
| 2146 |
|
| 2147 |
layPtr = (tvPtr->hideStyleText?NULL:valuePtr->textPtr); |
| 2148 |
|
| 2149 |
columnPtr = valuePtr->columnPtr; |
| 2150 |
drawTextBox(tvPtr, drawable, entryPtr, valuePtr, stylePtr, icon, x, y, &sRec); |
| 2151 |
gc = sRec.gc; |
| 2152 |
|
| 2153 |
if (!valuePtr->string) { |
| 2154 |
return; |
| 2155 |
} |
| 2156 |
buttonX = x + columnPtr->width; |
| 2157 |
buttonX -= columnPtr->pad.side2 + cbPtr->borderWidth + |
| 2158 |
cbPtr->buttonWidth + stylePtr->gap; |
| 2159 |
buttonY = y; |
| 2160 |
|
| 2161 |
columnWidth = columnPtr->width - |
| 2162 |
(2 * columnPtr->borderWidth + PADDING(columnPtr->pad)); |
| 2163 |
if (columnWidth > valWidth) { |
| 2164 |
switch(columnPtr->justify) { |
| 2165 |
case TK_JUSTIFY_RIGHT: |
| 2166 |
x += (columnWidth - valWidth); |
| 2167 |
break; |
| 2168 |
case TK_JUSTIFY_CENTER: |
| 2169 |
x += (columnWidth - valWidth) / 2; |
| 2170 |
break; |
| 2171 |
case TK_JUSTIFY_LEFT: |
| 2172 |
break; |
| 2173 |
} |
| 2174 |
} |
| 2175 |
|
| 2176 |
#ifdef notdef |
| 2177 |
textX = textY = iconX = iconY = 0; |
| 2178 |
#endif |
| 2179 |
|
| 2180 |
iconWidth = iconHeight = 0; |
| 2181 |
if (icon != NULL) { |
| 2182 |
iconWidth = TreeViewIconWidth(icon); |
| 2183 |
iconHeight = TreeViewIconHeight(icon); |
| 2184 |
} |
| 2185 |
textHeight = 0; |
| 2186 |
if (layPtr != NULL) { |
| 2187 |
textHeight = layPtr->height; |
| 2188 |
} |
| 2189 |
gap = 0; |
| 2190 |
if ((icon != NULL) && (layPtr != NULL)) { |
| 2191 |
gap = stylePtr->gap; |
| 2192 |
} |
| 2193 |
|
| 2194 |
iconX = x + gap; |
| 2195 |
iconY = y + (entryPtr->height - iconHeight) / 2; |
| 2196 |
textX = iconX + iconWidth + gap; |
| 2197 |
textY = y + (entryPtr->height - textHeight) / 2; |
| 2198 |
|
| 2199 |
valuePtr->iX = iconX; |
| 2200 |
valuePtr->iY = iconY; |
| 2201 |
valuePtr->iW = iconWidth; |
| 2202 |
valuePtr->iH = iconHeight; |
| 2203 |
valuePtr->tX = textX; |
| 2204 |
valuePtr->tY = textY; |
| 2205 |
valuePtr->tW = valuePtr->textPtr->width; |
| 2206 |
valuePtr->tH = textHeight; |
| 2207 |
if (icon != NULL) { |
| 2208 |
if (Blt_TreeViewRedrawIcon(tvPtr, entryPtr, columnPtr, icon, 0, 0, iconWidth, |
| 2209 |
iconHeight, drawable, iconX, iconY) != TCL_OK) return; |
| 2210 |
} else { |
| 2211 |
valuePtr->iW = 0; |
| 2212 |
} |
| 2213 |
if (layPtr != NULL) { |
| 2214 |
TextStyle ts; |
| 2215 |
XColor *color; |
| 2216 |
|
| 2217 |
int disabled = (entryPtr->state == STATE_DISABLED); |
| 2218 |
|
| 2219 |
if (disabled) { |
| 2220 |
color = tvPtr->disabledColor; |
| 2221 |
} else if (Blt_TreeViewEntryIsSelected(tvPtr, entryPtr, columnPtr)) { |
| 2222 |
color = SELECT_FG(tvPtr); |
| 2223 |
} else if (entryPtr->color != NULL) { |
| 2224 |
color = entryPtr->color; |
| 2225 |
} else { |
| 2226 |
color = sRec.fgColor; |
| 2227 |
GetColorPats(tvPtr, entryPtr, valuePtr, stylePtr, &color ); |
| 2228 |
} |
| 2229 |
XSetForeground(tvPtr->display, gc, color->pixel); |
| 2230 |
Blt_SetDrawTextStyle(&ts, sRec.font, gc, color, sRec.fgColor, |
| 2231 |
stylePtr->shadow.color, 0.0, |
| 2232 |
TK_ANCHOR_NW, columnPtr->justify, 0, stylePtr->shadow.offset); |
| 2233 |
Blt_DrawTextLayout(tvPtr->tkwin, drawable, valuePtr->textPtr, |
| 2234 |
&ts, textX, textY); |
| 2235 |
if (color != sRec.fgColor) { |
| 2236 |
XSetForeground(tvPtr->display, gc, sRec.fgColor->pixel); |
| 2237 |
} |
| 2238 |
} else { |
| 2239 |
valuePtr->tW = 0; |
| 2240 |
} |
| 2241 |
if (cbPtr->buttonIcons == NULL) { |
| 2242 |
if (valuePtr == tvPtr->activeValuePtr) { |
| 2243 |
Blt_Fill3DRectangle(tvPtr->tkwin, drawable, stylePtr->activeBorder, |
| 2244 |
buttonX, buttonY + cbPtr->borderWidth, cbPtr->buttonWidth, |
| 2245 |
entryPtr->height - 2 * cbPtr->borderWidth, |
| 2246 |
cbPtr->buttonBorderWidth, cbPtr->buttonRelief); |
| 2247 |
} else { |
| 2248 |
Blt_Fill3DRectangle(tvPtr->tkwin, drawable, columnPtr->titleBorder, |
| 2249 |
buttonX, buttonY + cbPtr->borderWidth, cbPtr->buttonWidth, |
| 2250 |
entryPtr->height - 2 * cbPtr->borderWidth, |
| 2251 |
cbPtr->buttonBorderWidth, cbPtr->buttonRelief); |
| 2252 |
} |
| 2253 |
buttonX += cbPtr->buttonWidth / 2; |
| 2254 |
buttonY += entryPtr->height / 2; |
| 2255 |
Blt_DrawArrow(tvPtr->display, drawable, gc, buttonX, buttonY, |
| 2256 |
STD_ARROW_HEIGHT, ARROW_DOWN); |
| 2257 |
stylePtr->flags &= ~STYLE_DIRTY; |
| 2258 |
} else { |
| 2259 |
TreeViewIcon butIcon; |
| 2260 |
int biconWidth; |
| 2261 |
int biconHeight; |
| 2262 |
if (valuePtr == tvPtr->activeValuePtr && cbPtr->buttonIcons[1]) { |
| 2263 |
butIcon = cbPtr->buttonIcons[1]; |
| 2264 |
} else { |
| 2265 |
butIcon = cbPtr->buttonIcons[0]; |
| 2266 |
} |
| 2267 |
biconWidth = TreeViewIconWidth(butIcon); |
| 2268 |
biconHeight = MAX(iconHeight,TreeViewIconHeight(butIcon)); |
| 2269 |
|
| 2270 |
buttonY += (entryPtr->height-biconHeight)/2; |
| 2271 |
Blt_TreeViewRedrawIcon(tvPtr, entryPtr, columnPtr, butIcon, 0, 0, biconWidth, |
| 2272 |
biconHeight, drawable, buttonX, buttonY); |
| 2273 |
} |
| 2274 |
} |
| 2275 |
|
| 2276 |
|
| 2277 |
|
| 2278 |
|
| 2279 |
|
| 2280 |
|
| 2281 |
|
| 2282 |
|
| 2283 |
|
| 2284 |
|
| 2285 |
|
| 2286 |
|
| 2287 |
|
| 2288 |
|
| 2289 |
|
| 2290 |
|
| 2291 |
|
| 2292 |
static int |
| 2293 |
PickComboBox(entryPtr, valuePtr, stylePtr, worldX, worldY) |
| 2294 |
TreeViewEntry *entryPtr; |
| 2295 |
TreeViewValue *valuePtr; |
| 2296 |
TreeViewStyle *stylePtr; |
| 2297 |
int worldX, worldY; |
| 2298 |
{ |
| 2299 |
TreeViewColumn *columnPtr; |
| 2300 |
TreeViewComboBox *cbPtr = (TreeViewComboBox *)stylePtr; |
| 2301 |
int x, y, width, height; |
| 2302 |
|
| 2303 |
columnPtr = valuePtr->columnPtr; |
| 2304 |
width = cbPtr->buttonWidth; |
| 2305 |
height = entryPtr->height - 4; |
| 2306 |
x = columnPtr->worldX + columnPtr->width - columnPtr->pad.side2 - |
| 2307 |
cbPtr->borderWidth - columnPtr->borderWidth - width; |
| 2308 |
y = entryPtr->worldY + cbPtr->borderWidth; |
| 2309 |
if ((worldX >= x) && (worldX < (x + width)) && |
| 2310 |
(worldY >= y) && (worldY < (y + height))) { |
| 2311 |
return TRUE; |
| 2312 |
} |
| 2313 |
return FALSE; |
| 2314 |
} |
| 2315 |
|
| 2316 |
|
| 2317 |
|
| 2318 |
|
| 2319 |
|
| 2320 |
|
| 2321 |
|
| 2322 |
|
| 2323 |
|
| 2324 |
|
| 2325 |
|
| 2326 |
|
| 2327 |
|
| 2328 |
|
| 2329 |
|
| 2330 |
|
| 2331 |
|
| 2332 |
static int |
| 2333 |
EditComboBox(tvPtr, entryPtr, valuePtr, stylePtr, x, y, retVal) |
| 2334 |
TreeView *tvPtr; |
| 2335 |
TreeViewEntry *entryPtr; |
| 2336 |
TreeViewValue *valuePtr; |
| 2337 |
TreeViewStyle *stylePtr; |
| 2338 |
int x; |
| 2339 |
int y; |
| 2340 |
int *retVal; |
| 2341 |
{ |
| 2342 |
int isTest = *retVal; |
| 2343 |
*retVal = 1; |
| 2344 |
if (isTest) { |
| 2345 |
return TCL_OK; |
| 2346 |
} |
| 2347 |
return Blt_TreeViewTextbox(tvPtr, entryPtr, valuePtr->columnPtr); |
| 2348 |
} |
| 2349 |
|
| 2350 |
|
| 2351 |
|
| 2352 |
|
| 2353 |
|
| 2354 |
|
| 2355 |
|
| 2356 |
|
| 2357 |
|
| 2358 |
|
| 2359 |
|
| 2360 |
|
| 2361 |
|
| 2362 |
|
| 2363 |
|
| 2364 |
|
| 2365 |
|
| 2366 |
|
| 2367 |
|
| 2368 |
static void |
| 2369 |
FreeComboBox(tvPtr, stylePtr) |
| 2370 |
TreeView *tvPtr; |
| 2371 |
TreeViewStyle *stylePtr; |
| 2372 |
{ |
| 2373 |
FreeTextBox(tvPtr, stylePtr); |
| 2374 |
} |
| 2375 |
|
| 2376 |
|
| 2377 |
|
| 2378 |
|
| 2379 |
|
| 2380 |
|
| 2381 |
|
| 2382 |
|
| 2383 |
|
| 2384 |
|
| 2385 |
|
| 2386 |
|
| 2387 |
|
| 2388 |
static TreeViewStyle * |
| 2389 |
CreateBarBox(tvPtr, hPtr) |
| 2390 |
TreeView *tvPtr; |
| 2391 |
Blt_HashEntry *hPtr; |
| 2392 |
{ |
| 2393 |
TreeViewBarBox *cbPtr; |
| 2394 |
|
| 2395 |
cbPtr = (TreeViewBarBox *)newStyle(tvPtr, hPtr, sizeof(TreeViewBarBox)); |
| 2396 |
cbPtr->classPtr = &barBoxClass; |
| 2397 |
cbPtr->gap = 4; |
| 2398 |
cbPtr->lineWidth = 1; |
| 2399 |
cbPtr->showValue = TRUE; |
| 2400 |
cbPtr->flags = STYLE_BARBOX; |
| 2401 |
return (TreeViewStyle *)cbPtr; |
| 2402 |
} |
| 2403 |
|
| 2404 |
|
| 2405 |
|
| 2406 |
|
| 2407 |
|
| 2408 |
|
| 2409 |
|
| 2410 |
|
| 2411 |
|
| 2412 |
|
| 2413 |
|
| 2414 |
|
| 2415 |
|
| 2416 |
|
| 2417 |
|
| 2418 |
|
| 2419 |
|
| 2420 |
static void |
| 2421 |
ConfigureBarBox(tvPtr, stylePtr) |
| 2422 |
TreeView *tvPtr; |
| 2423 |
TreeViewStyle *stylePtr; |
| 2424 |
{ |
| 2425 |
GC newGC; |
| 2426 |
TreeViewBarBox *cbPtr = (TreeViewBarBox *)stylePtr; |
| 2427 |
XColor *bgColor; |
| 2428 |
XGCValues gcValues; |
| 2429 |
unsigned long gcMask; |
| 2430 |
|
| 2431 |
bgColor = Tk_3DBorderColor(CHOOSE(tvPtr->border, stylePtr->border)); |
| 2432 |
|
| 2433 |
gcValues.background = bgColor->pixel; |
| 2434 |
gcValues.foreground = CHOOSE(tvPtr->fgColor, stylePtr->fgColor)->pixel; |
| 2435 |
ConfigureTextBox(tvPtr, stylePtr); |
| 2436 |
gcMask = GCForeground; |
| 2437 |
gcValues.foreground = cbPtr->fillColor->pixel; |
| 2438 |
newGC = Tk_GetGC(tvPtr->tkwin, gcMask, &gcValues); |
| 2439 |
if (cbPtr->fillGC != NULL) { |
| 2440 |
Tk_FreeGC(tvPtr->display, cbPtr->fillGC); |
| 2441 |
} |
| 2442 |
cbPtr->fillGC = newGC; |
| 2443 |
|
| 2444 |
gcMask = GCForeground | GCLineWidth; |
| 2445 |
gcValues.line_width = cbPtr->lineWidth; |
| 2446 |
gcValues.foreground = cbPtr->boxColor->pixel; |
| 2447 |
newGC = Tk_GetGC(tvPtr->tkwin, gcMask, &gcValues); |
| 2448 |
if (cbPtr->boxGC != NULL) { |
| 2449 |
Tk_FreeGC(tvPtr->display, cbPtr->boxGC); |
| 2450 |
} |
| 2451 |
cbPtr->boxGC = newGC; |
| 2452 |
if (cbPtr->barBg) { |
| 2453 |
bgColor = Tk_3DBorderColor(cbPtr->barBg); |
| 2454 |
gcValues.background = bgColor->pixel; |
| 2455 |
gcValues.foreground = bgColor->pixel; |
| 2456 |
newGC = Tk_GetGC(tvPtr->tkwin, gcMask, &gcValues); |
| 2457 |
if (cbPtr->bgGC != NULL) { |
| 2458 |
Tk_FreeGC(tvPtr->display, cbPtr->bgGC); |
| 2459 |
} |
| 2460 |
cbPtr->bgGC = newGC; |
| 2461 |
} |
| 2462 |
stylePtr->flags |= STYLE_DIRTY; |
| 2463 |
} |
| 2464 |
|
| 2465 |
|
| 2466 |
|
| 2467 |
|
| 2468 |
|
| 2469 |
|
| 2470 |
|
| 2471 |
|
| 2472 |
|
| 2473 |
|
| 2474 |
|
| 2475 |
|
| 2476 |
|
| 2477 |
|
| 2478 |
|
| 2479 |
|
| 2480 |
|
| 2481 |
|
| 2482 |
|
| 2483 |
|
| 2484 |
static void |
| 2485 |
MeasureBarBox(tvPtr, stylePtr, valuePtr) |
| 2486 |
TreeView *tvPtr; |
| 2487 |
TreeViewStyle *stylePtr; |
| 2488 |
TreeViewValue *valuePtr; |
| 2489 |
{ |
| 2490 |
TreeViewBarBox *cbPtr = (TreeViewBarBox *)stylePtr; |
| 2491 |
TreeViewColumn *columnPtr = valuePtr->columnPtr; |
| 2492 |
TreeViewEntry *entryPtr; |
| 2493 |
int iconWidth, iconHeight; |
| 2494 |
int textWidth, textHeight; |
| 2495 |
int gap, bGap; |
| 2496 |
int boxWidth, boxHeight; |
| 2497 |
TreeViewIcon icon; |
| 2498 |
int rel = 0; |
| 2499 |
|
| 2500 |
entryPtr = valuePtr->entryPtr; |
| 2501 |
bGap = stylePtr->gap; |
| 2502 |
if (cbPtr->barWidth <= 0) { |
| 2503 |
boxWidth = 0; |
| 2504 |
bGap = 0; |
| 2505 |
} else if (cbPtr->barWidth >= 4000) { |
| 2506 |
boxWidth = 4000; |
| 2507 |
} else { |
| 2508 |
boxWidth = ODD(cbPtr->barWidth); |
| 2509 |
} |
| 2510 |
if (cbPtr->barHeight <= 0) { |
| 2511 |
boxHeight = 0; |
| 2512 |
} else if (cbPtr->barHeight >= 4000) { |
| 2513 |
boxHeight = 4000; |
| 2514 |
} else { |
| 2515 |
boxHeight = ODD(cbPtr->barHeight); |
| 2516 |
} |
| 2517 |
|
| 2518 |
textWidth = textHeight = iconWidth = iconHeight = 0; |
| 2519 |
valuePtr->width = valuePtr->height = 0; |
| 2520 |
icon = (stylePtr->icon?stylePtr->icon:(columnPtr->stylePtr?columnPtr->stylePtr->icon:NULL)); |
| 2521 |
if (icon != NULL && tvPtr->hideStyleIcons == 0) { |
| 2522 |
iconWidth = TreeViewIconWidth(icon); |
| 2523 |
iconHeight = TreeViewIconHeight(icon); |
| 2524 |
} |
| 2525 |
|
| 2526 |
gap = 0; |
| 2527 |
if (cbPtr->showValue) { |
| 2528 |
|
| 2529 |
if (valuePtr->textPtr != NULL) { |
| 2530 |
Blt_Free(valuePtr->textPtr); |
| 2531 |
valuePtr->textPtr = NULL; |
| 2532 |
} |
| 2533 |
if (valuePtr->string != NULL) { |
| 2534 |
|
| 2535 |
TextStyle ts; |
| 2536 |
Tcl_Obj *fmtObj; |
| 2537 |
|
| 2538 |
fmtObj = NotNullObj(cbPtr->formatCmd); |
| 2539 |
if (fmtObj == NULL) { |
| 2540 |
fmtObj = NotNullObj(columnPtr->formatCmd); |
| 2541 |
} |
| 2542 |
if (fmtObj == NULL) { |
| 2543 |
fmtObj = NotNullObj(tvPtr->formatCmd); |
| 2544 |
} |
| 2545 |
|
| 2546 |
Blt_InitTextStyle(&ts); |
| 2547 |
ts.font = CHOOSE3(tvPtr->font, columnPtr->font, stylePtr->font); |
| 2548 |
ts.anchor = TK_ANCHOR_NW; |
| 2549 |
ts.justify = valuePtr->columnPtr->justify; |
| 2550 |
if (fmtObj) { |
| 2551 |
Tcl_DString cmdString; |
| 2552 |
char *string; |
| 2553 |
int result; |
| 2554 |
Tcl_Interp *interp = tvPtr->interp; |
| 2555 |
|
| 2556 |
Tcl_Preserve(entryPtr); |
| 2557 |
rel = 1; |
| 2558 |
Blt_TreeViewPercentSubst(tvPtr, valuePtr->entryPtr, valuePtr->columnPtr, Tcl_GetString(fmtObj), valuePtr->string, &cmdString); |
| 2559 |
result = Tcl_GlobalEval(interp, Tcl_DStringValue(&cmdString)); |
| 2560 |
if ((entryPtr->flags & ENTRY_DELETED) || (tvPtr->flags & TV_DELETED)) { |
| 2561 |
Tcl_Release(entryPtr); |
| 2562 |
return; |
| 2563 |
} |
| 2564 |
|
| 2565 |
Blt_TreeViewOptsInit(tvPtr); |
| 2566 |
Tcl_DStringFree(&cmdString); |
| 2567 |
if (result == TCL_OK) { |
| 2568 |
string = Tcl_GetStringResult(interp); |
| 2569 |
valuePtr->textPtr = Blt_GetTextLayoutStr(string, &ts); |
| 2570 |
} |
| 2571 |
} |
| 2572 |
if (valuePtr->textPtr == NULL) { |
| 2573 |
valuePtr->textPtr = Blt_GetTextLayoutStr(valuePtr->string, &ts); |
| 2574 |
} |
| 2575 |
} |
| 2576 |
if (valuePtr->textPtr != NULL && tvPtr->hideStyleText == 0) { |
| 2577 |
textWidth = valuePtr->textPtr->width; |
| 2578 |
textHeight = valuePtr->textPtr->height; |
| 2579 |
if (stylePtr->icon != NULL) { |
| 2580 |
gap = stylePtr->gap; |
| 2581 |
} |
| 2582 |
} |
| 2583 |
|
| 2584 |
if (stylePtr->icon != NULL) { |
| 2585 |
gap = stylePtr->gap; |
| 2586 |
} |
| 2587 |
} |
| 2588 |
valuePtr->width = stylePtr->gap + bGap + boxWidth + iconWidth + gap + textWidth + 2; |
| 2589 |
valuePtr->height = MAX3(boxHeight, textHeight, iconHeight); |
| 2590 |
if (rel) Tcl_Release(entryPtr); |
| 2591 |
} |
| 2592 |
|
| 2593 |
|
| 2594 |
|
| 2595 |
|
| 2596 |
|
| 2597 |
|
| 2598 |
|
| 2599 |
|
| 2600 |
|
| 2601 |
|
| 2602 |
|
| 2603 |
|
| 2604 |
|
| 2605 |
|
| 2606 |
|
| 2607 |
|
| 2608 |
|
| 2609 |
static void |
| 2610 |
DrawBarBox(tvPtr, drawable, entryPtr, valuePtr, stylePtr, icon, x, y) |
| 2611 |
TreeView *tvPtr; |
| 2612 |
Drawable drawable; |
| 2613 |
TreeViewEntry *entryPtr; |
| 2614 |
TreeViewValue *valuePtr; |
| 2615 |
TreeViewStyle *stylePtr; |
| 2616 |
TreeViewIcon icon; |
| 2617 |
int x, y; |
| 2618 |
{ |
| 2619 |
GC gc; |
| 2620 |
TreeViewColumn *columnPtr; |
| 2621 |
TreeViewBarBox *cbPtr = (TreeViewBarBox *)stylePtr; |
| 2622 |
int iconX, iconY, iconWidth, iconHeight; |
| 2623 |
int textX, textY, textHeight, ttlWidth, bGap, iGap; |
| 2624 |
int gap, columnWidth; |
| 2625 |
TextLayout *textPtr; |
| 2626 |
int boxX, boxY, boxWidth, boxHeight, bw; |
| 2627 |
TreeViewStyle *csPtr, sRec = *stylePtr; |
| 2628 |
int valWidth = (valuePtr->textPtr?valuePtr->width:(icon?TreeViewIconWidth(icon):0)); |
| 2629 |
double curValue; |
| 2630 |
TextStyle ts; |
| 2631 |
XColor *color; |
| 2632 |
int showValue = (tvPtr->hideStyleText ? 0 : cbPtr->showValue); |
| 2633 |
|
| 2634 |
textPtr = NULL; |
| 2635 |
columnPtr = valuePtr->columnPtr; |
| 2636 |
csPtr = columnPtr->stylePtr; |
| 2637 |
|
| 2638 |
drawTextBox(tvPtr, drawable, entryPtr, valuePtr, stylePtr, icon, x, y, &sRec); |
| 2639 |
gc = sRec.gc; |
| 2640 |
|
| 2641 |
columnWidth = columnPtr->width - PADDING(columnPtr->pad); |
| 2642 |
if (!valuePtr->string) { |
| 2643 |
return; |
| 2644 |
} |
| 2645 |
if (Tcl_GetDouble(NULL, valuePtr->string, &curValue) != TCL_OK) { |
| 2646 |
if (sscanf(valuePtr->string, "%lg", &curValue) != 1) { |
| 2647 |
return; |
| 2648 |
} |
| 2649 |
} |
| 2650 |
if (cbPtr->maxValue<=cbPtr->minValue) { |
| 2651 |
return; |
| 2652 |
} |
| 2653 |
|
| 2654 |
#ifdef notdef |
| 2655 |
textX = textY = iconX = iconY = 0; |
| 2656 |
#endif |
| 2657 |
iconWidth = iconHeight = 0; |
| 2658 |
bGap = stylePtr->gap; |
| 2659 |
iGap = 0; |
| 2660 |
if (cbPtr->barWidth<=0) { |
| 2661 |
boxWidth = 0; |
| 2662 |
bGap = 0; |
| 2663 |
} else if (cbPtr->barWidth >= 4000) { |
| 2664 |
boxWidth = 4000; |
| 2665 |
} else { |
| 2666 |
boxWidth = ODD(cbPtr->barWidth); |
| 2667 |
} |
| 2668 |
if (cbPtr->barHeight<=0) { |
| 2669 |
boxHeight = 0; |
| 2670 |
} else if (cbPtr->barHeight >= 4000) { |
| 2671 |
boxHeight = 4000; |
| 2672 |
} else { |
| 2673 |
boxHeight = ODD(cbPtr->barHeight); |
| 2674 |
} |
| 2675 |
ttlWidth = ( boxWidth + stylePtr->gap * 2); |
| 2676 |
if (showValue) { |
| 2677 |
ttlWidth += (valWidth + stylePtr->gap); |
| 2678 |
Blt_InitTextStyle(&ts); |
| 2679 |
ts.font = CHOOSE(tvPtr->font, stylePtr->font); |
| 2680 |
ts.anchor = TK_ANCHOR_NW; |
| 2681 |
ts.justify = columnPtr->justify; |
| 2682 |
} |
| 2683 |
if (icon != NULL) { |
| 2684 |
iGap = stylePtr->gap; |
| 2685 |
iconWidth = TreeViewIconWidth(icon); |
| 2686 |
iconHeight = TreeViewIconHeight(icon); |
| 2687 |
ttlWidth += iconWidth + stylePtr->gap; |
| 2688 |
} |
| 2689 |
|
| 2690 |
if (columnWidth > ttlWidth) { |
| 2691 |
switch(columnPtr->justify) { |
| 2692 |
case TK_JUSTIFY_RIGHT: |
| 2693 |
x += (columnWidth - ttlWidth - stylePtr->gap*2); |
| 2694 |
break; |
| 2695 |
case TK_JUSTIFY_CENTER: |
| 2696 |
x += (columnWidth - ttlWidth) / 2; |
| 2697 |
break; |
| 2698 |
case TK_JUSTIFY_LEFT: |
| 2699 |
break; |
| 2700 |
} |
| 2701 |
} |
| 2702 |
|
| 2703 |
|
| 2704 |
|
| 2705 |
|
| 2706 |
boxX = x + iGap; |
| 2707 |
boxY = y + (entryPtr->height - boxHeight) / 2; |
| 2708 |
if (curValue<cbPtr->minValue) { |
| 2709 |
bw = 0; |
| 2710 |
} else if (curValue > cbPtr->maxValue) { |
| 2711 |
bw = boxWidth; |
| 2712 |
} else if (cbPtr->minValue >= cbPtr->maxValue) { |
| 2713 |
bw = 0; |
| 2714 |
} else { |
| 2715 |
int diff = (cbPtr->maxValue-cbPtr->minValue); |
| 2716 |
bw = (int)(boxWidth*(1.0*(curValue-cbPtr->minValue)/diff)); |
| 2717 |
} |
| 2718 |
if (boxHeight && boxWidth) { |
| 2719 |
if (cbPtr->barBg) { |
| 2720 |
XFillRectangle(tvPtr->display, drawable, cbPtr->bgGC, boxX, boxY, boxWidth, boxHeight); |
| 2721 |
} |
| 2722 |
if (bw>0) { |
| 2723 |
if (Blt_HasTile(stylePtr->fillTile)) { |
| 2724 |
Blt_SetTileOrigin(tvPtr->tkwin, stylePtr->fillTile, -boxX, -boxY); |
| 2725 |
Blt_TileRectangle(tvPtr->tkwin, drawable, stylePtr->fillTile, |
| 2726 |
boxX, boxY, bw, boxHeight ); |
| 2727 |
} else if (csPtr != NULL && Blt_HasTile(csPtr->fillTile)) { |
| 2728 |
Blt_SetTileOrigin(tvPtr->tkwin, csPtr->fillTile, -boxX, -boxY); |
| 2729 |
Blt_TileRectangle(tvPtr->tkwin, drawable, csPtr->fillTile, |
| 2730 |
boxX, boxY, bw, boxHeight ); |
| 2731 |
} else { |
| 2732 |
|
| 2733 |
XFillRectangle(tvPtr->display, drawable, cbPtr->fillGC, boxX, boxY, bw, boxHeight); |
| 2734 |
} |
| 2735 |
} |
| 2736 |
XDrawRectangle(tvPtr->display, drawable, cbPtr->boxGC, boxX, boxY, |
| 2737 |
boxWidth, boxHeight); |
| 2738 |
} |
| 2739 |
|
| 2740 |
textHeight = 0; |
| 2741 |
gap = 0; |
| 2742 |
if (showValue) { |
| 2743 |
|
| 2744 |
int disabled = (entryPtr->state == STATE_DISABLED); |
| 2745 |
|
| 2746 |
if (disabled) { |
| 2747 |
color = tvPtr->disabledColor; |
| 2748 |
} else if (Blt_TreeViewEntryIsSelected(tvPtr, entryPtr, columnPtr)) { |
| 2749 |
color = SELECT_FG(tvPtr); |
| 2750 |
} else if (entryPtr->color != NULL) { |
| 2751 |
color = entryPtr->color; |
| 2752 |
} else { |
| 2753 |
color = sRec.fgColor; |
| 2754 |
GetColorPats(tvPtr, entryPtr, valuePtr, stylePtr, &color ); |
| 2755 |
} |
| 2756 |
Blt_SetDrawTextStyle(&ts, sRec.font, gc, color, sRec.fgColor, stylePtr->shadow.color, 0.0, TK_ANCHOR_NW, columnPtr->justify, 0, stylePtr->shadow.offset); |
| 2757 |
textPtr = valuePtr->textPtr; |
| 2758 |
textHeight = textPtr->height; |
| 2759 |
if (icon != NULL) { |
| 2760 |
gap = stylePtr->gap; |
| 2761 |
} |
| 2762 |
} |
| 2763 |
x = boxX + boxWidth + bGap; |
| 2764 |
|
| 2765 |
|
| 2766 |
iconX = x; |
| 2767 |
iconY = y + (entryPtr->height - iconHeight) / 2; |
| 2768 |
textX = iconX + iconWidth + gap; |
| 2769 |
textY = y + (entryPtr->height - textHeight) / 2; |
| 2770 |
|
| 2771 |
valuePtr->iX = iconX; |
| 2772 |
valuePtr->iY = iconY; |
| 2773 |
valuePtr->iW = iconWidth; |
| 2774 |
valuePtr->iH = iconHeight; |
| 2775 |
valuePtr->tX = textX; |
| 2776 |
valuePtr->tY = textY; |
| 2777 |
valuePtr->tW = (textPtr?textPtr->width:0); |
| 2778 |
valuePtr->tH = textHeight; |
| 2779 |
|
| 2780 |
if (icon != NULL) { |
| 2781 |
if (Blt_TreeViewRedrawIcon(tvPtr, entryPtr, columnPtr, icon, 0, 0, iconWidth, |
| 2782 |
iconHeight, drawable, iconX, iconY) != TCL_OK) return; |
| 2783 |
} else { |
| 2784 |
valuePtr->iW = 0; |
| 2785 |
} |
| 2786 |
if ((showValue) && (textPtr != NULL)) { |
| 2787 |
XSetForeground(tvPtr->display, gc, color->pixel); |
| 2788 |
Blt_DrawTextLayout(tvPtr->tkwin, drawable, textPtr, &ts, textX, textY); |
| 2789 |
if (color != sRec.fgColor) { |
| 2790 |
XSetForeground(tvPtr->display, gc, sRec.fgColor->pixel); |
| 2791 |
} |
| 2792 |
} else { |
| 2793 |
valuePtr->tW = 0; |
| 2794 |
} |
| 2795 |
stylePtr->flags &= ~STYLE_DIRTY; |
| 2796 |
} |
| 2797 |
|
| 2798 |
#if 0 |
| 2799 |
|
| 2800 |
|
| 2801 |
|
| 2802 |
|
| 2803 |
|
| 2804 |
|
| 2805 |
|
| 2806 |
|
| 2807 |
|
| 2808 |
|
| 2809 |
|
| 2810 |
|
| 2811 |
|
| 2812 |
|
| 2813 |
|
| 2814 |
|
| 2815 |
static int |
| 2816 |
PickBarBox(entryPtr, valuePtr, stylePtr, worldX, worldY) |
| 2817 |
TreeViewEntry *entryPtr; |
| 2818 |
TreeViewValue *valuePtr; |
| 2819 |
TreeViewStyle *stylePtr; |
| 2820 |
int worldX, worldY; |
| 2821 |
{ |
| 2822 |
TreeViewColumn *columnPtr; |
| 2823 |
TreeViewBarBox *cbPtr = (TreeViewBarBox *)stylePtr; |
| 2824 |
int columnWidth; |
| 2825 |
int x, y, width, height; |
| 2826 |
|
| 2827 |
columnPtr = valuePtr->columnPtr; |
| 2828 |
columnWidth = columnPtr->width - |
| 2829 |
(2 * columnPtr->borderWidth + PADDING(columnPtr->pad)); |
| 2830 |
if (columnWidth > valuePtr->width) { |
| 2831 |
switch(columnPtr->justify) { |
| 2832 |
case TK_JUSTIFY_RIGHT: |
| 2833 |
worldX += (columnWidth - valuePtr->width); |
| 2834 |
break; |
| 2835 |
case TK_JUSTIFY_CENTER: |
| 2836 |
worldX += (columnWidth - valuePtr->width) / 2; |
| 2837 |
break; |
| 2838 |
case TK_JUSTIFY_LEFT: |
| 2839 |
break; |
| 2840 |
} |
| 2841 |
} |
| 2842 |
width = ODD(cbPtr->barWidth) + 2 * cbPtr->lineWidth; |
| 2843 |
height = ODD(cbPtr->barHeight) + 2 * cbPtr->lineWidth; |
| 2844 |
x = columnPtr->worldX + columnPtr->pad.side1 + cbPtr->gap - |
| 2845 |
cbPtr->lineWidth; |
| 2846 |
y = entryPtr->worldY + (entryPtr->height - height) / 2; |
| 2847 |
if ((worldX >= x) && (worldX < (x + width)) && |
| 2848 |
(worldY >= y) && (worldY < (y + height))) { |
| 2849 |
return TRUE; |
| 2850 |
} |
| 2851 |
return FALSE; |
| 2852 |
} |
| 2853 |
#endif |
| 2854 |
|
| 2855 |
|
| 2856 |
|
| 2857 |
|
| 2858 |
|
| 2859 |
|
| 2860 |
|
| 2861 |
|
| 2862 |
|
| 2863 |
|
| 2864 |
|
| 2865 |
|
| 2866 |
|
| 2867 |
|
| 2868 |
|
| 2869 |
static int |
| 2870 |
EditBarBox(tvPtr, entryPtr, valuePtr, stylePtr, x, y, retVal) |
| 2871 |
TreeView *tvPtr; |
| 2872 |
TreeViewEntry *entryPtr; |
| 2873 |
TreeViewValue *valuePtr; |
| 2874 |
TreeViewStyle *stylePtr; |
| 2875 |
int x; |
| 2876 |
int y; |
| 2877 |
int *retVal; |
| 2878 |
{ |
| 2879 |
*retVal = 0; |
| 2880 |
return TCL_OK; |
| 2881 |
} |
| 2882 |
|
| 2883 |
|
| 2884 |
|
| 2885 |
|
| 2886 |
|
| 2887 |
|
| 2888 |
|
| 2889 |
|
| 2890 |
|
| 2891 |
|
| 2892 |
|
| 2893 |
|
| 2894 |
|
| 2895 |
|
| 2896 |
|
| 2897 |
|
| 2898 |
|
| 2899 |
|
| 2900 |
|
| 2901 |
static void |
| 2902 |
FreeBarBox(tvPtr, stylePtr) |
| 2903 |
TreeView *tvPtr; |
| 2904 |
TreeViewStyle *stylePtr; |
| 2905 |
{ |
| 2906 |
TreeViewBarBox *cbPtr = (TreeViewBarBox *)stylePtr; |
| 2907 |
|
| 2908 |
FreeTextBox(tvPtr, stylePtr); |
| 2909 |
if (cbPtr->fillGC != NULL) { |
| 2910 |
Tk_FreeGC(tvPtr->display, cbPtr->fillGC); |
| 2911 |
} |
| 2912 |
if (cbPtr->boxGC != NULL) { |
| 2913 |
Tk_FreeGC(tvPtr->display, cbPtr->boxGC); |
| 2914 |
} |
| 2915 |
if (cbPtr->bgGC != NULL) { |
| 2916 |
Tk_FreeGC(tvPtr->display, cbPtr->bgGC); |
| 2917 |
} |
| 2918 |
} |
| 2919 |
|
| 2920 |
|
| 2921 |
|
| 2922 |
|
| 2923 |
|
| 2924 |
|
| 2925 |
|
| 2926 |
|
| 2927 |
|
| 2928 |
|
| 2929 |
|
| 2930 |
|
| 2931 |
|
| 2932 |
static TreeViewStyle * |
| 2933 |
CreateWindowBox(tvPtr, hPtr) |
| 2934 |
TreeView *tvPtr; |
| 2935 |
Blt_HashEntry *hPtr; |
| 2936 |
{ |
| 2937 |
TreeViewWindowBox *tbPtr; |
| 2938 |
|
| 2939 |
tbPtr = (TreeViewWindowBox *)newStyle(tvPtr, hPtr, sizeof(TreeViewWindowBox)); |
| 2940 |
tbPtr->classPtr = &windowBoxClass; |
| 2941 |
tbPtr->flags = STYLE_WINDOWBOX; |
| 2942 |
return (TreeViewStyle *)tbPtr; |
| 2943 |
} |
| 2944 |
|
| 2945 |
|
| 2946 |
|
| 2947 |
|
| 2948 |
|
| 2949 |
|
| 2950 |
|
| 2951 |
|
| 2952 |
|
| 2953 |
|
| 2954 |
|
| 2955 |
|
| 2956 |
|
| 2957 |
|
| 2958 |
|
| 2959 |
|
| 2960 |
|
| 2961 |
static void |
| 2962 |
ConfigureWindowBox(tvPtr, stylePtr) |
| 2963 |
TreeView *tvPtr; |
| 2964 |
TreeViewStyle *stylePtr; |
| 2965 |
{ |
| 2966 |
TreeViewWindowBox *tbPtr = (TreeViewWindowBox *)stylePtr; |
| 2967 |
tbPtr->flags |= STYLE_DIRTY; |
| 2968 |
} |
| 2969 |
|
| 2970 |
|
| 2971 |
|
| 2972 |
|
| 2973 |
|
| 2974 |
|
| 2975 |
|
| 2976 |
|
| 2977 |
|
| 2978 |
|
| 2979 |
|
| 2980 |
|
| 2981 |
|
| 2982 |
|
| 2983 |
|
| 2984 |
|
| 2985 |
|
| 2986 |
|
| 2987 |
|
| 2988 |
|
| 2989 |
static void |
| 2990 |
MeasureWindowBox(tvPtr, stylePtr, valuePtr) |
| 2991 |
TreeView *tvPtr; |
| 2992 |
TreeViewStyle *stylePtr; |
| 2993 |
TreeViewValue *valuePtr; |
| 2994 |
{ |
| 2995 |
TreeViewWindowBox *tbPtr = (TreeViewWindowBox *)stylePtr; |
| 2996 |
valuePtr->width = tbPtr->windowWidth; |
| 2997 |
valuePtr->height = tbPtr->windowHeight; |
| 2998 |
} |
| 2999 |
|
| 3000 |
|
| 3001 |
typedef struct { |
| 3002 |
int flags; |
| 3003 |
char *name; |
| 3004 |
TreeView *tvPtr; |
| 3005 |
TreeViewEntry *entryPtr; |
| 3006 |
TreeViewColumn *columnPtr; |
| 3007 |
Blt_HashEntry *hPtr; |
| 3008 |
Tk_Window tkwin; |
| 3009 |
TreeViewWindowBox *stylePtr; |
| 3010 |
} WindowCell; |
| 3011 |
|
| 3012 |
static void EmbWinStructureProc( ClientData clientData, XEvent *eventPtr); |
| 3013 |
|
| 3014 |
static void |
| 3015 |
EmbWinRemove(WindowCell *wcPtr) { |
| 3016 |
Blt_HashEntry *hPtr; |
| 3017 |
TreeView *tvPtr = wcPtr->tvPtr; |
| 3018 |
hPtr = Blt_FindHashEntry(&tvPtr->winTable, wcPtr->name); |
| 3019 |
if (hPtr != NULL && wcPtr == (WindowCell*)Blt_GetHashValue(hPtr)) { |
| 3020 |
Blt_DeleteHashEntry(&tvPtr->winTable, hPtr); |
| 3021 |
} |
| 3022 |
Blt_Free(wcPtr->name); |
| 3023 |
wcPtr->name = NULL; |
| 3024 |
if (wcPtr->hPtr) Blt_DeleteHashEntry(&tvPtr->winCellTable, wcPtr->hPtr); |
| 3025 |
wcPtr->hPtr = NULL; |
| 3026 |
if (wcPtr->tkwin) { |
| 3027 |
Tk_DeleteEventHandler(wcPtr->tkwin, StructureNotifyMask, |
| 3028 |
EmbWinStructureProc, (ClientData) wcPtr); |
| 3029 |
Tk_ManageGeometry(wcPtr->tkwin, NULL, NULL); |
| 3030 |
wcPtr->tkwin = NULL; |
| 3031 |
} |
| 3032 |
Blt_Free(wcPtr); |
| 3033 |
} |
| 3034 |
|
| 3035 |
|
| 3036 |
void |
| 3037 |
Blt_TreeViewFreeWindows( TreeView *tvPtr) |
| 3038 |
{ |
| 3039 |
Blt_HashEntry *hPtr; |
| 3040 |
Blt_HashSearch cursor; |
| 3041 |
WindowCell *wcPtr; |
| 3042 |
|
| 3043 |
for (hPtr = Blt_FirstHashEntry(&tvPtr->winCellTable, &cursor); hPtr != NULL; |
| 3044 |
hPtr = Blt_NextHashEntry(&cursor)) { |
| 3045 |
wcPtr = Blt_GetHashValue(hPtr); |
| 3046 |
if (wcPtr) { |
| 3047 |
EmbWinRemove(wcPtr); |
| 3048 |
} |
| 3049 |
} |
| 3050 |
} |
| 3051 |
|
| 3052 |
static void |
| 3053 |
EmbWinUnmapNow(Tk_Window ewTkwin, Tk_Window tkwin) |
| 3054 |
{ |
| 3055 |
if (tkwin != Tk_Parent(ewTkwin)) { |
| 3056 |
Tk_UnmaintainGeometry(ewTkwin, tkwin); |
| 3057 |
} |
| 3058 |
Tk_UnmapWindow(ewTkwin); |
| 3059 |
} |
| 3060 |
|
| 3061 |
static void EmbWinRequestProc(ClientData clientData, |
| 3062 |
Tk_Window tkwin) |
| 3063 |
{ |
| 3064 |
} |
| 3065 |
|
| 3066 |
static void EmbWinLostSlaveProc(ClientData clientData, Tk_Window tkwin); |
| 3067 |
|
| 3068 |
static Tk_GeomMgr windowGeomType = { |
| 3069 |
"treeview", |
| 3070 |
EmbWinRequestProc, |
| 3071 |
EmbWinLostSlaveProc, |
| 3072 |
}; |
| 3073 |
|
| 3074 |
|
| 3075 |
void |
| 3076 |
Blt_TreeViewMarkWindows( TreeView *tvPtr, int flag) |
| 3077 |
{ |
| 3078 |
Blt_HashEntry *hPtr; |
| 3079 |
Blt_HashSearch cursor; |
| 3080 |
WindowCell *wcPtr; |
| 3081 |
|
| 3082 |
for (hPtr = Blt_FirstHashEntry(&tvPtr->winCellTable, &cursor); hPtr != NULL; |
| 3083 |
hPtr = Blt_NextHashEntry(&cursor)) { |
| 3084 |
wcPtr = Blt_GetHashValue(hPtr); |
| 3085 |
if (wcPtr) { |
| 3086 |
if (flag == TV_WINDOW_CLEAR) { |
| 3087 |
|
| 3088 |
wcPtr->flags &= ~TV_WINDOW_DRAW; |
| 3089 |
} else if (flag == TV_WINDOW_UNMAP && (wcPtr->flags&TV_WINDOW_DRAW)==0) { |
| 3090 |
|
| 3091 |
EmbWinUnmapNow(wcPtr->tkwin, tvPtr->tkwin); |
| 3092 |
} |
| 3093 |
} |
| 3094 |
} |
| 3095 |
} |
| 3096 |
|
| 3097 |
static WindowCell * |
| 3098 |
bltTreeViewFindWindow(TreeViewEntry *entryPtr, |
| 3099 |
TreeViewColumn *columnPtr) |
| 3100 |
{ |
| 3101 |
TreeView *tvPtr = columnPtr->tvPtr; |
| 3102 |
Blt_HashEntry *hPtr; |
| 3103 |
WindowCell *wcPtr; |
| 3104 |
Tcl_DString dStr; |
| 3105 |
char *key; |
| 3106 |
|
| 3107 |
Tcl_DStringInit(&dStr); |
| 3108 |
Tcl_DStringAppendElement(&dStr, columnPtr->key); |
| 3109 |
Tcl_DStringAppendElement(&dStr, Blt_Itoa(entryPtr->node->inode)); |
| 3110 |
key = Tcl_DStringValue(&dStr); |
| 3111 |
hPtr = Blt_FindHashEntry(&tvPtr->winCellTable, key); |
| 3112 |
Tcl_DStringFree(&dStr); |
| 3113 |
if (hPtr == NULL) return NULL; |
| 3114 |
wcPtr = (WindowCell*)Blt_GetHashValue(hPtr); |
| 3115 |
return wcPtr; |
| 3116 |
} |
| 3117 |
|
| 3118 |
static int isValidSubWin( TreeView *tvPtr, Tk_Window tkwin) { |
| 3119 |
Tk_Window ancestor, parent; |
| 3120 |
parent = Tk_Parent(tkwin); |
| 3121 |
for (ancestor = tvPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { |
| 3122 |
if (ancestor == parent) { |
| 3123 |
break; |
| 3124 |
} |
| 3125 |
if (Tk_IsTopLevel(ancestor)) { |
| 3126 |
return 0; |
| 3127 |
} |
| 3128 |
} |
| 3129 |
if (Tk_IsTopLevel(tkwin) || (tkwin == tvPtr->tkwin)) { |
| 3130 |
return 0; |
| 3131 |
} |
| 3132 |
return 1; |
| 3133 |
} |
| 3134 |
|
| 3135 |
static WindowCell * |
| 3136 |
bltTreeViewWindowMake( TreeView *tvPtr, TreeViewEntry *entryPtr, |
| 3137 |
TreeViewValue *valuePtr, TreeViewWindowBox *wbPtr) |
| 3138 |
{ |
| 3139 |
char *name, *key; |
| 3140 |
Blt_HashEntry *hPtr; |
| 3141 |
WindowCell *wcPtr = NULL, *w2Ptr; |
| 3142 |
TreeViewColumn *columnPtr = valuePtr->columnPtr; |
| 3143 |
Tcl_DString dStr; |
| 3144 |
Tk_Window tkwin; |
| 3145 |
int result, isNew; |
| 3146 |
Tcl_Interp *interp; |
| 3147 |
char *execCmd = wbPtr->windowCmd; |
| 3148 |
|
| 3149 |
interp = tvPtr->interp; |
| 3150 |
|
| 3151 |
Tcl_DStringInit(&dStr); |
| 3152 |
Tcl_DStringAppendElement(&dStr, columnPtr->key); |
| 3153 |
Tcl_DStringAppendElement(&dStr, Blt_Itoa(entryPtr->node->inode)); |
| 3154 |
key = Tcl_DStringValue(&dStr); |
| 3155 |
hPtr = Blt_CreateHashEntry(&tvPtr->winCellTable, key, &isNew); |
| 3156 |
Tcl_DStringFree(&dStr); |
| 3157 |
Tcl_DStringInit(&dStr); |
| 3158 |
|
| 3159 |
if (hPtr == NULL) return NULL; |
| 3160 |
if (!isNew) { |
| 3161 |
wcPtr = (WindowCell*)Blt_GetHashValue(hPtr); |
| 3162 |
if (wcPtr && wcPtr->tkwin == NULL) { |
| 3163 |
return NULL; |
| 3164 |
} |
| 3165 |
return wcPtr; |
| 3166 |
} |
| 3167 |
|
| 3168 |
wcPtr = (WindowCell*)Blt_Calloc(1, sizeof(WindowCell)); |
| 3169 |
Blt_SetHashValue(hPtr, wcPtr); |
| 3170 |
wcPtr->name = NULL; |
| 3171 |
wcPtr->tvPtr = tvPtr; |
| 3172 |
wcPtr->columnPtr = columnPtr; |
| 3173 |
wcPtr->entryPtr = entryPtr; |
| 3174 |
wcPtr->hPtr = hPtr; |
| 3175 |
wcPtr->stylePtr = wbPtr; |
| 3176 |
wcPtr->flags |= TV_WINDOW_DRAW; |
| 3177 |
|
| 3178 |
if (execCmd != NULL) { |
| 3179 |
Tcl_DString cmdString; |
| 3180 |
|
| 3181 |
Blt_TreeViewPercentSubst(tvPtr, entryPtr, columnPtr, execCmd, valuePtr->string, &cmdString); |
| 3182 |
result = Tcl_GlobalEval(interp, Tcl_DStringValue(&cmdString)); |
| 3183 |
Blt_TreeViewOptsInit(tvPtr); |
| 3184 |
Tcl_DStringFree(&cmdString); |
| 3185 |
if ((entryPtr->flags & ENTRY_DELETED) || (tvPtr->flags & TV_DELETED)) { |
| 3186 |
result = TCL_ERROR; |
| 3187 |
} |
| 3188 |
if (result != TCL_OK) { |
| 3189 |
goto error; |
| 3190 |
} |
| 3191 |
name = Tcl_GetStringResult(interp); |
| 3192 |
} else { |
| 3193 |
name = valuePtr->string; |
| 3194 |
if (name == NULL) { |
| 3195 |
goto error; |
| 3196 |
} |
| 3197 |
if (name[0] != '.') { |
| 3198 |
Tcl_DStringAppend(&dStr, Tk_PathName(tvPtr->tkwin), -1); |
| 3199 |
Tcl_DStringAppend(&dStr, ".", -1); |
| 3200 |
Tcl_DStringAppend(&dStr, name, -1); |
| 3201 |
name = Tcl_DStringValue(&dStr); |
| 3202 |
} |
| 3203 |
} |
| 3204 |
tkwin = Tk_NameToWindow(tvPtr->interp, name, tvPtr->tkwin); |
| 3205 |
if (tkwin == NULL || !isValidSubWin(tvPtr, tkwin)) { |
| 3206 |
goto error; |
| 3207 |
} |
| 3208 |
if (name && name[0]) { |
| 3209 |
|
| 3210 |
wcPtr->name = Blt_Strdup(name); |
| 3211 |
hPtr = Blt_CreateHashEntry(&tvPtr->winTable, wcPtr->name, &isNew); |
| 3212 |
if (hPtr != NULL) { |
| 3213 |
w2Ptr = (WindowCell*)Blt_GetHashValue(hPtr); |
| 3214 |
if (w2Ptr && (w2Ptr->flags&TV_WINDOW_DRAW)) { |
| 3215 |
goto error; |
| 3216 |
} |
| 3217 |
Blt_SetHashValue(hPtr, wcPtr); |
| 3218 |
} |
| 3219 |
} |
| 3220 |
Tcl_DStringFree(&dStr); |
| 3221 |
if (execCmd == NULL) { |
| 3222 |
entryPtr->flags |= ENTRY_DATA_WINDOW; |
| 3223 |
} |
| 3224 |
entryPtr->flags |= ENTRY_WINDOW; |
| 3225 |
wcPtr->tkwin = tkwin; |
| 3226 |
Tk_ManageGeometry(tkwin, &windowGeomType, wcPtr); |
| 3227 |
Tk_CreateEventHandler(tkwin, StructureNotifyMask, |
| 3228 |
EmbWinStructureProc, (ClientData) wcPtr); |
| 3229 |
return wcPtr; |
| 3230 |
|
| 3231 |
error: |
| 3232 |
if (wcPtr) { |
| 3233 |
Blt_DeleteHashEntry(&tvPtr->winCellTable, wcPtr->hPtr); |
| 3234 |
if (wcPtr->name) Blt_Free(wcPtr->name); |
| 3235 |
Blt_Free(wcPtr); |
| 3236 |
} |
| 3237 |
Tcl_DStringFree(&dStr); |
| 3238 |
return NULL; |
| 3239 |
} |
| 3240 |
|
| 3241 |
|
| 3242 |
static void EmbWinLostSlaveProc(ClientData clientData, Tk_Window tkwin) |
| 3243 |
{ |
| 3244 |
register WindowCell *wcPtr = (WindowCell *) clientData; |
| 3245 |
EmbWinUnmapNow(tkwin, wcPtr->tvPtr->tkwin); |
| 3246 |
EmbWinRemove(wcPtr); |
| 3247 |
} |
| 3248 |
|
| 3249 |
static void |
| 3250 |
EmbWinStructureProc(clientData, eventPtr) |
| 3251 |
ClientData clientData; |
| 3252 |
XEvent *eventPtr; |
| 3253 |
{ |
| 3254 |
register WindowCell *ewPtr = (WindowCell *) clientData; |
| 3255 |
|
| 3256 |
if (eventPtr->type != DestroyNotify) { |
| 3257 |
return; |
| 3258 |
} |
| 3259 |
EmbWinRemove(ewPtr); |
| 3260 |
} |
| 3261 |
|
| 3262 |
int |
| 3263 |
Blt_WinResizeAlways(Tk_Window tkwin) |
| 3264 |
{ |
| 3265 |
while (tkwin != NULL) { |
| 3266 |
#ifdef Tk_IsResizeYes |
| 3267 |
if (Tk_IsResizeYes(tkwin)) return 1; |
| 3268 |
#endif |
| 3269 |
if (Tk_TopWinHierarchy(tkwin)) break; |
| 3270 |
tkwin = Tk_Parent(tkwin); |
| 3271 |
} |
| 3272 |
return 0; |
| 3273 |
} |
| 3274 |
|
| 3275 |
static void |
| 3276 |
EmbWinDisplay(TreeView *tvPtr, WindowCell *wcPtr, |
| 3277 |
int x, int y, int width, int height) |
| 3278 |
{ |
| 3279 |
Tk_Window tkwin = tvPtr->tkwin; |
| 3280 |
Tk_Window cwTkwin = wcPtr->tkwin; |
| 3281 |
int diff, reqWidth, reqHeight, sticky, diffx, diffy; |
| 3282 |
|
| 3283 |
|
| 3284 |
if ((diff = (y-tvPtr->titleHeight- tvPtr->insetY))<0) { |
| 3285 |
height += diff; |
| 3286 |
y -= diff; |
| 3287 |
} |
| 3288 |
if (width < 2 || height < 2) { |
| 3289 |
if (wcPtr->flags&TV_WINDOW_DRAW) { |
| 3290 |
EmbWinUnmapNow(cwTkwin, tkwin); |
| 3291 |
} |
| 3292 |
return; |
| 3293 |
} |
| 3294 |
reqWidth = Tk_ReqWidth(cwTkwin); |
| 3295 |
if (reqWidth > width) { reqWidth = width; } |
| 3296 |
reqHeight = Tk_ReqHeight(cwTkwin); |
| 3297 |
if (reqHeight > height) { reqHeight = height; } |
| 3298 |
diffx = width - reqWidth; |
| 3299 |
diffy = height - reqHeight; |
| 3300 |
|
| 3301 |
sticky = wcPtr->stylePtr->sticky; |
| 3302 |
|
| 3303 |
if (sticky&STICK_EAST && sticky&STICK_WEST) { |
| 3304 |
reqWidth += diffx; |
| 3305 |
} |
| 3306 |
if (sticky&STICK_NORTH && sticky&STICK_SOUTH) { |
| 3307 |
reqHeight += diffy; |
| 3308 |
} |
| 3309 |
if (!(sticky&STICK_WEST)) { |
| 3310 |
x += (sticky&STICK_EAST) ? diffx : diffx/2; |
| 3311 |
} |
| 3312 |
if (!(sticky&STICK_NORTH)) { |
| 3313 |
y += (sticky&STICK_SOUTH) ? diffy : diffy/2; |
| 3314 |
} |
| 3315 |
width = reqWidth; |
| 3316 |
height = reqHeight; |
| 3317 |
if (tkwin == Tk_Parent(cwTkwin)) { |
| 3318 |
if ((x != Tk_X(cwTkwin)) || (y != Tk_Y(cwTkwin)) |
| 3319 |
|| (width != Tk_Width(cwTkwin)) |
| 3320 |
|| (height != Tk_Height(cwTkwin)) |
| 3321 |
|| Blt_WinResizeAlways(cwTkwin) |
| 3322 |
) { |
| 3323 |
Tk_MoveResizeWindow(cwTkwin, x, y, width, height); |
| 3324 |
} |
| 3325 |
Tk_MapWindow(cwTkwin); |
| 3326 |
} else { |
| 3327 |
Tk_MaintainGeometry(cwTkwin, tkwin, x, y, width, height); |
| 3328 |
} |
| 3329 |
wcPtr->flags |= TV_WINDOW_DRAW; |
| 3330 |
} |
| 3331 |
|
| 3332 |
|
| 3333 |
|
| 3334 |
|
| 3335 |
void |
| 3336 |
Blt_TreeViewWindowUpdate(TreeViewEntry *entryPtr, TreeViewColumn *columnPtr) |
| 3337 |
{ |
| 3338 |
TreeViewWindowBox *wbPtr; |
| 3339 |
WindowCell *wcPtr; |
| 3340 |
|
| 3341 |
if (entryPtr->flags & ENTRY_DATA_WINDOW) { |
| 3342 |
|
| 3343 |
|
| 3344 |
} else if (columnPtr->stylePtr != NULL && |
| 3345 |
columnPtr->stylePtr->classPtr->className[0] == 'w') { |
| 3346 |
wbPtr = (TreeViewWindowBox *)columnPtr->stylePtr; |
| 3347 |
if (wbPtr->windowCmd != NULL) return; |
| 3348 |
|
| 3349 |
} else { |
| 3350 |
return; |
| 3351 |
} |
| 3352 |
wcPtr = bltTreeViewFindWindow(entryPtr, columnPtr); |
| 3353 |
if (wcPtr == NULL || wcPtr->tkwin == NULL) return; |
| 3354 |
EmbWinUnmapNow(wcPtr->tkwin, wcPtr->tvPtr->tkwin); |
| 3355 |
Tk_ManageGeometry(wcPtr->tkwin, NULL, NULL); |
| 3356 |
EmbWinRemove(wcPtr); |
| 3357 |
} |
| 3358 |
|
| 3359 |
void |
| 3360 |
Blt_TreeViewWindowRelease(TreeViewEntry *entryPtr, TreeViewColumn *columnPtr) |
| 3361 |
{ |
| 3362 |
Blt_HashEntry *hPtr; |
| 3363 |
Blt_HashSearch cursor; |
| 3364 |
WindowCell *wcPtr; |
| 3365 |
TreeView *tvPtr; |
| 3366 |
|
| 3367 |
tvPtr = (columnPtr?columnPtr->tvPtr:entryPtr->tvPtr); |
| 3368 |
|
| 3369 |
for (hPtr = Blt_FirstHashEntry(&tvPtr->winCellTable, &cursor); hPtr != NULL; |
| 3370 |
hPtr = Blt_NextHashEntry(&cursor)) { |
| 3371 |
wcPtr = (WindowCell*)Blt_GetHashValue(hPtr); |
| 3372 |
if (wcPtr == NULL) continue; |
| 3373 |
if (entryPtr && entryPtr == wcPtr->entryPtr) { |
| 3374 |
EmbWinUnmapNow(wcPtr->tkwin, wcPtr->tvPtr->tkwin); |
| 3375 |
EmbWinRemove(wcPtr); |
| 3376 |
continue; |
| 3377 |
} |
| 3378 |
if (columnPtr && columnPtr == wcPtr->columnPtr) { |
| 3379 |
EmbWinUnmapNow(wcPtr->tkwin, wcPtr->tvPtr->tkwin); |
| 3380 |
EmbWinRemove(wcPtr); |
| 3381 |
continue; |
| 3382 |
} |
| 3383 |
} |
| 3384 |
} |
| 3385 |
|
| 3386 |
|
| 3387 |
|
| 3388 |
|
| 3389 |
|
| 3390 |
|
| 3391 |
|
| 3392 |
|
| 3393 |
|
| 3394 |
|
| 3395 |
|
| 3396 |
|
| 3397 |
|
| 3398 |
|
| 3399 |
|
| 3400 |
|
| 3401 |
static void |
| 3402 |
DrawWindowBox(tvPtr, drawable, entryPtr, valuePtr, stylePtr, icon, x, y) |
| 3403 |
TreeView *tvPtr; |
| 3404 |
Drawable drawable; |
| 3405 |
TreeViewEntry *entryPtr; |
| 3406 |
TreeViewValue *valuePtr; |
| 3407 |
TreeViewStyle *stylePtr; |
| 3408 |
TreeViewIcon icon; |
| 3409 |
int x, y; |
| 3410 |
{ |
| 3411 |
TreeViewColumn *columnPtr; |
| 3412 |
TreeViewWindowBox *tbPtr = (TreeViewWindowBox *)stylePtr; |
| 3413 |
int width, height, diff; |
| 3414 |
WindowCell *wcPtr; |
| 3415 |
TreeViewStyle sRec = *stylePtr; |
| 3416 |
|
| 3417 |
columnPtr = valuePtr->columnPtr; |
| 3418 |
|
| 3419 |
Tcl_Preserve(entryPtr); |
| 3420 |
wcPtr = bltTreeViewWindowMake(tvPtr, entryPtr, valuePtr, tbPtr); |
| 3421 |
if ((entryPtr->flags & ENTRY_DELETED) || (tvPtr->flags & TV_DELETED)) { |
| 3422 |
Tcl_Release(entryPtr); |
| 3423 |
return; |
| 3424 |
} |
| 3425 |
Tcl_Release(entryPtr); |
| 3426 |
|
| 3427 |
drawTextBox(tvPtr, drawable, entryPtr, valuePtr, stylePtr, icon, x, y, &sRec); |
| 3428 |
|
| 3429 |
if (wcPtr != NULL) { |
| 3430 |
int columnWidth = columnPtr->width - |
| 3431 |
(2 * columnPtr->borderWidth + PADDING(columnPtr->pad)); |
| 3432 |
|
| 3433 |
width = columnWidth; |
| 3434 |
height = entryPtr->height-1; |
| 3435 |
if ((diff = (y-tvPtr->titleHeight- tvPtr->insetY))<0) { |
| 3436 |
height += diff; |
| 3437 |
y -= diff; |
| 3438 |
} |
| 3439 |
EmbWinDisplay(tvPtr, wcPtr, x, y, width, height); |
| 3440 |
} |
| 3441 |
stylePtr->flags &= ~STYLE_DIRTY; |
| 3442 |
} |
| 3443 |
|
| 3444 |
|
| 3445 |
|
| 3446 |
|
| 3447 |
|
| 3448 |
|
| 3449 |
|
| 3450 |
|
| 3451 |
|
| 3452 |
|
| 3453 |
|
| 3454 |
|
| 3455 |
|
| 3456 |
|
| 3457 |
static int |
| 3458 |
EditWindowBox(tvPtr, entryPtr, valuePtr, stylePtr, x, y, retVal) |
| 3459 |
TreeView *tvPtr; |
| 3460 |
TreeViewEntry *entryPtr; |
| 3461 |
TreeViewValue *valuePtr; |
| 3462 |
TreeViewStyle *stylePtr; |
| 3463 |
int x; |
| 3464 |
int y; |
| 3465 |
int *retVal; |
| 3466 |
{ |
| 3467 |
return TCL_ERROR; |
| 3468 |
} |
| 3469 |
|
| 3470 |
|
| 3471 |
|
| 3472 |
|
| 3473 |
|
| 3474 |
|
| 3475 |
|
| 3476 |
|
| 3477 |
|
| 3478 |
|
| 3479 |
|
| 3480 |
|
| 3481 |
|
| 3482 |
|
| 3483 |
|
| 3484 |
|
| 3485 |
|
| 3486 |
|
| 3487 |
|
| 3488 |
static void |
| 3489 |
FreeWindowBox(tvPtr, stylePtr) |
| 3490 |
TreeView *tvPtr; |
| 3491 |
TreeViewStyle *stylePtr; |
| 3492 |
{ |
| 3493 |
TreeViewWindowBox *tbPtr = (TreeViewWindowBox *)stylePtr; |
| 3494 |
Blt_HashEntry *hPtr; |
| 3495 |
Blt_HashSearch cursor; |
| 3496 |
WindowCell *wcPtr; |
| 3497 |
|
| 3498 |
if (!tbPtr) return; |
| 3499 |
|
| 3500 |
for (hPtr = Blt_FirstHashEntry(&tvPtr->winCellTable, &cursor); hPtr != NULL; |
| 3501 |
hPtr = Blt_NextHashEntry(&cursor)) { |
| 3502 |
wcPtr = (WindowCell*)Blt_GetHashValue(hPtr); |
| 3503 |
if (wcPtr && stylePtr == (TreeViewStyle*)wcPtr->stylePtr) { |
| 3504 |
EmbWinRemove(wcPtr); |
| 3505 |
} |
| 3506 |
} |
| 3507 |
|
| 3508 |
} |
| 3509 |
|
| 3510 |
static TreeViewStyle * |
| 3511 |
GetStyle(interp, tvPtr, styleName) |
| 3512 |
Tcl_Interp *interp; |
| 3513 |
TreeView *tvPtr; |
| 3514 |
char *styleName; |
| 3515 |
{ |
| 3516 |
Blt_HashEntry *hPtr; |
| 3517 |
|
| 3518 |
hPtr = Blt_FindHashEntry(&tvPtr->styleTable, styleName); |
| 3519 |
if (hPtr == NULL) { |
| 3520 |
if (interp != NULL) { |
| 3521 |
Tcl_AppendResult(interp, "can't find style \"", styleName, |
| 3522 |
"\"", (char *)NULL); |
| 3523 |
} |
| 3524 |
return NULL; |
| 3525 |
} |
| 3526 |
return Blt_GetHashValue(hPtr); |
| 3527 |
} |
| 3528 |
|
| 3529 |
int |
| 3530 |
Blt_TreeViewGetStyle(interp, tvPtr, styleName, stylePtrPtr) |
| 3531 |
Tcl_Interp *interp; |
| 3532 |
TreeView *tvPtr; |
| 3533 |
char *styleName; |
| 3534 |
TreeViewStyle **stylePtrPtr; |
| 3535 |
{ |
| 3536 |
TreeViewStyle *stylePtr; |
| 3537 |
|
| 3538 |
stylePtr = GetStyle(interp, tvPtr, styleName); |
| 3539 |
if (stylePtr == NULL) { |
| 3540 |
return TCL_ERROR; |
| 3541 |
} |
| 3542 |
stylePtr->refCount++; |
| 3543 |
*stylePtrPtr = stylePtr; |
| 3544 |
return TCL_OK; |
| 3545 |
} |
| 3546 |
|
| 3547 |
int |
| 3548 |
Blt_TreeViewGetStyleMake(interp, tvPtr, styleName, stylePtrPtr, columnPtr, entryPtr, valuePtr) |
| 3549 |
Tcl_Interp *interp; |
| 3550 |
TreeView *tvPtr; |
| 3551 |
char *styleName; |
| 3552 |
TreeViewStyle **stylePtrPtr; |
| 3553 |
TreeViewColumn *columnPtr; |
| 3554 |
TreeViewEntry *entryPtr; |
| 3555 |
TreeViewValue *valuePtr; |
| 3556 |
{ |
| 3557 |
TreeViewStyle *stylePtr = NULL; |
| 3558 |
Tcl_DString dString; |
| 3559 |
int result; |
| 3560 |
|
| 3561 |
if (strlen(styleName)==0) { |
| 3562 |
Tcl_AppendResult(interp, "can not use style with empty name", 0); |
| 3563 |
return TCL_ERROR; |
| 3564 |
} |
| 3565 |
if (Blt_TreeViewGetStyle(NULL, tvPtr, styleName, &stylePtr) != TCL_OK) { |
| 3566 |
if (tvPtr->styleCmd == NULL) { |
| 3567 |
if (stylePtr == NULL) { |
| 3568 |
if (interp != NULL) { |
| 3569 |
Tcl_AppendResult(interp, "style not found: ", styleName, 0); |
| 3570 |
} |
| 3571 |
return TCL_ERROR; |
| 3572 |
} |
| 3573 |
} else if (!strcmp(tvPtr->styleCmd, "%W style create textbox %V")) { |
| 3574 |
stylePtr = Blt_TreeViewCreateStyle(interp, tvPtr, STYLE_TEXTBOX, styleName); |
| 3575 |
assert(stylePtr); |
| 3576 |
Blt_TreeViewUpdateStyleGCs(tvPtr, stylePtr); |
| 3577 |
|
| 3578 |
} else { |
| 3579 |
Tcl_DStringInit(&dString); |
| 3580 |
Blt_TreeViewPercentSubst(tvPtr, entryPtr, columnPtr, tvPtr->styleCmd, styleName, &dString); |
| 3581 |
|
| 3582 |
result = Tcl_GlobalEval(tvPtr->interp, Tcl_DStringValue(&dString)); |
| 3583 |
Tcl_DStringFree(&dString); |
| 3584 |
if ((tvPtr->flags & TV_DELETED)) { |
| 3585 |
return TCL_ERROR; |
| 3586 |
} |
| 3587 |
if (result != TCL_OK) { |
| 3588 |
if (interp != NULL) { |
| 3589 |
Tcl_AppendResult(interp, "error in -stylecommand ", tvPtr->styleCmd, " for: ", styleName, 0); |
| 3590 |
} |
| 3591 |
return TCL_ERROR; |
| 3592 |
} |
| 3593 |
result = Blt_TreeViewGetStyle(interp, tvPtr, styleName, &stylePtr); |
| 3594 |
if (result != TCL_OK) { |
| 3595 |
if (interp != NULL) { |
| 3596 |
Tcl_AppendResult(interp, "style not found: ", styleName, 0); |
| 3597 |
} |
| 3598 |
return TCL_ERROR; |
| 3599 |
} |
| 3600 |
Blt_TreeViewUpdateStyleGCs(tvPtr, stylePtr); |
| 3601 |
if (interp != NULL) { |
| 3602 |
Tcl_ResetResult(interp); |
| 3603 |
} |
| 3604 |
} |
| 3605 |
} |
| 3606 |
*stylePtrPtr = stylePtr; |
| 3607 |
return TCL_OK; |
| 3608 |
} |
| 3609 |
|
| 3610 |
static TreeViewStyle * |
| 3611 |
CreateStyle(interp, tvPtr, type, styleName, objc, objv, create) |
| 3612 |
Tcl_Interp *interp; |
| 3613 |
TreeView *tvPtr; |
| 3614 |
int type; |
| 3615 |
|
| 3616 |
|
| 3617 |
|
| 3618 |
char *styleName; |
| 3619 |
int objc; |
| 3620 |
Tcl_Obj *CONST *objv; |
| 3621 |
int create; |
| 3622 |
{ |
| 3623 |
Blt_HashEntry *hPtr; |
| 3624 |
int isNew, ref = 1; |
| 3625 |
TreeViewStyle *stylePtr; |
| 3626 |
|
| 3627 |
hPtr = Blt_CreateHashEntry(&tvPtr->styleTable, styleName, &isNew); |
| 3628 |
if (!isNew) { |
| 3629 |
|
| 3630 |
if (create && (tvPtr->styleCmd == NULL || strcmp(tvPtr->styleCmd, "%W style create textbox %V") == 0 || (tvPtr->styleCmd[0] == 0))) { |
| 3631 |
stylePtr = Blt_GetHashValue(hPtr); |
| 3632 |
if (type == (stylePtr->flags&STYLE_TYPE)) { |
| 3633 |
ref = 0; |
| 3634 |
goto doconf; |
| 3635 |
} |
| 3636 |
} |
| 3637 |
if (interp != NULL) { |
| 3638 |
Tcl_AppendResult(interp, "style \"", styleName, |
| 3639 |
"\" already exists", (char *)NULL); |
| 3640 |
} |
| 3641 |
return NULL; |
| 3642 |
} |
| 3643 |
|
| 3644 |
switch (type) { |
| 3645 |
case STYLE_TEXTBOX: |
| 3646 |
stylePtr = CreateTextBox(tvPtr, hPtr); |
| 3647 |
break; |
| 3648 |
case STYLE_COMBOBOX: |
| 3649 |
stylePtr = CreateComboBox(tvPtr, hPtr); |
| 3650 |
break; |
| 3651 |
case STYLE_CHECKBOX: |
| 3652 |
stylePtr = CreateCheckBox(tvPtr, hPtr); |
| 3653 |
break; |
| 3654 |
case STYLE_WINDOWBOX: |
| 3655 |
stylePtr = CreateWindowBox(tvPtr, hPtr); |
| 3656 |
break; |
| 3657 |
case STYLE_BARBOX: |
| 3658 |
stylePtr = CreateBarBox(tvPtr, hPtr); |
| 3659 |
break; |
| 3660 |
default: |
| 3661 |
return NULL; |
| 3662 |
} |
| 3663 |
doconf: |
| 3664 |
Blt_TreeViewOptsInit(tvPtr); |
| 3665 |
if (Blt_ConfigureComponentFromObj(tvPtr->interp, tvPtr->tkwin, styleName, |
| 3666 |
stylePtr->classPtr->className, stylePtr->classPtr->specsPtr, |
| 3667 |
objc, objv, (char *)stylePtr, 0) != TCL_OK) { |
| 3668 |
if (ref) { |
| 3669 |
Blt_TreeViewFreeStyle(tvPtr, stylePtr); |
| 3670 |
} |
| 3671 |
return NULL; |
| 3672 |
} |
| 3673 |
if (stylePtr->tile != NULL) { |
| 3674 |
Blt_SetTileChangedProc(stylePtr->tile, Blt_TreeViewTileChangedProc, tvPtr); |
| 3675 |
} |
| 3676 |
if (stylePtr->fillTile != NULL) { |
| 3677 |
Blt_SetTileChangedProc(stylePtr->fillTile, Blt_TreeViewTileChangedProc, tvPtr); |
| 3678 |
} |
| 3679 |
stylePtr->refCount += ref; |
| 3680 |
return stylePtr; |
| 3681 |
} |
| 3682 |
|
| 3683 |
void |
| 3684 |
Blt_TreeViewUpdateStyleGCs(tvPtr, stylePtr) |
| 3685 |
TreeView *tvPtr; |
| 3686 |
TreeViewStyle *stylePtr; |
| 3687 |
{ |
| 3688 |
if (tvPtr->font == NULL) return; |
| 3689 |
(*stylePtr->classPtr->configProc)(tvPtr, stylePtr); |
| 3690 |
stylePtr->flags |= STYLE_DIRTY; |
| 3691 |
Blt_TreeViewEventuallyRedraw(tvPtr); |
| 3692 |
} |
| 3693 |
|
| 3694 |
void |
| 3695 |
Blt_TreeViewUpdateStyles(tvPtr) |
| 3696 |
TreeView *tvPtr; |
| 3697 |
{ |
| 3698 |
Blt_HashEntry *hPtr; |
| 3699 |
Blt_HashSearch cursor; |
| 3700 |
TreeViewStyle *stylePtr; |
| 3701 |
Blt_TreeViewUpdateStyleGCs(tvPtr, tvPtr->stylePtr); |
| 3702 |
|
| 3703 |
for (hPtr = Blt_FirstHashEntry(&tvPtr->styleTable, &cursor); hPtr != NULL; |
| 3704 |
hPtr = Blt_NextHashEntry(&cursor)) { |
| 3705 |
stylePtr = Blt_GetHashValue(hPtr); |
| 3706 |
Blt_TreeViewUpdateStyleGCs(tvPtr, stylePtr); |
| 3707 |
} |
| 3708 |
} |
| 3709 |
|
| 3710 |
TreeViewStyle * |
| 3711 |
Blt_TreeViewCreateStyle(interp, tvPtr, type, styleName) |
| 3712 |
Tcl_Interp *interp; |
| 3713 |
TreeView *tvPtr; |
| 3714 |
int type; |
| 3715 |
|
| 3716 |
|
| 3717 |
|
| 3718 |
char *styleName; |
| 3719 |
{ |
| 3720 |
return CreateStyle(interp, tvPtr, type, styleName, 0, (Tcl_Obj **)NULL, 0); |
| 3721 |
} |
| 3722 |
|
| 3723 |
void |
| 3724 |
Blt_TreeViewFreeStyle(tvPtr, stylePtr) |
| 3725 |
TreeView *tvPtr; |
| 3726 |
TreeViewStyle *stylePtr; |
| 3727 |
{ |
| 3728 |
stylePtr->refCount--; |
| 3729 |
#ifdef notdef |
| 3730 |
fprint(f(stderr, "Blt_TreeViewFreeStyle %s count=%d\n", stylePtr->name, |
| 3731 |
stylePtr->refCount); |
| 3732 |
#endif |
| 3733 |
|
| 3734 |
|
| 3735 |
if ((stylePtr->refCount <= 0) && !(stylePtr->flags & STYLE_USER)){ |
| 3736 |
#ifdef notdef |
| 3737 |
fprintf(stderr, "freeing %s\n", stylePtr->name); |
| 3738 |
#endif |
| 3739 |
|
| 3740 |
|
| 3741 |
|
| 3742 |
|
| 3743 |
|
| 3744 |
Blt_TreeViewOptsInit(tvPtr); |
| 3745 |
Blt_FreeObjOptions(tvPtr->interp, |
| 3746 |
stylePtr->classPtr->specsPtr, (char *)stylePtr, |
| 3747 |
tvPtr->display, 0); |
| 3748 |
(*stylePtr->classPtr->freeProc)(tvPtr, stylePtr); |
| 3749 |
if (stylePtr->hashPtr != NULL) { |
| 3750 |
Blt_DeleteHashEntry(&tvPtr->styleTable, stylePtr->hashPtr); |
| 3751 |
} |
| 3752 |
if (stylePtr->name != NULL) { |
| 3753 |
Blt_Free(stylePtr->name); |
| 3754 |
} |
| 3755 |
if (tvPtr->subStylePtr == stylePtr) { tvPtr->subStylePtr = NULL; } |
| 3756 |
if (tvPtr->altStylePtr == stylePtr) { tvPtr->altStylePtr = NULL; } |
| 3757 |
if (tvPtr->emptyStylePtr == stylePtr) { tvPtr->emptyStylePtr = NULL; } |
| 3758 |
Blt_Free(stylePtr); |
| 3759 |
} |
| 3760 |
} |
| 3761 |
|
| 3762 |
void |
| 3763 |
Blt_TreeViewSetStyleIcon(tvPtr, stylePtr, icon) |
| 3764 |
TreeView *tvPtr; |
| 3765 |
TreeViewStyle *stylePtr; |
| 3766 |
TreeViewIcon icon; |
| 3767 |
{ |
| 3768 |
TreeViewTextBox *tbPtr = (TreeViewTextBox *)stylePtr; |
| 3769 |
|
| 3770 |
if (tbPtr && tbPtr->icon != NULL) { |
| 3771 |
Blt_TreeViewFreeIcon(tvPtr, tbPtr->icon); |
| 3772 |
} |
| 3773 |
tbPtr->icon = icon; |
| 3774 |
} |
| 3775 |
|
| 3776 |
GC |
| 3777 |
Blt_TreeViewGetStyleGC(tvPtr, stylePtr) |
| 3778 |
TreeView *tvPtr; |
| 3779 |
TreeViewStyle *stylePtr; |
| 3780 |
{ |
| 3781 |
TreeViewTextBox *tbPtr = (TreeViewTextBox *)stylePtr; |
| 3782 |
return (tbPtr && tbPtr->gc) ? tbPtr->gc : tvPtr->stylePtr->gc; |
| 3783 |
} |
| 3784 |
|
| 3785 |
Tk_3DBorder |
| 3786 |
Blt_TreeViewGetStyleBorder(tvPtr, stylePtr) |
| 3787 |
TreeView *tvPtr; |
| 3788 |
TreeViewStyle *stylePtr; |
| 3789 |
{ |
| 3790 |
TreeViewTextBox *tbPtr = (TreeViewTextBox *)stylePtr; |
| 3791 |
Tk_3DBorder border; |
| 3792 |
|
| 3793 |
if (!tbPtr) { |
| 3794 |
return tvPtr->border; |
| 3795 |
} |
| 3796 |
border = (tbPtr->flags & STYLE_HIGHLIGHT) |
| 3797 |
? tbPtr->highlightBorder : tbPtr->border; |
| 3798 |
return (border != NULL) ? border : tvPtr->border; |
| 3799 |
} |
| 3800 |
|
| 3801 |
Tk_Font |
| 3802 |
Blt_TreeViewGetStyleFont(tvPtr, columnPtr, stylePtr) |
| 3803 |
TreeView *tvPtr; |
| 3804 |
TreeViewColumn *columnPtr; |
| 3805 |
TreeViewStyle *stylePtr; |
| 3806 |
{ |
| 3807 |
TreeViewTextBox *tbPtr = (TreeViewTextBox *)stylePtr; |
| 3808 |
|
| 3809 |
if (tbPtr != NULL && tbPtr->font != NULL) { |
| 3810 |
return tbPtr->font; |
| 3811 |
} |
| 3812 |
if (columnPtr != NULL && columnPtr->font != NULL) { |
| 3813 |
return columnPtr->font; |
| 3814 |
} |
| 3815 |
return tvPtr->font; |
| 3816 |
} |
| 3817 |
|
| 3818 |
XColor * |
| 3819 |
Blt_TreeViewGetStyleFg(tvPtr, columnPtr, stylePtr) |
| 3820 |
TreeView *tvPtr; |
| 3821 |
TreeViewColumn *columnPtr; |
| 3822 |
TreeViewStyle *stylePtr; |
| 3823 |
{ |
| 3824 |
TreeViewTextBox *tbPtr = (TreeViewTextBox *)stylePtr; |
| 3825 |
|
| 3826 |
if (tbPtr && tbPtr->fgColor != NULL) { |
| 3827 |
return tbPtr->fgColor; |
| 3828 |
} |
| 3829 |
if (columnPtr && columnPtr->fgColor) { |
| 3830 |
return columnPtr->fgColor; |
| 3831 |
} |
| 3832 |
return tvPtr->fgColor; |
| 3833 |
} |
| 3834 |
|
| 3835 |
static void |
| 3836 |
DrawValue(tvPtr, entryPtr, valuePtr) |
| 3837 |
TreeView *tvPtr; |
| 3838 |
TreeViewEntry *entryPtr; |
| 3839 |
TreeViewValue *valuePtr; |
| 3840 |
{ |
| 3841 |
Drawable drawable; |
| 3842 |
int sx, sy, dx, dy; |
| 3843 |
int width, height, ishid; |
| 3844 |
int left, right, top, bottom; |
| 3845 |
TreeViewColumn *columnPtr; |
| 3846 |
TreeViewStyle *stylePtr; |
| 3847 |
Tk_3DBorder selBorder; |
| 3848 |
|
| 3849 |
stylePtr = valuePtr->stylePtr; |
| 3850 |
ishid = (stylePtr?stylePtr->hidden:0); |
| 3851 |
if (stylePtr == NULL) { |
| 3852 |
stylePtr = CHOOSE(tvPtr->stylePtr, valuePtr->columnPtr->stylePtr); |
| 3853 |
} |
| 3854 |
if (stylePtr->cursor != None) { |
| 3855 |
if (valuePtr == tvPtr->activeValuePtr) { |
| 3856 |
Tk_DefineCursor(tvPtr->tkwin, stylePtr->cursor); |
| 3857 |
} else { |
| 3858 |
if (tvPtr->cursor != None) { |
| 3859 |
Tk_DefineCursor(tvPtr->tkwin, tvPtr->cursor); |
| 3860 |
} else { |
| 3861 |
Tk_UndefineCursor(tvPtr->tkwin); |
| 3862 |
} |
| 3863 |
} |
| 3864 |
} |
| 3865 |
columnPtr = valuePtr->columnPtr; |
| 3866 |
dx = SCREENX(tvPtr, columnPtr->worldX) + columnPtr->pad.side1-1; |
| 3867 |
dy = SCREENY(tvPtr, entryPtr->worldY); |
| 3868 |
height = entryPtr->height - 1; |
| 3869 |
width = valuePtr->columnPtr->width - PADDING(columnPtr->pad); |
| 3870 |
|
| 3871 |
top = tvPtr->titleHeight + tvPtr->insetY; |
| 3872 |
bottom = Tk_Height(tvPtr->tkwin) - tvPtr->insetY; |
| 3873 |
left = tvPtr->insetX; |
| 3874 |
right = Tk_Width(tvPtr->tkwin) - tvPtr->insetX; |
| 3875 |
|
| 3876 |
if (((dx + width) < left) || (dx > right) || |
| 3877 |
((dy + height) < top) || (dy > bottom)) { |
| 3878 |
return; |
| 3879 |
} |
| 3880 |
|
| 3881 |
drawable = Tk_GetPixmap(tvPtr->display, Tk_WindowId(tvPtr->tkwin), |
| 3882 |
width, height, Tk_Depth(tvPtr->tkwin)); |
| 3883 |
|
| 3884 |
|
| 3885 |
if (Blt_TreeViewEntryIsSelected(tvPtr, entryPtr, columnPtr)) { |
| 3886 |
selBorder = SELECT_BORDER(tvPtr); |
| 3887 |
Blt_Fill3DRectangle(tvPtr->tkwin, drawable, selBorder, 0, 0, width, height, |
| 3888 |
0, TK_RELIEF_FLAT); |
| 3889 |
} else if ((valuePtr == tvPtr->activeValuePtr) || |
| 3890 |
(!Blt_TreeViewEntryIsSelected(tvPtr, entryPtr, columnPtr))) { |
| 3891 |
Tk_3DBorder border; |
| 3892 |
|
| 3893 |
border = Blt_TreeViewGetStyleBorder(tvPtr, tvPtr->stylePtr); |
| 3894 |
Blt_Fill3DRectangle(tvPtr->tkwin, drawable, border, 0, 0, width, height, |
| 3895 |
0, TK_RELIEF_FLAT); |
| 3896 |
} else if (Blt_HasTile(tvPtr->tile) == 0 && Blt_HasTile(columnPtr->tile) == 0) { |
| 3897 |
|
| 3898 |
Blt_Draw3DRectangle(tvPtr->tkwin, drawable, SELECT_BORDER(tvPtr), 0, 0, |
| 3899 |
width, height, tvPtr->selBorderWidth, tvPtr->selRelief); |
| 3900 |
} |
| 3901 |
Blt_TreeViewDrawValue(tvPtr, entryPtr, valuePtr, drawable, 0, 0, entryPtr->flags & ENTRY_ALTROW, ishid); |
| 3902 |
|
| 3903 |
|
| 3904 |
sx = sy = 0; |
| 3905 |
if (dx < left) { |
| 3906 |
width -= left - dx; |
| 3907 |
sx += left - dx; |
| 3908 |
dx = left; |
| 3909 |
} |
| 3910 |
if ((dx + width) >= right) { |
| 3911 |
width -= (dx + width) - right; |
| 3912 |
} |
| 3913 |
if (dy < top) { |
| 3914 |
height -= top - dy; |
| 3915 |
sy += top - dy; |
| 3916 |
dy = top; |
| 3917 |
} |
| 3918 |
if ((dy + height) >= bottom) { |
| 3919 |
height -= (dy + height) - bottom; |
| 3920 |
} |
| 3921 |
XCopyArea(tvPtr->display, drawable, Tk_WindowId(tvPtr->tkwin), |
| 3922 |
tvPtr->lineGC, sx, sy, width, height, dx, dy); |
| 3923 |
Tk_FreePixmap(tvPtr->display, drawable); |
| 3924 |
} |
| 3925 |
|
| 3926 |
|
| 3927 |
|
| 3928 |
|
| 3929 |
|
| 3930 |
|
| 3931 |
|
| 3932 |
|
| 3933 |
|
| 3934 |
|
| 3935 |
|
| 3936 |
|
| 3937 |
|
| 3938 |
|
| 3939 |
|
| 3940 |
|
| 3941 |
|
| 3942 |
static int |
| 3943 |
StyleActivateOp(tvPtr, interp, objc, objv) |
| 3944 |
TreeView *tvPtr; |
| 3945 |
|
| 3946 |
Tcl_Interp *interp; |
| 3947 |
int objc; |
| 3948 |
Tcl_Obj *CONST *objv; |
| 3949 |
{ |
| 3950 |
TreeViewEntry *entryPtr; |
| 3951 |
TreeViewValue *valuePtr, *oldPtr; |
| 3952 |
|
| 3953 |
oldPtr = tvPtr->activeValuePtr; |
| 3954 |
if (objc == 3) { |
| 3955 |
Tcl_Obj *listObjPtr; |
| 3956 |
|
| 3957 |
valuePtr = tvPtr->activeValuePtr; |
| 3958 |
entryPtr = tvPtr->activePtr; |
| 3959 |
listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); |
| 3960 |
if ((entryPtr != NULL) && (valuePtr != NULL)) { |
| 3961 |
Tcl_Obj *objPtr; |
| 3962 |
objPtr = Tcl_NewIntObj(Blt_TreeNodeId(entryPtr->node)); |
| 3963 |
Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); |
| 3964 |
objPtr = Tcl_NewStringObj(valuePtr->columnPtr->key, -1); |
| 3965 |
Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); |
| 3966 |
} |
| 3967 |
Tcl_SetObjResult(interp, listObjPtr); |
| 3968 |
return TCL_OK; |
| 3969 |
} else if (objc == 4) { |
| 3970 |
tvPtr->activeValuePtr = NULL; |
| 3971 |
if ((oldPtr != NULL) && (tvPtr->activePtr != NULL)) { |
| 3972 |
DrawValue(tvPtr, tvPtr->activePtr, oldPtr); |
| 3973 |
} |
| 3974 |
} else { |
| 3975 |
TreeViewColumn *columnPtr; |
| 3976 |
|
| 3977 |
if (Blt_TreeViewGetEntry(tvPtr, objv[3], &entryPtr) != TCL_OK) { |
| 3978 |
return TCL_ERROR; |
| 3979 |
} |
| 3980 |
|
| 3981 |
if (Blt_TreeViewGetColumn(interp, tvPtr, objv[4], &columnPtr) |
| 3982 |
!= TCL_OK) { |
| 3983 |
return TCL_ERROR; |
| 3984 |
} |
| 3985 |
valuePtr = Blt_TreeViewFindValue(entryPtr, columnPtr); |
| 3986 |
if (valuePtr == NULL) { |
| 3987 |
return TCL_OK; |
| 3988 |
} |
| 3989 |
tvPtr->activePtr = entryPtr; |
| 3990 |
tvPtr->activeColumnPtr = columnPtr; |
| 3991 |
oldPtr = tvPtr->activeValuePtr; |
| 3992 |
tvPtr->activeValuePtr = valuePtr; |
| 3993 |
if (valuePtr != oldPtr) { |
| 3994 |
if (oldPtr != NULL) { |
| 3995 |
DrawValue(tvPtr, entryPtr, oldPtr); |
| 3996 |
} |
| 3997 |
if (valuePtr != NULL) { |
| 3998 |
DrawValue(tvPtr, entryPtr, valuePtr); |
| 3999 |
} |
| 4000 |
} |
| 4001 |
} |
| 4002 |
return TCL_OK; |
| 4003 |
} |
| 4004 |
|
| 4005 |
|
| 4006 |
|
| 4007 |
|
| 4008 |
|
| 4009 |
|
| 4010 |
|
| 4011 |
|
| 4012 |
|
| 4013 |
|
| 4014 |
|
| 4015 |
|
| 4016 |
static int |
| 4017 |
StyleCgetOp(tvPtr, interp, objc, objv) |
| 4018 |
TreeView *tvPtr; |
| 4019 |
Tcl_Interp *interp; |
| 4020 |
int objc; |
| 4021 |
Tcl_Obj *CONST *objv; |
| 4022 |
{ |
| 4023 |
TreeViewStyle *stylePtr; |
| 4024 |
|
| 4025 |
stylePtr = GetStyle(interp, tvPtr, Tcl_GetString(objv[3])); |
| 4026 |
if (stylePtr == NULL) { |
| 4027 |
return TCL_ERROR; |
| 4028 |
} |
| 4029 |
Blt_TreeViewOptsInit(tvPtr); |
| 4030 |
return Blt_ConfigureValueFromObj(interp, tvPtr->tkwin, |
| 4031 |
stylePtr->classPtr->specsPtr, (char *)stylePtr, objv[4], 0); |
| 4032 |
} |
| 4033 |
|
| 4034 |
|
| 4035 |
|
| 4036 |
|
| 4037 |
|
| 4038 |
|
| 4039 |
|
| 4040 |
|
| 4041 |
|
| 4042 |
|
| 4043 |
|
| 4044 |
static int |
| 4045 |
StyleCheckBoxOp(tvPtr, interp, objc, objv) |
| 4046 |
TreeView *tvPtr; |
| 4047 |
Tcl_Interp *interp; |
| 4048 |
int objc; |
| 4049 |
Tcl_Obj *CONST *objv; |
| 4050 |
{ |
| 4051 |
TreeViewStyle *stylePtr; |
| 4052 |
|
| 4053 |
stylePtr = CreateStyle(interp, tvPtr, STYLE_CHECKBOX, |
| 4054 |
Tcl_GetString(objv[3]), objc - 4, objv + 4, 1); |
| 4055 |
if (stylePtr == NULL) { |
| 4056 |
return TCL_ERROR; |
| 4057 |
} |
| 4058 |
stylePtr->refCount = 0; |
| 4059 |
stylePtr->flags |= STYLE_USER; |
| 4060 |
Blt_TreeViewUpdateStyleGCs(tvPtr, stylePtr); |
| 4061 |
Tcl_SetObjResult(interp, objv[3]); |
| 4062 |
return TCL_OK; |
| 4063 |
} |
| 4064 |
|
| 4065 |
|
| 4066 |
|
| 4067 |
|
| 4068 |
|
| 4069 |
|
| 4070 |
|
| 4071 |
|
| 4072 |
|
| 4073 |
|
| 4074 |
|
| 4075 |
|
| 4076 |
static int |
| 4077 |
StyleComboBoxOp(tvPtr, interp, objc, objv) |
| 4078 |
TreeView *tvPtr; |
| 4079 |
Tcl_Interp *interp; |
| 4080 |
int objc; |
| 4081 |
Tcl_Obj *CONST *objv; |
| 4082 |
{ |
| 4083 |
TreeViewStyle *stylePtr; |
| 4084 |
|
| 4085 |
stylePtr = CreateStyle(interp, tvPtr, STYLE_COMBOBOX, |
| 4086 |
Tcl_GetString(objv[3]), objc - 4, objv + 4, 1); |
| 4087 |
if (stylePtr == NULL) { |
| 4088 |
return TCL_ERROR; |
| 4089 |
} |
| 4090 |
stylePtr->refCount = 0; |
| 4091 |
stylePtr->flags |= STYLE_USER; |
| 4092 |
Blt_TreeViewUpdateStyleGCs(tvPtr, stylePtr); |
| 4093 |
Tcl_SetObjResult(interp, objv[3]); |
| 4094 |
return TCL_OK; |
| 4095 |
} |
| 4096 |
|
| 4097 |
|
| 4098 |
|
| 4099 |
|
| 4100 |
|
| 4101 |
|
| 4102 |
|
| 4103 |
|
| 4104 |
|
| 4105 |
|
| 4106 |
|
| 4107 |
|
| 4108 |
|
| 4109 |
|
| 4110 |
|
| 4111 |
|
| 4112 |
|
| 4113 |
|
| 4114 |
|
| 4115 |
|
| 4116 |
|
| 4117 |
|
| 4118 |
static int |
| 4119 |
StyleConfigureOp(tvPtr, interp, objc, objv) |
| 4120 |
TreeView *tvPtr; |
| 4121 |
Tcl_Interp *interp; |
| 4122 |
int objc; |
| 4123 |
Tcl_Obj *CONST *objv; |
| 4124 |
{ |
| 4125 |
TreeViewStyle *stylePtr; |
| 4126 |
|
| 4127 |
if (Blt_TreeViewGetStyleMake(interp, tvPtr, Tcl_GetString(objv[3]), &stylePtr, |
| 4128 |
NULL, NULL, NULL) != TCL_OK) { |
| 4129 |
return TCL_ERROR; |
| 4130 |
} |
| 4131 |
stylePtr->refCount--; |
| 4132 |
|
| 4133 |
Blt_TreeViewOptsInit(tvPtr); |
| 4134 |
if (objc == 4) { |
| 4135 |
return Blt_ConfigureInfoFromObj(interp, tvPtr->tkwin, |
| 4136 |
stylePtr->classPtr->specsPtr, (char *)stylePtr, (Tcl_Obj *)NULL, 0); |
| 4137 |
} else if (objc == 5) { |
| 4138 |
return Blt_ConfigureInfoFromObj(interp, tvPtr->tkwin, |
| 4139 |
stylePtr->classPtr->specsPtr, (char *)stylePtr, objv[4], 0); |
| 4140 |
} |
| 4141 |
if (Blt_ConfigureWidgetFromObj(interp, tvPtr->tkwin, |
| 4142 |
stylePtr->classPtr->specsPtr, objc - 4, objv + 4, (char *)stylePtr, |
| 4143 |
BLT_CONFIG_OBJV_ONLY, NULL) != TCL_OK) { |
| 4144 |
return TCL_ERROR; |
| 4145 |
} |
| 4146 |
if (stylePtr->tile != NULL) { |
| 4147 |
Blt_SetTileChangedProc(stylePtr->tile, Blt_TreeViewTileChangedProc, tvPtr); |
| 4148 |
} |
| 4149 |
if (stylePtr->fillTile != NULL) { |
| 4150 |
Blt_SetTileChangedProc(stylePtr->fillTile, Blt_TreeViewTileChangedProc, tvPtr); |
| 4151 |
} |
| 4152 |
(*stylePtr->classPtr->configProc)(tvPtr, stylePtr); |
| 4153 |
Blt_TreeViewMakeStyleDirty(tvPtr); |
| 4154 |
Blt_TreeViewEventuallyRedraw(tvPtr); |
| 4155 |
return TCL_OK; |
| 4156 |
} |
| 4157 |
|
| 4158 |
|
| 4159 |
|
| 4160 |
|
| 4161 |
|
| 4162 |
|
| 4163 |
|
| 4164 |
|
| 4165 |
|
| 4166 |
|
| 4167 |
|
| 4168 |
|
| 4169 |
|
| 4170 |
|
| 4171 |
|
| 4172 |
|
| 4173 |
|
| 4174 |
static int |
| 4175 |
StyleForgetOp(tvPtr, interp, objc, objv) |
| 4176 |
TreeView *tvPtr; |
| 4177 |
|
| 4178 |
Tcl_Interp *interp; |
| 4179 |
int objc; |
| 4180 |
Tcl_Obj *CONST *objv; |
| 4181 |
{ |
| 4182 |
TreeViewStyle *stylePtr; |
| 4183 |
int i; |
| 4184 |
|
| 4185 |
for (i = 3; i < objc; i++) { |
| 4186 |
stylePtr = GetStyle(interp, tvPtr, Tcl_GetString(objv[i])); |
| 4187 |
if (stylePtr == NULL) { |
| 4188 |
return TCL_ERROR; |
| 4189 |
} |
| 4190 |
if (stylePtr->refCount > 1 || stylePtr == tvPtr->stylePtr) { |
| 4191 |
continue; |
| 4192 |
} |
| 4193 |
if (stylePtr->hashPtr != NULL) { |
| 4194 |
Blt_DeleteHashEntry(&tvPtr->styleTable, stylePtr->hashPtr); |
| 4195 |
stylePtr->hashPtr = NULL; |
| 4196 |
} |
| 4197 |
stylePtr->refCount--; |
| 4198 |
stylePtr->flags &= ~STYLE_USER; |
| 4199 |
Blt_TreeViewFreeStyle(tvPtr, stylePtr); |
| 4200 |
} |
| 4201 |
Blt_TreeViewEventuallyRedraw(tvPtr); |
| 4202 |
return TCL_OK; |
| 4203 |
} |
| 4204 |
|
| 4205 |
static int |
| 4206 |
StyleUseOp(tvPtr, interp, objc, objv) |
| 4207 |
TreeView *tvPtr; |
| 4208 |
|
| 4209 |
Tcl_Interp *interp; |
| 4210 |
int objc; |
| 4211 |
Tcl_Obj *CONST *objv; |
| 4212 |
{ |
| 4213 |
TreeViewStyle *stylePtr; |
| 4214 |
|
| 4215 |
stylePtr = GetStyle(interp, tvPtr, Tcl_GetString(objv[3])); |
| 4216 |
if (stylePtr == NULL) { |
| 4217 |
return TCL_ERROR; |
| 4218 |
} |
| 4219 |
Tcl_SetObjResult(interp, Tcl_NewIntObj(stylePtr->refCount-1)); |
| 4220 |
return TCL_OK; |
| 4221 |
} |
| 4222 |
|
| 4223 |
|
| 4224 |
static int StyleLookup(char *string) { |
| 4225 |
if (!strcmp(string, "combobox")) { |
| 4226 |
return STYLE_COMBOBOX; |
| 4227 |
} |
| 4228 |
if (!strcmp(string, "textbox")) { |
| 4229 |
return STYLE_TEXTBOX; |
| 4230 |
} |
| 4231 |
if (!strcmp(string, "barbox")) { |
| 4232 |
return STYLE_BARBOX; |
| 4233 |
} |
| 4234 |
if (!strcmp(string, "windowbox")) { |
| 4235 |
return STYLE_WINDOWBOX; |
| 4236 |
} |
| 4237 |
if (!strcmp(string, "checkbox")) { |
| 4238 |
return STYLE_CHECKBOX; |
| 4239 |
} |
| 4240 |
return -1; |
| 4241 |
} |
| 4242 |
|
| 4243 |
|
| 4244 |
|
| 4245 |
|
| 4246 |
|
| 4247 |
|
| 4248 |
|
| 4249 |
|
| 4250 |
|
| 4251 |
|
| 4252 |
|
| 4253 |
|
| 4254 |
|
| 4255 |
|
| 4256 |
|
| 4257 |
|
| 4258 |
static int |
| 4259 |
StyleTypeOp(tvPtr, interp, objc, objv) |
| 4260 |
TreeView *tvPtr; |
| 4261 |
|
| 4262 |
Tcl_Interp *interp; |
| 4263 |
int objc; |
| 4264 |
Tcl_Obj *CONST *objv; |
| 4265 |
{ |
| 4266 |
TreeViewStyle *stylePtr, *newStylePtr; |
| 4267 |
TreeViewAllStyles all; |
| 4268 |
const char *cp; |
| 4269 |
char *newType; |
| 4270 |
int nType; |
| 4271 |
|
| 4272 |
if (objc == 3) { |
| 4273 |
cp = "textbox combobox checkbox barbox windowbox"; |
| 4274 |
Tcl_AppendResult(interp, cp, 0); |
| 4275 |
return TCL_OK; |
| 4276 |
} |
| 4277 |
stylePtr = GetStyle(interp, tvPtr, Tcl_GetString(objv[3])); |
| 4278 |
if (stylePtr == NULL) { |
| 4279 |
return TCL_ERROR; |
| 4280 |
} |
| 4281 |
if (stylePtr->flags & STYLE_CHECKBOX) { |
| 4282 |
cp = "checkbox"; |
| 4283 |
} else if (stylePtr->flags & STYLE_COMBOBOX) { |
| 4284 |
cp = "combobox"; |
| 4285 |
} else if (stylePtr->flags & STYLE_WINDOWBOX) { |
| 4286 |
cp = "windowbox"; |
| 4287 |
} else if (stylePtr->flags & STYLE_BARBOX) { |
| 4288 |
cp = "barbox"; |
| 4289 |
} else { |
| 4290 |
cp = "textbox"; |
| 4291 |
} |
| 4292 |
|
| 4293 |
if (objc == 4) { |
| 4294 |
Tcl_AppendResult(interp, cp, 0); |
| 4295 |
return TCL_OK; |
| 4296 |
} |
| 4297 |
if (!strcmp(stylePtr->name, "text")) { |
| 4298 |
Tcl_AppendResult(interp, "can not change type of style \"text\"", 0); |
| 4299 |
return TCL_ERROR; |
| 4300 |
} |
| 4301 |
newType = Tcl_GetString(objv[4]); |
| 4302 |
nType = StyleLookup( newType ); |
| 4303 |
if (nType<0) { |
| 4304 |
Tcl_AppendResult(interp, "unknown type: ", newType, 0); |
| 4305 |
return TCL_ERROR; |
| 4306 |
} |
| 4307 |
|
| 4308 |
|
| 4309 |
|
| 4310 |
|
| 4311 |
newStylePtr = CreateStyle(interp, tvPtr, nType, "__%%StyleTypeSet%%_", 0, 0, 0); |
| 4312 |
if (newStylePtr == NULL) { |
| 4313 |
return TCL_ERROR; |
| 4314 |
} |
| 4315 |
newStylePtr->flags |= STYLE_USER; |
| 4316 |
memcpy(&all, stylePtr, sizeof(all)); |
| 4317 |
memcpy(stylePtr, newStylePtr, sizeof(all)); |
| 4318 |
memcpy(newStylePtr, &all, sizeof(all)); |
| 4319 |
newStylePtr->refCount = stylePtr->refCount; |
| 4320 |
stylePtr->refCount = all.tb.refCount ; |
| 4321 |
newStylePtr->hashPtr = stylePtr->hashPtr; |
| 4322 |
stylePtr->hashPtr = all.tb.hashPtr ; |
| 4323 |
newStylePtr->name = stylePtr->name; |
| 4324 |
stylePtr->name = all.tb.name ; |
| 4325 |
|
| 4326 |
newStylePtr->flags &= ~STYLE_USER; |
| 4327 |
Blt_TreeViewFreeStyle(tvPtr, newStylePtr); |
| 4328 |
Blt_TreeViewUpdateStyleGCs(tvPtr, stylePtr); |
| 4329 |
tvPtr->flags |= (TV_DIRTY | TV_LAYOUT | TV_SCROLL | TV_UPDATE); |
| 4330 |
Blt_TreeViewMakeStyleDirty(tvPtr); |
| 4331 |
Blt_TreeViewEventuallyRedraw(tvPtr); |
| 4332 |
return TCL_OK; |
| 4333 |
} |
| 4334 |
|
| 4335 |
|
| 4336 |
|
| 4337 |
|
| 4338 |
|
| 4339 |
|
| 4340 |
|
| 4341 |
|
| 4342 |
|
| 4343 |
|
| 4344 |
|
| 4345 |
|
| 4346 |
|
| 4347 |
|
| 4348 |
|
| 4349 |
|
| 4350 |
|
| 4351 |
static int |
| 4352 |
StyleHighlightOp(tvPtr, interp, objc, objv) |
| 4353 |
TreeView *tvPtr; |
| 4354 |
|
| 4355 |
Tcl_Interp *interp; |
| 4356 |
int objc; |
| 4357 |
Tcl_Obj *CONST *objv; |
| 4358 |
{ |
| 4359 |
TreeViewStyle *stylePtr; |
| 4360 |
int bool, oldBool; |
| 4361 |
|
| 4362 |
stylePtr = GetStyle(interp, tvPtr, Tcl_GetString(objv[3])); |
| 4363 |
if (stylePtr == NULL) { |
| 4364 |
return TCL_ERROR; |
| 4365 |
} |
| 4366 |
oldBool = ((stylePtr->flags & STYLE_HIGHLIGHT) != 0); |
| 4367 |
if (objc<=4) { |
| 4368 |
Tcl_SetObjResult(interp, Tcl_NewIntObj(oldBool)); |
| 4369 |
return TCL_OK; |
| 4370 |
} |
| 4371 |
if (Tcl_GetBooleanFromObj(interp, objv[4], &bool) != TCL_OK) { |
| 4372 |
return TCL_ERROR; |
| 4373 |
} |
| 4374 |
if (oldBool != bool) { |
| 4375 |
if (bool) { |
| 4376 |
stylePtr->flags |= STYLE_HIGHLIGHT; |
| 4377 |
} else { |
| 4378 |
stylePtr->flags &= ~STYLE_HIGHLIGHT; |
| 4379 |
} |
| 4380 |
Blt_TreeViewEventuallyRedraw(tvPtr); |
| 4381 |
} |
| 4382 |
return TCL_OK; |
| 4383 |
} |
| 4384 |
|
| 4385 |
|
| 4386 |
|
| 4387 |
|
| 4388 |
|
| 4389 |
|
| 4390 |
|
| 4391 |
|
| 4392 |
|
| 4393 |
|
| 4394 |
|
| 4395 |
|
| 4396 |
|
| 4397 |
|
| 4398 |
|
| 4399 |
|
| 4400 |
static int |
| 4401 |
StyleNamesOp(tvPtr, interp, objc, objv) |
| 4402 |
TreeView *tvPtr; |
| 4403 |
|
| 4404 |
Tcl_Interp *interp; |
| 4405 |
int objc; |
| 4406 |
Tcl_Obj *CONST *objv; |
| 4407 |
{ |
| 4408 |
Blt_HashEntry *hPtr; |
| 4409 |
Blt_HashSearch cursor; |
| 4410 |
Tcl_Obj *listObjPtr, *objPtr; |
| 4411 |
TreeViewStyle *stylePtr; |
| 4412 |
|
| 4413 |
listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); |
| 4414 |
for (hPtr = Blt_FirstHashEntry(&tvPtr->styleTable, &cursor); hPtr != NULL; |
| 4415 |
hPtr = Blt_NextHashEntry(&cursor)) { |
| 4416 |
stylePtr = Blt_GetHashValue(hPtr); |
| 4417 |
objPtr = Tcl_NewStringObj(stylePtr->name, -1); |
| 4418 |
Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); |
| 4419 |
} |
| 4420 |
Tcl_SetObjResult(interp, listObjPtr); |
| 4421 |
return TCL_OK; |
| 4422 |
} |
| 4423 |
|
| 4424 |
static int |
| 4425 |
StyleSlavesOp(tvPtr, interp, objc, objv) |
| 4426 |
TreeView *tvPtr; |
| 4427 |
|
| 4428 |
Tcl_Interp *interp; |
| 4429 |
int objc; |
| 4430 |
Tcl_Obj *CONST *objv; |
| 4431 |
{ |
| 4432 |
Blt_HashEntry *hPtr; |
| 4433 |
Blt_HashSearch cursor; |
| 4434 |
char *name, *window = NULL; |
| 4435 |
Tcl_DString dStr; |
| 4436 |
TreeViewColumn *columnPtr = NULL; |
| 4437 |
TreeViewEntry *entryPtr = NULL; |
| 4438 |
TreeViewStyle *stylePtr = NULL; |
| 4439 |
int visible; |
| 4440 |
WindowCell *wcPtr; |
| 4441 |
int sub = 0, chkVis = 0; |
| 4442 |
|
| 4443 |
if (!(objc%2)) { |
| 4444 |
goto argerr; |
| 4445 |
} |
| 4446 |
while (objc>3) { |
| 4447 |
char *string; |
| 4448 |
|
| 4449 |
string = Tcl_GetString(objv[3]); |
| 4450 |
if (string[0] != '-') { |
| 4451 |
argerr: |
| 4452 |
Tcl_AppendResult(interp, "expected -col, -id, -style, -visible, or -info", 0); |
| 4453 |
return TCL_ERROR; |
| 4454 |
} |
| 4455 |
if ((strcmp(string, "-col") == 0)) { |
| 4456 |
if (Blt_TreeViewGetColumn(interp, tvPtr, objv[4], &columnPtr) |
| 4457 |
!= TCL_OK) { |
| 4458 |
return TCL_ERROR; |
| 4459 |
} |
| 4460 |
} else if ((strcmp(string, "-info") == 0)) { |
| 4461 |
|
| 4462 |
window = Tcl_GetString(objv[4]); |
| 4463 |
|
| 4464 |
} else if ((strcmp(string, "-id") == 0)) { |
| 4465 |
if (Blt_TreeViewGetEntry(tvPtr, objv[4], &entryPtr) |
| 4466 |
!= TCL_OK) { |
| 4467 |
return TCL_ERROR; |
| 4468 |
} |
| 4469 |
} else if ((strcmp(string, "-visible") == 0)) { |
| 4470 |
if (Tcl_GetBooleanFromObj(interp, objv[4], &visible) != TCL_OK) { |
| 4471 |
return TCL_ERROR; |
| 4472 |
} |
| 4473 |
chkVis = 1; |
| 4474 |
} else if ((strcmp(string, "-style") == 0)) { |
| 4475 |
stylePtr = GetStyle(interp, tvPtr, Tcl_GetString(objv[4])); |
| 4476 |
if (stylePtr == NULL) { |
| 4477 |
return TCL_ERROR; |
| 4478 |
} |
| 4479 |
} else break; |
| 4480 |
|
| 4481 |
objc -= 2; |
| 4482 |
objv += 2; |
| 4483 |
sub++; |
| 4484 |
} |
| 4485 |
if (objc != 3) { |
| 4486 |
goto argerr; |
| 4487 |
} |
| 4488 |
|
| 4489 |
|
| 4490 |
Tcl_DStringInit(&dStr); |
| 4491 |
for (hPtr = Blt_FirstHashEntry(&tvPtr->winTable, &cursor); hPtr != NULL; |
| 4492 |
hPtr = Blt_NextHashEntry(&cursor)) { |
| 4493 |
name = (char*)Blt_GetHashKey(&tvPtr->winTable, hPtr); |
| 4494 |
if (sub) { |
| 4495 |
wcPtr = (WindowCell*)Blt_GetHashValue(hPtr); |
| 4496 |
if (wcPtr == NULL) continue; |
| 4497 |
if (columnPtr && columnPtr != wcPtr->columnPtr) continue; |
| 4498 |
if (entryPtr && entryPtr != wcPtr->entryPtr) continue; |
| 4499 |
if (stylePtr && stylePtr != (TreeViewStyle*)wcPtr->stylePtr) continue; |
| 4500 |
if (chkVis) { |
| 4501 |
if (wcPtr->flags&TV_WINDOW_DRAW) { |
| 4502 |
if (!visible) continue; |
| 4503 |
} else { |
| 4504 |
if (visible) continue; |
| 4505 |
} |
| 4506 |
} |
| 4507 |
if (window) { |
| 4508 |
if (wcPtr->tkwin == NULL) continue; |
| 4509 |
if (strcmp(window,Tk_PathName(wcPtr->tkwin))) continue; |
| 4510 |
Tcl_DStringAppendElement(&dStr, "-style"); |
| 4511 |
Tcl_DStringAppendElement(&dStr, wcPtr->stylePtr->name); |
| 4512 |
Tcl_DStringAppendElement(&dStr, "-col"); |
| 4513 |
Tcl_DStringAppendElement(&dStr, wcPtr->columnPtr->key); |
| 4514 |
Tcl_DStringAppendElement(&dStr, "-id"); |
| 4515 |
Tcl_DStringAppendElement(&dStr, Blt_Itoa(Blt_TreeNodeId(wcPtr->entryPtr->node))); |
| 4516 |
Tcl_DStringAppendElement(&dStr, "-visible"); |
| 4517 |
Tcl_DStringAppendElement(&dStr, (wcPtr->flags&TV_WINDOW_DRAW)?"True":"False"); |
| 4518 |
Tcl_DStringResult(interp, &dStr); |
| 4519 |
return TCL_OK; |
| 4520 |
} |
| 4521 |
} |
| 4522 |
if (name != NULL) { |
| 4523 |
Tcl_DStringAppendElement(&dStr, name); |
| 4524 |
} |
| 4525 |
} |
| 4526 |
Tcl_DStringResult(interp, &dStr); |
| 4527 |
return TCL_OK; |
| 4528 |
} |
| 4529 |
|
| 4530 |
|
| 4531 |
|
| 4532 |
|
| 4533 |
|
| 4534 |
|
| 4535 |
|
| 4536 |
|
| 4537 |
|
| 4538 |
|
| 4539 |
|
| 4540 |
|
| 4541 |
|
| 4542 |
|
| 4543 |
|
| 4544 |
|
| 4545 |
static int |
| 4546 |
StyleSetOp(tvPtr, interp, objc, objv) |
| 4547 |
TreeView *tvPtr; |
| 4548 |
|
| 4549 |
Tcl_Interp *interp; |
| 4550 |
int objc; |
| 4551 |
Tcl_Obj *CONST *objv; |
| 4552 |
{ |
| 4553 |
TreeViewColumn *columnPtr; |
| 4554 |
TreeViewEntry *entryPtr; |
| 4555 |
TreeViewStyle *stylePtr = NULL, *oldStylePtr; |
| 4556 |
TreeViewTagInfo info = {0}; |
| 4557 |
char *string; |
| 4558 |
int i, count; |
| 4559 |
|
| 4560 |
count = 0; |
| 4561 |
if (Blt_TreeViewGetColumn(interp, tvPtr, objv[4], &columnPtr) != TCL_OK) { |
| 4562 |
return TCL_ERROR; |
| 4563 |
} |
| 4564 |
string = Tcl_GetString(objv[3]); |
| 4565 |
if (string[0]) { |
| 4566 |
if (Blt_TreeViewGetStyleMake(interp, tvPtr, string, &stylePtr, columnPtr, |
| 4567 |
NULL, NULL) != TCL_OK) { |
| 4568 |
return TCL_ERROR; |
| 4569 |
} |
| 4570 |
stylePtr->refCount--; |
| 4571 |
} |
| 4572 |
if (stylePtr) { |
| 4573 |
stylePtr->flags |= STYLE_LAYOUT; |
| 4574 |
} |
| 4575 |
for (i = 5; i < objc; i++) { |
| 4576 |
if (Blt_TreeViewFindTaggedEntries(tvPtr, objv[i], &info) != TCL_OK) { |
| 4577 |
return TCL_ERROR; |
| 4578 |
} |
| 4579 |
for (entryPtr = Blt_TreeViewFirstTaggedEntry(&info); entryPtr != NULL; |
| 4580 |
entryPtr = Blt_TreeViewNextTaggedEntry(&info)) { |
| 4581 |
register TreeViewValue *valuePtr; |
| 4582 |
|
| 4583 |
if (columnPtr == &tvPtr->treeColumn) { |
| 4584 |
if (stylePtr == entryPtr->realStylePtr) continue; |
| 4585 |
if (stylePtr) stylePtr->refCount++; |
| 4586 |
oldStylePtr = entryPtr->realStylePtr; |
| 4587 |
entryPtr->realStylePtr = stylePtr; |
| 4588 |
if (stylePtr) stylePtr->refCount++; |
| 4589 |
if (oldStylePtr != NULL) { |
| 4590 |
Blt_TreeViewFreeStyle(tvPtr, oldStylePtr); |
| 4591 |
} |
| 4592 |
count++; |
| 4593 |
continue; |
| 4594 |
} |
| 4595 |
|
| 4596 |
for (valuePtr = entryPtr->values; valuePtr != NULL; |
| 4597 |
valuePtr = valuePtr->nextPtr) { |
| 4598 |
if (valuePtr->columnPtr == columnPtr) { |
| 4599 |
if (stylePtr == valuePtr->stylePtr) break; |
| 4600 |
if (stylePtr) stylePtr->refCount++; |
| 4601 |
oldStylePtr = valuePtr->stylePtr; |
| 4602 |
valuePtr->stylePtr = stylePtr; |
| 4603 |
if (stylePtr) stylePtr->refCount++; |
| 4604 |
if (oldStylePtr != NULL) { |
| 4605 |
Blt_TreeViewFreeStyle(tvPtr, oldStylePtr); |
| 4606 |
} |
| 4607 |
count++; |
| 4608 |
break; |
| 4609 |
} |
| 4610 |
} |
| 4611 |
} |
| 4612 |
Blt_TreeViewDoneTaggedEntries(&info); |
| 4613 |
} |
| 4614 |
tvPtr->flags |= (TV_DIRTY | TV_LAYOUT | TV_SCROLL | TV_UPDATE); |
| 4615 |
Blt_TreeViewMakeStyleDirty(tvPtr); |
| 4616 |
Blt_TreeViewEventuallyRedraw(tvPtr); |
| 4617 |
Tcl_SetObjResult(interp, Tcl_NewIntObj(count)); |
| 4618 |
return TCL_OK; |
| 4619 |
} |
| 4620 |
|
| 4621 |
|
| 4622 |
|
| 4623 |
|
| 4624 |
|
| 4625 |
|
| 4626 |
|
| 4627 |
|
| 4628 |
|
| 4629 |
|
| 4630 |
|
| 4631 |
|
| 4632 |
|
| 4633 |
|
| 4634 |
|
| 4635 |
|
| 4636 |
|
| 4637 |
static int |
| 4638 |
StyleFindOp(tvPtr, interp, objc, objv) |
| 4639 |
TreeView *tvPtr; |
| 4640 |
|
| 4641 |
Tcl_Interp *interp; |
| 4642 |
int objc; |
| 4643 |
Tcl_Obj *CONST *objv; |
| 4644 |
{ |
| 4645 |
TreeViewEntry *entryPtr; |
| 4646 |
TreeViewStyle *stylePtr; |
| 4647 |
TreeViewTagInfo info = {0}; |
| 4648 |
TreeViewColumn *columnPtr = NULL; |
| 4649 |
Tcl_Obj *listObjPtr, *objPtr; |
| 4650 |
|
| 4651 |
if (tvPtr->styleCmd == NULL || strcmp(tvPtr->styleCmd, "%W style create textbox %V")) { |
| 4652 |
stylePtr = GetStyle(interp, tvPtr, Tcl_GetString(objv[3])); |
| 4653 |
if (stylePtr == NULL) { |
| 4654 |
return TCL_ERROR; |
| 4655 |
} |
| 4656 |
} else { |
| 4657 |
stylePtr = GetStyle(NULL, tvPtr, Tcl_GetString(objv[3])); |
| 4658 |
if (stylePtr == NULL) { |
| 4659 |
return TCL_OK; |
| 4660 |
} |
| 4661 |
} |
| 4662 |
if (objc>5) { |
| 4663 |
if (Blt_TreeViewGetColumn(interp, tvPtr, objv[5], &columnPtr) != TCL_OK) { |
| 4664 |
return TCL_ERROR; |
| 4665 |
} |
| 4666 |
} |
| 4667 |
if (objc>4) { |
| 4668 |
if (Blt_TreeViewFindTaggedEntries(tvPtr, objv[4], &info) != TCL_OK) { |
| 4669 |
return TCL_ERROR; |
| 4670 |
} |
| 4671 |
} else { |
| 4672 |
objPtr = Tcl_NewStringObj("all", -1); |
| 4673 |
if (Blt_TreeViewFindTaggedEntries(tvPtr, objPtr, &info) != TCL_OK) { |
| 4674 |
Tcl_DecrRefCount(objPtr); |
| 4675 |
return TCL_ERROR; |
| 4676 |
} |
| 4677 |
Tcl_DecrRefCount(objPtr); |
| 4678 |
} |
| 4679 |
|
| 4680 |
listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); |
| 4681 |
for (entryPtr = Blt_TreeViewFirstTaggedEntry(&info); entryPtr != NULL; |
| 4682 |
entryPtr = Blt_TreeViewNextTaggedEntry(&info)) { |
| 4683 |
register TreeViewValue *valuePtr; |
| 4684 |
|
| 4685 |
if (columnPtr == NULL || columnPtr == &tvPtr->treeColumn) { |
| 4686 |
if (entryPtr->realStylePtr == stylePtr) { |
| 4687 |
objPtr = Tcl_NewIntObj(Blt_TreeNodeId(entryPtr->node)); |
| 4688 |
Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); |
| 4689 |
continue; |
| 4690 |
} |
| 4691 |
} |
| 4692 |
|
| 4693 |
for (valuePtr = entryPtr->values; valuePtr != NULL; |
| 4694 |
valuePtr = valuePtr->nextPtr) { |
| 4695 |
if (columnPtr && valuePtr->columnPtr != columnPtr) continue; |
| 4696 |
if (valuePtr->stylePtr != stylePtr) continue; |
| 4697 |
objPtr = Tcl_NewIntObj(Blt_TreeNodeId(entryPtr->node)); |
| 4698 |
Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); |
| 4699 |
break; |
| 4700 |
} |
| 4701 |
} |
| 4702 |
Blt_TreeViewDoneTaggedEntries(&info); |
| 4703 |
Tcl_SetObjResult(interp, listObjPtr); |
| 4704 |
return TCL_OK; |
| 4705 |
} |
| 4706 |
|
| 4707 |
|
| 4708 |
|
| 4709 |
|
| 4710 |
|
| 4711 |
|
| 4712 |
|
| 4713 |
|
| 4714 |
|
| 4715 |
|
| 4716 |
|
| 4717 |
static int |
| 4718 |
StyleTextBoxOp(tvPtr, interp, objc, objv) |
| 4719 |
TreeView *tvPtr; |
| 4720 |
Tcl_Interp *interp; |
| 4721 |
int objc; |
| 4722 |
Tcl_Obj *CONST *objv; |
| 4723 |
{ |
| 4724 |
TreeViewStyle *stylePtr; |
| 4725 |
|
| 4726 |
stylePtr = CreateStyle(interp, tvPtr, STYLE_TEXTBOX, |
| 4727 |
Tcl_GetString(objv[3]), objc - 4, objv + 4, 1); |
| 4728 |
if (stylePtr == NULL) { |
| 4729 |
return TCL_ERROR; |
| 4730 |
} |
| 4731 |
stylePtr->refCount = 0; |
| 4732 |
stylePtr->flags |= STYLE_USER; |
| 4733 |
Blt_TreeViewUpdateStyleGCs(tvPtr, stylePtr); |
| 4734 |
Tcl_SetObjResult(interp, objv[3]); |
| 4735 |
return TCL_OK; |
| 4736 |
} |
| 4737 |
|
| 4738 |
|
| 4739 |
|
| 4740 |
|
| 4741 |
|
| 4742 |
|
| 4743 |
|
| 4744 |
|
| 4745 |
|
| 4746 |
|
| 4747 |
|
| 4748 |
static int |
| 4749 |
StyleWindowBoxOp(tvPtr, interp, objc, objv) |
| 4750 |
TreeView *tvPtr; |
| 4751 |
Tcl_Interp *interp; |
| 4752 |
int objc; |
| 4753 |
Tcl_Obj *CONST *objv; |
| 4754 |
{ |
| 4755 |
TreeViewStyle *stylePtr; |
| 4756 |
|
| 4757 |
stylePtr = CreateStyle(interp, tvPtr, STYLE_WINDOWBOX, |
| 4758 |
Tcl_GetString(objv[3]), objc - 4, objv + 4, 1); |
| 4759 |
if (stylePtr == NULL) { |
| 4760 |
return TCL_ERROR; |
| 4761 |
} |
| 4762 |
stylePtr->refCount = 0; |
| 4763 |
stylePtr->flags |= STYLE_USER; |
| 4764 |
Blt_TreeViewUpdateStyleGCs(tvPtr, stylePtr); |
| 4765 |
Tcl_SetObjResult(interp, objv[3]); |
| 4766 |
return TCL_OK; |
| 4767 |
} |
| 4768 |
|
| 4769 |
|
| 4770 |
|
| 4771 |
|
| 4772 |
|
| 4773 |
|
| 4774 |
|
| 4775 |
|
| 4776 |
|
| 4777 |
|
| 4778 |
static int |
| 4779 |
StyleBarBoxOp(tvPtr, interp, objc, objv) |
| 4780 |
TreeView *tvPtr; |
| 4781 |
Tcl_Interp *interp; |
| 4782 |
int objc; |
| 4783 |
Tcl_Obj *CONST *objv; |
| 4784 |
{ |
| 4785 |
TreeViewStyle *stylePtr; |
| 4786 |
|
| 4787 |
stylePtr = CreateStyle(interp, tvPtr, STYLE_BARBOX, |
| 4788 |
Tcl_GetString(objv[3]), objc - 4, objv + 4, 1); |
| 4789 |
if (stylePtr == NULL) { |
| 4790 |
return TCL_ERROR; |
| 4791 |
} |
| 4792 |
stylePtr->refCount = 0; |
| 4793 |
stylePtr->flags |= STYLE_USER; |
| 4794 |
Blt_TreeViewUpdateStyleGCs(tvPtr, stylePtr); |
| 4795 |
Tcl_SetObjResult(interp, objv[3]); |
| 4796 |
return TCL_OK; |
| 4797 |
} |
| 4798 |
|
| 4799 |
|
| 4800 |
|
| 4801 |
|
| 4802 |
|
| 4803 |
|
| 4804 |
|
| 4805 |
|
| 4806 |
|
| 4807 |
|
| 4808 |
|
| 4809 |
|
| 4810 |
|
| 4811 |
|
| 4812 |
|
| 4813 |
|
| 4814 |
|
| 4815 |
static int |
| 4816 |
StyleGetOp(tvPtr, interp, objc, objv) |
| 4817 |
TreeView *tvPtr; |
| 4818 |
Tcl_Interp *interp; |
| 4819 |
int objc; |
| 4820 |
Tcl_Obj *CONST *objv; |
| 4821 |
{ |
| 4822 |
TreeViewColumn *columnPtr; |
| 4823 |
TreeViewEntry *entryPtr; |
| 4824 |
TreeViewTagInfo info = {0}; |
| 4825 |
Tcl_Obj *listObjPtr, *objPtr; |
| 4826 |
|
| 4827 |
if (Blt_TreeViewGetColumn(interp, tvPtr, objv[3], &columnPtr) != TCL_OK) { |
| 4828 |
return TCL_ERROR; |
| 4829 |
} |
| 4830 |
|
| 4831 |
if (Blt_TreeViewFindTaggedEntries(tvPtr, objv[4], &info) != TCL_OK) { |
| 4832 |
return TCL_ERROR; |
| 4833 |
} |
| 4834 |
listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); |
| 4835 |
for (entryPtr = Blt_TreeViewFirstTaggedEntry(&info); entryPtr != NULL; |
| 4836 |
entryPtr = Blt_TreeViewNextTaggedEntry(&info)) { |
| 4837 |
register TreeViewValue *valuePtr; |
| 4838 |
|
| 4839 |
if (columnPtr == &tvPtr->treeColumn) { |
| 4840 |
if (entryPtr->realStylePtr != NULL) { |
| 4841 |
objPtr = Tcl_NewStringObj(entryPtr->realStylePtr->name, -1); |
| 4842 |
} else { |
| 4843 |
objPtr = Tcl_NewStringObj("",0); |
| 4844 |
} |
| 4845 |
Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); |
| 4846 |
continue; |
| 4847 |
} |
| 4848 |
|
| 4849 |
for (valuePtr = entryPtr->values; valuePtr != NULL; |
| 4850 |
valuePtr = valuePtr->nextPtr) { |
| 4851 |
if (valuePtr->columnPtr == columnPtr) { |
| 4852 |
if (valuePtr->stylePtr != NULL) { |
| 4853 |
objPtr = Tcl_NewStringObj(valuePtr->stylePtr->name, -1); |
| 4854 |
} else { |
| 4855 |
objPtr = Tcl_NewStringObj("",0); |
| 4856 |
} |
| 4857 |
Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); |
| 4858 |
break; |
| 4859 |
} |
| 4860 |
} |
| 4861 |
} |
| 4862 |
Blt_TreeViewDoneTaggedEntries(&info); |
| 4863 |
Tcl_SetObjResult(interp, listObjPtr); |
| 4864 |
return TCL_OK; |
| 4865 |
} |
| 4866 |
|
| 4867 |
#if 0 |
| 4868 |
|
| 4869 |
|
| 4870 |
|
| 4871 |
|
| 4872 |
|
| 4873 |
|
| 4874 |
|
| 4875 |
|
| 4876 |
|
| 4877 |
|
| 4878 |
|
| 4879 |
|
| 4880 |
|
| 4881 |
|
| 4882 |
|
| 4883 |
static int |
| 4884 |
StylePriorityOp(tvPtr, interp, objc, objv) |
| 4885 |
TreeView *tvPtr; |
| 4886 |
Tcl_Interp *interp; |
| 4887 |
int objc; |
| 4888 |
Tcl_Obj *CONST *objv; |
| 4889 |
{ |
| 4890 |
TreeViewColumn *columnPtr; |
| 4891 |
TreeViewEntry *entryPtr; |
| 4892 |
TreeViewValue *valuePtr; |
| 4893 |
TreeViewStyle *s[4]; |
| 4894 |
int i, h = -1, p = -1; |
| 4895 |
|
| 4896 |
s[3] = tvPtr->stylePtr; |
| 4897 |
|
| 4898 |
if (Blt_TreeViewGetColumn(interp, tvPtr, objv[3], &columnPtr) != TCL_OK) { |
| 4899 |
return TCL_ERROR; |
| 4900 |
} |
| 4901 |
|
| 4902 |
if (Blt_TreeViewGetEntry(tvPtr, objv[4], &entryPtr) != TCL_OK) { |
| 4903 |
return TCL_ERROR; |
| 4904 |
} |
| 4905 |
|
| 4906 |
if (columnPtr == &tvPtr->treeColumn) { |
| 4907 |
s[0] = entryPtr->realStylePtr; |
| 4908 |
} else { |
| 4909 |
s[0] = NULL; |
| 4910 |
for (valuePtr = entryPtr->values; valuePtr != NULL; |
| 4911 |
valuePtr = valuePtr->nextPtr) { |
| 4912 |
if (valuePtr->columnPtr == columnPtr) { |
| 4913 |
s[0] = valuePtr->stylePtr; |
| 4914 |
break; |
| 4915 |
} |
| 4916 |
} |
| 4917 |
} |
| 4918 |
s[1] = entryPtr->stylePtr; |
| 4919 |
s[2] = columnPtr->stylePtr; |
| 4920 |
for (i=0; i<4; i++) { |
| 4921 |
if (s[i]==0) continue; |
| 4922 |
if (h<0) { h = i; } |
| 4923 |
if (s[i]->priority > p) { |
| 4924 |
h = i; |
| 4925 |
p = s[i]->priority; |
| 4926 |
} |
| 4927 |
} |
| 4928 |
Tcl_SetObjResult(interp, Tcl_NewStringObj(s[h]->name, -1)); |
| 4929 |
return TCL_OK; |
| 4930 |
} |
| 4931 |
#endif |
| 4932 |
|
| 4933 |
|
| 4934 |
|
| 4935 |
|
| 4936 |
|
| 4937 |
|
| 4938 |
|
| 4939 |
|
| 4940 |
|
| 4941 |
|
| 4942 |
static int |
| 4943 |
StyleCreateOp(tvPtr, interp, objc, objv) |
| 4944 |
TreeView *tvPtr; |
| 4945 |
Tcl_Interp *interp; |
| 4946 |
int objc; |
| 4947 |
Tcl_Obj *CONST *objv; |
| 4948 |
{ |
| 4949 |
char *string; |
| 4950 |
|
| 4951 |
string = Tcl_GetString(objv[3]); |
| 4952 |
if (!strcmp(string, "combobox")) { |
| 4953 |
return StyleComboBoxOp(tvPtr, interp, objc-1, objv+1); |
| 4954 |
} |
| 4955 |
if (!strcmp(string, "textbox")) { |
| 4956 |
return StyleTextBoxOp(tvPtr, interp, objc-1, objv+1); |
| 4957 |
} |
| 4958 |
if (!strcmp(string, "barbox")) { |
| 4959 |
return StyleBarBoxOp(tvPtr, interp, objc-1, objv+1); |
| 4960 |
} |
| 4961 |
if (!strcmp(string, "windowbox")) { |
| 4962 |
return StyleWindowBoxOp(tvPtr, interp, objc-1, objv+1); |
| 4963 |
} |
| 4964 |
if (!strcmp(string, "checkbox")) { |
| 4965 |
return StyleCheckBoxOp(tvPtr, interp, objc-1, objv+1); |
| 4966 |
} |
| 4967 |
Tcl_AppendResult(interp, "bad style type \"", string, "\", should be one of: textbox, barbox, checkbox, combobox, or windowbox", 0); |
| 4968 |
return TCL_ERROR; |
| 4969 |
} |
| 4970 |
|
| 4971 |
|
| 4972 |
|
| 4973 |
|
| 4974 |
|
| 4975 |
|
| 4976 |
|
| 4977 |
|
| 4978 |
|
| 4979 |
|
| 4980 |
|
| 4981 |
|
| 4982 |
|
| 4983 |
|
| 4984 |
|
| 4985 |
|
| 4986 |
|
| 4987 |
|
| 4988 |
|
| 4989 |
|
| 4990 |
|
| 4991 |
|
| 4992 |
static Blt_OpSpec styleOps[] = { |
| 4993 |
{"activate", 1, (Blt_Op)StyleActivateOp, 3, 5,"?entry column?",}, |
| 4994 |
|
| 4995 |
{"cget", 2, (Blt_Op)StyleCgetOp, 5, 5, "styleName option",}, |
| 4996 |
|
| 4997 |
|
| 4998 |
{"configure", 3, (Blt_Op)StyleConfigureOp, 4, 0, "styleName options...",}, |
| 4999 |
{"create", 2, (Blt_Op)StyleCreateOp, 5, 0, "type styleName options...",}, |
| 5000 |
{"find", 2, (Blt_Op)StyleFindOp, 4, 6, "styleName ?tagOrId? ?column?",}, |
| 5001 |
{"forget", 2, (Blt_Op)StyleForgetOp, 3, 0, "styleName...",}, |
| 5002 |
{"get", 1, (Blt_Op)StyleGetOp, 5, 5, "column tagOrId",}, |
| 5003 |
{"highlight", 1, (Blt_Op)StyleHighlightOp, 4, 5, "styleName ?boolean?",}, |
| 5004 |
{"names", 1, (Blt_Op)StyleNamesOp, 3, 3, "",}, |
| 5005 |
|
| 5006 |
{"set", 2, (Blt_Op)StyleSetOp, 6, 0, "styleName column tagOrId ...",}, |
| 5007 |
{"slaves", 2, (Blt_Op)StyleSlavesOp, 3, 0, "?-col col? ?-entry id? ?-style name? ?-visible bool? ?-info win?",}, |
| 5008 |
|
| 5009 |
{"type", 2, (Blt_Op)StyleTypeOp, 3, 5, "?styleName? ?newType?",}, |
| 5010 |
{"use", 2, (Blt_Op)StyleUseOp, 4, 4, "styleName",}, |
| 5011 |
|
| 5012 |
}; |
| 5013 |
|
| 5014 |
static int nStyleOps = sizeof(styleOps) / sizeof(Blt_OpSpec); |
| 5015 |
|
| 5016 |
int |
| 5017 |
Blt_TreeViewStyleOp(tvPtr, interp, objc, objv) |
| 5018 |
TreeView *tvPtr; |
| 5019 |
Tcl_Interp *interp; |
| 5020 |
int objc; |
| 5021 |
Tcl_Obj *CONST *objv; |
| 5022 |
{ |
| 5023 |
Blt_Op proc; |
| 5024 |
int result; |
| 5025 |
|
| 5026 |
proc = Blt_GetOpFromObj(interp, nStyleOps, styleOps, BLT_OP_ARG2, objc, |
| 5027 |
objv, 0); |
| 5028 |
if (proc == NULL) { |
| 5029 |
return TCL_ERROR; |
| 5030 |
} |
| 5031 |
result = (*proc)(tvPtr, interp, objc, objv); |
| 5032 |
return result; |
| 5033 |
} |
| 5034 |
#endif |