1
// mailboxmenu.cc for bbmail - an tool for display the mail in X11.
3
// Copyright (c) 1998-2000 by John Kennis, jkennis@chello.nl
5
// This program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 2 of the License, or
8
// (at your option) any later version.
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
// (See the included file COPYING / GPL-2.0)
21
#include "mailboxmenu.hh"
23
Mailboxmenu::Mailboxmenu(ToolWindow *toolwindow) :
29
setTitleVisibility(False);
32
setAlignment(AlignBottom);
35
word_length = new int [bbtool->getResource()->report.number_of_spoolfiles];
36
for (i=0;i<bbtool->getResource()->report.number_of_spoolfiles;i++) {
37
insert(&bbtool->getResource()->spoolfile[i].name);
38
word_length[i]=strlen(bbtool->getResource()->spoolfile[i].name);
40
insert("Reconfigure");
45
Mailboxmenu::~Mailboxmenu(void)
47
delete [] word_length;
50
void Mailboxmenu::ClearMenu()
54
for (i=0;i<=bbtool->getResource()->report.number_of_spoolfiles;i++)
58
delete [] word_length;
61
void Mailboxmenu::Reconfigure()
65
word_length = new int [bbtool->getResource()->report.number_of_spoolfiles];
66
for (i=0;i<bbtool->getResource()->report.number_of_spoolfiles;i++) {
67
insert(&bbtool->getResource()->spoolfile[i].name);
68
word_length[i]=strlen(bbtool->getResource()->spoolfile[i].name);
70
insert("Reconfigure");
72
Basemenu::reconfigure();
76
void Mailboxmenu::Move(int x, int y, bool withdrawn)
80
y= y - getHeight() -1;
81
if ((x+getWidth())>bbtool->getCurrentScreenInfo()->getWidth())
82
x=bbtool->getCurrentScreenInfo()->getWidth()-getWidth();
84
y=y_old+bbtool->Frame().height;
87
x= x - getWidth() - 6;
89
x=x + getWidth() + 12;
92
if (y+getHeight()>bbtool->getCurrentScreenInfo()->getHeight())
93
y=bbtool->getCurrentScreenInfo()->getHeight()-getHeight();
99
void Mailboxmenu::UpdateNumbers(int newmail, int totalmail,int spoolno)
103
bbtool->getResource()->spoolfile[spoolno].name[word_length[spoolno]]='\0';
104
sprintf(dummy," (%u/%u)",newmail,totalmail);
105
strcat(bbtool->getResource()->spoolfile[spoolno].name,dummy);
107
setHighlight(spoolno);
108
Basemenu::reconfigure();
111
void Mailboxmenu::Update()
113
wait_for_update=False;
117
void Mailboxmenu::itemSelected(int button, int index)
120
if (index < bbtool->getResource()->report.number_of_spoolfiles) {
121
system(bbtool->getResource()->spoolfile[index].runCommand);
122
} else if (index == bbtool->getResource()->report.number_of_spoolfiles) {
123
bbtool->reconfigure();
124
} else if (index == bbtool->getResource()->report.number_of_spoolfiles+1) {
128
bbtool->EnvelopePushed(False);
129
bbtool->Redraw(False);
133
void Mailboxmenu::show(void)
135
XRaiseWindow(bbtool->getXDisplay(), getWindowID());