home *** CD-ROM | disk | FTP | other *** search
- /*
- * CArticleDoc - manage an article document window
- *
- * SUPERCLASS = CEditDoc
- * Copyright ⌐ Tom Bereiter, 1990
- */
-
- #include <CApplication.h>
- #include <CBartender.h>
- #include <CStaticText.h>
- #include "CArticleList.h"
- #include "CArticleDoc.h"
-
-
- extern CApplication *gApplication;
- extern CBartender *gBartender;
-
- #define cmdNext 1030L
- #define cmdUnread 1031L
- #define cmdDetach 1032L
-
-
- extern art_t *next_article(CArticleList *alist, art_t *ap, Boolean zap, Boolean modline);
-
-
- void CArticleDoc::IArticleDoc(CBureaucrat *articlelist, art_t *articlep)
- {
- CEditDoc::IEditDoc(gApplication, FALSE);
- ap = articlep;
- alist = articlelist;
-
- NewFile();
- }
-
- Boolean CArticleDoc::Close(Boolean quitting) {
- CBureaucrat *alist1 = alist; /* need to make copies since a close zaps data */
- art_t *ap1 = ap;
- Boolean detached1 = detached;
- Boolean keepunread1 = keepunread;
-
- if (inherited::Close(quitting) == FALSE)
- return FALSE;
-
- if (!detached1) {
- if (!keepunread1)
- next_article((CArticleList *)alist1, ap1, FALSE, TRUE);
- }
- return TRUE;
- }
-
- void CArticleDoc::NewFile(void)
- {
- extern char *artbuf;
- extern int artlen;
-
- if (readart(ap) < 0) {
- Close(FALSE);
- return;
- }
-
- inherited::NewFile();
-
- CtoPstr(ap->title);
- itsWindow->SetTitle((StringPtr)ap->title);
- PtoCstr(ap->title);
- ((CStaticText *)itsMainPane)->SetFontNumber(monaco);
- ((CStaticText *)itsMainPane)->SetFontSize(9);
-
- ((CStaticText *)itsMainPane)->SetTextPtr(artbuf, artlen);
- }
-
- void CArticleDoc::DoCommand(long theCommand)
- {
- int n, i;
- art_t *old_ap;
- Point top;
- extern char *artbuf;
- extern int artlen;
-
- switch (theCommand) {
-
- case cmdNext: /* next article */
- old_ap = ap;
- ap = next_article((CArticleList *)alist, ap, FALSE, TRUE);
- if (ap == NULL || readart(ap) < 0) {
- Close(FALSE);
- break;
- }
-
- if (ap != old_ap) {
- CtoPstr(ap->title);
- itsWindow->SetTitle((StringPtr)ap->title);
- PtoCstr(ap->title);
- }
- ((CStaticText *)itsMainPane)->SetTextPtr(artbuf, artlen);
- top.h = top.v = 0;
- ((CStaticText *)itsMainPane)->ScrollTo(top, TRUE);
- break;
-
- case cmdUnread: /* close, but keep unread */
- keepunread = TRUE;
- Close(FALSE);
- break;
-
- case cmdDetach:
- detached = TRUE;
- break;
-
- default:
- inherited::DoCommand(theCommand);
- break;
- }
- }
-
- void CArticleDoc::UpdateMenus()
- {
- inherited::UpdateMenus();
-
- if (!detached) {
- if (ap->next || ap->tindex < ap->nthread-1)
- gBartender->EnableCmd(cmdNext);
- gBartender->EnableCmd(cmdUnread);
- gBartender->EnableCmd(cmdDetach);
- }
- }
-