Lars Gullik Bjønnes wrote:
Abdelrazak Younes <[EMAIL PROTECTED]> writes:
| Hello,
|
| Just committed this patch to "younes" branch.
|
| Next step on my agenda:
|
| 1) ensure that all frontends are unchanged feature wise
| 2) verify that "younes" branch does not contain changes non related to
| the GUI API cleanup (by merging them)
| 3) merge with trunk
|
| I need help for 1)
|
| Abdel.
|
|
|
| Log:
| new GUI API: autotools support.
Wrong patch?
Oups sorry... attached!
Thanks,
Abdel.
Index: frontends/gtk/Makefile.am
===================================================================
--- frontends/gtk/Makefile.am (revision 14006)
+++ frontends/gtk/Makefile.am (working copy)
@@ -133,8 +133,6 @@
LyXGdkImage.C \
LyXGdkImage.h \
LyXKeySymFactory.C \
- LyXScreenFactory.C \
- WorkAreaFactory.C \
ghelpers.C \
ghelpers.h \
io_callback.C \
@@ -142,5 +140,8 @@
lyx_gui.C \
xftFontLoader.C \
xftFontLoader.h \
- xftFontMetrics.C
+ xftFontMetrics.C \
+ Clipboard.h \
+ Gui.h \
+ WorkArea.h
Index: frontends/Makefile.am
===================================================================
--- frontends/Makefile.am (revision 14007)
+++ frontends/Makefile.am (working copy)
@@ -21,7 +21,6 @@
FileDialog.h \
LyXKeySym.h \
LyXKeySymFactory.h \
- LyXScreenFactory.h \
LyXView.C \
LyXView.h \
Menubar.h \
@@ -32,8 +31,11 @@
Toolbars.C \
Toolbars.h \
Clipboard.h \
+ Gui.h \
+ GuiCursor.C \
+ GuiCursor.h \
+ WorkArea.C \
WorkArea.h \
- WorkAreaFactory.h \
font_metrics.h \
guiapi.h \
guiapi.C \
@@ -41,6 +43,4 @@
lyx_gui.h \
mouse_state.h \
nullpainter.C \
- nullpainter.h \
- screen.C \
- screen.h
+ nullpainter.h
Index: frontends/qt3/Makefile.am
===================================================================
--- frontends/qt3/Makefile.am (revision 14006)
+++ frontends/qt3/Makefile.am (working copy)
@@ -28,7 +28,6 @@
Dialogs.C \
FileDialog.C \
LyXKeySymFactory.C \
- LyXScreenFactory.C \
QLMenubar.C QLMenubar.h \
qtTimeout.C qtTimeout.h \
QAbout.C QAbout.h \
@@ -73,7 +72,6 @@
QWrap.C QWrap.h \
Qt2BC.C Qt2BC.h \
QtLyXView.h \
- WorkAreaFactory.C \
checkedwidgets.C checkedwidgets.h \
lyx_gui.C \
lcolorcache.h lcolorcache.C \
@@ -85,4 +83,7 @@
qlkey.h \
qscreen.h qscreen.C \
qt_helpers.h qt_helpers.C \
+ Clipboard.h \
+ Gui.h \
+ WorkArea.h \
$(MOCFILES)
Index: frontends/qt4/Makefile.am
===================================================================
--- frontends/qt4/Makefile.am (revision 14007)
+++ frontends/qt4/Makefile.am (working copy)
@@ -36,7 +36,6 @@
Dialogs.C \
FileDialog.C \
LyXKeySymFactory.C \
- LyXScreenFactory.C \
QLMenubar.C QLMenubar.h \
qtTimeout.C qtTimeout.h \
QAbout.C QAbout.h \
@@ -79,11 +78,9 @@
QToc.C QToc.h \
QURL.C QURL.h \
QVSpace.C QVSpace.h \
- QWorkArea.C QWorkArea.h \
QWrap.C QWrap.h \
Qt2BC.C Qt2BC.h \
QtLyXView.h \
- WorkAreaFactory.C \
checkedwidgets.C checkedwidgets.h \
LyxClipboard.C LyxClipboard.h \
Application.C Application.h \
@@ -95,4 +92,6 @@
qfont_metrics.C \
qlkey.h \
qt_helpers.h qt_helpers.C \
+ Clipboard.h Clipboard.C \
+ Gui.h Gui.C \
$(MOCFILES)
Index: frontends/qt4/Makefile.dialogs
===================================================================
--- frontends/qt4/Makefile.dialogs (revision 14006)
+++ frontends/qt4/Makefile.dialogs (working copy)
@@ -128,7 +128,7 @@
QtView.C QtView.h \
QURLDialog.C QURLDialog.h \
QVSpaceDialog.C QVSpaceDialog.h \
- QWorkArea.C QWorkArea.h \
+ WorkArea.C WorkArea.h \
QWrapDialog.C QWrapDialog.h \
QLToolbar.C QLToolbar.h \
socket_callback.C socket_callback.h \
Index: frontends/qt4/QLPainter.C
===================================================================
--- frontends/qt4/QLPainter.C (revision 14065)
+++ frontends/qt4/QLPainter.C (working copy)
@@ -41,8 +41,13 @@
}
QLPainter::QLPainter(WorkArea * qwa)
- : Painter(), qwa_(qwa)
+ : Painter(), qwa_(qwa), current_color_(LColor::ignore),
+ current_qp_(NULL)
{
+ for (int i=0; i < LColor::ignore; ++i)
+ for (int j = 0; j < 2; ++j)
+ for (int k = 0; k < 2; ++k)
+ qpainters_[i][j][k] = 0;
}
@@ -57,18 +62,27 @@
return qwa_->viewport()->height();
}
-QPainter & QLPainter::setQPainterPen(QPainter & qp, LColor_color c,
+QPainter * QLPainter::getQPainter(LColor_color c,
Painter::line_style ls, Painter::line_width lw)
{
- if (c == current_color_ && ls == current_ls_ && lw == current_lw_)
- return qp;
+ if (c == current_color_ && ls == current_ls_ && lw == current_lw_
+ && current_qp_)
+ return current_qp_;
current_color_ = c;
current_ls_ = ls;
current_lw_ = lw;
- QPen pen = qp.pen();
+ // fi is a reference to the pointer type (QLFontInfo *) in the
+ // fontinfo_ table.
+ QPainter * & qp =
+ qpainters_[current_color_][current_ls_][current_lw_];
+ if (qp)
+ return qp;
+ qp = new QPainter;
+
+ QPen pen = qp->pen();
pen.setColor(lcolorcache.get(c));
switch (ls) {
@@ -81,15 +95,18 @@
case line_thick: pen.setWidth(3); break;
}
- qp.setPen(pen);
+ qp->setPen(pen);
+ current_qp_ = qp;
return qp;
}
void QLPainter::point(int x, int y, LColor_color c)
{
- QPainter qp(qwa_->paintDevice());
- setQPainterPen(qp, c).drawPoint(x, y);
+ QPainter * qp = getQPainter(c);
+ qp->begin(qwa_->paintDevice());
+ qp->drawPoint(x, y);
+ qp->end();
}
@@ -98,8 +115,10 @@
line_style ls,
line_width lw)
{
- QPainter qp(qwa_->paintDevice());
- setQPainterPen(qp, col, ls, lw).drawLine(x1, y1, x2, y2);
+ QPainter * qp = getQPainter(col, ls, lw);
+ qp->begin(qwa_->paintDevice());
+ qp->drawLine(x1, y1, x2, y2);
+ qp->end();
}
@@ -118,8 +137,10 @@
points[i].setY(yp[i]);
}
- QPainter qp(qwa_->paintDevice());
- setQPainterPen(qp, col, ls, lw).drawPolyline(points.get(), np);
+ QPainter * qp = getQPainter(col, ls, lw);
+ qp->begin(qwa_->paintDevice());
+ qp->drawPolyline(points.get(), np);
+ qp->end();
}
@@ -128,8 +149,10 @@
line_style ls,
line_width lw)
{
- QPainter qp(qwa_->paintDevice());
- setQPainterPen(qp, col, ls, lw).drawRect(x, y, w, h);
+ QPainter * qp = getQPainter(col, ls, lw);
+ qp->begin(qwa_->paintDevice());
+ qp->drawRect(x, y, w, h);
+ qp->end();
}
@@ -143,19 +166,6 @@
void QLPainter::fillPolygon(int const * xp, int const * yp,
int np, LColor_color col)
{
- // Must use new as np is not known at compile time.
- boost::scoped_array<QPoint> points(new QPoint[np]);
-
- for (int i = 0; i < np; ++i) {
- points[i].setX(xp[i]);
- points[i].setY(yp[i]);
- }
-
- QPainter qp(qwa_->paintDevice());
- setQPainterPen(qp, col);
- qp.setBrush(lcolorcache.get(col));
- qp.drawPolygon(points.get(), np);
- qp.setBrush(Qt::NoBrush);
}
@@ -163,8 +173,10 @@
int a1, int a2, LColor_color col)
{
// LyX usings 1/64ths degree, Qt usings 1/16th
- QPainter qp(qwa_->paintDevice());
- setQPainterPen(qp, col).drawArc(x, y, w, h, a1 / 4, a2 / 4);
+ QPainter * qp = getQPainter(col);
+ qp->begin(qwa_->paintDevice());
+ qp->drawArc(x, y, w, h, a1 / 4, a2 / 4);
+ qp->end();
}
@@ -227,9 +239,6 @@
void QLPainter::text(int x, int y, char const * s, size_t ls,
LyXFont const & f)
{
- QPainter qp(qwa_->paintDevice());
- setQPainterPen(qp, f.realColor());
-
Encoding const * encoding = f.language()->encoding();
if (f.isSymbolFont())
encoding = encodings.symbol_encoding();
@@ -244,11 +253,14 @@
str = ' ' + str;
if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
- qp.setFont(fontloader.get(f));
+ QPainter * qp = getQPainter(f.realColor());
+ qp->begin(qwa_->paintDevice());
+ qp->setFont(fontloader.get(f));
// We need to draw the text as LTR as we use our own bidi
// code.
- qp.setLayoutDirection(Qt::LeftToRight);
- qp.drawText(x, y, str);
+ qp->setLayoutDirection(Qt::LeftToRight);
+ qp->drawText(x, y, str);
+ qp->end();
} else {
smallCapsText(x, y, str, f);
}
@@ -256,7 +268,6 @@
if (f.underbar() == LyXFont::ON) {
underline(f, x, y, font_metrics::width(s, ls, f));
}
-
}
/// draw a pixmap from the image cache
void QLPainter::drawPixmap(int x, int y, QPixmap const & pixmap)
Index: frontends/qt4/QLPainter.h
===================================================================
--- frontends/qt4/QLPainter.h (revision 14065)
+++ frontends/qt4/QLPainter.h (working copy)
@@ -142,19 +142,24 @@
QString const & str, LyXFont const & f);
/// set pen parameters
- QPainter & setQPainterPen(QPainter & qp, LColor_color c,
+ QPainter * getQPainter(LColor_color c,
line_style ls = line_solid,
line_width lw = line_thin);
/// our qt painter
boost::scoped_ptr<QPainter> qp_;
+
/// the working area
WorkArea * qwa_;
LColor::color current_color_;
Painter::line_style current_ls_;
Painter::line_width current_lw_;
+ QPainter * current_qp_;
+
+ /// BUTT ugly !
+ QPainter * qpainters_[LColor::ignore][2][2];
};
} // namespace frontend
Index: frontends/xforms/Makefile.am
===================================================================
--- frontends/xforms/Makefile.am (revision 14074)
+++ frontends/xforms/Makefile.am (working copy)
@@ -159,7 +159,6 @@
LayoutEngine.C \
LayoutEngine.h \
LyXKeySymFactory.C \
- LyXScreenFactory.C \
XFormsMenubar.C \
XFormsMenubar.h \
RadioButtonGroup.C \
@@ -168,7 +167,6 @@
XFormsToolbar.h \
Tooltips.C \
Tooltips.h \
- WorkAreaFactory.C \
XFormsView.C \
XFormsView.h \
XLyXKeySym.C \
@@ -178,7 +176,10 @@
XPainter.C \
XPainter.h \
XWorkArea.h \
- XWorkArea.C
+ XWorkArea.C \
+ Clipboard.h \
+ Gui.h \
+ WorkArea.h
lyx_forms.h: stamp-forms
@: