home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
source
/
netnwscd.sit
/
CArticleList.c
< prev
next >
Wrap
Text File
|
1990-10-16
|
3KB
|
150 lines
/*
* CArticleList - manage an article list window
*
* SUPERCLASS = CListWind
* Copyright ⌐ Tom Bereiter, 1990
*/
#include <Commands.h>
#include <CBartender.h>
#include "CGroupList.h"
#include "CArticleDoc.h"
#include "CArticleList.h"
#define WINDreg 500 /* Resource ID for WIND template */
extern CBartender *gBartender;
extern short gClicks; /* Click counter, = 1 single click */
art_t *next_article(CArticleList *alist, art_t *ap, Boolean zap, Boolean modline);
void CArticleList::IArticleList(CBureaucrat *grouplist, grp_t *gp)
{
CListWind::IListWind(WINDreg, gp->gname, 80, 24);
groupptr = gp;
glist = grouplist;
ReDo();
}
void CArticleList::Dispose(void) {
dispose_artlist(groupptr);
inherited::Dispose();
}
Boolean CArticleList::Close(Boolean quitting) {
return inherited::Close(quitting);
}
void CArticleList::DoCommand(long theCommand)
{
int n, i, sub, lastl;
art_t *ap;
bitmap_t *bm;
switch (theCommand) {
case cmdClear: /* remove all selected */
bm = itsPane->GetSelect(bmTOTAL(groupptr));
sub = n = 0;
lastl = -1;
for (ap = groupptr->art_head,i=0; ap; i++) { /* for each selected cell */
if (Btst(bm, i))
ap = next_article(this, ap, TRUE, FALSE);
else {
ap=ap->next;
/* delete lines [n-i] */
if (n != i) {
itsPane->DelLine(n-sub, i-n);
lastl = (n-sub);
sub += (i-n);
}
n = i+1;
}
}
if (n != i) {
itsPane->DelLine(n-sub, i-n);
lastl = (n-sub);
}
DisposPtr(bm);
if (lastl > 0)
itsPane->SelectLine(lastl);
((CGroupList *)glist)->ReDoLine(groupptr);
if (groupptr->art_head == NULL)
Close(FALSE);
break;
default:
inherited::DoCommand(theCommand);
break;
}
}
void CArticleList::UpdateMenus()
{
inherited::UpdateMenus();
gBartender->EnableCmd(cmdClear);
}
void CArticleList::Dawdle(long *maxSleep)
{
}
void CArticleList::ReDo()
{
char buf[100];
art_t *ap;
Enab(0);
for (ap=groupptr->art_head; ap; ap = ap->next) {
sprintf(buf,"%5u %s%.90s", ap->nthread-ap->tindex, ap->re?"Re: ":"",ap->title);
itsPane->AddLine(buf);
}
Enab(1);
}
void CArticleList::ModLine(art_t *line_ap, int what)
{
art_t *ap;
char buf[128];
int n;
for (ap=groupptr->art_head,n=0; ap; ap = ap->next,n++)
if (ap == line_ap)
goto found;
return;
found:
switch(what) {
case 0: /* remove */
itsPane->DelLine(n, 1);
itsPane->SelectLine(n);
break;
case 1: /* redisplay */
sprintf(buf,"%5u %s%.90s", ap->nthread-ap->tindex, ap->re?"Re: ":"",ap->title);
itsPane->SetLine(n, buf);
break;
}
((CGroupList *)glist)->ReDoLine(groupptr);
}
void CArticleList::ClickLine(int line)
{
CArticleDoc *doc;
art_t *ap;
int n;
if (gClicks == 2 && lastclickline == line) { /* double-click: open article */
for (ap=groupptr->art_head,n=0; ap; ap = ap->next,n++)
if (n == line) {
doc = new(CArticleDoc);
doc->IArticleDoc(this, ap);
return;
}
}
lastclickline = line;
}