10 #include "tb_system.h" 
   11 #include "tb_renderer.h" 
   12 #include "tb_bitmap_fragment.h" 
   13 #include "tb_hashtable.h" 
   14 #include "tb_linklist.h" 
   15 #include "tb_dimension.h" 
   21 class TBSkinConditionContext;
 
   24 #define SKIN_VALUE_NOT_SPECIFIED TB_INVALID_DIMENSION 
   30     SKIN_STATE_DISABLED     = 1,
 
   31     SKIN_STATE_FOCUSED      = 2,
 
   32     SKIN_STATE_PRESSED      = 4,
 
   33     SKIN_STATE_SELECTED     = 8,
 
   34     SKIN_STATE_HOVERED      = 16,
 
   36     SKIN_STATE_ALL          =   SKIN_STATE_DISABLED |
 
   51     SKIN_ELEMENT_TYPE_IMAGE             
 
  157     bool HasStateElements()
 const { 
return m_state_elements.HasLinks(); }
 
  158     const TBSkinElementState *GetFirstElement()
 const { 
return m_state_elements.GetFirst(); }
 
  305     bool Load(
const TBStr & skin_file, 
const TBStr & override_skin_file = TBStr());
 
  308     bool Write(
const TBStr & skin_file);
 
  392 #ifdef TB_RUNTIME_DEBUG_INFO 
  411     float m_default_disabled_opacity;                   
 
  412     float m_default_placeholder_opacity;                
 
  413     int16_t m_default_spacing;                          
 
  414     bool LoadInternal(
const TBStr & skin_file);
 
  415     bool ReloadBitmapsInternal();
 
  421     void PaintElementStretchBox(
const TBRect &dst_rect, 
TBSkinElement *element, 
bool fill_center);
 
  423     int GetPxFromNode(
TBNode *node, 
int def_value) 
const;
 
int16_t height
Intrinsic height or SKIN_VALUE_NOT_SPECIFIED. 
Definition: tb_skin.h:189
 
int16_t width
Intrinsic width or SKIN_VALUE_NOT_SPECIFIED. 
Definition: tb_skin.h:188
 
TBBitmapFragment * bitmap
Bitmap fragment containing the graphics, or nullptr. 
Definition: tb_skin.h:178
 
TBLinkListOf is a double linked linklist. 
Definition: tb_linklist.h:122
 
All ancestors of the object painting the skin. 
Definition: tb_skin.h:65
 
int16_t img_ofs_y
Y offset for type image. Relative to image position (img_position_y). 
Definition: tb_skin.h:200
 
virtual void OnContextLost()
Called when the context has been lost and all TBBitmaps need to be deleted. 
Definition: tb_skin.cpp:639
 
int GetDefaultSpacing() const 
Get the default layout spacing in pixels. 
Definition: tb_skin.h:345
 
int16_t pref_height
Preferred height or SKIN_VALUE_NOT_SPECIFIED. 
Definition: tb_skin.h:191
 
SKIN_ELEMENT_TYPE type
Skin element type. 
Definition: tb_skin.h:181
 
TBBitmapFragmentManager manages loading bitmaps of arbitrary size, pack as many of them into as few T...
Definition: tb_bitmap_fragment.h:177
 
Focus is on the target or any child (no value required). 
Definition: tb_skin.h:80
 
int8_t flip_x
The skin is flipped horizontally. 
Definition: tb_skin.h:205
 
TBID custom_prop
Which property (only if prop is PROPERTY_CUSTOM). 
Definition: tb_skin.h:93
 
void SetListener(TBSkinListener *listener)
Set the listener for this skin. 
Definition: tb_skin.h:294
 
The object painting the skin. 
Definition: tb_skin.h:63
 
TBSkinElement * GetSkinElement(const TBID &skin_id) const 
Get the skin element with the given id. 
Definition: tb_skin.cpp:357
 
TBSkinElement * GetSkinElementStrongOverride(const TBID &skin_id, SKIN_STATE state, TBSkinConditionContext &context) const 
Get the skin element with the given id and state. 
Definition: tb_skin.cpp:364
 
const TBDimensionConverter * GetDimensionConverter() const 
Get the dimension converter used for the current skin. 
Definition: tb_skin.h:319
 
TBHashTableOf is a TBHashTable with the given class type as content. 
Definition: tb_hashtable.h:112
 
Same as above, but dont fill the center. 
Definition: tb_skin.h:48
 
bool HasOverlayElements() const 
Return true if this element has overlay elements. 
Definition: tb_skin.h:270
 
bool Load(const TBStr &skin_file, const TBStr &override_skin_file=TBStr())
Load the skin file and the bitmaps it refers to. 
Definition: tb_skin.cpp:155
 
TBSkinElementStateList m_child_elements
List of child elements (See TBSkin::PaintSkin) 
Definition: tb_skin.h:259
 
TBColor bitmap_color
Color to paint the bitmap with. (for now assume text_color if true). 
Definition: tb_skin.h:210
 
int16_t padding_bottom
Bottom padding for any content in the element. 
Definition: tb_skin.h:187
 
Value should be equal for condition to be true. 
Definition: tb_skin.h:86
 
TEST
Defines if the condition tested should be equal or not for the condition to be true. 
Definition: tb_skin.h:85
 
int16_t pref_width
Preferred width or SKIN_VALUE_NOT_SPECIFIED. 
Definition: tb_skin.h:190
 
It's a property unknown to skin, that the TBSkinConditionContext might know about. 
Definition: tb_skin.h:81
 
States with "all" (SKIN_STATE_ALL) will also be considered a match. 
Definition: tb_skin.h:128
 
The id. 
Definition: tb_skin.h:75
 
int16_t content_ofs_y
Y offset of the content in the widget. 
Definition: tb_skin.h:198
 
The state is set. 
Definition: tb_skin.h:76
 
bool GetCondition(TBSkinConditionContext &context) const 
Return true if the condition is true for the given context. 
Definition: tb_skin.cpp:134
 
TBColor GetDefaultTextColor() const 
Get the default text color for all skin elements. 
Definition: tb_skin.h:333
 
Default element type, cut bitmap into 9 pieces "cut" wide. 
Definition: tb_skin.h:46
 
float GetDefaultDisabledOpacity() const 
Get the default disabled opacity for all skin elements. 
Definition: tb_skin.h:339
 
TBStr name
Name of the skin element, f.ex "TBSelectDropdown.arrow". 
Definition: tb_skin.h:176
 
Scale the bitmap to the dest rect. 
Definition: tb_skin.h:49
 
int16_t min_width
Minimum width or SKIN_VALUE_NOT_SPECIFIED. 
Definition: tb_skin.h:192
 
int16_t max_width
Maximum width or SKIN_VALUE_NOT_SPECIFIED. 
Definition: tb_skin.h:194
 
int16_t padding_left
Left padding for any content in the element. 
Definition: tb_skin.h:184
 
TBSkin contains a list of TBSkinElement. 
Definition: tb_skin.h:287
 
int8_t img_position_y
Vertical position for type image. 
Definition: tb_skin.h:203
 
SKIN_ELEMENT_TYPE
Type of painting that should be done for a TBSkinElement. 
Definition: tb_skin.h:45
 
int16_t content_ofs_x
X offset of the content in the widget. 
Definition: tb_skin.h:197
 
TBBitmapFragmentManager * GetFragmentManager()
Get the fragment manager. 
Definition: tb_skin.h:398
 
int16_t min_height
Minimum height or SKIN_VALUE_NOT_SPECIFIED. 
Definition: tb_skin.h:193
 
TBColor bg_color
Color of the background in the widget. 
Definition: tb_skin.h:209
 
Skin element. 
Definition: tb_skin.h:168
 
int GetMaxHeight() const 
Get the maximum height, or SKIN_VALUE_NOT_SPECIFIED if not specified. 
Definition: tb_skin.h:230
 
bool Write(const TBStr &skin_file)
Write the current skin to a file. 
Definition: tb_skin.cpp:257
 
TARGET
Defines which target(s) relative to the context that should be tested for the condition. 
Definition: tb_skin.h:62
 
TBStr bitmap_file
File name of the bitmap (might be empty) 
Definition: tb_skin.h:177
 
int GetMinWidth() const 
Get the minimum width, or SKIN_VALUE_NOT_SPECIFIED if not specified. 
Definition: tb_skin.h:215
 
int8_t img_position_x
Horizontal position for type image. 
Definition: tb_skin.h:201
 
TBRendererListener is a listener for TBRenderer. 
Definition: tb_renderer.h:19
 
TBID is a wrapper for a uint32_t to be used as ID. 
Definition: tb_id.h:18
 
The previous sibling of the object painting the skin. 
Definition: tb_skin.h:66
 
int GetIntrinsicMinWidth() const 
Get the intrinsic minimum width. 
Definition: tb_skin.cpp:685
 
int16_t padding_right
Right padding for any content in the element. 
Definition: tb_skin.h:186
 
TBBitmapFragment represents a sub part of a TBBitmap. 
Definition: tb_bitmap_fragment.h:140
 
void SetBitmapDPI(const TBDimensionConverter &dim_conv, int bitmap_dpi)
Set the DPI that the bitmap was loaded in. 
Definition: tb_skin.cpp:723
 
void SetDefaultTextColor(TBColor color)
Set the default text color for all skin elements. 
Definition: tb_skin.h:336
 
virtual void OnSkinElementLoaded(TBSkin *skin, TBSkinElement *element, TBNode *node)=0
Called when a skin element has been loaded from the given TBNode. 
 
Focus is on the target or any child (no value required). 
Definition: tb_skin.h:78
 
int16_t max_height
Maximum height or SKIN_VALUE_NOT_SPECIFIED. 
Definition: tb_skin.h:195
 
int16_t expand
How much the skin should expand outside the widgets rect. 
Definition: tb_skin.h:180
 
TBSkinElementStateList m_override_elements
List of override elements (See TBSkin::PaintSkin) 
Definition: tb_skin.h:253
 
int GetIntrinsicWidth() const 
Get the intrinsic width. 
Definition: tb_skin.cpp:703
 
TBDimensionConverter converts device independant points to pixels, based on two DPI values...
Definition: tb_dimension.h:26
 
void PaintSkinOverlay(const TBRect &dst_rect, TBSkinElement *element, SKIN_STATE state, TBSkinConditionContext &context)
Paint the overlay elements for the given skin element and state. 
Definition: tb_skin.cpp:450
 
int16_t bitmap_dpi
The DPI of the bitmap that was loaded. 
Definition: tb_skin.h:211
 
Tile the bitmap to the dest rect. 
Definition: tb_skin.h:50
 
Value should not be equal for condition to be true. 
Definition: tb_skin.h:87
 
The alignment. 
Definition: tb_skin.h:74
 
TBValue tag
This value is free to use for anything. It's not used internally. 
Definition: tb_skin.h:212
 
Definition: tb_skin.h:276
 
PROPERTY prop
Which property. 
Definition: tb_skin.h:92
 
The background skin id. 
Definition: tb_skin.h:71
 
TBStr is a simple string class. 
Definition: tb_str.h:62
 
TBNode is a tree node with a string name and a value (TBValue). 
Definition: tb_node_tree.h:30
 
The current value (integer). 
Definition: tb_skin.h:77
 
Simple rectangle class. 
Definition: tb_geometry.h:25
 
TBValue holds value of a specific type. 
Definition: tb_value.h:59
 
int GetMinHeight() const 
Get the minimum height, or SKIN_VALUE_NOT_SPECIFIED if not specified. 
Definition: tb_skin.h:218
 
The window is active (no value required). 
Definition: tb_skin.h:72
 
bool is_painting
If the skin is being painted (avoiding eternal recursing) 
Definition: tb_skin.h:182
 
TBSkinElementStateList m_overlay_elements
List of overlay elements (See TBSkin::PaintSkin) 
Definition: tb_skin.h:262
 
TBFile is a portable interface for file access. 
Definition: tb_system.h:69
 
float GetDefaultPlaceholderOpacity() const 
Get the default placeholder opacity for all skin elements. 
Definition: tb_skin.h:342
 
float opacity
Opacity that should be used for the whole widget (0.f - 1.f). 
Definition: tb_skin.h:207
 
TBLinkListAutoDeleteOf is a double linked linklist that deletes all links on destruction. 
Definition: tb_linklist.h:194
 
int GetMaxWidth() const 
Get the maximum width, or SKIN_VALUE_NOT_SPECIFIED if not specified. 
Definition: tb_skin.h:227
 
Definition: tb_linklist.h:83
 
TBSkinElementState has a skin element id that should be used if its state and condition matches that ...
Definition: tb_skin.h:122
 
TBColor contains a 32bit color. 
Definition: tb_color.h:21
 
The next sibling of the object painting the skin. 
Definition: tb_skin.h:67
 
Stores the information needed for checking a condition. 
Definition: tb_skin.h:91
 
int8_t flip_y
The skin is flipped vertically. 
Definition: tb_skin.h:206
 
bool HasState(SKIN_STATE state, TBSkinConditionContext &context)
Check if there's a exact or partial match for the given state in either override, child or overlay el...
Definition: tb_skin.cpp:753
 
int16_t padding_top
Top padding for any content in the element. 
Definition: tb_skin.h:185
 
int GetIntrinsicHeight() const 
Get the intrinsic height. 
Definition: tb_skin.cpp:713
 
Capture is on the target or any child (no value required). 
Definition: tb_skin.h:79
 
void UnloadBitmaps()
Unload all bitmaps used in this skin. 
Definition: tb_skin.cpp:272
 
void PaintRectFill(const TBRect &dst_rect, const TBColor &color)
Paint a filled rectangle with the given color. 
Definition: tb_skin.cpp:525
 
States with "all" will not be considered a match. 
Definition: tb_skin.h:130
 
SKIN_STATE
Skin state types (may be combined). 
Definition: tb_skin.h:28
 
TBSkinCondition checks if a condition is true for a given TBSkinConditionContext. ...
Definition: tb_skin.h:58
 
TBID id
ID of the skin element. 
Definition: tb_skin.h:175
 
The axis of the content (x or y) 
Definition: tb_skin.h:73
 
int GetIntrinsicMinHeight() const 
Get the intrinsic minimum height. 
Definition: tb_skin.cpp:694
 
TBColor text_color
Color of the text in the widget. 
Definition: tb_skin.h:208
 
List of state elements in a TBSkinElement. 
Definition: tb_skin.h:146
 
TBID value
The value to compare. 
Definition: tb_skin.h:94
 
int GetPrefWidth() const 
Get the preferred width, or SKIN_VALUE_NOT_SPECIFIED if not specified. 
Definition: tb_skin.h:233
 
int GetPrefHeight() const 
Get the preferred height, or SKIN_VALUE_NOT_SPECIFIED if not specified. 
Definition: tb_skin.h:236
 
bool is_getting
If the skin is being got (avoiding eternal recursion) 
Definition: tb_skin.h:183
 
void PaintRect(const TBRect &dst_rect, const TBColor &color, int thickness)
Paint a rectangle outline inside dst_rect with the given thickness and color. 
Definition: tb_skin.cpp:505
 
bool ReloadBitmaps()
Reload all bitmaps used in this skin. 
Definition: tb_skin.cpp:284
 
virtual void OnContextRestored()
Called when the context has been restored again, and new TBBitmaps can be created again...
Definition: tb_skin.cpp:648
 
TBSkinElementStateList m_strong_override_elements
List of strong-override elements (See TBSkin::PaintSkin) 
Definition: tb_skin.h:256
 
TBSkinElement * PaintSkin(const TBRect &dst_rect, const TBID &skin_id, SKIN_STATE state, TBSkinConditionContext &context)
Paint the skin at dst_rect. 
Definition: tb_skin.cpp:391
 
int16_t img_ofs_x
X offset for type image. Relative to image position (img_position_x). 
Definition: tb_skin.h:199
 
int16_t spacing
Spacing used on layout or SKIN_VALUE_NOT_SPECIFIED. 
Definition: tb_skin.h:196
 
TBSkinConditionContext checks if a condition is true. 
Definition: tb_skin.h:111
 
The parent of the object painting the skin. 
Definition: tb_skin.h:64
 
virtual bool GetCondition(TBSkinCondition::TARGET target, const TBSkinCondition::CONDITION_INFO &info)=0
Return true if the given target and property equals the given value. 
 
PROPERTY
Defines which property in the context that should be checked. 
Definition: tb_skin.h:70
 
uint8_t cut
How the bitmap should be sliced using StretchBox. 
Definition: tb_skin.h:179
 
MATCH_RULE
Defines how to match states. 
Definition: tb_skin.h:126