The initial merge of the Qt frontend, and the necessary compile fixes.

All still VERY primitive, in fact even more primitive since some stuff
got re-horked after the meeting, and still needs working on. Won't actually
compile out of the box, but the tweaks should be pretty obvious for any
body sufficiently daring.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4427 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-06-19 03:38:44 +00:00
parent 059bf8b486
commit 0c5c06c8c4
83 changed files with 3233 additions and 586 deletions

View File

@ -1,3 +1,54 @@
2002-06-19 John Levon <moz@compsoc.man.ac.uk>
* Makefile.am: add the new files ...
* Dialogs.C:
* guiapi.C:
* all dialogs: implement new dialog stuff, fix compile
* FileDialog_private.h:
* GUIRunTime.C:
* lyx_gui.C: update for lyx_gui namespace
* LyXScreenFactory.C: add
* QContentPane.h:
* QContentPane.C: new widget for containing a lyx document
* QLPainter.h:
* QLPainter.C: qt painter object
* QWorkArea.h:
* QWorkArea.C: Qt version of the work area
* QtView.h:
* QtView.C: Qt version of LyXView
* Toolbar_pimpl.h:
* Toolbar_pimpl.C:
* Menubar_pimpl.h:
* Menubar_pimpl.C: initial Qt versions
* WorkAreaFactory.C: generate a QWorkArea
* emptytable.C: add a resize grippie
* qfont_loader.h:
* qfont_loader.C: font loader for Qt
* qfont_metrics.h:
* qfont_metrics.C: font metrics for Qt
* qlkey.h: convert Qt key symbol into a name
* qscreen.h:
* qscreen.C: Qt version of screen
* moc/Makefile.am: add new files
* xforms/Makefile.am: remove all xforms dialogs
2002-06-10 Lars Gullik Bjønnes <larsbj@birdstep.com>
* Qt2BC.C: do not include ButtonController.tmpl

View File

@ -7,121 +7,17 @@
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
// the dialog definitions
#include "QAboutDialog.h"
#include "QBibitemDialog.h"
#include "QBibtexDialog.h"
#include "QCharacterDialog.h"
#include "QCitationDialog.h"
#include "QErrorDialog.h"
#include "QERTDialog.h"
#include "QExternalDialog.h"
#include "QFloatDialog.h"
#include "QGraphicsDialog.h"
#include "QIncludeDialog.h"
#include "QIndexDialog.h"
#include "QLogDialog.h"
#include "QMinipageDialog.h"
#include "QPreambleDialog.h"
#include "QPrintDialog.h"
#include "QRefDialog.h"
#include "QSearchDialog.h"
#include "QShowFileDialog.h"
#include "QSpellcheckerDialog.h"
#include "QTabularCreateDialog.h"
#include "QTexinfoDialog.h"
#include "QThesaurusDialog.h"
#include "QTocDialog.h"
#include "QURLDialog.h"
#include "QVCLogDialog.h"
#include "QAbout.h"
#include "QBibitem.h"
#include "QBibtex.h"
#include "QCharacter.h"
#include "QCitation.h"
#include "QError.h"
#include "QERT.h"
#include "QExternal.h"
#include "QFloat.h"
#include "QGraphics.h"
#include "QInclude.h"
#include "QIndex.h"
#include "QLog.h"
#include "QMinipage.h"
#include "QPreamble.h"
#include "QPrint.h"
#include "QRef.h"
#include "QSearch.h"
#include "QShowFile.h"
#include "QSpellchecker.h"
#include "QTabularCreate.h"
#include "QTexinfo.h"
#include "QToc.h"
#include "QThesaurus.h"
#include "QURL.h"
#include "QVCLog.h"
#include "QtLyXView.h"
#include "Dialogs.h"
#include "BufferView.h"
#include "buffer.h"
#include "Qt2BC.h"
// xforms stuff
#include "xforms/FormDocument.h"
#include "xforms/FormMathsPanel.h"
#include "xforms/FormParagraph.h"
#include "xforms/FormPreferences.h"
#include "xforms/FormShowFile.h"
#include "xforms/FormTabular.h"
#include "GUI.h"
LyXView * dialogs_lyxview;
Dialogs::Dialogs(LyXView * lv)
{
// dialogs that have been converted to new scheme
add(new GUICitation<QCitation, Qt2BC>(*lv, *this));
add(new GUIAboutlyx<QAbout, Qt2BC>(*lv, *this));
add(new GUIBibitem<QBibitem, Qt2BC>(*lv, *this));
add(new GUIBibtex<QBibtex, Qt2BC>(*lv, *this));
add(new GUICharacter<QCharacter, Qt2BC>(*lv, *this));
add(new GUIError<QError, Qt2BC>(*lv, *this));
add(new GUIERT<QERT, Qt2BC>(*lv, *this));
add(new GUIExternal<QExternal, Qt2BC>(*lv, *this));
add(new GUIFloat<QFloat, Qt2BC>(*lv, *this));
add(new GUIGraphics<QGraphics, Qt2BC>(*lv, *this));
add(new GUIInclude<QInclude, Qt2BC>(*lv, *this));
add(new GUIIndex<QIndex, Qt2BC>(*lv, *this));
add(new GUILog<QLog, Qt2BC>(*lv, *this));
add(new GUIMinipage<QMinipage, Qt2BC>(*lv, *this));
add(new GUIPreamble<QPreamble, Qt2BC>(*lv, *this));
add(new GUIPrint<QPrint, Qt2BC>(*lv, *this));
add(new GUIRef<QRef, Qt2BC>(*lv, *this));
add(new GUISearch<QSearch, Qt2BC>(*lv, *this));
add(new GUIShowFile<QShowFile, Qt2BC>(*lv, *this));
add(new GUISpellchecker<QSpellchecker, Qt2BC>(*lv, *this));
add(new GUITabularCreate<QTabularCreate, Qt2BC>(*lv, *this));
add(new GUITexinfo<QTexinfo, Qt2BC>(*lv, *this));
add(new GUIThesaurus<QThesaurus, Qt2BC>(*lv, *this));
add(new GUIToc<QToc, Qt2BC>(*lv, *this));
add(new GUIUrl<QURL, Qt2BC>(*lv, *this));
add(new GUIVCLog<QVCLog, Qt2BC>(*lv, *this));
// dialogs not yet MVCd
add(new FormDocument(lv, this));
add(new FormMathsPanel(lv, this));
add(new FormParagraph(lv, this));
add(new FormPreferences(lv, this));
add(new FormTabular(lv, this));
dialogs_lyxview = lv;
// reduce the number of connections needed in
// dialogs by a simple connection here.
hideAll.connect(hideBufferDependent.slot());
hideAll.connect(hideBufferDependent);
}

View File

@ -12,13 +12,13 @@
#include <config.h>
#include <qfiledialog.h>
#include "LString.h"
#include "lyxfunc.h"
#include "frontends/FileDialog.h"
#include <qfiledialog.h>
class LyXView;
class LyXFileDialog : public QFileDialog

View File

@ -1,167 +0,0 @@
/**
* \file qt2/GUIRunTime.C
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author John Levon
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <qapplication.h>
#include <qpainter.h>
#include "QtLyXView.h"
#include "XFormsView.h"
#include "GUIRunTime.h"
#include "debug.h"
#include FORMS_H_LOCATION
// For now we use the xforms image loader if we can.
// In the future, this will be replaced by a Qt equivalent.
#if defined(HAVE_FLIMAGE_DUP) && defined(HAVE_FLIMAGE_TO_PIXMAP)
#include "xforms/xformsGImage.h"
#else
#include "graphics/GraphicsImageXPM.h"
#endif
using std::endl;
// For now we need this here as long as we use xforms components!
extern bool finished;
int GUIRunTime::initApplication(int & argc, char * argv[])
{
int const xforms_include_version = FL_INCLUDE_VERSION;
// Check the XForms version in the forms.h header against
// the one in the libforms. If they don't match quit the
// execution of LyX. Better with a clean fast exit than
// a strange segfault later.
int xforms_lib_version = fl_library_version(0, 0);
if (xforms_include_version != xforms_lib_version) {
lyxerr << "You are either running LyX with wrong "
"version of a dynamic XForms library\n"
"or you have build LyX with conflicting header "
"and library (different\n"
"versions of XForms. Sorry but there is no point "
"in continuing executing LyX!" << endl;
return 1;
}
// I belive this is done in the wrong place, imo this should
// be done in lyx_gui.C similar to how/where xforms does it (Lgb)
static QApplication a(argc, argv);
return 0;
}
void GUIRunTime::processEvents()
{
qApp->processEvents();
}
void GUIRunTime::runTime()
{
// We still use xforms event handler as the main one...
XEvent ev;
while (!finished) {
processEvents();
if (fl_check_forms() == FL_EVENT) {
fl_XNextEvent(&ev);
lyxerr << "Received unhandled X11 event" << endl;
lyxerr << "Type: 0x" << std::hex << ev.xany.type <<
"Target: 0x" << std::hex << ev.xany.window << endl;
}
}
}
LyXView * GUIRunTime::createMainView(int w, int h)
{
return new XFormsView(w, h);
}
// Called by the graphics cache to connect the appropriate frontend
// image loading routines to the LyX kernel.
void GUIRunTime::initialiseGraphics()
{
using namespace grfx;
using SigC::slot;
#if defined(HAVE_FLIMAGE_DUP) && defined(HAVE_FLIMAGE_TO_PIXMAP)
// connect the image loader based on the xforms library
GImage::newImage.connect(slot(&xformsGImage::newImage));
GImage::loadableFormats.connect(slot(&xformsGImage::loadableFormats));
#else
// connect the image loader based on the XPM library
GImage::newImage.connect(slot(&GImageXPM::newImage));
GImage::loadableFormats.connect(slot(&GImageXPM::loadableFormats));
#endif
}
Display * GUIRunTime::x11Display()
{
//return p.device()->x11Display();
return fl_get_display();
}
int GUIRunTime::x11Screen()
{
//return p.device()->x11Screen();
return fl_screen;
}
Colormap GUIRunTime::x11Colormap()
{
//return p.device()->x11Colormap();
return fl_state[fl_get_vclass()].colormap;
}
int GUIRunTime::x11VisualDepth()
{
//return p.device()->x11Depth();
return fl_get_visual_depth();
}
float GUIRunTime::getScreenDPI()
{
Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen);
return ((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
(WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2;
}
void GUIRunTime::setDefaults()
{
FL_IOPT cntl;
cntl.buttonFontSize = FL_NORMAL_SIZE;
cntl.browserFontSize = FL_NORMAL_SIZE;
cntl.labelFontSize = FL_NORMAL_SIZE;
cntl.choiceFontSize = FL_NORMAL_SIZE;
cntl.inputFontSize = FL_NORMAL_SIZE;
cntl.menuFontSize = FL_NORMAL_SIZE;
cntl.borderWidth = -1;
cntl.vclass = FL_DefaultVisual;
fl_set_defaults(FL_PDVisual
| FL_PDButtonFontSize
| FL_PDBrowserFontSize
| FL_PDLabelFontSize
| FL_PDChoiceFontSize
| FL_PDInputFontSize
| FL_PDMenuFontSize
| FL_PDBorderWidth, &cntl);
}

View File

@ -0,0 +1,23 @@
/**
* \file LyXScreenFactory.C
* Copyright 2002 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#include "frontends/LyXScreenFactory.h"
#include "QWorkArea.h"
#include "qscreen.h"
namespace LyXScreenFactory {
LyXScreen * create(WorkArea & owner)
{
return new QScreen(static_cast<QWorkArea &>(owner));
}
}

View File

@ -21,19 +21,42 @@ libqt2_la_SOURCES = \
$(DIALOGSOURCES) \
Alert_pimpl.C \
Dialogs.C \
GUIRunTime.C \
FileDialog.C \
FileDialog_private.C \
Timeout_pimpl.h \
LyXScreenFactory.C \
Menubar_pimpl.C \
Menubar_pimpl.h \
Timeout_pimpl.C \
Qt2Base.C \
Qt2Base.h \
Timeout_pimpl.h \
Toolbar_pimpl.C \
Toolbar_pimpl.h \
QContentPane.C \
QContentPane.h \
QLPainter.C \
QLPainter.h \
QLyXKeySym.C \
QLyXKeySym.h \
Qt2Base.C \
Qt2Base.h \
Qt2BC.C \
Qt2BC.h \
QtView.h \
QtView.C \
QWorkArea.h \
QWorkArea.C \
WorkAreaFactory.C \
emptytable.C \
emptytable.h \
guiapi.C \
lengthcombo.C \
lengthcombo.h \
lyx_gui.C \
qfont_loader.h \
qfont_loader.C \
qfont_metrics.C \
qlkey.h \
qscreen.h \
qscreen.C \
qttableview.h \
qttableview.C

View File

@ -12,16 +12,16 @@
#include "Lsstream.h"
#include "debug.h"
#include "gettext.h"
#include "QAboutDialog.h"
#include "LyXView.h"
#include "ButtonControllerBase.h"
#include "ControlAboutlyx.h"
#include <qlabel.h>
#include <qpushbutton.h>
#include <qtextview.h>
#include "QtLyXView.h"
#include "ButtonControllerBase.h"
#include "QAboutDialog.h"
#include "Qt2BC.h"
#include "ControlAboutlyx.h"
#include "QAbout.h"
using std::getline;

View File

@ -10,16 +10,17 @@
#include "support/lstrings.h"
#include "QBibitemDialog.h"
#include "ControlBibitem.h"
#include "QBibitem.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "debug.h"
#include <qlineedit.h>
#include <qpushbutton.h>
#include "QBibitemDialog.h"
#include "QBibitem.h"
#include "Qt2BC.h"
typedef Qt2CB<ControlBibitem, Qt2DB<QBibitemDialog> > base_class;
QBibitem::QBibitem(ControlBibitem & c)

View File

@ -6,14 +6,16 @@
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#include "ControlBibitem.h"
#include <qpushbutton.h>
#include <qlineedit.h>
#include "QBibitemDialog.h"
#include "QBibitem.h"
#include "Dialogs.h"
#include "ControlBibitem.h"
QBibitemDialog::QBibitemDialog(QBibitem * form)
: QBibitemDialogBase(0, 0, false, 0),
form_(form)

View File

@ -10,10 +10,7 @@
#include "support/lstrings.h"
#include "QBibtexDialog.h"
#include "ControlBibtex.h"
#include "QBibtex.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "debug.h"
@ -23,6 +20,10 @@
#include <qlistbox.h>
#include <qcheckbox.h>
#include "QBibtexDialog.h"
#include "QBibtex.h"
#include "Qt2BC.h"
typedef Qt2CB<ControlBibtex, Qt2DB<QBibtexDialog> > base_class;
QBibtex::QBibtex(ControlBibtex & c)

View File

@ -6,6 +6,14 @@
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#include "ControlBibtex.h"
#include "gettext.h"
#include "debug.h"
#include "support/filetools.h"
#include <qwidget.h>
#include <qpushbutton.h>
#include <qcombobox.h>
@ -16,13 +24,7 @@
#include "QBibtexDialog.h"
#include "QBibtex.h"
#include "Dialogs.h"
#include "ControlBibtex.h"
#include "gettext.h"
#include "debug.h"
#include "support/filetools.h"
QBibtexDialog::QBibtexDialog(QBibtex * form)
: QBibtexDialogBase(0, 0, false, 0),
form_(form)

View File

@ -43,7 +43,7 @@ void QCharacter::build_dialog()
size = getSizeData();
bar = getBarData();
color = getColorData();
language = getLanguageData();
language = getLanguageData(true);
for (vector<FamilyPair>::const_iterator cit = family.begin();
cit != family.end(); ++cit) {

View File

@ -12,8 +12,8 @@
#include <config.h>
#include "ui/QCharacterDialogBase.h"
#include "QCharacter.h"
#include "ui/QCharacterDialogBase.h"
#include <qevent.h>
#include <qcheckbox.h>

View File

@ -7,12 +7,13 @@
*/
#include <config.h>
#include <algorithm>
#include "gettext.h"
#include "QCitationDialog.h"
#include "Dialogs.h"
#include "controllers/ControlCitation.h"
#include "LyXView.h"
#include "buffer.h"
#include <qcheckbox.h>
#include <qcombobox.h>
@ -21,11 +22,8 @@
#include <qmultilineedit.h>
#include <qpushbutton.h>
#include "QtLyXView.h"
#include <algorithm>
#include "buffer.h"
#include "QCitationDialog.h"
using std::vector;
using std::find;
using std::max;

View File

@ -12,8 +12,8 @@
#include <config.h>
#include "support/lstrings.h"
#include "ui/QCitationDialogBase.h"
#include "QCitation.h"
#include "ui/QCitationDialogBase.h"
#include "controllers/biblio.h"
class QCitationDialog : public QCitationDialogBase

View File

@ -0,0 +1,171 @@
/**
* \file QContentPane.C
* Copyright 1995-2002 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "debug.h"
#include "QWorkArea.h"
#include "QLyXKeySym.h"
#include <qevent.h>
#include <qpainter.h>
namespace {
/// return the LyX key state from Qt's
key_modifier::state q_key_state(Qt::ButtonState state)
{
key_modifier::state k = key_modifier::none;
if (state & Qt::ControlButton)
k |= key_modifier::ctrl;
if (state & Qt::ShiftButton)
k |= key_modifier::shift;
if (state & Qt::AltButton)
k |= key_modifier::alt;
return k;
}
/// return the LyX mouse button state from Qt's
mouse_button::state q_button_state(Qt::ButtonState button)
{
mouse_button::state b = mouse_button::none;
switch (button) {
case Qt::LeftButton:
b = mouse_button::button1;
break;
case Qt::MidButton:
b = mouse_button::button2;
break;
case Qt::RightButton:
b = mouse_button::button3;
break;
default:
break;
}
return b;
}
/// return the LyX mouse button state from Qt's
mouse_button::state q_motion_state(Qt::ButtonState state)
{
mouse_button::state b = mouse_button::none;
if (state & Qt::LeftButton)
b |= mouse_button::button1;
if (state & Qt::MidButton)
b |= mouse_button::button2;
if (state & Qt::RightButton)
b |= mouse_button::button3;
return b;
}
} // namespace anon
QContentPane::QContentPane(QWorkArea * parent)
: QWidget(parent, "content_pane", WRepaintNoErase),
wa_(parent)
{
setFocusPolicy(QWidget::WheelFocus);
setFocus();
// stupid moc strikes again
connect(wa_->scrollbar_, SIGNAL(valueChanged(int)),
this, SLOT(scrollBarChanged(int)));
}
void QContentPane::scrollBarChanged(int val)
{
wa_->scrollDocView(val);
}
void QContentPane::mousePressEvent(QMouseEvent * e)
{
wa_->workAreaButtonPress(e->x(), e->y(), q_button_state(e->button()));
}
void QContentPane::mouseReleaseEvent(QMouseEvent * e)
{
wa_->workAreaButtonRelease(e->x(), e->y(), q_button_state(e->button()));
}
void QContentPane::mouseMoveEvent(QMouseEvent * e)
{
wa_->workAreaMotionNotify(e->x(), e->y(), q_motion_state(e->state()));
}
void QContentPane::keyPressEvent(QKeyEvent * e)
{
char const * tmp = e->text().latin1();
string const text = tmp ? tmp : "";
lyxerr[Debug::GUI] << "key text " << text << endl;
wa_->workAreaKeyPress(LyXKeySymPtr(new QLyXKeySym(*e)), q_key_state(e->state()));
}
void QContentPane::focusInEvent(QFocusEvent *)
{
wa_->workAreaFocus();
}
void QContentPane::focusOutEvent(QFocusEvent *)
{
wa_->workAreaUnfocus();
}
void QContentPane::mouseDoubleClickEvent(QMouseEvent * e)
{
wa_->workAreaDoubleClick(e->x(), e->y(), q_button_state(e->state()));
// FIXME: triple click
}
void QContentPane::resizeEvent(QResizeEvent *)
{
if (!pixmap_.get()) {
pixmap_.reset(new QPixmap(width(), height()));
}
pixmap_->resize(width(), height());
// FIXME wa_->workAreaResize();
}
void QContentPane::paintEvent(QPaintEvent * e)
{
if (!pixmap_.get()) {
pixmap_.reset(new QPixmap(width(), height()));
// FIXME: hmm. We do this to get an /initial/
// painting. So it's wrong.
// FIXME wa_->workAreaResize();
return;
}
QRect r(e->rect());
lyxerr[Debug::GUI] << "repainting " << r.x()
<< "," << r.y() << " " << r.width()
<< "," << r.height() << endl;
QPainter q(this);
q.drawPixmap(QPoint(r.x(), r.y()),
*pixmap_.get(), r);
}

View File

@ -0,0 +1,73 @@
// -*- C++ -*-
/**
* \file QContentPane.h
* Copyright 1995-2002 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef QCONTENTPANE_H
#define QCONTENTPANE_H
#ifdef __GNUG__
#pragma interface
#endif
#include <config.h>
#include <utility>
#include <boost/smart_ptr.hpp>
#include <qwidget.h>
#include <qscrollbar.h>
#include <qpixmap.h>
#include <qevent.h>
class QWorkArea;
/**
* Widget for actually drawing the document on
*/
class QContentPane : public QWidget {
Q_OBJECT
public:
QContentPane(QWorkArea * parent);
/// return the backing pixmap
QPixmap * pixmap() const { return pixmap_.get(); }
protected:
/// repaint part of the widget
void paintEvent(QPaintEvent * e);
/// widget has been resized
void resizeEvent(QResizeEvent * e);
/// keyboard focus in this widget
void focusInEvent(QFocusEvent * e);
/// keyboard focus lost
void focusOutEvent(QFocusEvent * e);
/// mouse button press
void mousePressEvent(QMouseEvent * e);
/// mouse button release
void mouseReleaseEvent(QMouseEvent * e);
/// mouse double click of button
void mouseDoubleClickEvent(QMouseEvent * e);
/// mouse motion
void mouseMoveEvent(QMouseEvent * e);
/// key press
void keyPressEvent(QKeyEvent * e);
public slots:
void scrollBarChanged(int);
private:
/// owning widget
QWorkArea * wa_;
/// the double buffered pixmap
boost::scoped_ptr<QPixmap> pixmap_;
};
#endif // QCONTENTPANE_H

View File

@ -17,7 +17,6 @@
#include "lyx_gui_misc.h"
#include "Dialogs.h"
#include "layout.h"
#include "tex-strings.h"
#include "bufferparams.h"

View File

@ -8,15 +8,16 @@
#include <config.h>
#include "QERTDialog.h"
#include "ControlERT.h"
#include "QERT.h"
#include "Qt2BC.h"
#include "gettext.h"
#include <qradiobutton.h>
#include <qpushbutton.h>
#include "QERTDialog.h"
#include "QERT.h"
#include "Qt2BC.h"
typedef Qt2CB<ControlERT, Qt2DB<QERTDialog> > base_class;
QERT::QERT(ControlERT & c)

View File

@ -6,9 +6,10 @@
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include "QERTDialog.h"
#include "Dialogs.h"
#include <config.h>
#include "QERT.h"
#include "QERTDialog.h"
#include <qpushbutton.h>

View File

@ -11,8 +11,8 @@
#include <config.h>
#include "ui/QERTDialogBase.h"
#include "QERT.h"
#include "ui/QERTDialogBase.h"
class QERTDialog : public QERTDialogBase
{ Q_OBJECT

View File

@ -8,15 +8,16 @@
#include <config.h>
#include "QErrorDialog.h"
#include "ControlError.h"
#include "QError.h"
#include "Qt2BC.h"
#include "gettext.h"
#include <qtextview.h>
#include <qpushbutton.h>
#include "QErrorDialog.h"
#include "QError.h"
#include "Qt2BC.h"
typedef Qt2CB<ControlError, Qt2DB<QErrorDialog> > base_class;
QError::QError(ControlError & c)

View File

@ -6,13 +6,15 @@
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include "QErrorDialog.h"
#include "Dialogs.h"
#include <config.h>
#include "QError.h"
#include <qwidget.h>
#include <qpushbutton.h>
#include "QErrorDialog.h"
QErrorDialog::QErrorDialog(QError * form)
: QErrorDialogBase(0, 0, false, 0),
form_(form)

View File

@ -9,10 +9,7 @@
#include <config.h>
#include <vector>
#include "QExternalDialog.h"
#include "ControlExternal.h"
#include "QExternal.h"
#include "Qt2BC.h"
#include "gettext.h"
#include <qlineedit.h>
@ -20,6 +17,10 @@
#include <qcombobox.h>
#include <qtextview.h>
#include "QExternalDialog.h"
#include "QExternal.h"
#include "Qt2BC.h"
typedef Qt2CB<ControlExternal, Qt2DB<QExternalDialog> > base_class;
QExternal::QExternal(ControlExternal & c)

View File

@ -8,6 +8,9 @@
#include <config.h>
#include "gettext.h"
#include "ControlExternal.h"
#include <qwidget.h>
#include <qpushbutton.h>
#include <qfiledialog.h>
@ -15,10 +18,7 @@
#include <qtextview.h>
#include <qlineedit.h>
#include "gettext.h"
#include "QExternalDialog.h"
#include "ControlExternal.h"
#include "Dialogs.h"
#include "QExternal.h"
QExternalDialog::QExternalDialog(QExternal * form)

View File

@ -8,15 +8,15 @@
#include <config.h>
#include <qpushbutton.h>
#include "LString.h"
#include "ControlFloat.h"
#include "QFloatDialog.h"
#include "Dialogs.h"
#include "QFloat.h"
#include <qpushbutton.h>
#include "QFloatDialog.h"
#include "QFloat.h"
QFloatDialog::QFloatDialog(QFloat * form)
: QFloatDialogBase(0, 0, false, 0),
form_(form)

View File

@ -13,6 +13,18 @@
#pragma implementation
#endif
#include "QtLyXView.h"
#include "ControlGraphics.h"
#include "support/lstrings.h"
#include "support/FileInfo.h"
#include "support/filetools.h"
#include "insets/insetgraphicsParams.h"
#include "lyxrc.h"
#include "lengthcombo.h"
#include "gettext.h"
#include "debug.h"
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qcheckbox.h>
@ -22,22 +34,9 @@
#include <qbuttongroup.h>
#include <qlabel.h>
#include "lengthcombo.h"
#include "QGraphicsDialog.h"
#include "QGraphics.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "debug.h"
#include "QtLyXView.h"
#include "ControlGraphics.h"
#include "support/lstrings.h"
#include "support/FileInfo.h"
#include "support/filetools.h" // for MakeAbsPath etc
#include "insets/insetgraphicsParams.h"
#include "lyxrc.h" // for lyxrc.display_graphics
typedef Qt2CB<ControlGraphics, Qt2DB<QGraphicsDialog> > base_class;

View File

@ -14,8 +14,8 @@
#pragma interface
#endif
#include "Qt2Base.h"
#include "insets/insetgraphics.h"
#include "Qt2Base.h"
class ControlGraphics;
class QGraphicsDialog;

View File

@ -9,17 +9,16 @@
#include <config.h>
#include <vector>
#include "ControlGraphics.h"
#include "debug.h"
#include "LString.h"
#include <qwidget.h>
#include <qpushbutton.h>
#include <qcheckbox.h>
#include "LString.h"
#include "QGraphicsDialog.h"
#include "ControlGraphics.h"
#include "Dialogs.h"
#include "QGraphics.h"
#include "debug.h"
QGraphicsDialog::QGraphicsDialog(QGraphics * form)
: QGraphicsDialogBase(0, 0, false, 0),

View File

@ -12,12 +12,13 @@
#pragma implementation
#endif
#include "QIncludeDialog.h"
#include "ControlInclude.h"
#include "QInclude.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "debug.h"
#include "QIncludeDialog.h"
#include "QInclude.h"
#include "Qt2BC.h"
#include <qlineedit.h>
#include <qpushbutton.h>

View File

@ -9,17 +9,16 @@
#include <config.h>
#include <vector>
#include "ControlInclude.h"
#include "debug.h"
#include "LString.h"
#include <qwidget.h>
#include <qpushbutton.h>
#include <qcheckbox.h>
#include "LString.h"
#include "QIncludeDialog.h"
#include "ControlInclude.h"
#include "Dialogs.h"
#include "QInclude.h"
#include "debug.h"
QIncludeDialog::QIncludeDialog(QInclude * form)
: QIncludeDialogBase(0, 0, false, 0),

View File

@ -8,12 +8,12 @@
#include <config.h>
#include "QIndexDialog.h"
#include "ControlIndex.h"
#include "QIndex.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "QIndexDialog.h"
#include "QIndex.h"
#include "Qt2BC.h"
#include <qlineedit.h>
#include <qpushbutton.h>

View File

@ -8,11 +8,11 @@
#include <config.h>
#include "QIndexDialog.h"
#include "Dialogs.h"
#include "QIndex.h"
#include "gettext.h"
#include "QIndex.h"
#include "QIndexDialog.h"
#include <qpushbutton.h>
#include <qlineedit.h>
#include <qwhatsthis.h>

View File

@ -0,0 +1,257 @@
/**
* \file QLPainter.C
* Copyright 1998-2002 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <iostream>
//#include "graphics/GraphicsImage.h"
#include "font_metrics.h"
#include "support/lstrings.h"
#include "lyxrc.h"
#include "debug.h"
#include "LyXView.h"
#include "QWorkArea.h"
#include "qfont_loader.h"
#include "QLPainter.h"
#include <qpainter.h>
#include <qbrush.h>
#include <qcolor.h>
QLPainter::QLPainter(QWorkArea & qwa)
: Painter(), owner_(qwa), paint_check_(0)
{
qp_.reset(new QPainter());
}
void QLPainter::start()
{
if (++paint_check_ == 1)
qp_->begin(owner_.getPixmap());
}
void QLPainter::end()
{
if (paint_check_ == 0) {
lyxerr << "ended painting whilst not painting ??" << endl;
} else if (--paint_check_ == 0) {
qp_->end();
}
}
int QLPainter::paperWidth() const
{
return owner_.workWidth();
}
int QLPainter::paperHeight() const
{
return owner_.workHeight();
}
QPainter & QLPainter::setPen(LColor::color c,
Painter::line_style ls, Painter::line_width lw)
{
QPen pen = qp_->pen();
pen.setColor(lcolor.getX11Name(c).c_str());
switch (ls) {
case line_solid: pen.setStyle(QPen::SolidLine); break;
case line_onoffdash: pen.setStyle(QPen::DashLine); break;
}
switch (lw) {
case line_thin: pen.setWidth(0); break;
case line_thick: pen.setWidth(3); break;
}
qp_->setPen(pen);
return *qp_;
}
Painter & QLPainter::point(int x, int y, LColor::color c)
{
setPen(c).drawPoint(x, y);
return *this;
}
Painter & QLPainter::line(int x1, int y1,
int x2, int y2,
LColor::color col,
line_style ls,
line_width lw)
{
setPen(col, ls, lw).drawLine(x1, y1, x2, y2);
return *this;
}
Painter & QLPainter::lines(int const * xp, int const * yp,
int np,
LColor::color col,
line_style ls,
line_width lw)
{
// FIXME ?
QCOORD points[np * 2];
int j = 0;
for (int i = 0; i < np; ++i) {
points[j++] = xp[i];
points[j++] = yp[i];
}
setPen(col, ls, lw).drawPolyline(QPointArray(np, points));
return *this;
}
Painter & QLPainter::rectangle(int x, int y,
int w, int h,
LColor::color col,
line_style ls,
line_width lw)
{
setPen(col, ls, lw).drawRect(x, y, w, h);
return *this;
}
Painter & QLPainter::fillRectangle(int x, int y,
int w, int h,
LColor::color col)
{
qp_->fillRect(x, y, w, h, QColor(lcolor.getX11Name(col).c_str()));
return *this;
}
Painter & QLPainter::fillPolygon(int const * xp, int const * yp,
int np, LColor::color col)
{
// FIXME ?
QCOORD points[np * 2];
int j = 0;
for (int i = 0; i < np; ++i) {
points[j++] = xp[i];
points[j++] = yp[i];
}
setPen(col).drawPolygon(QPointArray(np, points));
return *this;
}
Painter & QLPainter::arc(int x, int y,
unsigned int w, unsigned int h,
int a1, int a2, LColor::color col)
{
// FIXME
setPen(col).drawArc(x, y, w, h, a1, a2);
return *this;
}
Painter & QLPainter::image(int , int ,
int , int ,
grfx::GImage const & )
{
#if 0 // FIXME
XGCValues val;
val.function = GXcopy;
GC gc = XCreateGC(display(), owner_.getPixmap(),
GCFunction, &val);
XCopyArea(display(), image.getPixmap(), owner_.getPixmap(),
gc, 0, 0, w, h, x, y);
XFreeGC(display(), gc);
#endif
return *this;
}
Painter & QLPainter::text(int x, int y,
string const & s, LyXFont const & f)
{
return text(x, y, s.data(), s.length(), f);
}
Painter & QLPainter::text(int x, int y,
char c, LyXFont const & f)
{
char s[2] = { c, '\0' };
return text(x, y, s, 1, f);
}
void QLPainter::smallCapsText(int x, int y,
char const * s, size_t ls,
LyXFont const & f)
{
LyXFont smallfont(f);
smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
QFont const & qfont = fontloader.get(f);
QFont const & qsmallfont = fontloader.get(smallfont);
QFontMetrics const & qfontm = QFontMetrics(qfont);
QFontMetrics const & qsmallfontm = QFontMetrics(qsmallfont);
int tmpx = x;
for (size_t i = 0; i < ls; ++i) {
char const c = uppercase(s[i]);
if (c != s[i]) {
qp_->setFont(qsmallfont);
qp_->drawText(tmpx, y, &c, 1);
tmpx += qsmallfontm.width(&c, 1);
} else {
qp_->setFont(qfont);
qp_->drawText(tmpx, y, &c, 1);
tmpx += qfontm.width(&c, 1);
}
}
}
Painter & QLPainter::text(int x, int y,
char const * s, size_t ls,
LyXFont const & f)
{
setPen(f.color());
if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
qp_->setFont(fontloader.get(f));
qp_->drawText(x, y, s, ls);
} else {
smallCapsText(x, y, s, ls, f);
}
if (f.underbar() == LyXFont::ON) {
underline(f, x, y, font_metrics::width(s, ls, f));
}
return *this;
}

View File

@ -0,0 +1,142 @@
// -*- C++ -*-
/**
* \file QLPainter.h
* Copyright 1995-2002 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef QLPAINTER_H
#define QLPAINTER_H
#ifdef __GNUG__
#pragma interface
#endif
#include <config.h>
#include <boost/smart_ptr.hpp>
#include "Painter.h"
#include "LString.h"
#include "LColor.h"
class LyXFont;
class QWorkArea;
class QPainter;
/**
* QLPainter - a painter implementation for Xlib
*/
class QLPainter : public Painter {
public:
QLPainter(QWorkArea &);
/// begin painting
virtual void start();
/// end painting
virtual void end();
/// return the width of the work area in pixels
virtual int paperWidth() const;
/// return the height of the work area in pixels
virtual int paperHeight() const;
/// draw a line from point to point
virtual Painter & line(
int x1, int y1,
int x2, int y2,
LColor::color = LColor::foreground,
line_style = line_solid,
line_width = line_thin);
/**
* lines - draw a set of lines
* @param xp array of points' x co-ords
* @param yp array of points' y co-ords
* @param np size of the points array
*/
virtual Painter & lines(
int const * xp,
int const * yp,
int np,
LColor::color = LColor::foreground,
line_style = line_solid,
line_width = line_thin);
/// draw a rectangle
virtual Painter & rectangle(
int x, int y,
int w, int h,
LColor::color = LColor::foreground,
line_style = line_solid,
line_width = line_thin);
/// draw a filled rectangle
virtual Painter & fillRectangle(
int x, int y,
int w, int h,
LColor::color);
/// draw a filled (irregular) polygon
virtual Painter & fillPolygon(
int const * xp,
int const * yp,
int np,
LColor::color = LColor::foreground);
/// draw an arc
virtual Painter & arc(
int x, int y,
unsigned int w, unsigned int h,
int a1, int a2,
LColor::color = LColor::foreground);
/// draw a pixel
virtual Painter & point(
int x, int y,
LColor::color = LColor::foreground);
/// draw an image from the image cache
virtual Painter & image(int x, int y,
int w, int h,
grfx::GImage const & image);
/// draw a string at position x, y (y is the baseline)
virtual Painter & text(int x, int y,
string const & str, LyXFont const & f);
/** Draw a string at position x, y (y is the baseline)
* This is just for fast drawing
*/
virtual Painter & text(int x, int y,
char const * str, size_t l,
LyXFont const & f);
/// draw a char at position x, y (y is the baseline)
virtual Painter & text(int x, int y,
char c, LyXFont const & f);
private:
/// draw small caps text
void smallCapsText(int x, int y,
char const * str, size_t l,
LyXFont const & f);
/// set pen parameters
QPainter & setPen(LColor::color c,
line_style ls = line_solid,
line_width lw = line_thin);
/// our owner who we paint upon
QWorkArea & owner_;
/// our qt painter
boost::scoped_ptr<QPainter> qp_;
/// recursion check
int paint_check_;
};
#endif // QLPAINTER_H

View File

@ -13,16 +13,16 @@
#pragma implementation
#endif
#include "LyXView.h"
#include "gettext.h"
#include "ControlLog.h"
#include <qtextview.h>
#include <qpushbutton.h>
#include "QLogDialog.h"
#include "QLog.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "QtLyXView.h"
#include "ControlLog.h"
using std::ifstream;
using std::getline;

View File

@ -9,15 +9,15 @@
#include <config.h>
#include <vector>
#include "LyXView.h"
#include "ControlLog.h"
#include <qpushbutton.h>
#include <qtextview.h>
#include "QLogDialog.h"
#include "Dialogs.h"
#include "QLog.h"
#include "QtLyXView.h"
#include "ControlLog.h"
QLogDialog::QLogDialog(QLog * form)
: QLogDialogBase(0, 0, false, 0),
form_(form)

View File

@ -12,21 +12,21 @@
#pragma implementation
#endif
#include "debug.h"
#include "gettext.h"
#include "support/lstrings.h"
#include "LyXView.h"
#include "ControlMinipage.h"
#include "QMinipage.h"
#include "QMinipageDialog.h"
#include "Qt2BC.h"
#include "lengthcombo.h"
#include <qpushbutton.h>
#include <qcombobox.h>
#include <qlineedit.h>
#include "lengthcombo.h"
#include "QMinipageDialog.h"
#include "QMinipage.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "support/lstrings.h"
#include "QtLyXView.h"
#include "ControlMinipage.h"
#include "debug.h"
typedef Qt2CB<ControlMinipage, Qt2DB<QMinipageDialog> > base_class;
QMinipage::QMinipage(ControlMinipage & c)

View File

@ -9,17 +9,15 @@
#include <config.h>
#include <vector>
#include "ControlMinipage.h"
#include "QMinipage.h"
#include "QMinipageDialog.h"
#include <qpushbutton.h>
#include <qtextview.h>
#include "lengthcombo.h"
#include "QMinipageDialog.h"
#include "Dialogs.h"
#include "QMinipage.h"
#include "QtLyXView.h"
#include "ControlMinipage.h"
QMinipageDialog::QMinipageDialog(QMinipage * form)
: QMinipageDialogBase(0, 0, false, 0),
form_(form)

View File

@ -11,7 +11,6 @@
#include "QParagraphDialog.h"
#include "QParagraph.h"
#include "Dialogs.h"
#include "Liason.h"
#include "gettext.h"
#include "buffer.h"

View File

@ -13,17 +13,17 @@
#pragma implementation
#endif
#include "gettext.h"
#include "LyXView.h"
#include "ControlPreamble.h"
#include "QPreamble.h"
#include "QPreambleDialog.h"
#include "Qt2BC.h"
#include <qmultilineedit.h>
#include <qpushbutton.h>
#include "QPreambleDialog.h"
#include "QPreamble.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "QtLyXView.h"
#include "ControlPreamble.h"
typedef Qt2CB<ControlPreamble, Qt2DB<QPreambleDialog> > base_class;
QPreamble::QPreamble(ControlPreamble & c)

View File

@ -9,22 +9,20 @@
#include <config.h>
#include <fstream>
#include <qpushbutton.h>
#include <qmultilineedit.h>
#include <qinputdialog.h>
#include "QPreambleDialog.h"
#include "Dialogs.h"
#include "QPreamble.h"
#include "support/lyxlib.h"
#include "support/forkedcall.h"
#include "support/filetools.h"
#include "gettext.h"
#include "QtLyXView.h"
#include "LyXView.h"
#include "ControlPreamble.h"
#include "QPreamble.h"
#include "QPreambleDialog.h"
#include <qpushbutton.h>
#include <qmultilineedit.h>
#include <qinputdialog.h>
using std::getline;
QPreambleDialog::QPreambleDialog(QPreamble * form)

View File

@ -13,22 +13,23 @@
#pragma implementation
#endif
#include "LyXView.h"
#include "ControlPrint.h"
#include "support/lstrings.h"
#include "gettext.h"
#include "QPrint.h"
#include "QPrintDialog.h"
#include "Qt2BC.h"
#include <qlineedit.h>
#include <qcheckbox.h>
#include <qradiobutton.h>
#include <qspinbox.h>
#include <qpushbutton.h>
#include "QPrintDialog.h"
#include "QPrint.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "QtLyXView.h"
#include "ControlPrint.h"
#include "support/lstrings.h"
// FIXME FIXME QPrintDialog is getting destructed twice !!!!
typedef Qt2CB<ControlPrint, Qt2DB<QPrintDialog> > base_class;
QPrint::QPrint(ControlPrint & c)

View File

@ -7,6 +7,15 @@
* \author Edwin Leuven, leuven@fee.uva.nl
*/
#include <config.h>
#include <gettext.h>
#include "support/filetools.h"
#include "support/lstrings.h"
#include "QPrint.h"
#include "QPrintDialog.h"
#include <qfiledialog.h>
#include <qcheckbox.h>
#include <qlabel.h>
@ -15,17 +24,6 @@
#include <qradiobutton.h>
#include <qspinbox.h>
#include "QPrintDialog.h"
#include "QPrint.h"
#include <config.h>
#include "support/filetools.h"
#include "support/lstrings.h"
#include <gettext.h>
QPrintDialog::QPrintDialog(QPrint * f)
: QPrintDialogBase(0, 0, false, 0),
form_(f)

View File

@ -9,13 +9,13 @@
#include <config.h>
#include "support/lstrings.h"
#include "QRefDialog.h"
#include "ControlRef.h"
#include "QRef.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "insets/insetref.h"
#include "QRef.h"
#include "QRefDialog.h"
#include "Qt2BC.h"
#include <qlineedit.h>
#include <qcheckbox.h>

View File

@ -9,17 +9,17 @@
#include <config.h>
#include "ControlRef.h"
#include "debug.h"
#include "QRef.h"
#include "QRefDialog.h"
#include <qpushbutton.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qlistbox.h>
#include "QRefDialog.h"
#include "ControlRef.h"
#include "Dialogs.h"
#include "QRef.h"
#include "debug.h"
QRefDialog::QRefDialog(QRef * form)
: QRefDialogBase(0, 0, false, 0),
form_(form)

View File

@ -13,18 +13,18 @@
#pragma implementation
#endif
#include "LyXView.h"
#include "ControlSearch.h"
#include "gettext.h"
#include "QSearch.h"
#include "QSearchDialog.h"
#include "Qt2BC.h"
#include <qpushbutton.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include "QSearchDialog.h"
#include "QSearch.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "QtLyXView.h"
#include "ControlSearch.h"
typedef Qt2CB<ControlSearch, Qt2DB<QSearchDialog> > base_class;
QSearch::QSearch(ControlSearch & c)

View File

@ -11,8 +11,8 @@
#include <config.h>
#include "ui/QSearchDialogBase.h"
#include "QSearch.h"
#include "ui/QSearchDialogBase.h"
class QCloseEvent;
class QComboBox;

View File

@ -8,12 +8,13 @@
#include <config.h>
#include "QShowFileDialog.h"
#include "ControlShowFile.h"
#include "QShowFile.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "QShowFile.h"
#include "QShowFileDialog.h"
#include "Qt2BC.h"
#include <qtextview.h>
#include <qpushbutton.h>

View File

@ -6,9 +6,8 @@
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include "QShowFileDialog.h"
#include "Dialogs.h"
#include "QShowFile.h"
#include "QShowFileDialog.h"
#include <qwidget.h>
#include <qpushbutton.h>

View File

@ -9,7 +9,6 @@
#include <config.h>
#include "QSpellcheckerDialog.h"
#include "Dialogs.h"
#include "QSpellchecker.h"
#include "gettext.h"

View File

@ -11,9 +11,8 @@
#include <config.h>
#include "ui/QSpellcheckerDialogBase.h"
#include "QSpellchecker.h"
#include "ui/QSpellcheckerDialogBase.h"
class QSpellcheckerDialog : public QSpellcheckerDialogBase
{ Q_OBJECT

View File

@ -10,11 +10,11 @@
#include <config.h>
#include <gettext.h>
#include "QTabularCreateDialog.h"
#include "QTabularCreate.h"
#include "support/lstrings.h"
#include "QTabularCreate.h"
#include "QTabularCreateDialog.h"
#include <qpushbutton.h>
#include <qspinbox.h>
#include "emptytable.h"

View File

@ -13,7 +13,6 @@
#include "ControlTexinfo.h"
#include "QTexinfoDialog.h"
#include "Dialogs.h"
#include "QTexinfo.h"
#include <qlistbox.h>

View File

@ -13,7 +13,6 @@
#include "ControlThesaurus.h"
#include "QThesaurusDialog.h"
#include "Dialogs.h"
#include "QThesaurus.h"
#include <qpushbutton.h>

View File

@ -14,19 +14,19 @@
#include <stack>
#include <qslider.h>
#include <qlistview.h>
#include <qpushbutton.h>
#include <qcombobox.h>
#include "QTocDialog.h"
#include "QToc.h"
#include "Qt2BC.h"
#include "LyXView.h"
#include "gettext.h"
#include "support/lstrings.h"
#include "debug.h"
#include "QtLyXView.h"
#include "QToc.h"
#include "QTocDialog.h"
#include "Qt2BC.h"
#include <qslider.h>
#include <qlistview.h>
#include <qpushbutton.h>
#include <qcombobox.h>
using std::endl;
using std::pair;

View File

@ -15,10 +15,10 @@
#pragma interface
#endif
#include "Qt2Base.h"
#include "ControlToc.h"
#include "Qt2Base.h"
class ControlToc;
class QTocDialog;

View File

@ -7,9 +7,9 @@
*/
#include <config.h>
#include "QTocDialog.h"
#include "Dialogs.h"
#include "QToc.h"
#include "QTocDialog.h"
#include <qlistview.h>
#include <qpushbutton.h>

View File

@ -8,17 +8,18 @@
#include <config.h>
#include "ControlUrl.h"
#include "debug.h"
#include "gettext.h"
#include "QURL.h"
#include "QURLDialog.h"
#include "Qt2BC.h"
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qlineedit.h>
#include "ControlUrl.h"
#include "Qt2BC.h"
#include "QURL.h"
#include "debug.h"
#include "gettext.h"
typedef Qt2CB<ControlUrl, Qt2DB<QURLDialog> > base_class;
QURL::QURL(ControlUrl & c)

View File

@ -8,12 +8,11 @@
#include <config.h>
#include <qpushbutton.h>
#include "QURLDialog.h"
#include "Dialogs.h"
#include "QURL.h"
#include "QURLDialog.h"
#include <qpushbutton.h>
QURLDialog::QURLDialog(QURL * form)
: QURLDialogBase(0, 0, false, 0),
form_(form)

View File

@ -13,17 +13,17 @@
#pragma implementation
#endif
#include "gettext.h"
#include "LyXView.h"
#include "ControlVCLog.h"
#include "QVCLog.h"
#include "QVCLogDialog.h"
#include "Qt2BC.h"
#include <qtextview.h>
#include <qpushbutton.h>
#include "QVCLogDialog.h"
#include "QVCLog.h"
#include "Qt2BC.h"
#include "gettext.h"
#include "QtLyXView.h"
#include "ControlVCLog.h"
typedef Qt2CB<ControlVCLog, Qt2DB<QVCLogDialog> > base_class;
QVCLog::QVCLog(ControlVCLog & c)

View File

@ -9,15 +9,15 @@
#include <config.h>
#include <vector>
#include <qpushbutton.h>
#include <qtextview.h>
#include "QVCLogDialog.h"
#include "Dialogs.h"
#include "QVCLog.h"
#include "QtLyXView.h"
#include "LyXView.h"
#include "ControlVCLog.h"
#include "QVCLog.h"
#include "QVCLogDialog.h"
#include <qpushbutton.h>
#include <qtextview.h>
QVCLogDialog::QVCLogDialog(QVCLog * form)
: QVCLogDialogBase(0, 0, false, 0),
form_(form)

View File

@ -0,0 +1,110 @@
/**
* \file QWorkArea.C
* Copyright 1995-2002 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "debug.h"
#include "LyXView.h"
#include "lyxrc.h" // lyxrc.show_banner
#include "version.h" // lyx_version
#include "support/filetools.h" // LibFileSearch
#include "support/lstrings.h"
#include "support/LAssert.h"
#include <cmath>
#include <cctype>
#include "QWorkArea.h"
#include <qapplication.h>
#include <qevent.h>
#include <qpainter.h>
#include <qmainwindow.h>
#include <qlayout.h>
using std::endl;
using std::abs;
using std::hex;
QWorkArea::QWorkArea(int, int, int, int)
: WorkArea(), QWidget(qApp->mainWidget()), painter_(*this)
{
// Add a splash screen to the centre of the work area
string const splash_file = (lyxrc.show_banner) ?
LibFileSearch("images", "banner", "xpm") : string();
if (!splash_file.empty()) {
// FIXME
}
scrollbar_ = new QScrollBar(QScrollBar::Vertical, this);
content_ = new QContentPane(this);
(static_cast<QMainWindow*>(qApp->mainWidget()))->setCentralWidget(this);
content_->show();
content_->setBackgroundColor(lcolor.getX11Name(LColor::background).c_str());
QHBoxLayout * vl = new QHBoxLayout(this);
vl->addWidget(content_, 5);
vl->addWidget(scrollbar_, 0);
show();
}
QWorkArea::~QWorkArea()
{
}
void QWorkArea::resize(int xpos, int ypos, int width, int height)
{
setGeometry(xpos, ypos, width, height);
}
void QWorkArea::setScrollbarParams(int h, int pos, int line_h)
{
// do what cursor movement does (some grey)
h += height() / 4;
int max = h - height();
if (max < 0)
max = 0;
scrollbar_->setRange(0, max);
scrollbar_->setValue(pos);
scrollbar_->setLineStep(line_h);
scrollbar_->setPageStep(height());
}
void QWorkArea::haveSelection(bool ) const
{
// FIXME
}
string const QWorkArea::getClipboard() const
{
// FIXME
return "nothing";
}
void QWorkArea::putClipboard(string const &) const
{
// FIXME
}

View File

@ -0,0 +1,91 @@
// -*- C++ -*-
/**
* \file QWorkArea.h
* Copyright 1995-2002 the LyX Team
* Read the file COPYING
*
* \author unknown
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef QWORKAREA_H
#define QWORKAREA_H
#ifdef __GNUG__
#pragma interface
#endif
#include <utility>
#include "WorkArea.h"
#include "QLPainter.h"
#include "QContentPane.h"
#include <qwidget.h>
#include <qscrollbar.h>
#include <qpixmap.h>
/**
* Qt-specific implementation of the work area
* (buffer view GUI)
*
* It consists of a content pane widget, and a scrollbar.
* Hopefully soon we can just use QScrollView ...
*/
class QWorkArea : public WorkArea, public QWidget {
friend class QContentPane;
public:
QWorkArea(int x, int y, int w, int h);
// FIXME:
virtual int xpos() const { return 0; }
virtual int ypos() const { return 0; }
virtual bool visible() const { return true; }
virtual void greyOut() const { }
virtual ~QWorkArea();
/// return this widget's painter
virtual Painter & getPainter() { return painter_; }
/// return the width of the content pane
virtual int workWidth() const { return content_->width(); }
/// return the height of the content pane
virtual int workHeight() const { return content_->height(); }
/// resize this widget
virtual void resize(int xpos, int ypos, int width, int height);
/// FIXME: makes no sense ?
virtual void redraw() const { }
/// set focus to this widget
virtual void setFocus() const { /* FIXME */ }
/// does this widget have the focus ?
virtual bool hasFocus() const { /* FIXME */ return true; }
///
virtual void setScrollbarParams(int height, int pos, int line_height);
/// a selection exists
virtual void haveSelection(bool) const;
///
virtual string const getClipboard() const;
///
virtual void putClipboard(string const &) const;
/// get the pixmap we paint on to
QPixmap * getPixmap() const { return content_->pixmap(); }
/// get the content pane widget
QWidget * getContent() const { return content_; }
private:
/// scroll bar
QScrollBar * scrollbar_;
/// content
QContentPane * content_;
/// our painter
QLPainter painter_;
};
#endif // QWORKAREA_H

View File

@ -10,4 +10,5 @@
*/
#undef emit
#undef signals
#include "frontends/LyXView.h"

140
src/frontends/qt2/QtView.C Normal file
View File

@ -0,0 +1,140 @@
/**
* \file QtView.C
* Copyright 1995-2002 the LyX Team
* Read the file COPYING
*
* \author Lars Gullik Bjornes <larsbj@lyx.org>
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
//#include "minibuffer.h"
#include "debug.h"
#include "intl.h"
#include "lyx_cb.h"
#include "support/filetools.h"
#include "MenuBackend.h"
#include "ToolbarDefaults.h"
#include "lyxfunc.h"
#include "BufferView.h"
#include "frontends/Toolbar.h"
#include "frontends/Menubar.h"
#include "frontends/Dialogs.h"
#include "frontends/Timeout.h"
#include "QtView.h"
#include "qfont_loader.h"
#include <qapplication.h>
#include <qpixmap.h>
#include <qmenubar.h>
using std::endl;
// FIXME: this has to go away
BufferView * current_view;
qfont_loader fontloader;
QtView::QtView(unsigned int width, unsigned int height)
: QMainWindow(), LyXView()
{
resize(width, height);
qApp->setMainWidget(this);
menubar_.reset(new Menubar(this, menubackend));
connect(menuBar(), SIGNAL(activated(int)),
this, SLOT(activated(int)));
toolbar_.reset(new Toolbar(this, 0, 0, toolbardefaults));
toolbar_->set(true);
// FIXME minibuffer_.reset(new MiniBuffer(this, 0, 0, 30, 30));
bufferview_.reset(new BufferView(this, 0, 0, width, height));
::current_view = bufferview_.get();
// FIXME: move
// FIXME autosave_timeout_->timeout.connect(SigC::slot(this, &QtView::autoSave));
// assign an icon to main form
string const iconname = LibFileSearch("images", "lyx", "xpm");
if (!iconname.empty())
setIcon(QPixmap(iconname.c_str()));
#if 0
minibuffer_.reset(new MiniBuffer(this, air, height - (25 + air),
width - (2 * air), 25));
// connect the minibuffer signals
minibuffer_->stringReady.connect(SigC::slot(getLyXFunc(),
&LyXFunc::miniDispatch));
minibuffer_->timeout.connect(SigC::slot(getLyXFunc(),
&LyXFunc::initMiniBuffer));
minibuffer_->dd_init();
#endif
// make sure the buttons are disabled if needed
updateToolbar();
}
QtView::~QtView()
{
}
void QtView::activated(int id)
{
getLyXFunc()->verboseDispatch(id, true);
}
void QtView::closeEvent(QCloseEvent *)
{
QuitLyX();
}
void QtView::redraw()
{
// FIXME: does this make any sense for us ?
repaint();
}
void QtView::setPosition(unsigned int x, unsigned int y)
{
move(x, y);
}
void QtView::show(int, int, string const & title)
{
setCaption(title.c_str());
QMainWindow::show();
}
void QtView::prohibitInput() const
{
// FIXME
//setFocusPolicy(QWidget::NoFocus);
}
void QtView::allowInput() const
{
// FIXME
//setFocusPolicy(QWidget::strongFocus);
}

View File

@ -0,0 +1,76 @@
// -*- C++ -*-
/**
* \file QtView.h
* Copyright 1995-2002 the LyX Team
* Read the file COPYING
*
* \author Lars Gullik Bjornes <larsbj@lyx.org>
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef QTVIEW_H
#define QTVIEW_H
#ifdef __GNUG__
#pragma interface
#endif
#include <config.h>
#include "frontends/LyXView.h"
#include <qmainwindow.h>
/**
* QtView - Qt implementation of LyXView
*
* Qt-private implementation of the main LyX window.
*/
class QtView : public QMainWindow, public LyXView {
Q_OBJECT
public:
/// create a main window of the given dimensions
QtView(unsigned int w, unsigned int h);
~QtView();
/// set the x,y of the top level window
virtual void setPosition(unsigned int, unsigned int);
/**
* show - display the top-level window
* @param place general placement (FIXME: GUII)
* @param border border border type (FIXME: GUII)
* @param title window title
*/
virtual void show(int, int, string const & t = string("LyX"));
/// start modal operation
virtual void prohibitInput() const;
/// end modal operation
virtual void allowInput() const;
/// redraw the main form.
void redraw();
public slots:
/// menu item has been selected
void activated(int id);
protected:
/// make sure we quit cleanly
virtual void closeEvent(QCloseEvent * e);
private:
/**
* setWindowTitle - set title of window
* @param t main window title
* @param it iconified (short) title
*/
virtual void setWindowTitle(string const & t, string const & it) {
setCaption(t.c_str());
setIconText(it.c_str());
}
};
#endif // QTVIEW_H

View File

@ -1,11 +1,5 @@
This file contains some do's and dont's for the Qt2 frontend.
Random crashes
--------------
Both xforms and Qt use X error handlers which collide - if you get
crashes, try lyx -sync, which seems to help.
General rules
-------------
@ -75,7 +69,7 @@ Include John Done
Index Kalle Done
Log John Done
Minipage John Done
Paragraph Edwin Waiting for MVC
Paragraph Edwin Waiting to be updated
Preamble John Done
Print Edwin Done
Ref Kalle Done

View File

@ -6,12 +6,12 @@
* \author John Levon
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "Timeout_pimpl.h"
#include "debug.h"

View File

@ -18,8 +18,6 @@
#include "frontends/Timeout.h"
#include <sigc++/signal_system.h>
#include <qobject.h>
// stupid Qt
#undef emit

View File

@ -0,0 +1,297 @@
/**
* \file Toolbar_pimpl.C
* See the file COPYING.
*
* \author Lars Gullik Bjønnes, larsbj@lyx.org
* \uathor John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "ToolbarDefaults.h"
#include "debug.h"
#include "lyxfunc.h"
#include "FuncStatus.h"
#include "BufferView.h"
#include "buffer.h"
#include "lyxtextclasslist.h"
#include "LyXAction.h"
#include "MathsSymbols.h"
#include "gettext.h"
#include "Tooltips.h"
#include "support/LAssert.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include "QtView.h"
#include "Toolbar_pimpl.h"
#include <qtoolbar.h>
#include <qcombobox.h>
#include <qtooltip.h>
#include <qsizepolicy.h>
using std::endl;
extern LyXAction lyxaction;
namespace {
string const getPixmap(int action)
{
string arg;
string xpm_name;
const kb_action act = lyxaction.retrieveActionArg(action, arg);
string const name = lyxaction.getActionName(act);
if (!arg.empty())
xpm_name = subst(name + ' ' + arg, ' ','_');
else
xpm_name = name;
string fullname = LibFileSearch("images", xpm_name, "xpm");
if (!fullname.empty()) {
lyxerr[Debug::GUI] << "Full icon name is `"
<< fullname << "'" << endl;
return fullname;
}
#if 0 // FIXME
if (act == LFUN_INSERT_MATH && !arg.empty()) {
char const ** pixmap = get_pixmap_from_symbol(arg.c_str(),
buttonwidth,
height);
if (pixmap) {
lyxerr[Debug::GUI] << "Using mathed-provided icon"
<< endl;
fl_set_pixmapbutton_data(obj,
const_cast<char **>(pixmap));
return;
}
}
#endif
lyxerr << "Unable to find icon `" << xpm_name << "'" << endl;
fullname = LibFileSearch("images", "unknown", "xpm");
if (!fullname.empty()) {
lyxerr[Debug::GUI] << "Using default `unknown' icon"
<< endl;
}
return fullname;
}
} // namespace anon
Toolbar::Pimpl::Pimpl(LyXView * o, int, int)
: owner_(static_cast<QtView *>(o)),
combo_(0)
{
proxy_.reset(new ToolbarProxy(*this));
}
Toolbar::Pimpl::~Pimpl()
{
}
void Toolbar::Pimpl::activate()
{
// FIXME
}
void Toolbar::Pimpl::deactivate()
{
// FIXME
}
void Toolbar::Pimpl::update()
{
ButtonMap::const_iterator p = map_.begin();
ButtonMap::const_iterator end = map_.end();
for (; p != end; ++p) {
QToolButton * button = p->first;
int action = p->second;
FuncStatus const status =
owner_->getLyXFunc()->getStatus(action);
button->setToggleButton(true);
button->setOn(status.onoff(true));
button->setEnabled(!status.disabled());
}
if (combo_)
combo_->setEnabled(!owner_->getLyXFunc()->getStatus(LFUN_LAYOUT).disabled());
}
void Toolbar::Pimpl::button_selected(QToolButton * button)
{
ButtonMap::const_iterator cit = map_.find(button);
if (cit == map_.end()) {
lyxerr << "non existent tool button selected !" << endl;
return;
}
owner_->getLyXFunc()->verboseDispatch(cit->second, true);
}
void Toolbar::Pimpl::changed_layout(string const & sel)
{
LyXTextClass const & tc =
textclasslist[owner_->buffer()->params.textclass];
LyXTextClass::const_iterator end = tc.end();
for (LyXTextClass::const_iterator cit = tc.begin();
cit != end; ++cit) {
if (_(cit->name()) == sel) {
owner_->getLyXFunc()->dispatch(LFUN_LAYOUT, cit->name());
return;
}
}
lyxerr << "ERROR (Toolbar::Pimpl::layoutSelected): layout not found!"
<< endl;
}
void Toolbar::Pimpl::setLayout(string const & layout)
{
LyXTextClass const & tc =
textclasslist[owner_->buffer()->params.textclass];
string const & name = _(tc[layout].name());
int i;
for (i = 0; i < combo_->count(); ++i) {
if (name == combo_->text(i).latin1())
break;
}
if (i == combo_->count()) {
lyxerr << "Trying to select non existent layout type "
<< name << endl;
return;
}
combo_->setCurrentItem(i);
}
void Toolbar::Pimpl::updateLayoutList(bool force)
{
// if we don't need an update, don't ...
if (combo_->count() && !force)
return;
LyXTextClass const & tc =
textclasslist[owner_->buffer()->params.textclass];
combo_->setUpdatesEnabled(false);
combo_->clear();
LyXTextClass::const_iterator cit = tc.begin();
LyXTextClass::const_iterator end = tc.end();
for (; cit != end; ++cit) {
// ignore obsolete entries
if (cit->obsoleted_by().empty())
combo_->insertItem(_(cit->name()).c_str());
}
// needed to recalculate size hint
combo_->hide();
combo_->setMinimumWidth(combo_->sizeHint().width());
combo_->show();
combo_->setUpdatesEnabled(true);
combo_->update();
}
void Toolbar::Pimpl::clearLayoutList()
{
combo_->clear();
}
void Toolbar::Pimpl::openLayoutList()
{
#if 0 // popup() is protected
combo_->popup();
#endif
}
void Toolbar::Pimpl::set(bool)
{
// FIXME: ???
}
void Toolbar::Pimpl::add(int action, bool)
{
if (!toolbars_.size()) {
toolbars_.push_back(new QToolBar(owner_));
}
switch (action) {
case ToolbarDefaults::SEPARATOR:
toolbars_.back()->addSeparator();
break;
case ToolbarDefaults::NEWLINE:
toolbars_.push_back(new QToolBar(owner_));
break;
case ToolbarDefaults::LAYOUTS: {
combo_ = new QComboBox(toolbars_.back());
QSizePolicy p(QSizePolicy::Minimum, QSizePolicy::Fixed);
combo_->setSizePolicy(p);
combo_->setFocusPolicy(QWidget::TabFocus);
combo_->setMinimumWidth(combo_->sizeHint().width());
QObject::connect(combo_, SIGNAL(activated(const QString &)),
proxy_.get(), SLOT(layout_selected(const QString &)));
break;
}
default:
QToolButton * tb =
new QToolButton(QPixmap(getPixmap(action).c_str()),
"FIXME", "FIXME",
proxy_.get(), SLOT(button_selected()), toolbars_.back());
map_[tb] = action;
QToolTip::add(tb, _(lyxaction.helpText(action)).c_str());
break;
}
}
void Toolbar::Pimpl::push(int)
{
#if 0
lyxerr[Debug::GUI] << "Toolbar::push: trying to trigger no `"
<< nth << '\'' << endl;
if (nth <= 0 || nth >= int(toollist.size())) {
// item nth not found...
return;
}
fl_trigger_object(toollist[nth - 1].icon);
#endif
}

View File

@ -0,0 +1,118 @@
// -*- C++ -*-
/**
* \file Toolbar_pimpl.h
* Copyright 2002 the LyX Team
* Copyright 1996-2001 Lars Gullik Bjønnes
* Read the file COPYING
*
* \author Lars Gullik Bjønnes, larsbj@lyx.org
*/
#ifndef TOOLBAR_PIMPL_H
#define TOOLBAR_PIMPL_H
#include <config.h>
#include <map>
#include <vector>
#include <boost/smart_ptr.hpp>
#include "frontends/Toolbar.h"
#ifdef __GNUG__
#pragma interface
#endif
#include <qobject.h>
#include <qtoolbutton.h>
class QtView;
class QToolBar;
class QComboBox;
struct Toolbar::Pimpl {
friend class ToolbarProxy;
public:
///
Pimpl(LyXView * o, int x, int y);
///
~Pimpl();
/// (re)sets the toolbar
void set(bool doingmain = false);
void reset() { }
/** this is to be the entry point to the toolbar
frame, where you can change the toolbar realtime.
*/
void edit();
/// add a new button to the toolbar.
void add(int, bool doclean = true);
/// invokes the n'th icon in the toolbar
void push(int);
/// activates the toolbar
void activate();
/// deactivates the toolbar
void deactivate();
/// update the state of the icons
void update();
/// select the right layout in the combox
void setLayout(string const & layout);
/// Populate the layout combox; re-do everything if force is true.
void updateLayoutList(bool force);
/// Drop down the layout list
void openLayoutList();
/// Erase the layout list
void clearLayoutList();
private:
void changed_layout(string const & sel);
void button_selected(QToolButton * button);
QtView * owner_;
boost::scoped_ptr<ToolbarProxy> proxy_;
std::vector<QToolBar *> toolbars_;
QComboBox * combo_;
typedef std::map<QToolButton *, int> ButtonMap;
ButtonMap map_;
};
// moc is mind-numbingly stupid
class ToolbarProxy : public QObject {
Q_OBJECT
public:
ToolbarProxy(Toolbar::Pimpl & owner)
: owner_(owner) { };
public slots:
void layout_selected(const QString & str) {
owner_.changed_layout(str.latin1());
}
void button_selected() {
owner_.button_selected(
const_cast<QToolButton *>(
static_cast<QToolButton const *>(sender()))
);
}
private:
Toolbar::Pimpl & owner_;
};
#endif

View File

@ -0,0 +1,22 @@
/**
* \file WorkAreaFactory.C
* Copyright 2002 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#include "frontends/WorkAreaFactory.h"
#include "QWorkArea.h"
namespace WorkAreaFactory {
WorkArea * create(int x, int y, int w, int h)
{
return new QWorkArea(x, y, w, h);
}
}

View File

@ -15,7 +15,7 @@
const unsigned int cellsize = 20;
EmptyTable::EmptyTable(QWidget * parent, const char * name)
: QtTableView(parent,name)
: QtTableView(parent, name, WRepaintNoErase)
{
setNumCols(5);
setNumRows(5);
@ -38,6 +38,22 @@ void EmptyTable::paintCell(QPainter *p, int row, int col)
p->fillRect(0, 0, x2, y2, QColor("white"));
p->drawLine(x2, 0, x2, y2);
p->drawLine(0, y2, x2, y2);
if (row + 1 != numRows() || col + 1 != numCols())
return;
// draw handle
int const step = cellsize / 5;
int const space = 4;
int x = cellsize - step;
int const y = cellsize - space;
int const ex = cellsize - space;
int ey = cellsize - step;
while (x > space) {
p->drawLine(x, y, ex, ey);
x -= step;
ey -= step;
}
}
void EmptyTable::setNumberColumns(int nr_cols)

504
src/frontends/qt2/guiapi.C Normal file
View File

@ -0,0 +1,504 @@
/**
* \file guiapi.C
* Copyright 2002 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#include "guiapi.h"
#include "QAbout.h"
#include "QAboutDialog.h"
#include "QBibitem.h"
#include "QBibitemDialog.h"
#include "QBibtex.h"
#include "QBibtexDialog.h"
#include "QCharacter.h"
#include "QCharacterDialog.h"
#include "QCitation.h"
#include "QCitationDialog.h"
//#include "QDocument.h"
#include "QError.h"
#include "QErrorDialog.h"
#include "QERT.h"
#include "QERTDialog.h"
#include "QExternal.h"
#include "QExternalDialog.h"
#include "QFloat.h"
#include "QFloatDialog.h"
//#include "QForks.h"
// Here would be an appropriate point to lecture on the evils
// of the Qt headers, those most fucked up of disgusting ratholes.
// But I won't.
#undef signals
#include "QGraphics.h"
#include "QGraphicsDialog.h"
#include "QInclude.h"
#include "QIncludeDialog.h"
#include "QIndex.h"
#include "QIndexDialog.h"
#include "QLog.h"
#include "QLogDialog.h"
#include "QMinipage.h"
#include "QMinipageDialog.h"
//#include "QParagraph.h"
#include "QPreamble.h"
#include "QPreambleDialog.h"
//#include "QPreferences.h"
#include "QPrint.h"
#include "QPrintDialog.h"
#include "QRef.h"
#include "QRefDialog.h"
#include "QSearch.h"
#include "QSearchDialog.h"
//#include "QSendto.h"
#include "QShowFile.h"
#include "QShowFileDialog.h"
#include "QSpellchecker.h"
#include "QSpellcheckerDialog.h"
//#include "QTabular.h"
#include "QTabularCreate.h"
#include "QTabularCreateDialog.h"
#include "QTexinfo.h"
#include "QTexinfoDialog.h"
#ifdef HAVE_LIBAIKSAURUS
#include "QThesaurus.h"
#include "QThesaurusDialog.h"
#endif
#include "QToc.h"
#include "QTocDialog.h"
#include "QURL.h"
#include "QURLDialog.h"
#include "QVCLog.h"
#include "QVCLogDialog.h"
#include "Qt2BC.h"
#include "controllers/GUI.h"
#include "insets/inseterror.h"
#include "LyXView.h"
#include "ControlAboutlyx.h"
#include "ControlBibitem.h"
#include "ControlBibtex.h"
#include "ControlCharacter.h"
#include "ControlCitation.h"
#include "ControlError.h"
#include "ControlERT.h"
#include "ControlExternal.h"
#include "ControlFloat.h"
#include "ControlForks.h"
#include "ControlGraphics.h"
#include "insets/insetgraphicsParams.h"
#include "ControlInclude.h"
#include "ControlIndex.h"
#include "ControlLog.h"
#include "ControlMinipage.h"
#include "ControlParagraph.h"
#include "ControlPreamble.h"
#include "ControlPrint.h"
#include "ControlRef.h"
#include "ControlSearch.h"
#include "ControlSendto.h"
#include "ControlShowFile.h"
#include "ControlSpellchecker.h"
#include "ControlTabularCreate.h"
#include "ControlTexinfo.h"
#include "ControlThesaurus.h"
#include "ControlToc.h"
#include "ControlUrl.h"
#include "ControlVCLog.h"
namespace { // anon
// I belive that this one is buggy (Lgb)
// But not if used correctly. (Lgb)
template <class T>
class GUISingleton {
public:
static
T & get(LyXView & lv, Dialogs & d) {
static T t(lv, d);
return t;
}
};
GUISingleton<GUI<ControlCharacter, QCharacter,
OkApplyCancelReadOnlyPolicy, Qt2BC> >
controlCharacterSingleton;
GUISingleton<GUI<ControlCitation, QCitation,
NoRepeatedApplyReadOnlyPolicy, Qt2BC> >
controlCitationSingleton;
GUISingleton<GUI<ControlERT, QERT,
NoRepeatedApplyReadOnlyPolicy, Qt2BC> >
controlERTSingleton;
GUISingleton<GUI<ControlIndex, QIndex,
NoRepeatedApplyReadOnlyPolicy, Qt2BC> >
controlIndexSingleton;
GUISingleton<GUI<ControlMinipage, QMinipage,
NoRepeatedApplyReadOnlyPolicy, Qt2BC> >
controlMinipageSingleton;
//GUISingleton<QPreferences> formPreferencesSingleton;
GUISingleton<GUI<ControlRef, QRef,
NoRepeatedApplyReadOnlyPolicy, Qt2BC> >
controlRefSingleton;
//GUISingleton<QTabular> formTabularSingleton;
GUISingleton<GUI<ControlToc, QToc,
OkCancelPolicy, Qt2BC> >
controlTocSingleton;
GUISingleton<GUI<ControlUrl, QURL,
NoRepeatedApplyReadOnlyPolicy, Qt2BC> >
controlUrlSingleton;
} // anon
extern "C" {
void gui_ShowAboutlyx(LyXView & lv, Dialogs & d)
{
static GUI<ControlAboutlyx, QAbout,
OkCancelPolicy, Qt2BC> cal(lv, d);
cal.show();
}
void gui_ShowBibitem(InsetCommand * ic, LyXView & lv, Dialogs & d)
{
static GUI<ControlBibitem, QBibitem,
OkCancelReadOnlyPolicy, Qt2BC> cbi(lv, d);
cbi.showInset(ic);
}
void gui_ShowBibtex(InsetCommand * ic, LyXView & lv, Dialogs & d)
{
static GUI<ControlBibtex, QBibtex,
OkCancelReadOnlyPolicy, Qt2BC> cbt(lv, d);
cbt.showInset(ic);
}
void gui_ShowCharacter(LyXView & lv, Dialogs & d)
{
controlCharacterSingleton.get(lv, d).show();
}
void gui_SetUserFreeFont(LyXView & lv, Dialogs & d)
{
controlCharacterSingleton.get(lv, d).apply();
}
void gui_ShowCitation(InsetCommand * ic, LyXView & lv, Dialogs & d)
{
controlCitationSingleton.get(lv, d).showInset(ic);
}
void gui_CreateCitation(string const & s, LyXView & lv, Dialogs & d)
{
controlCitationSingleton.get(lv, d).createInset(s);
}
void gui_ShowDocument(LyXView & lv, Dialogs & d)
{
//static QDocument fd(&lv, &d);
//fd.show();
}
void gui_ShowError(InsetError * ie, LyXView & lv, Dialogs & d)
{
static GUI<ControlError, QError,
OkCancelPolicy, Qt2BC> ce(lv, d);
ce.showInset(ie);
}
void gui_ShowERT(InsetERT * ie, LyXView & lv, Dialogs & d)
{
controlERTSingleton.get(lv, d).showInset(ie);
}
void gui_UpdateERT(InsetERT * ie, LyXView & lv, Dialogs & d)
{
controlERTSingleton.get(lv, d).showInset(ie);
}
void gui_ShowExternal(InsetExternal * ie, LyXView & lv, Dialogs & d)
{
static GUI<ControlExternal, QExternal,
OkApplyCancelReadOnlyPolicy, Qt2BC> ce(lv, d);
ce.showInset(ie);
}
void gui_ShowFile(string const & f, LyXView & lv, Dialogs & d)
{
static GUI<ControlShowFile, QShowFile,
OkCancelPolicy, Qt2BC> csf(lv, d);
csf.showFile(f);
}
void gui_ShowFloat(InsetFloat * ifl, LyXView & lv, Dialogs & d)
{
static GUI<ControlFloat, QFloat,
NoRepeatedApplyReadOnlyPolicy, Qt2BC> cf(lv, d);
cf.showInset(ifl);
}
void gui_ShowForks(LyXView & lv, Dialogs & d)
{
#if 0
static GUI<ControlForks, QForks,
OkApplyCancelPolicy, Qt2BC> cf(lv, d);
cf.show();
#endif
}
void gui_ShowGraphics(InsetGraphics * ig, LyXView & lv, Dialogs & d)
{
static GUI<ControlGraphics, QGraphics,
NoRepeatedApplyReadOnlyPolicy, Qt2BC> cg(lv, d);
cg.showInset(ig);
}
void gui_ShowInclude(InsetInclude * ii, LyXView & lv, Dialogs & d)
{
static GUI<ControlInclude, QInclude,
OkCancelReadOnlyPolicy, Qt2BC> ci(lv, d);
ci.showInset(ii);
}
void gui_ShowIndex(InsetCommand * ic, LyXView & lv, Dialogs & d)
{
controlIndexSingleton.get(lv, d).showInset(ic);
}
void gui_CreateIndex(string const & s, LyXView & lv, Dialogs & d)
{
controlIndexSingleton.get(lv, d).createInset(s);
}
#if 0
void gui_ShowInfo(InsetInfo *, LyXView & lv, Dialogs & d)
{
}
#endif
void gui_ShowLogFile(LyXView & lv, Dialogs & d)
{
static GUI<ControlLog, QLog,
OkCancelPolicy, Qt2BC> cl(lv, d);
cl.show();
}
void gui_ShowMathPanel(LyXView & lv, Dialogs & d)
{
//static QMathsPanel fmp(&lv, &d);
//fmp.show();
}
void gui_ShowMinipage(InsetMinipage * im, LyXView & lv, Dialogs & d)
{
controlMinipageSingleton.get(lv, d).showInset(im);
}
void gui_UpdateMinipage(InsetMinipage * im, LyXView & lv, Dialogs & d)
{
controlMinipageSingleton.get(lv, d).showInset(im);
}
void gui_ShowParagraph(LyXView & lv, Dialogs & d)
{
#if 0
static GUI<ControlParagraph, QParagraph,
OkApplyCancelReadOnlyPolicy, Qt2BC> cp(lv, d);
cp.show();
#endif
}
#if 0
void gui_UpdateParagraph(LyXView & lv, Dialogs & d)
{
#warning FIXME!
// This should be the same object as in gui_ShowParagraph
static GUI<ControlParagraph, QParagraph,
OkApplyCancelReadOnlyPolicy, Qt2BC> cp(lv, d);
#if 0
cp.
#endif
}
#endif
void gui_ShowPreamble(LyXView & lv, Dialogs & d)
{
static GUI<ControlPreamble, QPreamble,
NoRepeatedApplyReadOnlyPolicy, Qt2BC> cp(lv, d);
cp.show();
}
void gui_ShowPreferences(LyXView & lv, Dialogs & d)
{
//formPreferencesSingleton.get(lv, d).show();
}
void gui_ShowPrint(LyXView & lv, Dialogs & d)
{
static GUI<ControlPrint, QPrint,
OkApplyCancelPolicy, Qt2BC> cp(lv, d);
cp.show();
}
void gui_ShowRef(InsetCommand * ic, LyXView & lv, Dialogs & d)
{
controlRefSingleton.get(lv, d).showInset(ic);
}
void gui_CreateRef(string const & s, LyXView & lv, Dialogs & d)
{
controlRefSingleton.get(lv, d).createInset(s);
}
void gui_ShowSearch(LyXView & lv, Dialogs & d)
{
static GUI<ControlSearch, QSearch,
NoRepeatedApplyReadOnlyPolicy, Qt2BC> cs(lv, d);
cs.show();
}
void gui_ShowSendto(LyXView & lv, Dialogs & d)
{
#if 0
static GUI<ControlSendto, QSendto,
OkApplyCancelPolicy, Qt2BC> cs(lv, d);
cs.show();
#endif
}
void gui_ShowSpellchecker(LyXView & lv, Dialogs & d)
{
static GUI<ControlSpellchecker, QSpellchecker,
NoRepeatedApplyReadOnlyPolicy, Qt2BC> cp(lv, d);
cp.show();
}
void gui_ShowSpellcheckerPreferences(LyXView & lv, Dialogs & d)
{
//formPreferencesSingleton.get(lv, d).showSpellPref();
}
void gui_ShowTabular(InsetTabular * it, LyXView & lv, Dialogs & d)
{
//formTabularSingleton.get(lv, d).showInset(it);
}
void gui_UpdateTabular(InsetTabular * it, LyXView & lv, Dialogs & d)
{
//formTabularSingleton.get(lv, d).updateInset(it);
}
void gui_ShowTabularCreate(LyXView & lv, Dialogs & d)
{
static GUI<ControlTabularCreate, QTabularCreate,
OkApplyCancelReadOnlyPolicy, Qt2BC> ctc(lv, d);
ctc.show();
}
void gui_ShowTexinfo(LyXView & lv, Dialogs & d)
{
static GUI<ControlTexinfo, QTexinfo,
OkCancelPolicy, Qt2BC> ct(lv, d);
ct.show();
}
void gui_ShowThesaurus(string const & s, LyXView & lv, Dialogs & d)
{
#ifdef HAVE_LIBAIKSAURUS
static GUI<ControlThesaurus, QThesaurus,
OkApplyCancelReadOnlyPolicy, Qt2BC> ct(lv, d);
ct.showEntry(s);
#endif
}
void gui_ShowTOC(InsetCommand * ic, LyXView & lv, Dialogs & d)
{
controlTocSingleton.get(lv, d).showInset(ic);
}
void gui_CreateTOC(string const & s, LyXView & lv, Dialogs & d)
{
controlTocSingleton.get(lv, d).createInset(s);
}
void gui_ShowUrl(InsetCommand * ic, LyXView & lv, Dialogs & d)
{
controlUrlSingleton.get(lv, d).showInset(ic);
}
void gui_CreateUrl(string const & s, LyXView & lv, Dialogs & d)
{
controlUrlSingleton.get(lv, d).createInset(s);
}
void gui_ShowVCLogFile(LyXView & lv, Dialogs & d)
{
static GUI<ControlVCLog, QVCLog,
OkCancelPolicy, Qt2BC> cv(lv, d);
cv.show();
}
} // extern "C"

View File

@ -21,7 +21,11 @@ nodist_libqt2moc_la_SOURCES = \
emptytable_moc.C \
lengthcombo_moc.C \
qttableview_moc.C \
Qt2Base_moc.C
Toolbar_pimpl_moc.C \
QContentPane_moc.C \
Qt2Base_moc.C \
QtView_moc.C \
$(MOCDIALOGS)
libqt2moc.la: $(libqt2moc_la_OBJECTS) $(libqt2moc_la_DEPENDENCIES)

View File

@ -0,0 +1,137 @@
/**
* \file qfont_loader.C
* Copyright 1997 the LyX Team
* Read the file COPYING
*
* \author Asger Alstrup
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "qfont_loader.h"
#include "gettext.h"
#include "debug.h"
#include "lyxrc.h"
#include "BufferView.h"
#include "frontends/LyXView.h"
qfont_loader::qfont_loader()
{
}
qfont_loader::~qfont_loader()
{
}
void qfont_loader::update()
{
int i1,i2,i3,i4;
// fuck this !
for (i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1) {
for (i2 = 0; i1 < 2; ++i2) {
for (i3 = 0; i1 < 4; ++i3) {
for (i4 = 0; i1 < 10; ++i4) {
fontinfo_[i1][i2][i3][i4].reset(0);
}
}
}
}
}
qfont_loader::font_info::font_info(LyXFont const & f)
: metrics(font)
{
font.setPointSize(int((lyxrc.font_sizes[f.size()] * lyxrc.dpi *
(lyxrc.zoom / 100.0)) / 72.27 + 0.5));
// FIXME: lyxrc, check for failure etc.
switch (f.family()) {
case LyXFont::SYMBOL_FAMILY:
font.setRawName("-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific");
break;
case LyXFont::CMR_FAMILY:
font.setRawName("-*-cmr10-medium-*-*-*-*-*-*-*-*-*-*-*");
break;
case LyXFont::CMSY_FAMILY:
font.setRawName("-*-cmsy10-*-*-*-*-*-*-*-*-*-*-*-*");
break;
case LyXFont::CMM_FAMILY:
font.setRawName("-*-cmmi10-medium-*-*-*-*-*-*-*-*-*-*-*");
break;
case LyXFont::CMEX_FAMILY:
font.setRawName("-*-cmex10-*-*-*-*-*-*-*-*-*-*-*-*");
break;
case LyXFont::MSA_FAMILY:
font.setRawName("-*-msam10-*-*-*-*-*-*-*-*-*-*-*-*");
break;
case LyXFont::MSB_FAMILY:
font.setRawName("-*-msbm10-*-*-*-*-*-*-*-*-*-*-*-*");
break;
case LyXFont::EUFRAK_FAMILY:
font.setRawName("-*-eufm10-medium-*-*-*-*-*-*-*-*-*-*-*");
break;
case LyXFont::ROMAN_FAMILY:
font.setFamily("times");
break;
case LyXFont::SANS_FAMILY:
font.setFamily("helvetica");
break;
case LyXFont::TYPEWRITER_FAMILY:
font.setFamily("courier");
break;
}
switch (f.series()) {
case LyXFont::MEDIUM_SERIES:
font.setWeight(QFont::Normal);
break;
case LyXFont::BOLD_SERIES:
font.setWeight(QFont::Bold);
break;
}
switch (f.shape()) {
case LyXFont::ITALIC_SHAPE:
case LyXFont::SLANTED_SHAPE:
font.setItalic(true);
break;
}
metrics = QFontMetrics(font);
}
qfont_loader::font_info const * qfont_loader::getfontinfo(LyXFont const & f)
{
if (!lyxrc.use_gui) {
// FIXME
}
font_info * fi = fontinfo_[f.family()][f.series()][f.shape()][f.size()].get();
if (fi) {
return fi;
} else {
fi = new font_info(f);
fontinfo_[f.family()][f.series()][f.shape()][f.size()].reset(fi);
return fi;
}
}
bool qfont_loader::available(LyXFont const &)
{
// FIXME (see getRawName docs)
return true;
}

View File

@ -0,0 +1,74 @@
// -*- C++ -*-
/**
* \file qfont_loader.h
* Copyright 1997 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef QFONTLOADER_H
#define QFONTLOADER_H
#ifdef __GNUG__
#pragma interface
#endif
#include <config.h>
#include <boost/smart_ptr.hpp>
#include "lyxfont.h"
#include "font_loader.h"
#include "LString.h"
#include <qfont.h>
#include <qfontmetrics.h>
/**
* Qt font loader for LyX. Matches LyXFonts against
* actual QFont instances, and also caches metrics.
*/
class qfont_loader {
public:
qfont_loader();
virtual ~qfont_loader();
/// update fonts after zoom, dpi, font names, or norm change
virtual void update();
/// do we have anything matching?
virtual bool available(LyXFont const & f);
/// get the QFont for this LyXFont
QFont const & get(LyXFont const & f) {
return getfontinfo(f)->font;
}
/// get the QFont metrics for this LyXFont
QFontMetrics const & metrics(LyXFont const & f) {
return getfontinfo(f)->metrics;
}
private:
/// hold info about a particular font
struct font_info {
font_info(LyXFont const & f);
/// the font instance
QFont font;
/// metrics on the font
QFontMetrics metrics;
};
/// get font info (font + metrics) for the given LyX font. Does not fail.
font_info const * getfontinfo(LyXFont const & f);
/// BUTT ugly !
boost::scoped_ptr<font_info> fontinfo_[LyXFont::NUM_FAMILIES][2][4][10];
};
extern qfont_loader fontloader;
#endif // QFONT_LOADER_H

View File

@ -0,0 +1,142 @@
/**
* \file qfont_metrics.C
* Copyright 1995-2002 the LyX Team
* Read the file COPYING
*
* \author unknown
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation "frontends/font_metrics.h"
#endif
#include "support/lstrings.h"
#include "font_metrics.h"
#include "qfont_loader.h"
#include "debug.h"
#include <qfontmetrics.h>
#include <qfont.h>
// FIXME ?
extern qfont_loader * global_fontloader;
namespace {
QFontMetrics const & metrics(LyXFont const & f) {
return global_fontloader->metrics(f);
}
};
namespace font_metrics {
int maxAscent(LyXFont const & f)
{
return metrics(f).ascent();
}
int maxDescent(LyXFont const & f)
{
return metrics(f).descent();
}
int ascent(char c, LyXFont const & f)
{
// FIXME - must do ascent for char not maxascent
//QRect r = metrics(f).boundingRect(c);
//lyxerr << r.x() << "," << r.y() <<
// " : " << r.width() << "," << r.height() << endl;
return metrics(f).ascent();
}
int descent(char, LyXFont const & f)
{
// FIXME
return metrics(f).descent();
}
int lbearing(char c, LyXFont const & f)
{
return metrics(f).leftBearing(c);
}
int rbearing(char c, LyXFont const & f)
{
return metrics(f).rightBearing(c);
}
int width(char const * s, size_t ls, LyXFont const & f)
{
if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
return metrics(f).width(s, ls);
}
// handle small caps ourselves ...
LyXFont smallfont(f);
smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
QFontMetrics qm = global_fontloader->metrics(f);
QFontMetrics qsmallm = global_fontloader->metrics(smallfont);
int w = 0;
for (size_t i = 0; i < ls; ++i) {
char const c = uppercase(s[i]);
if (c != s[i])
w += qsmallm.width(&c, 1);
else
w += qm.width(&c, 1);
}
return w;
}
int signedWidth(string const & s, LyXFont const & f)
{
if (s[0] == '-')
return -width(s.substr(1, s.length() - 1), f);
else
return width(s, f);
}
void rectText(string const & str, LyXFont const & f,
int & w,
int & ascent,
int & descent)
{
QFontMetrics const & metrics(metrics(f));
w = width(str, f);
ascent = metrics.ascent();
descent = metrics.descent();
}
void buttonText(string const & str, LyXFont const & f,
int & w,
int & ascent,
int & descent)
{
QFontMetrics const & metrics(metrics(f));
static int const d = 3;
w = width(str, f) + d * 2 + 2;
ascent = metrics.ascent() + d;
descent = metrics.descent() + d;
}
} // namespace font_metrics

267
src/frontends/qt2/qlkey.h Normal file
View File

@ -0,0 +1,267 @@
/**
* \file qlkey.h
* Copyright 2002 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef QLKEY_H
#define QLKEY_H
#include <config.h>
#include <qnamespace.h>
#include "LString.h"
/**
* q_to_lkey - convert Qt keypress into LyX
*
* Convert the Qt keypress into a string understandable
* by the LyX core (same as XKeysymToString)
*/
string const q_to_lkey(int lkey)
{
switch(lkey) {
case Qt::Key_Escape: return "Escape";
case Qt::Key_Tab: return "Tab";
case Qt::Key_BackSpace: return "BackSpace";
case Qt::Key_Return: return "Return";
case Qt::Key_Enter: return "KP_Enter"; // correct ??
case Qt::Key_Insert: return "Insert";
case Qt::Key_Delete: return "Delete";
case Qt::Key_Pause: return "Pause";
case Qt::Key_Print: return "Print";
case Qt::Key_SysReq: return "Sys_Req";
case Qt::Key_Home: return "Home";
case Qt::Key_End: return "End";
case Qt::Key_Left: return "Left";
case Qt::Key_Up: return "Up";
case Qt::Key_Right: return "Right";
case Qt::Key_Down: return "Down";
case Qt::Key_Prior: return "Prior";
case Qt::Key_Next: return "Next";
case Qt::Key_Shift: return "Shift_L";
case Qt::Key_Control: return "Control_L";
case Qt::Key_Meta: return "Alt_L"; // correct ?
case Qt::Key_Alt: return "Alt_L";
case Qt::Key_CapsLock: return "Caps_Lock";
case Qt::Key_NumLock: return "Num_Lock";
case Qt::Key_ScrollLock: return "Scroll_Lock";
case Qt::Key_F1: return "F1";
case Qt::Key_F2: return "F2";
case Qt::Key_F3: return "F3";
case Qt::Key_F4: return "F4";
case Qt::Key_F5: return "F5";
case Qt::Key_F6: return "F6";
case Qt::Key_F7: return "F7";
case Qt::Key_F8: return "F8";
case Qt::Key_F9: return "F9";
case Qt::Key_F10: return "F10";
case Qt::Key_F11: return "F11";
case Qt::Key_F12: return "F12";
case Qt::Key_F13: return "F13";
case Qt::Key_F14: return "F14";
case Qt::Key_F15: return "F15";
case Qt::Key_F16: return "F16";
case Qt::Key_F17: return "F17";
case Qt::Key_F18: return "F18";
case Qt::Key_F19: return "F19";
case Qt::Key_F20: return "F20";
case Qt::Key_F21: return "F21";
case Qt::Key_F22: return "F22";
case Qt::Key_F23: return "F23";
case Qt::Key_F24: return "F24";
case Qt::Key_F25: return "F25";
case Qt::Key_F26: return "F26";
case Qt::Key_F27: return "F27";
case Qt::Key_F28: return "F28";
case Qt::Key_F29: return "F29";
case Qt::Key_F30: return "F30";
case Qt::Key_F31: return "F31";
case Qt::Key_F32: return "F32";
case Qt::Key_F33: return "F33";
case Qt::Key_F34: return "F34";
case Qt::Key_F35: return "F35";
case Qt::Key_0: return "0";
case Qt::Key_1: return "1";
case Qt::Key_2: return "2";
case Qt::Key_3: return "3";
case Qt::Key_4: return "4";
case Qt::Key_5: return "5";
case Qt::Key_6: return "6";
case Qt::Key_7: return "7";
case Qt::Key_8: return "8";
case Qt::Key_9: return "9";
case Qt::Key_Colon: return "colon";
case Qt::Key_Semicolon: return "semicolon";
case Qt::Key_Less: return "less";
case Qt::Key_Equal: return "equal";
case Qt::Key_Greater: return "greater";
case Qt::Key_Question: return "question";
case Qt::Key_At: return "at";
case Qt::Key_A: return "a";
case Qt::Key_B: return "b";
case Qt::Key_C: return "c";
case Qt::Key_D: return "d";
case Qt::Key_E: return "e";
case Qt::Key_F: return "f";
case Qt::Key_G: return "g";
case Qt::Key_H: return "h";
case Qt::Key_I: return "i";
case Qt::Key_J: return "j";
case Qt::Key_K: return "k";
case Qt::Key_L: return "l";
case Qt::Key_M: return "m";
case Qt::Key_N: return "n";
case Qt::Key_O: return "o";
case Qt::Key_P: return "p";
case Qt::Key_Q: return "q";
case Qt::Key_R: return "r";
case Qt::Key_S: return "s";
case Qt::Key_T: return "t";
case Qt::Key_U: return "u";
case Qt::Key_V: return "v";
case Qt::Key_W: return "w";
case Qt::Key_X: return "x";
case Qt::Key_Y: return "y";
case Qt::Key_Z: return "z";
case Qt::Key_BracketLeft: return "bracketleft";
case Qt::Key_Backslash: return "backslash";
case Qt::Key_BracketRight: return "bracketright";
case Qt::Key_Underscore: return "underscore";
case Qt::Key_Space: return "space";
case Qt::Key_ParenLeft: return "parenleft";
case Qt::Key_ParenRight: return "parenright";
case Qt::Key_QuoteDbl: return "quotedbl";
case Qt::Key_Exclam: return "exclam";
case Qt::Key_NumberSign: return "numbersign";
case Qt::Key_AsciiCircum: return "asciicircum";
case Qt::Key_Dollar: return "dollar";
case Qt::Key_Percent: return "percent";
case Qt::Key_Ampersand: return "ampersand";
case Qt::Key_Asterisk: return "asterisk";
case Qt::Key_Apostrophe: return "apostrophe";
case Qt::Key_Plus: return "plus";
case Qt::Key_Minus: return "minus";
case Qt::Key_Comma: return "comma";
case Qt::Key_Period: return "period";
case Qt::Key_Slash: return "slash";
case Qt::Key_AsciiTilde: return "asciitilde";
case Qt::Key_BraceLeft: return "braceleft";
case Qt::Key_BraceRight: return "braceright";
case Qt::Key_QuoteLeft: return "grave"; // ???
case Qt::Key_notsign: return "notsign";
case Qt::Key_nobreakspace: return "nobreakspace";
case Qt::Key_exclamdown: return "exclamdown";
case Qt::Key_cent: return "cent";
case Qt::Key_sterling: return "sterling";
case Qt::Key_currency: return "currency";
case Qt::Key_yen: return "yen";
case Qt::Key_brokenbar: return "brokenbar";
case Qt::Key_section: return "section";
case Qt::Key_diaeresis: return "diaeresis";
case Qt::Key_copyright: return "copyright";
case Qt::Key_ordfeminine: return "ordfeminine";
case Qt::Key_guillemotleft: return "guillemotleft";
case Qt::Key_hyphen: return "hyphen";
case Qt::Key_registered: return "registered";
case Qt::Key_macron: return "macron";
case Qt::Key_degree: return "degree";
case Qt::Key_plusminus: return "plusminus";
case Qt::Key_twosuperior: return "twosuperior";
case Qt::Key_threesuperior: return "threesuperior";
case Qt::Key_acute: return "acute";
case Qt::Key_mu: return "mu";
case Qt::Key_paragraph: return "paragraph";
case Qt::Key_periodcentered: return "periodcentered";
case Qt::Key_cedilla: return "cedilla";
case Qt::Key_onesuperior: return "onesuperior";
case Qt::Key_masculine: return "masculine";
case Qt::Key_guillemotright: return "guillemotright";
case Qt::Key_onequarter: return "onequarter";
case Qt::Key_onehalf: return "onehalf";
case Qt::Key_threequarters: return "threequarters";
case Qt::Key_questiondown: return "questiondown";
case Qt::Key_Agrave: return "Agrave";
case Qt::Key_Aacute: return "Aacute";
case Qt::Key_Acircumflex: return "Acircumflex";
case Qt::Key_Atilde: return "Atilde";
case Qt::Key_Adiaeresis: return "Adiaeresis";
case Qt::Key_Aring: return "Aring";
case Qt::Key_AE: return "AE";
case Qt::Key_Ccedilla: return "Ccedilla";
case Qt::Key_Egrave: return "Egrave";
case Qt::Key_Eacute: return "Eacute";
case Qt::Key_Ecircumflex: return "Ecircumflex";
case Qt::Key_Ediaeresis: return "Ediaeresis";
case Qt::Key_Igrave: return "Igrave";
case Qt::Key_Iacute: return "Iacute";
case Qt::Key_Icircumflex: return "Icircumflex";
case Qt::Key_Idiaeresis: return "Idiaeresis";
case Qt::Key_ETH: return "ETH";
case Qt::Key_Ntilde: return "Ntilde";
case Qt::Key_Ograve: return "Ograve";
case Qt::Key_Oacute: return "Oacute";
case Qt::Key_Ocircumflex: return "Ocircumflex";
case Qt::Key_Otilde: return "Otilde";
case Qt::Key_Odiaeresis: return "Odiaeresis";
case Qt::Key_multiply: return "multiply";
case Qt::Key_Ooblique: return "Ooblique";
case Qt::Key_Ugrave: return "Ugrave";
case Qt::Key_Uacute: return "Uacute";
case Qt::Key_Ucircumflex: return "Ucircumflex";
case Qt::Key_Udiaeresis: return "Udiaeresis";
case Qt::Key_Yacute: return "Yacute";
case Qt::Key_THORN: return "THORN";
case Qt::Key_ssharp: return "ssharp";
case Qt::Key_agrave: return "agrave";
case Qt::Key_aacute: return "aacute";
case Qt::Key_acircumflex: return "acircumflex";
case Qt::Key_atilde: return "atilde";
case Qt::Key_adiaeresis: return "adiaeresis";
case Qt::Key_aring: return "aring";
case Qt::Key_ae: return "ae";
case Qt::Key_ccedilla: return "ccedilla";
case Qt::Key_egrave: return "egrave";
case Qt::Key_eacute: return "eacute";
case Qt::Key_ecircumflex: return "ecircumflex";
case Qt::Key_ediaeresis: return "ediaeresis";
case Qt::Key_igrave: return "igrave";
case Qt::Key_iacute: return "iacute";
case Qt::Key_icircumflex: return "icircumflex";
case Qt::Key_idiaeresis: return "idiaeresis";
case Qt::Key_eth: return "eth";
case Qt::Key_ntilde: return "ntilde";
case Qt::Key_ograve: return "ograve";
case Qt::Key_oacute: return "oacute";
case Qt::Key_ocircumflex: return "ocircumflex";
case Qt::Key_otilde: return "otilde";
case Qt::Key_odiaeresis: return "odiaeresis";
case Qt::Key_division: return "division";
case Qt::Key_oslash: return "oslash";
case Qt::Key_ugrave: return "ugrave";
case Qt::Key_uacute: return "uacute";
case Qt::Key_ucircumflex: return "ucircumflex";
case Qt::Key_udiaeresis: return "udiaeresis";
case Qt::Key_yacute: return "yacute";
case Qt::Key_thorn: return "thorn";
case Qt::Key_ydiaeresis: return "ydiaeresis";
// FIXME: these ones I don't know the names of ... help !
// what's here is basically guesses ...
case Qt::Key_Super_L: return "Super_L";
case Qt::Key_Super_R: return "Super_R";
case Qt::Key_Menu: return "Menu";
case Qt::Key_Hyper_L: return "Hyper_L";
case Qt::Key_Hyper_R: return "Hyper_R";
case Qt::Key_Help: return "Help";
case Qt::Key_Bar: return "Bar";
case Qt::Key_Backtab: return "BackTab";
default:
case Qt::Key_unknown: return "unknown";
}
}
#endif // QLKEY_H

176
src/frontends/qt2/qscreen.C Normal file
View File

@ -0,0 +1,176 @@
/**
* \file qscreen.C
* Copyright 2002 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <algorithm>
#include <iostream>
#include "LColor.h"
#include "QWorkArea.h"
#include "qscreen.h"
#include "lyxtext.h"
#include "Painter.h"
#include "BufferView.h"
#include "insets/insettext.h"
#include "debug.h"
using std::max;
using std::min;
namespace {
/// copy some horizontal regions about inside a pixmap
void copyInPixmap(QPixmap * p, int dest_y, int src_y, int src_w, int src_h)
{
bitBlt(p,
0, dest_y, // dest x,y
p, 0, src_y, // source x, y
src_w, src_h // source w, h
);
}
} // namespace anon
QScreen::QScreen(QWorkArea & o)
: LyXScreen(), owner_(o)
{
}
QScreen::~QScreen()
{
}
void QScreen::showManualCursor(LyXText const * text, int x, int y,
int asc, int desc, Cursor_Shape shape)
{
int const y1 = max(y - text->first_y - asc, 0);
int const y_tmp = min(y - text->first_y + desc, owner_.height());
// secure against very strange situations
// which would be when .... ?
int const y2 = max(y_tmp, y1);
if (y2 > 0 && y1 < owner_.height()) {
cursor_h_ = y2 - y1 + 1;
cursor_y_ = y1;
switch (shape) {
case BAR_SHAPE:
cursor_w_ = 1;
cursor_x_ = x;
break;
case L_SHAPE:
cursor_w_ = cursor_h_ / 3;
cursor_x_ = x;
break;
case REVERSED_L_SHAPE:
cursor_w_ = cursor_h_ / 3;
cursor_x_ = x - cursor_w_ + 1;
break;
}
if (!nocursor_pixmap_.get()
|| cursor_w_ != nocursor_pixmap_->width()
|| cursor_h_ != nocursor_pixmap_->height()) {
nocursor_pixmap_.reset(new QPixmap(cursor_w_, cursor_h_));
}
owner_.getPainter().start();
// save old area
bitBlt(nocursor_pixmap_.get(), 0, 0, owner_.getPixmap(),
cursor_x_, cursor_y_, cursor_w_, cursor_h_);
owner_.getPainter().line(x, y1, x, y2);
switch (shape) {
case BAR_SHAPE:
break;
case L_SHAPE:
case REVERSED_L_SHAPE:
int const rectangle_h = (cursor_h_ + 10) / 20;
owner_.getPainter().fillRectangle(
cursor_x_, y2 - rectangle_h + 1,
cursor_w_ - 1, rectangle_h, LColor::cursor);
break;
}
owner_.getPainter().end();
owner_.getContent()->repaint(
cursor_x_, cursor_y_,
cursor_w_, cursor_h_);
}
cursor_visible_ = true;
}
void QScreen::hideCursor()
{
if (!cursor_visible_)
return;
bitBlt(owner_.getPixmap(), cursor_x_, cursor_y_,
nocursor_pixmap_.get(), 0, 0, cursor_w_, cursor_h_);
owner_.getContent()->repaint(
cursor_x_, cursor_y_,
cursor_w_, cursor_h_);
cursor_visible_ = false;
}
void QScreen::expose(int x, int y, int exp_width, int exp_height)
{
owner_.getContent()->update(x, y, exp_width, exp_height);
}
void QScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
{
QPixmap * p(owner_.getPixmap());
owner_.getPainter().start();
if (cursor_visible_) hideCursor();
int const old_first = text->first_y;
bool const internal = (text == bv->text);
text->first_y = y;
// is any optimization possible?
if ((y - old_first) < owner_.workHeight()
&& (old_first - y) < owner_.workHeight()) {
if (text->first_y < old_first) {
int const dest_y = old_first - text->first_y;
drawFromTo(text, bv, 0, dest_y, 0, 0, internal);
copyInPixmap(p, dest_y, 0, owner_.workWidth(), owner_.height() - dest_y);
expose(0, 0, owner_.workWidth(), dest_y);
} else {
int const src_y = text->first_y - old_first;
drawFromTo(text, bv, owner_.height() - src_y, owner_.height(), 0, 0, internal);
copyInPixmap(p, 0, 0, owner_.workWidth(), owner_.height() - src_y);
expose(0, owner_.height() - src_y, owner_.workWidth(), src_y);
}
} else {
// make a dumb redraw
drawFromTo(text, bv, 0, owner_.height(), 0, 0, internal);
expose(0, 0, owner_.workWidth(), owner_.height());
}
owner_.getPainter().end();
}

View File

@ -0,0 +1,79 @@
// -*- C++ -*-
/**
* \file qscreen.h
* Copyright 2002 the LyX Team
* Read the file COPYING
*
* \author John Levon <moz@compsoc.man.ac.uk>
*/
#ifndef QSCREEN_H
#define QSCREEN_H
#ifdef __GNUG__
#pragma interface
#endif
#include <boost/smart_ptr.hpp>
#include "screen.h"
#include "QWorkArea.h"
#include <qrect.h>
/**
* Qt implementation of toolkit-specific parts of LyXScreen.
*/
class QScreen : public LyXScreen {
public:
QScreen(QWorkArea &);
virtual ~QScreen();
/**
* draw the screen from a given position
* @param y the text position to draw from
*
* Uses as much of the already printed pixmap as possible
*/
virtual void draw(LyXText *, BufferView *, unsigned int y);
/**
* showManualCursor - display the caret on the work area
* @param text the lyx text containing the cursor
* @param x the x position of the cursor
* @param y the y position of the row's baseline
* @param asc ascent of the row
* @param desc descent of the row
* @param shape the current shape
*/
virtual void showManualCursor(LyXText const *, int x, int y,
int asc, int desc,
Cursor_Shape shape);
/// unpaint the cursor painted by showManualCursor()
virtual void hideCursor();
protected:
/// get the work area
virtual WorkArea & workarea() const { return owner_; }
/// copies specified area of pixmap to screen
virtual void expose(int x, int y, int exp_width, int exp_height);
private:
/// our owning widget
QWorkArea & owner_;
/// the mini-pixmap used for backing store for the blinking caret
boost::scoped_ptr<QPixmap> nocursor_pixmap_;
//{@ the cursor pixmap position/size
int cursor_x_;
int cursor_y_;
int cursor_w_;
int cursor_h_;
//@}
};
#endif // QSCREEN_H

View File

@ -13,78 +13,13 @@ XFORMSGIMAGE = xformsGImage.C xformsGImage.h
endif
nodist_libqt2xforms_la_SOURCES = \
bmtable.h \
bmtable.c \
combox.h \
combox.C \
Color.h \
Color.C \
DropDown.h \
DropDown.C \
FeedbackController.h \
FeedbackController.C \
FormBase.h \
FormBase.C \
FormBaseDeprecated.h \
FormBaseDeprecated.C \
FormDocument.h \
FormDocument.C \
FormParagraph.h \
FormParagraph.C \
FormMathsBitmap.h \
FormMathsBitmap.C \
FormMathsDeco.h \
FormMathsDeco.C \
FormMathsDelim.h \
FormMathsDelim.C \
FormMathsMatrix.h \
FormMathsMatrix.C \
FormMathsPanel.h \
FormMathsPanel.C \
FormMathsStyle.h \
FormMathsStyle.C \
FormMathsSpace.h \
FormMathsSpace.C \
FormPreferences.h \
FormPreferences.C \
FormTabular.h \
FormTabular.C \
FormInset.h \
FormInset.C \
MathsSymbols.h \
MathsSymbols.C \
Menubar_pimpl.h \
Menubar_pimpl.C \
RadioButtonGroup.h \
RadioButtonGroup.C \
Toolbar_pimpl.h \
Toolbar_pimpl.C \
Tooltips.h \
Tooltips.C \
form_document.h \
form_document.C \
form_paragraph.h \
form_paragraph.C \
form_preferences.h \
form_preferences.C \
form_tabular.h \
form_tabular.C \
form_maths_deco.h \
form_maths_deco.C \
form_maths_delim.h \
form_maths_delim.C \
form_maths_matrix.h \
form_maths_matrix.C \
form_maths_panel.h \
form_maths_panel.C \
form_maths_space.h \
form_maths_space.C \
form_maths_style.h \
form_maths_style.C \
input_validators.h \
input_validators.C \
$(XFORMSGIMAGE) xformsBC.h \
xformsBC.C \
$(XFORMSGIMAGE) \
xforms_helpers.h \
xforms_helpers.C