Displays a standard Open/Save dialog. More...
|BFilePanel (file_panel_mode mode=B_OPEN_PANEL, BMessenger *target=NULL, const entry_ref *directory=NULL, uint32 nodeFlavors=0, bool allowMultipleSelection=true, BMessage *message=NULL, BRefFilter *refFilter=NULL, bool modal=false, bool hideWhenDone=true)|
|Creates and initializes a BFilePanel object. More...|
|Destroys the file panel object. More...|
|status_t||GetNextSelectedRef (entry_ref *ref)|
|Sets the ref pointer to the next entry in the directory. More...|
|void||GetPanelDirectory (entry_ref *ref) const|
|Gets the entry ref of the panel and sets ref to point to it. More...|
|Hides the file panel. More...|
|bool||HidesWhenDone () const|
|Gets whether or not the panel should hide on confirm or cancel. More...|
|bool||IsShowing () const|
|Determines whether or not the file panel is shown. More...|
|BMessenger||Messenger () const|
|Gets the panel's target messenger object. More...|
|file_panel_mode||PanelMode () const|
|Gets the panel mode, either |
|BRefFilter *||RefFilter () const|
|Gets the BRefFilter object associated with the panel. More...|
|Refresh the directory or the panel causing the entries to be re-run through the BRefFilter::Filter() method. More...|
|Sets the entry ref back to the top of the list. More...|
|virtual void||SendMessage (const BMessenger *target, BMessage *message)|
|Sends the message to the target BHandler messenger. More...|
|void||SetButtonLabel (file_panel_button button, const char *label)|
|Set the button label specified by button to text. More...|
|void||SetHideWhenDone (bool hideWhenDone)|
|Sets whether or not the panel should hide on confirm or cancel. More...|
|void||SetMessage (BMessage *message)|
|Sets the target messenge. More...|
|void||SetPanelDirectory (const BEntry *newDirectory)|
|Sets the entry ref of the panel to the directory referenced by entry. More...|
|void||SetPanelDirectory (const BDirectory *newDirectory)|
|Sets the entry ref of the panel to the directory referenced by dir. More...|
|void||SetPanelDirectory (const entry_ref *newDirectory)|
|Sets the entry ref of the panel to the directory contained by ref. More...|
|void||SetPanelDirectory (const char *newDirectory)|
|Sets the entry ref of the panel to the directory referenced by path. More...|
|void||SetRefFilter (BRefFilter *filter)|
|Sets the BRefFilter used by the panel to filter entries. More...|
|void||SetSaveText (const char *text)|
|Set some save text to display in the save dialog. More...|
|void||SetTarget (BMessenger target)|
|Sets the target messenger. More...|
|Displays the file panel on screen. More...|
|BWindow *||Window () const|
|Gets a pointer to the BWindow object used by the file panel. More...|
|virtual void||WasHidden ()|
|Hook method that gets called when the file panel is hidden due to a user action. More...|
|virtual void||SelectionChanged ()|
|Hook method that gets called when the entry ref references by the file panel changes. More...|
Displays a standard Open/Save dialog.
A save panel looks like this:
An open dialog looks similar but doesn't have a text box for the file name.
You generally construct a BFilePanel object in response to a user action for example the user clicks on a "Open" or "Save"/"Save As" menu item. Constructing an open or save panel is easy:
You can then call methods to indicate what directory to display, whether or not multiple selections are allowed, whether or not the user is allowed to open a directory, what target view to send send notifications, and more. See the constructor for details.
You can modify the look of your BFilePanel object by calling the SetButtonLabel() and SetSaveText() methods. If you want to change the look even more radically you can get alter the panel's BWindow and BView objects. You get the window by calling the Window() method. With a pointer to the panel's BWindow object you can drill down to the various views contained therein.
When the user confirms or cancels a BMessage object is constructed and sent to the target of the BFilePanel object. You can specify a different target in the constructor or by calling the SetTarget() method.
For open notifications the default target is
be_app_messenger and is caught by the RefsReceived() method The
what field is set to
B_REFS_RECEIVED. You can set your own message by calling the SetMessage() method; in this case the message will be sent to the target's MessageReceived() method instead.
refs field of the message contains an
entry_ref structure for each entry that the user has selected. The
refs field is of type
B_REF_TYPE. If the selected entry is a symlink to a file you'll need to dereference the file yourself. You can do this more easily by turning the
ref into a BEntry passing
true into the
traverse argument like this:
Save notifications are always sent to the target's MessageReceived() method unlike open notifications. The
what field of the message is set to
directory field contain a single
entry_ref structure that points to the directory that the entry is saved to. The text that the user typed in the save panel's text view is put in the
name field and is of type
Cancel notifications are sent when the panel is hidden whether by the user clicking the cancel button, closing the dialog, or confirming the action (assuming hide-when-done is turned on).
Cancel notifications can be caught by the MessageReceived() method of the target. The
what field is set to
old_what field is set to the previous what value which is useful if you have overridden the default message. The
what field of the message you sent is put in the
source field is a pointer of
B_POINTER_TYPE to the closed BFilePanel object. When the BFilePanel object is closed it is not destroyed, it is hidden instead. You can then delete the BFilePanel object or leave it be and simply call Show() to use the panel next time you need it.
|BMessenger *||target =
|const entry_ref *||ref =
|BMessage *||message =
|BRefFilter *||filter =
Creates and initializes a BFilePanel object.
The constructor has many parameters but they may generally be set after the object has been constructed. The only parameters that must be set during construction are the mode, nodeFlavors, multipleSelection, and modal parameters. The rest may be set after the object has been constructed by the SetTarget(), SetPanelDirectory(), SetMessage(), SetRefFilter(), and SetHideWhenDone() methods.
|mode||Set to |
|target||The BMessenger object that sends messages to the BLooper or BHandler controlled by the file panel.|
|ref||The directory to display, by default the current working directory.|
|nodeFlavors||One or more option flags, this applies to open panels only.|
|multipleSelection||Whether or not the user is allowed to select more than one item to open. Save panels should always set this to |
|message||Message sent by the file panel on confirms or cancels.|
|filter||Hook method to call.|
|modal||Whether or not the panel is modal, defaults to |
|hideWhenDone||Set to |
Destroys the file panel object.
If file panel is currently being displayed it is closed. The BRefFilter object references by this panel is not destroyed by this method.
|void BFilePanel::GetPanelDirectory||(||entry_ref *||ref||)||const|
Gets the entry ref of the panel and sets ref to point to it.
Hides the file panel.
Gets whether or not the panel should hide on confirm or cancel.
Panel always hides if the user clicks the window's close button.
trueif panel will hide,
falseif panel will not hide.
Determines whether or not the file panel is shown.
Gets the panel's target messenger object.
Gets the panel mode, either
B_OPEN_PANELif the panel is an open panel, or
B_SAVE_PANELif the panel is a save panel.
|BRefFilter * BFilePanel::RefFilter||(||)||const|
Refresh the directory or the panel causing the entries to be re-run through the BRefFilter::Filter() method.
Sets the entry ref back to the top of the list.
|const char *||text|
Set the button label specified by button to text.
|button||The button to set the label of.|
|text||The text to set the button label to.|
Sets whether or not the panel should hide on confirm or cancel.
|void BFilePanel::SetMessage||(||BMessage *||message||)|
Sets the target messenge.
|message||The BMessage object to send on confirm.|
|void BFilePanel::SetPanelDirectory||(||const BEntry *||entry||)|
Sets the entry ref of the panel to the directory referenced by entry.
|entry||The BEntry object pointing to the desired directory.|
|void BFilePanel::SetPanelDirectory||(||const BDirectory *||dir||)|
Sets the entry ref of the panel to the directory referenced by dir.
|dir||The BDirectory object pointing to the desired directory.|
|void BFilePanel::SetPanelDirectory||(||const entry_ref *||ref||)|
Sets the entry ref of the panel to the directory contained by ref.
|ref||The entry contained by the desired panel directory.|
|void BFilePanel::SetPanelDirectory||(||const char *||path||)|
Sets the entry ref of the panel to the directory referenced by path.
|path||The path of the desired directory.|
|void BFilePanel::SetRefFilter||(||BRefFilter *||filter||)|
|void BFilePanel::SetSaveText||(||const char *||text||)|
Set some save text to display in the save dialog.
|text||The text to display.|
Sets the target messenger.
|target||the target BMessenger object to set.|
Displays the file panel on screen.