draw.cpp (23954B)
1 // Copyright (c) 2003 - 2009 Anselm R Garbe <anselm@garbe.us> 2 // See LICENSE for license details. 3 4 #include <iostream> 5 6 #include "draw.h" 7 8 #include "config.h" 9 #include "kernel.h" 10 #include "rectangle.h" 11 #include "xcore.h" 12 13 #define XCORE XCore::instance() 14 #define FIGURE_DISTANCE 3 15 16 void Draw::drawDetachButton(Window window, GC gc, 17 Rectangle *rect, unsigned long background, 18 unsigned long shineBorder, unsigned long shadowBorder, 19 unsigned long shineFigure, unsigned long shadowFigure) 20 { 21 22 XCORE->setForeground(gc, background); 23 XCORE->fillRectangle(window, gc, rect); 24 25 XPoint shineButtonPoints[3]; 26 shineButtonPoints[0].x = rect->x() + FIGURE_DISTANCE; 27 shineButtonPoints[0].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 28 shineButtonPoints[1].x = rect->x() + FIGURE_DISTANCE; 29 shineButtonPoints[1].y = rect->y() + rect->height() - 2 * FIGURE_DISTANCE - 1; 30 shineButtonPoints[2].x = rect->x() + rect->width() - FIGURE_DISTANCE - 1; 31 shineButtonPoints[2].y = rect->y() + rect->height() - 2 * FIGURE_DISTANCE - 1; 32 XCORE->setForeground(gc, shineFigure); 33 XCORE->drawLines(window, gc, shineButtonPoints, 3); 34 35 XPoint shadowButtonPoints[3]; 36 shadowButtonPoints[0].x = rect->x() + rect->width() - FIGURE_DISTANCE - 1; 37 shadowButtonPoints[0].y = rect->y() + rect->height() - 2 * FIGURE_DISTANCE - 1; 38 shadowButtonPoints[1].x = rect->x() + rect->width() - FIGURE_DISTANCE - 1; 39 shadowButtonPoints[1].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 40 shadowButtonPoints[2].x = rect->x() + FIGURE_DISTANCE; 41 shadowButtonPoints[2].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 42 XCORE->setForeground(gc, shadowFigure); 43 XCORE->drawLines(window, gc, shadowButtonPoints, 3); 44 45 drawRectBorder(window, gc, rect, shineBorder, shadowBorder); 46 } 47 48 void Draw::drawMaxButton(Window window, GC gc, 49 Rectangle *rect, unsigned long background, 50 unsigned long shineBorder, unsigned long shadowBorder, 51 unsigned long shineFigure, unsigned long shadowFigure, 52 bool fill) 53 54 { 55 XCORE->setForeground(gc, background); 56 XCORE->fillRectangle(window, gc, rect); 57 58 XPoint shadowButtonPoints[3]; 59 shadowButtonPoints[0].x = rect->x() + rect->width() - FIGURE_DISTANCE - 1; 60 shadowButtonPoints[0].y = rect->y() + FIGURE_DISTANCE; 61 shadowButtonPoints[1].x = rect->x() + rect->width() - FIGURE_DISTANCE - 1; 62 shadowButtonPoints[1].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 63 shadowButtonPoints[2].x = rect->x() + FIGURE_DISTANCE; 64 shadowButtonPoints[2].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 65 XCORE->setForeground(gc, shadowFigure); 66 XCORE->drawLines(window, gc, shadowButtonPoints, 3); 67 68 XPoint shineButtonPoints[3]; 69 shineButtonPoints[0].x = rect->x() + FIGURE_DISTANCE; 70 shineButtonPoints[0].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 71 shineButtonPoints[1].x = rect->x() + FIGURE_DISTANCE; 72 shineButtonPoints[1].y = rect->y() + FIGURE_DISTANCE; 73 shineButtonPoints[2].x = rect->x() + rect->width() - FIGURE_DISTANCE - 1; 74 shineButtonPoints[2].y = rect->y() + FIGURE_DISTANCE; 75 XCORE->setForeground(gc, shineFigure); 76 XCORE->drawLines(window, gc, shineButtonPoints, 3); 77 78 if (fill) { 79 XCORE->setForeground(gc, shineFigure); 80 XCORE->fillRectangle(window, gc, 81 rect->x() + FIGURE_DISTANCE + 1, 82 rect->y() + FIGURE_DISTANCE + 1, 83 rect->width() - 2 * FIGURE_DISTANCE - 2, 84 rect->height() - 2 * FIGURE_DISTANCE - 2); 85 } 86 87 drawRectBorder(window, gc, rect, shineBorder, shadowBorder); 88 } 89 90 void Draw::drawMenuButton(Window window, GC gc, 91 Rectangle *rect, unsigned long background, 92 unsigned long shineBorder, unsigned long shadowBorder, 93 unsigned long shineFigure, unsigned long shadowFigure) 94 { 95 XCORE->setForeground(gc, background); 96 XCORE->fillRectangle(window, gc, rect); 97 98 // shine lines 99 XCORE->setForeground(gc, shineFigure); 100 XCORE->drawLine(window, gc, rect->x() + FIGURE_DISTANCE, 101 rect->y() + FIGURE_DISTANCE, 102 rect->x() + rect->width() - FIGURE_DISTANCE, 103 rect->y() + FIGURE_DISTANCE); 104 XCORE->drawLine(window, gc, rect->x() + FIGURE_DISTANCE, 105 rect->y() + rect->height() / 2, 106 rect->x() + rect->width() - FIGURE_DISTANCE, 107 rect->y() + rect->height() / 2); 108 XCORE->drawLine(window, gc, rect->x() + FIGURE_DISTANCE, 109 rect->y() + rect->height() - FIGURE_DISTANCE - 1, 110 rect->x() + rect->width() - FIGURE_DISTANCE, 111 rect->y() + rect->height() - FIGURE_DISTANCE - 1); 112 113 // shadow lines 114 XCORE->setForeground(gc, shadowFigure); 115 XCORE->drawLine(window, gc, rect->x() + FIGURE_DISTANCE, 116 rect->y() + FIGURE_DISTANCE + 1, 117 rect->x() + rect->width() - FIGURE_DISTANCE, 118 rect->y() + FIGURE_DISTANCE + 1); 119 XCORE->drawLine(window, gc, rect->x() + FIGURE_DISTANCE, 120 rect->y() + rect->height() / 2 + 1, 121 rect->x() + rect->width() - FIGURE_DISTANCE, 122 rect->y() + rect->height() / 2 + 1); 123 XCORE->drawLine(window, gc, rect->x() + FIGURE_DISTANCE, 124 rect->y() + rect->height() - FIGURE_DISTANCE, 125 rect->x() + rect->width() - FIGURE_DISTANCE, 126 rect->y() + rect->height() - FIGURE_DISTANCE); 127 128 drawRectBorder(window, gc, rect, shineBorder, shadowBorder); 129 } 130 131 void Draw::drawFloatButton(Window window, GC gc, 132 Rectangle *rect, unsigned long background, 133 unsigned long shineBorder, unsigned long shadowBorder, 134 unsigned long shineFigure, unsigned long shadowFigure, 135 bool fill) 136 { 137 XCORE->setForeground(gc, background); 138 XCORE->fillRectangle(window, gc, rect); 139 140 XPoint shadowButtonPoints[3]; 141 shadowButtonPoints[0].x = rect->x() + rect->width() - 2 * FIGURE_DISTANCE - 1; 142 shadowButtonPoints[0].y = rect->y() + FIGURE_DISTANCE; 143 shadowButtonPoints[1].x = rect->x() + rect->width() - 2 * FIGURE_DISTANCE - 1; 144 shadowButtonPoints[1].y = rect->y() + rect->height() - 2 * FIGURE_DISTANCE - 1; 145 shadowButtonPoints[2].x = rect->x() + FIGURE_DISTANCE; 146 shadowButtonPoints[2].y = rect->y() + rect->height() - 2 * FIGURE_DISTANCE - 1; 147 XCORE->setForeground(gc, shadowFigure); 148 XCORE->drawLines(window, gc, shadowButtonPoints, 3); 149 150 shadowButtonPoints[0].x = rect->x() + rect->width() - FIGURE_DISTANCE - 1; 151 shadowButtonPoints[0].y = rect->y() + 2 * FIGURE_DISTANCE; 152 shadowButtonPoints[1].x = rect->x() + rect->width() - FIGURE_DISTANCE - 1; 153 shadowButtonPoints[1].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 154 shadowButtonPoints[2].x = rect->x() + 2 * FIGURE_DISTANCE; 155 shadowButtonPoints[2].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 156 XCORE->drawLines(window, gc, shadowButtonPoints, 3); 157 158 XPoint shineButtonPoints[3]; 159 shineButtonPoints[0].x = rect->x() + FIGURE_DISTANCE; 160 shineButtonPoints[0].y = rect->y() + rect->height() - 2 * FIGURE_DISTANCE - 1; 161 shineButtonPoints[1].x = rect->x() + FIGURE_DISTANCE; 162 shineButtonPoints[1].y = rect->y() + FIGURE_DISTANCE; 163 shineButtonPoints[2].x = rect->x() + rect->width() - 2 * FIGURE_DISTANCE - 1; 164 shineButtonPoints[2].y = rect->y() + FIGURE_DISTANCE; 165 XCORE->setForeground(gc, shineFigure); 166 XCORE->drawLines(window, gc, shineButtonPoints, 3); 167 168 shineButtonPoints[0].x = rect->x() + 2 * FIGURE_DISTANCE; 169 shineButtonPoints[0].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 170 shineButtonPoints[1].x = rect->x() + 2 * FIGURE_DISTANCE; 171 shineButtonPoints[1].y = rect->y() + 2 * FIGURE_DISTANCE; 172 shineButtonPoints[2].x = rect->x() + rect->width() - FIGURE_DISTANCE - 1; 173 shineButtonPoints[2].y = rect->y() + 2 * FIGURE_DISTANCE; 174 XCORE->drawLines(window, gc, shineButtonPoints, 3); 175 176 if (fill) { 177 XCORE->setForeground(gc, shineFigure); 178 XCORE->fillRectangle(window, gc, 179 rect->x() + FIGURE_DISTANCE + 1, 180 rect->y() + FIGURE_DISTANCE + 1, 181 rect->width() - 3 * FIGURE_DISTANCE - 2, 182 rect->height() - 3 * FIGURE_DISTANCE - 2); 183 184 XCORE->fillRectangle(window, gc, 185 rect->x() + 2 * FIGURE_DISTANCE + 1, 186 rect->y() + 2 * FIGURE_DISTANCE + 1, 187 rect->width() - 3 * FIGURE_DISTANCE - 2, 188 rect->height() - 3 * FIGURE_DISTANCE - 2); 189 } 190 191 drawRectBorder(window, gc, rect, shineBorder, shadowBorder); 192 } 193 194 void Draw::drawCloseButton(Window window, GC gc, 195 Rectangle *rect, unsigned long background, 196 unsigned long shineBorder, unsigned long shadowBorder, 197 unsigned long shineFigure, unsigned long shadowFigure) 198 { 199 XCORE->setForeground(gc, background); 200 XCORE->fillRectangle(window, gc, rect); 201 202 int mx = rect->x() + rect->width() / 2; 203 int my = rect->y() + rect->height() / 2; 204 int md = FIGURE_DISTANCE / 2 + 1; 205 XPoint shineButtonPoints[3]; 206 shineButtonPoints[0].x = mx - md; 207 shineButtonPoints[0].y = my + md; 208 shineButtonPoints[1].x = shineButtonPoints[0].x; 209 shineButtonPoints[1].y = my - md; 210 shineButtonPoints[2].x = mx + md; 211 shineButtonPoints[2].y = shineButtonPoints[1].y; 212 XCORE->setForeground(gc, shineFigure); 213 XCORE->drawLines(window, gc, shineButtonPoints, 3); 214 215 XPoint shadowButtonPoints[3]; 216 shadowButtonPoints[0].x = mx + md; 217 shadowButtonPoints[0].y = my - md; 218 shadowButtonPoints[1].x = shadowButtonPoints[0].x; 219 shadowButtonPoints[1].y = my + md; 220 shadowButtonPoints[2].x = mx - md; 221 shadowButtonPoints[2].y = my + md; 222 XCORE->setForeground(gc, shadowFigure); 223 XCORE->drawLines(window, gc, shadowButtonPoints, 3); 224 225 drawRectBorder(window, gc, rect, shineBorder, shadowBorder); 226 } 227 228 void Draw::drawInputModeButton(Window window, GC gc, Rectangle *rect, 229 unsigned long background, 230 unsigned long shineBorder, unsigned long shadowBorder, 231 unsigned long shineFigure, unsigned long shadowFigure) 232 { 233 XCORE->setForeground(gc, background); 234 XCORE->fillRectangle(window, gc, rect); 235 236 XPoint shadowButtonPoints[2]; 237 shadowButtonPoints[0].x = rect->x() + 2 * FIGURE_DISTANCE; 238 shadowButtonPoints[0].y = rect->y() + FIGURE_DISTANCE; 239 shadowButtonPoints[1].x = rect->x() + 2 * FIGURE_DISTANCE; 240 shadowButtonPoints[1].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 241 shadowButtonPoints[2].x = rect->x() + FIGURE_DISTANCE; 242 shadowButtonPoints[2].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 243 XCORE->setForeground(gc, shadowFigure); 244 XCORE->drawLines(window, gc, shadowButtonPoints, 3); 245 246 shadowButtonPoints[0].x = rect->x() + rect->width() - FIGURE_DISTANCE - 1; 247 shadowButtonPoints[0].y = rect->y() + FIGURE_DISTANCE; 248 shadowButtonPoints[1].x = rect->x() + rect->width() - FIGURE_DISTANCE - 1; 249 shadowButtonPoints[1].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 250 shadowButtonPoints[2].x = rect->x() + rect->width() - 2 * FIGURE_DISTANCE - 1; 251 shadowButtonPoints[2].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 252 XCORE->drawLines(window, gc, shadowButtonPoints, 3); 253 254 XPoint shineButtonPoints[3]; 255 shineButtonPoints[0].x = rect->x() + FIGURE_DISTANCE; 256 shineButtonPoints[0].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 257 shineButtonPoints[1].x = rect->x() + FIGURE_DISTANCE; 258 shineButtonPoints[1].y = rect->y() + FIGURE_DISTANCE; 259 shineButtonPoints[2].x = rect->x() + 2 * FIGURE_DISTANCE; 260 shineButtonPoints[2].y = rect->y() + FIGURE_DISTANCE; 261 XCORE->setForeground(gc, shineFigure); 262 XCORE->drawLines(window, gc, shineButtonPoints, 3); 263 264 shineButtonPoints[0].x = rect->x() + rect->width() - 2 * FIGURE_DISTANCE - 1; 265 shineButtonPoints[0].y = rect->y() + rect->height() - FIGURE_DISTANCE - 1; 266 shineButtonPoints[1].x = rect->x() + rect->width() - 2 * FIGURE_DISTANCE - 1; 267 shineButtonPoints[1].y = rect->y() + FIGURE_DISTANCE; 268 shineButtonPoints[2].x = rect->x() + rect->width() - FIGURE_DISTANCE - 1; 269 shineButtonPoints[2].y = rect->y() + FIGURE_DISTANCE; 270 XCORE->drawLines(window, gc, shineButtonPoints, 3); 271 272 drawRectBorder(window, gc, rect, shineBorder, shadowBorder); 273 } 274 275 void Draw::drawMeter(Window window, GC gc, Rectangle *rect, 276 unsigned int percentage, unsigned long background, 277 unsigned long highFigure, unsigned long normalFigure, 278 unsigned long lowFigure, unsigned long shineBorder, 279 unsigned long shadowBorder) 280 { 281 XCORE->setForeground(gc, background); 282 XCORE->fillRectangle(window, gc, rect); 283 284 unsigned int pHeight = (rect->height() * percentage) / 100; 285 unsigned long figure = lowFigure; 286 if (percentage > 66) { 287 figure = highFigure; 288 } 289 else if (percentage > 33) { 290 figure = normalFigure; 291 } 292 XCORE->setForeground(gc, figure); 293 XCORE->fillRectangle(window, gc, 294 rect->x() + 1, rect->y() + (rect->height() - 1 - pHeight), 295 rect->width() - 2, pHeight); 296 297 drawRectBorder(window, gc, rect, shineBorder, shadowBorder); 298 } 299 300 void Draw::drawBorder(Window window, GC commonGC, 301 GC borderGC, Rectangle *rect, 302 unsigned long background, unsigned long shine, 303 unsigned long shadow, unsigned int titleBarHeight, 304 unsigned int borderWidth) 305 { 306 // titlebar 1px separator 307 XCORE->setForeground(commonGC, background); 308 if (titleBarHeight > 0 && borderWidth > 0) { 309 XPoint titleBorderPoints[2]; 310 titleBorderPoints[0].x = borderWidth; 311 titleBorderPoints[0].y = titleBarHeight; 312 titleBorderPoints[1].x = rect->width() - borderWidth; 313 titleBorderPoints[1].y = titleBarHeight; 314 XCORE->drawLines(window, commonGC, titleBorderPoints, 2); 315 } 316 317 if (borderWidth == 0) { 318 return; 319 } 320 321 // background border 322 XCORE->setForeground(borderGC, background); 323 XCORE->drawRectangle(window, borderGC, 324 borderWidth / 2, borderWidth / 2, 325 rect->width() - borderWidth, 326 rect->height() - borderWidth); 327 328 // shadow border 329 XPoint shadowBorderPoints[3]; 330 shadowBorderPoints[0].x = rect->width() - 1; 331 shadowBorderPoints[0].y = 0; 332 shadowBorderPoints[1].x = rect->width() - 1; 333 shadowBorderPoints[1].y = rect->height() - 1; 334 shadowBorderPoints[2].x = 0; 335 shadowBorderPoints[2].y = rect->height() - 1; 336 337 XCORE->setForeground(commonGC, shadow); 338 XCORE->drawLines(window, commonGC, shadowBorderPoints, 3); 339 340 // shine border 341 XPoint shineBorderPoints[3]; 342 shineBorderPoints[0].x = 0; 343 shineBorderPoints[0].y = rect->height() - 1; 344 shineBorderPoints[1].x = 0; 345 shineBorderPoints[1].y = 0; 346 shineBorderPoints[2].x = rect->width() - 1; 347 shineBorderPoints[2].y = 0; 348 349 XCORE->setForeground(commonGC, shine); 350 XCORE->drawLines(window, commonGC, shineBorderPoints, 3); 351 } 352 353 void Draw::drawFloatBorderAnchors(Window window, GC gc, Rectangle *rect, 354 unsigned long shine, unsigned long shadow, 355 unsigned int titleBarHeight, unsigned int borderWidth) 356 { 357 XCORE->setForeground(gc, shadow); 358 XCORE->drawLine(window, gc, titleBarHeight, 0, titleBarHeight, borderWidth); 359 XCORE->drawLine(window, gc, 0, titleBarHeight, borderWidth, titleBarHeight); 360 XCORE->drawLine(window, gc, 0, rect->height() - titleBarHeight - 1, 361 borderWidth, rect->height() - titleBarHeight); 362 XCORE->drawLine(window, gc, titleBarHeight, rect->height() - borderWidth, 363 titleBarHeight, rect->height()); 364 XCORE->drawLine(window, gc, rect->width() - titleBarHeight - 1, 0, 365 rect->width() - titleBarHeight - 1, borderWidth); 366 XCORE->drawLine(window, gc, rect->width() - borderWidth, titleBarHeight, 367 rect->width(), titleBarHeight); 368 XCORE->drawLine(window, gc, rect->width() - borderWidth, rect->height() 369 - titleBarHeight - 1, rect->width(), rect->height() 370 - titleBarHeight - 1); 371 XCORE->drawLine(window, gc, rect->width() - titleBarHeight - 1, 372 rect->height() - borderWidth, 373 rect->width() - titleBarHeight - 1, 374 rect->height()); 375 376 XCORE->setForeground(gc, shine); 377 XCORE->drawLine(window, gc, titleBarHeight + 1, 0, 378 titleBarHeight + 1, borderWidth); 379 XCORE->drawLine(window, gc, 0, titleBarHeight + 1, borderWidth, 380 titleBarHeight + 1); 381 XCORE->drawLine(window, gc, 0, rect->height() - titleBarHeight, 382 borderWidth, rect->height() - titleBarHeight); 383 XCORE->drawLine(window, gc, titleBarHeight + 1, 384 rect->height() - borderWidth, 385 titleBarHeight + 1, rect->height()); 386 XCORE->drawLine(window, gc, rect->width() - titleBarHeight, 0, 387 rect->width() - titleBarHeight, borderWidth); 388 XCORE->drawLine(window, gc, rect->width() - borderWidth, 389 titleBarHeight + 1, 390 rect->width(), titleBarHeight + 1); 391 XCORE->drawLine(window, gc, rect->width() - borderWidth, 392 rect->height() - titleBarHeight, 393 rect->width(), rect->height() - titleBarHeight); 394 XCORE->drawLine(window, gc, rect->width() - titleBarHeight, 395 rect->height() - borderWidth, 396 rect->width() - titleBarHeight, 397 rect->height()); 398 } 399 400 void Draw::drawShineBorder(Window window, GC gc, Rectangle *rect, 401 unsigned long shine) 402 { 403 XPoint shineBorderPoints[3]; 404 shineBorderPoints[0].x = rect->x(); 405 shineBorderPoints[0].y = rect->y() + rect->height() - 1; 406 shineBorderPoints[1].x = rect->x(); 407 shineBorderPoints[1].y = rect->y(); 408 shineBorderPoints[2].x = rect->x() + rect->width() - 1; 409 shineBorderPoints[2].y = rect->y(); 410 411 XCORE->setForeground(gc, shine); 412 XCORE->drawLines(window, gc, shineBorderPoints, 3); 413 } 414 415 void Draw::drawShadowBorder(Window window, GC gc, Rectangle *rect, 416 unsigned long shadow) 417 { 418 XPoint shadowBorderPoints[3]; 419 shadowBorderPoints[0].x = rect->x() + rect->width() - 1; 420 shadowBorderPoints[0].y = rect->y(); 421 shadowBorderPoints[1].x = rect->x() + rect->width() - 1; 422 shadowBorderPoints[1].y = rect->y() + rect->height() - 1; 423 shadowBorderPoints[2].x = rect->x(); 424 shadowBorderPoints[2].y = rect->y() + rect->height() - 1; 425 426 XCORE->setForeground(gc, shadow); 427 XCORE->drawLines(window, gc, shadowBorderPoints, 3); 428 } 429 430 void Draw::drawRectBorder(Window window, GC gc, Rectangle *rect, 431 unsigned long shine, unsigned long shadow) 432 { 433 drawShadowBorder(window, gc, rect, shadow); 434 drawShineBorder(window, gc, rect, shine); 435 } 436 437 void Draw::drawStickyNotifier(Window window, GC gc, Rectangle *rect, 438 unsigned long shine, unsigned long shadow, 439 unsigned int textWidth) 440 { 441 // We assume that the text is centered! 442 XCORE->setForeground(gc, shadow); 443 XCORE->drawLine(window, gc, 444 rect->x() + FIGURE_DISTANCE + 1, 445 rect->y() + FIGURE_DISTANCE + 2, 446 rect->x() + rect->width() / 2 - textWidth / 2 - FIGURE_DISTANCE - 1, 447 rect->y() + FIGURE_DISTANCE + 2); 448 449 XCORE->drawLine(window, gc, 450 rect->x() + FIGURE_DISTANCE + rect->width() / 2 + textWidth / 2 + FIGURE_DISTANCE, 451 rect->y() + FIGURE_DISTANCE + 2, 452 rect->x() + rect->width() - FIGURE_DISTANCE - 1, 453 rect->y() + FIGURE_DISTANCE + 2); 454 455 XCORE->drawLine(window, gc, 456 rect->x() + FIGURE_DISTANCE + 1, 457 rect->y() + rect->height() - FIGURE_DISTANCE - 1, 458 rect->x() + rect->width() / 2 - textWidth / 2 - FIGURE_DISTANCE - 1, 459 rect->y() + rect->height() - FIGURE_DISTANCE - 1); 460 461 XCORE->drawLine(window, gc, 462 rect->x() + FIGURE_DISTANCE + rect->width() / 2 + textWidth / 2 + FIGURE_DISTANCE, 463 rect->y() + rect->height() - FIGURE_DISTANCE - 1, 464 rect->x() + rect->width() - FIGURE_DISTANCE - 1, 465 rect->y() + rect->height() - FIGURE_DISTANCE - 1); 466 467 XCORE->setForeground(gc, shine); 468 XCORE->drawLine(window, gc, 469 rect->x() + FIGURE_DISTANCE + 1, 470 rect->y() + FIGURE_DISTANCE + 1, 471 rect->x() + rect->width() / 2 - textWidth / 2 - FIGURE_DISTANCE - 1, 472 rect->y() + FIGURE_DISTANCE + 1); 473 474 XCORE->drawLine(window, gc, 475 rect->x() + FIGURE_DISTANCE + rect->width() / 2 + textWidth / 2 + FIGURE_DISTANCE, 476 rect->y() + FIGURE_DISTANCE + 1, 477 rect->x() + rect->width() - FIGURE_DISTANCE - 1, 478 rect->y() + FIGURE_DISTANCE + 1); 479 480 XCORE->drawLine(window, gc, 481 rect->x() + FIGURE_DISTANCE + 1, 482 rect->y() + rect->height() - FIGURE_DISTANCE - 2, 483 rect->x() + rect->width() / 2 - textWidth / 2 - FIGURE_DISTANCE - 1, 484 rect->y() + rect->height() - FIGURE_DISTANCE - 2); 485 486 XCORE->drawLine(window, gc, 487 rect->x() + FIGURE_DISTANCE + rect->width() / 2 + textWidth / 2 + FIGURE_DISTANCE, 488 rect->y() + rect->height() - FIGURE_DISTANCE - 2, 489 rect->x() + rect->width() - FIGURE_DISTANCE - 1, 490 rect->y() + rect->height() - FIGURE_DISTANCE - 2); 491 } 492 493 void Draw::drawTransRectangle(Window window, GC gc, 494 Rectangle *rect, unsigned int barHeight, 495 unsigned int borderWidth) 496 { 497 XCORE->drawRectangle(window, gc, 498 rect->x(), rect->y(), 499 rect->width(), rect->height()); 500 501 unsigned int offsetY = borderWidth; 502 if (barHeight > 0) { 503 XCORE->drawLine(window, gc, 504 rect->x() + borderWidth / 2, 505 rect->y() + barHeight + 506 borderWidth, 507 rect->x() + rect->width() - 508 borderWidth / 2, 509 rect->y() + barHeight + 510 borderWidth); 511 offsetY += barHeight + borderWidth; 512 } 513 #if DIAMOND_BOX 514 XPoint orthRectPoints[3]; 515 516 orthRectPoints[0].x = rect->x() + rect->width() / 3; 517 orthRectPoints[0].y = rect->y() + rect->height() - borderWidth; 518 orthRectPoints[1].x = rect->x() + borderWidth; 519 orthRectPoints[1].y = rect->y() + rect->height() / 2 + offsetY / 2; 520 orthRectPoints[2].x = orthRectPoints[0].x; 521 orthRectPoints[2].y = rect->y() + offsetY; 522 XCORE->drawLines(window, gc, orthRectPoints, 3); 523 524 orthRectPoints[0].x = rect->x() + (2 * rect->width()) / 3; 525 orthRectPoints[0].y = rect->y() + offsetY; 526 orthRectPoints[1].x = rect->x() + rect->width() - borderWidth; 527 // same as above 528 //orthRectPoints[1].y = rect->y() + rect->height() / 2 + offsetY / 2; 529 orthRectPoints[2].x = orthRectPoints[0].x; 530 orthRectPoints[2].y = rect->y() + rect->height() - borderWidth; 531 XCORE->drawLines(window, gc, orthRectPoints, 3); 532 #endif 533 }