summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2011-01-15 19:18:58 +0000
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2011-01-15 19:18:58 +0000
commit867088f57e6b312780ff3c21861503cb66e94c6f (patch)
tree9577234135b36d2681d4b4aa466fe683a12c3a01
parentf4b2ec9608576d4442c79780b64747548bb61a74 (diff)
view changes
-rw-r--r--dw/fltkflatview.cc4
-rw-r--r--dw/fltkplatform.cc5
-rw-r--r--dw/fltkpreview.cc2
-rw-r--r--dw/fltkviewbase.cc115
-rw-r--r--dw/fltkviewbase.hh5
-rw-r--r--dw/fltkviewport.cc32
-rw-r--r--dw/fltkviewport.hh4
7 files changed, 101 insertions, 66 deletions
diff --git a/dw/fltkflatview.cc b/dw/fltkflatview.cc
index 85385394..b47b3f0a 100644
--- a/dw/fltkflatview.cc
+++ b/dw/fltkflatview.cc
@@ -21,12 +21,8 @@
#include "fltkflatview.hh"
-#include <fltk/draw.h>
-#include <fltk/events.h>
-
#include <stdio.h>
-using namespace fltk;
using namespace lout::container::typed;
namespace dw {
diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc
index 0b32705d..7ec11b5d 100644
--- a/dw/fltkplatform.cc
+++ b/dw/fltkplatform.cc
@@ -64,10 +64,7 @@ PORT1.3
font = FL_HELVETICA;
#endif
-#if 0
-PORT1.3
- setfont(font, size);
-#endif
+ fl_font(font, size);
spaceWidth = misc::max(0, (int)fl_width(' ') + letterSpacing);
int xh, xw = 0;
fl_measure("x", xw, xh, 0);
diff --git a/dw/fltkpreview.cc b/dw/fltkpreview.cc
index b31b7e02..fbf139c9 100644
--- a/dw/fltkpreview.cc
+++ b/dw/fltkpreview.cc
@@ -124,7 +124,7 @@ void FltkPreview::drawText (core::style::Font *font,
* else that measures text).
*/
FltkFont *ff = (FltkFont*)font;
- setfont(ff->font, translateCanvasXToViewX (ff->size));
+ Fl::set_font(ff->font, translateCanvasXToViewX (ff->size));
#if 0
/**
* \todo Normally, this should already be known, maybe it
diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc
index e20e670a..21c7ee0d 100644
--- a/dw/fltkviewbase.cc
+++ b/dw/fltkviewbase.cc
@@ -45,10 +45,13 @@ FltkViewBase::FltkViewBase (int x, int y, int w, int h, const char *label):
canvasHeight = 1;
bgColor = FL_WHITE;
mouse_x = mouse_y = 0;
+#if 0
+PORT1.3
exposeArea = NULL;
if (backBuffer == NULL) {
backBuffer = new Fl_Image ();
}
+#endif
}
FltkViewBase::~FltkViewBase ()
@@ -58,7 +61,10 @@ FltkViewBase::~FltkViewBase ()
void FltkViewBase::setBufferedDrawing (bool b) {
if (b && backBuffer == NULL) {
+#if 0
+PORT1.3
backBuffer = new Fl_Image ();
+#endif
} else if (!b && backBuffer != NULL) {
delete backBuffer;
backBuffer = NULL;
@@ -69,7 +75,7 @@ void FltkViewBase::draw ()
{
int d = damage ();
- if ((d & DAMAGE_VALUE) && !(d & FL_DAMAGE_EXPOSE)) {
+ if ((d & FL_DAMAGE_USER1) && !(d & FL_DAMAGE_EXPOSE)) {
lout::container::typed::Iterator <core::Rectangle> it;
for (it = drawRegion.rectangles (); it.hasNext (); ) {
@@ -77,7 +83,7 @@ void FltkViewBase::draw ()
}
drawRegion.clear ();
- d &= ~DAMAGE_VALUE;
+ d &= ~FL_DAMAGE_USER1;
}
if (d & FL_DAMAGE_CHILD) {
@@ -105,6 +111,8 @@ void FltkViewBase::draw ()
void FltkViewBase::draw (const core::Rectangle *rect,
DrawType type)
{
+#if 0
+PORT1.3
int offsetX = 0, offsetY = 0;
/* fltk-clipping does not use widget coordinates */
@@ -118,7 +126,7 @@ void FltkViewBase::draw (const core::Rectangle *rect,
::fltk::intersect_with_clip (viewRect);
viewRect.x (viewRect.x () - offsetX);
- viewRect.y (viewRect.y () - offsetY);
+ viewRect.y (viewRect.y () - offsetY);A
if (! viewRect.empty ()) {
dw::core::Rectangle r (
@@ -163,15 +171,24 @@ void FltkViewBase::draw (const core::Rectangle *rect,
exposeArea = NULL;
}
+#endif
+ core::Rectangle r (rect->x, rect->y, rect->width, rect->height);
+ fl_color(bgColor);
+ fl_rectf(translateViewXToCanvasX (rect->x),
+ translateCanvasYToViewY (rect->y), rect->width, rect->height);
+ theLayout->expose (this, &r);
}
void FltkViewBase::drawChildWidgets () {
for (int i = children () - 1; i >= 0; i--) {
Fl_Widget& w = *child(i);
+#if 0
+PORT1.3
if (w.damage() & DAMAGE_CHILD_LABEL) {
draw_outside_label(w);
w.set_damage(w.damage() & ~DAMAGE_CHILD_LABEL);
}
+#endif
update_child(w);
}
}
@@ -314,7 +331,10 @@ void FltkViewBase::setCursor (core::style::Cursor cursor)
*/
/** \bug Does not work */
+#if 0
+PORT1.3
this->cursor (mapDwToFltk[cursor]);
+#endif
}
void FltkViewBase::setBgColor (core::style::Color *color)
@@ -336,12 +356,12 @@ void FltkViewBase::queueDraw (core::Rectangle *area)
{
drawRegion.addRectangle (area);
/** DAMAGE_VALUE is just an arbitrary value other than DAMAGE_EXPOSE here */
- redraw (DAMAGE_VALUE);
+ damage (FL_DAMAGE_USER1);
}
void FltkViewBase::queueDrawTotal ()
{
- redraw (FL_DAMAGE_EXPOSE);
+ damage (FL_DAMAGE_EXPOSE);
}
void FltkViewBase::cancelQueueDraw ()
@@ -358,9 +378,9 @@ void FltkViewBase::drawLine (core::style::Color *color,
core::style::Color::Shading shading,
int x1, int y1, int x2, int y2)
{
- setcolor(((FltkColor*)color)->colors[shading]);
- drawline (translateCanvasXToViewX (x1), translateCanvasYToViewY (y1),
- translateCanvasXToViewX (x2), translateCanvasYToViewY (y2));
+ fl_color(((FltkColor*)color)->colors[shading]);
+ fl_line (translateCanvasXToViewX (x1), translateCanvasYToViewY (y1),
+ translateCanvasXToViewX (x2), translateCanvasYToViewY (y2));
}
void FltkViewBase::drawTypedLine (core::style::Color *color,
@@ -379,21 +399,21 @@ void FltkViewBase::drawTypedLine (core::style::Color *color,
d = len % f*width;
gap = ng ? d/ng + (w > 3 ? 2 : 0) : 0;
dashes[0] = 1; dashes[1] = f*width-gap; dashes[2] = 0;
- line_style(FL_DASH + FL_CAP_ROUND, w, dashes);
+ fl_line_style(FL_DASH + FL_CAP_ROUND, w, dashes);
/* These formulas also work, but ain't pretty ;)
- * line_style(FL_DOT + FL_CAP_ROUND, w);
+ * fl_line_style(FL_DOT + FL_CAP_ROUND, w);
* dashes[0] = 1; dashes[1] = 3*width-2; dashes[2] = 0;
*/
} else if (type == core::style::LINE_DASHED) {
- line_style(FL_DASH + FL_CAP_ROUND, w);
+ fl_line_style(FL_DASH + FL_CAP_ROUND, w);
}
- setcolor(((FltkColor*)color)->colors[shading]);
+ fl_color(((FltkColor*)color)->colors[shading]);
drawLine (color, shading, x1, y1, x2, y2);
if (type != core::style::LINE_NORMAL)
- line_style(FL_SOLID);
+ fl_line_style(FL_SOLID);
}
void FltkViewBase::drawRectangle (core::style::Color *color,
@@ -401,7 +421,7 @@ void FltkViewBase::drawRectangle (core::style::Color *color,
bool filled,
int x, int y, int width, int height)
{
- setcolor(((FltkColor*)color)->colors[shading]);
+ fl_color(((FltkColor*)color)->colors[shading]);
if (width < 0) {
x += width;
width = -width;
@@ -416,17 +436,19 @@ void FltkViewBase::drawRectangle (core::style::Color *color,
int x2 = translateCanvasXToViewX (x + width);
int y2 = translateCanvasYToViewY (y + height);
+#if 0
+PORT1.3
// We only support rectangles with line width 1px, so we clip with
// a rectangle 1px wider and higher than what we actually expose.
// This is only really necessary for non-filled rectangles.
clipPoint (&x1, &y1, 1);
clipPoint (&x2, &y2, 1);
+#endif
- ::fltk::Rectangle rect (x1, y1, x2 - x1, y2 - y1);
if (filled)
- fillrect (rect);
+ fl_rectf (x1, y1, x2 - x1, y2 - y1);
else
- strokerect (rect);
+ fl_rect (x1, y1, x2 - x1, y2 - y1);
}
void FltkViewBase::drawArc (core::style::Color *color,
@@ -434,7 +456,9 @@ void FltkViewBase::drawArc (core::style::Color *color,
int centerX, int centerY, int width, int height,
int angle1, int angle2)
{
- setcolor(((FltkColor*)color)->colors[shading]);
+ fl_color(((FltkColor*)color)->colors[shading]);
+#if 0
+PORT1.3
int x = translateCanvasXToViewX (centerX) - width / 2;
int y = translateCanvasYToViewY (centerY) - height / 2;
::fltk::Rectangle rect (x, y, width, height);
@@ -444,12 +468,15 @@ void FltkViewBase::drawArc (core::style::Color *color,
fillpath();
else
strokepath();
+#endif
}
void FltkViewBase::drawPolygon (core::style::Color *color,
core::style::Color::Shading shading,
bool filled, int points[][2], int npoints)
{
+#if 0
+PORT1.3
if (npoints > 0) {
for (int i = 0; i < npoints; i++) {
points[i][0] = translateCanvasXToViewX(points[i][0]);
@@ -463,6 +490,7 @@ void FltkViewBase::drawPolygon (core::style::Color *color,
else
strokepath();
}
+#endif
}
core::View *FltkViewBase::getClippingView (int x, int y, int width, int height)
@@ -490,6 +518,8 @@ FltkWidgetView::~FltkWidgetView ()
}
void FltkWidgetView::layout () {
+#if 0
+PORT1.3
/**
* pass layout to child widgets. This is needed for complex fltk
* widgets as TextEditor.
@@ -502,6 +532,7 @@ void FltkWidgetView::layout () {
widget->layout ();
}
}
+#endif
}
void FltkWidgetView::drawText (core::style::Font *font,
@@ -510,12 +541,12 @@ void FltkWidgetView::drawText (core::style::Font *font,
int x, int y, const char *text, int len)
{
FltkFont *ff = (FltkFont*)font;
- setfont(ff->font, ff->size);
- setcolor(((FltkColor*)color)->colors[shading]);
+ fl_font(ff->font, ff->size);
+ fl_color(((FltkColor*)color)->colors[shading]);
if (!font->letterSpacing && !font->fontVariant) {
- drawtext(text, len,
- translateCanvasXToViewX (x), translateCanvasYToViewY (y));
+ fl_draw(text, len,
+ translateCanvasXToViewX (x), translateCanvasYToViewY (y));
} else {
/* Nonzero letter spacing adjustment, draw each glyph individually */
int viewX = translateCanvasXToViewX (x),
@@ -531,25 +562,28 @@ void FltkWidgetView::drawText (core::style::Font *font,
wc = fl_utf8decode(text + curr, text + next, &nb);
if ((wcu = towupper(wc)) == wc) {
/* already uppercase, just draw the character */
- setfont(ff->font, ff->size);
- drawtext(text + curr, next - curr, viewX, viewY);
+ fl_font(ff->font, ff->size);
+ fl_draw(text + curr, next - curr, viewX, viewY);
viewX += font->letterSpacing;
- viewX += (int)getwidth(text + curr, next - curr);
+ viewX += (int)fl_width(text + curr, next - curr);
} else {
+#if 0
+PORT1.3
/* make utf8 string for converted char */
nb = utf8encode(wcu, chbuf);
- setfont(ff->font, sc_fontsize);
- drawtext(chbuf, nb, viewX, viewY);
+#endif
+ fl_font(ff->font, sc_fontsize);
+ fl_draw(chbuf, nb, viewX, viewY);
viewX += font->letterSpacing;
- viewX += (int)getwidth(chbuf, nb);
+ viewX += (int)fl_width(chbuf, nb);
}
}
} else {
while (next < len) {
next = theLayout->nextGlyph(text, curr);
- drawtext(text + curr, next - curr, viewX, viewY);
+ fl_draw(text + curr, next - curr, viewX, viewY);
viewX += font->letterSpacing +
- (int)getwidth(text + curr,next - curr);
+ (int)fl_width(text + curr,next - curr);
curr = next;
}
}
@@ -570,33 +604,36 @@ bool FltkWidgetView::usesFltkWidgets ()
return true;
}
-void FltkWidgetView::addFltkWidget (::fltk::Widget *widget,
- core::Allocation *allocation)
+void FltkWidgetView::addFltkWidget (Fl_Widget *widget,
+ core::Allocation *allocation)
{
allocateFltkWidget (widget, allocation);
add (widget);
}
-void FltkWidgetView::removeFltkWidget (::fltk::Widget *widget)
+void FltkWidgetView::removeFltkWidget (Fl_Widget *widget)
{
remove (widget);
}
-void FltkWidgetView::allocateFltkWidget (::fltk::Widget *widget,
+void FltkWidgetView::allocateFltkWidget (Fl_Widget *widget,
core::Allocation *allocation)
{
- widget->x (translateCanvasXToViewX (allocation->x));
- widget->y (translateCanvasYToViewY (allocation->y));
- widget->w (allocation->width);
- widget->h (allocation->ascent + allocation->descent);
+ widget->resize (translateCanvasXToViewX (allocation->x),
+ translateCanvasYToViewY (allocation->y),
+ allocation->width,
+ allocation->ascent + allocation->descent);
+#if 0
+PORT1.3
/* widgets created tiny and later resized need this flag to display */
uchar damage = widget->layout_damage ();
damage |= LAYOUT_XYWH;
widget->layout_damage (damage);
+#endif
}
-void FltkWidgetView::drawFltkWidget (::fltk::Widget *widget,
+void FltkWidgetView::drawFltkWidget (Fl_Widget *widget,
core::Rectangle *area)
{
draw_child (*widget);
diff --git a/dw/fltkviewbase.hh b/dw/fltkviewbase.hh
index f554a74d..ccdc86ef 100644
--- a/dw/fltkviewbase.hh
+++ b/dw/fltkviewbase.hh
@@ -20,12 +20,13 @@ private:
int bgColor;
core::Region drawRegion;
- ::fltk::Rectangle *exposeArea;
+ //::fltk::Rectangle *exposeArea;
static Fl_Image *backBuffer;
static bool backBufferInUse;
void draw (const core::Rectangle *rect, DrawType type);
void drawChildWidgets ();
+#if 0
inline void clipPoint (int *x, int *y, int border) {
if (exposeArea) {
if (*x < exposeArea->x () - border)
@@ -38,7 +39,7 @@ private:
*y = exposeArea->b () + border;
}
}
-
+#endif
protected:
core::Layout *theLayout;
int canvasWidth, canvasHeight;
diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc
index f27ec761..2d178f0e 100644
--- a/dw/fltkviewport.cc
+++ b/dw/fltkviewport.cc
@@ -143,18 +143,19 @@ void FltkViewport::hscrollbarCallback (Fl_Widget *hscrollbar,void *viewportPtr)
// ----------------------------------------------------------------------
-void FltkViewport::layout ()
+void FltkViewport::resize(int X, int Y, int W, int H)
{
- theLayout->viewportSizeChanged (this, w(), h());
- adjustScrollbarsAndGadgetsAllocation ();
-
- FltkWidgetView::layout ();
+ if (W != w() || H != h()) {
+ theLayout->viewportSizeChanged (this, W, H);
+ adjustScrollbarsAndGadgetsAllocation ();
+ }
+ Fl_Group::resize(X, Y, W, H);
}
-void FltkViewport::draw_area (void *data, const Rectangle& cr )
+void FltkViewport::draw_area (void *data, int x, int y, int w, int h)
{
FltkViewport *vp = (FltkViewport*) data;
- fl_push_clip(cr.x, cr.y, cr.w, cr.h);
+ fl_push_clip(x, y, w, h);
vp->FltkWidgetView::draw ();
@@ -172,18 +173,17 @@ void FltkViewport::draw ()
{
int hdiff = vscrollbar->visible () ? SCROLLBAR_THICKNESS : 0;
int vdiff = hscrollbar->visible () ? SCROLLBAR_THICKNESS : 0;
- Rectangle cr (0, 0, w () - hdiff, h () - vdiff);
int d = damage();
if (d & FL_DAMAGE_SCROLL) {
Fl::damage (FL_DAMAGE_SCROLL);
- scrollrect(cr, -scrollDX, -scrollDY, draw_area, this);
+ fl_scroll(0, 0, w () - hdiff, h () - vdiff, -scrollDX, -scrollDY, draw_area, this);
d &= ~FL_DAMAGE_SCROLL;
Fl::damage (d);
}
if (d) {
- draw_area(this, cr);
+ draw_area(this, 0, 0, w () - hdiff, h () - vdiff);
if (d == FL_DAMAGE_CHILD) {
if (hscrollbar->damage ())
@@ -203,7 +203,8 @@ void FltkViewport::draw ()
int FltkViewport::handle (int event)
{
_MSG("FltkViewport::handle %d\n", event);
-
+#if 0
+PORT1.3
if (hscrollbar->Rectangle::contains (Fl::event_x (), Fl::event_y ()) &&
!(Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT)) &&
hscrollbar->handle (event)) {
@@ -214,6 +215,7 @@ int FltkViewport::handle (int event)
vscrollbar->handle (event)) {
return 1;
}
+#endif
switch(event) {
case FL_KEYBOARD:
@@ -226,7 +228,8 @@ int FltkViewport::handle (int event)
case FL_FOCUS:
/** \bug Draw focus box. */
-
+#if 0
+PORT1.3
/* If the user clicks with the left button we take focus
* and thereby unfocus any form widgets.
* Otherwise we let fltk do the focus handling.
@@ -235,6 +238,7 @@ int FltkViewport::handle (int event)
focus_index(-1);
return 1;
}
+#endif
break;
case FL_UNFOCUS:
@@ -377,9 +381,9 @@ void FltkViewport::scroll (int dx, int dy)
void FltkViewport::scroll (core::ScrollCommand cmd)
{
if (cmd == core::SCREEN_UP_CMD) {
- scroll (0, -vscrollbar->pagesize ());
+ scroll (0, -h ());
} else if (cmd == core::SCREEN_DOWN_CMD) {
- scroll (0, vscrollbar->pagesize ());
+ scroll (0, h ());
} else if (cmd == core::LINE_UP_CMD) {
scroll (0, (int) -vscrollbar->linesize ());
} else if (cmd == core::LINE_DOWN_CMD) {
diff --git a/dw/fltkviewport.hh b/dw/fltkviewport.hh
index 353eac42..a0a16830 100644
--- a/dw/fltkviewport.hh
+++ b/dw/fltkviewport.hh
@@ -39,7 +39,7 @@ private:
static void vscrollbarCallback (Fl_Widget *vscrollbar, void *viewportPtr);
void updateCanvasWidgets (int oldScrollX, int oldScrollY);
- static void draw_area (void *data, const Rectangle& cr);
+ static void draw_area (void *data, int x, int y, int w, int h);
protected:
int translateViewXToCanvasX (int x);
@@ -51,7 +51,7 @@ public:
FltkViewport (int x, int y, int w, int h, const char *label = 0);
~FltkViewport ();
- void layout();
+ void resize(int x, int y, int w, int h);
void draw ();
int handle (int event);