1999-09-27 18:44:28 +00:00
|
|
|
|
/* This file is part of
|
1999-11-15 12:01:38 +00:00
|
|
|
|
* ======================================================
|
1999-10-07 18:44:17 +00:00
|
|
|
|
*
|
|
|
|
|
* LyX, The Document Processor
|
|
|
|
|
*
|
|
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
|
* Copyright 1995-2001 The LyX Team.
|
1999-10-07 18:44:17 +00:00
|
|
|
|
*
|
|
|
|
|
* This file is Copyright 1996-1998
|
|
|
|
|
* Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// Added pseudo-action handling, asierra 180296
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
2000-07-24 13:53:19 +00:00
|
|
|
|
#pragma implementation
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
#include "Toolbar_pimpl.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
|
#include "debug.h"
|
2001-07-03 15:19:04 +00:00
|
|
|
|
#include "XFormsView.h"
|
2001-04-24 17:33:01 +00:00
|
|
|
|
#include "lyxfunc.h"
|
2001-06-27 14:10:35 +00:00
|
|
|
|
#include "func_status.h"
|
2000-07-24 13:53:19 +00:00
|
|
|
|
#include "BufferView.h"
|
|
|
|
|
#include "buffer.h"
|
1999-11-22 16:19:48 +00:00
|
|
|
|
#include "LyXAction.h"
|
2001-03-16 12:08:14 +00:00
|
|
|
|
#include "MathsSymbols.h"
|
2000-07-19 10:22:12 +00:00
|
|
|
|
#include "support/filetools.h"
|
2001-03-07 14:25:31 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2000-07-26 10:30:09 +00:00
|
|
|
|
#include "gettext.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
|
using std::endl;
|
2000-02-15 14:28:15 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
extern LyXAction lyxaction;
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
// some constants
|
|
|
|
|
const int standardspacing = 2; // the usual space between items
|
|
|
|
|
const int sepspace = 6; // extra space
|
|
|
|
|
const int buttonwidth = 30; // the standard button width
|
|
|
|
|
const int height = 30; // the height of all items in the toolbar
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
Toolbar::Pimpl::toolbarItem::toolbarItem() {
|
2000-07-21 18:47:54 +00:00
|
|
|
|
action = LFUN_NOACTION;
|
|
|
|
|
icon = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
Toolbar::Pimpl::toolbarItem::~toolbarItem() {
|
|
|
|
|
clean();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Toolbar::Pimpl::toolbarItem::clean() {
|
2000-07-21 18:47:54 +00:00
|
|
|
|
if (icon) {
|
|
|
|
|
fl_delete_object(icon);
|
|
|
|
|
fl_free_object(icon);
|
|
|
|
|
icon = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
Toolbar::Pimpl::toolbarItem &
|
2000-09-14 17:53:12 +00:00
|
|
|
|
Toolbar::Pimpl::toolbarItem::operator=(toolbarItem const & ti) {
|
2000-07-31 12:51:19 +00:00
|
|
|
|
// Are we assigning the object onto itself?
|
|
|
|
|
if (this == &ti)
|
|
|
|
|
return *this;
|
|
|
|
|
|
|
|
|
|
// If we already have an icon, release it.
|
|
|
|
|
clean();
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
// do we have to check icon too?
|
2000-07-21 18:47:54 +00:00
|
|
|
|
action = ti.action;
|
|
|
|
|
icon = 0; // locally we need to get the icon anew
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
|
|
|
|
|
Toolbar::Pimpl::Pimpl(LyXView * o, int x, int y)
|
2001-07-03 15:19:04 +00:00
|
|
|
|
: owner(static_cast<XFormsView *>(o)), sxpos(x), sypos(y)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
combox = 0;
|
2000-02-15 14:28:15 +00:00
|
|
|
|
#if FL_REVISION < 89
|
1999-09-27 18:44:28 +00:00
|
|
|
|
bubble_timer = 0;
|
2000-02-15 14:28:15 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2000-02-15 14:28:15 +00:00
|
|
|
|
#if FL_REVISION < 89
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// timer-cb for bubble-help (Matthias)
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void BubbleTimerCB(FL_OBJECT *, long data)
|
1999-10-25 14:18:30 +00:00
|
|
|
|
{
|
1999-12-01 00:57:31 +00:00
|
|
|
|
FL_OBJECT * ob = reinterpret_cast<FL_OBJECT*>(data);
|
2000-07-20 11:39:14 +00:00
|
|
|
|
// The trick we use to get the help text is to read the
|
|
|
|
|
// argument of the callback that has been registered for
|
|
|
|
|
// ToolBarCB. (JMarc)
|
2001-01-08 14:19:29 +00:00
|
|
|
|
string help = _(lyxaction.helpText(ob->argument));
|
2000-07-20 11:39:14 +00:00
|
|
|
|
fl_show_oneliner(help.c_str(), ob->form->x + ob->x,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
ob->form->y + ob->y + ob->h);
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-01 00:57:31 +00:00
|
|
|
|
|
|
|
|
|
extern "C" void C_Toolbar_BubbleTimerCB(FL_OBJECT * ob, long data)
|
1999-10-25 14:18:30 +00:00
|
|
|
|
{
|
2000-07-24 13:53:19 +00:00
|
|
|
|
BubbleTimerCB(ob, data);
|
1999-10-25 14:18:30 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-12-01 00:57:31 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// post_handler for bubble-help (Matthias)
|
2000-07-24 13:53:19 +00:00
|
|
|
|
int BubblePost(FL_OBJECT *ob, int event,
|
1999-12-16 06:43:25 +00:00
|
|
|
|
FL_Coord /*mx*/, FL_Coord /*my*/,
|
2001-03-07 14:25:31 +00:00
|
|
|
|
int /*key*/, void * /*xev*/)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-07-24 13:53:19 +00:00
|
|
|
|
FL_OBJECT * bubble_timer = reinterpret_cast<FL_OBJECT *>(ob->u_cdata);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-07-20 11:39:14 +00:00
|
|
|
|
// We do not test for empty help here, since this can never happen
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (event == FL_ENTER){
|
2000-07-24 13:53:19 +00:00
|
|
|
|
fl_set_object_callback(bubble_timer,
|
1999-12-13 00:05:34 +00:00
|
|
|
|
C_Toolbar_BubbleTimerCB,
|
|
|
|
|
reinterpret_cast<long>(ob));
|
2000-07-24 13:53:19 +00:00
|
|
|
|
fl_set_timer(bubble_timer, 1);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2000-11-04 10:00:12 +00:00
|
|
|
|
else if (event != FL_MOTION){
|
2000-07-24 13:53:19 +00:00
|
|
|
|
fl_set_timer(bubble_timer, 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
fl_hide_oneliner();
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-01 00:57:31 +00:00
|
|
|
|
|
|
|
|
|
extern "C" int C_Toolbar_BubblePost(FL_OBJECT * ob, int event,
|
1999-12-16 06:43:25 +00:00
|
|
|
|
FL_Coord /*mx*/, FL_Coord /*my*/,
|
|
|
|
|
int key, void * xev)
|
1999-10-25 14:18:30 +00:00
|
|
|
|
{
|
2000-07-24 13:53:19 +00:00
|
|
|
|
return BubblePost(ob, event, 0, 0, key, xev);
|
1999-10-25 14:18:30 +00:00
|
|
|
|
}
|
2000-02-15 14:28:15 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
|
// this one is not "C" because combox callbacks are really C++ %-|
|
2001-09-06 12:42:47 +00:00
|
|
|
|
void Toolbar::Pimpl::layoutSelectedCB(int, void * arg, Combox *)
|
2001-03-07 14:25:31 +00:00
|
|
|
|
{
|
|
|
|
|
Toolbar::Pimpl * tb = reinterpret_cast<Toolbar::Pimpl *>(arg);
|
|
|
|
|
|
2001-09-06 12:42:47 +00:00
|
|
|
|
tb->layoutSelected();
|
2001-03-07 14:25:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-09-06 12:42:47 +00:00
|
|
|
|
void Toolbar::Pimpl::layoutSelected()
|
2001-03-07 14:25:31 +00:00
|
|
|
|
{
|
2001-09-06 12:42:47 +00:00
|
|
|
|
owner->getLyXFunc()->dispatch(LFUN_LAYOUT, combox->getline());
|
2001-03-07 14:25:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-12-01 00:57:31 +00:00
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void Toolbar::Pimpl::activate()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-07-20 11:39:14 +00:00
|
|
|
|
ToolbarList::const_iterator p = toollist.begin();
|
2000-08-03 21:17:52 +00:00
|
|
|
|
ToolbarList::const_iterator end = toollist.end();
|
|
|
|
|
for (; p != end; ++p) {
|
2000-07-20 11:39:14 +00:00
|
|
|
|
if (p->icon) {
|
|
|
|
|
fl_activate_object(p->icon);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void Toolbar::Pimpl::deactivate()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-07-20 11:39:14 +00:00
|
|
|
|
ToolbarList::const_iterator p = toollist.begin();
|
2000-08-03 21:17:52 +00:00
|
|
|
|
ToolbarList::const_iterator end = toollist.end();
|
|
|
|
|
for (; p != end; ++p) {
|
2000-07-20 11:39:14 +00:00
|
|
|
|
if (p->icon) {
|
|
|
|
|
fl_deactivate_object(p->icon);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void Toolbar::Pimpl::update()
|
2000-07-20 11:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
ToolbarList::const_iterator p = toollist.begin();
|
2000-08-03 21:17:52 +00:00
|
|
|
|
ToolbarList::const_iterator end = toollist.end();
|
|
|
|
|
for (; p != end; ++p) {
|
2000-07-20 11:39:14 +00:00
|
|
|
|
if (p->icon) {
|
|
|
|
|
int status = owner->getLyXFunc()->getStatus(p->action);
|
2001-06-27 14:10:35 +00:00
|
|
|
|
if (status & func_status::ToggleOn) {
|
2000-07-20 11:39:14 +00:00
|
|
|
|
// I'd like to use a different color
|
|
|
|
|
// here, but then the problem is to
|
|
|
|
|
// know how to use transparency with
|
|
|
|
|
// Xpm library. It seems pretty
|
|
|
|
|
// complicated to me (JMarc)
|
2000-07-20 12:39:25 +00:00
|
|
|
|
fl_set_object_color(p->icon, FL_LEFT_BCOL, FL_BLUE);
|
2000-07-20 11:39:14 +00:00
|
|
|
|
fl_set_object_boxtype(p->icon, FL_DOWN_BOX);
|
|
|
|
|
} else {
|
2000-07-20 12:39:25 +00:00
|
|
|
|
fl_set_object_color(p->icon, FL_MCOL, FL_BLUE);
|
2000-07-20 11:39:14 +00:00
|
|
|
|
fl_set_object_boxtype(p->icon, FL_UP_BOX);
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
|
if (status & func_status::Disabled) {
|
2000-07-20 11:39:14 +00:00
|
|
|
|
// Is there a way here to specify a
|
|
|
|
|
// mask in order to show that the
|
|
|
|
|
// button is disabled? (JMarc)
|
|
|
|
|
fl_deactivate_object(p->icon);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fl_activate_object(p->icon);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void Toolbar::Pimpl::setLayout(int layout) {
|
2001-09-06 12:42:47 +00:00
|
|
|
|
if (combox) {
|
|
|
|
|
LyXTextClass const & tc =
|
|
|
|
|
textclasslist.TextClass(owner->buffer()->
|
|
|
|
|
params.textclass);
|
|
|
|
|
combox->select(tc[layout].name());
|
|
|
|
|
}
|
2000-07-24 13:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Toolbar::Pimpl::updateLayoutList(bool force)
|
|
|
|
|
{
|
|
|
|
|
// Update the layout display
|
|
|
|
|
if (!combox) return;
|
|
|
|
|
|
|
|
|
|
// If textclass is different, we need to update the list
|
|
|
|
|
if (combox->empty() || force) {
|
|
|
|
|
combox->clear();
|
|
|
|
|
LyXTextClass const & tc =
|
|
|
|
|
textclasslist.TextClass(owner->buffer()->
|
|
|
|
|
params.textclass);
|
2000-08-03 21:17:52 +00:00
|
|
|
|
LyXTextClass::const_iterator end = tc.end();
|
2000-07-24 13:53:19 +00:00
|
|
|
|
for (LyXTextClass::const_iterator cit = tc.begin();
|
2000-08-03 21:17:52 +00:00
|
|
|
|
cit != end; ++cit) {
|
2001-09-06 12:42:47 +00:00
|
|
|
|
// ignore obsolete entries
|
2001-07-12 11:11:10 +00:00
|
|
|
|
if (cit->obsoleted_by().empty())
|
|
|
|
|
combox->addline(_(cit->name()));
|
2000-07-24 13:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// we need to do this.
|
2001-09-06 12:42:47 +00:00
|
|
|
|
combox->redraw();
|
2000-07-24 13:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void Toolbar::Pimpl::clearLayoutList()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-07-24 13:53:19 +00:00
|
|
|
|
if (combox) {
|
|
|
|
|
combox->clear();
|
2001-09-06 12:42:47 +00:00
|
|
|
|
combox->redraw();
|
2000-07-24 13:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void Toolbar::Pimpl::openLayoutList()
|
|
|
|
|
{
|
|
|
|
|
if (combox)
|
2001-09-06 12:42:47 +00:00
|
|
|
|
combox->show();
|
2000-07-24 13:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void ToolbarCB(FL_OBJECT * ob, long ac)
|
|
|
|
|
{
|
2001-07-03 15:19:04 +00:00
|
|
|
|
XFormsView * owner = static_cast<XFormsView *>(ob->u_vdata);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-07-16 15:42:57 +00:00
|
|
|
|
string res = owner->getLyXFunc()->dispatch(int(ac));
|
2000-11-04 10:00:12 +00:00
|
|
|
|
if (!res.empty())
|
2000-07-25 10:46:18 +00:00
|
|
|
|
lyxerr[Debug::GUI] << "ToolbarCB: Function returned: "
|
|
|
|
|
<< res << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
} // namespace anon
|
|
|
|
|
|
1999-12-01 00:57:31 +00:00
|
|
|
|
|
|
|
|
|
extern "C" void C_Toolbar_ToolbarCB(FL_OBJECT * ob, long data)
|
1999-10-25 14:18:30 +00:00
|
|
|
|
{
|
2000-07-24 13:53:19 +00:00
|
|
|
|
ToolbarCB(ob, data);
|
1999-10-25 14:18:30 +00:00
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-10-11 21:06:43 +00:00
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2000-07-19 10:22:12 +00:00
|
|
|
|
void setPixmap(FL_OBJECT * obj, int action, int buttonwidth, int height) {
|
|
|
|
|
string name, arg, xpm_name;
|
|
|
|
|
kb_action act;
|
|
|
|
|
|
|
|
|
|
if (lyxaction.isPseudoAction(action)) {
|
|
|
|
|
act = lyxaction.retrieveActionArg(action, arg);
|
|
|
|
|
name = lyxaction.getActionName(act);
|
|
|
|
|
xpm_name = subst(name + ' ' + arg, ' ','_');
|
|
|
|
|
} else {
|
|
|
|
|
act = (kb_action)action;
|
|
|
|
|
name = lyxaction.getActionName(action);
|
|
|
|
|
xpm_name = name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string fullname = LibFileSearch("images", xpm_name, "xpm");
|
|
|
|
|
|
|
|
|
|
if (!fullname.empty()) {
|
2000-07-24 13:53:19 +00:00
|
|
|
|
lyxerr[Debug::GUI] << "Full icon name is `"
|
2000-07-19 10:22:12 +00:00
|
|
|
|
<< fullname << "'" << endl;
|
|
|
|
|
fl_set_pixmapbutton_file(obj, fullname.c_str());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (act == LFUN_INSERT_MATH && !arg.empty()) {
|
|
|
|
|
char const ** pixmap = get_pixmap_from_symbol(arg.c_str(),
|
|
|
|
|
buttonwidth,
|
|
|
|
|
height);
|
2000-11-03 16:45:08 +00:00
|
|
|
|
if (pixmap) {
|
|
|
|
|
lyxerr[Debug::GUI] << "Using mathed-provided icon"
|
|
|
|
|
<< endl;
|
|
|
|
|
fl_set_pixmapbutton_data(obj,
|
|
|
|
|
const_cast<char **>(pixmap));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2000-07-19 10:22:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lyxerr << "Unable to find icon `" << xpm_name << "'" << endl;
|
|
|
|
|
fullname = LibFileSearch("images", "unknown", "xpm");
|
|
|
|
|
if (!fullname.empty()) {
|
2000-07-24 13:53:19 +00:00
|
|
|
|
lyxerr[Debug::GUI] << "Using default `unknown' icon"
|
2000-07-19 10:22:12 +00:00
|
|
|
|
<< endl;
|
|
|
|
|
fl_set_pixmapbutton_file(obj, fullname.c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void Toolbar::Pimpl::set(bool doingmain)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
// we shouldn't set if we have not cleaned
|
|
|
|
|
if (!cleaned) return;
|
|
|
|
|
|
1999-12-01 00:57:31 +00:00
|
|
|
|
FL_OBJECT * obj;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
if (!doingmain) {
|
|
|
|
|
fl_freeze_form(owner->getForm());
|
|
|
|
|
fl_addto_form(owner->getForm());
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-15 14:28:15 +00:00
|
|
|
|
#if FL_REVISION < 89
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// add the time if it don't exist
|
1999-10-02 16:21:10 +00:00
|
|
|
|
if (bubble_timer == 0)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
bubble_timer = fl_add_timer(FL_HIDDEN_TIMER,
|
1999-11-15 12:01:38 +00:00
|
|
|
|
xpos, ypos, 0, 0, "Timer");
|
2000-02-15 14:28:15 +00:00
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-07-20 11:39:14 +00:00
|
|
|
|
ToolbarList::iterator item = toollist.begin();
|
2000-08-03 21:17:52 +00:00
|
|
|
|
ToolbarList::iterator end = toollist.end();
|
|
|
|
|
for (; item != end; ++item) {
|
2000-11-04 10:00:12 +00:00
|
|
|
|
switch (item->action){
|
2000-07-24 13:53:19 +00:00
|
|
|
|
case ToolbarDefaults::SEPARATOR:
|
1999-12-16 06:43:25 +00:00
|
|
|
|
xpos += sepspace;
|
|
|
|
|
break;
|
2000-07-24 13:53:19 +00:00
|
|
|
|
case ToolbarDefaults::NEWLINE:
|
|
|
|
|
// Not supported yet.
|
|
|
|
|
break;
|
|
|
|
|
case ToolbarDefaults::LAYOUTS:
|
1999-12-16 06:43:25 +00:00
|
|
|
|
xpos += standardspacing;
|
|
|
|
|
if (!combox)
|
|
|
|
|
combox = new Combox(FL_COMBOX_DROPLIST);
|
2000-02-08 15:13:01 +00:00
|
|
|
|
combox->add(xpos, ypos, 135, height, 400);
|
2001-03-07 14:25:31 +00:00
|
|
|
|
combox->setcallback(layoutSelectedCB, this);
|
1999-12-16 06:43:25 +00:00
|
|
|
|
combox->resize(FL_RESIZE_ALL);
|
|
|
|
|
combox->gravity(NorthWestGravity, NorthWestGravity);
|
|
|
|
|
xpos += 135;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
xpos += standardspacing;
|
|
|
|
|
item->icon = obj =
|
|
|
|
|
fl_add_pixmapbutton(FL_NORMAL_BUTTON,
|
|
|
|
|
xpos, ypos,
|
|
|
|
|
buttonwidth,
|
|
|
|
|
height, "");
|
|
|
|
|
fl_set_object_resize(obj, FL_RESIZE_ALL);
|
|
|
|
|
fl_set_object_gravity(obj,
|
|
|
|
|
NorthWestGravity,
|
|
|
|
|
NorthWestGravity);
|
|
|
|
|
fl_set_object_callback(obj, C_Toolbar_ToolbarCB,
|
|
|
|
|
static_cast<long>(item->action));
|
|
|
|
|
// Remove the blue feedback rectangle
|
|
|
|
|
fl_set_pixmapbutton_focus_outline(obj, 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-02-15 14:28:15 +00:00
|
|
|
|
// Set the tooltip
|
2000-07-20 11:39:14 +00:00
|
|
|
|
#if FL_REVISION >= 89
|
2001-08-06 19:13:25 +00:00
|
|
|
|
string const help(_(lyxaction.helpText(item->action)));
|
2000-07-20 11:39:14 +00:00
|
|
|
|
fl_set_object_helper(obj, help.c_str());
|
2000-02-15 14:28:15 +00:00
|
|
|
|
#else
|
1999-12-16 06:43:25 +00:00
|
|
|
|
fl_set_object_posthandler(obj, C_Toolbar_BubblePost);
|
2000-07-24 13:53:19 +00:00
|
|
|
|
obj->u_cdata = reinterpret_cast<char *>(bubble_timer);
|
2000-02-15 14:28:15 +00:00
|
|
|
|
#endif
|
1999-12-16 06:43:25 +00:00
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
// The view that this object belongs to.
|
|
|
|
|
obj->u_vdata = owner;
|
2000-07-20 11:39:14 +00:00
|
|
|
|
|
2000-07-19 10:22:12 +00:00
|
|
|
|
setPixmap(obj, item->action, buttonwidth, height);
|
1999-12-16 06:43:25 +00:00
|
|
|
|
// we must remember to update the positions
|
|
|
|
|
xpos += buttonwidth;
|
|
|
|
|
// ypos is constant
|
|
|
|
|
/* Here will come a check to see if the new
|
|
|
|
|
* pos is within the bounds of the main frame,
|
|
|
|
|
* and perhaps wrap the toolbar if not.
|
|
|
|
|
*/
|
|
|
|
|
break;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (!doingmain) {
|
|
|
|
|
fl_end_form();
|
|
|
|
|
fl_unfreeze_form(owner->getForm());
|
|
|
|
|
// Should be safe to do this here.
|
|
|
|
|
owner->updateLayoutChoice();
|
|
|
|
|
}
|
2000-07-20 11:39:14 +00:00
|
|
|
|
|
|
|
|
|
// set the state of the icons
|
|
|
|
|
//update();
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
cleaned = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void Toolbar::Pimpl::add(int action, bool doclean)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
|
|
|
|
if (doclean && !cleaned) clean();
|
|
|
|
|
|
|
|
|
|
// this is what we do if we want to add to an existing
|
|
|
|
|
// toolbar.
|
|
|
|
|
if (!doclean && owner) {
|
2000-07-19 10:22:12 +00:00
|
|
|
|
// first "hide" the toolbar buttons. This is not a real hide
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// actually it deletes and frees the button altogether.
|
2000-07-20 11:39:14 +00:00
|
|
|
|
lyxerr << "Toolbar::add: \"hide\" the toolbar buttons."
|
|
|
|
|
<< endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
lightReset();
|
|
|
|
|
|
|
|
|
|
fl_freeze_form(owner->getForm());
|
2000-07-20 11:39:14 +00:00
|
|
|
|
|
|
|
|
|
ToolbarList::iterator p = toollist.begin();
|
2000-08-03 21:17:52 +00:00
|
|
|
|
ToolbarList::iterator end = toollist.end();
|
|
|
|
|
for (; p != end; ++p) {
|
2000-07-20 11:39:14 +00:00
|
|
|
|
p->clean();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2000-07-20 11:39:14 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (combox) {
|
|
|
|
|
delete combox;
|
|
|
|
|
combox = 0;
|
|
|
|
|
}
|
|
|
|
|
fl_unfreeze_form(owner->getForm());
|
|
|
|
|
cleaned = true; // this is not completely true, but OK anyway
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// there exist some special actions not part of
|
|
|
|
|
// kb_action: SEPARATOR, LAYOUTS
|
|
|
|
|
|
2000-07-20 11:39:14 +00:00
|
|
|
|
toolbarItem newItem;
|
|
|
|
|
newItem.action = action;
|
|
|
|
|
toollist.push_back(newItem);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void Toolbar::Pimpl::clean()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-07-20 11:39:14 +00:00
|
|
|
|
//reset(); // I do not understand what this reset() is, anyway
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
//now delete all the objects..
|
|
|
|
|
if (owner)
|
|
|
|
|
fl_freeze_form(owner->getForm());
|
2000-07-20 11:39:14 +00:00
|
|
|
|
|
|
|
|
|
// G++ vector does not have clear defined
|
|
|
|
|
//toollist.clear();
|
|
|
|
|
toollist.erase(toollist.begin(), toollist.end());
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
lyxerr[Debug::GUI] << "Combox: " << combox << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (combox) {
|
|
|
|
|
delete combox;
|
|
|
|
|
combox = 0;
|
|
|
|
|
}
|
2000-07-20 11:39:14 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
if (owner)
|
|
|
|
|
fl_unfreeze_form(owner->getForm());
|
2000-07-24 13:53:19 +00:00
|
|
|
|
lyxerr[Debug::GUI] << "toolbar cleaned" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
cleaned = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void Toolbar::Pimpl::push(int nth)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2000-07-24 13:53:19 +00:00
|
|
|
|
lyxerr[Debug::GUI] << "Toolbar::push: trying to trigger no `"
|
1999-10-07 18:44:17 +00:00
|
|
|
|
<< nth << '\'' << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-07-20 11:39:14 +00:00
|
|
|
|
if (nth <= 0 || nth >= int(toollist.size())) {
|
|
|
|
|
// item nth not found...
|
|
|
|
|
return;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2000-07-20 11:39:14 +00:00
|
|
|
|
|
|
|
|
|
fl_trigger_object(toollist[nth - 1].icon);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void Toolbar::Pimpl::reset()
|
2000-04-04 00:19:15 +00:00
|
|
|
|
{
|
2000-07-20 11:39:14 +00:00
|
|
|
|
//toollist = 0; // what is this supposed to do?
|
2000-04-04 00:19:15 +00:00
|
|
|
|
cleaned = false;
|
|
|
|
|
lightReset();
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-03 15:19:04 +00:00
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void Toolbar::Pimpl::lightReset() {
|
|
|
|
|
xpos = sxpos - standardspacing;
|
|
|
|
|
ypos = sypos;
|
|
|
|
|
}
|