| 1 |
#ifndef PROPERTY_H |
| 2 |
#define PROPERTY_H |
| 3 |
|
| 4 |
#include <commctrl.h> |
| 5 |
|
| 6 |
#define MAX_DATEFORMAT_LEN 256 |
| 7 |
|
| 8 |
//////////////////////////////////// |
| 9 |
// property index |
| 10 |
//////////////////////////////////// |
| 11 |
|
| 12 |
#define PROP_N_PASSTIMEOUT 0 |
| 13 |
#define PROP_N_DETAILSVIEW_KEEPCARET 1 |
| 14 |
#define PROP_NDETAILSVIEW_TABSTOP 2 |
| 15 |
#define PROP_N_SELECTVIEW_FONTSIZE 3 |
| 16 |
#define PROP_N_SELECTVIEW_FONTQUALITY 4 |
| 17 |
#define PROP_N_DETAILSVIEW_FONTSIZE 5 |
| 18 |
#define PROP_N_DETAILSVIEW_FONTQUALITY 6 |
| 19 |
#define PROP_N_AUTOSELECT_MODE 7 |
| 20 |
#define PROP_N_SINGLECLICK_MODE 8 |
| 21 |
#define PROP_N_USE_TWO_PANE 9 |
| 22 |
#define PROP_N_SWITCH_WINDOW_TITLE 10 |
| 23 |
#define PROP_N_KEEP_TITLE 11 |
| 24 |
#define PROP_N_APP_BUTTON1 12 |
| 25 |
#define PROP_N_APP_BUTTON2 13 |
| 26 |
#define PROP_N_APP_BUTTON3 14 |
| 27 |
#define PROP_N_APP_BUTTON4 15 |
| 28 |
#define PROP_N_APP_BUTTON5 16 |
| 29 |
#define PROP_N_CODEPAGE 17 |
| 30 |
#define PROP_N_DISABLEEXTRAACTIONBUTTON 18 // PKTPC |
| 31 |
#define PROP_N_SIPSIZE_DELTA 19 // PKTPC |
| 32 |
#define PROP_N_HIDESTATUSBAR 20 // HPC, WIN32 |
| 33 |
#define PROP_N_STAYTOPMOST 21 // WIN32 |
| 34 |
#define PROP_N_HIDEREBAR 22 // WIN32 |
| 35 |
#define PROP_N_WRAPTEXT 23 |
| 36 |
#define PROP_N_OPENREADONLY 24 |
| 37 |
#define PROP_N_DISABLESAVEDLG 25 |
| 38 |
#define PROP_N_USEASSOC 26 |
| 39 |
#define PROP_N_SAFEFILENAME 27 |
| 40 |
#define PROP_N_TOMBO_WINSIZE3 28 // PKTPCVGA |
| 41 |
#define PROP_N_KEEP_LAST_OPEN 29 |
| 42 |
#define PROP_N_USE_YAE 30 |
| 43 |
#define PROP_N_DISABLE_YAE 31 |
| 44 |
|
| 45 |
#define NUM_PROPS_NUM 32 |
| 46 |
|
| 47 |
#define PROP_S_TOPDIR 0 |
| 48 |
#define PROP_S_SELECTVIEW_FONTNAME 1 |
| 49 |
#define PROP_S_DETAILSVIEW_FONTNAME 2 |
| 50 |
#define PROP_S_DETAILSVIEW_DATEFORMAT1 3 |
| 51 |
#define PROP_S_DETAILSVIEW_DATEFORMAT2 4 |
| 52 |
#define PROP_S_DEFAULTNOTE 5 |
| 53 |
#define PROP_S_EXTAPP1 6 |
| 54 |
#define PROP_S_EXTAPP2 7 |
| 55 |
#define PROP_S_WINSIZE 8 |
| 56 |
#define PROP_S_LAST_OPEN_URI 9 |
| 57 |
|
| 58 |
#define NUM_PROPS_STR 10 |
| 59 |
|
| 60 |
// file encoding related defs |
| 61 |
#define TOMBO_CP_DEFAULT 0 |
| 62 |
#define TOMBO_CP_UTF16LE 1200 // UTF-16LE |
| 63 |
#define TOMBO_CP_UTF8 65001 // UTF-8 |
| 64 |
#define TOMBO_CP_GREEK 1253 // Greek |
| 65 |
|
| 66 |
//////////////////////////////////// |
| 67 |
// accessor generation macros |
| 68 |
//////////////////////////////////// |
| 69 |
|
| 70 |
#define STR_ACCESSOR(NAME, ATTR) \ |
| 71 |
LPCTSTR Get##NAME##() { return pPropsStr[ATTR]; }\ |
| 72 |
BOOL Set##NAME##(LPCTSTR pDir) { return SetStringProperty(ATTR, pDir); } |
| 73 |
|
| 74 |
#define NUM_ACCESSOR(NAME, ATTR) \ |
| 75 |
DWORD Get##NAME##() { return nPropsNum[ATTR]; }\ |
| 76 |
void Set##NAME##(DWORD n) { nPropsNum[ATTR] = n; } |
| 77 |
|
| 78 |
#define NUM_ACCESSOR_DECL(NAME) \ |
| 79 |
DWORD Get##NAME##();\ |
| 80 |
void Set##NAME##(DWORD n); |
| 81 |
|
| 82 |
class File; |
| 83 |
class TomboURI; |
| 84 |
class RepositoryImpl; |
| 85 |
class LocalFileRepository; |
| 86 |
|
| 87 |
//////////////////////////////////// |
| 88 |
// Property data |
| 89 |
//////////////////////////////////// |
| 90 |
|
| 91 |
class Property { |
| 92 |
|
| 93 |
// internal status |
| 94 |
BOOL bLoad; |
| 95 |
BOOL bNeedAsk; |
| 96 |
|
| 97 |
// persistent props |
| 98 |
DWORD nPropsNum[NUM_PROPS_NUM]; |
| 99 |
LPTSTR pPropsStr[NUM_PROPS_STR]; |
| 100 |
|
| 101 |
LPTSTR pBookMark; |
| 102 |
LPTSTR pSearchHistory; |
| 103 |
LPTSTR pTopDirHistory; |
| 104 |
|
| 105 |
#if defined(PLATFORM_HPC) |
| 106 |
LPCOMMANDBANDSRESTOREINFO pCmdBarInfo; |
| 107 |
#endif |
| 108 |
|
| 109 |
// not persistent props |
| 110 |
LPTSTR pCmdlineAssignedTopDir; |
| 111 |
|
| 112 |
// internal helper funcs |
| 113 |
BOOL SetStringProperty(DWORD nPropId, LPCTSTR pValue); |
| 114 |
|
| 115 |
BOOL SaveToFile(File *pFile); |
| 116 |
BOOL LoadFromReg(BOOL *pStrict); |
| 117 |
BOOL LoadProperties(); |
| 118 |
BOOL LoadDefaultProperties(); |
| 119 |
|
| 120 |
RepositoryImpl **pRepos; |
| 121 |
LocalFileRepository *pDefaultRep; |
| 122 |
DWORD nNumRepos; |
| 123 |
|
| 124 |
public: |
| 125 |
Property(); |
| 126 |
~Property(); |
| 127 |
|
| 128 |
///////////////////////////////// |
| 129 |
// set default props |
| 130 |
|
| 131 |
BOOL SetDefaultROMode(BOOL) {return TRUE; } |
| 132 |
BOOL SetCmdLineAssignedTomboRoot(LPCTSTR p, DWORD nLen); |
| 133 |
|
| 134 |
///////////////////////////////// |
| 135 |
// accessor |
| 136 |
|
| 137 |
// Repository related |
| 138 |
DWORD GetNumSubRepository() { return nNumRepos; } |
| 139 |
// Clone RepsitoryImpl and return it |
| 140 |
RepositoryImpl *GetSubRepository(DWORD nIndex); |
| 141 |
|
| 142 |
// startup related |
| 143 |
|
| 144 |
STR_ACCESSOR(TopDir, PROP_S_TOPDIR) // TOMBO root directory |
| 145 |
// GetTomboRoot |
| 146 |
LPCTSTR GetTomboRoot(); |
| 147 |
|
| 148 |
NUM_ACCESSOR_DECL(KeepCaret) // whether keep caret position or not |
| 149 |
NUM_ACCESSOR_DECL(UseSafeFileName) // change crypted file name random |
| 150 |
NUM_ACCESSOR_DECL(KeepTitle) // keep file name even if headline has changed |
| 151 |
|
| 152 |
STR_ACCESSOR(LastOpenURI, PROP_S_LAST_OPEN_URI) // notes store folder |
| 153 |
NUM_ACCESSOR(KeepLastOpen, PROP_N_KEEP_LAST_OPEN) // when starting, the note last open is opened. |
| 154 |
STR_ACCESSOR(DefaultNote, PROP_S_DEFAULTNOTE) // use this uri when starting tombo |
| 155 |
|
| 156 |
// font related |
| 157 |
STR_ACCESSOR(SelectViewFontName, PROP_S_SELECTVIEW_FONTNAME) |
| 158 |
NUM_ACCESSOR(SelectViewFontSize, PROP_N_SELECTVIEW_FONTSIZE) // selectview font size |
| 159 |
NUM_ACCESSOR(SelectViewFontQuality, PROP_N_SELECTVIEW_FONTQUALITY) // do use selectview ClearType font? |
| 160 |
STR_ACCESSOR(DetailsViewFontName, PROP_S_DETAILSVIEW_FONTNAME) |
| 161 |
NUM_ACCESSOR(DetailsViewFontSize, PROP_N_DETAILSVIEW_FONTSIZE) // editview font size |
| 162 |
NUM_ACCESSOR(DetailsViewFontQuality, PROP_N_DETAILSVIEW_FONTQUALITY) // do use editview ClearType font? |
| 163 |
HFONT SelectViewFont(); |
| 164 |
HFONT DetailsViewFont(); |
| 165 |
|
| 166 |
// editview related |
| 167 |
STR_ACCESSOR(DateFormat1, PROP_S_DETAILSVIEW_DATEFORMAT1) |
| 168 |
STR_ACCESSOR(DateFormat2, PROP_S_DETAILSVIEW_DATEFORMAT2) |
| 169 |
NUM_ACCESSOR(Tabstop, PROP_NDETAILSVIEW_TABSTOP) // tab stop |
| 170 |
NUM_ACCESSOR(WrapText, PROP_N_WRAPTEXT) // text wrapping on editview |
| 171 |
NUM_ACCESSOR(OpenReadOnly, PROP_N_OPENREADONLY) // always read only mode when open the nots. |
| 172 |
NUM_ACCESSOR(DisableSaveDlg, PROP_N_DISABLESAVEDLG) // disable asking save when closing notes |
| 173 |
NUM_ACCESSOR(CodePage, PROP_N_CODEPAGE) // Codepage selection |
| 174 |
|
| 175 |
// crypt related |
| 176 |
NUM_ACCESSOR(PassTimeout, PROP_N_PASSTIMEOUT) // password timeout |
| 177 |
|
| 178 |
// MainFrame related |
| 179 |
NUM_ACCESSOR(AutoSelectMemo, PROP_N_AUTOSELECT_MODE) // display note when treeview selection is moving |
| 180 |
NUM_ACCESSOR(SingleClick, PROP_N_SINGLECLICK_MODE) // display note when clicking the tree item |
| 181 |
NUM_ACCESSOR(SwitchWindowTitle, PROP_N_SWITCH_WINDOW_TITLE) // is sync window text to note's name? |
| 182 |
NUM_ACCESSOR(UseTwoPane, PROP_N_USE_TWO_PANE) // is two pane mode? |
| 183 |
|
| 184 |
// extapp related |
| 185 |
NUM_ACCESSOR(UseAssociation, PROP_N_USEASSOC) // use default file assosiation |
| 186 |
STR_ACCESSOR(ExtApp1, PROP_S_EXTAPP1) |
| 187 |
STR_ACCESSOR(ExtApp2, PROP_S_EXTAPP2) |
| 188 |
|
| 189 |
// Use YAEDIT component. On 1.x, always FALSE. |
| 190 |
NUM_ACCESSOR(UseYAEdit, PROP_N_USE_YAE) |
| 191 |
NUM_ACCESSOR(DisableYAEdit, PROP_N_DISABLE_YAE) |
| 192 |
|
| 193 |
|
| 194 |
NUM_ACCESSOR(AppButton1, PROP_N_APP_BUTTON1) // application buttons |
| 195 |
NUM_ACCESSOR(AppButton2, PROP_N_APP_BUTTON2) |
| 196 |
NUM_ACCESSOR(AppButton3, PROP_N_APP_BUTTON3) |
| 197 |
NUM_ACCESSOR(AppButton4, PROP_N_APP_BUTTON4) |
| 198 |
NUM_ACCESSOR(AppButton5, PROP_N_APP_BUTTON5) |
| 199 |
|
| 200 |
#if defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5) |
| 201 |
NUM_ACCESSOR(SipSizeDelta, PROP_N_SIPSIZE_DELTA) |
| 202 |
|
| 203 |
// Disable open/close notes when action button pushed |
| 204 |
NUM_ACCESSOR(DisableExtraActionButton, PROP_N_DISABLEEXTRAACTIONBUTTON) |
| 205 |
|
| 206 |
#endif |
| 207 |
|
| 208 |
#if defined(PLATFORM_HPC) || defined(PLATFORM_WIN32) |
| 209 |
NUM_ACCESSOR(HideStatusBar, PROP_N_HIDESTATUSBAR) // Hide status bar |
| 210 |
void ToggleShowStatusBar() { nPropsNum[PROP_N_HIDESTATUSBAR] = !nPropsNum[PROP_N_HIDESTATUSBAR]; } |
| 211 |
#else |
| 212 |
DWORD GetHideStatusBar() { return TRUE; } |
| 213 |
void ToggleShowStatusBar() { /* nop */ } |
| 214 |
#endif |
| 215 |
#if defined(PLATFORM_WIN32) |
| 216 |
NUM_ACCESSOR(StayTopMost, PROP_N_STAYTOPMOST) // keep tombo topmost of the window |
| 217 |
void ToggleStayTopMost() { nPropsNum[PROP_N_STAYTOPMOST] = !nPropsNum[PROP_N_STAYTOPMOST]; } |
| 218 |
|
| 219 |
NUM_ACCESSOR(HideRebar, PROP_N_HIDEREBAR) // hide rebar(toolbar) |
| 220 |
void ToggleShowRebar() { nPropsNum[PROP_N_HIDEREBAR] = !nPropsNum[PROP_N_HIDEREBAR]; } |
| 221 |
#endif |
| 222 |
|
| 223 |
// save restore main window size |
| 224 |
BOOL SaveWinSize(UINT flags, UINT showCmd, LPRECT pWinRect, WORD nSelectViewWidth); |
| 225 |
BOOL GetWinSize(UINT *pFlags, UINT *pShowCmd, LPRECT pWinRect, LPWORD pSelectViewWidth); |
| 226 |
|
| 227 |
#if (defined(PLATFORM_PKTPC) || defined(PLATFORM_WM5)) && defined(FOR_VGA) |
| 228 |
NUM_ACCESSOR(WinSize2, PROP_N_TOMBO_WINSIZE3) // horizontal pane size |
| 229 |
#endif |
| 230 |
|
| 231 |
LPCTSTR GetBookMark() { return pBookMark; } |
| 232 |
BOOL SetBookMark(LPCTSTR pBookMark); |
| 233 |
|
| 234 |
LPCTSTR GetSearchHist() { return pSearchHistory; } |
| 235 |
void SetSearchHist(LPTSTR pHist) { delete [] pSearchHistory; pSearchHistory = pHist; } |
| 236 |
|
| 237 |
LPCTSTR GetTopDirHist() { return pTopDirHistory; } |
| 238 |
void SetTopDirHist(LPTSTR pHist) { delete [] pTopDirHistory; pTopDirHistory = pHist; } |
| 239 |
|
| 240 |
#if defined(PLATFORM_HPC) |
| 241 |
// save commandbar position |
| 242 |
BOOL SetCommandbarInfo(LPCOMMANDBANDSRESTOREINFO p); |
| 243 |
void SetCommandbarInfoWithBuffer(LPCOMMANDBANDSRESTOREINFO p) { delete [] pCmdBarInfo; pCmdBarInfo = p; } |
| 244 |
BOOL GetCommandbarInfo(LPCOMMANDBANDSRESTOREINFO p, DWORD n); |
| 245 |
#endif |
| 246 |
|
| 247 |
void SetNumberPropertyById(DWORD nId, DWORD nValue) { nPropsNum[nId] = nValue; } |
| 248 |
void SetStringPropertyWithBuffer(DWORD nId, LPTSTR pValue) { pPropsStr[nId] = pValue; } |
| 249 |
|
| 250 |
///////////////////////////////// |
| 251 |
// main op |
| 252 |
|
| 253 |
// popup property dialog |
| 254 |
DWORD Popup(HINSTANCE hInst, HWND hWnd, const TomboURI *pCurrentSelectedURI); |
| 255 |
|
| 256 |
// load properties |
| 257 |
BOOL Load(); |
| 258 |
|
| 259 |
// save properties |
| 260 |
BOOL Save(); |
| 261 |
|
| 262 |
// check object status |
| 263 |
BOOL IsLoaded() { return bLoad; } |
| 264 |
BOOL IsNeedAskUser() { return bNeedAsk; } |
| 265 |
}; |
| 266 |
|
| 267 |
//////////////////////////////////// |
| 268 |
// Search history |
| 269 |
//////////////////////////////////// |
| 270 |
|
| 271 |
BOOL SetHistoryToComboBox(HWND hCombo, LPCTSTR pHistoryStr); |
| 272 |
LPTSTR GetHistoryFromComboBox(HWND hCombo, LPCTSTR pSelValue, DWORD nSave); |
| 273 |
|
| 274 |
//////////////////////////////////// |
| 275 |
// global var declaration |
| 276 |
//////////////////////////////////// |
| 277 |
extern Property g_Property; |
| 278 |
|
| 279 |
///////////////////////////////////////////// |
| 280 |
// attribute name definitions |
| 281 |
///////////////////////////////////////////// |
| 282 |
|
| 283 |
// some codes assumes this value is just '2'. check if this value is changed. |
| 284 |
#define NUM_COMMANDBAR 2 |
| 285 |
|
| 286 |
///////////////////////////////////////////// |
| 287 |
// Code conversion related |
| 288 |
///////////////////////////////////////////// |
| 289 |
|
| 290 |
LPBYTE ConvTCharToFileEncoding(LPCTSTR p, LPDWORD pSize); |
| 291 |
|
| 292 |
// p is assumed terminated by '\0' if encoding is MBCS/UTF-8 and L'\0' if encoding is UTF-16 |
| 293 |
LPTSTR ConvFileEncodingToTChar(LPBYTE p); |
| 294 |
|
| 295 |
#endif |