From ab5f0efdcbc357141375f7e7c53aa9f2cbdf2f45 Mon Sep 17 00:00:00 2001 From: John Levon Date: Wed, 12 Jun 2002 02:54:19 +0000 Subject: [PATCH] Some minor cleanup + use of scoped_ptr instead of raw pointer, to reduce diff size git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4374 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 30 ++---- src/BufferView.h | 8 +- src/BufferView2.C | 6 +- src/BufferView_pimpl.C | 60 ++++------- src/BufferView_pimpl.h | 21 ++-- src/ChangeLog | 13 +++ src/frontends/Alert.h | 2 +- src/frontends/ChangeLog | 8 ++ src/frontends/LyXView.C | 111 ++++++++++----------- src/frontends/LyXView.h | 108 +++++++++++++------- src/frontends/Menubar.h | 25 ++--- src/frontends/Timeout.h | 9 +- src/frontends/Toolbar.C | 19 ++-- src/frontends/controllers/ControlButtons.h | 2 +- src/frontends/xforms/ChangeLog | 14 +++ src/frontends/xforms/FontInfo.C | 20 ++-- src/frontends/xforms/FontInfo.h | 15 ++- src/frontends/xforms/XFormsView.C | 80 ++++++--------- src/frontends/xforms/XFormsView.h | 34 ++++--- src/frontends/xforms/XWorkArea.C | 45 ++++----- src/frontends/xforms/xfont_loader.C | 18 ++-- src/frontends/xforms/xfont_loader.h | 8 +- src/frontends/xforms/xformsGImage.C | 11 +- src/lyx_main.C | 6 -- src/lyx_main.h | 34 ++----- src/main.C | 1 + src/mathed/formulabase.C | 1 - 27 files changed, 336 insertions(+), 373 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index 5a2047f315..1700bfc132 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -1,12 +1,11 @@ -/* This file is part of - * ====================================================== +/** + * \file BufferView.C + * Copyright 1995-2002 the LyX Team + * Read the file COPYING * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * ====================================================== */ + * \author unknown + * \author John Levon + */ #include @@ -54,7 +53,7 @@ LyXView * BufferView::owner() const } -Painter & BufferView::painter() +Painter & BufferView::painter() const { return pimpl_->painter(); } @@ -179,19 +178,6 @@ void BufferView::setState() pimpl_->setState(); } -#if 0 -void BufferView::insetSleep() -{ - pimpl_->insetSleep(); -} - - -void BufferView::insetWakeup() -{ - pimpl_->insetWakeup(); -} -#endif - void BufferView::insetUnlock() { diff --git a/src/BufferView.h b/src/BufferView.h index da22d8781a..500e98e124 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -52,7 +52,7 @@ public: /// Buffer * buffer() const; /// - Painter & painter(); + Painter & painter() const; /// LScreen & screen() const; /// @@ -117,12 +117,6 @@ public: int sly; /// void insetUnlock(); -#if 0 - /// - void insetSleep(); - /// - void insetWakeup(); -#endif /// void replaceWord(string const & replacestring); /// diff --git a/src/BufferView2.C b/src/BufferView2.C index 9f069b1905..8022c299b6 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -576,7 +576,7 @@ void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc) ? LScreen::REVERSED_L_SHAPE : LScreen::L_SHAPE; y += cursor.iy() + theLockingInset()->insetInInsetY(); - pimpl_->screen_->showManualCursor(text, x, y, asc, desc, + screen().showManualCursor(text, x, y, asc, desc, shape); } } @@ -585,7 +585,7 @@ void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc) void BufferView::hideLockedInsetCursor() { if (theLockingInset() && available()) { - pimpl_->screen_->hideCursor(); + screen().hideCursor(); } } @@ -594,7 +594,7 @@ bool BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc) { if (theLockingInset() && available()) { y += text->cursor.iy() + theLockingInset()->insetInInsetY(); - if (pimpl_->screen_->fitManualCursor(text, this, x, y, asc, desc)) { + if (screen().fitManualCursor(text, this, x, y, asc, desc)) { updateScrollbar(); return true; } diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index c3c918535b..b4d62a1439 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -1,3 +1,11 @@ +/** + * \file BufferView_pimpl.C + * Copyright 2002 the LyX Team + * Read the file COPYING + * + * \author various + */ + #include #ifdef __GNUG__ @@ -31,7 +39,6 @@ #include "undo_funcs.h" #include "lyxtextclasslist.h" - #include "insets/insetbib.h" #include "insets/insettext.h" #include "insets/inseturl.h" @@ -68,6 +75,7 @@ #include +#include #include #include #include @@ -136,7 +144,7 @@ BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o, int xpos, int ypos, int width, int height) : bv_(b), owner_(o), buffer_(0), current_scrollbar_value(0), cursor_timeout(400), - using_xterm_cursor(false), inset_slept(false) + using_xterm_cursor(false) { workarea_.reset(new WorkArea(xpos, ypos, width, height)); screen_.reset(new LScreen(workarea())); @@ -181,7 +189,7 @@ LScreen & BufferView::Pimpl::screen() const } -Painter & BufferView::Pimpl::painter() +Painter & BufferView::Pimpl::painter() const { return workarea().getPainter(); } @@ -192,9 +200,6 @@ void BufferView::Pimpl::buffer(Buffer * b) lyxerr[Debug::INFO] << "Setting buffer in BufferView (" << b << ")" << endl; if (buffer_) { -#if 0 - insetSleep(); -#endif buffer_->delUser(bv_); // Put the old text into the TextCache, but @@ -236,9 +241,6 @@ void BufferView::Pimpl::buffer(Buffer * b) // require bv_->text. owner_->getDialogs()->updateBufferDependent(true); redraw(); -#if 0 - insetWakeup(); -#endif } else { lyxerr[Debug::INFO] << " No Buffer!" << endl; owner_->updateMenubar(); @@ -573,6 +575,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, mouse_button::state s int inset_x = font.isVisibleRightToLeft() ? cursor.ix() - width : cursor.ix(); int start_x = inset_x + bv_->theLockingInset()->scroll(); + bv_->theLockingInset()-> insetMotionNotify(bv_, x - start_x, @@ -588,9 +591,7 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, mouse_button::state s return; screen().hideCursor(); -#if 0 - int y_before = bv_->text->cursor.y(); -#endif + Row * cursorrow = bv_->text->cursor.row(); bv_->text->setCursorFromCoordinates(bv_, x, y + bv_->text->first_y); #if 0 @@ -627,7 +628,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, if (!buffer_) return; - // ok ok, this is a hack. + // ok ok, this is a hack (for xforms) if (button == mouse_button::button4) { scrollUp(lyxrc.wheel_jump); @@ -664,7 +665,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, otherwise give the event to the inset */ if (inset_hit == bv_->theLockingInset()) { bv_->theLockingInset()-> - insetButtonPress(bv_,xpos, ypos,button); + insetButtonPress(bv_, xpos, ypos, button); return; } else { bv_->unlockInset(bv_->theLockingInset()); @@ -1256,11 +1257,13 @@ void BufferView::Pimpl::cursorNext(LyXText * text) - bv_->text->first_y + bv_->theLockingInset()->insetInInsetY()); } + text->getRowNearY(y); Row * cursorrow = text->cursor.row(); text->setCursorFromCoordinates(bv_, text->cursor.x_fix(), y); // + workarea().workHeight()); finishUndo(); + int new_y; if (cursorrow == bv_->text->cursor.row()) { // we have a row which is higher than the workarea so we leave the @@ -1381,35 +1384,12 @@ void BufferView::Pimpl::setState() } -#if 0 -void BufferView::Pimpl::insetSleep() -{ - if (bv_->theLockingInset() && !inset_slept) { - bv_->theLockingInset()->getCursorPos(bv_, bv_->slx, bv_->sly); - bv_->theLockingInset()->insetUnlock(bv_); - inset_slept = true; - } -} - - -void BufferView::Pimpl::insetWakeup() -{ - if (bv_->theLockingInset() && inset_slept) { - bv_->theLockingInset()->edit(bv_, bv_->slx, bv_->sly, 0); - inset_slept = false; - } -} -#endif - - void BufferView::Pimpl::insetUnlock() { if (bv_->theLockingInset()) { - if (!inset_slept) - bv_->theLockingInset()->insetUnlock(bv_); + bv_->theLockingInset()->insetUnlock(bv_); bv_->theLockingInset(0); finishUndo(); - inset_slept = false; } } @@ -1530,7 +1510,7 @@ void BufferView::Pimpl::moveCursorUpdate(bool selecting, bool fitcur) if (!lt->selection.set()) workarea().haveSelection(false); - + /* ---> Everytime the cursor is moved, show the current font state. */ // should this too me moved out of this func? //owner->showState(); @@ -2030,7 +2010,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) // This is soooo ugly. Isn`t it possible to make // it simpler? (Lgb) LyXText * lt = bv_->getLyXText(); - bool is_rtl = lt->cursor.par()->isRightToLeftPar(buffer_->params); + bool const is_rtl = lt->cursor.par()->isRightToLeftPar(buffer_->params); if (!lt->selection.mark()) beforeChange(lt); update(lt, BufferView::SELECT|BufferView::FITCUR); diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index e768918ac9..28958ad579 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -1,13 +1,20 @@ // -*- C++ -*- +/** + * \file BufferView_pimpl.h + * Copyright 2002 the LyX Team + * Read the file COPYING + * + * \author various + */ #ifndef BUFFERVIEW_PIMPL_H #define BUFFERVIEW_PIMPL_H #include "BufferView.h" #include "commandtags.h" -#include "frontends/mouse_state.h" -#include "frontends/key_state.h" #include "frontends/Timeout.h" +#include "frontends/key_state.h" +#include "frontends/mouse_state.h" #include "box.h" #include "insets/insetspecialchar.h" #include "support/types.h" @@ -32,7 +39,7 @@ struct BufferView::Pimpl : public boost::signals::trackable { Pimpl(BufferView * i, LyXView * o, int xpos, int ypos, int width, int height); /// - Painter & painter(); + Painter & painter() const; /// return the work area for this bview WorkArea & workarea() const; /// return the screen for this bview @@ -107,12 +114,6 @@ struct BufferView::Pimpl : public boost::signals::trackable { bool isSavedPosition(unsigned int i); /// void setState(); -#if 0 - /// - void insetSleep(); - /// - void insetWakeup(); -#endif /// void insetUnlock(); /// @@ -208,7 +209,5 @@ private: Inset * getInsetByCode(Inset::Code code); /// void MenuInsertLyXFile(string const & filen); - /// - bool inset_slept; }; #endif diff --git a/src/ChangeLog b/src/ChangeLog index bac7537f24..b384286b10 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2002-06-12 John Levon + + * BufferView_pimpl.h: + * BufferView_pimpl.C: + * BufferView.h: + * BufferView.C: make painter() const, + remove dead code + + * BufferView2.C: use screen() accessor + + * lyx_main.h: + * lyx_main.C: some minor cleanup + 2002-06-12 John Levon * BufferView_pimpl.h: diff --git a/src/frontends/Alert.h b/src/frontends/Alert.h index a057811286..4009a42175 100644 --- a/src/frontends/Alert.h +++ b/src/frontends/Alert.h @@ -38,4 +38,4 @@ askForText(string const & msg, } -#endif +#endif // LYX_ALERT_H diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 2306270356..fb22822d2c 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,11 @@ +2002-06-12 John Levon + + * Menubar.C: + * Timeout.h: + * Toolbar.C: + * LyXView.h: + * LyXView.C: some cleanup, prefer scoped_ptr + 2002-06-12 John Levon * screen.C: diff --git a/src/frontends/LyXView.C b/src/frontends/LyXView.C index ee069dc279..3db1cfa3a8 100644 --- a/src/frontends/LyXView.C +++ b/src/frontends/LyXView.C @@ -1,12 +1,11 @@ -/* This file is part of - * ====================================================== +/** + * \file LyXView.C + * Copyright 1995-2002 the LyX Team + * Read the file COPYING * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * ====================================================== */ + * \author Lars Gullik Bjornes + * \author John Levon + */ #include @@ -14,7 +13,7 @@ #pragma implementation #endif -#include "frontends/LyXView.h" +#include "LyXView.h" #include "minibuffer.h" #include "debug.h" #include "intl.h" @@ -22,10 +21,11 @@ #include "lyxtext.h" #include "buffer.h" #include "MenuBackend.h" -#include "bufferview_funcs.h" // CurrentState() #include "gettext.h" #include "lyxfunc.h" +#include "lyx_cb.h" #include "BufferView.h" +#include "bufferview_funcs.h" #include "lyxtextclasslist.h" #include "frontends/Dialogs.h" @@ -33,7 +33,7 @@ #include "frontends/Timeout.h" #include "frontends/Menubar.h" -#include "support/filetools.h" // OnlyFilename() +#include "support/filetools.h" // OnlyFilename() #include @@ -51,28 +51,20 @@ string current_layout; LyXView::LyXView() { lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl; - lyxfunc = new LyXFunc(this); - intl = new Intl; + lyxfunc_.reset(new LyXFunc(this)); + intl_.reset(new Intl); // Give the timeout some default sensible value. - autosave_timeout = new Timeout(5000); + autosave_timeout_.reset(new Timeout(5000)); - dialogs_ = new Dialogs(this); + dialogs_.reset(new Dialogs(this)); Dialogs::redrawGUI.connect(boost::bind(&LyXView::redraw, this)); } LyXView::~LyXView() { - delete menubar; - delete toolbar; - delete bufferview; - delete minibuffer; - delete lyxfunc; - delete intl; - delete autosave_timeout; - delete dialogs_; } @@ -82,91 +74,90 @@ void LyXView::resize() } -/// returns the buffer currently shown in the main form. Buffer * LyXView::buffer() const { - return bufferview->buffer(); + return bufferview_->buffer(); } BufferView * LyXView::view() const { - return bufferview; + return bufferview_.get(); } Toolbar * LyXView::getToolbar() const { - return toolbar; + return toolbar_.get(); } void LyXView::setLayout(string const & layout) { - toolbar->setLayout(layout); + toolbar_->setLayout(layout); } void LyXView::updateToolbar() { - toolbar->update(); + toolbar_->update(); } LyXFunc * LyXView::getLyXFunc() const { - return lyxfunc; + return lyxfunc_.get(); } MiniBuffer * LyXView::getMiniBuffer() const { - return minibuffer; + return minibuffer_.get(); } void LyXView::message(string const & str) { - minibuffer->message(str); + minibuffer_->message(str); } void LyXView::messagePush(string const & str) { - minibuffer->messagePush(str); + minibuffer_->messagePush(str); } void LyXView::messagePop() { - minibuffer->messagePop(); + minibuffer_->messagePop(); } Menubar * LyXView::getMenubar() const { - return menubar; + return menubar_.get(); } void LyXView::updateMenubar() { - if ((!view() || !view()->buffer()) - && menubackend.hasMenu("main_nobuffer")) - menubar->set("main_nobuffer"); - else - menubar->set("main"); - menubar->update(); + if (!view()->buffer() && menubackend.hasMenu("main_nobuffer")) { + menubar_->set("main_nobuffer"); + } else { + menubar_->set("main"); + } + + menubar_->update(); } Intl * LyXView::getIntl() const { - return intl; + return intl_.get(); } -// Callback for autosave timer void LyXView::AutoSave() { lyxerr[Debug::INFO] << "Running AutoSave()" << endl; @@ -175,49 +166,46 @@ void LyXView::AutoSave() } -/// Reset autosave timer void LyXView::resetAutosaveTimer() { if (lyxrc.autosave) - autosave_timeout->restart(); + autosave_timeout_->restart(); } void LyXView::invalidateLayoutChoice() { - last_textclass = -1; + last_textclass_ = -1; } void LyXView::updateLayoutChoice() { - // This has a side-effect that the layouts are not showed when no - // document is loaded. - if (!view() || !view()->buffer()) { - toolbar->clearLayoutList(); + // don't show any layouts without a buffer + if (!view()->buffer()) { + toolbar_->clearLayoutList(); return; } - // Update the layout display - if (last_textclass != int(buffer()->params.textclass)) { - toolbar->updateLayoutList(true); - last_textclass = int(buffer()->params.textclass); - current_layout = textclasslist[last_textclass].defaultLayoutName(); + // update the layout display + if (last_textclass_ != int(buffer()->params.textclass)) { + toolbar_->updateLayoutList(true); + last_textclass_ = int(buffer()->params.textclass); + current_layout = textclasslist[last_textclass_].defaultLayoutName(); } else { - toolbar->updateLayoutList(false); + toolbar_->updateLayoutList(false); } string const & layout = - bufferview->getLyXText()->cursor.par()->layout(); + bufferview_->getLyXText()->cursor.par()->layout(); if (layout != current_layout) { - toolbar->setLayout(layout); + toolbar_->setLayout(layout); current_layout = layout; } } -// Updates the title of the window with the filename of the current document void LyXView::updateWindowTitle() { static string last_title = "LyX"; @@ -229,13 +217,14 @@ void LyXView::updateWindowTitle() if (!cur_title.empty()) { title += ": " + MakeDisplayPath(cur_title, 30); if (!buffer()->isLyxClean()) - title += _(" (Changed)"); + title += _(" (changed)"); if (buffer()->isReadonly()) title += _(" (read only)"); - /* Show only the filename if it's available. */ + // Show only the filename if it's available icon_title = OnlyFilename(cur_title); } } + if (title != last_title) { setWindowTitle(title, icon_title); last_title = title; diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index fe50626c23..eb1ce87f6c 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -1,7 +1,15 @@ // -*- C++ -*- - -#ifndef LYXVIEW_BASE_H -#define LYXVIEW_BASE_H +/** + * \file LyXView.h + * Copyright 1995-2002 the LyX Team + * Read the file COPYING + * + * \author Lars Gullik Bjornes + * \author John Levon + */ + +#ifndef LYXVIEW_H +#define LYXVIEW_H #ifdef __GNUG__ #pragma interface @@ -12,6 +20,7 @@ #include "support/types.h" #include +#include #include class Buffer; @@ -23,9 +32,22 @@ class Menubar; class BufferView; class Dialogs; class LyXFunc; +class LyXFont; class Timeout; -/// +/** + * LyXView - main LyX window + * + * This class represents the main LyX window and provides + * accessor functions to its content. + * + * The eventual intention is that LyX will support a number + * of containing LyXViews. Currently a lot of code still + * relies on there being a single top-level view. + * + * Additionally we would like to support multiple views + * in a single LyXView. + */ class LyXView : public boost::signals::trackable, boost::noncopyable { public: /// @@ -50,7 +72,7 @@ public: /// BufferView * view() const; - /// return a pointer to the toolbar + /// return the toolbar for this view Toolbar * getToolbar() const; /// sets the layout in the toolbar layout combox @@ -71,7 +93,7 @@ public: /// void messagePop(); - /// + /// return the menubar for this view Menubar * getMenubar() const; /// @@ -80,8 +102,8 @@ public: /// Intl * getIntl() const; - /// - Dialogs * getDialogs() { return dialogs_; } + /// get access to the dialogs + Dialogs * getDialogs() { return dialogs_.get(); } /// void updateLayoutChoice(); @@ -98,35 +120,51 @@ public: virtual void prohibitInput() const = 0; /// virtual void allowInput() const = 0; + protected: - /// - Menubar * menubar; - /// - Toolbar * toolbar; - /** This is supposed to be a pointer or a list of pointers to the - BufferViews currently being shown in the LyXView. So far - this is not used, but that should change pretty soon. (Lgb) */ - BufferView * bufferview; - /// - MiniBuffer * minibuffer; - /// - Intl * intl; - /// - Timeout * autosave_timeout; - /// A callback + /// view of a buffer. Eventually there will be several. + boost::scoped_ptr bufferview_; + + /// view's menubar + boost::scoped_ptr menubar_; + /// view's toolbar + boost::scoped_ptr toolbar_; + /// view's minibuffer + boost::scoped_ptr minibuffer_; + + /// keyboard mapping object + boost::scoped_ptr intl_; + + /// auto-saving of buffers + boost::scoped_ptr autosave_timeout_; + + /// called on timeout void AutoSave(); - /// + + /// FIXME: GUII - toolbar property void invalidateLayoutChoice(); + private: - /// - LyXFunc * lyxfunc; - /// - Dialogs * dialogs_; - /// - virtual void setWindowTitle(string const &, string const &) = 0; - /** The last textclass layout list in the layout choice selector - This should probably be moved to the toolbar, but for now it's - here. (Asger) */ - int last_textclass; + /** + * setWindowTitle - set title of window + * @param t main window title + * @param it iconified (short) title + */ + virtual void setWindowTitle(string const & t, string const & it) = 0; + + /// our function handler + boost::scoped_ptr lyxfunc_; + /// dialogs for this view + boost::scoped_ptr dialogs_; + + /** + * The last textclass layout list in the layout choice selector + * This should probably be moved to the toolbar, but for now it's + * here. (Asger) + * + * FIXME: GUII + */ + int last_textclass_; }; -#endif + +#endif // LYXVIEW_H diff --git a/src/frontends/Menubar.h b/src/frontends/Menubar.h index 1c3341149c..2dd3ca212b 100644 --- a/src/frontends/Menubar.h +++ b/src/frontends/Menubar.h @@ -1,15 +1,11 @@ // -*- C++ -*- -/* This file is part of - * ====================================================== +/** + * \file Menubar.h + * Copyright 1995-2002 the LyX Team + * Read the file COPYING * - * LyX, The Document Processor - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * This file is Copyright 1996-2001 - * Lars Gullik Bjønnes - * - * ====================================================== */ + * \author Lars Gullik Bjønnes + */ #ifndef MENUBAR_H #define MENUBAR_H @@ -23,9 +19,10 @@ class LyXView; class MenuBackend; -/** The LyX GUI independent menubar class - The GUI interface is implemented in the corresponding Menubar_pimpl class. - */ +/** + * The LyX GUI independent menubar class + * The GUI interface is implemented in the corresponding Menubar_pimpl class. + */ class Menubar { public: /// @@ -49,4 +46,4 @@ private: /// Pimpl * pimpl_; }; -#endif +#endif // MENUBAR_H diff --git a/src/frontends/Timeout.h b/src/frontends/Timeout.h index eaac2a37a0..d363e0c270 100644 --- a/src/frontends/Timeout.h +++ b/src/frontends/Timeout.h @@ -7,6 +7,7 @@ * \author Lars Gullik Bjønnes * \author John Levon */ + #ifndef TIMEOUT_H #define TIMEOUT_H @@ -21,12 +22,10 @@ */ class Timeout { public: - /// + /// the timeout type enum Type { - /// one-shot timer - ONETIME, - /// repeating - CONTINUOUS + ONETIME, //< one-shot timer + CONTINUOUS //< repeating }; /// Timeout(unsigned int msec, Type = ONETIME); diff --git a/src/frontends/Toolbar.C b/src/frontends/Toolbar.C index a01dcc314a..f564c534df 100644 --- a/src/frontends/Toolbar.C +++ b/src/frontends/Toolbar.C @@ -1,17 +1,10 @@ -/* This file is part of - * ====================================================== +/** + * \file Toolbar.C + * Copyright 1995-2002 the LyX Team + * Read the file COPYING * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * This file is Copyright 1996-1998 - * Lars Gullik Bjønnes - * - * ====================================================== */ - -// Added pseudo-action handling, asierra 180296 + * \author Lars Gullik Bjønnes + */ #include diff --git a/src/frontends/controllers/ControlButtons.h b/src/frontends/controllers/ControlButtons.h index 53264ee2c0..23978f2212 100644 --- a/src/frontends/controllers/ControlButtons.h +++ b/src/frontends/controllers/ControlButtons.h @@ -8,7 +8,7 @@ * * ====================================================== * - * \file ControlButtonss.h + * \file ControlButtons.h * \author Angus Leeming * * ControlButtons serves only to control the activation of the Ok, Apply, Cancel diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 5b37739656..96d35c5fa1 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,17 @@ +2002-06-12 John Levon + + * xformsGImage.C: + * FontInfo.h: + * FontInfo.C: some cleanup + + * XWorkArea.C: + * XFormsView.h: + * XFormsView.C: some minor cleanup, use of + scoped_ptr + + * xfont_loader.h: + * xfont_loader.C: rename + 2002-06-12 John Levon * XWorkArea.h: diff --git a/src/frontends/xforms/FontInfo.C b/src/frontends/xforms/FontInfo.C index c9dd2e1839..53824d55bc 100644 --- a/src/frontends/xforms/FontInfo.C +++ b/src/frontends/xforms/FontInfo.C @@ -1,12 +1,11 @@ -/* This file is part of - * ====================================================== +/** + * \file FontInfo.C + * Copyright 1997-2002 the LyX Team + * Read the file COPYING * - * LyX, The Document Processor - * - * Copyright 1997 Asger Alstrup - * and the LyX Team. - * - * ====================================================== */ + * \author Asger Alstrup + * \author John Levon + */ #include @@ -21,13 +20,12 @@ #include "support/lstrings.h" #include "support/lyxlib.h" -#include "frontends/GUIRunTime.h" - #include // abs() using std::endl; using std::abs; +#include FORMS_H_LOCATION /// Load font close to this size string const FontInfo::getFontname(int size) @@ -119,7 +117,7 @@ void FontInfo::query() char ** list = 0; if (lyxrc.use_gui) - list = XListFonts(GUIRunTime::x11Display(), pattern.c_str(), + list = XListFonts(fl_get_display(), pattern.c_str(), 100, &matches); if (list == 0) { diff --git a/src/frontends/xforms/FontInfo.h b/src/frontends/xforms/FontInfo.h index 50ca92d6df..6a9ecf0893 100644 --- a/src/frontends/xforms/FontInfo.h +++ b/src/frontends/xforms/FontInfo.h @@ -1,13 +1,12 @@ // -*- C++ -*- -/* This file is part of - * ====================================================== +/** + * \file FontInfo.h + * Copyright 1997-2002 the LyX Team + * Read the file COPYING * - * LyX, The Document Processor - * - * Copyright 1997 Asger Alstrup - * and the LyX Team. - * - * ====================================================== */ + * \author Asger Alstrup + * \author John Levon + */ #ifndef FONTINFO_H #define FONTINFO_H diff --git a/src/frontends/xforms/XFormsView.C b/src/frontends/xforms/XFormsView.C index 53733bb873..51326cab66 100644 --- a/src/frontends/xforms/XFormsView.C +++ b/src/frontends/xforms/XFormsView.C @@ -57,11 +57,11 @@ XFormsView::XFormsView(int width, int height) : LyXView() { create_form_form_main(width, height); - fl_set_form_atclose(form_, C_XFormsView_atCloseMainFormCB, 0); + fl_set_form_atclose(getForm(), C_XFormsView_atCloseMainFormCB, 0); // Connect the minibuffer signals - minibuffer->stringReady.connect(boost::bind(&LyXFunc::miniDispatch, getLyXFunc(), _1)); - minibuffer->timeout.connect(boost::bind(&LyXFunc::initMiniBuffer, getLyXFunc())); + minibuffer_->stringReady.connect(boost::bind(&LyXFunc::miniDispatch, getLyXFunc(), _1)); + minibuffer_->timeout.connect(boost::bind(&LyXFunc::initMiniBuffer, getLyXFunc())); // Make sure the buttons are disabled if needed. updateToolbar(); @@ -74,14 +74,14 @@ XFormsView::~XFormsView() {} /// Redraw the main form. void XFormsView::redraw() { lyxerr[Debug::INFO] << "XFormsView::redraw()" << endl; - fl_redraw_form(form_); + fl_redraw_form(getForm()); getMiniBuffer()->redraw(); } FL_FORM * XFormsView::getForm() const { - return form_; + return form_.get(); } @@ -95,17 +95,17 @@ int XFormsView::atCloseMainFormCB(FL_FORM *, void *) void XFormsView::setPosition(int x, int y) { - fl_set_form_position(form_, x, y); + fl_set_form_position(getForm(), x, y); } void XFormsView::show(int place, int border, string const & title) { - fl_set_form_minsize(form_, form_->w, form_->h); - fl_show_form(form_, place, border, title.c_str()); + fl_set_form_minsize(getForm(), getForm()->w, getForm()->h); + fl_show_form(getForm(), place, border, title.c_str()); getLyXFunc()->initMiniBuffer(); #if FL_VERSION < 1 && (FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5)) - InitLyXLookup(fl_get_display(), form_->window); + InitLyXLookup(fl_get_display(), getForm()->window); #endif } @@ -120,8 +120,8 @@ void XFormsView::create_form_form_main(int width, int height) */ { // the main form - form_ = fl_bgn_form(FL_NO_BOX, width, height); - form_->u_vdata = this; + form_.reset(fl_bgn_form(FL_NO_BOX, width, height)); + getForm()->u_vdata = this; FL_OBJECT * obj = fl_add_box(FL_FLAT_BOX, 0, 0, width, height, ""); fl_set_object_color(obj, FL_MCOL, FL_MCOL); @@ -129,47 +129,23 @@ void XFormsView::create_form_form_main(int width, int height) int const air = 2; int const bw = abs(fl_get_border_width()); - // - // THE MENUBAR - // - menubar = new Menubar(this, menubackend); + menubar_.reset(new Menubar(this, menubackend)); - // - // TOOLBAR - // - - toolbar = new Toolbar(this, air, 30 + air + bw, toolbardefaults); - - // Setup the toolbar - toolbar->set(true); - - // - // WORKAREA - // + toolbar_.reset(new Toolbar(this, air, 30 + air + bw, toolbardefaults)); + toolbar_->set(true); int const ywork = 60 + 2 * air + bw; int const workheight = height - ywork - (25 + 2 * air); - ::current_view = bufferview = new BufferView(this, air, ywork, - width - 3 * air, - workheight); - - // - // MINIBUFFER - // - - minibuffer = new MiniBuffer(this, air, height - (25 + air), - width - (2 * air), 25); - - // - // TIMERS - // + bufferview_.reset(new BufferView(this, air, ywork, + width - 3 * air, workheight)); + ::current_view = bufferview_.get(); - autosave_timeout->timeout.connect(boost::bind(&XFormsView::AutoSave, this)); + minibuffer_.reset(new MiniBuffer(this, air, height - (25 + air), + width - (2 * air), 25)); - // - // Misc - // + // FIXME: why do this in xforms/ ? + autosave_timeout_->timeout.connect(boost::bind(&XFormsView::AutoSave, this)); // assign an icon to main form string iconname = LibFileSearch("images", "lyx", "xpm"); @@ -184,15 +160,15 @@ void XFormsView::create_form_form_main(int width, int height) 0, 0, 0); // this leaks - fl_set_form_icon(form_, lyx_p, lyx_mask); + fl_set_form_icon(getForm(), lyx_p, lyx_mask); } // set min size - fl_set_form_minsize(form_, 50, 50); + fl_set_form_minsize(getForm(), 50, 50); fl_end_form(); - minibuffer->dd_init(); + minibuffer_->dd_init(); } @@ -205,17 +181,17 @@ void XFormsView::init() // Start autosave timer if (lyxrc.autosave) { - autosave_timeout->setTimeout(lyxrc.autosave * 1000); - autosave_timeout->start(); + autosave_timeout_->setTimeout(lyxrc.autosave * 1000); + autosave_timeout_->start(); } - intl->InitKeyMapper(lyxrc.use_kbmap); + intl_->InitKeyMapper(lyxrc.use_kbmap); } void XFormsView::setWindowTitle(string const & title, string const & icon_title) { - fl_set_form_title(form_, title.c_str()); + fl_set_form_title(getForm(), title.c_str()); fl_winicontitle(form_->window, icon_title.c_str()); } diff --git a/src/frontends/xforms/XFormsView.h b/src/frontends/xforms/XFormsView.h index 762bb32c4b..ae738f139e 100644 --- a/src/frontends/xforms/XFormsView.h +++ b/src/frontends/xforms/XFormsView.h @@ -21,15 +21,15 @@ #include "frontends/LyXView.h" /** - This class is the form containing the view of the buffer. The actual buffer - view is supposed (at least IMHO) to be another class, that shows its output - in one or more LyXView's. + * XFormsView - xforms implementation of LyXView + * + * xforms-private implementation of the main LyX window. */ class XFormsView : public LyXView { public: - /// constructor + /// create a main window of the given dimensions XFormsView(int w, int h); - /// destructor + ~XFormsView(); /// Where to place the form. virtual void setPosition(int, int); @@ -37,23 +37,29 @@ public: virtual void show(int, int, string const & t = string("LyX")); /// init (should probably be removed later) (Lgb) virtual void init(); - /// Redraw the main form. - virtual void redraw(); - /// returns a pointer to the form. + /// get the xforms main form FL_FORM * getForm() const; + /// redraw the main form. + virtual void redraw(); /// virtual void prohibitInput() const; /// virtual void allowInput() const; - /** This callback is run when a close event is sent from the - window manager. */ + + /// callback for close event from window manager static int atCloseMainFormCB(FL_FORM *, void *); + private: - /// pass the title, and the iconified title - virtual void setWindowTitle(string const &, string const &); + /** + * setWindowTitle - set title of window + * @param t main window title + * @param it iconified (short) title + */ + virtual void setWindowTitle(string const & t, string const & it); + /// makes the main form. void create_form_form_main(int width, int height); - /// A pointer to the form. - FL_FORM * form_; + /// the main form. + boost::scoped_ptr form_; }; #endif diff --git a/src/frontends/xforms/XWorkArea.C b/src/frontends/xforms/XWorkArea.C index 456829c779..23cd9b7508 100644 --- a/src/frontends/xforms/XWorkArea.C +++ b/src/frontends/xforms/XWorkArea.C @@ -134,28 +134,23 @@ extern "C" { } -WorkArea::WorkArea(int xpos, int ypos, int width, int height) +WorkArea::WorkArea(int x, int y, int w, int h) : splash_(0), splash_text_(0), workareapixmap(0), painter_(*this) { fl_freeze_all_forms(); - if (lyxerr.debugging(Debug::WORKAREA)) - lyxerr << "Creating work area: +" - << xpos << '+' << ypos << ' ' - << width << 'x' << height << endl; // FL_OBJECT * obj; - int const bw = int(abs(fl_get_border_width())); // a box if (lyxerr.debugging(Debug::WORKAREA)) lyxerr << "\tbackground box: +" - << xpos << '+' << ypos << ' ' - << width - 15 << 'x' << height << endl; + << x << '+' << y << ' ' + << w - 15 << 'x' << h << endl; backgroundbox = obj = fl_add_box(FL_BORDER_BOX, - xpos, ypos, - width - 15, - height,""); + x, y, + w - 15, + h,""); fl_set_object_resize(obj, FL_RESIZE_ALL); fl_set_object_gravity(obj, NorthWestGravity, SouthEastGravity); @@ -166,8 +161,8 @@ WorkArea::WorkArea(int xpos, int ypos, int width, int height) if (!splash_file.empty()) { int const splash_w = 425; int const splash_h = 290; - int const splash_x = xpos + (width - 15 - splash_w) / 2; - int const splash_y = ypos + (height - splash_h) / 2; + int const splash_x = x + (w - 15 - splash_w) / 2; + int const splash_y = y + (h - splash_h) / 2; splash_ = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, splash_x, splash_y, @@ -190,13 +185,9 @@ WorkArea::WorkArea(int xpos, int ypos, int width, int height) fl_set_object_lstyle(obj, FL_BOLD_STYLE); } - // - // THE SCROLLBAR - // - scrollbar = obj = fl_add_scrollbar(FL_VERT_SCROLLBAR, - xpos + width - 15, - ypos, 17, height, ""); + x + w - 15, + y, 17, h, ""); fl_set_object_boxtype(obj, FL_UP_BOX); fl_set_object_resize(obj, FL_RESIZE_ALL); fl_set_object_gravity(obj, NorthEastGravity, SouthEastGravity); @@ -207,21 +198,23 @@ WorkArea::WorkArea(int xpos, int ypos, int width, int height) /// /// The free object + int const bw = int(abs(fl_get_border_width())); + // Create the workarea pixmap - createPixmap(width - 15 - 2 * bw, height - 2 * bw); + createPixmap(w - 15 - 2 * bw, h - 2 * bw); // We add this object as late as possible to avoit problems // with drawing. if (lyxerr.debugging(Debug::WORKAREA)) lyxerr << "\tfree object: +" - << xpos + bw << '+' << ypos + bw << ' ' - << width - 15 - 2 * bw << 'x' - << height - 2 * bw << endl; + << x + bw << '+' << y + bw << ' ' + << w - 15 - 2 * bw << 'x' + << h - 2 * bw << endl; work_area = obj = fl_add_free(FL_ALL_FREE, - xpos + bw, ypos + bw, - width - 15 - 2 * bw, // scrollbarwidth - height - 2 * bw, "", + x + bw, y + bw, + w - 15 - 2 * bw, // scrollbarwidth + h - 2 * bw, "", C_WorkArea_work_area_handler); obj->wantkey = FL_KEY_ALL; obj->u_vdata = this; /* This is how we pass the WorkArea diff --git a/src/frontends/xforms/xfont_loader.C b/src/frontends/xforms/xfont_loader.C index cbadcf99d1..4b425abaa3 100644 --- a/src/frontends/xforms/xfont_loader.C +++ b/src/frontends/xforms/xfont_loader.C @@ -30,18 +30,18 @@ extern BufferView * current_view; // The global fontloader -FontLoader fontloader; +xfont_loader fontloader; // Initialize font loader -FontLoader::FontLoader() +xfont_loader::xfont_loader() { reset(); } // Destroy font loader -FontLoader::~FontLoader() +xfont_loader::~xfont_loader() { unload(); } @@ -50,14 +50,14 @@ FontLoader::~FontLoader() // Update fonts after zoom, dpi, font names, or norm change // For now, we just ditch all fonts we have. Later, we should // reuse the ones that are already loaded. -void FontLoader::update() +void xfont_loader::update() { unload(); } // Reset font loader -void FontLoader::reset() +void xfont_loader::reset() { // Clear font infos, font structs and font metrics for (int i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1) @@ -72,7 +72,7 @@ void FontLoader::reset() // Unload all fonts -void FontLoader::unload() +void xfont_loader::unload() { // Unload all fonts for (int i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1) @@ -95,7 +95,7 @@ void FontLoader::unload() // Get font info /* Takes care of finding which font that can match the given request. Tries different alternatives. */ -void FontLoader::getFontinfo(LyXFont::FONT_FAMILY family, +void xfont_loader::getFontinfo(LyXFont::FONT_FAMILY family, LyXFont::FONT_SERIES series, LyXFont::FONT_SHAPE shape) { @@ -259,7 +259,7 @@ bool dummyXFontStructisGood = false; } // namespace anon /// Do load font -XFontStruct * FontLoader::doLoad(LyXFont::FONT_FAMILY family, +XFontStruct * xfont_loader::doLoad(LyXFont::FONT_FAMILY family, LyXFont::FONT_SERIES series, LyXFont::FONT_SHAPE shape, LyXFont::FONT_SIZE size) @@ -326,7 +326,7 @@ XFontStruct * FontLoader::doLoad(LyXFont::FONT_FAMILY family, } -bool FontLoader::available(LyXFont const & f) +bool xfont_loader::available(LyXFont const & f) { if (!lyxrc.use_gui) return false; diff --git a/src/frontends/xforms/xfont_loader.h b/src/frontends/xforms/xfont_loader.h index 66cd1c0503..fdcd7660c8 100644 --- a/src/frontends/xforms/xfont_loader.h +++ b/src/frontends/xforms/xfont_loader.h @@ -27,13 +27,13 @@ intelligent guesses about matching font size, and it tries different tags itself in order to match the font loading demands. Later, I plan to extend this with support for T1Lib, probably via a new class building on this. (Asger) */ -class FontLoader { +class xfont_loader { public: /// - FontLoader(); + xfont_loader(); /// - ~FontLoader(); + ~xfont_loader(); /// Update fonts after zoom, dpi, font names, or norm change void update(); @@ -77,6 +77,6 @@ private: }; /// -extern FontLoader fontloader; +extern xfont_loader fontloader; #endif diff --git a/src/frontends/xforms/xformsGImage.C b/src/frontends/xforms/xformsGImage.C index dd0f48df6d..94e95d65a8 100644 --- a/src/frontends/xforms/xformsGImage.C +++ b/src/frontends/xforms/xformsGImage.C @@ -17,7 +17,6 @@ #include "LColor.h" #include "converter.h" // formats #include "debug.h" -#include "frontends/GUIRunTime.h" // x11Display, x11Screen #include "support/LAssert.h" #include "support/lyxfunctional.h" // compare_memfun @@ -127,7 +126,7 @@ xformsGImage::~xformsGImage() if (image_) flimage_free(image_); if (pixmap_) - XFreePixmap(GUIRunTime::x11Display(), pixmap_); + XFreePixmap(fl_get_display(), pixmap_); } @@ -197,7 +196,7 @@ bool xformsGImage::setPixmap(GParams const & params) if (!image_ || params.display == GParams::NONE) return false; - Display * display = GUIRunTime::x11Display(); + Display * display = fl_get_display(); if (pixmap_ && pixmap_status_ == PIXMAP_SUCCESS) XFreePixmap(display, pixmap_); @@ -230,7 +229,7 @@ bool xformsGImage::setPixmap(GParams const & params) } image_->xdisplay = display; - Screen * screen = ScreenOfDisplay(display, GUIRunTime::x11Screen()); + Screen * screen = ScreenOfDisplay(display, fl_screen); pixmap_ = flimage_to_pixmap(image_, XRootWindowOfScreen(screen)); pixmap_status_ = pixmap_ ? PIXMAP_SUCCESS : PIXMAP_FAILED; @@ -436,8 +435,8 @@ unsigned int packedcolor(LColor::color c) { string const x11color = lcolor.getX11Name(c); - Display * display = GUIRunTime::x11Display(); - Colormap cmap = GUIRunTime::x11Colormap(); + Display * display = fl_get_display(); + Colormap cmap = fl_state[fl_get_vclass()].colormap; XColor xcol; XColor ccol; if (XLookupColor(display, cmap, x11color.c_str(), &xcol, &ccol) == 0) diff --git a/src/lyx_main.C b/src/lyx_main.C index f60b69ee8f..6ea4b34dc4 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -180,12 +180,6 @@ LyX::LyX(int * argc, char * argv[]) } -// A destructor is always necessary (asierra-970604) -LyX::~LyX() -{ -} - - extern "C" { static diff --git a/src/lyx_main.h b/src/lyx_main.h index 5da9be0173..aa4e1120c8 100644 --- a/src/lyx_main.h +++ b/src/lyx_main.h @@ -1,16 +1,11 @@ // -*- C++ -*- -/* This file is part of -* ====================================================== -* -* LyX, The Document Processor -* -* Copyright 1995 Matthias Ettrich -* Copyright 1995-2001 The LyX Team. -* -* ====================================================== */ - -/* This is the declaration of the LyX class, there should only - * exist _one_ instance of this in the application. */ +/** + * \file lyx_main.h + * Copyright 2002 the LyX Team + * Read the file COPYING + * + * \author unknown + */ #ifndef LYX_MAIN_H #define LYX_MAIN_H @@ -32,27 +27,20 @@ class LastFiles; class Buffer; class kb_keymap; -/// -extern string system_lyxdir; + /// extern string user_lyxdir; /// +extern string system_lyxdir; +/// extern string system_tempdir; /// extern boost::scoped_ptr lastfiles; -/* we should hopefully be able to move this - * inside the LyX class */ -/** - This is the main LyX object it encapsulates most of the other objects. -*/ class LyX : boost::noncopyable { public: - /// the only allowed constructor - LyX(int * argc, char * argv[]); // constructor - /// Always is useful a destructor - ~LyX(); + LyX(int * argc, char * argv[]); /// in the case of failure static void emergencyCleanup(); diff --git a/src/main.C b/src/main.C index cd9680818c..5ad6288898 100644 --- a/src/main.C +++ b/src/main.C @@ -13,6 +13,7 @@ #include "lyx_main.h" #include "gettext.h" #include "LString.h" +#include "lyx_gui.h" #include "support/filetools.h" #include "support/os.h" #include "frontends/GUIRunTime.h" diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index b86cd77e1d..12eaf7b76f 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -56,7 +56,6 @@ using std::endl; using std::ostream; using std::vector; - using std::abs; MathCursor * mathcursor = 0; -- 2.39.5