aknlayoutcompiler/inc/Layout.h
changeset 0 f58d6ec98e88
equal deleted inserted replaced
-1:000000000000 0:f58d6ec98e88
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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 
       
    20 #ifndef LAYOUT_H
       
    21 #define LAYOUT_H
       
    22 
       
    23 // disable "identifier was truncated to '255' characters in the browser information" warning
       
    24 #pragma warning (disable:4786)
       
    25 #include <vector>
       
    26 #include <string>
       
    27 #include <iosfwd>
       
    28 #include <map>
       
    29 
       
    30 using namespace std;
       
    31 
       
    32 class TLayoutLine;
       
    33 class TLayoutTable;
       
    34 class TLayout;
       
    35 
       
    36 extern const string KWindowOutputOrder[];
       
    37 extern const string KTextOutputOrder[];
       
    38 extern const string KWindowOutputOrderMirrored[];
       
    39 extern const string KTextOutputOrderMirrored[];
       
    40 extern const int KWindowOutputOrderSize;
       
    41 extern const int KTextOutputOrderSize;
       
    42 
       
    43 
       
    44 /**
       
    45 *  TLayout 
       
    46 *  The core layout class - this represents a complete layout, 
       
    47 *  typically loaded from a .lay file
       
    48 */
       
    49 class TLayout : public vector<TLayoutTable*>
       
    50 	{
       
    51 public:
       
    52 	enum TMergeMode	{ KMergeModeMerge, KMergeModeVariant, KMergeModeUnion };
       
    53 
       
    54 public:
       
    55 	TLayout();
       
    56 	TLayout(const TLayout& aOther);
       
    57 	TLayout& operator=(const TLayout& aOther);
       
    58 
       
    59 	virtual ~TLayout();
       
    60 	void Merge(TLayout::TMergeMode aMergeMode, TLayout& aLayout);
       
    61 	TLayoutLine* FindLine(const string& aName);
       
    62 	void Compile();
       
    63 
       
    64 public:
       
    65 	string iName;
       
    66 	bool iCanBeMirror;
       
    67 	};
       
    68 
       
    69 
       
    70 /**
       
    71 *  TValues 
       
    72 *  The values stored in a cell in a layout line
       
    73 */
       
    74 class TValues : public vector<string>
       
    75 	{
       
    76 // This class is generic with respect to the type of line it is used by
       
    77 public:
       
    78 	TValues();
       
    79 	TValues(TLayoutLine* aLine, string aName);
       
    80 
       
    81 	bool operator==(const TValues& aOther) const;
       
    82 
       
    83 	void Merge(TValues& aValues);
       
    84 	void Compile();
       
    85 	string ParamName() const;
       
    86 	static string CppValue(const string& aValue);
       
    87 
       
    88 public:
       
    89 	TLayoutLine* iLine;
       
    90 	string iName;
       
    91 	string iParam;
       
    92 	bool iNeedsP;
       
    93 	bool iNeedsIndex;
       
    94 	};
       
    95 
       
    96 
       
    97 /**
       
    98 *  TLayoutLine 
       
    99 *  A layout line
       
   100 */
       
   101 class TLayoutLine : public map<string, TValues>
       
   102 	{
       
   103 public:
       
   104 	TLayoutLine(TLayoutTable* aTable, int aId);
       
   105 	TLayoutLine(TLayoutTable* aTable, const TLayoutLine& aOther);
       
   106 
       
   107 	bool operator==(const TLayoutLine& aOther) const;
       
   108 	bool ValuesEqual(const TLayoutLine& aOther) const;
       
   109 
       
   110 	void Merge(TLayout::TMergeMode aMergeMode, TLayoutLine& aLine);
       
   111 	void Compile();
       
   112 	string Name() const;					
       
   113 	string TableName() const;
       
   114 	bool MatchParams(const TLayoutLine& aLine) const;
       
   115 	bool NeedsParams() const { return iNeedsP || iNeedsIndex; }
       
   116 
       
   117 	void WarnMergeMismatch(TLayoutLine& aLine);
       
   118 
       
   119 public:
       
   120 	int iId;
       
   121 	TLayoutTable* iTable;
       
   122 	bool iNeedsP;
       
   123 	bool iNeedsIndex;
       
   124 	bool iIsUnique;
       
   125 	int iGlobalIndex;
       
   126 	bool iIsMirroredHorizontally; // i.e. l and r are swapped
       
   127 	bool iIsMergedIdentical;
       
   128 	};
       
   129 
       
   130 
       
   131 /**
       
   132 *  TLayoutTable 
       
   133 *  A layout table
       
   134 */
       
   135 class TLayoutTable : public vector<TLayoutLine*>
       
   136 	{
       
   137 public:
       
   138 	enum TTableType { EUnknownTable, EWindowTable, ETextTable };
       
   139 	class TLayoutSubTable : public vector<int>
       
   140 		{
       
   141 	public:
       
   142 		TLayoutSubTable();
       
   143 		bool iIsMergedIdentical;
       
   144 		};
       
   145 	typedef vector<TLayoutSubTable*> TLayoutSubTables;
       
   146 
       
   147 public:
       
   148 	TLayoutTable(TLayout* aTables);
       
   149 	TLayoutTable(TLayout* aTables, const TLayoutTable& aOther);
       
   150 	virtual ~TLayoutTable();
       
   151 
       
   152 	void Merge(TLayout::TMergeMode aMergeMode, TLayoutTable& aTable);
       
   153 	TLayoutLine* FindLine(const string& aName);
       
   154 	void Compile();
       
   155 	void BuildSubTables();
       
   156 	void DestroySubTables();
       
   157 	string Name();
       
   158 	static bool IsValueColumn(string aName);
       
   159 	static bool IsNumericColumn(string aName);
       
   160 	void SetDefaultColumnNames();
       
   161 	bool IsWorthATableIndex();
       
   162 
       
   163 public:
       
   164 	TLayoutSubTables iSubTables;
       
   165 	vector<string> iColumnNames;
       
   166 	TTableType iType;
       
   167 	TLayout* iTables;
       
   168 	string iName;
       
   169 	TLayoutLine* iParent;
       
   170 	string iParentName;
       
   171 	bool iNeedsP;
       
   172 	bool iNeedsIndex;
       
   173 	int iFirstLineGlobalIndex;
       
   174 	bool iAppend;
       
   175 	bool iNoSubTables;
       
   176 	};
       
   177 
       
   178 
       
   179 #endif
       
   180 
       
   181 // End of File