Derived from: public BWindow
Declared in: FileDocumentWindow.h
Library: none
Augments BWindow to manage association between the document window and a file which the document window represents. FileDocumentWindow keeps track of the file name, and for untitled windows, handles bringing up a Save As... BFilePanel if the user selects Save. If the user has modified the document (if the child class has called SetModifiedFlag() since the last load or save operation) then FileDocumentWindow handles presenting a Save, Don't Save, Cancel dialog box. It can work with DocumentApp as well to provide this "nice" quit behavior at the application level. A child class which has a Save As... menu item should have this menu item post a FDW_SAVE_AS_REQESTED message to the window, while a Save item should post a B_SAVE_REQUESTED message. Both of these are handled by the FileDocumentWindow's MessageReceived() method. To actually save the document, the child class should implement the Save() method.
FileDocumentWindow(BRect frame, const char* filename, window_type type, uint32 flags, uint32 workspace = B_CURRENT_WORKSPACE); FileDocumentWindow(BRect frame, const char* filename, window_look look, window_feel feel, uint32 flags, uint32 workspace = B_CURRENT_WORKSPACE)
Creates a FileDocumentWindow. For new documents, start them with the name "Untitled" "Untitled document" "Untitled 1" etc., without any path specified. This will flag the document as being truly untitled, and a Save request (as opposed to Save as...) will defer to Save as... to give it a name.
See also: the BWindow constructor
~FileDocumentWindow()
Deletes the save panel if any has been created, and unregisters the window with the DocumentApp object, if be_app is a DocumentApp.
void MessageReceived(BMessage* message)
Handles B_SAVE_REQUESTED and FDW_SAVE_AS_REQUESTED messages.
void QuitOnceSaved()
Used in conjunction with Save, Don't Save, Cancel dialog following a window close request to indicate that once the window has saved its contents to a file, it should quit.
virtual bool QuitRequested()
If the window content has been modified (if SetModifiedFlag() has been called), returns false so as not to stall the event loop, and presents the user with a Save, Don't Save, Cancel dialog box.
virtual bool Save()
Should be implemented by child classes to save the document to the file returned by GetFileName().
virtual void SetFileName(const char* filename) const char* GetLeafName(const char* a_filename = NULL) const char* GetFileName()
Sets the file name, or returns the file name (with full path ot just the leaf name) for the file.
void SetModifiedFlag(bool state = true) bool IsModifiedFlagSet()
Flags the file as having been modifed, and returns the state of this flag.
By Brian Tietz
Copyright 2000
Bug reports (including documentation errors) and feature requests can be sent to briant@timelinevista.com.