| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include "tkInt.h" |
| 17 |
#include "tixPort.h" |
| 18 |
#include "tixInt.h" |
| 19 |
#include "tixDef.h" |
| 20 |
#include "tixGrid.h" |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
static Tk_ConfigSpec configSpecs[] = { |
| 26 |
{TK_CONFIG_COLOR, "-background", "background", "Background", |
| 27 |
DEF_GRID_BG_COLOR, Tk_Offset(WidgetRecord, normalBg), |
| 28 |
TK_CONFIG_COLOR_ONLY}, |
| 29 |
|
| 30 |
{TK_CONFIG_COLOR, "-background", "background", "Background", |
| 31 |
DEF_GRID_BG_MONO, Tk_Offset(WidgetRecord, normalBg), |
| 32 |
TK_CONFIG_MONO_ONLY}, |
| 33 |
|
| 34 |
{TK_CONFIG_SYNONYM, "-bd", "borderWidth", (char *) NULL, |
| 35 |
(char *) NULL, 0, 0}, |
| 36 |
|
| 37 |
{TK_CONFIG_SYNONYM, "-bg", "background", (char *) NULL, |
| 38 |
(char *) NULL, 0, 0}, |
| 39 |
|
| 40 |
{TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", |
| 41 |
DEF_GRID_BORDER_WIDTH, Tk_Offset(WidgetRecord, borderWidth), 0}, |
| 42 |
|
| 43 |
{TK_CONFIG_CALLBACK, "-browsecmd", "browseCmd", "BrowseCmd", |
| 44 |
"", Tk_Offset(WidgetRecord, browseCmd), |
| 45 |
TK_CONFIG_NULL_OK}, |
| 46 |
|
| 47 |
{TK_CONFIG_CALLBACK, "-command", "command", "Command", |
| 48 |
"", Tk_Offset(WidgetRecord, command), |
| 49 |
TK_CONFIG_NULL_OK}, |
| 50 |
|
| 51 |
{TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor", |
| 52 |
DEF_GRID_CURSOR, Tk_Offset(WidgetRecord, cursor), |
| 53 |
TK_CONFIG_NULL_OK}, |
| 54 |
|
| 55 |
{TK_CONFIG_CALLBACK, "-editdonecmd", "editDoneCmd", "EditDoneCmd", |
| 56 |
DEF_GRID_EDITDONE_COMMAND, Tk_Offset(WidgetRecord, editDoneCmd), |
| 57 |
TK_CONFIG_NULL_OK}, |
| 58 |
|
| 59 |
{TK_CONFIG_CALLBACK, "-editnotifycmd", "editNotifyCmd", "EditNotifyCmd", |
| 60 |
DEF_GRID_EDITNOTIFY_COMMAND, Tk_Offset(WidgetRecord, editNotifyCmd), |
| 61 |
TK_CONFIG_NULL_OK}, |
| 62 |
|
| 63 |
{TK_CONFIG_SYNONYM, "-fg", "foreground", (char *) NULL, |
| 64 |
(char *) NULL, 0, 0}, |
| 65 |
|
| 66 |
{TK_CONFIG_BOOLEAN, "-floatingcols", "floatingCols", "FloatingCols", |
| 67 |
DEF_GRID_FLOATING_COLS, Tk_Offset(WidgetRecord, floatRange[1]), 0}, |
| 68 |
|
| 69 |
{TK_CONFIG_BOOLEAN, "-floatingrows", "floatingRows", "FloatingRows", |
| 70 |
DEF_GRID_FLOATING_ROWS, Tk_Offset(WidgetRecord, floatRange[0]), 0}, |
| 71 |
|
| 72 |
{TK_CONFIG_FONT, "-font", "font", "Font", |
| 73 |
DEF_GRID_FONT, Tk_Offset(WidgetRecord, font), 0}, |
| 74 |
|
| 75 |
{TK_CONFIG_COLOR, "-foreground", "foreground", "Foreground", |
| 76 |
DEF_GRID_FG_COLOR, Tk_Offset(WidgetRecord, normalFg), |
| 77 |
TK_CONFIG_COLOR_ONLY}, |
| 78 |
|
| 79 |
{TK_CONFIG_COLOR, "-foreground", "foreground", "Foreground", |
| 80 |
DEF_GRID_FG_MONO, Tk_Offset(WidgetRecord, normalFg), |
| 81 |
TK_CONFIG_MONO_ONLY}, |
| 82 |
|
| 83 |
{TK_CONFIG_CALLBACK, "-formatcmd", "formatCmd", "FormatCmd", |
| 84 |
DEF_GRID_FORMAT_COMMAND, Tk_Offset(WidgetRecord, formatCmd), |
| 85 |
TK_CONFIG_NULL_OK}, |
| 86 |
|
| 87 |
{TK_CONFIG_PIXELS, "-height", "height", "Height", |
| 88 |
DEF_GRID_HEIGHT, Tk_Offset(WidgetRecord, reqSize[1]), 0}, |
| 89 |
|
| 90 |
{TK_CONFIG_BORDER, "-highlightbackground", "highlightBackground", |
| 91 |
"HighlightBackground", |
| 92 |
DEF_GRID_BG_COLOR, Tk_Offset(WidgetRecord, border), |
| 93 |
TK_CONFIG_COLOR_ONLY}, |
| 94 |
|
| 95 |
{TK_CONFIG_BORDER, "-highlightbackground", "highlightBackground", |
| 96 |
"HighlightBackground", |
| 97 |
DEF_GRID_BG_MONO, Tk_Offset(WidgetRecord, border), |
| 98 |
TK_CONFIG_MONO_ONLY}, |
| 99 |
|
| 100 |
{TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", |
| 101 |
DEF_GRID_HIGHLIGHT_COLOR, Tk_Offset(WidgetRecord, highlightColorPtr), |
| 102 |
TK_CONFIG_COLOR_ONLY}, |
| 103 |
|
| 104 |
{TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", |
| 105 |
DEF_GRID_HIGHLIGHT_MONO, Tk_Offset(WidgetRecord, highlightColorPtr), |
| 106 |
TK_CONFIG_MONO_ONLY}, |
| 107 |
|
| 108 |
{TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness", |
| 109 |
"HighlightThickness", |
| 110 |
DEF_GRID_HIGHLIGHT_WIDTH, Tk_Offset(WidgetRecord, highlightWidth), 0}, |
| 111 |
|
| 112 |
{TK_CONFIG_INT, "-leftmargin", "leftMargin", "LeftMargin", |
| 113 |
DEF_GRID_LEFT_MARGIN, Tk_Offset(WidgetRecord, hdrSize[0]), 0}, |
| 114 |
|
| 115 |
{TK_CONFIG_CUSTOM, "-itemtype", "itemType", "ItemType", |
| 116 |
DEF_GRID_ITEM_TYPE, Tk_Offset(WidgetRecord, diTypePtr), |
| 117 |
0, &tixConfigItemType}, |
| 118 |
|
| 119 |
{TK_CONFIG_PIXELS, "-padx", "padX", "Pad", |
| 120 |
DEF_GRID_PADX, Tk_Offset(WidgetRecord, padX), 0}, |
| 121 |
|
| 122 |
{TK_CONFIG_PIXELS, "-pady", "padY", "Pad", |
| 123 |
DEF_GRID_PADY, Tk_Offset(WidgetRecord, padY), 0}, |
| 124 |
|
| 125 |
{TK_CONFIG_RELIEF, "-relief", "relief", "Relief", |
| 126 |
DEF_GRID_RELIEF, Tk_Offset(WidgetRecord, relief), 0}, |
| 127 |
|
| 128 |
{TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground", |
| 129 |
DEF_GRID_SELECT_BG_COLOR, Tk_Offset(WidgetRecord, selectBorder), |
| 130 |
TK_CONFIG_COLOR_ONLY}, |
| 131 |
|
| 132 |
{TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground", |
| 133 |
DEF_GRID_SELECT_BG_MONO, Tk_Offset(WidgetRecord, selectBorder), |
| 134 |
TK_CONFIG_MONO_ONLY}, |
| 135 |
|
| 136 |
{TK_CONFIG_PIXELS, "-selectborderwidth", "selectBorderWidth","BorderWidth", |
| 137 |
DEF_GRID_SELECT_BORDERWIDTH,Tk_Offset(WidgetRecord, selBorderWidth),0}, |
| 138 |
|
| 139 |
{TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background", |
| 140 |
DEF_GRID_SELECT_FG_COLOR, Tk_Offset(WidgetRecord, selectFg), |
| 141 |
TK_CONFIG_COLOR_ONLY}, |
| 142 |
|
| 143 |
{TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background", |
| 144 |
DEF_GRID_SELECT_FG_MONO, Tk_Offset(WidgetRecord, selectFg), |
| 145 |
TK_CONFIG_MONO_ONLY}, |
| 146 |
|
| 147 |
{TK_CONFIG_UID, "-selectmode", "selectMode", "SelectMode", |
| 148 |
DEF_GRID_SELECT_MODE, Tk_Offset(WidgetRecord, selectMode), 0}, |
| 149 |
|
| 150 |
{TK_CONFIG_UID, "-selectunit", "selectUnit", "SelectUnit", |
| 151 |
DEF_GRID_SELECT_UNIT, Tk_Offset(WidgetRecord, selectUnit), 0}, |
| 152 |
|
| 153 |
{TK_CONFIG_CALLBACK, "-sizecmd", "sizeCmd", "SizeCmd", |
| 154 |
DEF_GRID_SIZE_COMMAND, Tk_Offset(WidgetRecord, sizeCmd), |
| 155 |
TK_CONFIG_NULL_OK}, |
| 156 |
|
| 157 |
{TK_CONFIG_UID, "-state", (char*)NULL, (char*)NULL, |
| 158 |
DEF_GRID_STATE, Tk_Offset(WidgetRecord, state), 0}, |
| 159 |
|
| 160 |
{TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus", |
| 161 |
DEF_GRID_TAKE_FOCUS, Tk_Offset(WidgetRecord, takeFocus), |
| 162 |
TK_CONFIG_NULL_OK}, |
| 163 |
|
| 164 |
{TK_CONFIG_INT, "-topmargin", "topMargin", "TopMargin", |
| 165 |
DEF_GRID_TOP_MARGIN, Tk_Offset(WidgetRecord, hdrSize[1]), 0}, |
| 166 |
|
| 167 |
{TK_CONFIG_PIXELS, "-width", "width", "Width", |
| 168 |
DEF_GRID_WIDTH, Tk_Offset(WidgetRecord, reqSize[0]), 0}, |
| 169 |
|
| 170 |
{TK_CONFIG_CALLBACK, "-xscrollcommand", "xScrollCommand", "ScrollCommand", |
| 171 |
DEF_GRID_X_SCROLL_COMMAND, |
| 172 |
Tk_Offset(WidgetRecord, scrollInfo[0].command), |
| 173 |
TK_CONFIG_NULL_OK}, |
| 174 |
|
| 175 |
{TK_CONFIG_CALLBACK, "-yscrollcommand", "yScrollCommand", "ScrollCommand", |
| 176 |
DEF_GRID_Y_SCROLL_COMMAND, |
| 177 |
Tk_Offset(WidgetRecord, scrollInfo[1].command), |
| 178 |
TK_CONFIG_NULL_OK}, |
| 179 |
|
| 180 |
{TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL, |
| 181 |
(char *) NULL, 0, 0} |
| 182 |
}; |
| 183 |
|
| 184 |
static Tk_ConfigSpec entryConfigSpecs[] = { |
| 185 |
{TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL, |
| 186 |
(char *) NULL, 0, 0} |
| 187 |
}; |
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
static void WidgetCmdDeletedProc _ANSI_ARGS_(( |
| 199 |
ClientData clientData)); |
| 200 |
static int WidgetConfigure _ANSI_ARGS_((Tcl_Interp *interp, |
| 201 |
WidgetPtr wPtr, int argc, char **argv, |
| 202 |
int flags)); |
| 203 |
static void WidgetDestroy _ANSI_ARGS_((char *clientData)); |
| 204 |
static void WidgetEventProc _ANSI_ARGS_((ClientData clientData, |
| 205 |
XEvent *eventPtr)); |
| 206 |
static int WidgetCommand _ANSI_ARGS_((ClientData clientData, |
| 207 |
Tcl_Interp *, int argc, char **argv)); |
| 208 |
static void WidgetDisplay _ANSI_ARGS_((ClientData clientData)); |
| 209 |
static void WidgetComputeGeometry _ANSI_ARGS_(( |
| 210 |
ClientData clientData)); |
| 211 |
static void IdleHandler _ANSI_ARGS_(( |
| 212 |
ClientData clientData)); |
| 213 |
|
| 214 |
|
| 215 |
static int ConfigElement _ANSI_ARGS_((WidgetPtr wPtr, |
| 216 |
TixGrEntry *chPtr, int argc, char ** argv, |
| 217 |
int flags, int forced)); |
| 218 |
static void Tix_GrDisplayMainBody _ANSI_ARGS_(( |
| 219 |
WidgetPtr wPtr, Drawable buffer, |
| 220 |
int winW, int winH)); |
| 221 |
static void Tix_GrDrawBackground _ANSI_ARGS_((WidgetPtr wPtr, |
| 222 |
RenderInfo * riPtr,Drawable drawable)); |
| 223 |
static void Tix_GrDrawCells _ANSI_ARGS_((WidgetPtr wPtr, |
| 224 |
RenderInfo * riPtr,Drawable drawable)); |
| 225 |
static void Tix_GrDrawSites _ANSI_ARGS_((WidgetPtr wPtr, |
| 226 |
RenderInfo * riPtr,Drawable drawable)); |
| 227 |
int Tix_GrGetElementPosn _ANSI_ARGS_(( |
| 228 |
WidgetPtr wPtr, int x, int y, |
| 229 |
int rect[2][2], int clipOK, int isSite, |
| 230 |
int isScr, int nearest)); |
| 231 |
static void UpdateScrollBars _ANSI_ARGS_((WidgetPtr wPtr, |
| 232 |
int sizeChanged)); |
| 233 |
static void GetScrollFractions _ANSI_ARGS_(( |
| 234 |
WidgetPtr wPtr, Tix_GridScrollInfo *siPtr, |
| 235 |
double * first_ret, double * last_ret)); |
| 236 |
static void Tix_GrDItemSizeChanged _ANSI_ARGS_(( |
| 237 |
Tix_DItem *iPtr)); |
| 238 |
static TixGrEntry * Tix_GrFindCreateElem _ANSI_ARGS_((Tcl_Interp * interp, |
| 239 |
WidgetPtr wPtr, int x, int y)); |
| 240 |
static TixGrEntry * Tix_GrFindElem _ANSI_ARGS_((Tcl_Interp * interp, |
| 241 |
WidgetPtr wPtr, int x, int y)); |
| 242 |
static void Tix_GrPropagateSize _ANSI_ARGS_(( |
| 243 |
WidgetPtr wPtr, TixGrEntry * chPtr)); |
| 244 |
static RenderBlock * Tix_GrAllocateRenderBlock _ANSI_ARGS_(( |
| 245 |
WidgetPtr wPtr, int winW, int winH, |
| 246 |
int *exactW, int *exactH)); |
| 247 |
static void Tix_GrFreeRenderBlock _ANSI_ARGS_(( |
| 248 |
WidgetPtr wPtr, RenderBlock * rbPtr)); |
| 249 |
static void Tix_GrComputeSelection _ANSI_ARGS_(( |
| 250 |
WidgetPtr wPtr)); |
| 251 |
static int Tix_GrBBox _ANSI_ARGS_((Tcl_Interp * interp, |
| 252 |
WidgetPtr wPtr, int x, int y)); |
| 253 |
static int TranslateFromTo _ANSI_ARGS_((Tcl_Interp * interp, |
| 254 |
WidgetPtr wPtr, int argc, char **argv, int *from, |
| 255 |
int * to, int *which)); |
| 256 |
static void Tix_GrComputeSubSelection _ANSI_ARGS_(( |
| 257 |
WidgetPtr wPtr, int rect[2][2], int offs[2])); |
| 258 |
static int Tix_GrCallFormatCmd _ANSI_ARGS_((WidgetPtr wPtr, |
| 259 |
int which)); |
| 260 |
static void RecalScrollRegion _ANSI_ARGS_((WidgetPtr wPtr, |
| 261 |
int winW, int winH, |
| 262 |
Tix_GridScrollInfo *scrollInfo)); |
| 263 |
static void Tix_GrResetRenderBlocks _ANSI_ARGS_((WidgetPtr wPtr)); |
| 264 |
|
| 265 |
static TIX_DECLARE_SUBCMD(Tix_GrBdType); |
| 266 |
static TIX_DECLARE_SUBCMD(Tix_GrCGet); |
| 267 |
static TIX_DECLARE_SUBCMD(Tix_GrConfig); |
| 268 |
static TIX_DECLARE_SUBCMD(Tix_GrDelete); |
| 269 |
static TIX_DECLARE_SUBCMD(Tix_GrEdit); |
| 270 |
static TIX_DECLARE_SUBCMD(Tix_GrEntryCget); |
| 271 |
static TIX_DECLARE_SUBCMD(Tix_GrEntryConfig); |
| 272 |
EXTERN TIX_DECLARE_SUBCMD(Tix_GrFormat); |
| 273 |
static TIX_DECLARE_SUBCMD(Tix_GrGeometryInfo); |
| 274 |
static TIX_DECLARE_SUBCMD(Tix_GrInfo); |
| 275 |
static TIX_DECLARE_SUBCMD(Tix_GrIndex); |
| 276 |
static TIX_DECLARE_SUBCMD(Tix_GrMove); |
| 277 |
static TIX_DECLARE_SUBCMD(Tix_GrSee); |
| 278 |
static TIX_DECLARE_SUBCMD(Tix_GrNearest); |
| 279 |
EXTERN TIX_DECLARE_SUBCMD(Tix_GrSelection); |
| 280 |
static TIX_DECLARE_SUBCMD(Tix_GrSet); |
| 281 |
EXTERN TIX_DECLARE_SUBCMD(Tix_GrSetSize); |
| 282 |
static TIX_DECLARE_SUBCMD(Tix_GrSetSite); |
| 283 |
EXTERN TIX_DECLARE_SUBCMD(Tix_GrSort); |
| 284 |
static TIX_DECLARE_SUBCMD(Tix_GrView); |
| 285 |
static TIX_DECLARE_SUBCMD(Tix_GrUnset); |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
int |
| 305 |
Tix_GridCmd(clientData, interp, argc, argv) |
| 306 |
ClientData clientData; |
| 307 |
Tcl_Interp *interp; |
| 308 |
int argc; |
| 309 |
char **argv; |
| 310 |
{ |
| 311 |
Tk_Window mainw = (Tk_Window) clientData; |
| 312 |
WidgetPtr wPtr; |
| 313 |
Tk_Window tkwin; |
| 314 |
|
| 315 |
if (argc < 2) { |
| 316 |
Tcl_AppendResult(interp, "wrong # args: should be \"", |
| 317 |
argv[0], " pathName ?options?\"", (char *) NULL); |
| 318 |
return TCL_ERROR; |
| 319 |
} |
| 320 |
|
| 321 |
tkwin = Tk_CreateWindowFromPath(interp, mainw, argv[1], (char *) NULL); |
| 322 |
if (tkwin == NULL) { |
| 323 |
return TCL_ERROR; |
| 324 |
} |
| 325 |
|
| 326 |
Tk_SetClass(tkwin, "TixGrid"); |
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
wPtr = (WidgetPtr) ckalloc(sizeof(WidgetRecord)); |
| 332 |
|
| 333 |
wPtr->dispData.tkwin = tkwin; |
| 334 |
wPtr->dispData.display = Tk_Display(tkwin); |
| 335 |
wPtr->dispData.interp = interp; |
| 336 |
wPtr->dispData.sizeChangedProc = Tix_GrDItemSizeChanged; |
| 337 |
wPtr->font = NULL; |
| 338 |
wPtr->normalBg = NULL; |
| 339 |
wPtr->normalFg = NULL; |
| 340 |
wPtr->command = NULL; |
| 341 |
wPtr->border = NULL; |
| 342 |
wPtr->borderWidth = 0; |
| 343 |
wPtr->selectBorder = NULL; |
| 344 |
wPtr->selBorderWidth = 0; |
| 345 |
wPtr->selectFg = NULL; |
| 346 |
wPtr->backgroundGC = None; |
| 347 |
wPtr->selectGC = None; |
| 348 |
wPtr->anchorGC = None; |
| 349 |
wPtr->highlightWidth = 0; |
| 350 |
wPtr->highlightColorPtr = NULL; |
| 351 |
wPtr->highlightGC = None; |
| 352 |
wPtr->relief = TK_RELIEF_FLAT; |
| 353 |
wPtr->cursor = None; |
| 354 |
wPtr->selectMode = NULL; |
| 355 |
wPtr->selectUnit = NULL; |
| 356 |
wPtr->anchor[0] = TIX_SITE_NONE; |
| 357 |
wPtr->anchor[1] = TIX_SITE_NONE; |
| 358 |
wPtr->dragSite[0] = TIX_SITE_NONE; |
| 359 |
wPtr->dragSite[1] = TIX_SITE_NONE; |
| 360 |
wPtr->dropSite[0] = TIX_SITE_NONE; |
| 361 |
wPtr->dropSite[1] = TIX_SITE_NONE; |
| 362 |
wPtr->browseCmd = 0; |
| 363 |
wPtr->formatCmd = 0; |
| 364 |
wPtr->editDoneCmd = 0; |
| 365 |
wPtr->editNotifyCmd = 0; |
| 366 |
wPtr->sizeCmd = 0; |
| 367 |
wPtr->takeFocus = NULL; |
| 368 |
wPtr->serial = 0; |
| 369 |
wPtr->mainRB = (RenderBlock*)NULL; |
| 370 |
wPtr->hdrSize[0] = 1; |
| 371 |
wPtr->hdrSize[1] = 1; |
| 372 |
wPtr->expArea.x1 = 10000; |
| 373 |
wPtr->expArea.y1 = 10000; |
| 374 |
wPtr->expArea.x2 = 0; |
| 375 |
wPtr->expArea.y2 = 0; |
| 376 |
wPtr->dataSet = TixGridDataSetInit(); |
| 377 |
wPtr->renderInfo = NULL; |
| 378 |
wPtr->defSize[0].sizeType = TIX_GR_DEFINED_CHAR; |
| 379 |
wPtr->defSize[0].charValue = 10.0; |
| 380 |
wPtr->defSize[0].pad0 = 2; |
| 381 |
wPtr->defSize[0].pad1 = 2; |
| 382 |
wPtr->defSize[1].sizeType = TIX_GR_DEFINED_CHAR; |
| 383 |
wPtr->defSize[1].charValue = 1.2; |
| 384 |
wPtr->defSize[1].pad0 = 2; |
| 385 |
wPtr->defSize[1].pad1 = 2; |
| 386 |
wPtr->gridSize[0] = 0; |
| 387 |
wPtr->gridSize[1] = 0; |
| 388 |
wPtr->reqSize[0] = 0; |
| 389 |
wPtr->reqSize[1] = 0; |
| 390 |
wPtr->state = tixNormalUid; |
| 391 |
wPtr->colorInfoCounter = 0; |
| 392 |
|
| 393 |
|
| 394 |
wPtr->idleEvent = 0; |
| 395 |
wPtr->toRedraw = 0; |
| 396 |
wPtr->toResize = 0; |
| 397 |
wPtr->toResetRB = 0; |
| 398 |
wPtr->toComputeSel = 0; |
| 399 |
wPtr->toRedrawHighlight = 0; |
| 400 |
|
| 401 |
wPtr->scrollInfo[0].command = NULL; |
| 402 |
wPtr->scrollInfo[1].command = NULL; |
| 403 |
|
| 404 |
wPtr->scrollInfo[0].max = 1; |
| 405 |
wPtr->scrollInfo[0].unit = 1; |
| 406 |
wPtr->scrollInfo[0].offset = 0; |
| 407 |
wPtr->scrollInfo[0].window = 1.0; |
| 408 |
wPtr->scrollInfo[1].max = 1; |
| 409 |
wPtr->scrollInfo[1].unit = 1; |
| 410 |
wPtr->scrollInfo[1].offset = 0; |
| 411 |
wPtr->scrollInfo[1].window = 1.0; |
| 412 |
|
| 413 |
Tix_SimpleListInit(&wPtr->colorInfo); |
| 414 |
Tix_SimpleListInit(&wPtr->selList); |
| 415 |
Tix_SimpleListInit(&wPtr->mappedWindows); |
| 416 |
|
| 417 |
Tk_CreateEventHandler(wPtr->dispData.tkwin, |
| 418 |
ExposureMask|StructureNotifyMask|FocusChangeMask, |
| 419 |
WidgetEventProc, (ClientData) wPtr); |
| 420 |
wPtr->widgetCmd = Tcl_CreateCommand(interp, |
| 421 |
Tk_PathName(wPtr->dispData.tkwin), WidgetCommand, (ClientData) wPtr, |
| 422 |
WidgetCmdDeletedProc); |
| 423 |
|
| 424 |
if (WidgetConfigure(interp, wPtr, argc-2, argv+2, 0) != TCL_OK) { |
| 425 |
Tk_DestroyWindow(wPtr->dispData.tkwin); |
| 426 |
return TCL_ERROR; |
| 427 |
} |
| 428 |
|
| 429 |
interp->result = Tk_PathName(wPtr->dispData.tkwin); |
| 430 |
return TCL_OK; |
| 431 |
} |
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
static int |
| 454 |
WidgetConfigure(interp, wPtr, argc, argv, flags) |
| 455 |
Tcl_Interp *interp; |
| 456 |
WidgetPtr wPtr; |
| 457 |
int argc; |
| 458 |
char **argv; |
| 459 |
int flags; |
| 460 |
|
| 461 |
{ |
| 462 |
XGCValues gcValues; |
| 463 |
GC newGC; |
| 464 |
TixFont oldfont; |
| 465 |
Tix_StyleTemplate stTmpl; |
| 466 |
|
| 467 |
oldfont = wPtr->font; |
| 468 |
|
| 469 |
if (Tk_ConfigureWidget(interp, wPtr->dispData.tkwin, configSpecs, |
| 470 |
argc, argv, (char *) wPtr, flags) != TCL_OK) { |
| 471 |
return TCL_ERROR; |
| 472 |
} |
| 473 |
|
| 474 |
wPtr->bdPad = wPtr->highlightWidth + wPtr->borderWidth; |
| 475 |
|
| 476 |
if ((wPtr->state != tixNormalUid) && (wPtr->state != tixDisabledUid)) { |
| 477 |
Tcl_AppendResult(interp, "bad state value \"", wPtr->state, |
| 478 |
"\": must be normal or disabled", (char *) NULL); |
| 479 |
wPtr->state = tixNormalUid; |
| 480 |
return TCL_ERROR; |
| 481 |
} |
| 482 |
|
| 483 |
if (oldfont != wPtr->font) { |
| 484 |
int i; |
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
wPtr->toResetRB = 1; |
| 491 |
|
| 492 |
TixComputeTextGeometry(wPtr->font, "0", 1, |
| 493 |
0, &wPtr->fontSize[0], &wPtr->fontSize[1]); |
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
for (i=0; i<2; i++) { |
| 498 |
switch (wPtr->defSize[i].sizeType) { |
| 499 |
case TIX_GR_DEFINED_CHAR: |
| 500 |
wPtr->defSize[i].pixels = (int) |
| 501 |
(wPtr->defSize[i].charValue * wPtr->fontSize[i]); |
| 502 |
break; |
| 503 |
case TIX_GR_AUTO: |
| 504 |
if (i==0) { |
| 505 |
wPtr->defSize[i].pixels = 10 * wPtr->fontSize[0]; |
| 506 |
} |
| 507 |
if (i==1) { |
| 508 |
wPtr->defSize[i].pixels = 1 * wPtr->fontSize[1]; |
| 509 |
} |
| 510 |
break; |
| 511 |
} |
| 512 |
} |
| 513 |
} |
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
Tk_SetBackgroundFromBorder(wPtr->dispData.tkwin, wPtr->border); |
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
gcValues.foreground = wPtr->normalBg->pixel; |
| 531 |
gcValues.graphics_exposures = False; |
| 532 |
|
| 533 |
newGC = Tk_GetGC(wPtr->dispData.tkwin, |
| 534 |
GCForeground|GCGraphicsExposures, &gcValues); |
| 535 |
if (wPtr->backgroundGC != None) { |
| 536 |
Tk_FreeGC(wPtr->dispData.display, wPtr->backgroundGC); |
| 537 |
} |
| 538 |
wPtr->backgroundGC = newGC; |
| 539 |
|
| 540 |
|
| 541 |
gcValues.font = TixFontId(wPtr->font); |
| 542 |
gcValues.foreground = wPtr->selectFg->pixel; |
| 543 |
gcValues.background = Tk_3DBorderColor(wPtr->selectBorder)->pixel; |
| 544 |
gcValues.graphics_exposures = False; |
| 545 |
|
| 546 |
newGC = Tk_GetGC(wPtr->dispData.tkwin, |
| 547 |
GCForeground|GCBackground|GCFont|GCGraphicsExposures, &gcValues); |
| 548 |
if (wPtr->selectGC != None) { |
| 549 |
Tk_FreeGC(wPtr->dispData.display, wPtr->selectGC); |
| 550 |
} |
| 551 |
wPtr->selectGC = newGC; |
| 552 |
|
| 553 |
|
| 554 |
gcValues.foreground = wPtr->normalFg->pixel; |
| 555 |
gcValues.background = wPtr->normalBg->pixel; |
| 556 |
gcValues.graphics_exposures = False; |
| 557 |
gcValues.line_style = LineDoubleDash; |
| 558 |
gcValues.dashes = 2; |
| 559 |
gcValues.subwindow_mode = IncludeInferiors; |
| 560 |
|
| 561 |
newGC = Tk_GetGC(wPtr->dispData.tkwin, |
| 562 |
GCForeground|GCBackground|GCGraphicsExposures|GCLineStyle|GCDashList| |
| 563 |
GCSubwindowMode, &gcValues); |
| 564 |
if (wPtr->anchorGC != None) { |
| 565 |
Tk_FreeGC(wPtr->dispData.display, wPtr->anchorGC); |
| 566 |
} |
| 567 |
wPtr->anchorGC = newGC; |
| 568 |
|
| 569 |
|
| 570 |
gcValues.background = wPtr->selectFg->pixel; |
| 571 |
gcValues.foreground = wPtr->highlightColorPtr->pixel; |
| 572 |
gcValues.graphics_exposures = False; |
| 573 |
|
| 574 |
newGC = Tk_GetGC(wPtr->dispData.tkwin, |
| 575 |
GCForeground|GCBackground|GCGraphicsExposures, &gcValues); |
| 576 |
if (wPtr->highlightGC != None) { |
| 577 |
Tk_FreeGC(wPtr->dispData.display, wPtr->highlightGC); |
| 578 |
} |
| 579 |
wPtr->highlightGC = newGC; |
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
stTmpl.font = wPtr->font; |
| 586 |
stTmpl.pad[0] = wPtr->padX; |
| 587 |
stTmpl.pad[1] = wPtr->padY; |
| 588 |
stTmpl.colors[TIX_DITEM_NORMAL].fg = wPtr->normalFg; |
| 589 |
stTmpl.colors[TIX_DITEM_NORMAL].bg = wPtr->normalBg; |
| 590 |
stTmpl.colors[TIX_DITEM_SELECTED].fg= wPtr->selectFg; |
| 591 |
stTmpl.colors[TIX_DITEM_SELECTED].bg= Tk_3DBorderColor(wPtr->selectBorder); |
| 592 |
stTmpl.flags = TIX_DITEM_FONT|TIX_DITEM_NORMAL_BG| |
| 593 |
TIX_DITEM_SELECTED_BG|TIX_DITEM_NORMAL_FG|TIX_DITEM_SELECTED_FG | |
| 594 |
TIX_DITEM_PADX|TIX_DITEM_PADY; |
| 595 |
|
| 596 |
Tix_SetDefaultStyleTemplate(wPtr->dispData.tkwin, &stTmpl); |
| 597 |
|
| 598 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_RESIZE); |
| 599 |
|
| 600 |
return TCL_OK; |
| 601 |
} |
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
static int |
| 621 |
WidgetCommand(clientData, interp, argc, argv) |
| 622 |
ClientData clientData; |
| 623 |
Tcl_Interp *interp; |
| 624 |
int argc; |
| 625 |
char **argv; |
| 626 |
{ |
| 627 |
int code; |
| 628 |
|
| 629 |
static Tix_SubCmdInfo subCmdInfo[] = { |
| 630 |
{TIX_DEFAULT_LEN, "anchor", 1, 3, Tix_GrSetSite, |
| 631 |
"option ?x y?"}, |
| 632 |
{TIX_DEFAULT_LEN, "bdtype", 2, 4, Tix_GrBdType, |
| 633 |
"x y ?xbdWidth ybdWidth?"}, |
| 634 |
{TIX_DEFAULT_LEN, "cget", 1, 1, Tix_GrCGet, |
| 635 |
"option"}, |
| 636 |
{TIX_DEFAULT_LEN, "configure", 0, TIX_VAR_ARGS, Tix_GrConfig, |
| 637 |
"?option? ?value? ?option value ... ?"}, |
| 638 |
{TIX_DEFAULT_LEN, "delete", 2, 3, Tix_GrDelete, |
| 639 |
"option from ?to?"}, |
| 640 |
{TIX_DEFAULT_LEN, "dragsite", 1, 3, Tix_GrSetSite, |
| 641 |
"option ?x y?"}, |
| 642 |
{TIX_DEFAULT_LEN, "dropsite", 1, 3, Tix_GrSetSite, |
| 643 |
"option ?x y?"}, |
| 644 |
{TIX_DEFAULT_LEN, "entrycget", 3, 3, Tix_GrEntryCget, |
| 645 |
"x y option"}, |
| 646 |
{TIX_DEFAULT_LEN, "edit", 1, 3, Tix_GrEdit, |
| 647 |
"option ?args ...?"}, |
| 648 |
{TIX_DEFAULT_LEN, "entryconfigure", 2, TIX_VAR_ARGS, Tix_GrEntryConfig, |
| 649 |
"x y ?option? ?value? ?option value ... ?"}, |
| 650 |
{TIX_DEFAULT_LEN, "format", 1, TIX_VAR_ARGS, Tix_GrFormat, |
| 651 |
"option ?args ...?"}, |
| 652 |
{TIX_DEFAULT_LEN, "geometryinfo", 0, 2, Tix_GrGeometryInfo, |
| 653 |
"?width height?"}, |
| 654 |
{TIX_DEFAULT_LEN, "info", 1, TIX_VAR_ARGS, Tix_GrInfo, |
| 655 |
"option ?args ...?"}, |
| 656 |
{TIX_DEFAULT_LEN, "index", 2, 2, Tix_GrIndex, |
| 657 |
"x y"}, |
| 658 |
{TIX_DEFAULT_LEN, "move", 4, 4, Tix_GrMove, |
| 659 |
"option from to by"}, |
| 660 |
{TIX_DEFAULT_LEN, "nearest", 2, 2, Tix_GrNearest, |
| 661 |
"x y"}, |
| 662 |
{TIX_DEFAULT_LEN, "see", 2, 2, Tix_GrSee, |
| 663 |
"x y"}, |
| 664 |
{TIX_DEFAULT_LEN, "selection", 3, 5, Tix_GrSelection, |
| 665 |
"option x1 y1 ?x2 y2?"}, |
| 666 |
{TIX_DEFAULT_LEN, "set", 2, TIX_VAR_ARGS, Tix_GrSet, |
| 667 |
"x y ?option value ...?"}, |
| 668 |
{TIX_DEFAULT_LEN, "size", 1, TIX_VAR_ARGS, Tix_GrSetSize, |
| 669 |
"option ?args ...?"}, |
| 670 |
#ifndef _WINDOWS |
| 671 |
{TIX_DEFAULT_LEN, "sort", 3, TIX_VAR_ARGS, Tix_GrSort, |
| 672 |
"dimension start end ?args ...?"}, |
| 673 |
#endif |
| 674 |
{TIX_DEFAULT_LEN, "unset", 2, 2, Tix_GrUnset, |
| 675 |
"x y"}, |
| 676 |
{TIX_DEFAULT_LEN, "xview", 0, 3, Tix_GrView, |
| 677 |
"args"}, |
| 678 |
{TIX_DEFAULT_LEN, "yview", 0, 3, Tix_GrView, |
| 679 |
"args"}, |
| 680 |
}; |
| 681 |
|
| 682 |
static Tix_CmdInfo cmdInfo = { |
| 683 |
Tix_ArraySize(subCmdInfo), 1, TIX_VAR_ARGS, "?option? arg ?arg ...?", |
| 684 |
}; |
| 685 |
|
| 686 |
Tcl_Preserve(clientData); |
| 687 |
code = Tix_HandleSubCmds(&cmdInfo, subCmdInfo, clientData, |
| 688 |
interp, argc, argv); |
| 689 |
Tcl_Release(clientData); |
| 690 |
|
| 691 |
return code; |
| 692 |
} |
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
static void |
| 713 |
WidgetEventProc(clientData, eventPtr) |
| 714 |
ClientData clientData; |
| 715 |
XEvent *eventPtr; |
| 716 |
{ |
| 717 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 718 |
int x2, y2; |
| 719 |
|
| 720 |
switch (eventPtr->type) { |
| 721 |
case DestroyNotify: |
| 722 |
if (wPtr->dispData.tkwin != NULL) { |
| 723 |
wPtr->dispData.tkwin = NULL; |
| 724 |
Tcl_DeleteCommand(wPtr->dispData.interp, |
| 725 |
Tcl_GetCommandName(wPtr->dispData.interp, wPtr->widgetCmd)); |
| 726 |
} |
| 727 |
Tix_GrCancelDoWhenIdle(wPtr); |
| 728 |
Tcl_EventuallyFree((ClientData) wPtr, WidgetDestroy); |
| 729 |
break; |
| 730 |
|
| 731 |
case ConfigureNotify: |
| 732 |
wPtr->expArea.x1 = 0; |
| 733 |
wPtr->expArea.y1 = 0; |
| 734 |
wPtr->expArea.x2 = Tk_Width (wPtr->dispData.tkwin) - 1; |
| 735 |
wPtr->expArea.y2 = Tk_Height(wPtr->dispData.tkwin) - 1; |
| 736 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_RESIZE); |
| 737 |
break; |
| 738 |
|
| 739 |
case Expose: |
| 740 |
if (wPtr->expArea.x1 > eventPtr->xexpose.x) { |
| 741 |
wPtr->expArea.x1 = eventPtr->xexpose.x; |
| 742 |
} |
| 743 |
if (wPtr->expArea.y1 > eventPtr->xexpose.y) { |
| 744 |
wPtr->expArea.y1 = eventPtr->xexpose.y; |
| 745 |
} |
| 746 |
x2 = eventPtr->xexpose.x + eventPtr->xexpose.width - 1; |
| 747 |
y2 = eventPtr->xexpose.y + eventPtr->xexpose.height - 1; |
| 748 |
|
| 749 |
if (wPtr->expArea.x2 < x2) { |
| 750 |
wPtr->expArea.x2 = x2; |
| 751 |
} |
| 752 |
if (wPtr->expArea.y2 < y2) { |
| 753 |
wPtr->expArea.y2 = y2; |
| 754 |
} |
| 755 |
wPtr->toRedrawHighlight = 1; |
| 756 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_REDRAW); |
| 757 |
break; |
| 758 |
|
| 759 |
case FocusIn: |
| 760 |
wPtr->hasFocus = 1; |
| 761 |
wPtr->toRedrawHighlight = 1; |
| 762 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_REDRAW); |
| 763 |
break; |
| 764 |
|
| 765 |
case FocusOut: |
| 766 |
wPtr->hasFocus = 0; |
| 767 |
wPtr->toRedrawHighlight = 1; |
| 768 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_REDRAW); |
| 769 |
break; |
| 770 |
} |
| 771 |
} |
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
static void |
| 792 |
WidgetDestroy(clientData) |
| 793 |
char *clientData; |
| 794 |
{ |
| 795 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 796 |
|
| 797 |
if (wPtr->dataSet) { |
| 798 |
Tix_GrDataRowSearch rowSearch; |
| 799 |
Tix_GrDataCellSearch cellSearch; |
| 800 |
int rowDone, cellDone; |
| 801 |
|
| 802 |
for (rowDone = TixGrDataFirstRow(wPtr->dataSet, &rowSearch); |
| 803 |
!rowDone; |
| 804 |
rowDone = TixGrDataNextRow(&rowSearch)) { |
| 805 |
|
| 806 |
|
| 807 |
for (cellDone = TixGrDataFirstCell(&rowSearch, &cellSearch); |
| 808 |
!cellDone; |
| 809 |
cellDone = TixGrDataNextCell(&cellSearch)) { |
| 810 |
|
| 811 |
TixGridDataDeleteSearchedEntry(&cellSearch); |
| 812 |
Tix_GrFreeElem((TixGrEntry*)cellSearch.data); |
| 813 |
} |
| 814 |
} |
| 815 |
|
| 816 |
TixGridDataSetFree(wPtr->dataSet); |
| 817 |
} |
| 818 |
|
| 819 |
if (wPtr->backgroundGC != None) { |
| 820 |
Tk_FreeGC(wPtr->dispData.display, wPtr->backgroundGC); |
| 821 |
} |
| 822 |
if (wPtr->selectGC != None) { |
| 823 |
Tk_FreeGC(wPtr->dispData.display, wPtr->selectGC); |
| 824 |
} |
| 825 |
if (wPtr->anchorGC != None) { |
| 826 |
Tk_FreeGC(wPtr->dispData.display, wPtr->anchorGC); |
| 827 |
} |
| 828 |
if (wPtr->highlightGC != None) { |
| 829 |
Tk_FreeGC(wPtr->dispData.display, wPtr->highlightGC); |
| 830 |
} |
| 831 |
|
| 832 |
if (wPtr->mainRB) { |
| 833 |
Tix_GrFreeRenderBlock(wPtr, wPtr->mainRB); |
| 834 |
} |
| 835 |
|
| 836 |
Tix_GrFreeUnusedColors(wPtr, 1); |
| 837 |
|
| 838 |
if (!Tix_IsLinkListEmpty(wPtr->mappedWindows)) { |
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
panic("tixGrid: mappedWindows not NULL"); |
| 844 |
} |
| 845 |
|
| 846 |
Tk_FreeOptions(configSpecs, (char *) wPtr, wPtr->dispData.display, 0); |
| 847 |
ckfree((char *) wPtr); |
| 848 |
} |
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
static void |
| 868 |
WidgetCmdDeletedProc(clientData) |
| 869 |
ClientData clientData; |
| 870 |
{ |
| 871 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
if (wPtr->dispData.tkwin != NULL) { |
| 880 |
Tk_Window tkwin = wPtr->dispData.tkwin; |
| 881 |
wPtr->dispData.tkwin = NULL; |
| 882 |
Tk_DestroyWindow(tkwin); |
| 883 |
} |
| 884 |
} |
| 885 |
|
| 886 |
static void |
| 887 |
RecalScrollRegion(wPtr, winW, winH, scrollInfo) |
| 888 |
WidgetPtr wPtr; |
| 889 |
int winW; |
| 890 |
int winH; |
| 891 |
Tix_GridScrollInfo *scrollInfo; |
| 892 |
{ |
| 893 |
int gridSize[2]; |
| 894 |
int winSize[2]; |
| 895 |
int i, k; |
| 896 |
int count; |
| 897 |
int visibleSize; |
| 898 |
int totalSize; |
| 899 |
int pad0, pad1; |
| 900 |
|
| 901 |
winSize[0] = winW; |
| 902 |
winSize[1] = winH; |
| 903 |
|
| 904 |
TixGridDataGetGridSize(wPtr->dataSet, &gridSize[0], |
| 905 |
&gridSize[1]); |
| 906 |
|
| 907 |
for (i=0; i<2; i++) { |
| 908 |
for (k=0; k<wPtr->hdrSize[i] && k<gridSize[i]; k++) { |
| 909 |
winSize[i] -= TixGridDataGetRowColSize(wPtr, wPtr->dataSet, i, |
| 910 |
k, &wPtr->defSize[i], &pad0, &pad1); |
| 911 |
winSize[i] -= pad0 + pad1; |
| 912 |
} |
| 913 |
if (winSize[i] <= 0) { |
| 914 |
|
| 915 |
|
| 916 |
|
| 917 |
scrollInfo[i].max = 0; |
| 918 |
scrollInfo[i].window = 1.0; |
| 919 |
continue; |
| 920 |
} |
| 921 |
if (wPtr->hdrSize[i] >= gridSize[i]) { |
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
scrollInfo[i].max = 0; |
| 926 |
scrollInfo[i].window = 1.0; |
| 927 |
continue; |
| 928 |
} |
| 929 |
|
| 930 |
visibleSize = winSize[i]; |
| 931 |
|
| 932 |
for (count=0,k=gridSize[i]-1; k>=wPtr->hdrSize[i]&&k>=0; count++,k--) { |
| 933 |
winSize[i] -= TixGridDataGetRowColSize(wPtr, wPtr->dataSet, i, |
| 934 |
k, &wPtr->defSize[i], &pad0, &pad1); |
| 935 |
winSize[i] -= pad0 + pad1; |
| 936 |
|
| 937 |
if (winSize[i] == 0) { |
| 938 |
++ count; |
| 939 |
break; |
| 940 |
} |
| 941 |
else if (winSize[i] < 0) { |
| 942 |
break; |
| 943 |
} |
| 944 |
} |
| 945 |
|
| 946 |
if (count == 0) { |
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
count = 1; |
| 952 |
} |
| 953 |
scrollInfo[i].max = (gridSize[i]-wPtr->hdrSize[i]) - count; |
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
for (totalSize=0,k=wPtr->hdrSize[i];k<gridSize[i];k++) { |
| 959 |
totalSize += TixGridDataGetRowColSize(wPtr, wPtr->dataSet, i, |
| 960 |
k, &wPtr->defSize[i], &pad0, &pad1); |
| 961 |
totalSize += pad0 + pad1; |
| 962 |
} |
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
totalSize += (-winSize[i]); |
| 968 |
|
| 969 |
scrollInfo[i].window = |
| 970 |
(double)(visibleSize) / (double)totalSize; |
| 971 |
} |
| 972 |
for (i=0; i<2; i++) { |
| 973 |
if (scrollInfo[i].offset < 0) { |
| 974 |
scrollInfo[i].offset = 0; |
| 975 |
} |
| 976 |
if (scrollInfo[i].offset > scrollInfo[i].max) { |
| 977 |
scrollInfo[i].offset = scrollInfo[i].max; |
| 978 |
} |
| 979 |
} |
| 980 |
} |
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
|
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
static void |
| 1001 |
WidgetComputeGeometry(clientData) |
| 1002 |
ClientData clientData; |
| 1003 |
{ |
| 1004 |
WidgetPtr wPtr = (WidgetPtr)clientData; |
| 1005 |
int i, k; |
| 1006 |
int gridSize[2]; |
| 1007 |
int req[2], pad0, pad1; |
| 1008 |
Tk_Window tkwin = wPtr->dispData.tkwin; |
| 1009 |
|
| 1010 |
TixGridDataGetGridSize(wPtr->dataSet, &gridSize[0], |
| 1011 |
&gridSize[1]); |
| 1012 |
|
| 1013 |
for (i=0; i<2; i++) { |
| 1014 |
int end = wPtr->reqSize[i]; |
| 1015 |
if (end == 0) { |
| 1016 |
end = gridSize[0] + 1; |
| 1017 |
} |
| 1018 |
for (req[i]=0,k=0; k<end; k++) { |
| 1019 |
req[i] += TixGridDataGetRowColSize(wPtr, wPtr->dataSet, i, |
| 1020 |
k, &wPtr->defSize[i], &pad0, &pad1); |
| 1021 |
req[i] += pad0 + pad1; |
| 1022 |
} |
| 1023 |
|
| 1024 |
req[i] += 2*(wPtr->highlightWidth + wPtr->borderWidth); |
| 1025 |
} |
| 1026 |
|
| 1027 |
if (Tk_ReqWidth(tkwin) != req[0] || Tk_ReqHeight(tkwin) != req[0]) { |
| 1028 |
Tk_GeometryRequest(tkwin, req[0], req[1]); |
| 1029 |
} |
| 1030 |
|
| 1031 |
|
| 1032 |
wPtr->toResetRB = 1; |
| 1033 |
wPtr->toComputeSel = 1; |
| 1034 |
wPtr->toRedrawHighlight = 1; |
| 1035 |
|
| 1036 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_REDRAW); |
| 1037 |
} |
| 1038 |
|
| 1039 |
static void |
| 1040 |
Tix_GrResetRenderBlocks(wPtr) |
| 1041 |
WidgetPtr wPtr; |
| 1042 |
{ |
| 1043 |
int winW, winH, exactW, exactH; |
| 1044 |
Tk_Window tkwin = wPtr->dispData.tkwin; |
| 1045 |
|
| 1046 |
winW = Tk_Width (tkwin) - 2*wPtr->highlightWidth - 2*wPtr->borderWidth; |
| 1047 |
winH = Tk_Height(tkwin) - 2*wPtr->highlightWidth - 2*wPtr->borderWidth; |
| 1048 |
|
| 1049 |
RecalScrollRegion(wPtr, winW, winH, wPtr->scrollInfo); |
| 1050 |
|
| 1051 |
UpdateScrollBars(wPtr, 1); |
| 1052 |
|
| 1053 |
if (wPtr->mainRB) { |
| 1054 |
Tix_GrFreeRenderBlock(wPtr, wPtr->mainRB); |
| 1055 |
} |
| 1056 |
wPtr->mainRB = Tix_GrAllocateRenderBlock(wPtr, winW, winH,&exactW,&exactH); |
| 1057 |
|
| 1058 |
wPtr->expArea.x1 = 0; |
| 1059 |
wPtr->expArea.y1 = 0; |
| 1060 |
wPtr->expArea.x2 = Tk_Width (wPtr->dispData.tkwin) - 1; |
| 1061 |
wPtr->expArea.y2 = Tk_Height(wPtr->dispData.tkwin) - 1; |
| 1062 |
} |
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
static void |
| 1072 |
Tix_GrDItemSizeChanged(iPtr) |
| 1073 |
Tix_DItem *iPtr; |
| 1074 |
{ |
| 1075 |
WidgetPtr wPtr = (WidgetPtr)iPtr->base.clientData; |
| 1076 |
|
| 1077 |
if (wPtr) { |
| 1078 |
|
| 1079 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_RESIZE); |
| 1080 |
} |
| 1081 |
} |
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
|
| 1086 |
|
| 1087 |
|
| 1088 |
void |
| 1089 |
Tix_GrDoWhenIdle(wPtr, type) |
| 1090 |
WidgetPtr wPtr; |
| 1091 |
int type; |
| 1092 |
{ |
| 1093 |
switch (type) { |
| 1094 |
case TIX_GR_RESIZE: |
| 1095 |
wPtr->toResize = 1; |
| 1096 |
break; |
| 1097 |
case TIX_GR_REDRAW: |
| 1098 |
wPtr->toRedraw = 1; |
| 1099 |
break; |
| 1100 |
} |
| 1101 |
|
| 1102 |
if (!wPtr->idleEvent) { |
| 1103 |
wPtr->idleEvent = 1; |
| 1104 |
Tcl_DoWhenIdle(IdleHandler, (ClientData)wPtr); |
| 1105 |
} |
| 1106 |
} |
| 1107 |
|
| 1108 |
static void |
| 1109 |
IdleHandler(clientData) |
| 1110 |
ClientData clientData; |
| 1111 |
{ |
| 1112 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 1113 |
|
| 1114 |
if (!wPtr->idleEvent) { |
| 1115 |
return; |
| 1116 |
} |
| 1117 |
wPtr->idleEvent = 0; |
| 1118 |
|
| 1119 |
if (wPtr->toResize) { |
| 1120 |
wPtr->toResize = 0; |
| 1121 |
WidgetComputeGeometry(clientData); |
| 1122 |
} |
| 1123 |
else if (wPtr->toRedraw) { |
| 1124 |
wPtr->toRedraw = 0; |
| 1125 |
WidgetDisplay(clientData); |
| 1126 |
} |
| 1127 |
} |
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
void |
| 1135 |
Tix_GrCancelDoWhenIdle(wPtr) |
| 1136 |
WidgetPtr wPtr; |
| 1137 |
{ |
| 1138 |
wPtr->toResize = 0; |
| 1139 |
wPtr->toRedraw = 0; |
| 1140 |
|
| 1141 |
if (wPtr->idleEvent) { |
| 1142 |
Tcl_CancelIdleCall(IdleHandler, (ClientData)wPtr); |
| 1143 |
wPtr->idleEvent = 0; |
| 1144 |
} |
| 1145 |
} |
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
static void |
| 1155 |
WidgetDisplay(clientData) |
| 1156 |
ClientData clientData; |
| 1157 |
{ |
| 1158 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 1159 |
Drawable buffer = None; |
| 1160 |
Tk_Window tkwin = wPtr->dispData.tkwin; |
| 1161 |
int winH, winW, expW, expH; |
| 1162 |
GC highlightGC; |
| 1163 |
|
| 1164 |
if (!Tk_IsMapped(tkwin)) { |
| 1165 |
return; |
| 1166 |
} |
| 1167 |
wPtr->serial ++; |
| 1168 |
|
| 1169 |
winW = Tk_Width(tkwin) - 2*wPtr->highlightWidth - 2*wPtr->borderWidth; |
| 1170 |
winH = Tk_Height(tkwin) - 2*wPtr->highlightWidth - 2*wPtr->borderWidth; |
| 1171 |
|
| 1172 |
if (winW <= 0 || winH <= 0) { |
| 1173 |
goto done; |
| 1174 |
} |
| 1175 |
|
| 1176 |
if (wPtr->toResetRB) { |
| 1177 |
Tix_GrResetRenderBlocks(wPtr); |
| 1178 |
wPtr->toResetRB = 0; |
| 1179 |
} |
| 1180 |
if (wPtr->toComputeSel) { |
| 1181 |
Tix_GrComputeSelection(wPtr); |
| 1182 |
wPtr->toComputeSel = 0; |
| 1183 |
} |
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
|
| 1188 |
|
| 1189 |
if (wPtr->expArea.x1 < wPtr->bdPad) { |
| 1190 |
wPtr->expArea.x1 = wPtr->bdPad; |
| 1191 |
} |
| 1192 |
if (wPtr->expArea.y1 < wPtr->bdPad) { |
| 1193 |
wPtr->expArea.y1 = wPtr->bdPad; |
| 1194 |
} |
| 1195 |
if (wPtr->expArea.x2 >= Tk_Width(tkwin) - wPtr->bdPad) { |
| 1196 |
wPtr->expArea.x2 = Tk_Width(tkwin) - wPtr->bdPad - 1; |
| 1197 |
} |
| 1198 |
if (wPtr->expArea.y2 >= Tk_Height(tkwin) - wPtr->bdPad) { |
| 1199 |
wPtr->expArea.y2 = Tk_Height(tkwin) - wPtr->bdPad - 1; |
| 1200 |
} |
| 1201 |
|
| 1202 |
expW = wPtr->expArea.x2 - wPtr->expArea.x1 + 1; |
| 1203 |
expH = wPtr->expArea.y2 - wPtr->expArea.y1 + 1; |
| 1204 |
|
| 1205 |
if (expW <= 0 || expH <= 0) { |
| 1206 |
goto drawBorder; |
| 1207 |
} |
| 1208 |
|
| 1209 |
buffer = Tix_GetRenderBuffer(wPtr->dispData.display, Tk_WindowId(tkwin), |
| 1210 |
expW, expH, Tk_Depth(tkwin)); |
| 1211 |
|
| 1212 |
if (buffer == Tk_WindowId(tkwin)) { |
| 1213 |
|
| 1214 |
XFillRectangle(wPtr->dispData.display, buffer, wPtr->backgroundGC, |
| 1215 |
wPtr->expArea.x1, wPtr->expArea.y1, expW, expH); |
| 1216 |
} else { |
| 1217 |
XFillRectangle(wPtr->dispData.display, buffer, wPtr->backgroundGC, |
| 1218 |
0, 0, expW, expH); |
| 1219 |
} |
| 1220 |
|
| 1221 |
if (wPtr->mainRB) { |
| 1222 |
Tix_GrDisplayMainBody(wPtr, buffer, winW, winH); |
| 1223 |
} |
| 1224 |
|
| 1225 |
if (buffer != Tk_WindowId(tkwin)) { |
| 1226 |
XCopyArea(wPtr->dispData.display, buffer, Tk_WindowId(tkwin), |
| 1227 |
wPtr->backgroundGC, 0, 0, expW, expH, |
| 1228 |
wPtr->expArea.x1, wPtr->expArea.y1); |
| 1229 |
Tk_FreePixmap(wPtr->dispData.display, buffer); |
| 1230 |
} |
| 1231 |
|
| 1232 |
drawBorder: |
| 1233 |
Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), wPtr->border, |
| 1234 |
wPtr->highlightWidth, |
| 1235 |
wPtr->highlightWidth, |
| 1236 |
Tk_Width(tkwin) - 2*wPtr->highlightWidth, |
| 1237 |
Tk_Height(tkwin) - 2*wPtr->highlightWidth, |
| 1238 |
wPtr->borderWidth, wPtr->relief); |
| 1239 |
|
| 1240 |
if (wPtr->toRedrawHighlight && wPtr->highlightWidth > 0) { |
| 1241 |
if (wPtr->hasFocus) { |
| 1242 |
highlightGC = wPtr->highlightGC; |
| 1243 |
} else { |
| 1244 |
highlightGC = Tk_3DBorderGC(tkwin, wPtr->border, |
| 1245 |
TK_3D_FLAT_GC); |
| 1246 |
} |
| 1247 |
|
| 1248 |
Tk_DrawFocusHighlight(tkwin, highlightGC, wPtr->highlightWidth, |
| 1249 |
Tk_WindowId(tkwin)); |
| 1250 |
} |
| 1251 |
|
| 1252 |
done: |
| 1253 |
wPtr->expArea.x1 = 10000; |
| 1254 |
wPtr->expArea.y1 = 10000; |
| 1255 |
wPtr->expArea.x2 = 0; |
| 1256 |
wPtr->expArea.y2 = 0; |
| 1257 |
} |
| 1258 |
|
| 1259 |
|
| 1260 |
|
| 1261 |
|
| 1262 |
|
| 1263 |
|
| 1264 |
|
| 1265 |
|
| 1266 |
|
| 1267 |
|
| 1268 |
|
| 1269 |
|
| 1270 |
|
| 1271 |
|
| 1272 |
|
| 1273 |
static void Tix_GrDisplayMainBody(wPtr, buffer, winW, winH) |
| 1274 |
WidgetPtr wPtr; |
| 1275 |
Drawable buffer; |
| 1276 |
int winW; |
| 1277 |
int winH; |
| 1278 |
{ |
| 1279 |
Tk_Window tkwin = wPtr->dispData.tkwin; |
| 1280 |
RenderInfo mainRI; |
| 1281 |
int i, j; |
| 1282 |
|
| 1283 |
if (buffer == Tk_WindowId(tkwin)) { |
| 1284 |
|
| 1285 |
mainRI.origin[0] = wPtr->highlightWidth + wPtr->borderWidth; |
| 1286 |
mainRI.origin[1] = wPtr->highlightWidth + wPtr->borderWidth; |
| 1287 |
|
| 1288 |
} else { |
| 1289 |
|
| 1290 |
mainRI.origin[0] = wPtr->highlightWidth + wPtr->borderWidth |
| 1291 |
- wPtr->expArea.x1; |
| 1292 |
mainRI.origin[1] = wPtr->highlightWidth + wPtr->borderWidth |
| 1293 |
- wPtr->expArea.y1; |
| 1294 |
} |
| 1295 |
|
| 1296 |
mainRI.drawable = buffer; |
| 1297 |
wPtr->colorInfoCounter ++; |
| 1298 |
|
| 1299 |
wPtr->renderInfo = &mainRI; |
| 1300 |
|
| 1301 |
|
| 1302 |
|
| 1303 |
for (i=0; i<wPtr->mainRB->size[0]; i++) { |
| 1304 |
for (j=0; j<wPtr->mainRB->size[1]; j++) { |
| 1305 |
wPtr->mainRB->elms[i][j].borderW[0][0] = 0; |
| 1306 |
wPtr->mainRB->elms[i][j].borderW[1][0] = 0; |
| 1307 |
wPtr->mainRB->elms[i][j].borderW[0][1] = 0; |
| 1308 |
wPtr->mainRB->elms[i][j].borderW[1][1] = 0; |
| 1309 |
wPtr->mainRB->elms[i][j].filled = 0; |
| 1310 |
} |
| 1311 |
} |
| 1312 |
Tix_GrDrawBackground(wPtr, &mainRI, buffer); |
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
Tix_GrDrawCells(wPtr, &mainRI, buffer); |
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
Tix_GrDrawSites(wPtr, &mainRI, buffer); |
| 1321 |
|
| 1322 |
|
| 1323 |
wPtr->renderInfo = NULL; |
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
|
| 1328 |
Tix_GrFreeUnusedColors(wPtr, 0); |
| 1329 |
} |
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
|
| 1337 |
static void Tix_GrDrawCells(wPtr, riPtr, drawable) |
| 1338 |
WidgetPtr wPtr; |
| 1339 |
RenderInfo * riPtr; |
| 1340 |
Drawable drawable; |
| 1341 |
{ |
| 1342 |
int x, y, i, j; |
| 1343 |
int x1, y1, x2, y2; |
| 1344 |
TixGrEntry * chPtr; |
| 1345 |
int margin = wPtr->borderWidth + wPtr->highlightWidth; |
| 1346 |
|
| 1347 |
for (x=0,i=0; i<wPtr->mainRB->size[0]; i++) { |
| 1348 |
x1 = x + margin; |
| 1349 |
x2 = x1 - 1 + wPtr->mainRB->dispSize[0][i].total; |
| 1350 |
|
| 1351 |
if (x1 > wPtr->expArea.x2) { |
| 1352 |
goto nextCol; |
| 1353 |
} |
| 1354 |
if (x2 < wPtr->expArea.x1) { |
| 1355 |
goto nextCol; |
| 1356 |
} |
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
for (y=0,j=0; j<wPtr->mainRB->size[1]; j++) { |
| 1361 |
|
| 1362 |
|
| 1363 |
|
| 1364 |
|
| 1365 |
y1 = y + margin; |
| 1366 |
y2 = y1 - 1 + wPtr->mainRB->dispSize[1][j].total; |
| 1367 |
|
| 1368 |
if (y1 > wPtr->expArea.y2) { |
| 1369 |
goto nextRow; |
| 1370 |
} |
| 1371 |
if (y2 < wPtr->expArea.y1) { |
| 1372 |
goto nextRow; |
| 1373 |
} |
| 1374 |
if (!wPtr->mainRB->elms[i][j].filled) { |
| 1375 |
if (wPtr->mainRB->elms[i][j].selected) { |
| 1376 |
|
| 1377 |
Tk_Fill3DRectangle(wPtr->dispData.tkwin, |
| 1378 |
drawable, wPtr->selectBorder, |
| 1379 |
x+riPtr->origin[0]+ |
| 1380 |
wPtr->mainRB->elms[i][j].borderW[0][0], |
| 1381 |
y+riPtr->origin[1]+ |
| 1382 |
wPtr->mainRB->elms[i][j].borderW[1][0], |
| 1383 |
wPtr->mainRB->dispSize[0][i].total - |
| 1384 |
wPtr->mainRB->elms[i][j].borderW[0][0] - |
| 1385 |
wPtr->mainRB->elms[i][j].borderW[0][1], |
| 1386 |
wPtr->mainRB->dispSize[1][j].total - |
| 1387 |
wPtr->mainRB->elms[i][j].borderW[1][0] - |
| 1388 |
wPtr->mainRB->elms[i][j].borderW[1][1], |
| 1389 |
0, TK_RELIEF_FLAT); |
| 1390 |
} |
| 1391 |
} |
| 1392 |
|
| 1393 |
chPtr = wPtr->mainRB->elms[i][j].chPtr; |
| 1394 |
if (chPtr != NULL) { |
| 1395 |
if (Tix_DItemType(chPtr->iPtr) == TIX_DITEM_WINDOW) { |
| 1396 |
Tix_DItemDisplay(Tk_WindowId(wPtr->dispData.tkwin), None, |
| 1397 |
chPtr->iPtr, x1, y1, |
| 1398 |
wPtr->mainRB->dispSize[0][i].size, |
| 1399 |
wPtr->mainRB->dispSize[1][j].size, |
| 1400 |
TIX_DITEM_NORMAL_FG); |
| 1401 |
} else { |
| 1402 |
int drawX, drawY; |
| 1403 |
drawX = x + riPtr->origin[0] + |
| 1404 |
wPtr->mainRB->dispSize[0][i].preBorder; |
| 1405 |
drawY = y + riPtr->origin[1] + |
| 1406 |
wPtr->mainRB->dispSize[1][j].preBorder; |
| 1407 |
|
| 1408 |
Tix_DItemDisplay(drawable, None, chPtr->iPtr, |
| 1409 |
drawX, drawY, |
| 1410 |
wPtr->mainRB->dispSize[0][i].size, |
| 1411 |
wPtr->mainRB->dispSize[1][j].size, |
| 1412 |
TIX_DITEM_NORMAL_FG); |
| 1413 |
} |
| 1414 |
} |
| 1415 |
nextRow: |
| 1416 |
y+= wPtr->mainRB->dispSize[1][j].total; |
| 1417 |
} |
| 1418 |
nextCol: |
| 1419 |
x+= wPtr->mainRB->dispSize[0][i].total; |
| 1420 |
} |
| 1421 |
|
| 1422 |
for (i=0; i<wPtr->mainRB->size[0]; i++) { |
| 1423 |
for (j=0; j<wPtr->mainRB->size[1]; j++) { |
| 1424 |
chPtr = wPtr->mainRB->elms[i][j].chPtr; |
| 1425 |
if (chPtr != NULL) { |
| 1426 |
if (Tix_DItemType(chPtr->iPtr) == TIX_DITEM_WINDOW) { |
| 1427 |
|
| 1428 |
Tix_SetWindowItemSerial(&wPtr->mappedWindows, |
| 1429 |
chPtr->iPtr, wPtr->serial); |
| 1430 |
} |
| 1431 |
} |
| 1432 |
} |
| 1433 |
} |
| 1434 |
|
| 1435 |
|
| 1436 |
Tix_UnmapInvisibleWindowItems(&wPtr->mappedWindows, wPtr->serial); |
| 1437 |
} |
| 1438 |
|
| 1439 |
|
| 1440 |
|
| 1441 |
|
| 1442 |
|
| 1443 |
|
| 1444 |
|
| 1445 |
static void Tix_GrDrawSites(wPtr, riPtr, drawable) |
| 1446 |
WidgetPtr wPtr; |
| 1447 |
RenderInfo * riPtr; |
| 1448 |
Drawable drawable; |
| 1449 |
{ |
| 1450 |
int rect[2][2]; |
| 1451 |
int visible; |
| 1452 |
|
| 1453 |
visible = Tix_GrGetElementPosn(wPtr, wPtr->anchor[0], wPtr->anchor[1], |
| 1454 |
rect, 0, 1, 0, 0); |
| 1455 |
if (!visible) { |
| 1456 |
return; |
| 1457 |
} |
| 1458 |
|
| 1459 |
Tix_DrawAnchorLines(Tk_Display(wPtr->dispData.tkwin), drawable, |
| 1460 |
wPtr->anchorGC, |
| 1461 |
rect[0][0] + riPtr->origin[0], |
| 1462 |
rect[1][0] + riPtr->origin[1], |
| 1463 |
rect[0][1] - rect[0][0] + 1, |
| 1464 |
rect[1][1] - rect[1][0] + 1); |
| 1465 |
} |
| 1466 |
|
| 1467 |
|
| 1468 |
|
| 1469 |
|
| 1470 |
|
| 1471 |
|
| 1472 |
|
| 1473 |
|
| 1474 |
|
| 1475 |
|
| 1476 |
|
| 1477 |
|
| 1478 |
|
| 1479 |
|
| 1480 |
|
| 1481 |
|
| 1482 |
|
| 1483 |
|
| 1484 |
|
| 1485 |
|
| 1486 |
|
| 1487 |
|
| 1488 |
int |
| 1489 |
Tix_GrGetElementPosn(wPtr, x, y, rect, clipOK, isSite, isScr, nearest) |
| 1490 |
WidgetPtr wPtr; |
| 1491 |
int x; |
| 1492 |
int y; |
| 1493 |
int rect[2][2]; |
| 1494 |
int clipOK; |
| 1495 |
int isSite; |
| 1496 |
int isScr; |
| 1497 |
int nearest; |
| 1498 |
{ |
| 1499 |
int i, j, pos[2]; |
| 1500 |
int axis = 0; |
| 1501 |
int useAxis; |
| 1502 |
|
| 1503 |
if (wPtr->selectUnit == tixRowUid) { |
| 1504 |
axis = 0; |
| 1505 |
useAxis = 1; |
| 1506 |
} |
| 1507 |
else if (wPtr->selectUnit == tixColumnUid) { |
| 1508 |
axis = 1; |
| 1509 |
useAxis = 1; |
| 1510 |
} |
| 1511 |
else { |
| 1512 |
useAxis = 0; |
| 1513 |
} |
| 1514 |
|
| 1515 |
|
| 1516 |
|
| 1517 |
pos[0] = x; |
| 1518 |
pos[1] = y; |
| 1519 |
|
| 1520 |
|
| 1521 |
for (i=0; i<2; i++) { |
| 1522 |
if (pos[i] == TIX_SITE_NONE) { |
| 1523 |
return 0; |
| 1524 |
} |
| 1525 |
|
| 1526 |
if (isSite && useAxis && i == axis) { |
| 1527 |
rect[i][0] = 0; |
| 1528 |
rect[i][1] = wPtr->mainRB->visArea[i]-1; |
| 1529 |
} else { |
| 1530 |
if (pos[i] >= wPtr->hdrSize[i]) { |
| 1531 |
pos[i] -= wPtr->scrollInfo[i].offset; |
| 1532 |
if (pos[i] < wPtr->hdrSize[i]) { |
| 1533 |
|
| 1534 |
return 0; |
| 1535 |
} |
| 1536 |
} |
| 1537 |
|
| 1538 |
if (pos[i] < 0) { |
| 1539 |
if (!nearest) { |
| 1540 |
return 0; |
| 1541 |
} |
| 1542 |
pos[i] = 0; |
| 1543 |
} |
| 1544 |
if (pos[i] >= wPtr->mainRB->size[i]) { |
| 1545 |
if (!nearest) { |
| 1546 |
return 0; |
| 1547 |
} |
| 1548 |
pos[i] = wPtr->mainRB->size[i] - 1; |
| 1549 |
} |
| 1550 |
rect[i][0] = 0; |
| 1551 |
for (j=0; j<pos[i]; j++) { |
| 1552 |
rect[i][0] += wPtr->mainRB->dispSize[i][j].total; |
| 1553 |
} |
| 1554 |
rect[i][1] = rect[i][0] + wPtr->mainRB->dispSize[i][j].total - 1; |
| 1555 |
} |
| 1556 |
} |
| 1557 |
|
| 1558 |
if (isScr) { |
| 1559 |
rect[0][0] += wPtr->bdPad; |
| 1560 |
rect[1][0] += wPtr->bdPad; |
| 1561 |
rect[0][1] += wPtr->bdPad; |
| 1562 |
rect[1][1] += wPtr->bdPad; |
| 1563 |
} |
| 1564 |
|
| 1565 |
return 1; |
| 1566 |
} |
| 1567 |
|
| 1568 |
|
| 1569 |
|
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
|
| 1578 |
static int |
| 1579 |
Tix_GrBdType(clientData, interp, argc, argv) |
| 1580 |
ClientData clientData; |
| 1581 |
Tcl_Interp *interp; |
| 1582 |
int argc; |
| 1583 |
char **argv; |
| 1584 |
{ |
| 1585 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 1586 |
Tk_Window tkwin = wPtr->dispData.tkwin; |
| 1587 |
int i, k, screenPos[2], bd[2], pos[2], in[2], bdWidth[2]; |
| 1588 |
char buf[100]; |
| 1589 |
int inX = 0; |
| 1590 |
int inY = 0; |
| 1591 |
|
| 1592 |
if (argc != 2 && argc != 4) { |
| 1593 |
return Tix_ArgcError(interp, argc+2, argv-2, 2, |
| 1594 |
"x y ?xbdWidth ybdWidth?"); |
| 1595 |
} |
| 1596 |
|
| 1597 |
if (Tcl_GetIntFromObj(interp, argv[0], &screenPos[0]) != TCL_OK) { |
| 1598 |
return TCL_ERROR; |
| 1599 |
} |
| 1600 |
if (Tcl_GetIntFromObj(interp, argv[1], &screenPos[1]) != TCL_OK) { |
| 1601 |
return TCL_ERROR; |
| 1602 |
} |
| 1603 |
if (argc == 4) { |
| 1604 |
if (Tcl_GetIntFromObj(interp, argv[2], &bdWidth[0]) != TCL_OK) { |
| 1605 |
return TCL_ERROR; |
| 1606 |
} |
| 1607 |
if (Tcl_GetIntFromObj(interp, argv[3], &bdWidth[1]) != TCL_OK) { |
| 1608 |
return TCL_ERROR; |
| 1609 |
} |
| 1610 |
} else { |
| 1611 |
bdWidth[0] = -1; |
| 1612 |
bdWidth[1] = -1; |
| 1613 |
} |
| 1614 |
|
| 1615 |
if (!Tk_IsMapped(tkwin)) { |
| 1616 |
Tcl_ResetResult(interp); |
| 1617 |
return TCL_OK; |
| 1618 |
} |
| 1619 |
|
| 1620 |
if (wPtr->mainRB == NULL || wPtr->toResetRB) { |
| 1621 |
Tix_GrResetRenderBlocks(wPtr); |
| 1622 |
wPtr->toResetRB = 0; |
| 1623 |
} |
| 1624 |
|
| 1625 |
screenPos[0] -= wPtr->highlightWidth - wPtr->borderWidth; |
| 1626 |
screenPos[1] -= wPtr->highlightWidth - wPtr->borderWidth; |
| 1627 |
|
| 1628 |
for (i=0; i<2; i++) { |
| 1629 |
bd[i] = -1; |
| 1630 |
pos[i] = 0; |
| 1631 |
in[i] = 0; |
| 1632 |
for (k=0; k<wPtr->mainRB->size[i]; k++) { |
| 1633 |
ElmDispSize * elm = &wPtr->mainRB->dispSize[i][k]; |
| 1634 |
if (screenPos[i] - elm->total <= 0) { |
| 1635 |
if (bdWidth[i] != -1) { |
| 1636 |
if (screenPos[i] < bdWidth[i]) { |
| 1637 |
bd[i] = k - 1; |
| 1638 |
pos[i] = k; |
| 1639 |
} |
| 1640 |
else if ((elm->total - screenPos[i]) <= bdWidth[i]) { |
| 1641 |
bd[i] = k; |
| 1642 |
pos[i] = k + 1; |
| 1643 |
} |
| 1644 |
else { |
| 1645 |
pos[i] = k; |
| 1646 |
} |
| 1647 |
} else { |
| 1648 |
if (screenPos[i] < elm->preBorder) { |
| 1649 |
bd[i] = k - 1; |
| 1650 |
pos[i] = k; |
| 1651 |
} |
| 1652 |
else if ((screenPos[i] - elm->preBorder - elm->size)>= 0) { |
| 1653 |
bd[i] = k; |
| 1654 |
pos[i] = k + 1; |
| 1655 |
} |
| 1656 |
else { |
| 1657 |
pos[i] = k; |
| 1658 |
} |
| 1659 |
} |
| 1660 |
in[i] = k; |
| 1661 |
break; |
| 1662 |
} else { |
| 1663 |
screenPos[i] -= elm->total; |
| 1664 |
} |
| 1665 |
} |
| 1666 |
} |
| 1667 |
|
| 1668 |
if (in[0] < wPtr->hdrSize[0] && bd[1] >= 0) { |
| 1669 |
inY = 1; |
| 1670 |
} |
| 1671 |
else if (in[1] < wPtr->hdrSize[1] && bd[0] >= 0) { |
| 1672 |
inX = 1; |
| 1673 |
} |
| 1674 |
|
| 1675 |
if (bd[0] < 0) { |
| 1676 |
bd[0] = 0; |
| 1677 |
} |
| 1678 |
if (bd[1] < 0) { |
| 1679 |
bd[1] = 0; |
| 1680 |
} |
| 1681 |
|
| 1682 |
Tcl_ResetResult(interp); |
| 1683 |
if (inX && inY) { |
| 1684 |
Tcl_AppendElement(interp,"xy"); |
| 1685 |
Tcl_IntResults(interp,2,1, bd[0], bd[1]); |
| 1686 |
} else if (inX) { |
| 1687 |
Tcl_AppendElement(interp,"x"); |
| 1688 |
Tcl_IntResults(interp,2,1, bd[0], bd[1]); |
| 1689 |
} else if (inY) { |
| 1690 |
Tcl_AppendElement(interp,"y"); |
| 1691 |
Tcl_IntResults(interp,2,1, bd[0], bd[1]); |
| 1692 |
} else { |
| 1693 |
|
| 1694 |
} |
| 1695 |
return TCL_OK; |
| 1696 |
} |
| 1697 |
|
| 1698 |
|
| 1699 |
|
| 1700 |
|
| 1701 |
|
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
|
| 1706 |
|
| 1707 |
static int |
| 1708 |
Tix_GrSet(clientData, interp, argc, argv) |
| 1709 |
ClientData clientData; |
| 1710 |
Tcl_Interp *interp; |
| 1711 |
int argc; |
| 1712 |
char **argv; |
| 1713 |
{ |
| 1714 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 1715 |
TixGrEntry * chPtr = NULL; |
| 1716 |
Tix_DItem * iPtr; |
| 1717 |
int x, y; |
| 1718 |
char * ditemType; |
| 1719 |
int code = TCL_OK; |
| 1720 |
|
| 1721 |
|
| 1722 |
|
| 1723 |
|
| 1724 |
|
| 1725 |
if (TixGridDataGetIndex(interp, wPtr, objv[0], objv[1], &x, &y)!=TCL_OK) { |
| 1726 |
return TCL_ERROR; |
| 1727 |
} |
| 1728 |
|
| 1729 |
|
| 1730 |
|
| 1731 |
|
| 1732 |
|
| 1733 |
|
| 1734 |
ditemType = wPtr->diTypePtr->name; |
| 1735 |
if (argc > 2) { |
| 1736 |
size_t len; |
| 1737 |
int i; |
| 1738 |
if (argc %2 != 0) { |
| 1739 |
Tcl_AppendResult(interp, "value for \"", argv[argc-1], |
| 1740 |
"\" missing", NULL); |
| 1741 |
code = TCL_ERROR; |
| 1742 |
goto done; |
| 1743 |
} |
| 1744 |
for (i=2; i<argc; i+=2) { |
| 1745 |
len = strlen(argv[i]); |
| 1746 |
if (strncmp(argv[i], "-itemtype", len) == 0) { |
| 1747 |
ditemType = argv[i+1]; |
| 1748 |
} |
| 1749 |
} |
| 1750 |
} |
| 1751 |
|
| 1752 |
if (Tix_GetDItemType(interp, ditemType) == NULL) { |
| 1753 |
code = TCL_ERROR; |
| 1754 |
goto done; |
| 1755 |
} |
| 1756 |
|
| 1757 |
|
| 1758 |
|
| 1759 |
|
| 1760 |
|
| 1761 |
chPtr = Tix_GrFindCreateElem(interp, wPtr, x, y); |
| 1762 |
|
| 1763 |
|
| 1764 |
if ((iPtr = Tix_DItemCreate(&wPtr->dispData, ditemType)) == NULL) { |
| 1765 |
code = TCL_ERROR; |
| 1766 |
goto done; |
| 1767 |
} |
| 1768 |
iPtr->base.clientData = (ClientData)wPtr; |
| 1769 |
|
| 1770 |
if (chPtr->iPtr) { |
| 1771 |
Tix_DItemFree(chPtr->iPtr); |
| 1772 |
} |
| 1773 |
chPtr->iPtr = iPtr; |
| 1774 |
|
| 1775 |
if (ConfigElement(wPtr, chPtr, argc-2, argv+2, 0, 1) != TCL_OK) { |
| 1776 |
code = TCL_ERROR; goto done; |
| 1777 |
} |
| 1778 |
Tix_GrPropagateSize(wPtr, chPtr); |
| 1779 |
|
| 1780 |
done: |
| 1781 |
if (code == TCL_ERROR) { |
| 1782 |
|
| 1783 |
} else { |
| 1784 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_RESIZE); |
| 1785 |
} |
| 1786 |
|
| 1787 |
return code; |
| 1788 |
} |
| 1789 |
|
| 1790 |
|
| 1791 |
|
| 1792 |
|
| 1793 |
|
| 1794 |
|
| 1795 |
static int |
| 1796 |
Tix_GrUnset(clientData, interp, argc, argv) |
| 1797 |
ClientData clientData; |
| 1798 |
Tcl_Interp *interp; |
| 1799 |
int argc; |
| 1800 |
char **argv; |
| 1801 |
{ |
| 1802 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 1803 |
TixGrEntry * chPtr; |
| 1804 |
int x, y; |
| 1805 |
|
| 1806 |
if (TixGridDataGetIndex(interp, wPtr, objv[0], objv[1], &x, &y) |
| 1807 |
!=TCL_OK) { |
| 1808 |
return TCL_ERROR; |
| 1809 |
} |
| 1810 |
|
| 1811 |
chPtr = Tix_GrFindElem(interp, wPtr, x, y); |
| 1812 |
if (chPtr != NULL) { |
| 1813 |
TixGridDataDeleteEntry(wPtr->dataSet, x, y); |
| 1814 |
Tix_GrFreeElem(chPtr); |
| 1815 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_RESIZE); |
| 1816 |
} |
| 1817 |
return TCL_OK; |
| 1818 |
} |
| 1819 |
|
| 1820 |
|
| 1821 |
|
| 1822 |
|
| 1823 |
|
| 1824 |
static int |
| 1825 |
Tix_GrCGet(clientData, interp, argc, argv) |
| 1826 |
ClientData clientData; |
| 1827 |
Tcl_Interp *interp; |
| 1828 |
int argc; |
| 1829 |
char **argv; |
| 1830 |
{ |
| 1831 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 1832 |
|
| 1833 |
return Tk_ConfigureValue(interp, wPtr->dispData.tkwin, configSpecs, |
| 1834 |
(char *)wPtr, argv[0], 0); |
| 1835 |
} |
| 1836 |
|
| 1837 |
|
| 1838 |
|
| 1839 |
|
| 1840 |
|
| 1841 |
static int |
| 1842 |
Tix_GrConfig(clientData, interp, argc, argv) |
| 1843 |
ClientData clientData; |
| 1844 |
Tcl_Interp *interp; |
| 1845 |
int argc; |
| 1846 |
char **argv; |
| 1847 |
{ |
| 1848 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 1849 |
|
| 1850 |
if (argc == 0) { |
| 1851 |
return Tk_ConfigureInfo(interp, wPtr->dispData.tkwin, configSpecs, |
| 1852 |
(char *) wPtr, (char *) NULL, 0); |
| 1853 |
} else if (argc == 1) { |
| 1854 |
return Tk_ConfigureInfo(interp, wPtr->dispData.tkwin, configSpecs, |
| 1855 |
(char *) wPtr, argv[0], 0); |
| 1856 |
} else { |
| 1857 |
return WidgetConfigure(interp, wPtr, argc, argv, |
| 1858 |
TK_CONFIG_ARGV_ONLY); |
| 1859 |
} |
| 1860 |
} |
| 1861 |
|
| 1862 |
|
| 1863 |
|
| 1864 |
|
| 1865 |
|
| 1866 |
static int |
| 1867 |
Tix_GrDelete(clientData, interp, argc, argv) |
| 1868 |
ClientData clientData; |
| 1869 |
Tcl_Interp *interp; |
| 1870 |
int argc; |
| 1871 |
char **argv; |
| 1872 |
{ |
| 1873 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 1874 |
int from, to, which; |
| 1875 |
|
| 1876 |
if (TranslateFromTo(interp, wPtr, argc, argv, &from, &to, &which)!=TCL_OK){ |
| 1877 |
return TCL_ERROR; |
| 1878 |
} |
| 1879 |
TixGridDataDeleteRange(wPtr, wPtr->dataSet, which, from, to); |
| 1880 |
|
| 1881 |
return TCL_OK; |
| 1882 |
} |
| 1883 |
|
| 1884 |
|
| 1885 |
|
| 1886 |
|
| 1887 |
|
| 1888 |
static int |
| 1889 |
Tix_GrEdit(clientData, interp, argc, argv) |
| 1890 |
ClientData clientData; |
| 1891 |
Tcl_Interp *interp; |
| 1892 |
int argc; |
| 1893 |
Tcl_Obj *CONST *objv; |
| 1894 |
{ |
| 1895 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 1896 |
int x, y; |
| 1897 |
char buff[20]; |
| 1898 |
int len; |
| 1899 |
int code = TCL_OK; |
| 1900 |
Tcl_Obj *obj = NULL; |
| 1901 |
|
| 1902 |
|
| 1903 |
len = strlen(argv[0]); |
| 1904 |
if (strncmp(argv[0], "set", len) == 0) { |
| 1905 |
if (argc != 3) { |
| 1906 |
Tcl_AppendResult(interp, "wrong # of arguments, must be: ", |
| 1907 |
argv[-2], " edit set x y", NULL); |
| 1908 |
} |
| 1909 |
if (TixGridDataGetIndex(interp, wPtr, objv[1], objv[2], &x, &y) |
| 1910 |
!=TCL_OK) { |
| 1911 |
return TCL_ERROR; |
| 1912 |
} |
| 1913 |
obj = LangWidgetObj(interp,wPtr->dispData.tkwin); |
| 1914 |
code = LangMethodCall(interp,obj, "EditCell",0, 2," %d %d",x, y); |
| 1915 |
} else if (strncmp(argv[0], "apply", len) == 0) { |
| 1916 |
if (argc != 1) { |
| 1917 |
Tcl_AppendResult(interp, "wrong # of arguments, must be: ", |
| 1918 |
argv[-2], " edit apply", NULL); |
| 1919 |
} |
| 1920 |
obj = LangWidgetObj(interp,wPtr->dispData.tkwin); |
| 1921 |
code = LangMethodCall(interp,obj, "EditApply",0, 0); |
| 1922 |
} else { |
| 1923 |
Tcl_AppendResult(interp, "unknown option \"", argv[0], |
| 1924 |
"\", must be apply or set", NULL); |
| 1925 |
return TCL_ERROR; |
| 1926 |
} |
| 1927 |
if (obj) { |
| 1928 |
Tcl_DecrRefCount(obj); |
| 1929 |
} |
| 1930 |
return code; |
| 1931 |
} |
| 1932 |
|
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
|
| 1937 |
static int |
| 1938 |
Tix_GrEntryCget(clientData, interp, argc, argv) |
| 1939 |
ClientData clientData; |
| 1940 |
Tcl_Interp *interp; |
| 1941 |
int argc; |
| 1942 |
char **argv; |
| 1943 |
{ |
| 1944 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 1945 |
int x, y; |
| 1946 |
TixGrEntry * chPtr; |
| 1947 |
|
| 1948 |
if (TixGridDataGetIndex(interp, wPtr, objv[0], objv[1], &x, &y)!=TCL_OK) { |
| 1949 |
return TCL_ERROR; |
| 1950 |
} |
| 1951 |
|
| 1952 |
chPtr = Tix_GrFindElem(interp, wPtr, x, y); |
| 1953 |
if (!chPtr) { |
| 1954 |
Tcl_AppendResult(interp, "entry \"", argv[0], ",", argv[1], |
| 1955 |
"\" does not exist", NULL); |
| 1956 |
return TCL_ERROR; |
| 1957 |
} |
| 1958 |
|
| 1959 |
return Tix_ConfigureValue2(interp, wPtr->dispData.tkwin, (char *)chPtr, |
| 1960 |
entryConfigSpecs, chPtr->iPtr, argv[2], 0); |
| 1961 |
} |
| 1962 |
|
| 1963 |
|
| 1964 |
|
| 1965 |
|
| 1966 |
|
| 1967 |
static int |
| 1968 |
Tix_GrEntryConfig(clientData, interp, argc, argv) |
| 1969 |
ClientData clientData; |
| 1970 |
Tcl_Interp *interp; |
| 1971 |
int argc; |
| 1972 |
char **argv; |
| 1973 |
{ |
| 1974 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 1975 |
int x, y; |
| 1976 |
TixGrEntry * chPtr; |
| 1977 |
|
| 1978 |
if (TixGridDataGetIndex(interp, wPtr, objv[0], objv[1], &x, &y)!=TCL_OK) { |
| 1979 |
return TCL_ERROR; |
| 1980 |
} |
| 1981 |
|
| 1982 |
chPtr = Tix_GrFindElem(interp, wPtr, x, y); |
| 1983 |
if (!chPtr) { |
| 1984 |
Tcl_AppendResult(interp, "entry \"", argv[0], ",", argv[1], |
| 1985 |
"\" does not exist", NULL); |
| 1986 |
return TCL_ERROR; |
| 1987 |
} |
| 1988 |
|
| 1989 |
if (argc == 2) { |
| 1990 |
return Tix_ConfigureInfo2(interp, wPtr->dispData.tkwin, |
| 1991 |
(char*)chPtr, entryConfigSpecs, chPtr->iPtr, (char *) NULL, 0); |
| 1992 |
} else if (argc == 3) { |
| 1993 |
return Tix_ConfigureInfo2(interp, wPtr->dispData.tkwin, |
| 1994 |
(char*)chPtr, entryConfigSpecs, chPtr->iPtr, (char *) argv[2], 0); |
| 1995 |
} else { |
| 1996 |
return ConfigElement(wPtr, chPtr, argc-2, argv+2, |
| 1997 |
TK_CONFIG_ARGV_ONLY, 0); |
| 1998 |
} |
| 1999 |
} |
| 2000 |
|
| 2001 |
|
| 2002 |
|
| 2003 |
|
| 2004 |
|
| 2005 |
static int |
| 2006 |
Tix_GrGeometryInfo(clientData, interp, argc, argv) |
| 2007 |
ClientData clientData; |
| 2008 |
Tcl_Interp *interp; |
| 2009 |
int argc; |
| 2010 |
char **argv; |
| 2011 |
{ |
| 2012 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 2013 |
int qSize[2]; |
| 2014 |
double first[2], last[2]; |
| 2015 |
int i; |
| 2016 |
Tix_GridScrollInfo scrollInfo[2]; |
| 2017 |
|
| 2018 |
if (argc == 2) { |
| 2019 |
if (Tcl_GetIntFromObj(interp, argv[0], &qSize[0]) != TCL_OK) { |
| 2020 |
return TCL_ERROR; |
| 2021 |
} |
| 2022 |
if (Tcl_GetIntFromObj(interp, argv[1], &qSize[1]) != TCL_OK) { |
| 2023 |
return TCL_ERROR; |
| 2024 |
} |
| 2025 |
} else { |
| 2026 |
qSize[0] = Tk_Width (wPtr->dispData.tkwin); |
| 2027 |
qSize[1] = Tk_Height(wPtr->dispData.tkwin); |
| 2028 |
} |
| 2029 |
qSize[0] -= 2*wPtr->borderWidth + 2*wPtr->highlightWidth; |
| 2030 |
qSize[1] -= 2*wPtr->borderWidth + 2*wPtr->highlightWidth; |
| 2031 |
|
| 2032 |
RecalScrollRegion(wPtr, qSize[0], qSize[1], scrollInfo); |
| 2033 |
|
| 2034 |
for (i=0; i<2; i++) { |
| 2035 |
qSize[i] -= 2*wPtr->borderWidth + 2*wPtr->highlightWidth; |
| 2036 |
GetScrollFractions(wPtr, &scrollInfo[i], |
| 2037 |
&first[i], &last[i]); |
| 2038 |
} |
| 2039 |
|
| 2040 |
Tcl_DoubleResults(interp,1,4,"{%f %f} {%f %f}", first[0], last[0], first[1], last[1]); |
| 2041 |
return TCL_OK; |
| 2042 |
} |
| 2043 |
|
| 2044 |
|
| 2045 |
|
| 2046 |
|
| 2047 |
|
| 2048 |
static int |
| 2049 |
Tix_GrIndex(clientData, interp, argc, argv) |
| 2050 |
ClientData clientData; |
| 2051 |
Tcl_Interp *interp; |
| 2052 |
int argc; |
| 2053 |
char **argv; |
| 2054 |
{ |
| 2055 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 2056 |
int x, y; |
| 2057 |
|
| 2058 |
if (TixGridDataGetIndex(interp, wPtr, objv[0], objv[1], &x, &y)!=TCL_OK) { |
| 2059 |
return TCL_ERROR; |
| 2060 |
} |
| 2061 |
Tcl_IntResults(interp,2,0, x, y); |
| 2062 |
return TCL_OK; |
| 2063 |
} |
| 2064 |
|
| 2065 |
|
| 2066 |
|
| 2067 |
|
| 2068 |
|
| 2069 |
static int |
| 2070 |
Tix_GrInfo(clientData, interp, argc, argv) |
| 2071 |
ClientData clientData; |
| 2072 |
Tcl_Interp *interp; |
| 2073 |
int argc; |
| 2074 |
char **argv; |
| 2075 |
{ |
| 2076 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 2077 |
size_t len = strlen(argv[0]); |
| 2078 |
int x, y; |
| 2079 |
|
| 2080 |
if (strncmp(argv[0], "bbox", len)==0) { |
| 2081 |
if (argc != 3) { |
| 2082 |
return Tix_ArgcError(interp, argc+2, argv-2, 3, "x y"); |
| 2083 |
} |
| 2084 |
if (TixGridDataGetIndex(interp, wPtr, objv[1], objv[2], &x, &y) |
| 2085 |
!=TCL_OK) { |
| 2086 |
return TCL_ERROR; |
| 2087 |
} |
| 2088 |
|
| 2089 |
return Tix_GrBBox(interp, wPtr, x, y); |
| 2090 |
} |
| 2091 |
else if (strncmp(argv[0], "exists", len)==0) { |
| 2092 |
if (argc != 3) { |
| 2093 |
return Tix_ArgcError(interp, argc+2, argv-2, 3, "x y"); |
| 2094 |
} |
| 2095 |
if (TixGridDataGetIndex(interp, wPtr, objv[1], objv[2], &x, &y) |
| 2096 |
!=TCL_OK) { |
| 2097 |
return TCL_ERROR; |
| 2098 |
} |
| 2099 |
if (Tix_GrFindElem(interp, wPtr, x, y)) { |
| 2100 |
Tcl_SetResult(interp, "1", TCL_STATIC); |
| 2101 |
} else { |
| 2102 |
Tcl_SetResult(interp, "0", TCL_STATIC); |
| 2103 |
} |
| 2104 |
return TCL_OK; |
| 2105 |
} |
| 2106 |
else { |
| 2107 |
Tcl_AppendResult(interp, "unknown option \"", argv[0], |
| 2108 |
"\": must be bbox or exists", |
| 2109 |
NULL); |
| 2110 |
return TCL_ERROR; |
| 2111 |
} |
| 2112 |
} |
| 2113 |
|
| 2114 |
|
| 2115 |
|
| 2116 |
|
| 2117 |
|
| 2118 |
static int |
| 2119 |
Tix_GrMove(clientData, interp, argc, argv) |
| 2120 |
ClientData clientData; |
| 2121 |
Tcl_Interp *interp; |
| 2122 |
int argc; |
| 2123 |
char **argv; |
| 2124 |
{ |
| 2125 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 2126 |
int from, to, which, by; |
| 2127 |
|
| 2128 |
if (TranslateFromTo(interp, wPtr, 3, argv, &from, &to, &which)!=TCL_OK){ |
| 2129 |
return TCL_ERROR; |
| 2130 |
} |
| 2131 |
if (Tcl_GetIntFromObj(interp, argv[3], &by) != TCL_OK) { |
| 2132 |
return TCL_ERROR; |
| 2133 |
} |
| 2134 |
|
| 2135 |
TixGridDataMoveRange(wPtr, wPtr->dataSet, which, from, to, by); |
| 2136 |
|
| 2137 |
return TCL_OK; |
| 2138 |
} |
| 2139 |
|
| 2140 |
|
| 2141 |
|
| 2142 |
|
| 2143 |
|
| 2144 |
static int |
| 2145 |
Tix_GrNearest(clientData, interp, argc, argv) |
| 2146 |
ClientData clientData; |
| 2147 |
Tcl_Interp *interp; |
| 2148 |
int argc; |
| 2149 |
char **argv; |
| 2150 |
{ |
| 2151 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 2152 |
Tk_Window tkwin = wPtr->dispData.tkwin; |
| 2153 |
int i, k, screenPos[2], rbPos[2]; |
| 2154 |
char buf[100]; |
| 2155 |
RenderBlockElem* rePtr; |
| 2156 |
|
| 2157 |
if (Tcl_GetIntFromObj(interp, argv[0], &screenPos[0]) != TCL_OK) { |
| 2158 |
return TCL_ERROR; |
| 2159 |
} |
| 2160 |
if (Tcl_GetIntFromObj(interp, argv[1], &screenPos[1]) != TCL_OK) { |
| 2161 |
return TCL_ERROR; |
| 2162 |
} |
| 2163 |
|
| 2164 |
if (!Tk_IsMapped(tkwin)) { |
| 2165 |
Tcl_ResetResult(interp); |
| 2166 |
return TCL_OK; |
| 2167 |
} |
| 2168 |
|
| 2169 |
if (wPtr->mainRB == NULL || wPtr->toResetRB) { |
| 2170 |
Tix_GrResetRenderBlocks(wPtr); |
| 2171 |
wPtr->toResetRB = 0; |
| 2172 |
} |
| 2173 |
|
| 2174 |
screenPos[0] -= wPtr->highlightWidth - wPtr->borderWidth; |
| 2175 |
screenPos[1] -= wPtr->highlightWidth - wPtr->borderWidth; |
| 2176 |
|
| 2177 |
for (i=0; i<2; i++) { |
| 2178 |
for (k=0; k<wPtr->mainRB->size[i]; k++) { |
| 2179 |
screenPos[i] -= wPtr->mainRB->dispSize[i][k].total; |
| 2180 |
if (screenPos[i]<=0) { |
| 2181 |
break; |
| 2182 |
} |
| 2183 |
} |
| 2184 |
if (k >= wPtr->mainRB->size[i]) { |
| 2185 |
k = wPtr->mainRB->size[i] - 1; |
| 2186 |
} |
| 2187 |
rbPos[i] = k; |
| 2188 |
} |
| 2189 |
rePtr = &(wPtr->mainRB->elms[rbPos[0]][rbPos[1]]); |
| 2190 |
|
| 2191 |
Tcl_IntResults(interp, 2, 0, rePtr->index[0], rePtr->index[1]); |
| 2192 |
return TCL_OK; |
| 2193 |
} |
| 2194 |
|
| 2195 |
|
| 2196 |
|
| 2197 |
|
| 2198 |
|
| 2199 |
|
| 2200 |
|
| 2201 |
static int |
| 2202 |
Tix_GrSetSite(clientData, interp, argc, argv) |
| 2203 |
ClientData clientData; |
| 2204 |
Tcl_Interp *interp; |
| 2205 |
int argc; |
| 2206 |
char **argv; |
| 2207 |
{ |
| 2208 |
int changed = 0; |
| 2209 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 2210 |
int * changePtr; |
| 2211 |
size_t len; |
| 2212 |
int changedRect[2][2]; |
| 2213 |
|
| 2214 |
|
| 2215 |
|
| 2216 |
|
| 2217 |
|
| 2218 |
|
| 2219 |
len = strlen(argv[-1]); |
| 2220 |
if (strncmp(argv[-1], "anchor", len)==0) { |
| 2221 |
changePtr = wPtr->anchor; |
| 2222 |
} |
| 2223 |
else if (strncmp(argv[-1], "dragsite", len)==0) { |
| 2224 |
changePtr = wPtr->dragSite; |
| 2225 |
} |
| 2226 |
else { |
| 2227 |
changePtr = wPtr->dropSite; |
| 2228 |
} |
| 2229 |
|
| 2230 |
len = strlen(argv[0]); |
| 2231 |
if (strncmp(argv[0], "get", len)==0) { |
| 2232 |
Tcl_IntResults(interp, 2, 0, changePtr[0], changePtr[1]); |
| 2233 |
return TCL_OK; |
| 2234 |
} else if (strncmp(argv[0], "set", len)==0) { |
| 2235 |
if (argc == 3) { |
| 2236 |
int x, y; |
| 2237 |
|
| 2238 |
if (TixGridDataGetIndex(interp, wPtr, objv[1], objv[2], |
| 2239 |
&x, &y)!=TCL_OK) { |
| 2240 |
return TCL_ERROR; |
| 2241 |
} |
| 2242 |
if (x != changePtr[0] || y != changePtr[1]) { |
| 2243 |
changedRect[0][0] = x; |
| 2244 |
changedRect[1][0] = y; |
| 2245 |
changedRect[0][1] = changePtr[0]; |
| 2246 |
changedRect[1][1] = changePtr[1]; |
| 2247 |
changed = 1; |
| 2248 |
|
| 2249 |
changePtr[0] = x; |
| 2250 |
changePtr[1] = y; |
| 2251 |
} |
| 2252 |
} else { |
| 2253 |
Tcl_AppendResult(interp, "wrong # of arguments, must be: ", |
| 2254 |
Tk_PathName(wPtr->dispData.tkwin), " ", argv[-1], |
| 2255 |
" set x y", NULL); |
| 2256 |
return TCL_ERROR; |
| 2257 |
} |
| 2258 |
} |
| 2259 |
else if (strncmp(argv[0], "clear", len)==0) { |
| 2260 |
if (argc == 1) { |
| 2261 |
if (changePtr[0] !=TIX_SITE_NONE || changePtr[1] !=TIX_SITE_NONE) { |
| 2262 |
changedRect[0][0] = TIX_SITE_NONE; |
| 2263 |
changedRect[1][0] = TIX_SITE_NONE; |
| 2264 |
changedRect[0][1] = changePtr[0]; |
| 2265 |
changedRect[1][1] = changePtr[1]; |
| 2266 |
changed = 1; |
| 2267 |
|
| 2268 |
changePtr[0] = TIX_SITE_NONE; |
| 2269 |
changePtr[1] = TIX_SITE_NONE; |
| 2270 |
} |
| 2271 |
} else { |
| 2272 |
Tcl_AppendResult(interp, "wrong # of arguments, must be: ", |
| 2273 |
Tk_PathName(wPtr->dispData.tkwin), " ", argv[-1], |
| 2274 |
" clear", NULL); |
| 2275 |
return TCL_ERROR; |
| 2276 |
} |
| 2277 |
} |
| 2278 |
else { |
| 2279 |
Tcl_AppendResult(interp, "wrong option \"", argv[0], "\", ", |
| 2280 |
"must be clear, get or set", NULL); |
| 2281 |
return TCL_ERROR; |
| 2282 |
} |
| 2283 |
|
| 2284 |
if (changed) { |
| 2285 |
Tix_GrAddChangedRect(wPtr, changedRect, 1); |
| 2286 |
} |
| 2287 |
|
| 2288 |
return TCL_OK; |
| 2289 |
} |
| 2290 |
|
| 2291 |
|
| 2292 |
|
| 2293 |
|
| 2294 |
|
| 2295 |
|
| 2296 |
|
| 2297 |
void |
| 2298 |
Tix_GrAddChangedRect(wPtr, changedRect, isSite) |
| 2299 |
WidgetPtr wPtr; |
| 2300 |
int changedRect[2][2]; |
| 2301 |
int isSite; |
| 2302 |
{ |
| 2303 |
int rect[2][2]; |
| 2304 |
int visible; |
| 2305 |
int i; |
| 2306 |
int changed = 0; |
| 2307 |
|
| 2308 |
if (wPtr->mainRB == NULL) { |
| 2309 |
|
| 2310 |
|
| 2311 |
|
| 2312 |
return; |
| 2313 |
} |
| 2314 |
|
| 2315 |
for (i=0; i<2; i++) { |
| 2316 |
visible = Tix_GrGetElementPosn(wPtr, changedRect[0][i], |
| 2317 |
changedRect[1][i], rect, 1, isSite, 1, 1); |
| 2318 |
if (!visible) { |
| 2319 |
continue; |
| 2320 |
} |
| 2321 |
if (wPtr->expArea.x1 > rect[0][0]) { |
| 2322 |
wPtr->expArea.x1 = rect[0][0]; |
| 2323 |
changed = 1; |
| 2324 |
} |
| 2325 |
if (wPtr->expArea.x2 < rect[0][1]) { |
| 2326 |
wPtr->expArea.x2 = rect[0][1]; |
| 2327 |
changed = 1; |
| 2328 |
} |
| 2329 |
if (wPtr->expArea.y1 > rect[1][0]) { |
| 2330 |
wPtr->expArea.y1 = rect[1][0]; |
| 2331 |
changed = 1; |
| 2332 |
} |
| 2333 |
if (wPtr->expArea.y2 < rect[1][1]) { |
| 2334 |
wPtr->expArea.y2 = rect[1][1]; |
| 2335 |
changed = 1; |
| 2336 |
} |
| 2337 |
} |
| 2338 |
if (changed) { |
| 2339 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_REDRAW); |
| 2340 |
} |
| 2341 |
} |
| 2342 |
|
| 2343 |
void Tix_GrScrollPage(wPtr, count, axis) |
| 2344 |
WidgetPtr wPtr; |
| 2345 |
int count; |
| 2346 |
int axis; |
| 2347 |
{ |
| 2348 |
int k, i = axis; |
| 2349 |
int winSize, sz, start, num; |
| 2350 |
int pad0, pad1; |
| 2351 |
|
| 2352 |
Tix_GridScrollInfo * siPtr = &wPtr->scrollInfo[axis]; |
| 2353 |
int gridSize[2]; |
| 2354 |
|
| 2355 |
if (count == 0) { |
| 2356 |
return; |
| 2357 |
} |
| 2358 |
|
| 2359 |
TixGridDataGetGridSize(wPtr->dataSet, &gridSize[0], |
| 2360 |
&gridSize[1]); |
| 2361 |
|
| 2362 |
if (gridSize[i] < wPtr->hdrSize[i]) { |
| 2363 |
return; |
| 2364 |
} |
| 2365 |
|
| 2366 |
if (axis == 0) { |
| 2367 |
winSize = Tk_Width(wPtr->dispData.tkwin); |
| 2368 |
} else { |
| 2369 |
winSize = Tk_Height(wPtr->dispData.tkwin); |
| 2370 |
} |
| 2371 |
winSize -= 2*wPtr->highlightWidth + 2*wPtr->borderWidth; |
| 2372 |
|
| 2373 |
for (k=0; k<wPtr->hdrSize[i] && k<gridSize[i]; k++) { |
| 2374 |
winSize -= TixGridDataGetRowColSize(wPtr, wPtr->dataSet, i, |
| 2375 |
k, &wPtr->defSize[i], &pad0, &pad1); |
| 2376 |
winSize -= pad0 + pad1; |
| 2377 |
} |
| 2378 |
|
| 2379 |
if (winSize <= 0) { |
| 2380 |
return; |
| 2381 |
} |
| 2382 |
|
| 2383 |
if (count > 0) { |
| 2384 |
start = siPtr->offset + wPtr->hdrSize[i]; |
| 2385 |
for (; count > 0; count--) { |
| 2386 |
sz = winSize; |
| 2387 |
|
| 2388 |
for (num=0,k=start; k<gridSize[i]; k++,num++) { |
| 2389 |
sz -= TixGridDataGetRowColSize(wPtr, wPtr->dataSet, i, |
| 2390 |
k, &wPtr->defSize[i], &pad0, &pad1); |
| 2391 |
sz -= pad0 + pad1; |
| 2392 |
if (sz == 0) { |
| 2393 |
num++; |
| 2394 |
break; |
| 2395 |
} |
| 2396 |
if (sz < 0) { |
| 2397 |
break; |
| 2398 |
} |
| 2399 |
} |
| 2400 |
if (num==0) { |
| 2401 |
num++; |
| 2402 |
} |
| 2403 |
start += num; |
| 2404 |
} |
| 2405 |
siPtr->offset = start - wPtr->hdrSize[i]; |
| 2406 |
} |
| 2407 |
else { |
| 2408 |
start = siPtr->offset + wPtr->hdrSize[i]; |
| 2409 |
|
| 2410 |
for (; count < 0; count++) { |
| 2411 |
sz = winSize; |
| 2412 |
|
| 2413 |
for (num=0,k=start-1; k>=wPtr->hdrSize[i]; k--,num++) { |
| 2414 |
sz -= TixGridDataGetRowColSize(wPtr, wPtr->dataSet, i, |
| 2415 |
k, &wPtr->defSize[i], &pad0, &pad1); |
| 2416 |
sz -= pad0 + pad1; |
| 2417 |
if (sz == 0) { |
| 2418 |
num++; |
| 2419 |
break; |
| 2420 |
} |
| 2421 |
if (sz < 0) { |
| 2422 |
break; |
| 2423 |
} |
| 2424 |
} |
| 2425 |
if (num==0) { |
| 2426 |
num++; |
| 2427 |
} |
| 2428 |
start -= num; |
| 2429 |
} |
| 2430 |
siPtr->offset = start - wPtr->hdrSize[i]; |
| 2431 |
} |
| 2432 |
} |
| 2433 |
|
| 2434 |
|
| 2435 |
|
| 2436 |
|
| 2437 |
|
| 2438 |
static int |
| 2439 |
Tix_GrSee(clientData, interp, argc, argv) |
| 2440 |
ClientData clientData; |
| 2441 |
Tcl_Interp *interp; |
| 2442 |
int argc; |
| 2443 |
char **argv; |
| 2444 |
{ |
| 2445 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 2446 |
int x, y; |
| 2447 |
int code = TCL_OK; |
| 2448 |
int oldXOff, oldYOff, lim; |
| 2449 |
|
| 2450 |
oldXOff = wPtr->scrollInfo[0].offset; |
| 2451 |
oldYOff = wPtr->scrollInfo[1].offset; |
| 2452 |
|
| 2453 |
if (TixGridDataGetIndex(interp, wPtr, objv[0], objv[1], &x, &y)!=TCL_OK) { |
| 2454 |
return TCL_ERROR; |
| 2455 |
} |
| 2456 |
|
| 2457 |
x -= wPtr->hdrSize[0]; |
| 2458 |
if (x >= wPtr->scrollInfo[0].max) { |
| 2459 |
x = wPtr->scrollInfo[0].max -1; |
| 2460 |
} |
| 2461 |
if (x < 0) { |
| 2462 |
x = 0; |
| 2463 |
} |
| 2464 |
lim = wPtr->scrollInfo[0].offset + (int)(wPtr->scrollInfo[0].window * wPtr->scrollInfo[0].max); |
| 2465 |
|
| 2466 |
if (x < wPtr->scrollInfo[0].offset || (x+1) > lim) { |
| 2467 |
wPtr->scrollInfo[0].offset = x; |
| 2468 |
} |
| 2469 |
|
| 2470 |
y -= wPtr->hdrSize[1]; |
| 2471 |
if (y >= wPtr->scrollInfo[1].max) { |
| 2472 |
y = wPtr->scrollInfo[1].max -1; |
| 2473 |
} |
| 2474 |
if (y < 0) { |
| 2475 |
y = 0; |
| 2476 |
} |
| 2477 |
lim = wPtr->scrollInfo[1].offset + (int)(wPtr->scrollInfo[1].window * wPtr->scrollInfo[1].max); |
| 2478 |
|
| 2479 |
if (y < wPtr->scrollInfo[1].offset || (y+1) > lim) { |
| 2480 |
wPtr->scrollInfo[1].offset = y; |
| 2481 |
} |
| 2482 |
|
| 2483 |
if (oldXOff != wPtr->scrollInfo[0].offset || |
| 2484 |
oldYOff != wPtr->scrollInfo[1].offset) { |
| 2485 |
wPtr->toResetRB = 1; |
| 2486 |
wPtr->toComputeSel = 1; |
| 2487 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_REDRAW); |
| 2488 |
} |
| 2489 |
|
| 2490 |
return code; |
| 2491 |
} |
| 2492 |
|
| 2493 |
|
| 2494 |
|
| 2495 |
|
| 2496 |
|
| 2497 |
static int |
| 2498 |
Tix_GrView(clientData, interp, argc, argv) |
| 2499 |
ClientData clientData; |
| 2500 |
Tcl_Interp *interp; |
| 2501 |
int argc; |
| 2502 |
char **argv; |
| 2503 |
{ |
| 2504 |
WidgetPtr wPtr = (WidgetPtr) clientData; |
| 2505 |
int axis, oldXOff, oldYOff; |
| 2506 |
Tix_GridScrollInfo * siPtr; |
| 2507 |
|
| 2508 |
if (argv[-1][0] == 'x') { |
| 2509 |
axis = 0; |
| 2510 |
} else { |
| 2511 |
axis = 1; |
| 2512 |
} |
| 2513 |
|
| 2514 |
oldXOff = wPtr->scrollInfo[0].offset; |
| 2515 |
oldYOff = wPtr->scrollInfo[1].offset; |
| 2516 |
|
| 2517 |
if (argc == 0) { |
| 2518 |
char string[100]; |
| 2519 |
double first, last; |
| 2520 |
|
| 2521 |
GetScrollFractions(wPtr, &wPtr->scrollInfo[axis], &first, &last); |
| 2522 |
Tcl_DoubleResults(interp,0,2,"%f %f",first, last); |
| 2523 |
return TCL_OK; |
| 2524 |
} |
| 2525 |
else { |
| 2526 |
int offset; |
| 2527 |
siPtr = &wPtr->scrollInfo[axis]; |
| 2528 |
|
| 2529 |
if (Tcl_GetIntFromObj(interp, argv[0], &offset) == TCL_OK) { |
| 2530 |
|
| 2531 |
siPtr->offset = offset; |
| 2532 |
} else { |
| 2533 |
int type, count; |
| 2534 |
double fraction; |
| 2535 |
|
| 2536 |
Tcl_ResetResult(interp); |
| 2537 |
|
| 2538 |
|
| 2539 |
type = Tk_GetScrollInfo(interp, argc+2, argv-2, &fraction, &count); |
| 2540 |
|
| 2541 |
switch (type) { |
| 2542 |
case TK_SCROLL_ERROR: |
| 2543 |
return TCL_ERROR; |
| 2544 |
|
| 2545 |
case TK_SCROLL_MOVETO: |
| 2546 |
if (siPtr->window < 1.0) { |
| 2547 |
fraction /= (1.0 - siPtr->window); |
| 2548 |
} |
| 2549 |
|
| 2550 |
siPtr->offset = (int)(fraction * (siPtr->max+1)); |
| 2551 |
break; |
| 2552 |
|
| 2553 |
case TK_SCROLL_PAGES: |
| 2554 |
Tix_GrScrollPage(wPtr, count, axis); |
| 2555 |
break; |
| 2556 |
|
| 2557 |
case TK_SCROLL_UNITS: |
| 2558 |
siPtr->offset += count * siPtr->unit; |
| 2559 |
break; |
| 2560 |
} |
| 2561 |
} |
| 2562 |
|
| 2563 |
if (siPtr->offset < 0) { |
| 2564 |
siPtr->offset = 0; |
| 2565 |
} |
| 2566 |
if (siPtr->offset > siPtr->max) { |
| 2567 |
siPtr->offset = siPtr->max; |
| 2568 |
} |
| 2569 |
} |
| 2570 |
|
| 2571 |
#if 0 |
| 2572 |
printf("Configing Scrollbars: (%d %f %d) (%d %f %d)\n", |
| 2573 |
wPtr->scrollInfo[0].max, |
| 2574 |
wPtr->scrollInfo[0].window, |
| 2575 |
wPtr->scrollInfo[0].offset, |
| 2576 |
wPtr->scrollInfo[1].max, |
| 2577 |
wPtr->scrollInfo[1].window, |
| 2578 |
wPtr->scrollInfo[1].offset); |
| 2579 |
#endif |
| 2580 |
|
| 2581 |
if (oldXOff != wPtr->scrollInfo[0].offset || |
| 2582 |
oldYOff != wPtr->scrollInfo[1].offset) { |
| 2583 |
wPtr->toResetRB = 1; |
| 2584 |
wPtr->toComputeSel = 1; |
| 2585 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_REDRAW); |
| 2586 |
} |
| 2587 |
return TCL_OK; |
| 2588 |
} |
| 2589 |
|
| 2590 |
|
| 2591 |
|
| 2592 |
|
| 2593 |
|
| 2594 |
|
| 2595 |
|
| 2596 |
|
| 2597 |
static int |
| 2598 |
ConfigElement(wPtr, chPtr, argc, argv, flags, forced) |
| 2599 |
WidgetPtr wPtr; |
| 2600 |
TixGrEntry *chPtr; |
| 2601 |
int argc; |
| 2602 |
char ** argv; |
| 2603 |
int flags; |
| 2604 |
int forced; |
| 2605 |
{ |
| 2606 |
int sizeChanged; |
| 2607 |
|
| 2608 |
if (Tix_WidgetConfigure2(wPtr->dispData.interp, wPtr->dispData.tkwin, |
| 2609 |
(char*)chPtr, entryConfigSpecs, chPtr->iPtr, argc, argv, flags, |
| 2610 |
forced, &sizeChanged) != TCL_OK) { |
| 2611 |
return TCL_ERROR; |
| 2612 |
} |
| 2613 |
|
| 2614 |
if (sizeChanged) { |
| 2615 |
|
| 2616 |
|
| 2617 |
|
| 2618 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_RESIZE); |
| 2619 |
} else { |
| 2620 |
|
| 2621 |
Tix_GrDoWhenIdle(wPtr, TIX_GR_REDRAW); |
| 2622 |
} |
| 2623 |
return TCL_OK; |
| 2624 |
} |
| 2625 |
|
| 2626 |
static char * areaNames[4] = { |
| 2627 |
"s_margin", |
| 2628 |
"x_margin", |
| 2629 |
"y_margin", |
| 2630 |
"main" |
| 2631 |
}; |
| 2632 |
|
| 2633 |
static int |
| 2634 |
Tix_GrCallFormatCmd(wPtr, which) |
| 2635 |
WidgetPtr wPtr; |
| 2636 |
int which; |
| 2637 |
{ |
| 2638 |
int code; |
| 2639 |
|
| 2640 |
wPtr->renderInfo->fmt.whichArea = which; |
| 2641 |
code = LangDoCallback(wPtr->dispData.interp, wPtr->formatCmd, 0, 5, "%s %d %d %d %d", |
| 2642 |
areaNames[which], |
| 2643 |
wPtr->renderInfo->fmt.x1, |
| 2644 |
wPtr->renderInfo->fmt.y1, |
| 2645 |
wPtr->renderInfo->fmt.x2, |
| 2646 |
wPtr->renderInfo->fmt.y2); |
| 2647 |
|
| 2648 |
if (code != TCL_OK) { |
| 2649 |
Tcl_AddErrorInfo(wPtr->dispData.interp, |
| 2650 |
"\n (format command executed by tixGrid)"); |
| 2651 |
Tcl_BackgroundError(wPtr->dispData.interp); |
| 2652 |
} |
| 2653 |
|
| 2654 |
return code; |
| 2655 |
} |
| 2656 |
|
| 2657 |
|
| 2658 |
static void Tix_GrDrawBackground(wPtr, riPtr, drawable) |
| 2659 |
WidgetPtr wPtr; |
| 2660 |
RenderInfo * riPtr; |
| 2661 |
Drawable drawable; |
| 2662 |
{ |
| 2663 |
int mainSize[2]; |
| 2664 |
int visibleHdr[2]; |
| 2665 |
|
| 2666 |
if (wPtr->formatCmd == NULL) { |
| 2667 |
return; |
| 2668 |
} |
| 2669 |
|
| 2670 |
|
| 2671 |
|
| 2672 |
mainSize[0] = wPtr->mainRB->size[0] - wPtr->hdrSize[0]; |
| 2673 |
mainSize[1] = wPtr->mainRB->size[1] - wPtr->hdrSize[1]; |
| 2674 |
if (mainSize[0] < 0) { |
| 2675 |
mainSize[0] = 0; |
| 2676 |
} |
| 2677 |
if (mainSize[1] < 0) { |
| 2678 |
mainSize[1] = 0; |
| 2679 |
} |
| 2680 |
|
| 2681 |
|
| 2682 |
|
| 2683 |
if (wPtr->mainRB->size[0] < wPtr->hdrSize[0]) { |
| 2684 |
visibleHdr[0] = wPtr->mainRB->size[0]; |
| 2685 |
} else { |
| 2686 |
visibleHdr[0] = wPtr->hdrSize[0]; |
| 2687 |
} |
| 2688 |
if (wPtr->mainRB->size[1] < wPtr->hdrSize[1]) { |
| 2689 |
visibleHdr[1] = wPtr->mainRB->size[1]; |
| 2690 |
} else { |
| 2691 |
visibleHdr[1] = wPtr->hdrSize[1]; |
| 2692 |
} |
| 2693 |
|
| 2694 |
|
| 2695 |
|
| 2696 |
|
| 2697 |
if (wPtr->hdrSize[1] > 0 && mainSize[0] > 0) { |
| 2698 |
wPtr->renderInfo->fmt.x1 = |
| 2699 |
wPtr->scrollInfo[0].offset + wPtr->hdrSize[0]; |
| 2700 |
wPtr->renderInfo->fmt.x2 = |
| 2701 |
wPtr->renderInfo->fmt.x1 + mainSize[0] - 1; |
| 2702 |
wPtr->renderInfo->fmt.y1 = 0; |
| 2703 |
wPtr->renderInfo->fmt.y2 = visibleHdr[1] - 1; |
| 2704 |
|
| 2705 |
Tix_GrCallFormatCmd(wPtr, TIX_X_MARGIN); |
| 2706 |
} |
| 2707 |
|
| 2708 |
|
| 2709 |
|
| 2710 |
if (wPtr->hdrSize[0] > 0 && mainSize[1] > 0) { |
| 2711 |
wPtr->renderInfo->fmt.x1 = 0; |
| 2712 |
wPtr->renderInfo->fmt.x2 = visibleHdr[0] - 1; |
| 2713 |
wPtr->renderInfo->fmt.y1 = |
| 2714 |
wPtr->scrollInfo[1].offset + wPtr->hdrSize[1]; |
| 2715 |
wPtr->renderInfo->fmt.y2 = |
| 2716 |
wPtr->renderInfo->fmt.y1 + mainSize[1] - 1; |
| 2717 |
|
| 2718 |
Tix_GrCallFormatCmd(wPtr, TIX_Y_MARGIN); |
| 2719 |
} |
| 2720 |
|
| 2721 |
|
| 2722 |
|
| 2723 |
if (visibleHdr[0] > 0 && visibleHdr[1] > 0) { |
| 2724 |
wPtr->renderInfo->fmt.x1 = 0; |
| 2725 |
wPtr->renderInfo->fmt.x2 = visibleHdr[0] - 1; |
| 2726 |
wPtr->renderInfo->fmt.y1 = 0; |
| 2727 |
wPtr->renderInfo->fmt.y2 = visibleHdr[1] - 1; |
| 2728 |
|
| 2729 |
Tix_GrCallFormatCmd(wPtr, TIX_S_MARGIN); |
| 2730 |
} |
| 2731 |
|
| 2732 |
|
| 2733 |
|
| 2734 |
if (mainSize[0] > 0 && mainSize[1] > 0) { |
| 2735 |
wPtr->renderInfo->fmt.x1 = |
| 2736 |
wPtr->scrollInfo[0].offset + wPtr->hdrSize[0]; |
| 2737 |
wPtr->renderInfo->fmt.x2 = |
| 2738 |
wPtr->renderInfo->fmt.x1 + mainSize[0] - 1; |
| 2739 |
wPtr->renderInfo->fmt.y1 = |
| 2740 |
wPtr->scrollInfo[1].offset + wPtr->hdrSize[1]; |
| 2741 |
wPtr->renderInfo->fmt.y2 = |
| 2742 |
wPtr->renderInfo->fmt.y1 + mainSize[1] - 1; |
| 2743 |
|
| 2744 |
Tix_GrCallFormatCmd(wPtr, TIX_MAIN); |
| 2745 |
} |
| 2746 |
} |
| 2747 |
|
| 2748 |
static void |
| 2749 |
Tix_GrComputeSubSelection(wPtr, rect, offs) |
| 2750 |
WidgetPtr wPtr; |
| 2751 |
int rect[2][2]; |
| 2752 |
int offs[2]; |
| 2753 |
{ |
| 2754 |
int iMin, iMax, jMin, jMax; |
| 2755 |
Tix_ListIterator li; |
| 2756 |
SelectBlock * sbPtr; |
| 2757 |
int i, j, x, y; |
| 2758 |
|
| 2759 |
Tix_SimpleListIteratorInit(&li); |
| 2760 |
for (Tix_SimpleListStart(&wPtr->selList, &li); |
| 2761 |
!Tix_SimpleListDone(&li); |
| 2762 |
Tix_SimpleListNext (&wPtr->selList, &li)) { |
| 2763 |
|
| 2764 |
sbPtr = (SelectBlock *)li.curr; |
| 2765 |
|
| 2766 |
|
| 2767 |
|
| 2768 |
if (rect[0][0] > sbPtr->range[0][0]) { |
| 2769 |
iMin = rect[0][0]; |
| 2770 |
} else { |
| 2771 |
iMin = sbPtr->range[0][0]; |
| 2772 |
} |
| 2773 |
|
| 2774 |
if (rect[0][1]<sbPtr->range[0][1] || sbPtr->range[0][1]==TIX_GR_MAX) { |
| 2775 |
iMax = rect[0][1]; |
| 2776 |
} else { |
| 2777 |
iMax = sbPtr->range[0][1]; |
| 2778 |
} |
| 2779 |
if (iMin > iMax) { |
| 2780 |
continue; |
| 2781 |
} |
| 2782 |
|
| 2783 |
|
| 2784 |
|
| 2785 |
if (rect[1][0] > sbPtr->range[1][0]) { |
| 2786 |
jMin = rect[1][0]; |
| 2787 |
} else { |
| 2788 |
jMin = sbPtr->range[1][0]; |
| 2789 |
} |
| 2790 |
if (rect[1][1]<sbPtr->range[1][1] || sbPtr->range[1][1]==TIX_GR_MAX) { |
| 2791 |
jMax = rect[1][1]; |
| 2792 |
} else { |
| 2793 |
jMax = sbPtr->range[1][1]; |
| 2794 |
} |
| 2795 |
if (jMin > jMax) { |
| 2796 |
continue; |
| 2797 |
} |
| 2798 |
|
| 2799 |
for (i=iMin; i<=iMax; i++) { |
| 2800 |
for (j=jMin; j<=jMax; j++) { |
| 2801 |
x = i - offs[0]; |
| 2802 |
y = j - offs[1]; |
| 2803 |
|
| 2804 |
switch (sbPtr->type) { |
| 2805 |
case TIX_GR_CLEAR: |
| 2806 |
wPtr->mainRB->elms[x][y].selected = 0; |
| 2807 |
break; |
| 2808 |
case TIX_GR_SET: |
| 2809 |
wPtr->mainRB->elms[x][y].selected = 1; |
| 2810 |
break; |
| 2811 |
case TIX_GR_TOGGLE: |
| 2812 |
wPtr->mainRB->elms[x][y].selected = |
| 2813 |
!wPtr->mainRB->elms[x][y].selected; |
| 2814 |
break; |
| 2815 |
|
| 2816 |
} |
| 2817 |
} |
| 2818 |
} |
| 2819 |
} |
| 2820 |
} |
| 2821 |
|
| 2822 |
static void Tix_GrComputeSelection(wPtr) |
| 2823 |
WidgetPtr wPtr; |
| 2824 |
{ |
| 2825 |
int rect[2][2], offs[2]; |
| 2826 |
int i, j; |
| 2827 |
int mainSize[2]; |
| 2828 |
int visibleHdr[2]; |
| 2829 |
|
| 2830 |
for (i=0; i<wPtr->mainRB->size[0]; i++) { |
| 2831 |
for (j=0; j<wPtr->mainRB->size[1]; j++) { |
| 2832 |
wPtr->mainRB->elms[i][j].selected = 0; |
| 2833 |
} |
| 2834 |
} |
| 2835 |
|
| 2836 |
|
| 2837 |
|
| 2838 |
mainSize[0] = wPtr->mainRB->size[0] - wPtr->hdrSize[0]; |
| 2839 |
mainSize[1] = wPtr->mainRB->size[1] - wPtr->hdrSize[1]; |
| 2840 |
if (mainSize[0] < 0) { |
| 2841 |
mainSize[0] = 0; |
| 2842 |
} |
| 2843 |
if (mainSize[1] < 0) { |
| 2844 |
mainSize[1] = 0; |
| 2845 |
} |
| 2846 |
|
| 2847 |
|
| 2848 |
|
| 2849 |
if (wPtr->mainRB->size[0] < wPtr->hdrSize[0]) { |
| 2850 |
visibleHdr[0] = wPtr->mainRB->size[0]; |
| 2851 |
} else { |
| 2852 |
visibleHdr[0] = wPtr->hdrSize[0]; |
| 2853 |
} |
| 2854 |
if (wPtr->mainRB->size[1] < wPtr->hdrSize[1]) { |
| 2855 |
visibleHdr[1] = wPtr->mainRB->size[1]; |
| 2856 |
} else { |
| 2857 |
visibleHdr[1] = wPtr->hdrSize[1]; |
| 2858 |
} |
| 2859 |
|
| 2860 |
|
| 2861 |
|
| 2862 |
if (visibleHdr[0] > 0 && visibleHdr[1] > 0) { |
| 2863 |
rect[0][0] = 0; |
| 2864 |
rect[0][1] = visibleHdr[0] - 1; |
| 2865 |
rect[1][0] = 0; |
| 2866 |
rect[1][1] = visibleHdr[1] - 1; |
| 2867 |
offs[0] = 0; |
| 2868 |
offs[1] = 0; |
| 2869 |
|
| 2870 |
Tix_GrComputeSubSelection(wPtr, rect, offs); |
| 2871 |
} |
| 2872 |
|
| 2873 |
|
| 2874 |
|
| 2875 |
if (wPtr->hdrSize[1] > 0 && mainSize[0] > 0) { |
| 2876 |
rect[0][0] = wPtr->scrollInfo[0].offset + wPtr->hdrSize[0]; |
| 2877 |
rect[0][1] = rect[0][0] + mainSize[0] - 1; |
| 2878 |
rect[1][0] = 0; |
| 2879 |
rect[1][1] = visibleHdr[1] - 1; |
| 2880 |
offs[0] = wPtr->scrollInfo[0].offset;; |
| 2881 |
offs[1] = 0; |
| 2882 |
|
| 2883 |
Tix_GrComputeSubSelection(wPtr, rect, offs); |
| 2884 |
} |
| 2885 |
|
| 2886 |
|
| 2887 |
|
| 2888 |
if (wPtr->hdrSize[0] > 0 && mainSize[1] > 0) { |
| 2889 |
rect[0][0] = 0; |
| 2890 |
rect[0][1] = visibleHdr[0] - 1; |
| 2891 |
rect[1][0] = wPtr->scrollInfo[1].offset + wPtr->hdrSize[1]; |
| 2892 |
rect[1][1] = rect[1][0] + mainSize[1] - 1; |
| 2893 |
offs[0] = 0; |
| 2894 |
offs[1] = wPtr->scrollInfo[1].offset;; |
| 2895 |
|
| 2896 |
Tix_GrComputeSubSelection(wPtr, rect, offs); |
| 2897 |
} |
| 2898 |
|
| 2899 |
|
| 2900 |
|
| 2901 |
if (mainSize[0] > 0 && mainSize[1] > 0) { |
| 2902 |
rect[0][0] = wPtr->scrollInfo[0].offset + wPtr->hdrSize[0]; |
| 2903 |
rect[0][1] = rect[0][0] + mainSize[0] - 1; |
| 2904 |
rect[1][0] = wPtr->scrollInfo[1].offset + wPtr->hdrSize[1]; |
| 2905 |
rect[1][1] = rect[1][0] + mainSize[1] - 1; |
| 2906 |
offs[0] = wPtr->scrollInfo[0].offset;; |
| 2907 |
offs[1] = wPtr->scrollInfo[1].offset;; |
| 2908 |
|
| 2909 |
Tix_GrComputeSubSelection(wPtr, rect, offs); |
| 2910 |
} |
| 2911 |
} |
| 2912 |
|
| 2913 |
|
| 2914 |
|
| 2915 |
|
| 2916 |
|
| 2917 |
static void |
| 2918 |
GetScrollFractions(wPtr, siPtr, first_ret, last_ret) |
| 2919 |
WidgetPtr wPtr; |
| 2920 |
Tix_GridScrollInfo *siPtr; |
| 2921 |
double * first_ret; |
| 2922 |
double * last_ret; |
| 2923 |
{ |
| 2924 |
double first, last; |
| 2925 |
double usuable; |
| 2926 |
|
| 2927 |
usuable = 1.0 - siPtr->window; |
| 2928 |
|
| 2929 |
if (siPtr->max > 0) { |
| 2930 |
first = usuable * (double)(siPtr->offset) / (double)(siPtr->max); |
| 2931 |
last = first + siPtr->window; |
| 2932 |
} else { |
| 2933 |
first = 0.0; |
| 2934 |
last = 1.0; |
| 2935 |
} |
| 2936 |
|
| 2937 |
*first_ret = first; |
| 2938 |
*last_ret = last; |
| 2939 |
} |
| 2940 |
|
| 2941 |
static void UpdateScrollBars(wPtr, sizeChanged) |
| 2942 |
WidgetPtr wPtr; |
| 2943 |
int sizeChanged; |
| 2944 |
{ |
| 2945 |
int i; |
| 2946 |
Tix_GridScrollInfo *siPtr; |
| 2947 |
Tcl_Interp * interp = wPtr->dispData.interp; |
| 2948 |
|
| 2949 |
for (i=0; i<2; i++) { |
| 2950 |
double first, last; |
| 2951 |
double usuable; |
| 2952 |
|
| 2953 |
siPtr = &wPtr->scrollInfo[i]; |
| 2954 |
|
| 2955 |
usuable = 1.0 - siPtr->window; |
| 2956 |
|
| 2957 |
if (siPtr->max > 0) { |
| 2958 |
first = usuable * (double)(siPtr->offset) / (double)(siPtr->max); |
| 2959 |
last = first + siPtr->window; |
| 2960 |
} else { |
| 2961 |
first = 0.0; |
| 2962 |
last = 1.0; |
| 2963 |
} |
| 2964 |
|
| 2965 |
if (siPtr->command) { |
| 2966 |
if (LangDoCallback(interp, siPtr->command, 0, 2, " %g %g", first, last) |
| 2967 |
!= TCL_OK) { |
| 2968 |
Tcl_AddErrorInfo(interp, |
| 2969 |
"\n (scrolling command executed by tixGrid)"); |
| 2970 |
Tcl_BackgroundError(interp); |
| 2971 |
} |
| 2972 |
} |
| 2973 |
} |
| 2974 |
|
| 2975 |
if (wPtr->sizeCmd && sizeChanged) { |
| 2976 |
if (LangDoCallback(wPtr->dispData.interp, wPtr->sizeCmd, 0, 0) != TCL_OK) { |
| 2977 |
Tcl_AddErrorInfo(wPtr->dispData.interp, |
| 2978 |
"\n (size command executed by tixGrid)"); |
| 2979 |
Tcl_BackgroundError(wPtr->dispData.interp); |
| 2980 |
} |
| 2981 |
} |
| 2982 |
} |
| 2983 |
|
| 2984 |
|
| 2985 |
|
| 2986 |
|
| 2987 |
|
| 2988 |
|
| 2989 |
|
| 2990 |
|
| 2991 |
|
| 2992 |
static TixGrEntry * |
| 2993 |
Tix_GrFindCreateElem(interp, wPtr, x, y) |
| 2994 |
Tcl_Interp * interp; |
| 2995 |
WidgetPtr wPtr; |
| 2996 |
int x; |
| 2997 |
int y; |
| 2998 |
{ |
| 2999 |
static TixGrEntry * defaultEntry = NULL; |
| 3000 |
TixGrEntry * chPtr; |
| 3001 |
|
| 3002 |
if (defaultEntry == NULL) { |
| 3003 |
defaultEntry = (TixGrEntry*)ckalloc(sizeof(TixGrEntry)); |
| 3004 |
defaultEntry->iPtr = NULL; |
| 3005 |
} |
| 3006 |
|
| 3007 |
chPtr = (TixGrEntry*)TixGridDataCreateEntry(wPtr->dataSet, x, y, |
| 3008 |
(char*)defaultEntry); |
| 3009 |
|
| 3010 |
if (chPtr == defaultEntry) { |
| 3011 |
defaultEntry = NULL; |
| 3012 |
} |
| 3013 |
|
| 3014 |
return chPtr; |
| 3015 |
} |
| 3016 |
|
| 3017 |
|
| 3018 |
|
| 3019 |
|
| 3020 |
|
| 3021 |
|
| 3022 |
|
| 3023 |
static TixGrEntry * |
| 3024 |
Tix_GrFindElem(interp, wPtr, x, y) |
| 3025 |
Tcl_Interp * interp; |
| 3026 |
WidgetPtr wPtr; |
| 3027 |
int x; |
| 3028 |
int y; |
| 3029 |
{ |
| 3030 |
return (TixGrEntry*)TixGridDataFindEntry(wPtr->dataSet, x, y); |
| 3031 |
} |
| 3032 |
|
| 3033 |
|
| 3034 |
|
| 3035 |
|
| 3036 |
|
| 3037 |
|
| 3038 |
|
| 3039 |
|
| 3040 |
|
| 3041 |
void |
| 3042 |
Tix_GrFreeElem(chPtr) |
| 3043 |
TixGrEntry * chPtr; |
| 3044 |
{ |
| 3045 |
if (chPtr->iPtr) { |
| 3046 |
Tix_DItemFree(chPtr->iPtr); |
| 3047 |
} |
| 3048 |
ckfree((char*)chPtr); |
| 3049 |
} |
| 3050 |
|
| 3051 |
static void |
| 3052 |
Tix_GrPropagateSize(wPtr, chPtr) |
| 3053 |
WidgetPtr wPtr; |
| 3054 |
TixGrEntry * chPtr; |
| 3055 |
{ |
| 3056 |
#if 0 |
| 3057 |
int i; |
| 3058 |
|
| 3059 |
for (i=0; i<2; i++) { |
| 3060 |
TreeListRoot * rPtr; |
| 3061 |
GridHeader * hdr; |
| 3062 |
|
| 3063 |
rPtr = chPtr->nodes[i].root; |
| 3064 |
hdr = (GridHeader*) rPtr->data; |
| 3065 |
|
| 3066 |
if (hdr->size < chPtr->size[i]) { |
| 3067 |
hdr->size = chPtr->size[i]; |
| 3068 |
hdr->recalSize = 0; |
| 3069 |
} |
| 3070 |
} |
| 3071 |
#endif |
| 3072 |
} |
| 3073 |
|
| 3074 |
static RenderBlock * Tix_GrAllocateRenderBlock(wPtr, winW, winH, exactW,exactH) |
| 3075 |
WidgetPtr wPtr; |
| 3076 |
int winW; |
| 3077 |
int winH; |
| 3078 |
int * exactW; |
| 3079 |
int * exactH; |
| 3080 |
{ |
| 3081 |
RenderBlock * rbPtr; |
| 3082 |
int i, j, k; |
| 3083 |
int offset[2]; |
| 3084 |
int winSize[2]; |
| 3085 |
int exactSize[2]; |
| 3086 |
|
| 3087 |
int pad0, pad1; |
| 3088 |
|
| 3089 |
offset[0] = wPtr->scrollInfo[0].offset + wPtr->hdrSize[0]; |
| 3090 |
offset[1] = wPtr->scrollInfo[1].offset + wPtr->hdrSize[1]; |
| 3091 |
|
| 3092 |
winSize[0] = winW; |
| 3093 |
winSize[1] = winH; |
| 3094 |
|
| 3095 |
rbPtr = (RenderBlock*)ckalloc(sizeof(RenderBlock)); |
| 3096 |
|
| 3097 |
rbPtr->size[0]=0; |
| 3098 |
rbPtr->size[1]=0; |
| 3099 |
rbPtr->visArea[0] = winW; |
| 3100 |
rbPtr->visArea[1] = winH; |
| 3101 |
|
| 3102 |
|
| 3103 |
|
| 3104 |
|
| 3105 |
|
| 3106 |
for (i=0; i<2; i++) { |
| 3107 |
|
| 3108 |
|
| 3109 |
|
| 3110 |
int index; |
| 3111 |
int pixelSize = 0; |
| 3112 |
|
| 3113 |
|
| 3114 |
for (index=0; index<wPtr->hdrSize[i] && pixelSize<winSize[i]; index++){ |
| 3115 |
pixelSize += TixGridDataGetRowColSize(wPtr, wPtr->dataSet, i, |
| 3116 |
index, &wPtr->defSize[i], &pad0, &pad1); |
| 3117 |
pixelSize += pad0 + pad1; |
| 3118 |
rbPtr->size[i] ++; |
| 3119 |
} |
| 3120 |
|
| 3121 |
for (index=offset[i]; pixelSize<winSize[i]; index++) { |
| 3122 |
pixelSize += TixGridDataGetRowColSize(wPtr, wPtr->dataSet, i, |
| 3123 |
index, &wPtr->defSize[i], &pad0, &pad1); |
| 3124 |
pixelSize += pad0 + pad1; |
| 3125 |
rbPtr->size[i] ++; |
| 3126 |
} |
| 3127 |
if (pixelSize == winSize[i]) { |
| 3128 |
exactSize[i] = 1; |
| 3129 |
} else { |
| 3130 |
exactSize[i] = 0; |
| 3131 |
} |
| 3132 |
} |
| 3133 |
|
| 3134 |
|
| 3135 |
|
| 3136 |
*exactW = exactSize[0]; |
| 3137 |
*exactH = exactSize[1]; |
| 3138 |
|
| 3139 |
rbPtr->dispSize[0] = (ElmDispSize*) |
| 3140 |
ckalloc(sizeof(ElmDispSize)*rbPtr->size[0]); |
| 3141 |
rbPtr->dispSize[1] = (ElmDispSize*) |
| 3142 |
ckalloc(sizeof(ElmDispSize)*rbPtr->size[1]); |
| 3143 |
|
| 3144 |
|
| 3145 |
|
| 3146 |
|
| 3147 |
|
| 3148 |
|
| 3149 |
for (i=0; i<2; i++) { |
| 3150 |
|
| 3151 |
|
| 3152 |
|
| 3153 |
|
| 3154 |
int index; |
| 3155 |
|
| 3156 |
for (k=0; k<rbPtr->size[i]; k++) { |
| 3157 |
if (k < wPtr->hdrSize[i]) { |
| 3158 |
index = k; |
| 3159 |
} else { |
| 3160 |
index = k + offset[i] - wPtr->hdrSize[i]; |
| 3161 |
} |
| 3162 |
|
| 3163 |
rbPtr->dispSize[i][k].size = TixGridDataGetRowColSize(wPtr, |
| 3164 |
wPtr->dataSet, i, index, &wPtr->defSize[i], &pad0, &pad1); |
| 3165 |
rbPtr->dispSize[i][k].preBorder = pad0; |
| 3166 |
rbPtr->dispSize[i][k].postBorder = pad1; |
| 3167 |
} |
| 3168 |
} |
| 3169 |
|
| 3170 |
|
| 3171 |
|
| 3172 |
|
| 3173 |
|
| 3174 |
rbPtr->elms = (RenderBlockElem**) |
| 3175 |
ckalloc(sizeof(RenderBlockElem*)*rbPtr->size[0]); |
| 3176 |
|
| 3177 |
for (i=0; i<rbPtr->size[0]; i++) { |
| 3178 |
rbPtr->elms[i] = (RenderBlockElem*) |
| 3179 |
ckalloc(sizeof(RenderBlockElem) * rbPtr->size[1]); |
| 3180 |
for (j=0; j<rbPtr->size[1]; j++) { |
| 3181 |
rbPtr->elms[i][j].chPtr = NULL; |
| 3182 |
rbPtr->elms[i][j].selected = 0; |
| 3183 |
} |
| 3184 |
} |
| 3185 |
|
| 3186 |
for (i=0; i<rbPtr->size[0]; i++) { |
| 3187 |
for (j=0; j<rbPtr->size[1]; j++) { |
| 3188 |
int x, y; |
| 3189 |
|
| 3190 |
if (i<wPtr->hdrSize[0]) { |
| 3191 |
x = i; |
| 3192 |
} else { |
| 3193 |
x = i+offset[0]-wPtr->hdrSize[0]; |
| 3194 |
} |
| 3195 |
|
| 3196 |
if (j<wPtr->hdrSize[1]) { |
| 3197 |
y = j; |
| 3198 |
} else { |
| 3199 |
y = j+offset[1]-wPtr->hdrSize[1]; |
| 3200 |
} |
| 3201 |
|
| 3202 |
rbPtr->elms[i][j].chPtr = (TixGrEntry*) TixGridDataFindEntry( |
| 3203 |
wPtr->dataSet, x, y); |
| 3204 |
rbPtr->elms[i][j].index[0] = x; |
| 3205 |
rbPtr->elms[i][j].index[1] = y; |
| 3206 |
} |
| 3207 |
} |
| 3208 |
|
| 3209 |
for (k=0; k<2; k++) { |
| 3210 |
for (i=0; i<rbPtr->size[k]; i++) { |
| 3211 |
rbPtr->dispSize[k][i].total = |
| 3212 |
rbPtr->dispSize[k][i].preBorder |
| 3213 |
+ rbPtr->dispSize[k][i].size |
| 3214 |
+ rbPtr->dispSize[k][i].postBorder; |
| 3215 |
} |
| 3216 |
} |
| 3217 |
|
| 3218 |
return rbPtr; |
| 3219 |
} |
| 3220 |
|
| 3221 |
static void |
| 3222 |
Tix_GrFreeRenderBlock(wPtr, rbPtr) |
| 3223 |
WidgetPtr wPtr; |
| 3224 |
RenderBlock * rbPtr; |
| 3225 |
{ |
| 3226 |
int i; |
| 3227 |
|
| 3228 |
for (i=0; i<rbPtr->size[0]; i++) { |
| 3229 |
ckfree((char*)rbPtr->elms[i]); |
| 3230 |
} |
| 3231 |
ckfree((char*)rbPtr->elms); |
| 3232 |
ckfree((char*)rbPtr->dispSize[0]); |
| 3233 |
ckfree((char*)rbPtr->dispSize[1]); |
| 3234 |
ckfree((char*)rbPtr); |
| 3235 |
} |
| 3236 |
|
| 3237 |
|
| 3238 |
|
| 3239 |
|
| 3240 |
|
| 3241 |
|
| 3242 |
|
| 3243 |
|
| 3244 |
|
| 3245 |
|
| 3246 |
|
| 3247 |
|
| 3248 |
|
| 3249 |
|
| 3250 |
static int Tix_GrBBox(interp, wPtr, x, y) |
| 3251 |
Tcl_Interp * interp; |
| 3252 |
WidgetPtr wPtr; |
| 3253 |
int x; |
| 3254 |
int y; |
| 3255 |
{ |
| 3256 |
int rect[2][2]; |
| 3257 |
int visible; |
| 3258 |
|
| 3259 |
if (!Tk_IsMapped(wPtr->dispData.tkwin)) { |
| 3260 |
return TCL_OK; |
| 3261 |
} |
| 3262 |
|
| 3263 |
visible = Tix_GrGetElementPosn(wPtr, wPtr->anchor[0], wPtr->anchor[1], |
| 3264 |
rect, 0, 0, 1, 0); |
| 3265 |
if (!visible) { |
| 3266 |
return TCL_OK; |
| 3267 |
} |
| 3268 |
Tcl_IntResults(interp,4,0, rect[0][0], rect[1][0], |
| 3269 |
rect[0][1] - rect[0][0] + 1, |
| 3270 |
rect[1][1] - rect[1][0] + 1); |
| 3271 |
return TCL_OK; |
| 3272 |
} |
| 3273 |
|
| 3274 |
|
| 3275 |
|
| 3276 |
|
| 3277 |
|
| 3278 |
|
| 3279 |
|
| 3280 |
|
| 3281 |
|
| 3282 |
|
| 3283 |
|
| 3284 |
|
| 3285 |
|
| 3286 |
|
| 3287 |
|
| 3288 |
static int |
| 3289 |
TranslateFromTo(interp, wPtr, argc, argv, from, to, which) |
| 3290 |
Tcl_Interp * interp; |
| 3291 |
WidgetPtr wPtr; |
| 3292 |
int argc; |
| 3293 |
char **argv; |
| 3294 |
int *from; |
| 3295 |
int *to; |
| 3296 |
int * which; |
| 3297 |
{ |
| 3298 |
int dummy = 0; |
| 3299 |
size_t len = strlen(argv[0]); |
| 3300 |
|
| 3301 |
if (strncmp(argv[0], "row", len) == 0) { |
| 3302 |
*which = 1; |
| 3303 |
|
| 3304 |
if (TixGridDataGetIndex(interp, wPtr, NULL, objv[1], &dummy, from) |
| 3305 |
!=TCL_OK) { |
| 3306 |
return TCL_ERROR; |
| 3307 |
} |
| 3308 |
if (argc == 3) { |
| 3309 |
if (TixGridDataGetIndex(interp, wPtr, NULL, objv[2], &dummy, to) |
| 3310 |
!=TCL_OK) { |
| 3311 |
return TCL_ERROR; |
| 3312 |
} |
| 3313 |
} else { |
| 3314 |
*to = *from; |
| 3315 |
} |
| 3316 |
} else if (strncmp(argv[0], "column", len) == 0) { |
| 3317 |
*which = 0; |
| 3318 |
if (TixGridDataGetIndex(interp, wPtr, objv[1], NULL, from, &dummy) |
| 3319 |
!=TCL_OK) { |
| 3320 |
return TCL_ERROR; |
| 3321 |
} |
| 3322 |
|
| 3323 |
if (argc == 3) { |
| 3324 |
if (TixGridDataGetIndex(interp, wPtr, objv[2], NULL, to, &dummy) |
| 3325 |
!=TCL_OK) { |
| 3326 |
return TCL_ERROR; |
| 3327 |
} |
| 3328 |
} else { |
| 3329 |
*to = *from; |
| 3330 |
} |
| 3331 |
} |
| 3332 |
|
| 3333 |
return TCL_OK; |
| 3334 |
} |