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.
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: -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: -monitorinterval
-
Default value 3 seconds. Specifies the interval for the monitor cycle. This cycle monitors loaded files for changes on disk and modified status.
- Switch: -readonly
-
Default value 0. If set to 1 MDI will operate in read only mode.
COMMANDS
The following commands are defined.
- 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 content handler for it. If no parameter is specified and Untitled document is created. Returns a boolean for succes or failure.
- doc_open
-
Takes a filename name as parameter and opens it. If no parameter is specified a file dialog is issued. Returns a boolean for succes or failure.
- 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.
- 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.
- docGet($name)
-
Returns the content manager object for $name.
- docList
-
Returns a list of all loaded documents.
- 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)
- 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.
- 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.
- monitorCycle
-
This method is called every time the monitor interval times out. It will check all monitored files for changes on disk and checks if they should be marked ad modified or saved in the navigator.
- monitorCycleStart
-
Starts the timer for monitorCycle. The value of the timer is specified in the -monitorinterval option.
- 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.