1 /* 2 * Copyright 2009-2017, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _HAIKU_CONTROL_LOOK_H 6 #define _HAIKU_CONTROL_LOOK_H 7 8 9 #include <ControlLook.h> 10 11 12 class BBitmap; 13 class BControl; 14 class BGradientLinear; 15 class BView; 16 17 18 namespace BPrivate { 19 20 21 class HaikuControlLook : public BControlLook { 22 public: 23 HaikuControlLook(); 24 virtual ~HaikuControlLook(); 25 26 virtual BAlignment DefaultLabelAlignment() const; 27 virtual float DefaultLabelSpacing() const; 28 29 virtual float DefaultItemSpacing() const; 30 31 static float ComposeSpacing(float spacing); 32 33 virtual uint32 Flags(BControl* control) const; 34 35 virtual void DrawButtonFrame(BView* view, BRect& rect, 36 const BRect& updateRect, 37 const rgb_color& base, 38 const rgb_color& background, 39 uint32 flags = 0, 40 uint32 borders = B_ALL_BORDERS); 41 virtual void DrawButtonFrame(BView* view, BRect& rect, 42 const BRect& updateRect, 43 float radius, 44 const rgb_color& base, 45 const rgb_color& background, 46 uint32 flags = 0, 47 uint32 borders = B_ALL_BORDERS); 48 virtual void DrawButtonFrame(BView* view, BRect& rect, 49 const BRect& updateRect, 50 float leftTopRadius, 51 float rightTopRadius, 52 float leftBottomRadius, 53 float rightBottomRadius, 54 const rgb_color& base, 55 const rgb_color& background, 56 uint32 flags = 0, 57 uint32 borders = B_ALL_BORDERS); 58 59 virtual void DrawButtonBackground(BView* view, BRect& rect, 60 const BRect& updateRect, 61 const rgb_color& base, 62 uint32 flags = 0, 63 uint32 borders = B_ALL_BORDERS, 64 orientation orientation = B_HORIZONTAL); 65 virtual void DrawButtonBackground(BView* view, BRect& rect, 66 const BRect& updateRect, 67 float radius, 68 const rgb_color& base, 69 uint32 flags = 0, 70 uint32 borders = B_ALL_BORDERS, 71 orientation orientation = B_HORIZONTAL); 72 virtual void DrawButtonBackground(BView* view, BRect& rect, 73 const BRect& updateRect, 74 float leftTopRadius, 75 float rightTopRadius, 76 float leftBottomRadius, 77 float rightBottomRadius, 78 const rgb_color& base, 79 uint32 flags = 0, 80 uint32 borders = B_ALL_BORDERS, 81 orientation orientation = B_HORIZONTAL); 82 83 virtual void DrawMenuBarBackground(BView* view, BRect& rect, 84 const BRect& updateRect, 85 const rgb_color& base, 86 uint32 flags = 0, 87 uint32 borders = B_ALL_BORDERS); 88 89 virtual void DrawMenuFieldFrame(BView* view, BRect& rect, 90 const BRect& updateRect, 91 const rgb_color& base, 92 const rgb_color& background, 93 uint32 flags = 0, 94 uint32 borders = B_ALL_BORDERS); 95 virtual void DrawMenuFieldFrame(BView* view, BRect& rect, 96 const BRect& updateRect, 97 float radius, 98 const rgb_color& base, 99 const rgb_color& background, 100 uint32 flags = 0, 101 uint32 borders = B_ALL_BORDERS); 102 virtual void DrawMenuFieldFrame(BView* view, BRect& rect, 103 const BRect& updateRect, 104 float leftTopRadius, 105 float rightTopRadius, 106 float leftBottomRadius, 107 float rightBottomRadius, 108 const rgb_color& base, 109 const rgb_color& background, 110 uint32 flags = 0, 111 uint32 borders = B_ALL_BORDERS); 112 113 virtual void DrawMenuFieldBackground(BView* view, 114 BRect& rect, const BRect& updateRect, 115 const rgb_color& base, bool popupIndicator, 116 uint32 flags = 0); 117 virtual void DrawMenuFieldBackground(BView* view, 118 BRect& rect, const BRect& updateRect, 119 float radius, const rgb_color& base, 120 bool popupIndicator, uint32 flags = 0); 121 virtual void DrawMenuFieldBackground(BView* view, 122 BRect& rect, const BRect& updateRect, 123 float leftTopRadius, 124 float rightTopRadius, 125 float leftBottomRadius, 126 float rightBottomRadius, 127 const rgb_color& base, 128 bool popupIndicator, uint32 flags = 0); 129 virtual void DrawMenuFieldBackground(BView* view, 130 BRect& rect, const BRect& updateRect, 131 const rgb_color& base, uint32 flags = 0, 132 uint32 borders = B_ALL_BORDERS); 133 134 virtual void DrawMenuBackground(BView* view, 135 BRect& rect, const BRect& updateRect, 136 const rgb_color& base, uint32 flags = 0, 137 uint32 borders = B_ALL_BORDERS); 138 139 virtual void DrawMenuItemBackground(BView* view, 140 BRect& rect, const BRect& updateRect, 141 const rgb_color& base, uint32 flags = 0, 142 uint32 borders = B_ALL_BORDERS); 143 144 virtual void DrawStatusBar(BView* view, BRect& rect, 145 const BRect& updateRect, 146 const rgb_color& base, 147 const rgb_color& barColor, 148 float progressPosition); 149 150 virtual void DrawCheckBox(BView* view, BRect& rect, 151 const BRect& updateRect, 152 const rgb_color& base, 153 uint32 flags = 0); 154 155 virtual void DrawRadioButton(BView* view, BRect& rect, 156 const BRect& updateRect, 157 const rgb_color& base, 158 uint32 flags = 0); 159 160 virtual void DrawScrollBarBackground(BView* view, 161 BRect& rect1, BRect& rect2, 162 const BRect& updateRect, 163 const rgb_color& base, uint32 flags, 164 orientation orientation); 165 virtual void DrawScrollBarBackground(BView* view, 166 BRect& rect, const BRect& updateRect, 167 const rgb_color& base, uint32 flags, 168 orientation orientation); 169 170 virtual void DrawScrollViewFrame(BView* view, 171 BRect& rect, const BRect& updateRect, 172 BRect verticalScrollBarFrame, 173 BRect horizontalScrollBarFrame, 174 const rgb_color& base, 175 border_style borderStyle, 176 uint32 flags = 0, 177 uint32 borders = B_ALL_BORDERS); 178 179 virtual void DrawArrowShape(BView* view, 180 BRect& rect, const BRect& updateRect, 181 const rgb_color& base, uint32 direction, 182 uint32 flags = 0, 183 float tint = B_DARKEN_MAX_TINT); 184 185 virtual rgb_color SliderBarColor(const rgb_color& base); 186 187 virtual void DrawSliderBar(BView* view, BRect rect, 188 const BRect& updateRect, 189 const rgb_color& base, 190 rgb_color leftFillColor, 191 rgb_color rightFillColor, 192 float sliderScale, uint32 flags, 193 orientation orientation); 194 virtual void DrawSliderBar(BView* view, BRect rect, 195 const BRect& updateRect, 196 const rgb_color& base, rgb_color fillColor, 197 uint32 flags, orientation orientation); 198 199 virtual void DrawSliderThumb(BView* view, BRect& rect, 200 const BRect& updateRect, 201 const rgb_color& base, uint32 flags, 202 orientation orientation); 203 204 virtual void DrawSliderTriangle(BView* view, BRect& rect, 205 const BRect& updateRect, 206 const rgb_color& base, uint32 flags, 207 orientation orientation); 208 virtual void DrawSliderTriangle(BView* view, BRect& rect, 209 const BRect& updateRect, 210 const rgb_color& base, 211 const rgb_color& fill, uint32 flags, 212 orientation orientation); 213 214 virtual void DrawSliderHashMarks(BView* view, BRect& rect, 215 const BRect& updateRect, 216 const rgb_color& base, int32 count, 217 hash_mark_location location, 218 uint32 flags, orientation orientation); 219 220 virtual void DrawActiveTab(BView* view, BRect& rect, 221 const BRect& updateRect, 222 const rgb_color& base, uint32 flags = 0, 223 uint32 borders = B_ALL_BORDERS, 224 uint32 side = B_TOP_BORDER); 225 226 virtual void DrawInactiveTab(BView* view, BRect& rect, 227 const BRect& updateRect, 228 const rgb_color& base, uint32 flags = 0, 229 uint32 borders = B_ALL_BORDERS, 230 uint32 side = B_TOP_BORDER); 231 232 virtual void DrawSplitter(BView* view, BRect& rect, 233 const BRect& updateRect, 234 const rgb_color& base, 235 orientation orientation, 236 uint32 flags = 0, 237 uint32 borders = B_ALL_BORDERS); 238 239 // various borders 240 241 virtual void DrawBorder(BView* view, BRect& rect, 242 const BRect& updateRect, 243 const rgb_color& base, 244 border_style borderStyle, uint32 flags = 0, 245 uint32 borders = B_ALL_BORDERS); 246 247 virtual void DrawRaisedBorder(BView* view, BRect& rect, 248 const BRect& updateRect, 249 const rgb_color& base, uint32 flags = 0, 250 uint32 borders = B_ALL_BORDERS); 251 252 virtual void DrawGroupFrame(BView* view, BRect& rect, 253 const BRect& updateRect, 254 const rgb_color& base, 255 uint32 borders = B_ALL_BORDERS); 256 257 virtual void DrawTextControlBorder(BView* view, BRect& rect, 258 const BRect& updateRect, 259 const rgb_color& base, uint32 flags = 0, 260 uint32 borders = B_ALL_BORDERS); 261 262 // aligned labels 263 264 virtual void DrawLabel(BView* view, const char* label, 265 BRect rect, const BRect& updateRect, 266 const rgb_color& base, uint32 flags, 267 const rgb_color* textColor = NULL); 268 virtual void DrawLabel(BView* view, const char* label, 269 BRect rect, const BRect& updateRect, 270 const rgb_color& base, uint32 flags, 271 const BAlignment& alignment, 272 const rgb_color* textColor = NULL); 273 // TODO: Would be nice to have a (non-virtual) version of this method 274 // which takes an array of labels and locations. That would save some 275 // setup with the view graphics state. 276 virtual void DrawLabel(BView* view, const char* label, 277 const rgb_color& base, uint32 flags, 278 const BPoint& where, 279 const rgb_color* textColor = NULL); 280 281 virtual void DrawLabel(BView* view, const char* label, 282 const BBitmap* icon, BRect rect, 283 const BRect& updateRect, 284 const rgb_color& base, uint32 flags, 285 const BAlignment& alignment, 286 const rgb_color* textColor = NULL); 287 288 virtual void GetFrameInsets(frame_type frameType, 289 uint32 flags, float& _left, float& _top, 290 float& _right, float& _bottom); 291 virtual void GetBackgroundInsets( 292 background_type backgroundType, 293 uint32 flags, float& _left, float& _top, 294 float& _right, float& _bottom); 295 296 virtual void DrawButtonWithPopUpBackground(BView* view, 297 BRect& rect, const BRect& updateRect, 298 const rgb_color& base, 299 uint32 flags = 0, 300 uint32 borders = B_ALL_BORDERS, 301 orientation orientation = B_HORIZONTAL); 302 virtual void DrawButtonWithPopUpBackground(BView* view, 303 BRect& rect, const BRect& updateRect, 304 float radius, 305 const rgb_color& base, 306 uint32 flags = 0, 307 uint32 borders = B_ALL_BORDERS, 308 orientation orientation = B_HORIZONTAL); 309 virtual void DrawButtonWithPopUpBackground(BView* view, 310 BRect& rect, const BRect& updateRect, 311 float leftTopRadius, 312 float rightTopRadius, 313 float leftBottomRadius, 314 float rightBottomRadius, 315 const rgb_color& base, 316 uint32 flags = 0, 317 uint32 borders = B_ALL_BORDERS, 318 orientation orientation = B_HORIZONTAL); 319 320 protected: 321 void _DrawButtonFrame(BView* view, BRect& rect, 322 const BRect& updateRect, 323 float leftTopRadius, 324 float rightTopRadius, 325 float leftBottomRadius, 326 float rightBottomRadius, 327 const rgb_color& base, 328 const rgb_color& background, 329 float contrast, float brightness = 1.0, 330 uint32 flags = 0, 331 uint32 borders = B_ALL_BORDERS); 332 333 void _DrawOuterResessedFrame(BView* view, 334 BRect& rect, const rgb_color& base, 335 float contrast = 1.0f, 336 float brightness = 1.0f, 337 uint32 flags = 0, 338 uint32 borders = B_ALL_BORDERS); 339 340 void _DrawFrame(BView* view, BRect& rect, 341 const rgb_color& left, 342 const rgb_color& top, 343 const rgb_color& right, 344 const rgb_color& bottom, 345 uint32 borders = B_ALL_BORDERS); 346 void _DrawFrame(BView* view, BRect& rect, 347 const rgb_color& left, 348 const rgb_color& top, 349 const rgb_color& right, 350 const rgb_color& bottom, 351 const rgb_color& rightTop, 352 const rgb_color& leftBottom, 353 uint32 borders = B_ALL_BORDERS); 354 355 void _DrawButtonBackground(BView* view, BRect& rect, 356 const BRect& updateRect, 357 float leftTopRadius, 358 float rightTopRadius, 359 float leftBottomRadius, 360 float rightBottomRadius, 361 const rgb_color& base, 362 bool popupIndicator = false, 363 uint32 flags = 0, 364 uint32 borders = B_ALL_BORDERS, 365 orientation orientation = B_HORIZONTAL); 366 void _DrawFlatButtonBackground(BView* view, 367 BRect& rect, const BRect& updateRect, 368 const rgb_color& base, 369 bool popupIndicator = false, 370 uint32 flags = 0, 371 uint32 borders = B_ALL_BORDERS, 372 orientation orientation = B_HORIZONTAL); 373 void _DrawNonFlatButtonBackground(BView* view, 374 BRect& rect, const BRect& updateRect, 375 BRegion& clipping, 376 float leftTopRadius, 377 float rightTopRadius, 378 float leftBottomRadius, 379 float rightBottomRadius, 380 const rgb_color& base, 381 bool popupIndicator = false, 382 uint32 flags = 0, 383 uint32 borders = B_ALL_BORDERS, 384 orientation orientation = B_HORIZONTAL); 385 386 void _DrawPopUpMarker(BView* view, const BRect& rect, 387 const rgb_color& base, uint32 flags); 388 389 void _DrawMenuFieldBackgroundOutside(BView* view, 390 BRect& rect, const BRect& updateRect, 391 float leftTopRadius, 392 float rightTopRadius, 393 float leftBottomRadius, 394 float rightBottomRadius, 395 const rgb_color& base, 396 bool popupIndicator = false, 397 uint32 flags = 0); 398 399 void _DrawMenuFieldBackgroundInside(BView* view, 400 BRect& rect, const BRect& updateRect, 401 float leftTopRadius, 402 float rightTopRadius, 403 float leftBottomRadius, 404 float rightBottomRadius, 405 const rgb_color& base, uint32 flags = 0, 406 uint32 borders = B_ALL_BORDERS); 407 408 // Rounded corner methods 409 void _DrawRoundCornerLeftTop(BView* view, 410 BRect& cornerRect, const BRect& updateRect, 411 const rgb_color& background, 412 const rgb_color& edgeColor, 413 const rgb_color& frameColor, 414 const rgb_color& bevelColor, 415 const BGradientLinear& fillGradient); 416 417 void _DrawRoundCornerFrameLeftTop(BView* view, 418 BRect& cornerRect, const BRect& updateRect, 419 const rgb_color& background, 420 const rgb_color& edgeColor, 421 const rgb_color& frameColor); 422 423 void _DrawRoundCornerBackgroundLeftTop(BView* view, 424 BRect& cornerRect, const BRect& updateRect, 425 const rgb_color& bevelColor, 426 const BGradientLinear& fillGradient); 427 428 void _DrawRoundCornerRightTop(BView* view, 429 BRect& cornerRect, const BRect& updateRect, 430 const rgb_color& background, 431 const rgb_color& edgeTopColor, 432 const rgb_color& edgeRightColor, 433 const rgb_color& frameTopColor, 434 const rgb_color& frameRightColor, 435 const rgb_color& bevelTopColor, 436 const rgb_color& bevelRightColor, 437 const BGradientLinear& fillGradient); 438 439 void _DrawRoundCornerFrameRightTop(BView* view, 440 BRect& cornerRect, const BRect& updateRect, 441 const rgb_color& background, 442 const rgb_color& edgeTopColor, 443 const rgb_color& edgeRightColor, 444 const rgb_color& frameTopColor, 445 const rgb_color& frameRightColor); 446 447 void _DrawRoundCornerBackgroundRightTop(BView* view, 448 BRect& cornerRect, const BRect& updateRect, 449 const rgb_color& bevelTopColor, 450 const rgb_color& bevelRightColor, 451 const BGradientLinear& fillGradient); 452 453 void _DrawRoundCornerLeftBottom(BView* view, 454 BRect& cornerRect, const BRect& updateRect, 455 const rgb_color& background, 456 const rgb_color& edgeLeftColor, 457 const rgb_color& edgeBottomColor, 458 const rgb_color& frameLeftColor, 459 const rgb_color& frameBottomColor, 460 const rgb_color& bevelLeftColor, 461 const rgb_color& bevelBottomColor, 462 const BGradientLinear& fillGradient); 463 464 void _DrawRoundCornerFrameLeftBottom(BView* view, 465 BRect& cornerRect, const BRect& updateRect, 466 const rgb_color& background, 467 const rgb_color& edgeLeftColor, 468 const rgb_color& edgeBottomColor, 469 const rgb_color& frameLeftColor, 470 const rgb_color& frameBottomColor); 471 472 void _DrawRoundCornerBackgroundLeftBottom(BView* view, 473 BRect& cornerRect, const BRect& updateRect, 474 const rgb_color& bevelLeftColor, 475 const rgb_color& bevelBottomColor, 476 const BGradientLinear& fillGradient); 477 478 void _DrawRoundCornerRightBottom(BView* view, 479 BRect& cornerRect, const BRect& updateRect, 480 const rgb_color& background, 481 const rgb_color& edgeColor, 482 const rgb_color& frameColor, 483 const rgb_color& bevelColor, 484 const BGradientLinear& fillGradient); 485 486 void _DrawRoundCornerFrameRightBottom(BView* view, 487 BRect& cornerRect, const BRect& updateRect, 488 const rgb_color& background, 489 const rgb_color& edgeColor, 490 const rgb_color& frameColor); 491 492 void _DrawRoundCornerBackgroundRightBottom( 493 BView* view, 494 BRect& cornerRect, const BRect& updateRect, 495 const rgb_color& bevelColor, 496 const BGradientLinear& fillGradient); 497 498 void _DrawRoundBarCorner(BView* view, BRect& rect, 499 const BRect& updateRect, 500 const rgb_color& edgeLightColor, 501 const rgb_color& edgeShadowColor, 502 const rgb_color& frameLightColor, 503 const rgb_color& frameShadowColor, 504 const rgb_color& fillLightColor, 505 const rgb_color& fillShadowColor, 506 float leftInset, float topInset, 507 float rightInset, float bottomInset, 508 orientation orientation); 509 510 // Border color methods 511 rgb_color _EdgeLightColor(const rgb_color& base, 512 float contrast, float brightness, 513 uint32 flags); 514 515 rgb_color _EdgeShadowColor(const rgb_color& base, 516 float contrast, float brightness, 517 uint32 flags); 518 519 rgb_color _FrameLightColor(const rgb_color& base, 520 uint32 flags); 521 522 rgb_color _FrameShadowColor(const rgb_color& base, 523 uint32 flags); 524 525 rgb_color _BevelLightColor(const rgb_color& base, 526 uint32 flags); 527 528 rgb_color _BevelShadowColor(const rgb_color& base, 529 uint32 flags); 530 531 // Background gradient methods 532 void _FillGradient(BView* view, const BRect& rect, 533 const rgb_color& base, float topTint, 534 float bottomTint, 535 orientation orientation = B_HORIZONTAL); 536 537 void _FillGlossyGradient(BView* view, 538 const BRect& rect, const rgb_color& base, 539 float topTint, float middle1Tint, 540 float middle2Tint, float bottomTint, 541 orientation orientation = B_HORIZONTAL); 542 543 void _MakeGradient(BGradientLinear& gradient, 544 const BRect& rect, const rgb_color& base, 545 float topTint, float bottomTint, 546 orientation orientation = B_HORIZONTAL) const; 547 548 void _MakeGlossyGradient(BGradientLinear& gradient, 549 const BRect& rect, const rgb_color& base, 550 float topTint, float middle1Tint, 551 float middle2Tint, float bottomTint, 552 orientation orientation = B_HORIZONTAL) const; 553 554 void _MakeButtonGradient(BGradientLinear& gradient, 555 BRect& rect, const rgb_color& base, 556 uint32 flags, orientation orientation = B_HORIZONTAL) const; 557 558 bool _RadioButtonAndCheckBoxMarkColor( 559 const rgb_color& base, rgb_color& color, 560 uint32 flags) const; 561 562 private: 563 bool fCachedOutline; 564 }; 565 566 567 } // namespace BPrivate 568 569 #endif // _HAIKU_CONTROL_LOOK_H 570