16#include <owl/docview.rh>
22#if defined(__BORLANDC__)
31#define IDC_FILENAMETXT stc3
32#define IDC_FILENAME edt1
33#define IDC_FILELIST lst1
34#define IDC_CURDIR stc1
35#define IDC_DIRLIST lst2
36#define IDC_FILETYPEEXT stc2
37#define IDC_FILETYPES cmb1
38#define IDC_DRIVESTEXT stc4
39#define IDC_DRIVES cmb2
40#define IDC_HELPF pshHelp
41#define IDC_READONLY chx1
99 CHECK(ofn.lpstrDefExt);
100 ofn.lpstrDefExt =
tpl->GetDefaultExt();
129 handleTemplateChanged(*
this, *
this,
GetOFN());
160 handleTemplateChanged(*
this, *
this,
GetOFN());
215 AdditionalFileDialogFlags = 0;
222 tpl->DocManager =
this;
238 while ((
doc = DocList.
Next(
nullptr)) !=
nullptr) {
255 while (TemplateList) {
257 TemplateList =
tpl->GetNextTemplate();
259 tpl->SetDocManager(
nullptr);
322 if (
tpl->IsVisible() &&
402 if (
tpl->IsMyKindOfDoc(
doc)) {
408 for (index = 0; index <
tplCount; index++) {
463 for (
int count=0; count <
tplcount; count++) {
470 p =
tpl->GetFileFilter();
487 for (
int count = 0; count <
tplcount; count++ ) {
495 p =
tpl->GetFileFilter();
574 _T(
"Invalid template index from SelectDocPath"));
586 if (
doc !=
nullptr) {
626 return tpl->ConstructDoc(parent);
670 CHECKX(
tpl,
_T(
"TDocManager::InitDoc: No template"));
674 flags ^=
tpl->GetFlags();
679 doc->SetDocPath(
nullptr);
683 if (!
doc->InitDoc()){
692 CHECKX(
tpl->GetFileFilter(),
_T(
"TDocManager::InitDoc: No file filter"));
717 if (!
doc->InitDoc()) {
720 doc->SetDocPath(
nullptr);
732 doc->SetDocPath(
nullptr);
746 doc->SetDocPath(
nullptr);
844 if (!
tpl || !
tpl->GetFileFilter())
848 if (
doc.GetDocPath())
882 if (
doc.GetDocPath())
916 while (
doc.IsDirty()) {
925 if (!
doc.IsEmbedded() &&
doc.GetDocPath() ==
nullptr) {
939#if defined(OLD_DOCVIEW)
971 if (
doc.Revert(
true))
1067 if (*
wc ==
_T(
'*')) {
1076#if defined(BI_DBCS_SUPPORT)
1130 if (*
ppe ==
_T(
'.'))
1164#if defined(OLD_DOCVIEW)
1183 while ((
doc = DocList.
Next(
doc)) !=
nullptr ) {
1209 if (
doc->GetDocPath() ==
nullptr)
1223 tpl.SetDocManager(
this);
1236 if (
tpl.IsStatic()) {
1243 if (!
tpl.GetDocManager()) {
1279#if BI_MSG_LANGUAGE == 0x0411
1280 _stprintf(buf,
"´×°: •¶Žš—ñ ID %u ‚ªŒ©‚‚©‚è‚Ü‚¹‚ñ",
sid);
1282 _stprintf(buf,
_T(
"Error: Message [string ID %u] not found"),
sid);
1335 int index =
pickl.Execute() + 1;
1371 for (index = count = 0; count <
tplcount; count++) {
1379 for (index = count = 0; count <
tplcount; count++) {
1389 flags = (
tpllist[index]->GetFlags() | flags);
1390 flags &= 0x000FFFFF;
1391 flags |= AdditionalFileDialogFlags;
1392 flags &= ~dtProhibited;
1397 index ? index+1 : 0,
1418 if (result !=
IDOK ||
data.Error != 0)
return 0;
1429 for (count = 0; count <
tplcount; count++) {
1430 if (count == index-1)
1444 if (
data.FileName &&
data.FileName[0]) {
1446 _T(
"SelectDocPath: Specified buffer is too small"));
1456 return data.FilterIndex;
1472 return pickl.Execute() + 1;
1486 if (!
doc->CanClose())
1488 if (!
doc->Close()) {
1560 while ((
doc = DocList.
Next(
doc)) !=
nullptr) {
1561 if (!
doc->CanClose())
1593 doc->ReindexFrames();
1606 ce.Enable(TemplateList !=
nullptr);
1624 ce.Enable(TemplateList !=
nullptr);
1652 if (
doc &&
doc->CanClose()) {
1668 ce.Enable(
doc !=
nullptr);
1682 if (
tpl !=
doc->Template)
1684 if (
doc->Commit(
true))
1708 if (!
doc->GetDocPath()) {
1727 ce.Enable(
doc &&
doc->IsDirty() &&
doc->GetDocPath());
1737 if (
doc &&
doc->GetDocPath()) {
1738 if (!
doc->IsDirty()) {
1770#if OWL_PERSISTENT_STREAMS
1791 tpl =
o->GetNextTemplate(
tpl);
1794 char tbuf[
sizeof(TDocTemplate)];
1796 is >> *(TDocTemplate*)
tbuf;
1803 tpl->SetModule(module);
1804 o->AttachTemplate(*
tpl);
1813 doc->SetDocManager(*
o);
1820 TWindow* win =
o->Application->GetMainWindow();
1821 if (win && win->GetHandle())
1831TDocManager::Streamer::Write(opstream&
os)
const
1833 TDocManager*
o = GetObject();
1835 TDocTemplate*
tpl = 0;
1836 while ((
tpl =
o->GetNextTemplate(
tpl)) != 0) {
1843 os <<
tpl->GetModule();
1851 for (count = 0; (
doc =
o->DocList.Next(
doc))!=0; count++) ;
Definition of class TAppDictionary.
#define WARNX(group, condition, level, message)
#define PRECONDITION(condition)
#define CHECKX(condition, message)
#define TRACEX(group, level, message)
#define DIAG_DEFINE_GROUP_INIT(f, g, e, l)
TApplication * GetApplication(uint pid=0)
Looks up and returns the application associated with a given process ID.
Derived from TModule and TMsgThread and virtually derived from TEventHandler, TApplication acts as an...
TFrameWindow * GetMainWindow()
Return the current main window.
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
Typically used to obtain information from a user, a dialog box is a window inside of which other cont...
auto Execute() -> int override
Creates and executes a modal dialog box interface element associated with the TDialog object.
virtual INT_PTR DialogFunction(TMsgId, TParam1, TParam2)
Override this to process messages within the dialog function.
TDocManager creates a document manager object that manages the list of current documents and register...
virtual void ViewCreate()
Calls CreateAnyView(*doc) where doc is the current document.
void CmFileSaveAs()
Public to allow direct invocation from app; for backward compatibility.
TView * CreateView(TDocument &doc, TDocTemplate *tpl=nullptr)
Create a view on a given document using the given tempalte, or document's template if none given,...
bool EvCanClose()
Checks to see if all child documents can be closed before closing the current document.
virtual void PostEvent(int id, TDocument &doc)
changed doc status
virtual uint PostDocError(TDocument &doc, uint sid, uint choice=MB_OK)
Displays a message box with the error message passed as a string resource ID in sid.
int GetTemplateCount(TDocument *ofDocType=nullptr, TView *ofViewType=nullptr)
Count the number of templates, filtering by document type and/or view type as indicated.
virtual int SelectViewType(TDocTemplate **tpllist, int tplcount)
Given a list of templates, lets the user select a view name for a new view from a list of view names.
static bool MatchFilter(LPCTSTR path, LPCTSTR filters)
Helper function used by 'MatchTemplate'.
void EvWakeUp()
Used only after streaming in the doc manager, EvWakeUp allows for the windows to be created after the...
virtual bool FlushDoc(TDocument &doc)
Method invoked when specified document is about to be closed.
bool IsFlagSet(int flag) const
Returns true if the specified flag is currently enabled by the DocManager or false otherwise.
bool NotifyAllDocs(int event, long item, TView *exclude)
Notifies the views of all documents and the views of any child documents of a change.
virtual int GetNewTemplates(TDocTemplate **tplList, int size, bool newDoc)
Build a list of templates for creating new documents or opening existing documents.
virtual void UpdateFileMenu(TMenu &menubar)
Update the specified menu bar by removing the current '&File' popup menu [assumed to be the first pop...
virtual void FileSaveAs()
SelectAnySave() is called to get a template.
virtual ~TDocManager()
Destruct this DocManager.
virtual TView * CreateAnyView(TDocument &doc, long flags=0)
Creates a document view based on the directory path and specified template.
int UntitledIndex
Index of last untitled document.
TApplication * GetApplication() const
Returns the TApplication* object associated with this DocManager.
TDocument * InitDoc(TDocument *doc, LPCTSTR path, long flags)
Initializes the document, using the given path for the document and the given document flags.
virtual TDocument * CreateDoc(TDocTemplate *tpl, LPCTSTR path, TDocument *parent=nullptr, long flags=0)
CreateDoc creates a document based on the directory path and the specified template.
virtual int GetTemplateDescription(TDocTemplate **tpllist, int tplcount, tchar *buff=nullptr, int size=0)
Build up a long string containing the template descriptions and file filters for every template in th...
TDocument * FindDocument(LPCTSTR path)
0 if not found
void UnRefTemplate(TDocTemplate &)
drop template ref
virtual bool CreatingDoc(TDocTemplate *tpl)
Overrideable method invoked just before the DocumentManager creates a new document.
virtual int GetSaveTemplates(TDocTemplate **tplList, int size, TDocument &doc, bool sameDoc)
Build a list of templates for saving documents.
void Init(int mode, TApplication *app, TDocTemplate *&templateHead)
Helper routine used by constructor(s)
virtual TDocument * CreateAnyDoc(LPCTSTR path, long flags=0)
Creates a document based on the directory path and the specified template.
static bool IsAMatch(LPCTSTR path, LPCTSTR fltr)
Helper function used by 'MatchTemplate'.
bool SelectSave(TDocument &doc)
Displays FileSave dialog prompting the user to select a file name for savinng the document.
void EvPreProcessMenu(HMENU hMenu)
Preprocess the app frame's menu to replace the file menu with one managed by this docmanager.
virtual TDocument * GetCurrentDoc()
Return doc with focus, else 0.
void DeleteTemplate(TDocTemplate &)
remove from list
virtual void FileClose()
If the document can be closed it is closed.
virtual void FileRevert()
virtual TDocTemplate * MatchTemplate(LPCTSTR path)
Returns the first registered template whose pattern matches the given file name.
virtual TDocTemplate * SelectAnySave(TDocument &doc, bool samedoc=true)
Select a new docpath for a document from the registered templates supporting the doc.
virtual int SelectDocPath(TDocTemplate **tpllist, int tplcount, tchar *path, int buflen, long flags, bool save=false, TDocument *doc=nullptr)
Given a list of templates, prompts the user to select one of the templates to use for the file to be ...
virtual int SelectDocType(TDocTemplate **tpllist, int tplcount)
Given a list of templates, lets the user select a document type from a list of document templates.
virtual int GetViewTemplates(TDocTemplate **tplList, int size, TDocument &doc)
Build a list of templates for creating views.
void AttachTemplate(TDocTemplate &)
append to list
TDocTemplate is an abstract base class that contains document template functionality.
TDocument * Next(const TDocument *doc)
If the doc parameter is 0, Next returns the first document in the list of documents.
An abstract base class, TDocument is the base class for all document objects and serves as an interfa...
TDvFileOpenDialog encapsulates the FileOpen dialog used by the DocView manager.
TDvFileOpenDialog(TWindow *parent, TDvOpenSaveData &data, LPCTSTR title=nullptr, TModule *module=nullptr)
Constructor of object encapsulating the Open File dialog used by the DocManager.
virtual INT_PTR DialogFunction(TMsgId, TParam1, TParam2)
Overriden virtual function of TFileOpenDialog to allow us to detect when the user switches between fi...
TDvFileSaveDialog encapsulates the FileSave dialog used by the DocView manager.
TDvFileSaveDialog(TWindow *parent, TDvOpenSaveData &data, LPCTSTR title=nullptr, TModule *module=nullptr)
Constructor of object encapsulating the FileSave dialog used by the DocManager.
virtual INT_PTR DialogFunction(TMsgId, TParam1, TParam2)
Overriden virtual function of TFileOpenDialog to allow us to detect when the user switches between fi...
TDvOpenSaveData encapsulates the information used to initialized the Open or Save As dialog box by Ob...
TDvOpenSaveData(uint32 flags, tchar *filter, tchar *initialDir, tchar *defExt, int filterIndex, TDocTemplate **tmplList, int tmplCount)
Constructor of class representing the data to be displayed in the Open/Save dialogs used by the DocMa...
TDvOpenSaveDataOwner is a mixin class used by the DocView encapsulation of the FileOpen and FileSave ...
TDvOpenSaveDataOwner(TDvOpenSaveData &data)
Constructor of mixin.
The TFileName class constructs filenames.
@ File
Filename part without the extension.
TFileOpenDialog is a modal dialog box that lets you specify the name of a file to open.
TFileSaveDialog is a modal dialog box that lets you enter the name of a file to save.
virtual HWND GetCommandTarget()
Locates and returns the child window that is the target of the command and command enable messages.
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
bool PumpWaitingMessages()
The inner message loop.
TOpenSaveDialog is the base class for modal dialogs that let you open and save a file under a specifi...
OPENFILENAME & GetOFN()
Returns the OPENFILENAME structure.
A linked structure in which each node points to a list of TRegList objects (or TRegList-derived objec...
static void AddLink(TRegLink **head, TRegLink *newLink)
Adds a new link to the end of the link list.
static bool RemoveLink(TRegLink **head, TRegLink *remLink)
Removes a link from the link list. Returns true if the link is found and removed.
Abstract base class for view access from document.
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
int MessageBox(LPCTSTR text, LPCTSTR caption=0, uint flags=MB_OK) const
Creates and displays a message box that contains a message (text), a title (caption),...
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
HWND GetHandle() const
Returns the handle of the window.
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition of class TDocManager.
#define DEFINE_RESPONSE_TABLE(cls)
Macro to define a response table for a class with no base response tables.
#define IMPLEMENT_STREAMABLE(cls)
const uint dtNewDoc
create new document, no path used
const uint dtNoAutoView
no automatic create of default view
const uint dtAutoOpen
open document upon creation
const uint dtForbidNew
forbids creating new document
const uint dmNoRevert
Disable FileRevert menu item.
const uint dmSDI
Does not support multiple open documents.
const uint dmMenu
Set IDs for file menu.
const uint dtHidden
hide template from user selection
const uint dmSaveEnable
Enable FileSave even if doc is unmodified.
const uint dtSelected
indicates template last selected
const uint dtSingleView
only a single view per document
@ dnRename
Document has been renamed.
@ dnCreate
New document or view has been created.
@ ofRead
ios::in, open for reading
int LoadString(uint id, TCHAR *buf, int maxChars) const
Loads a string resource identified by id into the buffer pointed to by buff.
HMENU LoadMenu(TResId id) const
Wrapper for the Windows API.
UINT CharSize(const TCHAR *s)
Return the number of bytes of the first character of the passed string.
Object Windows Library (OWLNext Core)
UINT TMsgId
Message ID type.
TDocTemplate * TDocTemplatePtr
LPARAM TParam2
Second parameter type.
WPARAM TParam1
First parameter type.
TAppDictionary & OWLGetAppDictionary()
Global exported TAppDictionary in Owl.
TModule & GetGlobalModule()
Definition of TOpenSave abstract, TFileOpen, TFileSave common Dialog classes.
#define CONST_CAST(targetType, object)
#define COUNTOF(s)
Array element count Important: Only use this with an argument of array type.
Definition of classes TPickListPopup & TPickListDialog.
Definition of class TString, a flexible universal string envelope class.
Definition of TSystem, a system information provider class.
#define EV_COMMAND_ENABLE(id, method)
Response table entry for enabling a command.
#define EV_COMMAND(id, method)
Response table entry for a menu/accelerator/push button message.