aknlayoutcompiler/inc/MLCompData.h
changeset 0 f58d6ec98e88
child 1 b700e12870ca
equal deleted inserted replaced
-1:000000000000 0:f58d6ec98e88
       
     1 /*
       
     2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef MLCOMPDATA_H
       
    20 #define MLCOMPDATA_H
       
    21 
       
    22 // disable "identifier was truncated to '255' characters in the browser information" warning
       
    23 #pragma warning (disable:4786)
       
    24 
       
    25 // disable "decorated name length exceeded, name was truncated"
       
    26 #pragma warning (disable:4503)
       
    27 
       
    28 #include "MLAttributes.h"
       
    29 
       
    30 #include <vector>
       
    31 #include <string>
       
    32 #include <iosfwd>
       
    33 #include <map>
       
    34 
       
    35 using namespace std;
       
    36 
       
    37 class TMLCompDataLine;
       
    38 class TMLCompDataTable;
       
    39 class TMLCompData;
       
    40 class TMLAttributes;
       
    41 
       
    42 extern const string KCompDataPaneOutputOrder[];
       
    43 extern const string KCompDataPaneOutputOrderMirrored[];
       
    44 extern const string KCompDataGraphicOutputOrder[];
       
    45 extern const string KCompDataGraphicOutputOrderMirrored[];
       
    46 extern const string KCompDataTextOutputOrder[];
       
    47 extern const string KCompDataTextOutputOrderMirrored[];
       
    48 extern const int KCompDataPaneOutputOrderSize;
       
    49 extern const int KCompDataGraphicOutputOrderSize;
       
    50 extern const int KCompDataTextOutputOrderSize;
       
    51 /**
       
    52 *  TMLCompDataCalcs
       
    53 *  The calcs stored in a value
       
    54 */
       
    55 typedef map<int, string> TMLCompDataCalcs;
       
    56 typedef map<int, TMLCompDataCalcs> TMLCompDataZoomLevels;
       
    57 typedef map<int, TMLCompDataZoomLevels> TMLCompDataVarieties;
       
    58 
       
    59 /**
       
    60 *  TMLCompDataValues 
       
    61 *  The values stored in a cell in a layout line
       
    62 */
       
    63 class TMLCompDataValues : public TMLCompDataVarieties
       
    64 	{
       
    65 public:
       
    66 	enum TCompDataCellType
       
    67 		{
       
    68 		ECellTypeDefault,
       
    69 		ECellTypeParamLimit,
       
    70 		ECellTypeCol,
       
    71 		ECellTypeRow
       
    72 		};
       
    73 
       
    74 public: // constructors, operators, etc
       
    75 	TMLCompDataValues();
       
    76 	TMLCompDataValues(TMLCompDataLine* aLine);
       
    77 	virtual ~TMLCompDataValues();
       
    78 	bool operator==(const TMLCompDataValues& aOther) const;
       
    79 
       
    80 public: // new methods
       
    81     bool Merge(TMLCompDataLine* aLine, string aName, TMLCompDataValues& aOtherValues, bool aMirrorMerge);
       
    82 	void Compile(const string& aCellName);
       
    83 	static string CppValue(const string& aValue);
       
    84 	static string MirrorJustificationValue(const string& aValue);
       
    85 	static TCompDataCellType Type(string aName); 
       
    86 
       
    87 public: // member data
       
    88 	TMLCompDataLine* iLine; // not owned
       
    89 	string iName;
       
    90 	};
       
    91 
       
    92 
       
    93 //
       
    94 // Parent Info
       
    95 //
       
    96 
       
    97 /**
       
    98 *  TMLCompDataParentInfoSelector
       
    99 *
       
   100 *  The parent id and parent variety index for each variety index
       
   101 */
       
   102 struct TMLCompDataParentInfoSelector
       
   103 	{
       
   104 public:
       
   105 	TMLCompDataParentInfoSelector();
       
   106 	TMLCompDataParentInfoSelector(int aParentId, int aParentVariety);
       
   107 public:
       
   108 	int iParentId;
       
   109 	int iParentVariety;
       
   110 	};
       
   111 
       
   112 typedef map<int, TMLCompDataParentInfoSelector> TMLCompDataParentInfoVarieties;
       
   113 
       
   114 /**
       
   115 *  TMLCompDataParentInfo
       
   116 *
       
   117 *  Contains the parent info selector for each variety index
       
   118 */
       
   119 class TMLCompDataParentInfo : public TMLCompDataParentInfoVarieties
       
   120 	{
       
   121 public: // constructors etc
       
   122 	TMLCompDataParentInfo();
       
   123 	TMLCompDataParentInfo(TMLCompDataLine* aLine);
       
   124 	virtual ~TMLCompDataParentInfo();
       
   125 public: // new methods
       
   126 	void Merge(const TMLCompDataParentInfo& aOther);
       
   127 public: // member data
       
   128 	TMLCompDataLine* iLine; // not owned
       
   129 	};
       
   130 
       
   131 class TMLCompDataAttributeInfo;
       
   132 
       
   133 /**
       
   134 *  TMLCompDataLine 
       
   135 *  A layout line
       
   136 */
       
   137 class TMLCompDataLine : public map<string, TMLCompDataValues>
       
   138 	{
       
   139 public:
       
   140 	enum TComponentType 
       
   141 		{ 
       
   142 		EUnknownComponent, 
       
   143 		EScreenComponent, 
       
   144 		EContainerComponent, 
       
   145 		EPaneComponent, 
       
   146 		EGraphicComponent, 
       
   147 		ETextComponent 
       
   148 		};
       
   149 
       
   150 public: // constructors etc
       
   151 	TMLCompDataLine();
       
   152 	TMLCompDataLine(const TMLCompDataLine& aOther);
       
   153 	virtual ~TMLCompDataLine();
       
   154 
       
   155 	bool operator==(const TMLCompDataLine& aOther) const;
       
   156 	static bool lessthan(TMLCompDataLine* aLeft, TMLCompDataLine* aRight);
       
   157 	bool ValuesEqual(const TMLCompDataLine& aOther) const;
       
   158 
       
   159 public: // new methods
       
   160 	bool Merge(TMLCompDataLine& aOther);
       
   161 	void Compile();
       
   162 	TMLAttributeZoomLevels* GetAttributeZoomLevels(string aAttribName, int aVariety);
       
   163 
       
   164 public: // get and set methods
       
   165 	string Name() const;					
       
   166 	bool NeedsParams() const;
       
   167 	bool NeedsOptions() const;
       
   168 	bool NeedsCols() const;
       
   169 	bool NeedsRows() const;
       
   170 	int MaxVariety() const;
       
   171 	int NumCols() const;
       
   172 	int NumRows() const;
       
   173 	void SetMaxVariety(int aMaxVariety);
       
   174 	void SetNumCols(int aNumCols);
       
   175 	void SetNumRows(int aNumRows);
       
   176 	void SetNeedsCols(bool aNeeds);
       
   177 	void SetNeedsRows(bool aNeeds);
       
   178 
       
   179 public: // helpers
       
   180 	int EncodeFontId(int aHeight, int aOutline, int aPosture, int aWeight, int aCategory) const;
       
   181 	bool MatchParams(const TMLCompDataLine& aLine) const;
       
   182 	bool MatchNameDiscountingSuffix(const TMLCompDataLine& aLine) const;
       
   183 	bool MatchType(const TMLCompDataLine& aLine) const;
       
   184 	string NameDiscountingSuffix() const;
       
   185 	string NameSuffix() const;
       
   186 
       
   187 private: // helpers
       
   188 	TMLAttributeZoomLevels* GetParentAttributeZoomLevels(string aAttribSetName, int aAttribId, int aVariety);
       
   189 	TMLAttributeZoomLevels* FindAttributeZoomLevels(string aAttribSetName, int aAttribId);
       
   190 	void CompileParamLimits(TMLCompDataValues::TCompDataCellType aParamLimitType, const string& aParamLimitCellName);
       
   191 	void CompileFontHeights();
       
   192 
       
   193 
       
   194 public: // member data
       
   195 	int iId;
       
   196 	string iName;
       
   197 	TComponentType iType;
       
   198 	int iDrawingOrder;
       
   199 	int iMaxVariety;
       
   200 	TMLCompDataTable* iParentTable;
       
   201 	TMLCompDataParentInfo* iParentInfo;// owned
       
   202 	TMLCompDataAttributeInfo* iAttributeInfo;// owned
       
   203 	bool iIsUnique;
       
   204 	int iGlobalIndex;
       
   205 	bool iIsMirroredHorizontally; // i.e. l and r are swapped
       
   206 	bool iNeedsOptions; // note that can need options although numOptions is only 1, as may be needed for subtable
       
   207 	bool iNeedsCols;
       
   208 	bool iNeedsRows;
       
   209 
       
   210 private:
       
   211 	int iNumCols; // there is always at least one column
       
   212 	int iNumRows; // there is always at least one row
       
   213 	};
       
   214 
       
   215 
       
   216 //
       
   217 // Attribute Info
       
   218 //
       
   219 
       
   220 /**
       
   221 *  TMLCompDataAttributeInfoSelector
       
   222 *
       
   223 *  Contains the attribute set name, which is used to 
       
   224 *  disambiguate the attribute data for a given component
       
   225 */
       
   226 struct TMLCompDataAttributeInfoSelector
       
   227 	{
       
   228 public:
       
   229 	TMLCompDataAttributeInfoSelector();
       
   230 	TMLCompDataAttributeInfoSelector(string aAttributeSetName);
       
   231 public:
       
   232 	string iAttributeSetName;
       
   233 	};
       
   234 
       
   235 typedef map<int, TMLCompDataAttributeInfoSelector> TMLCompDataAttributeInfoVarieties;
       
   236 
       
   237 /**
       
   238 *  TMLCompDataAttributeInfo
       
   239 *
       
   240 *  Contains the attribute info selector for each variety
       
   241 */
       
   242 class TMLCompDataAttributeInfo : public TMLCompDataAttributeInfoVarieties
       
   243 	{
       
   244 public: // constructors etc
       
   245 	TMLCompDataAttributeInfo();
       
   246 	TMLCompDataAttributeInfo(TMLCompDataLine* aLine);
       
   247 	virtual ~TMLCompDataAttributeInfo();
       
   248 public: // new methods
       
   249 	void Merge(const TMLCompDataAttributeInfo& aOther);
       
   250 public: // member data
       
   251 	TMLCompDataLine* iLine; // not owned
       
   252 	};
       
   253 
       
   254 
       
   255 
       
   256 /**
       
   257 *  TMLCompDataTable 
       
   258 *  A layout table
       
   259 */
       
   260 class TMLCompDataTable : public vector<TMLCompDataLine*>
       
   261 	{
       
   262 public:
       
   263 	/*
       
   264 	 * Subtables are automatically generated for contiguous collections 
       
   265 	 * of components whose names are the same, ending in _g or _t 
       
   266 	 * followed by a number. These components represent numbered
       
   267 	 * rendered objects in the specification, and often need to be 
       
   268 	 * indexed by clients of the scalable layout API.
       
   269 	 * 
       
   270 	 */
       
   271 	class TMLCompDataSubTable : public vector<int>
       
   272 		{
       
   273 	public:
       
   274 		TMLCompDataSubTable();
       
   275 		bool NeedsParams() const;
       
   276 	public:
       
   277 		bool iNeedsOption;
       
   278 		bool iNeedsCol;
       
   279 		bool iNeedsRow;
       
   280 		string iName;
       
   281 		};
       
   282 	typedef vector<TMLCompDataSubTable*> TMLCompDataSubTables;
       
   283 
       
   284 public: // constructors etc
       
   285 	TMLCompDataTable(TMLCompData* aTables);
       
   286 	TMLCompDataTable(TMLCompData* aTables, const TMLCompDataTable& aOther);
       
   287 	virtual ~TMLCompDataTable();
       
   288 	static bool lessthan(TMLCompDataTable* aLeft, TMLCompDataTable* aRight);
       
   289 
       
   290 public: // new methods
       
   291 	TMLCompDataSubTable* FindSubTable(const string& aName);
       
   292 	TMLCompDataLine* FindLine(const string& aName);
       
   293     void Merge(TMLCompDataTable& aOther);
       
   294 	void Compile();
       
   295 	void BuildSubTables();
       
   296 	void NormalizeSubTables();
       
   297 	void DestroySubTables();
       
   298 	void SetDefaultColumnNames();
       
   299 
       
   300 public: // accessors
       
   301 	string Name();
       
   302 	static bool IsValueColumn(string aName);
       
   303 	static bool IsNumericColumn(string aName);
       
   304 	static bool IsHorizontalColumn(string aName);
       
   305 	static bool IsVerticalColumn(string aName);
       
   306 
       
   307 public: // member data
       
   308 	int iId;
       
   309 	string iName;
       
   310 	TMLCompData* iTables;
       
   311 	TMLCompDataSubTables iSubTables;
       
   312 	vector<string> iColumnNames;
       
   313 	TMLCompDataLine* iParentLine; // not owned
       
   314 	string iParentName;
       
   315 	bool iNeedsP;
       
   316 	bool iNeedsIndex;
       
   317 	bool iAppend;
       
   318 	int iFirstLineGlobalIndex;
       
   319 	};
       
   320 
       
   321 /**
       
   322 *  TMLCompData 
       
   323 *  The core layout class - this represents a complete layout, 
       
   324 *  typically loaded from a .xml file that has been exported from the 
       
   325 * layout creation tool
       
   326 */
       
   327 class TMLCompData : public vector<TMLCompDataTable*>
       
   328 	{
       
   329 public:
       
   330 	typedef map<int, TMLCompDataLine*> TMLComponents;
       
   331 
       
   332 public: // constructors
       
   333 	TMLCompData();
       
   334 	TMLCompData(const TMLCompData& aOther);
       
   335 	TMLCompData& operator=(const TMLCompData& aOther);
       
   336 
       
   337 public: // new methods
       
   338 	virtual ~TMLCompData();
       
   339 	TMLCompDataLine* FindComponent(const string& aName) const;
       
   340 	TMLCompDataLine* FindLine(const string& aName) const;
       
   341 	TMLCompDataTable* FindTable(int aId) const;
       
   342 	TMLCompDataTable* FindTable(const string& aName) const;
       
   343 	TMLCompDataTable::TMLCompDataSubTable* FindSubTable(const string& aName) const;
       
   344 	void Merge(TMLCompData& aOther);
       
   345 	void MergeComponents(TMLCompData& aOther);
       
   346 	void Compile();
       
   347 	void CreateTables();
       
   348 	void DeleteComponents();
       
   349 
       
   350 public: // member data
       
   351 	string iName;
       
   352 	bool iCanBeMirror;
       
   353 	string iMasterName;
       
   354 	string iLayoutName;
       
   355 	string iVariantName;
       
   356 	string iResolutionHeight;
       
   357 	string iResolutionWidth;
       
   358 	string iTimestamp;
       
   359 	TMLComponents iComponents; // this is used to accumulate the lines, which are then compiled into tables
       
   360 	bool iIsBaseInstance;
       
   361 	TMLAttributes* iAttributes; // owned
       
   362 	};
       
   363 
       
   364 
       
   365 #endif
       
   366 
       
   367 // End of File