2 * @file DirViewColItems.h
4 * @brief Declaration file for DirColInfo
6 * @date Created: 2003-08-19
8 // RCS ID line follows -- this is updated by CVS
9 // $Id: DirViewColItems.h 4619 2007-10-14 08:50:20Z jtuc $
11 #ifndef DirViewColItems_h
12 #define DirViewColItems_h
14 #include "UnicodeString.h"
22 // DirViewColItems typedefs
23 typedef String (*ColGetFncPtrType)(const CDiffContext *, const void *);
24 typedef int (*ColSortFncPtrType)(const CDiffContext *, const void *, const void *);
28 * @brief Information about one column of dirview list info
34 ALIGN_LEFT = 0, // LVCFMT_LEFT
35 ALIGN_RIGHT = 1, // LVCFMT_RIGHT
36 ALIGN_CENTER = 2 // LVCFMT_CENTER
38 const TCHAR *regName; /**< Internal name used for registry entries etc */
39 // localized string resources
40 const char *idName; /**< Displayed name, ID of string resource */
41 const char *idDesc; /**< Description, ID of string resource */
42 ColGetFncPtrType getfnc; /**< Handler giving display string */
43 ColSortFncPtrType sortfnc; /**< Handler for sorting this column */
45 int physicalIndex; /**< Current physical index, -1 if not displayed */
46 bool defSortUp; /**< Does column start with ascending sort (most do) */
47 int alignment; /**< Column alignment */
50 extern const int g_ncols;
51 extern const int g_ncols3;
56 DirViewColItems(int nDirs):
57 m_nDirs(nDirs), m_numcols(-1), m_dispcols(-1) {}
58 String GetColRegValueNameBase(int col) const;
59 int GetColDefaultOrder(int col) const;
60 const DirColInfo * GetDirColInfo(int col) const;
61 bool IsColById(int col, const char *idname) const;
62 bool IsColName(int col) const;
63 bool IsColLmTime(int col) const;
64 bool IsColMmTime(int col) const;
65 bool IsColRmTime(int col) const;
66 bool IsColStatus(int col) const;
67 bool IsColStatusAbbr(int col) const;
68 bool IsDefaultSortAscending(int col) const;
69 String GetColDisplayName(int col) const;
70 String GetColDescription(int col) const;
71 int GetColCount() const;
72 int GetDispColCount() const { return m_dispcols; }
73 String ColGetTextToDisplay(const CDiffContext *pCtxt, int col, const DIFFITEM & di) const;
74 int ColSort(const CDiffContext *pCtxt, int col, const DIFFITEM & ldi, const DIFFITEM &rdi, bool bTreeMode) const;
76 int ColPhysToLog(int i) const { return m_invcolorder[i]; }
77 int ColLogToPhys(int i) const { return m_colorder[i]; } /**< -1 if not displayed */
78 void ClearColumnOrders();
79 void MoveColumn(int psrc, int pdest);
80 void ResetColumnOrdering();
81 void SetColumnOrdering(const int colorder[]);
82 void ValidateColumnOrdering();
83 String ResetColumnWidths(int defcolwidth);
84 void LoadColumnOrders(String colorders);
85 String SaveColumnOrders();
87 /// Update all column widths (from registry to screen)
88 // Necessary when user reorders columns
89 template<class SetColumnWidthFunc>
90 void LoadColumnWidths(String colwidths, SetColumnWidthFunc setcolwidth, int defcolwidth)
92 std::basic_istringstream<TCHAR> ss(colwidths);
93 for (int i = 0; i < m_numcols; ++i)
95 int phy = ColLogToPhys(i);
100 setcolwidth(phy, max(w, 10));
105 /** @brief store current column widths into registry */
106 template<class GetColumnWidthFunc>
107 String SaveColumnWidths(GetColumnWidthFunc getcolwidth)
110 for (int i = 0; i < m_numcols; i++)
112 int phy = ColLogToPhys(i);
115 if (!result.empty()) result += ' ';
116 result += string_to_str(getcolwidth(phy));
127 std::vector<int> m_colorder; /**< colorder[logical#]=physical# */
128 std::vector<int> m_invcolorder; /**< invcolorder[physical]=logical# */
131 #endif // DirViewColItems_h