[commit] r2454 - in trunk: GME/Annotator SDK/DecoratorLib
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Tue Mar 4 10:24:02 CST 2014
Author: ksmyth
Date: Tue Mar 4 10:24:02 2014
New Revision: 2454
Log:
Simplify confusing preferences. If you need that functionality, just override InitializeEx
Modified:
trunk/GME/Annotator/AnnotatorTextPart.cpp
trunk/SDK/DecoratorLib/AttributePart.cpp
trunk/SDK/DecoratorLib/ClassLabelPart.cpp
trunk/SDK/DecoratorLib/LabelPart.cpp
trunk/SDK/DecoratorLib/LabelPart.h
trunk/SDK/DecoratorLib/PortLabelPart.cpp
trunk/SDK/DecoratorLib/StereoLabelPart.cpp
trunk/SDK/DecoratorLib/TextPart.cpp
trunk/SDK/DecoratorLib/TextPart.h
Modified: trunk/GME/Annotator/AnnotatorTextPart.cpp
==============================================================================
--- trunk/GME/Annotator/AnnotatorTextPart.cpp Thu Feb 27 12:15:07 2014 (r2453)
+++ trunk/GME/Annotator/AnnotatorTextPart.cpp Tue Mar 4 10:24:02 2014 (r2454)
@@ -27,9 +27,6 @@
m_crText = AN_DEFAULT_COLOR;
memset(&m_logFont, 0, sizeof(LOGFONT));
- textStringVariableName = ""; // disable
- textColorVariableName = ""; // disable
- textMaxLengthVariableName = DecoratorSDK::PREF_LABELLENGTH;
}
AnnotatorTextPart::~AnnotatorTextPart()
Modified: trunk/SDK/DecoratorLib/AttributePart.cpp
==============================================================================
--- trunk/SDK/DecoratorLib/AttributePart.cpp Thu Feb 27 12:15:07 2014 (r2453)
+++ trunk/SDK/DecoratorLib/AttributePart.cpp Tue Mar 4 10:24:02 2014 (r2454)
@@ -20,13 +20,6 @@
AttributePart::AttributePart(PartBase* pPart, CComPtr<IMgaCommonDecoratorEvents>& eventSink):
TextPart(pPart, eventSink)
{
- textStringVariableName = ""; // disable
- textFontVariableName = PREF_LABELFONT;
- textMaxLengthVariableName = PREF_LABELLENGTH;
- textColorVariableName = PREF_LABELCOLOR;
- textLocationVariableName = PREF_LABELLOCATION;
- textStatusVariableName = PREF_LABELENABLED;
- textWrapStatusVariableName = PREF_LABELWRAP;
}
AttributePart::~AttributePart()
Modified: trunk/SDK/DecoratorLib/ClassLabelPart.cpp
==============================================================================
--- trunk/SDK/DecoratorLib/ClassLabelPart.cpp Thu Feb 27 12:15:07 2014 (r2453)
+++ trunk/SDK/DecoratorLib/ClassLabelPart.cpp Tue Mar 4 10:24:02 2014 (r2454)
@@ -21,14 +21,6 @@
TextPart(pPart, eventSink),
m_bIsAbstract(bIsAbstract)
{
- // TODO
- textStringVariableName = ""; // disable
- textFontVariableName = PREF_LABELFONT;
- textMaxLengthVariableName = PREF_LABELLENGTH;
- textColorVariableName = PREF_LABELCOLOR;
- textLocationVariableName = PREF_LABELLOCATION;
- textStatusVariableName = PREF_LABELENABLED;
- textWrapStatusVariableName = PREF_LABELWRAP;
}
ClassLabelPart::~ClassLabelPart()
Modified: trunk/SDK/DecoratorLib/LabelPart.cpp
==============================================================================
--- trunk/SDK/DecoratorLib/LabelPart.cpp Thu Feb 27 12:15:07 2014 (r2453)
+++ trunk/SDK/DecoratorLib/LabelPart.cpp Tue Mar 4 10:24:02 2014 (r2454)
@@ -20,13 +20,6 @@
LabelPart::LabelPart(PartBase* pPart, CComPtr<IMgaCommonDecoratorEvents>& eventSink):
TextPart(pPart, eventSink)
{
- textStringVariableName = PREF_LABEL;
- textFontVariableName = PREF_LABELFONT;
- textMaxLengthVariableName = PREF_LABELLENGTH;
- textColorVariableName = PREF_LABELCOLOR;
- textLocationVariableName = PREF_LABELLOCATION;
- textStatusVariableName = PREF_LABELENABLED;
- textWrapStatusVariableName = PREF_LABELWRAP;
}
LabelPart::~LabelPart()
@@ -136,4 +129,29 @@
// transaction operation end
}
+void LabelPart::InitializeEx(CComPtr<IMgaProject>& pProject, CComPtr<IMgaMetaPart>& pPart, CComPtr<IMgaFCO>& pFCO,
+ HWND parentWnd, PreferenceMap& preferences)
+{
+ preferences[DecoratorSDK::PREF_TEXTOVERRIDE] = DecoratorSDK::PreferenceVariant(true);
+ TextPart::InitializeEx(pProject, pPart, pFCO, parentWnd, preferences);
+ PreferenceMap::iterator it = preferences.find(PREF_LABEL);
+ if (it != preferences.end())
+ m_strText = *it->second.uValue.pstrValue;
+
+ m_vecText = getFacilities().wrapString(m_strText, m_iTextWrapCount, m_iMaxTextLength);
+}
+
+long LabelPart::GetLongest(void) const
+{
+ long maxv = 0;
+ for (unsigned int i = 0; i < m_vecText.size(); i++) {
+ long ilen = m_vecText[i].GetLength();
+ if (m_iMaxTextLength > 0)
+ ilen = min(ilen, m_iMaxTextLength);
+ if (maxv < ilen)
+ maxv = ilen;
+ }
+ return maxv;
+}
+
}; // namespace DecoratorSDK
Modified: trunk/SDK/DecoratorLib/LabelPart.h
==============================================================================
--- trunk/SDK/DecoratorLib/LabelPart.h Thu Feb 27 12:15:07 2014 (r2453)
+++ trunk/SDK/DecoratorLib/LabelPart.h Tue Mar 4 10:24:02 2014 (r2454)
@@ -23,16 +23,20 @@
class LabelPart: public TextPart
{
+protected:
+ std::vector<CString> m_vecText;
public:
LabelPart(PartBase* pPart, CComPtr<IMgaCommonDecoratorEvents>& eventSink);
virtual ~LabelPart();
virtual void Draw (CDC* pDC, Gdiplus::Graphics* gdip);
+ virtual void InitializeEx(CComPtr<IMgaProject>& pProject, CComPtr<IMgaMetaPart>& pPart, CComPtr<IMgaFCO>& pFCO, HWND parentWnd, PreferenceMap& preferences);
virtual CPoint GetTextPosition (CDC* pDC, Gdiplus::Graphics* gdip) const;
virtual void SetTextRelYPosition (long relYPosition) {}; // This doesn't make sense in case of box label decorator: label text location is computed automatically from box location and text alignment
virtual CRect GetTextLocation (CDC* pDC, Gdiplus::Graphics* gdip) const;
virtual void ExecuteOperation (const CString& newString);
+ virtual long GetLongest (void) const;
};
}; // namespace DecoratorSDK
Modified: trunk/SDK/DecoratorLib/PortLabelPart.cpp
==============================================================================
--- trunk/SDK/DecoratorLib/PortLabelPart.cpp Thu Feb 27 12:15:07 2014 (r2453)
+++ trunk/SDK/DecoratorLib/PortLabelPart.cpp Tue Mar 4 10:24:02 2014 (r2454)
@@ -45,6 +45,12 @@
m_eAdjust = preferences[PREF_LABELLOCATION].uValue.eLocation;
LabelPart::InitializeEx(pProject, pPart, pFCO, parentWnd, preferences);
+
+ // Text's Max Length
+ m_iMaxTextLength = MAX_LABEL_LENGTH;
+ PreferenceMap::iterator it = preferences.find(PREF_PORTLABELLENGTH);
+ if (it != preferences.end())
+ m_iMaxTextLength = it->second.uValue.lValue;
}
bool PortLabelPart::MouseLeftButtonDoubleClick(UINT nFlags, const CPoint& point, HDC transformHDC)
Modified: trunk/SDK/DecoratorLib/StereoLabelPart.cpp
==============================================================================
--- trunk/SDK/DecoratorLib/StereoLabelPart.cpp Thu Feb 27 12:15:07 2014 (r2453)
+++ trunk/SDK/DecoratorLib/StereoLabelPart.cpp Tue Mar 4 10:24:02 2014 (r2454)
@@ -20,13 +20,6 @@
StereoLabelPart::StereoLabelPart(PartBase* pPart, CComPtr<IMgaCommonDecoratorEvents>& eventSink):
TextPart(pPart, eventSink)
{
- textStringVariableName = ""; // disable
- textFontVariableName = PREF_LABELFONT;
- textMaxLengthVariableName = PREF_LABELLENGTH;
- textColorVariableName = PREF_LABELCOLOR;
- textLocationVariableName = PREF_LABELLOCATION;
- textStatusVariableName = PREF_LABELENABLED;
- textWrapStatusVariableName = PREF_LABELWRAP;
}
StereoLabelPart::~StereoLabelPart()
Modified: trunk/SDK/DecoratorLib/TextPart.cpp
==============================================================================
--- trunk/SDK/DecoratorLib/TextPart.cpp Thu Feb 27 12:15:07 2014 (r2453)
+++ trunk/SDK/DecoratorLib/TextPart.cpp Tue Mar 4 10:24:02 2014 (r2454)
@@ -90,11 +90,6 @@
// Get Text
it = preferences.find(DecoratorSDK::PREF_TEXTOVERRIDE);
if (it == preferences.end()) {
- it = preferences.find(textStringVariableName);
- bool bTextDefined = (it != preferences.end());
- if (bTextDefined)
- m_strText = *it->second.uValue.pstrValue;
-
CComBSTR bstrText;
CComPtr<IMgaMetaFCO> spMetaFCO;
if (!m_spFCO) {
@@ -103,68 +98,57 @@
COMTHROW(m_spPart->get_Role(&spRole));
COMTHROW(spRole->get_Kind(&spMetaFCO));
- if (!bTextDefined) {
- CComBSTR bstrKindName;
- COMTHROW(spMetaFCO->get_Name(&bstrKindName));
- CComBSTR bstrRoleName;
- COMTHROW(spRole->get_Name(&bstrRoleName));
- if (bstrKindName == bstrRoleName) {
- COMTHROW(spMetaFCO->get_DisplayedName(&bstrText));
- }
- else {
- bstrText = bstrRoleName;
- }
+ CComBSTR bstrKindName;
+ COMTHROW(spMetaFCO->get_Name(&bstrKindName));
+ CComBSTR bstrRoleName;
+ COMTHROW(spRole->get_Name(&bstrRoleName));
+ if (bstrKindName == bstrRoleName) {
+ COMTHROW(spMetaFCO->get_DisplayedName(&bstrText));
+ }
+ else {
+ bstrText = bstrRoleName;
}
}
} else {
- if (!bTextDefined)
- COMTHROW(m_spFCO->get_Name(&bstrText));
- }
- if (!bTextDefined)
- m_strText = bstrText;
- if (m_strText == "Condition") {
- m_strText = "Condition";
+ COMTHROW(m_spFCO->get_Name(&bstrText));
}
+ m_strText = bstrText;
}
// Text's Font
m_iFontKey = FONT_LABEL;
- it = preferences.find(textFontVariableName);
+ it = preferences.find(PREF_LABELFONT);
if (it != preferences.end())
m_iFontKey = it->second.uValue.lValue;
- // Text's Max Length
- m_iMaxTextLength = MAX_LABEL_LENGTH;
- it = preferences.find(textMaxLengthVariableName);
- if (it != preferences.end())
- m_iMaxTextLength = it->second.uValue.lValue;
-
// Text's Color
it = preferences.find(DecoratorSDK::PREF_TEXTCOLOROVERRIDE);
if (it == preferences.end()) {
m_crText = COLOR_BLACK;
- it = preferences.find(textColorVariableName);
+ it = preferences.find(PREF_LABELCOLOR);
if (it != preferences.end()) {
m_crText = it->second.uValue.crValue;
} else {
if (m_spFCO)
- getFacilities().getPreference(m_spFCO, textColorVariableName, m_crText);
+ getFacilities().getPreference(m_spFCO, PREF_LABELCOLOR, m_crText);
}
}
+ m_iMaxTextLength = MAX_LABEL_LENGTH;
+
// Text's Location
m_eTextLocation = L_SOUTH;
- it = preferences.find(textLocationVariableName);
+ it = preferences.find(PREF_LABELLOCATION);
if (it != preferences.end()) {
m_eTextLocation = it->second.uValue.eLocation;
} else {
if (m_spFCO)
- getFacilities().getPreference(m_spFCO, textLocationVariableName, m_eTextLocation);
+ getFacilities().getPreference(m_spFCO, PREF_LABELLOCATION, m_eTextLocation);
}
// Text's Enabled
if (m_spFCO) {
- if (!getFacilities().getPreference(m_spFCO, textStatusVariableName, m_bTextEnabled))
+ if (!getFacilities().getPreference(m_spFCO, PREF_LABELENABLED, m_bTextEnabled))
m_bTextEnabled = true;
} else {
m_bTextEnabled = true;
@@ -172,7 +156,7 @@
// Text's Wrap
if (m_spFCO) {
- if (getFacilities().getPreference(m_spFCO, textWrapStatusVariableName, m_iTextWrapCount)) {
+ if (getFacilities().getPreference(m_spFCO, PREF_LABELWRAP, m_iTextWrapCount)) {
m_iTextWrapCount = max(m_iTextWrapCount, 0L);
} else {
m_iTextWrapCount = 0;
@@ -180,8 +164,6 @@
} else {
m_iTextWrapCount = 0;
}
-
- m_vecText = getFacilities().wrapString(m_strText, m_iTextWrapCount, m_iMaxTextLength);
}
bool TextPart::MouseMoved(UINT nFlags, const CPoint& point, HDC transformHDC)
@@ -259,15 +241,7 @@
long TextPart::GetLongest(void) const
{
- long maxv = 0;
- for (unsigned int i = 0; i < m_vecText.size(); i++) {
- long ilen = m_vecText[i].GetLength();
- if (m_iMaxTextLength > 0)
- ilen = min(ilen, m_iMaxTextLength);
- if (maxv < ilen)
- maxv = ilen;
- }
- return maxv;
+ return m_strText.GetLength();
}
CRect TextPart::GetTextLocation(void) const
Modified: trunk/SDK/DecoratorLib/TextPart.h
==============================================================================
--- trunk/SDK/DecoratorLib/TextPart.h Thu Feb 27 12:15:07 2014 (r2453)
+++ trunk/SDK/DecoratorLib/TextPart.h Tue Mar 4 10:24:02 2014 (r2454)
@@ -25,15 +25,6 @@
class TextPart: public PartBase
{
protected:
- // Preference variable name strings
- CString textStringVariableName;
- CString textFontVariableName;
- CString textMaxLengthVariableName;
- CString textColorVariableName;
- CString textLocationVariableName;
- CString textStatusVariableName;
- CString textWrapStatusVariableName;
-
// Members
ResizeLogic resizeLogic;
CRect location;
@@ -42,15 +33,14 @@
bool m_bCursorSaved;
CString m_strText;
- std::vector<CString> m_vecText;
ELocation m_eTextLocation;
bool m_bTextEnabled;
bool m_bTextEditable;
+ bool m_bMultiLine;
long m_iTextWrapCount;
COLORREF m_crText;
int m_iFontKey;
int m_iMaxTextLength;
- bool m_bMultiLine;
public:
TextPart(PartBase* pPart, CComPtr<IMgaCommonDecoratorEvents>& eventSink);
@@ -75,7 +65,6 @@
virtual long GetLongest (void) const;
- virtual void SetText (const CString& text) { m_strText = text; };
virtual CPoint GetTextPosition (CDC* pDC, Gdiplus::Graphics* gdip) const = 0;
virtual void SetTextRelYPosition (long relYPosition) = 0;
virtual CRect GetTextLocation (CDC* pDC, Gdiplus::Graphics* gdip) const = 0;
More information about the gme-commit
mailing list