1 /* 2 * Copyright 2009, Stephan Aßmus <superstippi@gmx.de> 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _CONTROL_LOOK_H 6 #define _CONTROL_LOOK_H 7 8 #include <Alignment.h> 9 #include <Font.h> 10 #include <Rect.h> 11 #include <Slider.h> 12 13 14 class BControl; 15 class BGradientLinear; 16 class BView; 17 18 19 namespace BPrivate { 20 21 22 class BControlLook { 23 public: 24 BControlLook(); 25 virtual ~BControlLook(); 26 27 enum frame_type { 28 B_BUTTON_FRAME, 29 B_MENU_FRAME, 30 B_LISTVIEW_FRAME, 31 B_INPUT_FRAME 32 }; 33 34 enum background_type { 35 B_BUTTON_BACKGROUND, 36 B_MENU_BACKGROUND, 37 B_LISTVIEW_BACKGROUND, 38 B_INPUT_BACKGROUND 39 }; 40 41 enum { 42 B_LEFT_BORDER = 1 << 0, 43 B_RIGHT_BORDER = 1 << 1, 44 B_TOP_BORDER = 1 << 2, 45 B_BOTTOM_BORDER = 1 << 3, 46 47 B_ALL_BORDERS = B_LEFT_BORDER | B_RIGHT_BORDER 48 | B_TOP_BORDER | B_BOTTOM_BORDER 49 }; 50 51 enum { 52 B_LEFT_ARROW = 0, 53 B_RIGHT_ARROW = 1, 54 B_UP_ARROW = 2, 55 B_DOWN_ARROW = 3 56 }; 57 58 enum { 59 B_FOCUSED = 1 << 0, 60 B_CLICKED = 1 << 1, // some controls activate on mouse up 61 B_ACTIVATED = 1 << 2, 62 B_HOVER = 1 << 3, 63 B_DISABLED = 1 << 4, 64 B_DEFAULT_BUTTON = 1 << 5, 65 66 B_BLEND_FRAME = 1 << 16 67 }; 68 69 virtual BAlignment DefaultLabelAlignment() const; 70 virtual float DefaultLabelSpacing() const; 71 uint32 Flags(BControl* control) const; 72 73 virtual void DrawButtonFrame(BView* view, BRect& rect, 74 const BRect& updateRect, 75 const rgb_color& base, 76 const rgb_color& background, 77 uint32 flags = 0, 78 uint32 borders = B_ALL_BORDERS); 79 80 virtual void DrawButtonBackground(BView* view, BRect& rect, 81 const BRect& updateRect, 82 const rgb_color& base, 83 uint32 flags = 0, 84 uint32 borders = B_ALL_BORDERS, 85 enum orientation orientation 86 = B_HORIZONTAL); 87 88 virtual void DrawMenuBarBackground(BView* view, BRect& rect, 89 const BRect& updateRect, 90 const rgb_color& base, 91 uint32 flags = 0, 92 uint32 borders = B_ALL_BORDERS); 93 94 virtual void DrawMenuFieldFrame(BView* view, BRect& rect, 95 const BRect& updateRect, 96 const rgb_color& base, 97 const rgb_color& background, 98 uint32 flags = 0, 99 uint32 borders = B_ALL_BORDERS); 100 101 virtual void DrawMenuFieldBackground(BView* view, 102 BRect& rect, const BRect& updateRect, 103 const rgb_color& base, bool popupIndicator, 104 uint32 flags = 0); 105 106 virtual void DrawMenuFieldBackground(BView* view, 107 BRect& rect, const BRect& updateRect, 108 const rgb_color& base, uint32 flags = 0, 109 uint32 borders = B_ALL_BORDERS); 110 111 virtual void DrawMenuBackground(BView* view, 112 BRect& rect, const BRect& updateRect, 113 const rgb_color& base, uint32 flags = 0, 114 uint32 borders = B_ALL_BORDERS); 115 116 virtual void DrawMenuItemBackground(BView* view, 117 BRect& rect, const BRect& updateRect, 118 const rgb_color& base, uint32 flags = 0, 119 uint32 borders = B_ALL_BORDERS); 120 121 virtual void DrawStatusBar(BView* view, BRect& rect, 122 const BRect& updateRect, 123 const rgb_color& base, 124 const rgb_color& barColor, 125 float progressPosition); 126 127 virtual void DrawCheckBox(BView* view, BRect& rect, 128 const BRect& updateRect, 129 const rgb_color& base, 130 uint32 flags = 0); 131 132 virtual void DrawRadioButton(BView* view, BRect& rect, 133 const BRect& updateRect, 134 const rgb_color& base, 135 uint32 flags = 0); 136 137 virtual void DrawScrollBarBackground(BView* view, 138 BRect& rect1, BRect& rect2, 139 const BRect& updateRect, 140 const rgb_color& base, uint32 flags, 141 enum orientation orientation); 142 143 virtual void DrawScrollBarBackground(BView* view, 144 BRect& rect, const BRect& updateRect, 145 const rgb_color& base, uint32 flags, 146 enum orientation orientation); 147 148 // TODO: Make all these virtual before R1 release 149 void DrawScrollViewFrame(BView* view, 150 BRect& rect, const BRect& updateRect, 151 BRect verticalScrollBarFrame, 152 BRect horizontalScrollBarFrame, 153 const rgb_color& base, 154 border_style border, 155 uint32 flags = 0, 156 uint32 borders = B_ALL_BORDERS); 157 158 void DrawArrowShape(BView* view, 159 BRect& rect, const BRect& updateRect, 160 const rgb_color& base, uint32 direction, 161 uint32 flags = 0, 162 float tint = B_DARKEN_MAX_TINT); 163 164 virtual rgb_color SliderBarColor(const rgb_color& base); 165 166 virtual void DrawSliderBar(BView* view, BRect rect, 167 const BRect& updateRect, 168 const rgb_color& base, 169 rgb_color leftFillColor, 170 rgb_color rightFillColor, 171 float sliderScale, uint32 flags, 172 enum orientation orientation); 173 174 virtual void DrawSliderBar(BView* view, BRect rect, 175 const BRect& updateRect, 176 const rgb_color& base, rgb_color fillColor, 177 uint32 flags, enum orientation orientation); 178 179 virtual void DrawSliderThumb(BView* view, BRect& rect, 180 const BRect& updateRect, 181 const rgb_color& base, uint32 flags, 182 enum orientation orientation); 183 184 void DrawSliderTriangle(BView* view, BRect& rect, 185 const BRect& updateRect, 186 const rgb_color& base, uint32 flags, 187 enum orientation orientation); 188 189 virtual void DrawSliderTriangle(BView* view, BRect& rect, 190 const BRect& updateRect, 191 const rgb_color& base, 192 const rgb_color& fill, uint32 flags, 193 enum orientation orientation); 194 195 virtual void DrawSliderHashMarks(BView* view, BRect& rect, 196 const BRect& updateRect, 197 const rgb_color& base, int32 count, 198 hash_mark_location location, 199 uint32 flags, enum orientation orientation); 200 201 virtual void DrawActiveTab(BView* view, BRect& rect, 202 const BRect& updateRect, 203 const rgb_color& base, uint32 flags = 0, 204 uint32 borders = B_ALL_BORDERS); 205 206 virtual void DrawInactiveTab(BView* view, BRect& rect, 207 const BRect& updateRect, 208 const rgb_color& base, uint32 flags = 0, 209 uint32 borders = B_ALL_BORDERS); 210 211 /*virtual*/ void DrawSplitter(BView* view, BRect& rect, 212 const BRect& updateRect, 213 const rgb_color& base, 214 enum orientation orientation, 215 uint32 flags = 0, 216 uint32 borders = B_ALL_BORDERS); 217 218 // various borders 219 220 virtual void DrawBorder(BView* view, BRect& rect, 221 const BRect& updateRect, 222 const rgb_color& base, 223 border_style border, uint32 flags = 0, 224 uint32 borders = B_ALL_BORDERS); 225 226 virtual void DrawRaisedBorder(BView* view, BRect& rect, 227 const BRect& updateRect, 228 const rgb_color& base, uint32 flags = 0, 229 uint32 borders = B_ALL_BORDERS); 230 231 virtual void DrawGroupFrame(BView* view, BRect& rect, 232 const BRect& updateRect, 233 const rgb_color& base, 234 uint32 borders = B_ALL_BORDERS); 235 236 virtual void DrawTextControlBorder(BView* view, BRect& rect, 237 const BRect& updateRect, 238 const rgb_color& base, uint32 flags = 0, 239 uint32 borders = B_ALL_BORDERS); 240 241 // aligned labels 242 243 void DrawLabel(BView* view, const char* label, 244 BRect rect, const BRect& updateRect, 245 const rgb_color& base, uint32 flags); 246 247 virtual void DrawLabel(BView* view, const char* label, 248 BRect rect, const BRect& updateRect, 249 const rgb_color& base, uint32 flags, 250 const BAlignment& alignment); 251 252 protected: 253 void _DrawButtonFrame(BView* view, BRect& rect, 254 const BRect& updateRect, 255 const rgb_color& base, 256 const rgb_color& background, 257 float contrast, float brightness = 1.0, 258 uint32 flags = 0, 259 uint32 borders = B_ALL_BORDERS); 260 261 void _DrawOuterResessedFrame(BView* view, 262 BRect& rect, const rgb_color& base, 263 float contrast = 1.0f, 264 float brightness = 1.0f, 265 uint32 flags = 0, 266 uint32 borders = B_ALL_BORDERS); 267 268 void _DrawFrame(BView* view, BRect& rect, 269 const rgb_color& left, 270 const rgb_color& top, 271 const rgb_color& right, 272 const rgb_color& bottom, 273 uint32 borders = B_ALL_BORDERS); 274 275 void _DrawFrame(BView* view, BRect& rect, 276 const rgb_color& left, 277 const rgb_color& top, 278 const rgb_color& right, 279 const rgb_color& bottom, 280 const rgb_color& rightTop, 281 const rgb_color& leftBottom, 282 uint32 borders = B_ALL_BORDERS); 283 284 void _FillGradient(BView* view, const BRect& rect, 285 const rgb_color& base, float topTint, 286 float bottomTint, 287 enum orientation orientation 288 = B_HORIZONTAL); 289 290 void _FillGlossyGradient(BView* view, 291 const BRect& rect, const rgb_color& base, 292 float topTint, float middle1Tint, 293 float middle2Tint, float bottomTint, 294 enum orientation orientation 295 = B_HORIZONTAL); 296 297 void _MakeGradient(BGradientLinear& gradient, 298 const BRect& rect, const rgb_color& base, 299 float topTint, float bottomTint, 300 enum orientation orientation 301 = B_HORIZONTAL) const; 302 303 void _MakeGlossyGradient(BGradientLinear& gradient, 304 const BRect& rect, const rgb_color& base, 305 float topTint, float middle1Tint, 306 float middle2Tint, float bottomTint, 307 enum orientation orientation 308 = B_HORIZONTAL) const; 309 310 bool _RadioButtonAndCheckBoxMarkColor( 311 const rgb_color& base, rgb_color& color, 312 uint32 flags) const; 313 314 void _DrawRoundBarCorner(BView* view, BRect& rect, 315 const BRect& updateRect, 316 const rgb_color& edgeLightColor, 317 const rgb_color& edgeShadowColor, 318 const rgb_color& frameLightColor, 319 const rgb_color& frameShadowColor, 320 const rgb_color& fillLightColor, 321 const rgb_color& fillShadowColor, 322 float leftInset, float topInset, 323 float rightInset, float bottomInset, 324 enum orientation orientation); 325 326 void _DrawRoundCornerLeftTop(BView* view, 327 BRect& rect, const BRect& updateRect, 328 const rgb_color& base, 329 const rgb_color& edgeColor, 330 const rgb_color& frameColor, 331 const rgb_color& bevelColor, 332 const BGradientLinear& fillGradient); 333 void _DrawRoundCornerRightTop(BView* view, 334 BRect& rect, const BRect& updateRect, 335 const rgb_color& base, 336 const rgb_color& edgeTopColor, 337 const rgb_color& edgeRightColor, 338 const rgb_color& frameTopColor, 339 const rgb_color& frameRightColor, 340 const rgb_color& bevelTopColor, 341 const rgb_color& bevelRightColor, 342 const BGradientLinear& fillGradient); 343 }; 344 345 extern BControlLook* be_control_look; 346 347 348 } // namespace BPrivate 349 350 using BPrivate::BControlLook; 351 using BPrivate::be_control_look; 352 353 #endif // _CONTROL_LOOK_H 354