wxRuby Documentation Home

# Wx::DocManager

The DocManager class is part of the document/view framework supported by Widgets,
and cooperates with the View, Document and DocTemplate classes.

## Derived from

EvtHandler

Object

## See also

DocManager overview, Document, View, DocTemplate, FileHistory

## Methods

- DocManager#m__current_view
- DocManager#m__default_document_name_counter
- DocManager#m__file_history
- DocManager#m__max_docs_open
- DocManager#m__docs
- DocManager#m__flags
- DocManager#m__last_directory
- DocManager#m__templates
- DocManager.new
- DocManager#activate_view
- DocManager#add_document
- DocManager#add_file_to_history
- DocManager#associate_template
- DocManager#close_documents
- DocManager#create_document
- DocManager#create_view
- DocManager#disassociate_template
- DocManager#file_history_add_files_to_menu
- DocManager#file_history_load
- DocManager#file_history_remove_menu
- DocManager#file_history_save
- DocManager#file_history_use_menu
- DocManager#find_template_for_path
- DocManager#get_current_document
- DocManager#get_current_view
- DocManager#get_documents
- DocManager#get_file_history
- DocManager#get_last_directory
- DocManager#get_max_docs_open
- DocManager#get_history_files_count
- DocManager#get_templates
- DocManager#initialize
- DocManager#make_default_name
- DocManager#on_create_file_history
- DocManager#on_file_close
- DocManager#on_file_close_all
- DocManager#on_file_new
- DocManager#on_file_open
- DocManager#on_file_revert
- DocManager#on_file_save
- DocManager#on_file_save_as
- DocManager#remove_document
- DocManager#select_document_path
- DocManager#select_document_type
- DocManager#select_view_type
- DocManager#set_last_directory
- DocManager#set_max_docs_open

### DocManager#m__current_view

View*m_currentView

The currently active view.

### DocManager#m__default_document_name_counter

intm_defaultDocumentNameCounter

Stores the integer to be used for the next default document name.

### DocManager#m__file_history

FileHistory*m_fileHistory

A pointer to an instance of FileHistory,
which manages the history of recently-visited files on the File menu.

### DocManager#m__max_docs_open

intm_maxDocsOpen

Stores the maximum number of documents that can be opened before
existing documents are closed. By default, this is 10,000.

### DocManager#m__docs

Listm_docs

A list of all documents.

### DocManager#m__flags

longm_flags

Stores the flags passed to the constructor.

### DocManager#m__last_directory

The directory last selected by the user when opening a file.

FileHistory*m_fileHistory

### DocManager#m__templates

Listm_templates

A list of all document templates.

### DocManager.new

DocManager.new(%(arg-type)Integer% flags = DEFAULT_DOCMAN_FLAGS, Boolean initialize = true)

Constructor. Create a document manager instance dynamically near the start of your application
before doing any document or view operations.

flags is currently unused.

If initialize is true, the Initialize function will be called
to create a default history list object. If you derive from DocManager, you may wish to call the
base constructor with false, and then call Initialize in your own constructor, to allow
your own Initialize or OnCreateFileHistory functions to be called.

destructor()

Destructor.

### DocManager#activate_view

activate_view(%(arg-type)View% doc, Boolean activate = true)

Sets the current view.

### DocManager#add_document

add_document(%(arg-type)Document% doc)

Adds the document to the list of documents.

### DocManager#add_file_to_history

add_file_to_history(%(arg-type)String% filename)

Adds a file to the file history list, if we have a pointer to an appropriate file menu.

### DocManager#associate_template

associate_template(%(arg-type)DocTemplate% temp)

Adds the template to the document manager’s template list.

### DocManager#close_documents

Boolean close_documents(%(arg-type)Boolean% force = true)

Closes all currently opened documents.

### DocManager#create_document

Document create_document(%(arg-type)String% path, Integer flags)

Creates a new document in a manner determined by the flags parameter, which can be:

- DOC_NEW Creates a fresh document.
- DOC_SILENT Silently loads the given document file.

If DOC_NEW is present, a new document will be created and returned, possibly after
asking the user for a template to use if there is more than one document template.
If DOC_SILENT is present, a new document will be created and the given file loaded
into it. If neither of these flags is present, the user will be presented with
a file selector for the file to load, and the template to use will be determined by the
extension (Windows) or by popping up a template choice list (other platforms).

If the maximum number of documents has been reached, this function
will delete the oldest currently loaded document before creating a new one.

### DocManager#create_view

View create_view(%(arg-type)Document% doc, Integer flags)

Creates a new view for the given document. If more than one view is allowed for the
document (by virtue of multiple templates mentioning the same document type), a choice
of view is presented to the user.

### DocManager#disassociate_template

disassociate_template(%(arg-type)DocTemplate% temp)

Removes the template from the list of templates.

### DocManager#file_history_add_files_to_menu

file_history_add_files_to_menu()

Appends the files in the history list, to all menus managed by the file history object.

file_history_add_files_to_menu(%(arg-type)Menu% menu)

Appends the files in the history list, to the given menu only.

### DocManager#file_history_load

file_history_load(%(arg-type)ConfigBase% config)

Loads the file history from a config object.

#### See also

Config

### DocManager#file_history_remove_menu

file_history_remove_menu(%(arg-type)Menu% menu)

Removes the given menu from the list of menus managed by the file history object.

### DocManager#file_history_save

file_history_save(%(arg-type)ConfigBase% resourceFile)

Saves the file history into a config object. This must be called
explicitly by the application.

#### See also

Config

### DocManager#file_history_use_menu

file_history_use_menu(%(arg-type)Menu% menu)

Use this menu for appending recently-visited document filenames, for convenient
access. Calling this function with a valid menu pointer enables the history
list functionality.

Note that you can add multiple menus using this function, to be managed by the
file history object.

### DocManager#find_template_for_path

DocTemplate find_template_for_path(%(arg-type)String% path)

Given a path, try to find template that matches the extension. This is only
an approximate method of finding a template for creating a document.

### DocManager#get_current_document

Document get_current_document()

Returns the document associated with the currently active view (if any).

### DocManager#get_current_view

View get_current_view()

Returns the currently active view

### DocManager#get_documents

List get_documents()

Returns a reference to the list of documents.

### DocManager#get_file_history

FileHistory get_file_history()

Returns a pointer to file history.

### DocManager#get_last_directory

String get_last_directory()

Returns the directory last selected by the user when opening a file. Initially empty.

### DocManager#get_max_docs_open

Integer get_max_docs_open()

Returns the number of documents that can be open simultaneously.

### DocManager#get_history_files_count

Integer get_history_files_count()

Returns the number of files currently stored in the file history.

### DocManager#get_templates

List get_templates()

Returns a reference to the list of associated templates.

### DocManager#initialize

Boolean initialize()

Initializes data; currently just calls OnCreateFileHistory. Some data cannot
always be initialized in the constructor because the programmer must be given
the opportunity to override functionality. If OnCreateFileHistory was called
from the constructor, an overridden virtual OnCreateFileHistory would not be
called due to C++’s `interesting’ constructor semantics. In fact Initialize

[This page automatically generated from the Textile source at 2023-06-09 00:45:35 +0000]