1 /* 2 * Copyright 2009-2020 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _CONTROL_LOOK_H 6 #define _CONTROL_LOOK_H 7 8 9 #include <Alignment.h> 10 #include <Font.h> 11 #include <Rect.h> 12 #include <Slider.h> 13 14 15 class BBitmap; 16 class BControl; 17 class BGradientLinear; 18 class BView; 19 20 21 // WARNING! This is experimental API and may change! Be prepared to 22 // recompile your software in a next version of haiku. 23 24 25 namespace BPrivate { 26 27 28 class BControlLook { 29 public: 30 BControlLook(); 31 virtual ~BControlLook(); 32 33 // TODO: Probably more convenient to pull these enums into global 34 // namespace and rename them to e.g. "B_CONTROL_LOOK_FOCUSED" instead of 35 // "BControlLook::B_FOCUSED". 36 37 enum frame_type { 38 B_BUTTON_FRAME, 39 B_GROUP_FRAME, 40 B_MENU_FIELD_FRAME, 41 B_SCROLL_VIEW_FRAME, 42 B_TEXT_CONTROL_FRAME, 43 }; 44 45 enum background_type { 46 B_BUTTON_BACKGROUND, 47 B_BUTTON_WITH_POP_UP_BACKGROUND, 48 B_MENU_BACKGROUND, 49 B_MENU_BAR_BACKGROUND, 50 B_MENU_FIELD_BACKGROUND, 51 B_MENU_ITEM_BACKGROUND, 52 B_HORIZONTAL_SCROLL_BAR_BACKGROUND, 53 B_VERTICAL_SCROLL_BAR_BACKGROUND, 54 }; 55 56 enum { 57 B_LEFT_BORDER = 1 << 0, 58 B_RIGHT_BORDER = 1 << 1, 59 B_TOP_BORDER = 1 << 2, 60 B_BOTTOM_BORDER = 1 << 3, 61 62 B_ALL_BORDERS = B_LEFT_BORDER | B_RIGHT_BORDER 63 | B_TOP_BORDER | B_BOTTOM_BORDER 64 }; 65 66 enum { 67 B_LEFT_ARROW = 0, 68 B_RIGHT_ARROW = 1, 69 B_UP_ARROW = 2, 70 B_DOWN_ARROW = 3, 71 B_LEFT_UP_ARROW = 4, 72 B_RIGHT_UP_ARROW = 5, 73 B_RIGHT_DOWN_ARROW = 6, 74 B_LEFT_DOWN_ARROW = 7 75 }; 76 77 enum { 78 B_FOCUSED = 1 << 0, 79 B_CLICKED = 1 << 1, // some controls activate on mouse up 80 B_ACTIVATED = 1 << 2, 81 B_HOVER = 1 << 3, 82 B_DISABLED = 1 << 4, 83 B_DEFAULT_BUTTON = 1 << 5, 84 B_IGNORE_OUTLINE = 1 << 6, 85 B_PARTIALLY_ACTIVATED = 1 << 7, // like B_ACTIVATED, but for tri-state 86 B_FLAT = 1 << 8, // flat look (e.g. button background) 87 B_INVALID = 1 << 9, // invalid value, use B_FAILURE_COLOR 88 B_IS_CONTROL = 1 << 10, // use control colors 89 90 B_BLEND_FRAME = 1 << 16, 91 }; 92 93 enum { 94 B_KNOB_NONE = 0, 95 B_KNOB_DOTS, 96 B_KNOB_LINES 97 }; 98 99 virtual BAlignment DefaultLabelAlignment() const = 0; 100 virtual float DefaultLabelSpacing() const = 0; 101 102 virtual float DefaultItemSpacing() const = 0; 103 104 static float ComposeSpacing(float spacing); 105 106 virtual uint32 Flags(BControl* control) const = 0; 107 108 virtual void DrawButtonFrame(BView* view, BRect& rect, 109 const BRect& updateRect, 110 const rgb_color& base, 111 const rgb_color& background, 112 uint32 flags = 0, 113 uint32 borders = B_ALL_BORDERS) = 0; 114 virtual void DrawButtonFrame(BView* view, BRect& rect, 115 const BRect& updateRect, 116 float radius, 117 const rgb_color& base, 118 const rgb_color& background, 119 uint32 flags = 0, 120 uint32 borders = B_ALL_BORDERS) = 0; 121 virtual void DrawButtonFrame(BView* view, BRect& rect, 122 const BRect& updateRect, 123 float leftTopRadius, 124 float rightTopRadius, 125 float leftBottomRadius, 126 float rightBottomRadius, 127 const rgb_color& base, 128 const rgb_color& background, 129 uint32 flags = 0, 130 uint32 borders = B_ALL_BORDERS) = 0; 131 132 virtual void DrawButtonBackground(BView* view, BRect& rect, 133 const BRect& updateRect, 134 const rgb_color& base, 135 uint32 flags = 0, 136 uint32 borders = B_ALL_BORDERS, 137 orientation orientation = B_HORIZONTAL) = 0; 138 virtual void DrawButtonBackground(BView* view, BRect& rect, 139 const BRect& updateRect, 140 float radius, 141 const rgb_color& base, 142 uint32 flags = 0, 143 uint32 borders = B_ALL_BORDERS, 144 orientation orientation = B_HORIZONTAL) = 0; 145 virtual void DrawButtonBackground(BView* view, BRect& rect, 146 const BRect& updateRect, 147 float leftTopRadius, 148 float rightTopRadius, 149 float leftBottomRadius, 150 float rightBottomRadius, 151 const rgb_color& base, 152 uint32 flags = 0, 153 uint32 borders = B_ALL_BORDERS, 154 orientation orientation = B_HORIZONTAL) = 0; 155 156 virtual void DrawMenuBarBackground(BView* view, BRect& rect, 157 const BRect& updateRect, 158 const rgb_color& base, 159 uint32 flags = 0, 160 uint32 borders = B_ALL_BORDERS) = 0; 161 162 virtual void DrawMenuFieldFrame(BView* view, BRect& rect, 163 const BRect& updateRect, 164 const rgb_color& base, 165 const rgb_color& background, 166 uint32 flags = 0, 167 uint32 borders = B_ALL_BORDERS) = 0; 168 virtual void DrawMenuFieldFrame(BView* view, BRect& rect, 169 const BRect& updateRect, 170 float radius, 171 const rgb_color& base, 172 const rgb_color& background, 173 uint32 flags = 0, 174 uint32 borders = B_ALL_BORDERS) = 0; 175 virtual void DrawMenuFieldFrame(BView* view, BRect& rect, 176 const BRect& updateRect, 177 float leftTopRadius, 178 float rightTopRadius, 179 float leftBottomRadius, 180 float rightBottomRadius, 181 const rgb_color& base, 182 const rgb_color& background, 183 uint32 flags = 0, 184 uint32 borders = B_ALL_BORDERS) = 0; 185 186 virtual void DrawMenuFieldBackground(BView* view, 187 BRect& rect, const BRect& updateRect, 188 const rgb_color& base, bool popupIndicator, 189 uint32 flags = 0) = 0; 190 virtual void DrawMenuFieldBackground(BView* view, 191 BRect& rect, const BRect& updateRect, 192 float radius, const rgb_color& base, 193 bool popupIndicator, uint32 flags = 0) = 0; 194 virtual void DrawMenuFieldBackground(BView* view, 195 BRect& rect, const BRect& updateRect, 196 float leftTopRadius, 197 float rightTopRadius, 198 float leftBottomRadius, 199 float rightBottomRadius, 200 const rgb_color& base, 201 bool popupIndicator, uint32 flags = 0) = 0; 202 virtual void DrawMenuFieldBackground(BView* view, 203 BRect& rect, const BRect& updateRect, 204 const rgb_color& base, uint32 flags = 0, 205 uint32 borders = B_ALL_BORDERS) = 0; 206 207 virtual void DrawMenuBackground(BView* view, 208 BRect& rect, const BRect& updateRect, 209 const rgb_color& base, uint32 flags = 0, 210 uint32 borders = B_ALL_BORDERS) = 0; 211 212 virtual void DrawMenuItemBackground(BView* view, 213 BRect& rect, const BRect& updateRect, 214 const rgb_color& base, uint32 flags = 0, 215 uint32 borders = B_ALL_BORDERS) = 0; 216 217 virtual void DrawStatusBar(BView* view, BRect& rect, 218 const BRect& updateRect, 219 const rgb_color& base, 220 const rgb_color& barColor, 221 float progressPosition) = 0; 222 223 virtual void DrawCheckBox(BView* view, BRect& rect, 224 const BRect& updateRect, 225 const rgb_color& base, 226 uint32 flags = 0) = 0; 227 228 virtual void DrawRadioButton(BView* view, BRect& rect, 229 const BRect& updateRect, 230 const rgb_color& base, 231 uint32 flags = 0) = 0; 232 233 virtual void DrawScrollBarBackground(BView* view, 234 BRect& rect1, BRect& rect2, 235 const BRect& updateRect, 236 const rgb_color& base, uint32 flags, 237 orientation orientation) = 0; 238 virtual void DrawScrollBarBackground(BView* view, 239 BRect& rect, const BRect& updateRect, 240 const rgb_color& base, uint32 flags, 241 orientation orientation) = 0; 242 243 virtual void DrawScrollViewFrame(BView* view, 244 BRect& rect, const BRect& updateRect, 245 BRect verticalScrollBarFrame, 246 BRect horizontalScrollBarFrame, 247 const rgb_color& base, 248 border_style borderStyle, 249 uint32 flags = 0, 250 uint32 borders = B_ALL_BORDERS) = 0; 251 252 virtual void DrawArrowShape(BView* view, 253 BRect& rect, const BRect& updateRect, 254 const rgb_color& base, uint32 direction, 255 uint32 flags = 0, 256 float tint = B_DARKEN_MAX_TINT) = 0; 257 258 virtual rgb_color SliderBarColor(const rgb_color& base) = 0; 259 260 virtual void DrawSliderBar(BView* view, BRect rect, 261 const BRect& updateRect, 262 const rgb_color& base, 263 rgb_color leftFillColor, 264 rgb_color rightFillColor, 265 float sliderScale, uint32 flags, 266 orientation orientation) = 0; 267 virtual void DrawSliderBar(BView* view, BRect rect, 268 const BRect& updateRect, 269 const rgb_color& base, rgb_color fillColor, 270 uint32 flags, orientation orientation) = 0; 271 272 virtual void DrawSliderThumb(BView* view, BRect& rect, 273 const BRect& updateRect, 274 const rgb_color& base, uint32 flags, 275 orientation orientation) = 0; 276 277 virtual void DrawSliderTriangle(BView* view, BRect& rect, 278 const BRect& updateRect, 279 const rgb_color& base, uint32 flags, 280 orientation orientation) = 0; 281 virtual void DrawSliderTriangle(BView* view, BRect& rect, 282 const BRect& updateRect, 283 const rgb_color& base, 284 const rgb_color& fill, uint32 flags, 285 orientation orientation) = 0; 286 287 virtual void DrawSliderHashMarks(BView* view, BRect& rect, 288 const BRect& updateRect, 289 const rgb_color& base, int32 count, 290 hash_mark_location location, 291 uint32 flags, orientation orientation) = 0; 292 293 virtual void DrawActiveTab(BView* view, BRect& rect, 294 const BRect& updateRect, 295 const rgb_color& base, uint32 flags = 0, 296 uint32 borders = B_ALL_BORDERS, 297 uint32 side = B_TOP_BORDER, 298 int32 index = 0, int32 selected = -1, 299 int32 first = 0, int32 last = 0) = 0; 300 virtual void DrawInactiveTab(BView* view, BRect& rect, 301 const BRect& updateRect, 302 const rgb_color& base, uint32 flags = 0, 303 uint32 borders = B_ALL_BORDERS, 304 uint32 side = B_TOP_BORDER, 305 int32 index = 0, int32 selected = -1, 306 int32 first = 0, int32 last = 0) = 0; 307 308 virtual void DrawSplitter(BView* view, BRect& rect, 309 const BRect& updateRect, 310 const rgb_color& base, 311 orientation orientation, 312 uint32 flags = 0, 313 uint32 borders = B_ALL_BORDERS) = 0; 314 315 // various borders 316 317 virtual void DrawBorder(BView* view, BRect& rect, 318 const BRect& updateRect, 319 const rgb_color& base, 320 border_style borderStyle, uint32 flags = 0, 321 uint32 borders = B_ALL_BORDERS) = 0; 322 323 virtual void DrawRaisedBorder(BView* view, BRect& rect, 324 const BRect& updateRect, 325 const rgb_color& base, uint32 flags = 0, 326 uint32 borders = B_ALL_BORDERS) = 0; 327 328 virtual void DrawGroupFrame(BView* view, BRect& rect, 329 const BRect& updateRect, 330 const rgb_color& base, 331 uint32 borders = B_ALL_BORDERS) = 0; 332 333 virtual void DrawTextControlBorder(BView* view, BRect& rect, 334 const BRect& updateRect, 335 const rgb_color& base, uint32 flags = 0, 336 uint32 borders = B_ALL_BORDERS) = 0; 337 338 // aligned labels 339 340 virtual void DrawLabel(BView* view, const char* label, 341 BRect rect, const BRect& updateRect, 342 const rgb_color& base, uint32 flags, 343 const rgb_color* textColor = NULL) = 0; 344 virtual void DrawLabel(BView* view, const char* label, 345 BRect rect, const BRect& updateRect, 346 const rgb_color& base, uint32 flags, 347 const BAlignment& alignment, 348 const rgb_color* textColor = NULL) = 0; 349 // TODO: Would be nice to have a (non-virtual) version of this method 350 // which takes an array of labels and locations. That would save some 351 // setup with the view graphics state. 352 virtual void DrawLabel(BView* view, const char* label, 353 const rgb_color& base, uint32 flags, 354 const BPoint& where, 355 const rgb_color* textColor = NULL) = 0; 356 357 void DrawLabel(BView* view, const char* label, 358 const BBitmap* icon, BRect rect, 359 const BRect& updateRect, 360 const rgb_color& base, uint32 flags, 361 const rgb_color* textColor = NULL); 362 virtual void DrawLabel(BView* view, const char* label, 363 const BBitmap* icon, BRect rect, 364 const BRect& updateRect, 365 const rgb_color& base, uint32 flags, 366 const BAlignment& alignment, 367 const rgb_color* textColor = NULL) = 0; 368 369 virtual void GetFrameInsets(frame_type frameType, 370 uint32 flags, float& _left, float& _top, 371 float& _right, float& _bottom) = 0; 372 virtual void GetBackgroundInsets( 373 background_type backgroundType, 374 uint32 flags, float& _left, float& _top, 375 float& _right, float& _bottom) = 0; 376 void GetInsets(frame_type frameType, 377 background_type backgroundType, 378 uint32 flags, float& _left, float& _top, 379 float& _right, float& _bottom); 380 381 virtual void DrawButtonWithPopUpBackground(BView* view, 382 BRect& rect, const BRect& updateRect, 383 const rgb_color& base, 384 uint32 flags = 0, 385 uint32 borders = B_ALL_BORDERS, 386 orientation orientation = B_HORIZONTAL) = 0; 387 virtual void DrawButtonWithPopUpBackground(BView* view, 388 BRect& rect, const BRect& updateRect, 389 float radius, 390 const rgb_color& base, 391 uint32 flags = 0, 392 uint32 borders = B_ALL_BORDERS, 393 orientation orientation = B_HORIZONTAL) = 0; 394 virtual void DrawButtonWithPopUpBackground(BView* view, 395 BRect& rect, const BRect& updateRect, 396 float leftTopRadius, 397 float rightTopRadius, 398 float leftBottomRadius, 399 float rightBottomRadius, 400 const rgb_color& base, 401 uint32 flags = 0, 402 uint32 borders = B_ALL_BORDERS, 403 orientation orientation = B_HORIZONTAL) = 0; 404 405 void SetBackgroundInfo( 406 const BMessage& backgroundInfo); 407 408 virtual void DrawTabFrame(BView* view, BRect& rect, 409 const BRect& updateRect, 410 const rgb_color& base, uint32 flags = 0, 411 uint32 borders = B_ALL_BORDERS, 412 border_style borderStyle = B_FANCY_BORDER, 413 uint32 side = B_TOP_BORDER) = 0; 414 415 virtual void DrawScrollBarButton(BView* view, 416 BRect rect, const BRect& updateRect, 417 const rgb_color& base, uint32 flags, 418 int32 direction, orientation orientation, 419 bool down = false) = 0; 420 virtual void DrawScrollBarThumb(BView* view, 421 BRect& rect, const BRect& updateRect, 422 const rgb_color& base, uint32 flags, 423 orientation orientation, 424 uint32 knobStyle = B_KNOB_NONE) = 0; 425 virtual void DrawScrollBarBorder(BView* view, 426 BRect rect, const BRect& updateRect, 427 const rgb_color& base, uint32 flags, 428 orientation orientation) = 0; 429 virtual float GetScrollBarWidth( 430 orientation orientation = B_VERTICAL); 431 432 private: 433 // FBC padding 434 virtual void _ReservedControlLook6(); 435 virtual void _ReservedControlLook7(); 436 virtual void _ReservedControlLook8(); 437 virtual void _ReservedControlLook9(); 438 virtual void _ReservedControlLook10(); 439 440 protected: 441 int32 fCachedWorkspace; 442 BMessage fBackgroundInfo; 443 444 uint32 _reserved[20]; 445 }; 446 447 extern BControlLook* be_control_look; 448 449 extern "C" _EXPORT BControlLook *instantiate_control_look(image_id id); 450 451 452 } // namespace BPrivate 453 454 using BPrivate::BControlLook; 455 using BPrivate::be_control_look; 456 457 458 #endif // _CONTROL_LOOK_H 459