home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-09-30 | 5.0 KB | 216 lines | [TEXT/MMCC] |
- // CEditArticle.cp -- dialog methods
- // Created 01/01/95 12:01 PM by AppMaker
-
- #include "CEditArticle.h"
- #include "FileAndFind_OOFILE.h"
-
-
- #include <UReanimator.h>
- #include <LStream.h>
- #include <LStdControl.h>
- #include <LTabGroup.h>
- #include <LTextEdit.h>
- #include <LListBox.h>
- #include <PP_Messages.h>
-
- #define PPob_EditArticleID 202
- #define RidL_EditArticleID 202
-
-
- //----------
- // This is the function you register with URegistrar to create a
- // CEditArticle from a resource
- CEditArticle*
- CEditArticle::CreateEditArticleStream(
- LStream *inStream)
- {
- return (new CEditArticle(inStream));
- }
-
- //----------
- // The default constructor does nothing.
- CEditArticle::CEditArticle()
- {
- }
-
- //----------
- // The read-from-stream constructor just reads a dialog object.
- CEditArticle::CEditArticle(
- LStream *inStream)
- : LDialogBox(inStream)
- {
- }
-
- //----------
- // The destructor does nothing.
- CEditArticle::~CEditArticle()
- {
- }
-
- //----------
- // This member function gets called once the containment hierarchy that contains
- // this pane has been built. It gives us a chance to get data members for
- // interesting subviews, and to do other operations now that our subviews exist.
- void
- CEditArticle::FinishCreateSelf()
- {
- LDialogBox::FinishCreateSelf();
-
- mOKButton = (LStdButton *)FindPaneByID('OK ');
- mCancelButton = (LStdButton *)FindPaneByID('Canl');
- mTitleField = (LTextEdit *)FindPaneByID('Tit2');
- mSourceField = (LTextEdit *)FindPaneByID('Sou2');
- mAuthorsField = (LTextEdit *)FindPaneByID('Aut2');
- mAbstractField = (LTextEdit *)FindPaneByID('Abs2');
- mLocationsList = (LListBox *)FindPaneByID('Locs');
- mAddLocationButton = (LStdButton *)FindPaneByID('Addn');
- mDelLocationButton = (LStdButton *)FindPaneByID('Deln');
- mGoFirstButton = (LStdButton *)FindPaneByID('GoFt');
- mGoPrevButton = (LStdButton *)FindPaneByID('GoPv');
- mGoNextButton = (LStdButton *)FindPaneByID('GoNt');
- mGoLastButton = (LStdButton *)FindPaneByID('GoLt');
-
- LTabGroup *tabGroup = new LTabGroup(this);
- mTitleField->SetSuperCommander(tabGroup); // becomes the active field
- mSourceField->SetSuperCommander(tabGroup);
- mAuthorsField->SetSuperCommander(tabGroup);
- mAbstractField->SetSuperCommander(tabGroup);
-
- UReanimator::LinkListenerToControls(this, this, RidL_EditArticleID);
- // the purpose is to "connect" self to whatever controls
- // that we want to "listen" to
-
- // any additional initialization for your dialog:
-
- }
-
- //----------
- void
- CEditArticle::DoAddArticleLocation()
- {
- }
-
- //----------
- void
- CEditArticle::DoDelArticleLocation()
- {
- }
-
- //----------
- void
- CEditArticle::ListenToMessage(
- MessageT inMessage,
- void *ioParam)
- {
- switch (inMessage) {
- case 'Addn':
- DoAddArticleLocation();
- break;
-
- case 'Deln':
- DoDelArticleLocation();
- break;
-
- default:
- if (!OOFILEhandlesMessage(inMessage, ioParam))
- ; // do something
- break;
- }
- }
-
-
- //----------
- Boolean
- CEditArticle::ObeyCommand(
- CommandT inCommand,
- void *ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
- // Remember to add same cases to FindCommandStatus below
- // to enable/disable the commands
-
- default:
- cmdHandled = OOFILEhandlesMessage(inCommand, ioParam);
- if (!cmdHandled)
- cmdHandled = LDialogBox::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
- //----------
- void
- CEditArticle::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
-
- default:
- LDialogBox::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-
- //----------
- Boolean
- CEditArticle::FocusDraw()
- {
- Boolean focused = LView::FocusDraw();
-
- if (focused) {
- AuxWinHandle awHndl;
- CTabHandle awCTable;
- ColorSpec contentSpec;
-
- GetAuxWin(GetMacPort(), &awHndl);
- awCTable = (**awHndl).awCTable;
- contentSpec = (**awCTable).ctTable [wContentColor]; // should search vs. index
- ::RGBBackColor(&contentSpec.rgb);
- }
-
- return focused;
- }
-
-
- void CEditArticle::SetDatabase(CdbArticles* inArticles)
- {
- // our copy of the database, if we need to change its state in our Do methods
- mArticles = new CdbArticles(*inArticles);
-
- mMainTable = mArticles; // mixin dbEditHelper's copy of pointer, which it deletes for us
- // link fields to controls created in FinishCreateSelf
- LinkField(mArticles->Title(), mTitleField);
- LinkField(mArticles->Source(), mSourceField);
- LinkField(mArticles->Authors(), mAuthorsField);
- LinkField(mArticles->Abstract(), mAbstractField);
- }
-
-
- // lightweight class to wrap creating CEditArticle
-
- LWindow* CEditArticleFactory::makeWindow(const bool loadData) const
- {
- CdbArticles* realTable = (CdbArticles*) mTable; // safe downcast
- // would later use dynamic_cast to test the above
- CEditArticle* dlg = ((CEditArticle *)LWindow::CreateWindow(PPob_EditArticleID, mCommander));
- dlg->SetDatabase(realTable);
- if (loadData)
- dlg->LoadData(); // do separately so SetDatabase doesn't imply updating fields
- return (LWindow*) dlg;
- }
-
-