1 /* 2 * Copyright 2009-2017, 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 virtual BAlignment DefaultLabelAlignment() const = 0; 94 virtual float DefaultLabelSpacing() const = 0; 95 96 virtual float DefaultItemSpacing() const = 0; 97 98 static float ComposeSpacing(float spacing); 99 100 virtual uint32 Flags(BControl* control) const = 0; 101 102 virtual void DrawButtonFrame(BView* view, BRect& rect, 103 const BRect& updateRect, 104 const rgb_color& base, 105 const rgb_color& background, 106 uint32 flags = 0, 107 uint32 borders = B_ALL_BORDERS) = 0; 108 virtual void DrawButtonFrame(BView* view, BRect& rect, 109 const BRect& updateRect, 110 float radius, 111 const rgb_color& base, 112 const rgb_color& background, 113 uint32 flags = 0, 114 uint32 borders = B_ALL_BORDERS) = 0; 115 virtual void DrawButtonFrame(BView* view, BRect& rect, 116 const BRect& updateRect, 117 float leftTopRadius, 118 float rightTopRadius, 119 float leftBottomRadius, 120 float rightBottomRadius, 121 const rgb_color& base, 122 const rgb_color& background, 123 uint32 flags = 0, 124 uint32 borders = B_ALL_BORDERS) = 0; 125 126 virtual void DrawButtonBackground(BView* view, BRect& rect, 127 const BRect& updateRect, 128 const rgb_color& base, 129 uint32 flags = 0, 130 uint32 borders = B_ALL_BORDERS, 131 orientation orientation = B_HORIZONTAL) = 0; 132 virtual void DrawButtonBackground(BView* view, BRect& rect, 133 const BRect& updateRect, 134 float radius, 135 const rgb_color& base, 136 uint32 flags = 0, 137 uint32 borders = B_ALL_BORDERS, 138 orientation orientation = B_HORIZONTAL) = 0; 139 virtual void DrawButtonBackground(BView* view, BRect& rect, 140 const BRect& updateRect, 141 float leftTopRadius, 142 float rightTopRadius, 143 float leftBottomRadius, 144 float rightBottomRadius, 145 const rgb_color& base, 146 uint32 flags = 0, 147 uint32 borders = B_ALL_BORDERS, 148 orientation orientation = B_HORIZONTAL) = 0; 149 150 virtual void DrawMenuBarBackground(BView* view, BRect& rect, 151 const BRect& updateRect, 152 const rgb_color& base, 153 uint32 flags = 0, 154 uint32 borders = B_ALL_BORDERS) = 0; 155 156 virtual void DrawMenuFieldFrame(BView* view, BRect& rect, 157 const BRect& updateRect, 158 const rgb_color& base, 159 const rgb_color& background, 160 uint32 flags = 0, 161 uint32 borders = B_ALL_BORDERS) = 0; 162 virtual void DrawMenuFieldFrame(BView* view, BRect& rect, 163 const BRect& updateRect, 164 float radius, 165 const rgb_color& base, 166 const rgb_color& background, 167 uint32 flags = 0, 168 uint32 borders = B_ALL_BORDERS) = 0; 169 virtual void DrawMenuFieldFrame(BView* view, BRect& rect, 170 const BRect& updateRect, 171 float leftTopRadius, 172 float rightTopRadius, 173 float leftBottomRadius, 174 float rightBottomRadius, 175 const rgb_color& base, 176 const rgb_color& background, 177 uint32 flags = 0, 178 uint32 borders = B_ALL_BORDERS) = 0; 179 180 virtual void DrawMenuFieldBackground(BView* view, 181 BRect& rect, const BRect& updateRect, 182 const rgb_color& base, bool popupIndicator, 183 uint32 flags = 0) = 0; 184 virtual void DrawMenuFieldBackground(BView* view, 185 BRect& rect, const BRect& updateRect, 186 float radius, const rgb_color& base, 187 bool popupIndicator, uint32 flags = 0) = 0; 188 virtual void DrawMenuFieldBackground(BView* view, 189 BRect& rect, const BRect& updateRect, 190 float leftTopRadius, 191 float rightTopRadius, 192 float leftBottomRadius, 193 float rightBottomRadius, 194 const rgb_color& base, 195 bool popupIndicator, uint32 flags = 0) = 0; 196 virtual void DrawMenuFieldBackground(BView* view, 197 BRect& rect, const BRect& updateRect, 198 const rgb_color& base, uint32 flags = 0, 199 uint32 borders = B_ALL_BORDERS) = 0; 200 201 virtual void DrawMenuBackground(BView* view, 202 BRect& rect, const BRect& updateRect, 203 const rgb_color& base, uint32 flags = 0, 204 uint32 borders = B_ALL_BORDERS) = 0; 205 206 virtual void DrawMenuItemBackground(BView* view, 207 BRect& rect, const BRect& updateRect, 208 const rgb_color& base, uint32 flags = 0, 209 uint32 borders = B_ALL_BORDERS) = 0; 210 211 virtual void DrawStatusBar(BView* view, BRect& rect, 212 const BRect& updateRect, 213 const rgb_color& base, 214 const rgb_color& barColor, 215 float progressPosition) = 0; 216 217 virtual void DrawCheckBox(BView* view, BRect& rect, 218 const BRect& updateRect, 219 const rgb_color& base, 220 uint32 flags = 0) = 0; 221 222 virtual void DrawRadioButton(BView* view, BRect& rect, 223 const BRect& updateRect, 224 const rgb_color& base, 225 uint32 flags = 0) = 0; 226 227 virtual void DrawScrollBarBackground(BView* view, 228 BRect& rect1, BRect& rect2, 229 const BRect& updateRect, 230 const rgb_color& base, uint32 flags, 231 orientation orientation) = 0; 232 virtual void DrawScrollBarBackground(BView* view, 233 BRect& rect, const BRect& updateRect, 234 const rgb_color& base, uint32 flags, 235 orientation orientation) = 0; 236 237 virtual void DrawScrollViewFrame(BView* view, 238 BRect& rect, const BRect& updateRect, 239 BRect verticalScrollBarFrame, 240 BRect horizontalScrollBarFrame, 241 const rgb_color& base, 242 border_style borderStyle, 243 uint32 flags = 0, 244 uint32 borders = B_ALL_BORDERS) = 0; 245 246 virtual void DrawArrowShape(BView* view, 247 BRect& rect, const BRect& updateRect, 248 const rgb_color& base, uint32 direction, 249 uint32 flags = 0, 250 float tint = B_DARKEN_MAX_TINT) = 0; 251 252 virtual rgb_color SliderBarColor(const rgb_color& base) = 0; 253 254 virtual void DrawSliderBar(BView* view, BRect rect, 255 const BRect& updateRect, 256 const rgb_color& base, 257 rgb_color leftFillColor, 258 rgb_color rightFillColor, 259 float sliderScale, uint32 flags, 260 orientation orientation) = 0; 261 virtual void DrawSliderBar(BView* view, BRect rect, 262 const BRect& updateRect, 263 const rgb_color& base, rgb_color fillColor, 264 uint32 flags, orientation orientation) = 0; 265 266 virtual void DrawSliderThumb(BView* view, BRect& rect, 267 const BRect& updateRect, 268 const rgb_color& base, uint32 flags, 269 orientation orientation) = 0; 270 271 virtual void DrawSliderTriangle(BView* view, BRect& rect, 272 const BRect& updateRect, 273 const rgb_color& base, uint32 flags, 274 orientation orientation) = 0; 275 virtual void DrawSliderTriangle(BView* view, BRect& rect, 276 const BRect& updateRect, 277 const rgb_color& base, 278 const rgb_color& fill, uint32 flags, 279 orientation orientation) = 0; 280 281 virtual void DrawSliderHashMarks(BView* view, BRect& rect, 282 const BRect& updateRect, 283 const rgb_color& base, int32 count, 284 hash_mark_location location, 285 uint32 flags, orientation orientation) = 0; 286 287 virtual void DrawActiveTab(BView* view, BRect& rect, 288 const BRect& updateRect, 289 const rgb_color& base, uint32 flags = 0, 290 uint32 borders = B_ALL_BORDERS, 291 uint32 side = B_TOP_BORDER) = 0; 292 293 virtual void DrawInactiveTab(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) = 0; 298 299 virtual void DrawSplitter(BView* view, BRect& rect, 300 const BRect& updateRect, 301 const rgb_color& base, 302 orientation orientation, 303 uint32 flags = 0, 304 uint32 borders = B_ALL_BORDERS) = 0; 305 306 // various borders 307 308 virtual void DrawBorder(BView* view, BRect& rect, 309 const BRect& updateRect, 310 const rgb_color& base, 311 border_style borderStyle, uint32 flags = 0, 312 uint32 borders = B_ALL_BORDERS) = 0; 313 314 virtual void DrawRaisedBorder(BView* view, BRect& rect, 315 const BRect& updateRect, 316 const rgb_color& base, uint32 flags = 0, 317 uint32 borders = B_ALL_BORDERS) = 0; 318 319 virtual void DrawGroupFrame(BView* view, BRect& rect, 320 const BRect& updateRect, 321 const rgb_color& base, 322 uint32 borders = B_ALL_BORDERS) = 0; 323 324 virtual void DrawTextControlBorder(BView* view, BRect& rect, 325 const BRect& updateRect, 326 const rgb_color& base, uint32 flags = 0, 327 uint32 borders = B_ALL_BORDERS) = 0; 328 329 // aligned labels 330 331 virtual void DrawLabel(BView* view, const char* label, 332 BRect rect, const BRect& updateRect, 333 const rgb_color& base, uint32 flags, 334 const rgb_color* textColor = NULL) = 0; 335 virtual void DrawLabel(BView* view, const char* label, 336 BRect rect, const BRect& updateRect, 337 const rgb_color& base, uint32 flags, 338 const BAlignment& alignment, 339 const rgb_color* textColor = NULL) = 0; 340 // TODO: Would be nice to have a (non-virtual) version of this method 341 // which takes an array of labels and locations. That would save some 342 // setup with the view graphics state. 343 virtual void DrawLabel(BView* view, const char* label, 344 const rgb_color& base, uint32 flags, 345 const BPoint& where, 346 const rgb_color* textColor = NULL) = 0; 347 348 void DrawLabel(BView* view, const char* label, 349 const BBitmap* icon, BRect rect, 350 const BRect& updateRect, 351 const rgb_color& base, uint32 flags, 352 const rgb_color* textColor = NULL); 353 virtual void DrawLabel(BView* view, const char* label, 354 const BBitmap* icon, BRect rect, 355 const BRect& updateRect, 356 const rgb_color& base, uint32 flags, 357 const BAlignment& alignment, 358 const rgb_color* textColor = NULL) = 0; 359 360 virtual void GetFrameInsets(frame_type frameType, 361 uint32 flags, float& _left, float& _top, 362 float& _right, float& _bottom) = 0; 363 virtual void GetBackgroundInsets( 364 background_type backgroundType, 365 uint32 flags, float& _left, float& _top, 366 float& _right, float& _bottom) = 0; 367 void GetInsets(frame_type frameType, 368 background_type backgroundType, 369 uint32 flags, float& _left, float& _top, 370 float& _right, float& _bottom); 371 372 virtual void DrawButtonWithPopUpBackground(BView* view, 373 BRect& rect, const BRect& updateRect, 374 const rgb_color& base, 375 uint32 flags = 0, 376 uint32 borders = B_ALL_BORDERS, 377 orientation orientation = B_HORIZONTAL) = 0; 378 virtual void DrawButtonWithPopUpBackground(BView* view, 379 BRect& rect, const BRect& updateRect, 380 float radius, 381 const rgb_color& base, 382 uint32 flags = 0, 383 uint32 borders = B_ALL_BORDERS, 384 orientation orientation = B_HORIZONTAL) = 0; 385 virtual void DrawButtonWithPopUpBackground(BView* view, 386 BRect& rect, const BRect& updateRect, 387 float leftTopRadius, 388 float rightTopRadius, 389 float leftBottomRadius, 390 float rightBottomRadius, 391 const rgb_color& base, 392 uint32 flags = 0, 393 uint32 borders = B_ALL_BORDERS, 394 orientation orientation = B_HORIZONTAL) = 0; 395 396 void SetBackgroundInfo( 397 const BMessage& backgroundInfo); 398 399 protected: 400 int32 fCachedWorkspace; 401 BMessage fBackgroundInfo; 402 403 uint32 _reserved[20]; 404 }; 405 406 extern BControlLook* be_control_look; 407 408 409 } // namespace BPrivate 410 411 using BPrivate::BControlLook; 412 using BPrivate::be_control_look; 413 414 415 #endif // _CONTROL_LOOK_H 416