Kaydet (Commit) cad78399 authored tarafından Caolán McNamara's avatar Caolán McNamara

support loading certain stock images as button symbols

Change-Id: I475a4bc7e0686fa17beceb68f1aed016ef158117
üst b3584b90
...@@ -23,16 +23,16 @@ class NumericFormatter; ...@@ -23,16 +23,16 @@ class NumericFormatter;
class VCL_DLLPUBLIC VclBuilder class VCL_DLLPUBLIC VclBuilder
{ {
public: public:
typedef std::map<rtl::OString, rtl::OString> stringmap; typedef std::map<OString, OString> stringmap;
typedef Window* (*customMakeWidget)(Window *pParent, stringmap &rVec); typedef Window* (*customMakeWidget)(Window *pParent, stringmap &rVec);
private: private:
struct WinAndId struct WinAndId
{ {
rtl::OString m_sID; OString m_sID;
Window *m_pWindow; Window *m_pWindow;
sal_Int32 m_nPosition; sal_Int32 m_nPosition;
bool m_bOwned; bool m_bOwned;
WinAndId(const rtl::OString &rId, Window *pWindow) WinAndId(const OString &rId, Window *pWindow)
: m_sID(rId) : m_sID(rId)
, m_pWindow(pWindow) , m_pWindow(pWindow)
, m_nPosition(-1) , m_nPosition(-1)
...@@ -44,15 +44,15 @@ private: ...@@ -44,15 +44,15 @@ private:
struct ListStore struct ListStore
{ {
typedef std::vector<rtl::OString> row; typedef std::vector<OString> row;
std::vector<row> m_aEntries; std::vector<row> m_aEntries;
}; };
struct ModelAndId struct ModelAndId
{ {
rtl::OString m_sID; OString m_sID;
ListStore *m_pModel; ListStore *m_pModel;
ModelAndId(const rtl::OString &rId, ListStore *pListStore) ModelAndId(const OString &rId, ListStore *pListStore)
: m_sID(rId) : m_sID(rId)
, m_pModel(pListStore) , m_pModel(pListStore)
{ {
...@@ -61,9 +61,9 @@ private: ...@@ -61,9 +61,9 @@ private:
struct StringPair struct StringPair
{ {
rtl::OString m_sID; OString m_sID;
rtl::OString m_sValue; OString m_sValue;
StringPair(const rtl::OString &rId, const rtl::OString &rValue) StringPair(const OString &rId, const OString &rValue)
: m_sID(rId) : m_sID(rId)
, m_sValue(rValue) , m_sValue(rValue)
{ {
...@@ -72,17 +72,18 @@ private: ...@@ -72,17 +72,18 @@ private:
typedef StringPair RadioButtonGroupMap; typedef StringPair RadioButtonGroupMap;
typedef StringPair ComboBoxModelMap; typedef StringPair ComboBoxModelMap;
typedef StringPair ButtonImageWidgetMap;
ListStore *get_model_by_name(rtl::OString sID); ListStore *get_model_by_name(OString sID);
static void mungemodel(ListBox &rTarget, ListStore &rStore); static void mungemodel(ListBox &rTarget, ListStore &rStore);
typedef stringmap Adjustment; typedef stringmap Adjustment;
struct AdjustmentAndId struct AdjustmentAndId
{ {
rtl::OString m_sID; OString m_sID;
Adjustment m_aAdjustment; Adjustment m_aAdjustment;
AdjustmentAndId(const rtl::OString &rId, Adjustment &rAdjustment) AdjustmentAndId(const OString &rId, Adjustment &rAdjustment)
: m_sID(rId) : m_sID(rId)
{ {
m_aAdjustment.swap(rAdjustment); m_aAdjustment.swap(rAdjustment);
...@@ -91,12 +92,13 @@ private: ...@@ -91,12 +92,13 @@ private:
typedef StringPair SpinButtonAdjustmentMap; typedef StringPair SpinButtonAdjustmentMap;
Adjustment *get_adjustment_by_name(rtl::OString sID); Adjustment *get_adjustment_by_name(OString sID);
static void mungeadjustment(NumericFormatter &rTarget, Adjustment &rAdjustment); static void mungeadjustment(NumericFormatter &rTarget, Adjustment &rAdjustment);
typedef std::map<rtl::OString, rtl::OString> WidgetTranslations; typedef std::map<OString, OString> WidgetTranslations;
typedef std::map<rtl::OString, WidgetTranslations> Translations; typedef std::map<OString, WidgetTranslations> Translations;
typedef std::map<OString, OString> StockMap;
struct ParserState struct ParserState
{ {
std::vector<RadioButtonGroupMap> m_aGroupMaps; std::vector<RadioButtonGroupMap> m_aGroupMaps;
...@@ -104,22 +106,25 @@ private: ...@@ -104,22 +106,25 @@ private:
std::vector<ModelAndId> m_aModels; std::vector<ModelAndId> m_aModels;
std::vector<AdjustmentAndId> m_aAdjustments; std::vector<AdjustmentAndId> m_aAdjustments;
std::vector<SpinButtonAdjustmentMap> m_aAdjustmentMaps; std::vector<SpinButtonAdjustmentMap> m_aAdjustmentMaps;
std::vector<ButtonImageWidgetMap> m_aButtonImageWidgetMaps;
StockMap m_aStockMap;
Translations m_aTranslations; Translations m_aTranslations;
}; };
rtl::OString getTranslation(const rtl::OString &rId, const rtl::OString &rProperty) const; OString getTranslation(const OString &rId, const OString &rProperty) const;
rtl::OString m_sID; OString m_sID;
rtl::OString m_sHelpRoot; OString m_sHelpRoot;
Window *m_pParent; Window *m_pParent;
ParserState *m_pParserState; ParserState *m_pParserState;
Window *get_by_name(rtl::OString sID); Window *get_by_name(OString sID);
void delete_by_name(OString sID);
public: public:
VclBuilder(Window *pParent, rtl::OUString sUIRootDir, rtl::OUString sUIFile, rtl::OString sID = rtl::OString()); VclBuilder(Window *pParent, OUString sUIRootDir, OUString sUIFile, OString sID = OString());
~VclBuilder(); ~VclBuilder();
Window *get_widget_root(); Window *get_widget_root();
template <typename T> T* get(T*& ret, rtl::OString sID) template <typename T> T* get(T*& ret, OString sID)
{ {
Window *w = get_by_name(sID); Window *w = get_by_name(sID);
ret = static_cast<T*>(w); ret = static_cast<T*>(w);
...@@ -134,7 +139,7 @@ public: ...@@ -134,7 +139,7 @@ public:
return ret; return ret;
} }
template <typename T /*=Window if we had c++11*/> T* get(rtl::OString sID) template <typename T /*=Window if we had c++11*/> T* get(OString sID)
{ {
Window *w = get_by_name(sID); Window *w = get_by_name(sID);
T* ret = static_cast<T*>(w); T* ret = static_cast<T*>(w);
...@@ -150,18 +155,20 @@ public: ...@@ -150,18 +155,20 @@ public:
return ret; return ret;
} }
rtl::OString get_by_window(const Window *pWindow) const; OString get_by_window(const Window *pWindow) const;
//for the purposes of retrofitting this to the existing code //for the purposes of retrofitting this to the existing code
//look up sID, clone its properties into replacement and //look up sID, clone its properties into replacement and
//splice replacement into the tree instead of it, without //splice replacement into the tree instead of it, without
//taking ownership of it //taking ownership of it
bool replace(rtl::OString sID, Window &rReplacement); bool replace(OString sID, Window &rReplacement);
private: private:
Window *insertObject(Window *pParent, const rtl::OString &rClass, const rtl::OString &rID, stringmap &rVec); Window *insertObject(Window *pParent, const OString &rClass, const OString &rID, stringmap &rVec);
Window *makeObject(Window *pParent, const rtl::OString &rClass, const rtl::OString &rID, stringmap &rVec); Window *makeObject(Window *pParent, const OString &rClass, const OString &rID, stringmap &rVec);
bool extractGroup(const rtl::OString &id, stringmap &rVec); bool extractGroup(const OString &id, stringmap &rVec);
bool extractModel(const rtl::OString &id, stringmap &rVec); bool extractModel(const OString &id, stringmap &rVec);
bool extractAdjustment(const rtl::OString &id, stringmap &rVec); bool extractAdjustment(const OString &id, stringmap &rVec);
bool extractImage(const OString &id, stringmap &rMap);
bool extractStock(const OString &id, stringmap &rMap);
void handleTranslations(xmlreader::XmlReader &reader); void handleTranslations(xmlreader::XmlReader &reader);
...@@ -169,11 +176,11 @@ private: ...@@ -169,11 +176,11 @@ private:
Window* handleObject(Window *pParent, xmlreader::XmlReader &reader); Window* handleObject(Window *pParent, xmlreader::XmlReader &reader);
void handlePacking(Window *pCurrent, xmlreader::XmlReader &reader); void handlePacking(Window *pCurrent, xmlreader::XmlReader &reader);
void applyPackingProperty(Window *pCurrent, xmlreader::XmlReader &reader); void applyPackingProperty(Window *pCurrent, xmlreader::XmlReader &reader);
void collectProperty(xmlreader::XmlReader &reader, const rtl::OString &rID, stringmap &rVec); void collectProperty(xmlreader::XmlReader &reader, const OString &rID, stringmap &rVec);
void handleListStore(xmlreader::XmlReader &reader, const rtl::OString &rID); void handleListStore(xmlreader::XmlReader &reader, const OString &rID);
void handleRow(xmlreader::XmlReader &reader, const rtl::OString &rID, sal_Int32 nRowIndex); void handleRow(xmlreader::XmlReader &reader, const OString &rID, sal_Int32 nRowIndex);
void handleAdjustment(const rtl::OString &rID, stringmap &rProperties); void handleAdjustment(const OString &rID, stringmap &rProperties);
void handleTabChild(Window *pParent, xmlreader::XmlReader &reader); void handleTabChild(Window *pParent, xmlreader::XmlReader &reader);
sal_Int32 get_window_packing_position(const Window *pWindow) const; sal_Int32 get_window_packing_position(const Window *pWindow) const;
...@@ -205,14 +212,14 @@ protected: ...@@ -205,14 +212,14 @@ protected:
public: public:
VclBuilderContainer(); VclBuilderContainer();
virtual ~VclBuilderContainer(); virtual ~VclBuilderContainer();
static rtl::OUString getUIRootDir(); static OUString getUIRootDir();
static VclBuilder* overrideResourceWithUIXML(Window *pWindow, const ResId& rResId); static VclBuilder* overrideResourceWithUIXML(Window *pWindow, const ResId& rResId);
static bool replace_buildable(Window *pParent, const ResId& rResId, Window &rReplacement); static bool replace_buildable(Window *pParent, const ResId& rResId, Window &rReplacement);
template <typename T> T* get(T*& ret, rtl::OString sID) template <typename T> T* get(T*& ret, OString sID)
{ {
return m_pUIBuilder->get<T>(ret, sID); return m_pUIBuilder->get<T>(ret, sID);
} }
template <typename T /*=Window if we had c++11*/> T* get(rtl::OString sID) template <typename T /*=Window if we had c++11*/> T* get(OString sID)
{ {
return m_pUIBuilder->get<T>(sID); return m_pUIBuilder->get<T>(sID);
} }
...@@ -221,7 +228,7 @@ public: ...@@ -221,7 +228,7 @@ public:
/* /*
* @return true if rValue is "True", "true", "1", etc. * @return true if rValue is "True", "true", "1", etc.
*/ */
bool VCL_DLLPUBLIC toBool(const rtl::OString &rValue); bool VCL_DLLPUBLIC toBool(const OString &rValue);
#endif #endif
......
...@@ -904,8 +904,6 @@ void PushButton::ImplDrawPushButtonContent( OutputDevice* pDev, sal_uLong nDrawF ...@@ -904,8 +904,6 @@ void PushButton::ImplDrawPushButtonContent( OutputDevice* pDev, sal_uLong nDrawF
else else
{ {
Rectangle aSymbolRect; Rectangle aSymbolRect;
// FIXME: (GetStyle() & WB_FLATBUTTON) != 0 is preliminary
// in the next major this should be replaced by "true"
ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, nImageSep, nDrawFlags, ImplDrawAlignedImage( pDev, aPos, aSize, bLayout, nImageSep, nDrawFlags,
nTextStyle, IsSymbol() ? &aSymbolRect : NULL, true ); nTextStyle, IsSymbol() ? &aSymbolRect : NULL, true );
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment