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 67 virtual BAlignment DefaultLabelAlignment() const; 68 virtual float DefaultLabelSpacing() const; 69 uint32 Flags(BControl* control) const; 70 71 virtual void DrawButtonFrame(BView* view, BRect& rect, 72 const BRect& updateRect, 73 const rgb_color& base, 74 uint32 flags = 0, 75 uint32 borders = B_ALL_BORDERS); 76 77 virtual void DrawButtonBackground(BView* view, BRect& rect, 78 const BRect& updateRect, 79 const rgb_color& base, 80 uint32 flags = 0, 81 uint32 borders = B_ALL_BORDERS, 82 enum orientation orientation 83 = B_HORIZONTAL); 84 85 virtual void DrawMenuBarBackground(BView* view, BRect& rect, 86 const BRect& updateRect, 87 const rgb_color& base, 88 uint32 flags = 0, 89 uint32 borders = B_ALL_BORDERS); 90 91 virtual void DrawMenuFieldFrame(BView* view, BRect& rect, 92 const BRect& updateRect, 93 const rgb_color& base, 94 uint32 flags = 0, 95 uint32 borders = B_ALL_BORDERS); 96 97 virtual void DrawMenuFieldBackground(BView* view, 98 BRect& rect, const BRect& updateRect, 99 const rgb_color& base, bool popupIndicator, 100 uint32 flags = 0); 101 102 virtual void DrawMenuFieldBackground(BView* view, 103 BRect& rect, const BRect& updateRect, 104 const rgb_color& base, uint32 flags = 0, 105 uint32 borders = B_ALL_BORDERS); 106 107 virtual void DrawMenuBackground(BView* view, 108 BRect& rect, const BRect& updateRect, 109 const rgb_color& base, uint32 flags = 0, 110 uint32 borders = B_ALL_BORDERS); 111 112 virtual void DrawMenuItemBackground(BView* view, 113 BRect& rect, const BRect& updateRect, 114 const rgb_color& base, uint32 flags = 0, 115 uint32 borders = B_ALL_BORDERS); 116 117 virtual void DrawStatusBar(BView* view, BRect& rect, 118 const BRect& updateRect, 119 const rgb_color& base, 120 const rgb_color& barColor, 121 float progressPosition); 122 123 virtual void DrawCheckBox(BView* view, BRect& rect, 124 const BRect& updateRect, 125 const rgb_color& base, 126 uint32 flags = 0); 127 128 virtual void DrawRadioButton(BView* view, BRect& rect, 129 const BRect& updateRect, 130 const rgb_color& base, 131 uint32 flags = 0); 132 133 virtual void DrawScrollBarBackground(BView* view, 134 BRect& rect1, BRect& rect2, 135 const BRect& updateRect, 136 const rgb_color& base, uint32 flags, 137 enum orientation orientation); 138 139 virtual void DrawScrollBarBackground(BView* view, 140 BRect& rect, const BRect& updateRect, 141 const rgb_color& base, uint32 flags, 142 enum orientation orientation); 143 144 // TODO: Make virtual before R1 release 145 void DrawArrowShape(BView* view, 146 BRect& rect, const BRect& updateRect, 147 const rgb_color& base, uint32 direction, 148 uint32 flags = 0, 149 float tint = B_DARKEN_MAX_TINT); 150 151 virtual rgb_color SliderBarColor(const rgb_color& base); 152 153 virtual void DrawSliderBar(BView* view, BRect rect, 154 const BRect& updateRect, 155 const rgb_color& base, 156 rgb_color leftFillColor, 157 rgb_color rightFillColor, 158 float sliderScale, uint32 flags, 159 enum orientation orientation); 160 161 virtual void DrawSliderBar(BView* view, BRect rect, 162 const BRect& updateRect, 163 const rgb_color& base, rgb_color fillColor, 164 uint32 flags, enum orientation orientation); 165 166 virtual void DrawSliderThumb(BView* view, BRect& rect, 167 const BRect& updateRect, 168 const rgb_color& base, uint32 flags, 169 enum orientation orientation); 170 171 void DrawSliderTriangle(BView* view, BRect& rect, 172 const BRect& updateRect, 173 const rgb_color& base, uint32 flags, 174 enum orientation orientation); 175 176 virtual void DrawSliderTriangle(BView* view, BRect& rect, 177 const BRect& updateRect, 178 const rgb_color& base, 179 const rgb_color& fill, uint32 flags, 180 enum orientation orientation); 181 182 virtual void DrawSliderHashMarks(BView* view, BRect& rect, 183 const BRect& updateRect, 184 const rgb_color& base, int32 count, 185 hash_mark_location location, 186 uint32 flags, enum orientation orientation); 187 188 virtual void DrawActiveTab(BView* view, BRect& rect, 189 const BRect& updateRect, 190 const rgb_color& base, uint32 flags = 0, 191 uint32 borders = B_ALL_BORDERS); 192 193 virtual void DrawInactiveTab(BView* view, BRect& rect, 194 const BRect& updateRect, 195 const rgb_color& base, uint32 flags = 0, 196 uint32 borders = B_ALL_BORDERS); 197 198 // various borders 199 200 virtual void DrawBorder(BView* view, BRect& rect, 201 const BRect& updateRect, 202 const rgb_color& base, 203 border_style border, uint32 flags = 0, 204 uint32 borders = B_ALL_BORDERS); 205 206 virtual void DrawRaisedBorder(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 DrawGroupFrame(BView* view, BRect& rect, 212 const BRect& updateRect, 213 const rgb_color& base, 214 uint32 borders = B_ALL_BORDERS); 215 216 virtual void DrawTextControlBorder(BView* view, BRect& rect, 217 const BRect& updateRect, 218 const rgb_color& base, uint32 flags = 0, 219 uint32 borders = B_ALL_BORDERS); 220 221 // aligned labels 222 223 void DrawLabel(BView* view, const char* label, 224 BRect rect, const BRect& updateRect, 225 const rgb_color& base, uint32 flags); 226 227 virtual void DrawLabel(BView* view, const char* label, 228 BRect rect, const BRect& updateRect, 229 const rgb_color& base, uint32 flags, 230 const BAlignment& alignment); 231 232 protected: 233 void _DrawButtonFrame(BView* view, BRect& rect, 234 const BRect& updateRect, 235 const rgb_color& base, 236 float contrast, float brightness = 1.0, 237 uint32 flags = 0, 238 uint32 borders = B_ALL_BORDERS); 239 240 void _DrawOuterResessedFrame(BView* view, 241 BRect& rect, const rgb_color& base, 242 float contrast = 1.0f, 243 float brightness = 1.0f, 244 uint32 borders = B_ALL_BORDERS); 245 246 void _DrawFrame(BView* view, BRect& rect, 247 const rgb_color& left, 248 const rgb_color& top, 249 const rgb_color& right, 250 const rgb_color& bottom, 251 uint32 borders = B_ALL_BORDERS); 252 253 void _DrawFrame(BView* view, BRect& rect, 254 const rgb_color& left, 255 const rgb_color& top, 256 const rgb_color& right, 257 const rgb_color& bottom, 258 const rgb_color& rightTop, 259 const rgb_color& leftBottom, 260 uint32 borders = B_ALL_BORDERS); 261 262 void _FillGradient(BView* view, const BRect& rect, 263 const rgb_color& base, float topTint, 264 float bottomTint, 265 enum orientation orientation 266 = B_HORIZONTAL); 267 268 void _FillGlossyGradient(BView* view, 269 const BRect& rect, const rgb_color& base, 270 float topTint, float middle1Tint, 271 float middle2Tint, float bottomTint, 272 enum orientation orientation 273 = B_HORIZONTAL); 274 275 void _MakeGradient(BGradientLinear& gradient, 276 const BRect& rect, const rgb_color& base, 277 float topTint, float bottomTint, 278 enum orientation orientation 279 = B_HORIZONTAL) const; 280 281 void _MakeGlossyGradient(BGradientLinear& gradient, 282 const BRect& rect, const rgb_color& base, 283 float topTint, float middle1Tint, 284 float middle2Tint, float bottomTint, 285 enum orientation orientation 286 = B_HORIZONTAL) const; 287 288 bool _RadioButtonAndCheckBoxMarkColor( 289 const rgb_color& base, rgb_color& color, 290 uint32 flags) const; 291 292 void _DrawRoundBarCorner(BView* view, BRect& rect, 293 const BRect& updateRect, 294 const rgb_color& edgeLightColor, 295 const rgb_color& edgeShadowColor, 296 const rgb_color& frameLightColor, 297 const rgb_color& frameShadowColor, 298 const rgb_color& fillLightColor, 299 const rgb_color& fillShadowColor, 300 float leftInset, float topInset, 301 float rightInset, float bottomInset, 302 enum orientation orientation); 303 304 void _DrawRoundCornerLeftTop(BView* view, 305 BRect& rect, const BRect& updateRect, 306 const rgb_color& base, 307 const rgb_color& edgeColor, 308 const rgb_color& frameColor, 309 const rgb_color& bevelColor, 310 const BGradientLinear& fillGradient); 311 void _DrawRoundCornerRightTop(BView* view, 312 BRect& rect, const BRect& updateRect, 313 const rgb_color& base, 314 const rgb_color& edgeTopColor, 315 const rgb_color& edgeRightColor, 316 const rgb_color& frameTopColor, 317 const rgb_color& frameRightColor, 318 const rgb_color& bevelTopColor, 319 const rgb_color& bevelRightColor, 320 const BGradientLinear& fillGradient); 321 }; 322 323 extern BControlLook* be_control_look; 324 325 326 } // namespace BPrivate 327 328 using BPrivate::BControlLook; 329 using BPrivate::be_control_look; 330 331 #endif // _CONTROL_LOOK_H 332