NAME
Tk::AppWindow::Ext::MDI - multiple document interface
SYNOPSIS
my $app = new Tk::AppWindow(@options,
-extensions => ['MDI'],
);
$app->MainLoop;
DESCRIPTION
Provides a multi document interface to your application.
When Tk::AppWindow::Ext::MenuBar is loaded it creates menu entries for creating, opening, saving and closing files. It also maintains a history of recently closed files.
When Tk::AppWindow::Ext::ToolBar is loaded it creates toolbuttons for creating, opening, saving and closing files.
It features deferred loading. If you open a document it will not load the document until there is a need to access it. This comes in handy when you want to open multiple documents at one time.
You should define a content handler based on the abstract baseclass Tk::AppWindow::BaseClasses::ContentManager. See also there.
This extension will also load the extensions ConfigFolder and Daemons.
CONFIG VARIABLES
- Switch: -contentmanagerclass
-
This one should always be specified and you should always define a content manager class inheriting Tk::AppWindow::BaseClasses::ContentManager. This base class is a valid Tk widget.
- Switch: -contentmanageroptions
-
The possible options to pass on to the contentmanager. These will also become options to the main application.
- Switch: -diskmonitorinterval
-
Default value 100. This means every 100 cycles of the Daemons extension. Specifies the interval for monitoring the disk status of documents.
- Switch: -filetypes
-
Default value is "All files|*"
-
Specifies the default location in the main menu of the history menu. Default value is File::Open recent. See also Tk::AppWindow::Ext::MenuBar.
- Switch: -maxhistory
-
Default value is 12.
- Switch: -maxtablength
-
Default value 16
Maximum size of the document tab in the document bar.
- Switch: -modifiedmonitorinterval
-
Default value 25. This means every 25 cycles of the Daemons extension. Specifies the interval for monitoring the modified status of documents.
- Switch: -readonly
-
Default value 0. If set to 1 MDI will operate in read only mode.
COMMANDS
The following commands are defined.
- deferred_open
-
Takes a document name that is in deferred state as parameter and creates a new content handler for it. Returns a boolean indicating the succesfull load of its content.
- doc_close
-
Takes a document name as parameter and closes it. If no parameter is specified closes the current selected document. Returns a boolean for succes or failure.
- doc_new
-
Takes a document name as parameter and creates a new document. If no parameter is specified an Untitled document is created. Returns a boolean for succes or failure.
- doc_open
-
Takes a filename as parameter and opens it in deferred state. If no parameter is specified a file dialog is issued. Returns a boolean for succes or failure.
- doc_rename
-
Takes two document names as parameters and renames the first one to the second one in the interface.
- doc_save
-
Takes a document name as parameter and saves it if it is modified. If no parameter is specified the current selected document is saved. Returns a boolean for succes or failure.
- doc_save_as
-
Takes a document name as parameter and issues a file dialog to rename it. If no parameter is specified the current selected document is initiated in the dialog. Returns a boolean for succes or failure.
- doc_save_all
-
Saves all open and modified documents. Returns a boolean for succes or failure.
- doc_select
-
Select an opened document.
-
Is called when the file menu is opened in the menubar. It populates the 'Open recent' menu with the current history.
- set_title
-
Takes a document name as parameter and sets the main window title accordingly.
METHODS
- ConfirmSaveDialog($name)
-
Pops a dialog with a warning that $name is unsaved. Asks for your action. Does not check if $name is modified or not. Returns the key you press, 'Yes', 'No', or cancel. Does not do any saving or checking whether a file has been modified.
- ContentSpace($name)
-
Returns the page frame widget in the notebook belonging to $name.
- CreateContentHandlerI($name);
-
Initiates a new content handler for $name.
- CreateInterface
-
Creates a Tk::YANoteBook multiple document interface.
- deferredAssign($name, ?$options?)
-
This method is called when you open a document. It adds document $name to the interface and stores $options in the deferred hash. $options is a reference to a hash. It's keys can be any option accepted by your content manager.
- deferredExists($name)
-
Returns true if deferred entry $name exists.
- deferredList
-
Returns a list of deferred documents.
- deferredOpen($name)
-
This method is called when you access the document for the first time. It creates the content manager with the deferred options and loads the file.
- deferredOptions($name, ?$options?)
-
Sets and returns a reference to the hash containing the options for $name.
- deferredRemove($name)
-
Removes $name from the deferred hash.
- docClose($name)
-
Removes $name from the interface and destroys the content manager. Also adds $name to the history list.
- docConfirmSave($name)
-
Checks if $name is modified and asks confirmation for save. Saves the document if you press 'Yes'. Returns 1 unless you cancel the dialog, then it returns 0.
- docConfirmSaveAll
-
Calls docConfirmSave for all loaded documents. returns 0 if a 'Cancel' is detected.
- docExists($name)
-
Returns true if $name exists in either loaded or deferred state.
- docForceClose(?$flag?)
-
If $flag is set ConfirmSave dialogs will be skipped, documents will be closed ruthlessly. Use with care and always reset it back to 0 when you're done.
- docFullList
-
Returns a list of all documents, loaded and deferred.
- docGet($name)
-
Returns the content manager object for $name.
- docList
-
Returns a list of all loaded documents.
- docListDisplayed
-
Returns a list of documents currently visible in the tabs bar.
- docListUnDisplayed
-
Returns a list of documents currently not visible in the tabs bar.
- docModified($name)
-
Returns true if $name is modified.
- docRename($old, $new)
-
Renames a loaded document.
- docSelect($name)
-
Selects $name.
- docSelected
-
Returns the name of the currently selected document. Returns undef if no document is selected.
- docTitle($name)
-
Strips the path from $name for the title bar.
- docUntitled>
-
Returns 'Untitled' plus a digit '(d)'. It checks how many untitled documents exists and adjusts the number.
- historyAdd($name)
- historyDisabled($name)
- historyLoad
-
Loads the history file in the config folder.
- historyRemove($name)
-
Removes $name from the history list. Called when a document is opened.
- historySave
-
Saves the history list to the history file in the config folder.
- Interface
-
Returns a reference to the multiple document interface.
- interfaceAdd($name)
-
Adds $name to the multiple document interface and to the Navigator if the Navigator extension is loaded.
- interfaceCollapse
-
Collapses all folder trees in the document tree except the path of the selected entry, if extension Navigator is loaded.
- interfaceExpand
-
Opens all folder trees in the document tree, if extension Navigator is loaded.
- interfaceRemove($name, ?$flag?)
-
Removes $name from the multiple document interface and from the Navigator if the Navigator extension is loaded.
- interfaceRename($old, $new)
-
Renames the $old entry in the multiple document interface and the navigator.
- interfaceSelect($name)
-
Is called when something else than the user selects a document.
- MenuItems
-
Returns the menu items for MDI. Called by extension MenuBar.
- monitorAdd($name)
-
Adds $name to the hash of monitored documents. It will check it's modified status. It willcollect its time stamp, if $name is an existing file.
- monitorDisk($name)
-
Checks if $name is modified on disk after it was loaded. Launches a dialog for reload or ignore if so.
- monitorList($name)
-
returns a list of monitored documents.
- monitorModified($name)
-
Checks if the modified status of the document has changed and updates the navigator.
- monitorRemove($name)
-
Removes $name from the hash of monitored documents.
- monitorUpdate($name)
-
Assigns a fresh time stamp to $name. Called when a document is saved.
- selectDisabled?$flag?)
-
Sets and returns the selectdisabled flag. If this flag is set, no document can be selected. Use with care.
- ToolItems
-
Returns the tool items for MDI. Called by extension ToolBar.
AUTHOR
Hans Jeuken (hanje at cpan dot org)
BUGS
Unknown. If you find any, please contact the author.