tagging release
[dasher.git] / trunk / Src / Win32 / Widgets / FilenameGUI.h
blob73d8ea9d22522dca75e8297958f1e139d0f5c0ac
1 // FilenameGUI.h
2 //
3 /////////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge.
6 //
7 /////////////////////////////////////////////////////////////////////////////
9 #ifndef __FilenameGUI_h__
10 #define __FilenameGUI_h__
12 /* CFilenameGUI Notes: {{{
14 This class provides an interface to the Windows common dialogs for file
15 opening and saving. It also (optionally) generates dated filenames and will
16 manage the title bar of a Window to show the filename (formatted according to
17 windows system preferences) and whether it is "dirty" (using a *).
19 BTW I also wrote a class CFileGUI that assumes it has total control over
20 setting files. It returns Windows file handles, rather than filenames and
21 is neater and easier to use (as it did more). I decided it wasn't suitable
22 for Dasher though as it wouldn't allow for setting of filenames through the
23 Dasher interface. I'll provide CFileGUI on request. IAM 09/2002
24 }}}*/
26 class CFilenameGUI {
27 public:
28 CFilenameGUI(HWND WindowWithTitlebar, Tstring AppName, bool NewWithDate = false);
30 // Used by the Windows GUI:
31 ////////////////////////////////////////////////////////////////////////////
32 const Tstring & New(); // Returns a dated filename or ""
33 const Tstring & Open(); // Returns filename or "" if user aborts
34 const Tstring & SaveAs(); // Returns filename or "" if user aborts
36 const Tstring & Save(); // Returns current filename if there is one,
37 // otherwise returns FileSaveAs().
39 int QuerySaveFirst(); // Called before doing something that will trash
40 // unsaved text (FileNew(), FileOpen(), quitting, etc)
41 // returns IDNO if you should just carry on,
42 // returns IDYES if you should call save,
43 // returns IDCANCEL if you should do nothing.
45 void SetNewWithDate(bool Value); // Should we automatically generate filenames
46 // based on the date when a user hits New?
47 // In this section as options are set by the GUI
49 // Used by the client - eg an edit box control
50 ////////////////////////////////////////////////////////////////////////////
51 void SetFilename(const Tstring & FileName); // Objects of this class cannot
52 // know if the filename from FileOpen() or FileSaveAs()
53 // worked out. A FileName may also be set in another way.
54 // Therefore, the window title is not set until this
55 // member is called.
57 void SetDirty(bool Value); // Needed to format the dirty * in window title
58 // QuerySaveFirst also automatically returns IDNO
59 // if (!Dirty). This flag is NOT altered by
60 // FileOpen(), FileSave() or FileSaveAs(). We
61 // cannot guess whether these requests succeeded
62 // at the client end.
63 private:
64 static const Tstring Empty;
65 Tstring AppName;
66 Tstring OriginalPath;
68 Tstring FileAndPath;
69 bool Dirty;
70 bool NewWithDate;
71 HWND WindowWithTitlebar;
73 void SetWindowTitle();
76 #endif /* #ifndef __FilenameGUI_h__ */