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