GME  13
Preference.cpp
Go to the documentation of this file.
00001 // Preference.cpp: implementation of the CPreference class.
00002 //
00004 
00005 #include "stdafx.h"
00006 #include "objectinspector.h"
00007 #include "ObjectInspectorCtl.h"
00008 
00009 #include "Preference.h"
00010 
00011 #ifdef _DEBUG
00012 #undef THIS_FILE
00013 static char THIS_FILE[]=__FILE__;
00014 #define new DEBUG_NEW
00015 #endif
00016 
00017 
00018 // Definitions of static member variables
00019 
00020 // LINE_STYLE_LIST (butt,arrow,diamond)
00021 #define LINE_STYLE_LIST_SIZE 10
00022 TCHAR *CPreference::m_szLineStyleList[]={_T("butt"), _T("arrow"), _T("diamond"), _T("apex"), _T("bullet"), _T("empty diamond"), _T("empty apex"), _T("empty bullet"), _T("left half arrow"), _T("right half arrow") };
00023 
00024 // LINE_TYPE_LIST (solid,dash)
00025 #define LINE_TYPE_LIST_SIZE 2
00026 TCHAR *CPreference::m_szLineTypeList[]={_T("solid"), _T("dash")};
00027 
00028 // BOOLEAN_LIST
00029 #define BOOLEAN_LIST_SIZE 2
00030 TCHAR *CPreference::m_szBooleanList[]={_T("true"), _T("false")};
00031 
00032 
00033 
00034 //----------------------------------- Static  tables ------------------------------------
00035 
00036 // Connection Preferences
00037 /**** Type ************* Path In Registry ** Default Value ** Name to display ************ Help Text *******************************************************************************************************************************************************/
00038 TCHAR *CPreference::m_szConnectionPreferenceTable[][5]=
00039 {
00040         {_T("COLOR"),                           _T("color"),                    _T("0x000000"),         _T("Color"),                                                            _T("Connection line color. Set this value to change the connection line color.")},
00041         {_T("COLOR"),                           _T("nameColor"),                _T("0x000000"),         _T("Name color"),                                                       _T("Connection label color. Set this value to change the connection label color.")},
00042         {_T("STRING"),                          _T("help"),                             _T(""),                         _T("Help URL"),                                                         _T("Sets this value to specify the URL containig the help information belonging to the connection.")},
00043         {_T("MULTISTRING"),                 _T("description"),          _T(""),                         _T("Description"),                                                      _T("Free format description of the model element for documentation purposes.")},
00044         {_T("LINE_STYLE_LIST"),         _T("srcStyle"),                 _T("butt"),                     _T("Source end style"),                                         _T("Sets this value to specify the source end style of the connection. Eg. Arrow.")},
00045         {_T("LINE_STYLE_LIST"),         _T("dstStyle"),                 _T("butt"),                     _T("Destination end style"),                            _T("Sets this value to specify the destination end style of the connection. Eg. Arrow.")},
00046         {_T("LINE_TYPE_LIST"),          _T("lineType"),                 _T("solid"),            _T("Line type"),                                                        _T("Sets this value to specify the connection line type. Eg. Dashed.")},
00047         {_T("STRING"),                          _T("labelFormatStr"),   _T(""),                         _T("Label format string"),                                      _T("Sets this value to form a centered connection label from the connection attributes. Eg. %name%")},
00048         {_T("STRING"),                          _T("srcLabel1"),                _T("<blank>"),          _T("Source primary attribute"),                         _T("Displays an attribute as a label on the source side of the connection.")},
00049         {_T("STRING"),                          _T("srcLabel2"),                _T("<blank>"),          _T("Source secondary attribute"),                       _T("Displays an attribute as a label on the source side of the connection.")},
00050         {_T("STRING"),                          _T("dstLabel1"),                _T("<blank>"),          _T("Destination primary attribute"),            _T("Displays an attribute as a label on the destination side of the connection.")},
00051         {_T("STRING"),                          _T("dstLabel2"),                _T("<blank>"),          _T("Destination secondary attribute"),          _T("Displays an attribute as a label on the destination side of the connection.")},
00052         {_T("BOOLEAN_LIST"),            _T("isAutoRouted"),             _T("true"),                     _T("Is auto routed"),                                           _T("Is the connection treated by the auto router.")}
00053 };
00054 
00055 
00056 // Atom Preferences
00057 /**** Type ************* Path In Registry ** Default Value ** Name to display ************ Help Text *******************************************************************************************************************************************************/
00058 TCHAR* CPreference::m_szAtomPreferenceTable[][5]=
00059 {
00060         {_T("COLOR"),                   _T("color"),                    _T("0x000000"),         _T("Color"),                                            _T("Atom color. Set this value to change the atom line color.")},
00061         {_T("COLOR"),                   _T("nameColor"),                _T("0x000000"),         _T("Name color"),                                       _T("Atom name label color. Set this value to change the atom name label color.")},
00062         {_T("COLOR"),                   _T("fillColor"),                _T("0xFFFFFF"),         _T("Fill color"),                                       _T("Atom background fill color for the closed models.")},
00063         {_T("BOOLEAN_LIST"),    _T("gradientFill"),             _T("false"),            _T("Gradient fill enabled"),            _T("Is the gradient fill feature enabled.")},
00064         {_T("COLOR"),                   _T("gradientColor"),    _T("0xc0c0c0"),         _T("Gradient (2nd fill) color"),        _T("Atom gradient background color (the other fill color).")},
00065         {_T("STRING"),                  _T("gradientDirection"),_T("0"),                        _T("Gradient direction (angle)"),       _T("Direction of the gradient fill.")},
00066         {_T("BOOLEAN_LIST"),    _T("itemShadowCast"),   _T("false"),            _T("Shadow casting enabled"),           _T("Is the shadow casting feature enabled.")},
00067         {_T("COLOR"),                   _T("shadowColor"),              _T("0xc0c0c0"),         _T("Shadow color"),                                     _T("Atom shadow color.")},
00068         {_T("STRING"),                  _T("shadowThickness"),  _T("9"),                        _T("Shadow thickness/offset"),          _T("Thickness/offset of the shadow.")},
00069         {_T("STRING"),                  _T("shadowDirection"),  _T("45"),                       _T("Shadow direction (angle)"),         _T("Direction of the shadow (angle).")},
00070         {_T("BOOLEAN_LIST"),    _T("roundCornerRect"),  _T("false"),            _T("Round rectangle corner enabled"),_T("Is rounding of rectangle corner feature enabled.")},
00071         {_T("STRING"),                  _T("roundCornerRadius"),_T("9"),                        _T("Round rectangle corner radius"),_T("Radius of round rectangle corner.")},
00072         {_T("STRING"),                  _T("help"),                             _T(""),                         _T("Help URL"),                                         _T("Sets this value to specify the URL containig the help information belonging to the atom.")},
00073         {_T("MULTISTRING"),             _T("description"),              _T(""),                         _T("Description"),                                      _T("Free format description of the model element for documentation purposes.")},
00074         {_T("COMPASS_OPTION"),  _T("namePosition"),             _T("4"),                        _T("Name Location"),                            _T("Sets the name label location relative to the atom icon. Eg. North.")},
00075         {_T("STRING"),                  _T("nameWrap"),                 _T("0"),                        _T("NameWrap number"),                          _T("Sets the number of characters in a line of the name. If it is 0, then wrapping is disabled.")},
00076         {_T("BOOLEAN_LIST"),    _T("isNameEnabled"),    _T("true"),                     _T("Name enabled"),                                     _T("Displays the name.")},
00077         {_T("COMPASS_CHECK"),   _T("autorouterPref"),   _T("neswNESW"),         _T("Auto Router Preference"),           _T("Sets the allowed stick point of the connections from and to this atom.")},
00078         {_T("BOOLEAN_LIST"),    _T("isHotspotEnabled"), _T("true"),                     _T("Hotspots enabled"),                         _T("Enables the hotspot feature in connection mode.")},
00079         {_T("BOOLEAN_LIST"),    _T("isTypeShown"),              _T("false"),            _T("Type displayed"),                           _T("Displays the type (subtype) if the atom is an Instance")},
00080         {_T("STRING"),                  _T("decorator"),                _T(""),                         _T("Decorator"),                                        _T("ProgID of an process COM component followed by optional parameters for installing  custom drawing code.\r\n Syntax: <ProgID> [<Param1=Value>...<ParamX=ValueX>]")},
00081         {_T("STRING"),                  _T("icon"),                             _T(""),                         _T("Icon name"),                                        _T("Image(.bmp,.gif) file name to display the atom. Icon search paths can be set in File/Settings menu.")},
00082         {_T("STRING"),                  _T("porticon"),                 _T(""),                         _T("Port icon name"),                           _T("Specifies the image(.bmp,.gif) file name to display the atom if it is a port in a model.")},
00083         {_T("STRING"),                  _T("subTypeIcon"),              _T(""),                         _T("Subtype icon name"),                        _T("Image(.bmp,.gif) file name to display the atom if it a subtype. Icon search paths can be set in File/Settings menu.")},
00084         {_T("STRING"),                  _T("instanceIcon"),             _T(""),                         _T("Instance icon name"),                       _T("Image(.bmp,.gif) file name to display the atom if it an instance. Icon search paths can be set in File/Settings menu.")}
00085 };
00086 
00087 
00088 // Model Preferences - item [3][2] is corrected in the constructor
00089 /**** Type ************* Path In Registry ** Default Value ** Name to display ************ Help Text *******************************************************************************************************************************************************/
00090 TCHAR* CPreference::m_szModelPreferenceTable[][5]=
00091 {
00092         {_T("COLOR"),                   _T("color"),                    _T("0xc0c0c0"),         _T("Color"),                                                            _T("Model color. Set this value to change the model line color.")},
00093         {_T("COLOR"),                   _T("nameColor"),                _T("0x000000"),         _T("Name color"),                                                       _T("Model name label color. Set this value to change the model name label color.")},
00094         {_T("COLOR"),                   _T("borderColor"),              _T("0x000000"),         _T("Border color"),                                                     _T("Model border color. Set this value to change the model border color.")},
00095         {_T("COLOR"),                   _T("backgroundColor"),  NULL,/*->Const*/_T("Background color"),                                         _T("Window background color for the open models.")},
00096         {_T("COLOR"),                   _T("fillColor"),                _T("0xFFFFFF"),         _T("Fill color"),                                                       _T("Model background fill color for the closed models.")},
00097         {_T("BOOLEAN_LIST"),    _T("gradientFill"),             _T("false"),            _T("Gradient fill enabled"),                            _T("Is the gradient fill feature enabled.")},
00098         {_T("COLOR"),                   _T("gradientColor"),    _T("0xc0c0c0"),         _T("Gradient (2nd fill) color"),                        _T("Model gradient background color for the closed models (the other fill color).")},
00099         {_T("STRING"),                  _T("gradientDirection"),_T("0"),                        _T("Gradient direction (angle)"),                       _T("Direction of the gradient (angle).")},
00100         {_T("BOOLEAN_LIST"),    _T("itemShadowCast"),   _T("false"),            _T("Shadow casting enabled"),                           _T("Is the shadow casting feature enabled.")},
00101         {_T("COLOR"),                   _T("shadowColor"),              _T("0xc0c0c0"),         _T("Shadow color"),                                                     _T("Model shadow color for the closed models.")},
00102         {_T("STRING"),                  _T("shadowThickness"),  _T("9"),                        _T("Shadow thickness/offset"),                          _T("Thickness/offset of the shadow.")},
00103         {_T("STRING"),                  _T("shadowDirection"),  _T("45"),                       _T("Shadow direction (angle)"),                         _T("Direction of the shadow (angle).")},
00104         {_T("BOOLEAN_LIST"),    _T("roundCornerRect"),  _T("false"),            _T("Round rectangle corner enabled"),           _T("Is rounding of rectangle corner feature enabled.")},
00105         {_T("STRING"),                  _T("roundCornerRadius"),_T("9"),                        _T("Round rectangle corner radius"),            _T("Radius of round rectangle corner.")},
00106         {_T("COLOR"),                   _T("portColor"),                _T("0x000000"),         _T("Port name color"),                                          _T("Port name color for the displayed ports of this model.")},
00107         {_T("STRING"),                  _T("help"),                             _T(""),                         _T("Help URL"),                                                         _T("Sets this value to specify the URL containig the help information belonging to the model.")},
00108         {_T("MULTISTRING"),             _T("description"),              _T(""),                         _T("Description"),                                                      _T("Free format description of the model element for documentation purposes.")},
00109         {_T("COMPASS_OPTION"),  _T("namePosition"),             _T("4"),                        _T("Name Location"),                                            _T("Sets the name label location relative to the atom icon. Eg. North.")},
00110         {_T("STRING"),                  _T("nameWrap"),                 _T("0"),                        _T("NameWrap number"),                                          _T("Sets the number of characters in a line of the name. If it is 0, then wrapping is disabled.")},
00111         {_T("BOOLEAN_LIST"),    _T("isNameEnabled"),    _T("true"),                     _T("Name enabled"),                                                     _T("Displays the name.")},
00112         {_T("BOOLEAN_LIST"),    _T("isModelAutoRouted"),_T("true"),                     _T("Is auto routed"),                                           _T("Are the models' connections treated by the auto router by default.")},
00113         {_T("COMPASS_CHECK"),   _T("autorouterPref"),   _T("neswNESW"),         _T("Auto Router Preference"),                           _T("Sets the allowed stick point of the connections from and to this model.")},
00114         {_T("BOOLEAN_LIST"),    _T("isHotspotEnabled"), _T("true"),                     _T("Hotspots enabled"),                                         _T("Enables the hotspot feature in connection mode.")},
00115         {_T("BOOLEAN_LIST"),    _T("isTypeShown"),              _T("false"),            _T("Type displayed"),                                           _T("Displays the type (subtype) if the model is an Instance")},
00116         {_T("BOOLEAN_LIST"),    _T("isTypeInfoShown"),  _T("false"),            _T("Typeinfo displayed"),                                       _T("Displays T, S or I letter according to that the model is Type, Subtype or Instance")},
00117         {_T("STRING"),                  _T("decorator"),                _T(""),                         _T("Decorator"),                                                        _T("ProgID of an process COM component followed by optional parameters for installing  custom drawing code.\r\n Syntax: <ProgID> [<Param1=Value>...<ParamX=ValueX>]")},
00118         {_T("STRING"),                  _T("icon"),                             _T(""),                         _T("Icon name"),                                                        _T("Image(.bmp,.gif) file name to display the model. Icon search paths can be set in File/Settings menu.")},
00119         {_T("STRING"),                  _T("porticon"),                 _T(""),                         _T("Port icon name"),                                           _T("Specifies the image(.bmp,.gif) file name to display this model if it is a port in another model.")},
00120         {_T("STRING"),                  _T("subTypeIcon"),              _T(""),                         _T("Subtype icon name"),                                        _T("Image(.bmp,.gif) file name to display the model if it a subtype. Icon search paths can be set in File/Settings menu.")},
00121         {_T("STRING"),                  _T("instanceIcon"),             _T(""),                         _T("Instance icon name"),                                       _T("Image(.bmp,.gif) file name to display the model if it an instance. Icon search paths can be set in File/Settings menu.")},
00122         {_T("BOOLEAN_LIST"),    _T("portLabelInside"),  _T("true"),                     _T("PortLabel shown inside container?"),        _T("Portname label may be shown either inside or outside the container.")},
00123         {_T("STRING"),                  _T("portLabelLength"),  _T("3"),                        _T("PortLabel Length"),                                         _T("Sets the text length shown when displaying portnames. If 0 total length is shown.")}
00124 };
00125 
00126 
00127 // Reference (Proxy) Preferences
00128 /**** Type ************* Path In Registry ** Default Value ** Name to display ************ Help Text *******************************************************************************************************************************************************/
00129 TCHAR* CPreference::m_szProxyPreferenceTable[][5]=
00130 {
00131         {_T("COLOR"),                   _T("color"),                    _T("0xc0c0c0"),         _T("Color"),                                                            _T("Proxy color. Set this value to change the proxy line color.")},
00132         {_T("COLOR"),                   _T("nameColor"),                _T("0x000000"),         _T("Name color"),                                                       _T("Proxy name label color. Set this value to change the proxy name label color.")},
00133         {_T("COLOR"),                   _T("fillColor"),                _T("0xFFFFFF"),         _T("Fill color"),                                                       _T("Proxy background fill color for the closed models.")},
00134         {_T("BOOLEAN_LIST"),    _T("gradientFill"),             _T("false"),            _T("Gradient fill enabled"),                            _T("Is the gradient fill feature enabled.")},
00135         {_T("COLOR"),                   _T("gradientColor"),    _T("0xc0c0c0"),         _T("Gradient (2nd fill) color"),                        _T("Proxy gradient background color for the closed models (the other fill color).")},
00136         {_T("STRING"),                  _T("gradientDirection"),_T("0"),                        _T("Gradient direction (angle)"),                       _T("Direction of the gradient fill.")},
00137         {_T("BOOLEAN_LIST"),    _T("itemShadowCast"),   _T("false"),            _T("Shadow casting enabled"),                           _T("Is the shadow casting feature enabled.")},
00138         {_T("COLOR"),                   _T("shadowColor"),              _T("0xc0c0c0"),         _T("Shadow color"),                                                     _T("Proxy shadow color.")},
00139         {_T("STRING"),                  _T("shadowThickness"),  _T("9"),                        _T("Shadow thickness/offset"),                          _T("Thickness/offset of the shadow.")},
00140         {_T("STRING"),                  _T("shadowDirection"),  _T("45"),                       _T("Shadow direction (angle)"),                         _T("Direction of the shadow (angle).")},
00141         {_T("BOOLEAN_LIST"),    _T("roundCornerRect"),  _T("false"),            _T("Round rectangle corner enabled"),           _T("Is rounding of rectangle corner feature enabled.")},
00142         {_T("STRING"),                  _T("roundCornerRadius"),_T("9"),                        _T("Round rectangle corner radius"),            _T("Radius of round rectangle corner.")},
00143         {_T("STRING"),                  _T("help"),                             _T(""),                         _T("Help URL"),                                                         _T("Sets this value to specify the URL containig the help information belonging to the proxy.")},
00144         {_T("MULTISTRING"),             _T("description"),              _T(""),                         _T("Description"),                                                      _T("Free format description of the model element for documentation purposes.")},
00145         {_T("COMPASS_OPTION"),  _T("namePosition"),             _T("4"),                        _T("Name Location"),                                            _T("Sets the name label location relative to the proxy icon. Eg. North.")},
00146         {_T("STRING"),                  _T("nameWrap"),                 _T("0"),                        _T("NameWrap number"),                                          _T("Sets the number of characters in a line of the name. If it is 0, then wrapping is disabled.")},
00147         {_T("BOOLEAN_LIST"),    _T("isNameEnabled"),    _T("true"),                     _T("Name enabled"),                                                     _T("Displays the name.")},
00148         {_T("COMPASS_CHECK"),   _T("autorouterPref"),   _T("neswNESW"),         _T("Auto Router Preference"),                           _T("Sets the allowed stick point of the connections from and to this proxy.")},
00149         {_T("BOOLEAN_LIST"),    _T("isHotspotEnabled"), _T("true"),                     _T("Hotspots enabled"),                                         _T("Enables the hotspot feature in connection mode.")},
00150         {_T("COLOR"),                   _T("borderColor"),              _T("0x000000"),         _T("Border color"),                                                     _T("Proxy border color. Set this value to change the proxy border color.")},
00151         {_T("COLOR"),                   _T("portColor"),                _T("0x000000"),         _T("Port name color"),                                          _T("Port name color for the displayed ports of this proxy.")},
00152         {_T("STRING"),                  _T("decorator"),                _T(""),                         _T("Decorator"),                                                        _T("ProgID of an process COM component followed by optional parameters for installing  custom drawing code.\r\n Syntax: <ProgID> [<Param1=Value>...<ParamX=ValueX>]")},
00153         {_T("STRING"),                  _T("icon"),                             _T(""),                         _T("Icon name"),                                                        _T("Image(.bmp,.gif) file name to display the proxy. Icon search paths can be set in File/Settings menu.")},
00154         {_T("STRING"),                  _T("porticon"),                 _T(""),                         _T("Port icon name"),                                           _T("Specifies the image(.bmp,.gif) file name to display the proxy if it is a port in a proxy.")},
00155         {_T("BOOLEAN_LIST"),    _T("portLabelInside"),  _T("true"),                     _T("PortLabel shown inside container?"),        _T("Portname label may be shown either inside or outside the container.")},
00156         {_T("STRING"),                  _T("portLabelLength"),  _T("3"),                        _T("PortLabel Length"),                                         _T("Sets the text length shown when displaying portnames. If 0 total length is shown.")}
00157 };
00158 
00159 
00160 // Set Preferences
00161 /**** Type ************* Path In Registry ** Default Value ** Name to display ************ Help Text *******************************************************************************************************************************************************/
00162 TCHAR* CPreference::m_szSetPreferenceTable[][5]=
00163 {
00164         {_T("COLOR"),                   _T("color"),                    _T("0x000000"),         _T("Color"),                                            _T("Set color. Set this value to change the set line color.")},
00165         {_T("COLOR"),                   _T("nameColor"),                _T("0x000000"),         _T("Name color"),                                       _T("Set name label color. Set this value to change the set name label color.")},
00166         {_T("COLOR"),                   _T("fillColor"),                _T("0xFFFFFF"),         _T("Fill color"),                                       _T("Set background fill color for the closed models.")},
00167         {_T("BOOLEAN_LIST"),    _T("gradientFill"),             _T("false"),            _T("Gradient fill enabled"),            _T("Is the gradient fill feature enabled.")},
00168         {_T("COLOR"),                   _T("gradientColor"),    _T("0xc0c0c0"),         _T("Gradient (2nd fill) color"),        _T("Set gradient background color (the other fill color).")},
00169         {_T("STRING"),                  _T("gradientDirection"),_T("0"),                        _T("Gradient direction (angle)"),       _T("Direction of the gradient fill.")},
00170         {_T("BOOLEAN_LIST"),    _T("itemShadowCast"),   _T("false"),            _T("Shadow casting enabled"),           _T("Is the shadow casting feature enabled.")},
00171         {_T("COLOR"),                   _T("shadowColor"),              _T("0xc0c0c0"),         _T("Shadow color"),                                     _T("Set shadow color.")},
00172         {_T("STRING"),                  _T("shadowThickness"),  _T("9"),                        _T("Shadow thickness/offset"),          _T("Thickness/offset of the shadow.")},
00173         {_T("STRING"),                  _T("shadowDirection"),  _T("45"),                       _T("Shadow direction (angle)"),         _T("Direction of the shadow (angle).")},
00174         {_T("BOOLEAN_LIST"),    _T("roundCornerRect"),  _T("false"),            _T("Round rectangle corner enabled"),_T("Is rounding of rectangle corner feature enabled.")},
00175         {_T("STRING"),                  _T("roundCornerRadius"),_T("9"),                        _T("Round rectangle corner radius"),_T("Radius of round rectangle corner.")},
00176         {_T("STRING"),                  _T("help"),                             _T(""),                         _T("Help URL"),                                         _T("Sets this value to specify the URL containig the help information belonging to the set.")},
00177         {_T("MULTISTRING"),             _T("description"),              _T(""),                         _T("Description"),                                      _T("Free format description of the model element for documentation purposes.")},
00178         {_T("COMPASS_OPTION"),  _T("namePosition"),             _T("4"),                        _T("Name Location"),                            _T("Sets the name label location relative to the set icon. Eg. North.")},
00179         {_T("STRING"),                  _T("nameWrap"),                 _T("0"),                        _T("NameWrap number"),                          _T("Sets the number of characters in a line of the name. If it is 0, then wrapping is disabled.")},
00180         {_T("BOOLEAN_LIST"),    _T("isNameEnabled"),    _T("true"),                     _T("Name enabled"),                                     _T("Displays the name.")},
00181         {_T("COMPASS_CHECK"),   _T("autorouterPref"),   _T("neswNESW"),         _T("Auto Router Preference"),           _T("Sets the allowed stick point of the connections from and to this set.")},
00182         {_T("BOOLEAN_LIST"),    _T("isHotspotEnabled"), _T("true"),                     _T("Hotspots enabled"),                         _T("Enables the hotspot feature in connection mode.")},
00183         {_T("BOOLEAN_LIST"),    _T("isTypeShown"),              _T("false"),            _T("Type displayed"),                           _T("Displays the type (subtype) if the set is an Instance")},
00184         {_T("STRING"),                  _T("decorator"),                _T(""),                         _T("Decorator"),                                        _T("ProgID of an process COM component followed by optional parameters for installing  custom drawing code.\r\n Syntax: <ProgID> [<Param1=Value>...<ParamX=ValueX>]")},
00185         {_T("STRING"),                  _T("icon"),                             _T(""),                         _T("Icon name"),                                        _T("Image(.bmp,.gif) file name to display the set. Icon search paths can be set in File/Settings menu.")},
00186         {_T("STRING"),                  _T("porticon"),                 _T(""),                         _T("Port icon name"),                           _T("Specifies the image(.bmp,.gif) file name to display the set if it is a port in a model.")},
00187         {_T("STRING"),                  _T("subTypeIcon"),              _T(""),                         _T("Subtype icon name"),                        _T("Image(.bmp,.gif) file name to display the set if it a subtype. Icon search paths can be set in File/Settings menu.")},
00188         {_T("STRING"),                  _T("instanceIcon"),             _T(""),                         _T("Instance icon name"),                       _T("Image(.bmp,.gif) file name to display the set if it an instance. Icon search paths can be set in File/Settings menu.")}
00189 };
00190 /***********************************************************************************************************************************************************************************************************************************************************/
00191 
00192 
00193 
00194 
00195 
00196 
00198 // Construction/Destruction
00200 
00201 CPreference::CPreference()
00202 {
00203         nConnTableLength = sizeof(m_szConnectionPreferenceTable)/sizeof(TCHAR*)/5;
00204         nAtomTableLength = sizeof(m_szAtomPreferenceTable)/sizeof(TCHAR*)/5;
00205         nModelTableLength= sizeof(m_szModelPreferenceTable)/sizeof(TCHAR*)/5;
00206         nProxyTableLength= sizeof(m_szProxyPreferenceTable)/sizeof(TCHAR*)/5;
00207         nSetTableLength=   sizeof(m_szSetPreferenceTable)/sizeof(TCHAR*)/5;
00208 
00209         // Get system background color
00210         COLORREF crSysBckg=::GetSysColor(COLOR_WINDOW);
00211         swprintf(m_szSysBckGrnd, sizeof(m_szSysBckGrnd)/sizeof(m_szSysBckGrnd[0]), _T("0x%02x%02x%02x"),GetRValue(crSysBckg), GetGValue(crSysBckg), GetBValue(crSysBckg));
00212 
00213         // Correcting table
00214         m_szModelPreferenceTable[3][2]=m_szSysBckGrnd;
00215 
00216         isAutRouterPrefsCategoryAdded = false;
00217 }
00218 
00219 CPreference::~CPreference()
00220 {
00221 
00222 }
00223 
00224 
00225 // Finding the common preferences based on registry path
00226 // which is assumed unique in the tables.
00227 
00228 void CPreference::SetupPreferences(BYTE cFlags)
00229 {
00230         m_strRegPathList.RemoveAll();
00231 
00232         if(cFlags<1 || cFlags>=32)
00233         {
00234                 ASSERT((_T("Invalid cFlags parameter SetupPreferences(...)"),0));
00235                 return;
00236         }
00237 
00238         // If there is a Connection
00239         if(cFlags&PREF_CONNECTION)
00240         {
00241                 for(int i=0;i<nConnTableLength;i++)
00242                 {
00243                         bool bIsCommonRegPath=true;
00244                         CString strCurrRegPath(m_szConnectionPreferenceTable[i][1]);
00245 
00246                         if(cFlags&PREF_ATOM)
00247                         {
00248                                 bIsCommonRegPath&=(FindRegPathInAtomTable(strCurrRegPath)!=-1);
00249                         }
00250                         if(cFlags&PREF_MODEL)
00251                         {
00252                                 bIsCommonRegPath&=(FindRegPathInModelTable(strCurrRegPath)!=-1);
00253                         }
00254                         if(cFlags&PREF_PROXY)
00255                         {
00256                                 bIsCommonRegPath&=(FindRegPathInProxyTable(strCurrRegPath)!=-1);
00257                         }
00258                         if(cFlags&PREF_SET)
00259                         {
00260                                 bIsCommonRegPath&=(FindRegPathInSetTable(strCurrRegPath)!=-1);
00261                         }
00262 
00263                         // If it was a common preference
00264                         if(bIsCommonRegPath)
00265                         {
00266                                 m_strRegPathList.AddTail(strCurrRegPath);
00267                         }
00268                 }
00269         }
00270         // Atom
00271         else if(cFlags&PREF_ATOM)
00272         {
00273                 for(int i=0;i<nAtomTableLength;i++)
00274                 {
00275                         bool bIsCommonRegPath=true;
00276                         CString strCurrRegPath(m_szAtomPreferenceTable[i][1]);
00277 
00278                         if(cFlags&PREF_MODEL)
00279                         {
00280                                 bIsCommonRegPath&=(FindRegPathInModelTable(strCurrRegPath)!=-1);
00281                         }
00282                         if(cFlags&PREF_PROXY)
00283                         {
00284                                 bIsCommonRegPath&=(FindRegPathInProxyTable(strCurrRegPath)!=-1);
00285                         }
00286                         if(cFlags&PREF_SET)
00287                         {
00288                                 bIsCommonRegPath&=(FindRegPathInSetTable(strCurrRegPath)!=-1);
00289                         }
00290 
00291                         // If it was a common preference
00292                         if(bIsCommonRegPath)
00293                         {
00294                                 m_strRegPathList.AddTail(strCurrRegPath);
00295                         }
00296 
00297                 }
00298         }
00299         // Model
00300         else if(cFlags&PREF_MODEL)
00301         {
00302                 for(int i=0;i<nModelTableLength;i++)
00303                 {
00304                         bool bIsCommonRegPath=true;
00305                         CString strCurrRegPath(m_szModelPreferenceTable[i][1]);
00306 
00307                         if(cFlags&PREF_PROXY)
00308                         {
00309                                 bIsCommonRegPath&=(FindRegPathInProxyTable(strCurrRegPath)!=-1);
00310                         }
00311                         if(cFlags&PREF_SET)
00312                         {
00313                                 bIsCommonRegPath&=(FindRegPathInSetTable(strCurrRegPath)!=-1);
00314                         }
00315 
00316                         // If it was a common preference
00317                         if(bIsCommonRegPath)
00318                         {
00319                                 m_strRegPathList.AddTail(strCurrRegPath);
00320                         }
00321                 }
00322         }
00323         //Proxy
00324         else if(cFlags&PREF_PROXY)
00325         {
00326                 for(int i=0;i<nProxyTableLength;i++)
00327                 {
00328                         CString strCurrRegPath(m_szProxyPreferenceTable[i][1]);
00329                         bool bIsCommonRegPath=true;
00330 
00331                         if(cFlags&PREF_SET)
00332                         {
00333                                 bIsCommonRegPath&=(FindRegPathInSetTable(strCurrRegPath)!=-1);
00334                         }
00335 
00336                         // If it was a common preference
00337                         if(bIsCommonRegPath)
00338                         {
00339                                 m_strRegPathList.AddTail(strCurrRegPath);
00340                         }
00341                 }
00342         }
00343         // Set
00344         else if(cFlags&PREF_SET)
00345         {
00346                 for(int i=0;i<nSetTableLength;i++)
00347                 {
00348                         CString strCurrRegPath(m_szSetPreferenceTable[i][1]);
00349                         m_strRegPathList.AddTail(strCurrRegPath);
00350                 }
00351         }
00352 
00353         // ERROR: wrong cFlags parameter
00354         else
00355         {
00356                 ASSERT((_T("Invalid cFlags parameter SetupPreferences(...)"),0));
00357         }
00358 
00359 }
00360 
00361 int CPreference::FindRegPathInConnectionTable(const CString &strPath)
00362 {
00363 
00364         for(int i=0;i<nConnTableLength;i++)
00365         {
00366                 CString strPathElement(m_szConnectionPreferenceTable[i][1]);
00367                 if(strPath==strPathElement)
00368                 {
00369                         return i;
00370                 }
00371         }
00372 
00373         return -1;
00374 }
00375 
00376 int CPreference::FindRegPathInAtomTable(const CString &strPath)
00377 {
00378         for(int i=0;i<nAtomTableLength;i++)
00379         {
00380                 CString strPathElement(m_szAtomPreferenceTable[i][1]);
00381                 if(strPath==strPathElement)
00382                 {
00383                         return i;
00384                 }
00385         }
00386 
00387         return -1;
00388 }
00389 
00390 
00391 int CPreference::FindRegPathInModelTable(const CString &strPath)
00392 {
00393         for(int i=0;i<nModelTableLength;i++)
00394         {
00395                 CString strPathElement(m_szModelPreferenceTable[i][1]);
00396                 if(strPath==strPathElement)
00397                 {
00398                         return i;
00399                 }
00400         }
00401 
00402         return -1;
00403 }
00404 
00405 
00406 int CPreference::FindRegPathInProxyTable(const CString &strPath)
00407 {
00408         for(int i=0;i<nProxyTableLength;i++)
00409         {
00410                 CString strPathElement(m_szProxyPreferenceTable[i][1]);
00411                 if(strPath==strPathElement)
00412                 {
00413                         return i;
00414                 }
00415         }
00416         return -1;
00417 }
00418 
00419 
00420 int CPreference::FindRegPathInSetTable(const CString &strPath)
00421 {
00422         for(int i=0;i<nSetTableLength;i++)
00423         {
00424                 CString strPathElement(m_szSetPreferenceTable[i][1]);
00425                 if(strPath==strPathElement)
00426                 {
00427                         return i;
00428                 }
00429         }
00430 
00431         return -1;
00432 }
00433 
00434 
00435 // Must be in transaction
00436 void CPreference::CreateList(const CMgaFCOPtrList& MgaFCOPtrList)
00437 {
00438         m_ListItemArray.RemoveAll();
00439         isAutRouterPrefsCategoryAdded = false;
00440         // If there is no FCO to show
00441         if(MgaFCOPtrList.IsEmpty())
00442         {
00443                 return;
00444         }
00445 
00446         CListItem ListItem;
00447         ListItem.bIsContainer=true;
00448         ListItem.strName=_T("General Preferences");
00449 
00450         m_ListItemArray.Add(ListItem);
00451 
00452         BYTE cFlag=0;
00453         //CComPtr<IMgaFCO> ccpMgaFCO; // commented by zolmol7
00454 
00455 
00456         POSITION pos=MgaFCOPtrList.GetHeadPosition();
00457 
00458         // Iterating through the list determining the types of the FCOs
00459         while(pos)
00460         {
00461                 CComPtr<IMgaFCO> ccpMgaFCO = MgaFCOPtrList.GetNext(pos); // zolmol7
00462 
00463                 objtype_enum oeType;
00464                 COMTHROW(ccpMgaFCO->get_ObjType(&oeType));
00465 
00466 
00467                 switch(oeType)
00468                 {
00469                         case OBJTYPE_MODEL:
00470                                 cFlag|=PREF_MODEL;break;
00471 
00472                         case OBJTYPE_ATOM:
00473                                 cFlag|=PREF_ATOM;break;
00474 
00475                         case OBJTYPE_CONNECTION:
00476                                 cFlag|=PREF_CONNECTION;break;
00477 
00478                         case OBJTYPE_REFERENCE:
00479                                 cFlag|=PREF_PROXY;break;
00480 
00481                         case OBJTYPE_SET:
00482                                 cFlag|=PREF_SET;break;
00483 
00484                         default: ASSERT((_T("Invalid MGA object type found creating preference list"),FALSE));break;
00485                 }
00486         }
00487 
00488         // Creating preferences registry paths to m_strRegPathList
00489         SetupPreferences(cFlag);
00490 
00491         // Iterating through m_strRegPathList
00492         POSITION posPathList=m_strRegPathList.GetHeadPosition();
00493         // Because GetNext updates the position, we store the position of the current element
00494         POSITION posPathListCurr=posPathList;
00495 
00496         while(posPathList)
00497         {
00498                 CString strCurrPath=m_strRegPathList.GetNext(posPathList);
00499 
00500                 // Getting the registry entry for each objects
00501                 POSITION posFCOs=MgaFCOPtrList.GetHeadPosition();
00502 
00503                 // If there are multiple objects, they will be displayed based on the first one.
00504                 bool bFirstRun=true;
00505                 bool bSameValuefOrAll=true;
00506                 bool bIsDefault=true;
00507                 objtype_enum oeFirstType = OBJTYPE_ATOM;
00508                 CString strFirstValue;
00509 
00510                 while(posFCOs)
00511                 {
00512                         CComPtr<IMgaFCO> ccpMgaFCO = MgaFCOPtrList.GetNext(posFCOs);
00513 
00514                         /*** Getting value belonging to the current registry path from MGA ***/
00515                         CString strRegValue;
00516                         int status = GetRegistryValue(ccpMgaFCO,strCurrPath,strRegValue);
00517 
00518                         if (status == ATTSTATUS_INVALID || status == ATTSTATUS_UNDEFINED)
00519                         {
00520                                 // get default value from table
00521                                 objtype_enum oeType;
00522                                 COMTHROW(ccpMgaFCO->get_ObjType(&oeType));
00523                                 GetDefaultValue(strCurrPath, oeType, strRegValue);
00524                         }
00525 
00526                         bIsDefault = (status != ATTSTATUS_HERE);
00527 
00528                         if(bFirstRun)
00529                         {
00530                                 strFirstValue=strRegValue;
00531                                 COMTHROW(ccpMgaFCO->get_ObjType(&oeFirstType));
00532 
00533                                 bFirstRun=false;
00534                         }
00535                         if(strFirstValue!=strRegValue)
00536                         {
00537                                 bSameValuefOrAll=false;
00538                         }
00539                 }
00540 
00541                 TableRowType pTableRow=GetTableRow(strCurrPath,oeFirstType);
00542 
00543                 // Creating CListItem
00544                 CArray<CListItem,CListItem&> ListItems;
00545 
00546                 bool bIsMultiple=(MgaFCOPtrList.GetCount()>1);
00547 
00548                 CComPtr<IMgaFCO> ccpFirstFCO=MgaFCOPtrList.GetHead();
00549 
00550 
00551 
00552                 // Create list items - they may consist of more then one item (AutoRouter Preference)
00553                 CreateListItem(ListItems, pTableRow,strFirstValue,bSameValuefOrAll,
00554                                                 bIsDefault,bIsMultiple,ccpFirstFCO,posPathListCurr);
00555 
00556                 SetCategories(strCurrPath,false);
00557 
00558                 m_ListItemArray.Append(ListItems);
00559 
00560                 SetCategories(strCurrPath,true);
00561 
00562                 posPathListCurr=posPathList;
00563         }
00564 
00565 
00566 }
00567 
00568 
00569 void CPreference::SetCategories( const CString& strPath, bool bIsAfter)
00570 {
00571 
00572         CString strName, strToolTip;
00573 
00574         if(!bIsAfter)
00575         {
00576                 if(strPath==_T("srcStyle"))
00577                 {
00578                         strName=_T("Connection Preferences");
00579                 }
00580                 else if((strPath==_T("autorouterPref") || strPath==_T("isModelAutoRouted")) && !isAutRouterPrefsCategoryAdded)
00581                 {
00582                         strName=_T("Auto Router Preferences");
00583                         isAutRouterPrefsCategoryAdded = true;
00584                 }
00585                 else
00586                 {
00587                         return;
00588                 }
00589         }
00590         else
00591         {
00592                 return;
00593         }
00594 
00595         CListItem ListItem;
00596         ListItem.bIsContainer=true;
00597         ListItem.strName=strName;
00598         ListItem.strToolTip=strToolTip;
00599 
00600         m_ListItemArray.Add(ListItem);
00601 
00602 
00603 }
00604 
00605 
00606 // Getting value belonging to the specified registry path from MGA.
00607 // If strRegValue is empty the registry value does not exist.
00608 int CPreference::GetRegistryValue(CComPtr<IMgaFCO>&ccpMgaFCO,CString strPath, CString &strRegValue)
00609 {
00610         CComBSTR bstrRegPath(strPath);
00611 
00612         // Getting regnode
00613         CComPtr<IMgaRegNode> ccpMgaRegNode;
00614         COMTHROW(ccpMgaFCO->get_RegistryNode(bstrRegPath,&ccpMgaRegNode));
00615 
00616         // Getting regnode status
00617         long lRegNodeStatus;
00618         COMTHROW(ccpMgaRegNode->get_Status(&lRegNodeStatus));
00619 
00620 
00621         //Status of definition: 0: this node, -1: in meta, >=1: inherited
00622         if(lRegNodeStatus == ATTSTATUS_HERE)
00623         {
00624                 /* Getting the value of the registry node */
00625 
00626                 CComBSTR bstrRegValue;
00627                 COMTHROW(ccpMgaRegNode->get_Value(&bstrRegValue));
00628 
00629                 strRegValue=bstrRegValue;
00630 
00631         }
00632         else if(lRegNodeStatus == ATTSTATUS_METADEFAULT)
00633         {
00634                 /* Getting value from meta */
00635 
00636                 // Getting Meta
00637                 CComPtr<IMgaMetaFCO> ccpMetaFCO;
00638                 COMTHROW(ccpMgaFCO->get_Meta(&ccpMetaFCO));
00639 
00640                 // Getting registry value from meta
00641                 CComBSTR bstrRegValue;
00642                 COMTHROW(ccpMetaFCO->get_RegistryValue(bstrRegPath,&bstrRegValue));
00643 
00644                 strRegValue=bstrRegValue;
00645         }
00646         else if(lRegNodeStatus >= ATTSTATUS_IN_ARCHETYPE1)
00647         {
00648                 /* Getting inherited value */
00649 
00650                 // Getting ancestor FCO
00651                 CComPtr<IMgaFCO> ccpAncestorFCO;
00652                 COMTHROW(ccpMgaFCO->get_DerivedFrom(&ccpAncestorFCO));
00653 
00654                 // Getting registry value from the ancestor
00655                 CComBSTR bstrRegValue;
00656                 COMTHROW(ccpAncestorFCO->get_RegistryValue(bstrRegPath,&bstrRegValue));
00657 
00658                 strRegValue=bstrRegValue;
00659         }
00660         else if(lRegNodeStatus == ATTSTATUS_INVALID)  //  - It does happen.
00661         {
00662                 strRegValue=_T("");
00663         }
00664         else if (lRegNodeStatus == ATTSTATUS_UNDEFINED)
00665         {
00666         }
00667         else
00668         {
00669                 ASSERT((_T("Undocumented(and undesired) MGA feature"),false));
00670         }
00671         return lRegNodeStatus;
00672 }
00673 
00674 
00675 
00676 
00677 void CPreference::GetDefaultValue(CString strCurrPath, objtype_enum oeType, CString& strDefValue)
00678 {
00679         switch(oeType)
00680         {
00681                 case OBJTYPE_MODEL:
00682                         {
00683                                 int nIndex=FindRegPathInModelTable(strCurrPath);
00684                                 ASSERT(nIndex!=-1);
00685                                 strDefValue=m_szModelPreferenceTable[nIndex][2];
00686                         }
00687                         break;
00688 
00689                 case OBJTYPE_ATOM:
00690                         {
00691                                 int nIndex=FindRegPathInAtomTable(strCurrPath);
00692                                 ASSERT(nIndex!=-1);
00693                                 strDefValue=m_szAtomPreferenceTable[nIndex][2];
00694                         }
00695                         break;
00696 
00697                 case OBJTYPE_CONNECTION:
00698                         {
00699                                 int nIndex=FindRegPathInConnectionTable(strCurrPath);
00700                                 ASSERT(nIndex!=-1);
00701                                 strDefValue=m_szConnectionPreferenceTable[nIndex][2];
00702                         }
00703                         break;
00704 
00705                 case OBJTYPE_REFERENCE:
00706                         {
00707                                 int nIndex=FindRegPathInProxyTable(strCurrPath);
00708                                 ASSERT(nIndex!=-1);
00709                                 strDefValue=m_szProxyPreferenceTable[nIndex][2];
00710                         }
00711                         break;
00712 
00713                 case OBJTYPE_SET:
00714                         {
00715                                 int nIndex=FindRegPathInSetTable(strCurrPath);
00716                                 ASSERT(nIndex!=-1);
00717                                 strDefValue=m_szSetPreferenceTable[nIndex][2];
00718                         }
00719                         break;
00720 
00721                 default: ASSERT((_T("Invalid MGA object type found creating preference list"),FALSE));break;
00722         }
00723 }
00724 
00725 
00726 
00727 
00728 void CPreference::CreateListItem(CArray<CListItem,CListItem&> &ListItems,
00729                                                                  TableRowType pTableRow, const CString &strValue,
00730                                                                  bool bSameValueForAll, bool bIsDefault,
00731                                                                  bool bIsMultiple, const CComPtr<IMgaFCO>&ccpMgaFCO,
00732                                                                  POSITION nKey)
00733 {
00734 
00735         ListItems.RemoveAll();
00736 
00737         CListItem ListItem;
00738         ListItem.strName=(*pTableRow)[3];
00739         ListItem.strToolTip=(*pTableRow)[4];
00740         ListItem.bIsDefault=bIsDefault;
00741         ListItem.bIsDifferentValue=!bSameValueForAll;
00742         ListItem.dwKeyValue=(DWORD)nKey;
00743         ListItem.dwUserData=0;
00744 
00745         CString strPrefName=(*pTableRow)[1];
00746 
00747         if(strPrefName==_T("isAutoRouted"))
00748         {
00749                 ListItem.dwUserData=AUTOROUTER_STATE_CONN;
00750         }
00751         else if(strPrefName==_T("isModelAutoRouted"))
00752         {
00753                 ListItem.dwUserData=AUTOROUTER_STATE_MODEL;
00754         }
00755 
00756         CString strEntryType=(*pTableRow)[0];
00757 
00758         if(strEntryType==_T("COLOR"))
00759         {
00760                 // Change value format from MGA 0xrrggbb to Windows 0xbbggrr
00761                 CString strNewVal;
00762 
00763                 TCHAR* endptr;
00764                 long l = _tcstol(strValue, &endptr, 16);
00765                 if(*endptr == _T('\0'))
00766                 {
00767                         strNewVal.Format(_T("0x%02x%02x%02x"),GetRValue(l), GetGValue(l), GetBValue(l));
00768                 }
00769                 else
00770                 {
00771                         // Invalid color format
00772                         ASSERT(false);
00773                 }
00774                 ListItem.Value.dataType=ITEMDATA_COLOR;
00775                 ListItem.Value.stringVal.SetAtGrow(0,strNewVal);
00776                 VERIFY(ListItem.Value.Validate());
00777 
00778                 ListItem.DefValue.dataType=ITEMDATA_COLOR;
00779                 ListItem.DefValue.stringVal.SetAtGrow(0,(*pTableRow)[2]);
00780                 VERIFY(ListItem.DefValue.Validate());
00781                 ListItems.Add(ListItem);
00782         }
00783 
00784         else if(strEntryType==_T("STRING"))
00785         {
00786                 ListItem.Value.SetStringValue(strValue);
00787                 ListItem.DefValue.SetStringValue((*pTableRow)[2]);
00788                 ListItems.Add(ListItem);
00789         }
00790 
00791         else if(strEntryType==_T("MULTISTRING"))
00792         {
00793                 CStringArray strValueArray;
00794                 str_split(strValue, strValueArray);
00795                 ListItem.Value.SetStringValue(strValueArray,3);
00796 
00797                 CString strDefValue = (*pTableRow)[2];
00798                 CStringArray strDefValueArray;
00799                 str_split(strDefValue, strDefValueArray);
00800                 ListItem.DefValue.SetStringValue(strDefValueArray,3);
00801                 
00802                 ListItems.Add(ListItem);
00803         }
00804 
00805         else if(strEntryType==_T("COMPASS_OPTION"))
00806         {
00807                 UINT uCompassValue= CCompassData::ParseMgaCompassValueOption(strValue);
00808                 ListItem.Value.SetCompassExclValue(uCompassValue);
00809 
00810                 uCompassValue=CCompassData::ParseMgaCompassValueOption((*pTableRow)[2]);
00811                 ListItem.DefValue.SetCompassExclValue(uCompassValue);
00812                 ListItems.Add(ListItem);
00813         }
00814 
00815         else if(strEntryType==_T("COMPASS_CHECK"))
00816         {
00817                 // Dst: small case; Src: capital
00818                 UINT uSrcVal,uDstVal,uSrcDefVal,uDstDefVal;
00819                 CCompassData::ParseMgaCompassValueCheck(strValue,uDstVal,uSrcVal);
00820                 CCompassData::ParseMgaCompassValueCheck((*pTableRow)[2],uDstDefVal,uSrcDefVal);
00821 
00822                 CListItem ListItemSrc=ListItem;
00823 
00824                 // Setting source
00825                 ListItemSrc.Value.SetCompassValue(uSrcVal);
00826                 ListItemSrc.DefValue.SetCompassValue(uSrcDefVal);
00827                 ListItemSrc.strName+=_T(" (Source)");
00828                 ListItemSrc.strToolTip+=_T(" (Source side)");
00829                 ListItemSrc.dwUserData=AUTOROUTER_SOURCE;
00830 
00831                 ListItems.Add(ListItemSrc);
00832 
00833                 // Setting destination
00834                 ListItem.Value.SetCompassValue(uDstVal);
00835                 ListItem.DefValue.SetCompassValue(uDstDefVal);
00836                 ListItem.strName+=_T(" (Destination)");
00837                 ListItem.strToolTip+=_T(" (Destination side)");
00838                 ListItem.dwUserData=AUTOROUTER_DESTINATION;
00839                 ListItems.Add(ListItem);
00840 
00841                 // Creating _T("Miscellaneous Preferences") category
00842                 CListItem ListItemMisc;
00843                 ListItemMisc.bIsContainer=true;
00844                 ListItemMisc.strName=_T("Miscellaneous Preferences");
00845                 ListItems.Add(ListItemMisc);
00846 
00847         }
00848 
00849         else if(strEntryType==_T("LINE_STYLE_LIST"))
00850         {
00851                 CString strDefValue=(*pTableRow)[2];
00852                 CStringArray strArr;
00853                 int nDefIndex=-1, nIndex=-1;
00854 
00855                 for(int i=0;i<LINE_STYLE_LIST_SIZE;i++)
00856                 {
00857                         CString strTemp=m_szLineStyleList[i];
00858                         if(strTemp==strValue)
00859                         {
00860                                 nIndex=i;
00861                         }
00862 
00863                         if(strTemp==strDefValue)
00864                         {
00865                                 nDefIndex=i;
00866                         }
00867                         strArr.Add(strTemp);
00868                 }
00869 
00870                 ASSERT(nIndex!=-1);             // Values is not in the list
00871                 ASSERT(nDefIndex!=-1);  // Value in the table as default is not in the list
00872 
00873                 ListItem.Value.SetListValue(strArr,nIndex);
00874                 ListItem.DefValue.SetListValue(strArr,nDefIndex);
00875                 ListItems.Add(ListItem);
00876 
00877         }
00878         else if(strEntryType==_T("LINE_TYPE_LIST"))
00879         {
00880                 CString strDefValue=(*pTableRow)[2];
00881                 CStringArray strArr;
00882                 int nDefIndex=-1, nIndex=-1;
00883 
00884                 for(int i=0;i<LINE_TYPE_LIST_SIZE;i++)
00885                 {
00886                         CString strTemp=m_szLineTypeList[i];
00887                         if(strTemp==strValue)
00888                         {
00889                                 nIndex=i;
00890                         }
00891 
00892                         if(strTemp==strDefValue)
00893                         {
00894                                 nDefIndex=i;
00895                         }
00896                         strArr.Add(strTemp);
00897                 }
00898 
00899                 ASSERT(nIndex!=-1);             // Values is not in the list
00900                 ASSERT(nDefIndex!=-1);  // Value in the table as default is not in the list
00901 
00902                 ListItem.Value.SetListValue(strArr,nIndex);
00903                 ListItem.DefValue.SetListValue(strArr,nDefIndex);
00904                 ListItems.Add(ListItem);
00905 
00906         }
00907 
00908         else if(strEntryType==_T("BOOLEAN_LIST"))
00909         {
00910                 CString strDefValue=(*pTableRow)[2];
00911                 CStringArray strArr;
00912                 int nDefIndex=-1, nIndex=-1;
00913 
00914                 for(int i=0;i<BOOLEAN_LIST_SIZE;i++)
00915                 {
00916                         CString strTemp=m_szBooleanList[i];
00917                         if(strTemp==strValue)
00918                         {
00919                                 nIndex=i;
00920                         }
00921 
00922                         if(strTemp==strDefValue)
00923                         {
00924                                 nDefIndex=i;
00925                         }
00926                         strArr.Add(strTemp);
00927                 }
00928                 if (nIndex < 0) {
00929                         nIndex = nDefIndex;
00930                 }
00931 
00932                 ASSERT(nIndex!=-1);             // Values is not in the list
00933                 ASSERT(nDefIndex!=-1);  // Value in the table as default is not in the list
00934 
00935                 ListItem.Value.SetListValue(strArr,nIndex);
00936                 ListItem.DefValue.SetListValue(strArr,nDefIndex);
00937                 ListItems.Add(ListItem);
00938 
00939         }
00940 
00941 
00942         else if(strEntryType==_T("ATTR_LIST"))
00943         {
00944                 if(!bIsMultiple)
00945                 {
00946 
00947                         CStringArray strArr;
00948                         CStringArray strLabelArr;
00949 
00950                         // Get default value and set it as the first element
00951                         CString strTemp=(*pTableRow)[2];
00952                         strArr.Add(_T(""));
00953                         strLabelArr.Add(strTemp);
00954                         int nDefIndex=0;
00955 
00956                         CComPtr<IMgaMetaFCO> ccpMetaFCO;
00957 
00958                         COMTHROW(ccpMgaFCO->get_Meta(&ccpMetaFCO));
00959 
00960                         CComPtr<IMgaMetaAttributes> ccpMetaAttributes;
00961                         COMTHROW(ccpMetaFCO->get_Attributes(&ccpMetaAttributes));
00962 
00963                         int nIndex=-1;
00964                         if(strValue.IsEmpty())
00965                         {
00966                                 nIndex=0;
00967                         }
00968 
00969                         int i=1;
00970                         MGACOLL_ITERATE(IMgaMetaAttribute, ccpMetaAttributes)
00971                         {
00972                                 CComBSTR bstrName;
00973                                 COMTHROW(MGACOLL_ITER->get_Name(&bstrName));
00974                                 strTemp=bstrName;
00975                                 strLabelArr.Add(strTemp);
00976 
00977                                 strTemp=_T("%") + strTemp + _T("%");
00978                                 strArr.Add(strTemp);
00979 
00980 
00981                                 if(strTemp==strValue)
00982                                 {
00983                                         nIndex=i;
00984                                 }
00985 
00986                                 i++;
00987                         }MGACOLL_ITERATE_END;
00988 
00989 //                      ASSERT(nIndex!=-1);             // Value is not among the attributes
00990                         if( nIndex < 0 )
00991                                 nIndex = 0;
00992 
00993                         ListItem.Value.SetListValue(strLabelArr,strArr,nIndex);
00994                         ListItem.DefValue.SetListValue(strLabelArr,strArr,nDefIndex);
00995                 }
00996                 ListItems.Add(ListItem);
00997         }
00998 
00999         else
01000         {
01001                 // If you created a new type in the tables, add a piece of converter code above
01002                 // for it.
01003                 ASSERT((_T("Unknown preference type has been specified in the preference tables."),0));
01004         }
01005 
01006 
01007 }
01008 
01009 
01010 
01011 
01012 TableRowType CPreference::GetTableRow(CString strCurrPath, objtype_enum oeType)
01013 {
01014         switch(oeType)
01015         {
01016                 case OBJTYPE_MODEL:
01017                         {
01018                                 int nIndex=FindRegPathInModelTable(strCurrPath);
01019                                 ASSERT(nIndex!=-1);
01020                                 return &m_szModelPreferenceTable[nIndex];
01021                         }
01022                         break;
01023 
01024                 case OBJTYPE_ATOM:
01025                         {
01026                                 int nIndex=FindRegPathInAtomTable(strCurrPath);
01027                                 ASSERT(nIndex!=-1);
01028                                 return &m_szAtomPreferenceTable[nIndex];
01029                         }
01030                         break;
01031 
01032                 case OBJTYPE_CONNECTION:
01033                         {
01034                                 int nIndex=FindRegPathInConnectionTable(strCurrPath);
01035                                 ASSERT(nIndex!=-1);
01036                                 return &m_szConnectionPreferenceTable[nIndex];
01037                         }
01038                         break;
01039 
01040                 case OBJTYPE_REFERENCE:
01041                         {
01042                                 int nIndex=FindRegPathInProxyTable(strCurrPath);
01043                                 ASSERT(nIndex!=-1);
01044                                 return &m_szProxyPreferenceTable[nIndex];
01045                         }
01046                         break;
01047 
01048                 case OBJTYPE_SET:
01049                         {
01050                                 int nIndex=FindRegPathInSetTable(strCurrPath);
01051                                 ASSERT(nIndex!=-1);
01052                                 return &m_szSetPreferenceTable[nIndex];
01053                         }
01054                         break;
01055 
01056                 default:
01057                         {
01058                                 ASSERT((_T("Invalid MGA object type found creating preference list"),FALSE));break;
01059                         }
01060         }
01061 
01062         return NULL;
01063 }
01064 
01065 void CPreference::Write2Mga(const CString& strValue,const CComPtr<IMgaFCO>& ccpMgaFCO,const CListItem& ListItem, const CString& strRegPath, bool bIsForKind)
01066 {
01067 
01068 
01069         // Converting path and value in BSTR format for MGA
01070         CComBSTR bstrPath(strRegPath);
01071         CComBSTR bstrValue(strValue);
01072 
01073 
01074         if(ListItem.bIsDefault)
01075         {
01076                 // Getting regnode
01077                 CComPtr<IMgaRegNode> ccpMgaRegNode;
01078                 COMTHROW(ccpMgaFCO->get_RegistryNode(bstrPath,&ccpMgaRegNode));
01079 
01080                 // Delete the registry entries
01081                 COMTHROW(ccpMgaRegNode->RemoveTree());
01082         }
01083         else
01084         {
01085                 if(bIsForKind)
01086                 {
01087                         // Delete current value - meta will be displayed
01088                         // Getting regnode
01089                         CComPtr<IMgaRegNode> ccpMgaRegNode;
01090                         COMTHROW(ccpMgaFCO->get_RegistryNode(bstrPath,&ccpMgaRegNode));
01091 
01092                         // Hacked by Paka in order to always do something in the project !!!
01093                         // If there is nothing in the Project (NOT the MetaProject) to be commited, then the user gets confused
01094                         // because the Project does not change and nothing has to be refreshed
01095                          COMTHROW( ccpMgaRegNode->put_Value( CComBSTR( _T("Dummy") ) ) );
01096                         // Hacked part end
01097 
01098                         // Delete the registry entries
01099                         COMTHROW(ccpMgaRegNode->RemoveTree());
01100                                 // For _T("kind") we set registry values in the meta
01101                         CComPtr<IMgaMetaFCO> ccpMetaFCO;
01102                         COMTHROW(ccpMgaFCO->get_Meta(&ccpMetaFCO));
01103 
01104                         COMTHROW(ccpMetaFCO->put_RegistryValue(bstrPath,bstrValue));
01105                 }
01106                 else
01107                 {
01108                         // For a specific object we modify the registry value
01109                         COMTHROW(ccpMgaFCO->put_RegistryValue(bstrPath,bstrValue));
01110 
01111                 }
01112         }
01113 }
01114 
01115 
01116 void CPreference::ListValue2MgaValue(const CListItem& ListItem, CString& strValue)
01117 {
01118 
01119         switch(ListItem.Value.dataType)
01120         {
01121                 case ITEMDATA_COLOR     :
01122                 {
01123                         strValue.Format(_T("0x%02x%02x%02x"),
01124                                                         GetRValue(ListItem.Value.colorVal),
01125                                                         GetGValue(ListItem.Value.colorVal),
01126                                                         GetBValue(ListItem.Value.colorVal));
01127                 }break;
01128 
01129                 case ITEMDATA_COMPASS_EXCL:
01130                 {
01131                         CCompassData::toMgaStringOption(strValue,ListItem.Value.compassVal);
01132                 }break;
01133 
01134                 case ITEMDATA_COMPASS:
01135                 {
01136                         strValue=ListItem.Value.stringVal[0];
01137                 }break;
01138 
01139                 case ITEMDATA_FIXED_LIST:
01140                 {
01141                         if (ListItem.Value.stringListNames.GetSize() > 0) {
01142                                 strValue=ListItem.Value.stringListNames.GetAt(ListItem.Value.listVal);
01143                         }
01144                         else {
01145                                 ListItem.Value.toString(strValue);
01146                         }
01147                 }break;
01148 
01149                 default:
01150                 {
01151                         ListItem.Value.toString(strValue);
01152                 }break;
01153         }
01154 }
01155 
01156 void CPreference::WriteItemToMga(CListItem ListItem,const CMgaFCOPtrList& MgaFCOPtrList, bool bIsForKind)
01157 {
01158         if(ListItem.bIsContainer)return;
01159 
01160         CString strValue;
01161         ListValue2MgaValue(ListItem,strValue);
01162 
01163         CString strRegPath=m_strRegPathList.GetAt((POSITION)ListItem.dwKeyValue);
01164 
01165         POSITION pos=MgaFCOPtrList.GetHeadPosition();
01166 
01167         while(pos)
01168         {
01169                 CComPtr<IMgaFCO> ccpMgaFCO=MgaFCOPtrList.GetNext(pos);
01170 
01171                 Write2Mga(strValue,ccpMgaFCO,ListItem,strRegPath,bIsForKind);
01172 
01173 
01174         }
01175 }
01176 
01177 void CPreference::IssuePossiblePathConversion(CListItem ListItem, const CMgaFCOPtrList& MgaFCOPtrList,
01178                                                                                           CObjectInspectorCtrl* pParent)
01179 {
01180         if (ListItem.bIsContainer)
01181                 return;
01182 
01183         CString strValue;
01184         ListValue2MgaValue(ListItem,strValue);
01185 
01186         POSITION pos = MgaFCOPtrList.GetHeadPosition();
01187 
01188         while(pos)
01189         {
01190                 CComPtr<IMgaFCO> ccpMgaFCO = MgaFCOPtrList.GetNext(pos);
01191 
01192                 // Firing the event
01193                 if ((ListItem.dwUserData == AUTOROUTER_STATE_CONN ||
01194                          ListItem.dwUserData == AUTOROUTER_STATE_MODEL) &&
01195                          strValue == _T("false"))
01196                 {
01197                         if (ListItem.dwUserData == AUTOROUTER_STATE_CONN)
01198                                 pParent->IgnoreNextEvents();
01199                         pParent->FireConvertPathToCustom(ccpMgaFCO);
01200                 }
01201         }
01202 }