123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- #include "skinclr.h"
- #include <bfc/assert.h>
- #include <tataki/api__tataki.h>
- static const int *skin_iterator = 0;
- SkinColor::SkinColor(const wchar_t *_name, const wchar_t *colorgroup)
- : FilteredColor(0, (colorgroup == NULL || !*colorgroup) ? L"Text" : colorgroup)
- {
- name = 0;
- latest_iteration = -1;
- //CUT skin_iterator = NULL;
- setElementName(_name);
- ovr_grp = colorgroup;
- dooverride = 0;
- color_override = 0;
- }
- SkinColor::~SkinColor()
- {
- if (name) free(name);
- }
- ARGB32 SkinColor::v(ARGB32 defaultColor)
- {
- if (!name || !*name) return defaultColor;
- if (!iteratorValid())
- {
- val = NULL; // pointer now invalid, must re-get
- latest_iteration = *skin_iterator; // and then we'll be current
- // new pointer please
- const wchar_t *grp = NULL;
- ARGB32 r;
- if (dooverride)
- r = color_override;
- else
- r = WASABI_API_PALETTE->getColorElement(name, &grp);
- if (ovr_grp == NULL && grp != NULL)
- setColorGroup(grp);
- FilteredColor::setColor(r);
- val = getColorRef();
- }
- if (val == NULL) return defaultColor;
- return *val;
- }
- void SkinColor::setElementName(const wchar_t *_name)
- {
- if (name) free(name);
- if (_name)
- name = _wcsdup(_name);
- else
- name = 0;
- val = NULL;
- latest_iteration = 0;
- }
- void SkinColor::setColor(ARGB32 c)
- {
- dooverride = 1;
- color_override = c;
- FilteredColor::setColor(color_override);
- }
- int SkinColor::iteratorValid()
- {
- // fetch iterator pointer if necessary
- if (skin_iterator == NULL)
- {
- skin_iterator = WASABI_API_PALETTE->getSkinPartIteratorPtr();
- ASSERT(skin_iterator != NULL);
- }
- // see if we're current
- return (*skin_iterator == latest_iteration);
- }
- const wchar_t *SkinColor::operator =(const wchar_t *name) { setElementName(name); return name;}
- const wchar_t *SkinColor::getColorName() { return name; }
- ARGB32 SkinColor::GetColor(const wchar_t *name, const wchar_t *group, ARGB32 defaultColor)
- {
- const wchar_t *colorGroup = NULL;
- const ARGB32 *color = WASABI_API_PALETTE->getColorElementRef(name, &colorGroup);
- if (!color)
- return defaultColor;
- /* TODO: benski> if we ever add color themes to Classic, we'll need to change this */
- if (WASABI_API_SKIN)
- {
- if (group)
- colorGroup = group;
-
- if (!colorGroup)
- colorGroup = L"Text";
- return WASABI_API_SKIN->filterSkinColor(*color, name, colorGroup);
- }
- else
- {
- return *color;
- }
- }
- bool SkinColor::TryGetColor(ARGB32 *returned_color, const wchar_t *name, const wchar_t *group)
- {
- const wchar_t *colorGroup = NULL;
- const ARGB32 *color = WASABI_API_PALETTE->getColorElementRef(name, &colorGroup);
- if (!color)
- return false;
- /* TODO: benski> if we ever add color themes to Classic, we'll need to change this */
- if (WASABI_API_SKIN)
- {
- if (group)
- colorGroup = group;
-
- if (!colorGroup)
- colorGroup = L"Text";
- *returned_color = WASABI_API_SKIN->filterSkinColor(*color, name, colorGroup);
- }
- else
- {
- *returned_color = *color;
- }
- return true;
- }
|