+2000-08-09 Juergen Vigna <jug@sad.it>
+
+ * src/insets/insettext.C (draw): small fix for clearing rectangle.
+
+ * src/insets/insettabular.C: make drawing of single cell smarter.
+
+2000-08-09 Marko Vendelin <markov@ioc.ee>
+ * src/frontends/gnome/Menubar_pimpl.C
+ * src/frontends/gnome/Menubar_pimpl.h: Gnome frontend Menubar
+ implementation: new files
+
+ * src/frontends/gnome/mainapp.C
+ * src/frontends/gnome/mainapp.h: Gnome main window (temporary
+ implementation)
+
+ * src/main.C: create Gnome main window
+
+ * src/frontends/xforms/Menubar_pimpl.h
+ * src/frontends/Menubar.C
+ * src/frontends/Menubar.h: added method Menubar::update that calls
+ Menubar_pimpl::update and xforms/Menubar_pimpl::update (empty one)
+
+ * src/LyXView.C: calls Menubar::update to update the state
+ of menu items
+
+ * src/frontends/gnome/Makefile.am: added new files
+
+ * src/frontends/Makefile.am: added frontend compiler options
+
2000-08-08 Juergen Vigna <jug@sad.it>
* src/lyx_cb.C (AutoSave): autosave for unnamed files enabled!
src/frontends/xforms/form_preferences.C
src/frontends/xforms/FormPrint.C
src/frontends/xforms/form_print.C
+src/frontends/xforms/FormRef.C
+src/frontends/xforms/form_ref.C
+src/frontends/xforms/forms/form_citation.C
+src/frontends/xforms/forms/form_copyright.C
+src/frontends/xforms/forms/form_graphics.C
+src/frontends/xforms/forms/form_preferences.C
+src/frontends/xforms/forms/form_print.C
+src/frontends/xforms/forms/form_tabular.C
+src/frontends/xforms/forms/form_url.C
src/frontends/xforms/FormTabular.C
src/frontends/xforms/form_tabular.C
src/frontends/xforms/FormToc.C
src/insets/insetmarginal.C
src/insets/insetminipage.C
src/insets/insetparent.C
-src/insets/insetref.C
src/insets/insettabular.C
src/insets/insettext.C
src/insets/insettheorem.C
// Make sure the buttons are disabled if needed.
toolbar->update();
+ menubar->update();
dialogs_ = new Dialogs(this);
// temporary until all dialogs moved into Dialogs.
void LyXView::updateToolbar()
{
toolbar->update();
+ menubar->update();
}
{
getMiniBuffer()->Set(CurrentState(view()));
getToolbar()->update();
+ menubar->update();
}
MAINTAINERCLEANFILES = $(srcdir)/Makefile.in
SUBDIRS = @FRONTEND@
ETAGS_ARGS = --lang=c++
-INCLUDES = -I${srcdir}/.. -I${srcdir}/@FRONTEND@
+INCLUDES = ${FRONTEND_INCLUDES} -I${srcdir}/.. -I${srcdir}/@FRONTEND@ ${SIGC_CFLAGS}
LIBS =
noinst_LTLIBRARIES = libfrontends.la
libfrontends_la_SOURCES=\
{
pimpl_->openByName(name);
}
+
+void Menubar::update()
+{
+ pimpl_->update();
+}
void set(string const &);
/// Opens a top-level submenu given its name
void openByName(string const &);
+ /// update the state of the menuitems
+ void update();
//I disable this temporarily until I find a nice way to make it work
//with compaq cxx. (Jean-Marc)
// Is this a new comment? (Lgb)
struct Pimpl;
- ///
friend struct Pimpl;
private:
- ///
Pimpl * pimpl_;
};
#endif
Menubar_pimpl.C \
Menubar_pimpl.h \
Toolbar_pimpl.C \
- Toolbar_pimpl.h
+ Toolbar_pimpl.h \
+ mainapp.C \
+ mainapp.h
# These still have to be added. Sooner or later. ARRae-20000411
# GUI_defaults.C \
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2000 The LyX Team.
+ *
+ * ====================================================== */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+
+#include <algorithm>
+#include <cctype>
+#include "support/lstrings.h"
+#include "support/filetools.h"
+#include "support/StrPool.h"
+#include "support/LAssert.h"
+#include "debug.h"
+#include "LyXAction.h"
+#include "lyxfunc.h"
+#include "kbmap.h"
+#include "bufferlist.h"
+#include "lastfiles.h"
+#include "LyXView.h"
+#include "MenuBackend.h"
+#include "Menubar_pimpl.h"
+
+#include "mainapp.h"
+
+using SigC::slot;
+using SigC::bind;
+
+using std::endl;
+
+// temporary solution for LyXView
+extern GLyxAppWin * mainAppWin;
+
+// Some constants
+extern LyXAction lyxaction;
+extern BufferList bufferlist;
+extern LastFiles * lastfiles;
+
+
+
+Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mb)
+ : owner_(view), menubackend_(&mb), ignore_action_(false)
+{
+ // Should we do something here?
+}
+
+Menubar::Pimpl::~Pimpl()
+{
+ // Should we do something here?
+}
+
+void Menubar::Pimpl::set(string const & menu_name)
+{
+ // if (current_menu_name_ != menu_name) // disabled until Lastfiles and Documents are added dynamically to menu
+ {
+ current_menu_name_ = menu_name;
+ // compose new menu
+ vector<Gnome::UI::Info> menus;
+ composeUIInfo(current_menu_name_, menus);
+
+ // set menu
+ Menu_ = menus;
+ mainAppWin->set_menu(Menu_);
+
+ // connect all menu items to correspoding action
+ wid_act_.clear();
+ ignore_action_ = true;
+ connectWidgetToAction(Menu_.gtkobj());
+ ignore_action_ = false;
+
+ // update state of the items
+ update();
+ }
+}
+
+void Menubar::Pimpl::callback(int action)
+{
+ // Dispatch action OR record action to local variable (see connectWidgetToAction)
+ if (!ignore_action_) owner_->getLyXFunc()->Dispatch(action);
+ else action_ = action;
+}
+
+void Menubar::Pimpl::composeUIInfo(string const & menu_name, vector<Gnome::UI::Info> & Menus)
+{
+ if (!menubackend_->hasMenu(menu_name))
+ {
+ cout << "ERROR:composeUIInfo: Unknown menu `" << menu_name
+ << "'" << endl;
+ return;
+ }
+
+ Menu menu = menubackend_->getMenu(menu_name);
+
+ for (Menu::const_iterator i = menu.begin(); i != menu.end(); ++i)
+ {
+ MenuItem item = (*i);
+ switch(item.kind()) {
+
+ case MenuItem::Command: {
+ string label = item.label();
+ if (label.find(item.shortcut()) != string::npos)
+ label.insert(label.find(item.shortcut()), "_");
+
+ LyXFunc::func_status flag = owner_->getLyXFunc()->getStatus(item.action());
+
+ Gnome::UI::Info gitem;
+ SigC::Slot0<void> cback = bind<int>(slot(this, &Menubar::Pimpl::callback),item.action());
+
+ {
+ using namespace Gnome::MenuItems;
+ string actionname = lyxaction.getActionName(item.action());
+ if ( actionname == "buffer-open") gitem = Open(cback);
+ else if ( actionname == "lyx-quit") gitem = Exit(cback);
+ else if ( actionname == "buffer-close") gitem = Close(cback);
+ else if ( actionname == "buffer-write") gitem = Save(cback);
+ else if ( actionname == "buffer-write-as") gitem = SaveAs(cback);
+ else if ( actionname == "buffer-print") gitem = Print(cback);
+ else if ( actionname == "cut") gitem = Cut(cback);
+ else if ( actionname == "copy") gitem = Copy(cback);
+ else if ( actionname == "paste") gitem = Paste(cback);
+ else if ( actionname == "undo") gitem = Gnome::MenuItems::Undo(cback); // confused with class Undo
+ else if ( actionname == "redo") gitem = Redo(cback);
+ else if ( actionname == "dialog-preferences") gitem = Preferences(cback);
+ else if ( actionname == "buffer-new")
+ gitem = Gnome::UI::Item(Gnome::UI::Icon(GNOME_STOCK_MENU_NEW),
+ label, cback, lyxaction.helpText(item.action()));
+ else if ( actionname == "buffer-new-template")
+ gitem = Gnome::UI::Item(Gnome::UI::Icon(GNOME_STOCK_MENU_NEW),
+ label, cback, lyxaction.helpText(item.action()));
+ else if ( actionname == "find-replace" )
+ gitem = Gnome::UI::Item(Gnome::UI::Icon(GNOME_STOCK_MENU_SRCHRPL),
+ label, cback, lyxaction.helpText(item.action()));
+ else if ( actionname == "spellchecker" )
+ gitem = Gnome::UI::Item(Gnome::UI::Icon(GNOME_STOCK_MENU_SPELLCHECK),
+ label, cback, lyxaction.helpText(item.action()));
+// else if ( actionname == "" )
+// gitem = Gnome::UI::Item(Gnome::UI::Icon(),
+// label, cback, lyxaction.helpText(item.action()));
+ else gitem = Gnome::UI::Item(label, cback, lyxaction.helpText(item.action()));
+ }
+
+ // DON'T KNOW HOW TO TOGGLE/UNTOGGLE IT (Marko)
+ if ((flag & LyXFunc::ToggleOn) || (flag & LyXFunc::ToggleOff))
+ gitem = Gnome::UI::ToggleItem(label, cback, lyxaction.helpText(item.action()));
+
+ Menus.push_back(gitem);
+ break;
+ }
+
+ case MenuItem::Submenu: {
+ vector<Gnome::UI::Info> submenu;
+ string label = item.label();
+ if (label.find(item.shortcut()) != string::npos)
+ label.insert(label.find(item.shortcut()), "_");
+ composeUIInfo(item.submenu(), submenu);
+ Menus.push_back(Gnome::UI::Menu(label,submenu,label));
+ break;
+ }
+
+ case MenuItem::Separator: {
+ Menus.push_back(Gnome::UI::Separator());
+ break;
+ }
+
+ case MenuItem::Lastfiles: {
+ int ii = 1;
+ for (LastFiles::const_iterator cit = lastfiles->begin();
+ cit != lastfiles->end() && ii < 10; ++cit, ++ii)
+ {
+ int action = lyxaction.getPseudoAction(LFUN_FILE_OPEN, (*cit));
+ string label = "_" + tostr(ii) + ". " + MakeDisplayPath((*cit),30);
+
+ Menus.push_back(Gnome::UI::Item(label,
+ bind<int>(slot(this, &Menubar::Pimpl::callback), action),
+ label));
+ }
+ break;
+ }
+
+ case MenuItem::Documents: {
+ std::vector<string> names = bufferlist.getFileNames();
+
+ for (std::vector<string>::const_iterator cit = names.begin();
+ cit != names.end() ; ++cit)
+ {
+ int action = lyxaction.getPseudoAction(LFUN_SWITCHBUFFER, *cit);
+ string label = MakeDisplayPath(*cit, 30);
+
+ Menus.push_back(Gnome::UI::Item(label,
+ bind<int>(slot(this, &Menubar::Pimpl::callback), action),
+ label));
+
+ }
+ break;
+ }
+ }
+ }
+}
+
+void Menubar::Pimpl::connectWidgetToAction(GnomeUIInfo * guinfo)
+{
+ for (; guinfo->type != GnomeUIInfoType(GNOME_APP_UI_ENDOFINFO); ++guinfo)
+ {
+ if ( guinfo->type == GnomeUIInfoType(GNOME_APP_UI_ITEM) ||
+ guinfo->type == GnomeUIInfoType(GNOME_APP_UI_TOGGLEITEM) )
+ {
+ (*((void(*)(void *, void *))(guinfo->moreinfo)))(NULL, guinfo->user_data);
+ wid_act_.push_back( GtkWidgetToAction( guinfo->widget, action_ ) );
+ }
+ else if ( guinfo->type == GnomeUIInfoType(GNOME_APP_UI_SUBTREE) ||
+ guinfo->type == GnomeUIInfoType(GNOME_APP_UI_RADIOITEMS) )
+ {
+ connectWidgetToAction( (GnomeUIInfo *)(guinfo->moreinfo) );
+ }
+ }
+}
+
+void Menubar::Pimpl::update()
+{
+ vector<GtkWidgetToAction>::const_iterator end=wid_act_.end();
+ for (vector<GtkWidgetToAction>::const_iterator i = wid_act_.begin(); i != end; ++i)
+ {
+ GtkWidgetToAction wa = (*i);
+ LyXFunc::func_status flag = owner_->getLyXFunc()->getStatus(wa.action_);
+
+ if ( flag & (LyXFunc::Disabled | LyXFunc::Unknown) ) gtk_widget_set_sensitive(wa.widget_, false);
+ else gtk_widget_set_sensitive(wa.widget_, true);
+
+ //don't know how to toggle/untoggle GtkCheckMenuItem
+ if ( flag & LyXFunc::ToggleOn )
+ {
+ ignore_action_=true;
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(wa.widget_), true);
+ ignore_action_=false;
+ }
+
+ if ( flag & LyXFunc::ToggleOff )
+ {
+ ignore_action_=true;
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(wa.widget_), false);
+ ignore_action_=false;
+ }
+ }
+}
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2000 The LyX Team.
+ *
+ * ====================================================== */
+
+#ifndef MENUBAR_PIMPL_H
+#define MENUBAR_PIMPL_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include <vector>
+#include "LString.h"
+#include <gnome--/app.h>
+#include "frontends/Menubar.h"
+
+class LyXView;
+class MenuBackend;
+class MenuItem;
+class StrPool;
+
+#include "debug.h"
+
+/*
+ Structure containing Gtk widget and corresponding LyX action
+*/
+struct GtkWidgetToAction
+{
+public:
+ GtkWidgetToAction(GtkWidget * w, int a) { widget_=w; action_=a; }
+
+public:
+ GtkWidget * widget_;
+ int action_;
+};
+
+/** The LyX GUI independent menubar class
+ The GUI interface is implemented in the corresponding Menubar_pimpl class.
+ */
+class Menubar::Pimpl: public SigC::Object {
+public:
+ ///
+ Pimpl(LyXView *, MenuBackend const &);
+ ///
+ ~Pimpl();
+ ///
+ void set(string const &);
+ /// Opens a top-level submenu given its name
+ void openByName(string const &) {}
+ /// update the state of menuitems
+ void update();
+
+protected:
+ /// callback function
+ void callback(int action);
+ /// compose Gnome::UI::Array object describing the menu
+ void composeUIInfo(string const & menu_name, vector<Gnome::UI::Info> & Menus);
+ /// populate wid_act_ vector with all widgets and corresponding actions
+ void connectWidgetToAction(GnomeUIInfo * guinfo);
+
+private:
+ ///
+ LyXView * owner_;
+ ///
+ MenuBackend const * menubackend_;
+ ///
+ string current_menu_name_;
+ Gnome::UI::Array Menu_;
+
+ ///
+ bool ignore_action_;
+ int action_;
+ vector<GtkWidgetToAction> wid_act_;
+};
+#endif
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2000 The LyX Team.
+ *
+ * ====================================================== */
+
+#include <config.h>
+#include <gnome--/main.h>
+#include <gtk--/accelgroup.h>
+#include <vector>
+#include <algorithm>
+
+#include "mainapp.h"
+
+using SigC::bind;
+using SigC::slot;
+
+GLyxAppWin::GLyxAppWin() :
+ Gnome::App("GnomeLyX","LyX Gnomified"),
+ status_(false, true, GNOME_PREFERENCES_NEVER)
+{
+ init();
+ show_all();
+}
+
+GLyxAppWin::~GLyxAppWin()
+{
+}
+
+void GLyxAppWin::init()
+{
+ // set defaults
+ set_policy(false, true, false);
+ set_default_size(250, 350);
+ set_wmclass("lyx", "GnomeLyX");
+
+ frame_.set_shadow_type(GTK_SHADOW_IN);
+
+ set_contents(frame_);
+
+ set_statusbar(status_);
+
+ // initial (dummy) menu
+ vector<Gnome::UI::Info> menus, fm;
+ fm.push_back(Gnome::MenuItems::Open());
+ menus.push_back(Gnome::Menus::File(fm));
+
+ Gnome::UI::Array menu = menus;
+ gnome_app_create_menus(this->gtkobj(),
+ menu.gtkobj());
+
+ menusize_ = menu.size();
+}
+
+
+void GLyxAppWin::set_menu(Gnome::UI::Array &menu)
+{
+ // clean up and install new menus
+ gnome_app_remove_menus(this->gtkobj(),"/",menusize_);
+ gnome_app_insert_menus(this->gtkobj(), "", menu.gtkobj());
+ gnome_app_install_menu_hints(this->gtkobj(), menu.gtkobj());
+ menusize_ = menu.size();
+}
+
+
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 2000 The LyX Team.
+ *
+ * ====================================================== */
+
+#ifndef GNOMELYX_MAINWIN
+#define GNOMELYX_MAINWIN
+
+#include <gnome--/app.h>
+#include <gnome--/appbar.h>
+#include <gtk--/frame.h>
+
+#include "MenuBackend.h"
+
+/*
+ This is (most probably) temporary class and it will be either merged with
+ LyXView or replaced by new implementation of GUI-dependend MainWindow class
+*/
+
+class GLyxAppWin: public Gnome::App
+{
+ public:
+ GLyxAppWin();
+ ~GLyxAppWin();
+
+ /// set menu of the window
+ void set_menu(Gnome::UI::Array &);
+
+ protected:
+ /// init window widgets
+ void init();
+
+ protected:
+ // widgets
+ Gnome::AppBar status_;
+ Gtk::Frame frame_;
+
+ // menu size
+ int menusize_;
+};
+
+#endif
string const & menuname,
std::vector<int> & smn, StrPool & strpool);
+ /// update the state of the menuitems
+ void update() { }
+
private:
///
FL_OBJECT * frame_;
}
top_x = int(x);
top_baseline = baseline;
+ if (bv->text->status == LyXText::CHANGED_IN_DRAW)
+ return;
bool dodraw;
x += ADD_TO_TABULAR_WIDTH;
if (cleared || (need_update == FULL) || (need_update == CELL)) {
if (hasSelection())
DrawCellSelection(pain, nx, baseline, i, j, cell);
if (dodraw && !cleared && locked && the_locking_inset) {
- if (the_locking_inset == tabular->GetCellInset(cell))
-#warning Reminder make this better! (Jug)
- if (need_update == CELL) // clear this cell
- pain.fillRectangle(cx,
- baseline -
- tabular->GetAscentOfRow(i),
- tabular->GetWidthOfColumn(cell),
- tabular->GetAscentOfRow(i) +
- tabular->GetDescentOfRow(i));
- tabular->GetCellInset(cell)->draw(bv, font,
- baseline, cx,
- need_update==CELL);
- if (need_update == CELL)
- DrawCellLines(pain, nx, baseline, i, cell);
+ if (the_locking_inset == tabular->GetCellInset(cell)) {
+ LyXText::text_status st = bv->text->status;
+ do {
+ bv->text->status = st;
+ if (need_update == CELL) {
+ // clear before the inset
+ pain.fillRectangle(
+ nx+1,
+ baseline - tabular->GetAscentOfRow(i)+1,
+ cx - nx - 1,
+ tabular->GetAscentOfRow(i) +
+ tabular->GetDescentOfRow(i) - 1);
+ // clear behind the inset
+ pain.fillRectangle(
+ cx + the_locking_inset->width(bv,font) + 1,
+ baseline - tabular->GetAscentOfRow(i)+1,
+ tabular->GetWidthOfColumn(cell) -
+ tabular->GetBeginningOfTextInCell(cell) -
+ the_locking_inset->width(bv,font) - 1,
+ tabular->GetAscentOfRow(i) +
+ tabular->GetDescentOfRow(i) - 1);
+ }
+ tabular->GetCellInset(cell)->draw(
+ bv, font, baseline, cx, false);
+// if (need_update == CELL)
+// DrawCellLines(pain, nx, baseline, i, cell);
+ } while(bv->text->status == LyXText::CHANGED_IN_DRAW);
+ }
} else if (dodraw) {
tabular->GetCellInset(cell)->draw(bv, font, baseline, cx,
cleared);
{
Painter & pain = bv->painter();
+ // no draw is necessary !!!
+ if ((drawFrame == LOCKED) && !locked && !par->size()) {
+ if (!cleared && (need_update == CLEAR_FRAME)) {
+ pain.rectangle(top_x, baseline - insetAscent, insetWidth,
+ insetAscent + insetDescent,
+ LColor::background);
+ }
+ top_x = int(x);
+ top_baseline = baseline;
+ x += width(bv, f);
+ need_update = NONE;
+ return;
+ }
+
xpos = x;
UpdatableInset::draw(bv, f, baseline, x, cleared);
int h = insetAscent + insetDescent;
int ty = baseline - insetAscent;
- if (ty < 0)
+ if (ty < 0) {
+ h += ty;
ty = 0;
+ }
if ((ty + h) > pain.paperHeight())
h = pain.paperHeight();
if ((top_x + drawTextXOffset + w) > pain.paperWidth())
insetAscent + insetDescent,
LColor::background);
}
- x += insetWidth - TEXT_TO_INSET_OFFSET;
+ x += width(bv, f) - 1;
if (bv->text->status==LyXText::CHANGED_IN_DRAW)
need_update = INIT;
else if (need_update != INIT)
#endif
#ifdef GTKGUI
# include <gnome--/main.h>
+# include "frontends/gnome/mainapp.h"
+GLyxAppWin * mainAppWin;
#endif
#include FORMS_H_LOCATION
KApplication a( argc, argv );
#endif
#ifdef GTKGUI
- Gnome::Main a(PACKAGE,VERSION,argc, argv );
+ Gnome::Main a(PACKAGE,VERSION,1,argv); //argc, argv );
+ GLyxAppWin appWin;
+ mainAppWin = &appWin;
#endif
// lyx_localedir is used by gettext_init() is we have