summaryrefslogtreecommitdiff
path: root/dw/fltkviewbase.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dw/fltkviewbase.cc')
-rw-r--r--dw/fltkviewbase.cc494
1 files changed, 251 insertions, 243 deletions
diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc
index 06e0cbc8..22fb06ef 100644
--- a/dw/fltkviewbase.cc
+++ b/dw/fltkviewbase.cc
@@ -21,40 +21,65 @@
#include "fltkviewport.hh"
-#include <fltk/draw.h>
-#include <fltk/damage.h>
-#include <fltk/layout.h>
-#include <fltk/events.h>
-#include <fltk/Cursor.h>
-#include <fltk/run.h>
-#include <fltk/utf.h>
+#include <FL/Fl.H>
+#include <FL/fl_draw.H>
#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
#include "../lout/msg.h"
-using namespace fltk;
+extern Fl_Widget* fl_oldfocus;
+
using namespace lout::object;
using namespace lout::container::typed;
namespace dw {
namespace fltk {
-::fltk::Image *FltkViewBase::backBuffer;
+FltkViewBase::BackBuffer::BackBuffer ()
+{
+ w = 0;
+ h = 0;
+ created = false;
+}
+
+FltkViewBase::BackBuffer::~BackBuffer ()
+{
+ if (created)
+ fl_delete_offscreen (offscreen);
+}
+
+void FltkViewBase::BackBuffer::setSize (int w, int h)
+{
+ if (!created || w > this->w || h > this->h) {
+ this->w = w;
+ this->h = h;
+ if (created)
+ fl_delete_offscreen (offscreen);
+ offscreen = fl_create_offscreen (w, h);
+ created = true;
+ }
+}
+
+FltkViewBase::BackBuffer *FltkViewBase::backBuffer;
bool FltkViewBase::backBufferInUse;
FltkViewBase::FltkViewBase (int x, int y, int w, int h, const char *label):
- Group (x, y, w, h, label)
+ Fl_Group (x, y, w, h, label)
{
+ Fl_Group::current(0);
canvasWidth = 1;
canvasHeight = 1;
- bgColor = WHITE;
+ bgColor = FL_WHITE;
mouse_x = mouse_y = 0;
+ focused_child = NULL;
exposeArea = NULL;
if (backBuffer == NULL) {
- backBuffer = new Image ();
+ backBuffer = new BackBuffer ();
}
+ box(FL_NO_BOX);
+ resizable(NULL);
}
FltkViewBase::~FltkViewBase ()
@@ -64,7 +89,7 @@ FltkViewBase::~FltkViewBase ()
void FltkViewBase::setBufferedDrawing (bool b) {
if (b && backBuffer == NULL) {
- backBuffer = new Image ();
+ backBuffer = new BackBuffer ();
} else if (!b && backBuffer != NULL) {
delete backBuffer;
backBuffer = NULL;
@@ -75,7 +100,7 @@ void FltkViewBase::draw ()
{
int d = damage ();
- if ((d & DAMAGE_VALUE) && !(d & DAMAGE_EXPOSE)) {
+ if ((d & FL_DAMAGE_USER1) && !(d & FL_DAMAGE_EXPOSE)) {
lout::container::typed::Iterator <core::Rectangle> it;
for (it = drawRegion.rectangles (); it.hasNext (); ) {
@@ -83,22 +108,22 @@ void FltkViewBase::draw ()
}
drawRegion.clear ();
- d &= ~DAMAGE_VALUE;
+ d &= ~FL_DAMAGE_USER1;
}
- if (d & DAMAGE_CHILD) {
+ if (d & FL_DAMAGE_CHILD) {
drawChildWidgets ();
- d &= ~DAMAGE_CHILD;
+ d &= ~FL_DAMAGE_CHILD;
}
if (d) {
dw::core::Rectangle rect (
- translateViewXToCanvasX (0),
- translateViewYToCanvasY (0),
+ translateViewXToCanvasX (x ()),
+ translateViewYToCanvasY (y ()),
w (),
h ());
- if (d == DAMAGE_SCROLL) {
+ if (d == FL_DAMAGE_SCROLL) {
// a clipping rectangle has already been set by fltk::scrollrect ()
draw (&rect, DRAW_PLAIN);
} else {
@@ -111,88 +136,81 @@ void FltkViewBase::draw ()
void FltkViewBase::draw (const core::Rectangle *rect,
DrawType type)
{
- int offsetX = 0, offsetY = 0;
-
- /* fltk-clipping does not use widget coordinates */
- transform (offsetX, offsetY);
-
- ::fltk::Rectangle viewRect (
- translateCanvasXToViewX (rect->x) + offsetX,
- translateCanvasYToViewY (rect->y) + offsetY,
- rect->width, rect->height);
-
- ::fltk::intersect_with_clip (viewRect);
-
- viewRect.x (viewRect.x () - offsetX);
- viewRect.y (viewRect.y () - offsetY);
-
- if (! viewRect.empty ()) {
- dw::core::Rectangle r (
- translateViewXToCanvasX (viewRect.x ()),
- translateViewYToCanvasY (viewRect.y ()),
- viewRect.w (),
- viewRect.h ());
-
- exposeArea = &viewRect;
-
- if (type == DRAW_BUFFERED && backBuffer && !backBufferInUse) {
- backBufferInUse = true;
- {
- GSave gsave;
-
- backBuffer->setsize (viewRect.w (), viewRect.h ());
- backBuffer->make_current ();
- translate (-viewRect.x (), -viewRect.y ());
-
- setcolor (bgColor);
- fillrect (viewRect);
- theLayout->expose (this, &r);
- }
-
- backBuffer->draw (Rectangle (0, 0, viewRect.w (), viewRect.h ()),
- viewRect);
-
- backBufferInUse = false;
- } else if (type == DRAW_BUFFERED || type == DRAW_CLIPPED) {
- // if type == DRAW_BUFFERED but we do not have backBuffer available
- // we fall back to clipped drawing
- push_clip (viewRect);
- setcolor (bgColor);
- fillrect (viewRect);
- theLayout->expose (this, &r);
- pop_clip ();
- } else {
- setcolor (bgColor);
- fillrect (viewRect);
- theLayout->expose (this, &r);
- }
-
- exposeArea = NULL;
+ int X = translateCanvasXToViewX (rect->x);
+ int Y = translateCanvasYToViewY (rect->y);
+ int W, H;
+
+ // fl_clip_box() can't handle values greater than SHRT_MAX!
+ if (X > x () + w () || Y > y () + h ())
+ return;
+
+ W = X + rect->width > x () + w () ? x () + w () - X : rect->width;
+ H = Y + rect->height > y () + h () ? y () + h () - Y : rect->height;
+
+ fl_clip_box(X, Y, W, H, X, Y, W, H);
+
+ core::Rectangle r (translateViewXToCanvasX (X),
+ translateViewYToCanvasY (Y), W, H);
+
+ if (r.isEmpty ())
+ return;
+
+ exposeArea = &r;
+
+ if (type == DRAW_BUFFERED && backBuffer && !backBufferInUse) {
+ backBufferInUse = true;
+ backBuffer->setSize (X + W, Y + H); // would be nicer to use (W, H)...
+ fl_begin_offscreen (backBuffer->offscreen);
+ fl_push_matrix ();
+ fl_color (bgColor);
+ fl_rectf (X, Y, W, H);
+ theLayout->expose (this, &r);
+ fl_pop_matrix ();
+ fl_end_offscreen ();
+ fl_copy_offscreen (X, Y, W, H, backBuffer->offscreen, X, Y);
+ backBufferInUse = false;
+ } else if (type == DRAW_BUFFERED || type == DRAW_CLIPPED) {
+ // if type == DRAW_BUFFERED but we do not have backBuffer available
+ // we fall back to clipped drawing
+ fl_push_clip (X, Y, W, H);
+ fl_color (bgColor);
+ fl_rectf (X, Y, W, H);
+ theLayout->expose (this, &r);
+ fl_pop_clip ();
+ } else {
+ fl_color (bgColor);
+ fl_rectf (X, Y, W, H);
+ theLayout->expose (this, &r);
}
+
+ exposeArea = NULL;
}
void FltkViewBase::drawChildWidgets () {
for (int i = children () - 1; i >= 0; i--) {
- Widget& w = *child(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);
}
}
core::ButtonState getDwButtonState ()
{
- int s1 = event_state ();
+ int s1 = Fl::event_state ();
int s2 = (core::ButtonState)0;
- if (s1 & SHIFT) s2 |= core::SHIFT_MASK;
- if (s1 & CTRL) s2 |= core::CONTROL_MASK;
- if (s1 & ALT) s2 |= core::META_MASK;
- if (s1 & BUTTON1) s2 |= core::BUTTON1_MASK;
- if (s1 & BUTTON2) s2 |= core::BUTTON2_MASK;
- if (s1 & BUTTON3) s2 |= core::BUTTON3_MASK;
+ if (s1 & FL_SHIFT) s2 |= core::SHIFT_MASK;
+ if (s1 & FL_CTRL) s2 |= core::CONTROL_MASK;
+ if (s1 & FL_ALT) s2 |= core::META_MASK;
+ if (s1 & FL_BUTTON1) s2 |= core::BUTTON1_MASK;
+ if (s1 & FL_BUTTON2) s2 |= core::BUTTON2_MASK;
+ if (s1 & FL_BUTTON3) s2 |= core::BUTTON3_MASK;
return (core::ButtonState)s2;
}
@@ -207,60 +225,72 @@ int FltkViewBase::handle (int event)
* when passed a fltk::PUSH event. "
*/
switch(event) {
- case PUSH:
+ case FL_PUSH:
processed =
- theLayout->buttonPress (this, event_clicks () + 1,
- translateViewXToCanvasX (event_x ()),
- translateViewYToCanvasY (event_y ()),
- getDwButtonState (), event_button ());
+ theLayout->buttonPress (this, Fl::event_clicks () + 1,
+ translateViewXToCanvasX (Fl::event_x ()),
+ translateViewYToCanvasY (Fl::event_y ()),
+ getDwButtonState (), Fl::event_button ());
_MSG("PUSH => %s\n", processed ? "true" : "false");
if (processed) {
/* pressed dw content; give focus to the view */
- ::fltk::focus(this);
+ Fl::focus(this);
}
- return processed ? true : Group::handle (event);
+ return processed ? true : Fl_Group::handle (event);
- case RELEASE:
+ case FL_RELEASE:
processed =
- theLayout->buttonRelease (this, event_clicks () + 1,
- translateViewXToCanvasX (event_x ()),
- translateViewYToCanvasY (event_y ()),
- getDwButtonState (), event_button ());
+ theLayout->buttonRelease (this, Fl::event_clicks () + 1,
+ translateViewXToCanvasX (Fl::event_x ()),
+ translateViewYToCanvasY (Fl::event_y ()),
+ getDwButtonState (), Fl::event_button ());
_MSG("RELEASE => %s\n", processed ? "true" : "false");
- return processed ? true : Group::handle (event);
+ return processed ? true : Fl_Group::handle (event);
- case MOVE:
- mouse_x = event_x();
- mouse_y = event_y();
+ case FL_MOVE:
+ mouse_x = Fl::event_x();
+ mouse_y = Fl::event_y();
processed =
theLayout->motionNotify (this,
translateViewXToCanvasX (mouse_x),
translateViewYToCanvasY (mouse_y),
getDwButtonState ());
_MSG("MOVE => %s\n", processed ? "true" : "false");
- return processed ? true : Group::handle (event);
+ return processed ? true : Fl_Group::handle (event);
- case DRAG:
+ case FL_DRAG:
processed =
theLayout->motionNotify (this,
- translateViewXToCanvasX (event_x ()),
- translateViewYToCanvasY (event_y ()),
+ translateViewXToCanvasX (Fl::event_x ()),
+ translateViewYToCanvasY (Fl::event_y ()),
getDwButtonState ());
_MSG("DRAG => %s\n", processed ? "true" : "false");
- return processed ? true : Group::handle (event);
+ return processed ? true : Fl_Group::handle (event);
- case ENTER:
- theLayout->enterNotify (this, translateViewXToCanvasX (event_x ()),
- translateViewYToCanvasY (event_y ()),
+ case FL_ENTER:
+ theLayout->enterNotify (this,
+ translateViewXToCanvasX (Fl::event_x ()),
+ translateViewYToCanvasY (Fl::event_y ()),
getDwButtonState ());
- return Group::handle (event);
+ return Fl_Group::handle (event);
- case LEAVE:
+ case FL_LEAVE:
theLayout->leaveNotify (this, getDwButtonState ());
- return Group::handle (event);
+ return Fl_Group::handle (event);
+
+ case FL_FOCUS:
+ if (focused_child && find(focused_child) < children()) {
+ /* strangely, find() == children() if the child is not found */
+ focused_child->take_focus();
+ }
+ return 1;
+
+ case FL_UNFOCUS:
+ focused_child = fl_oldfocus;
+ return 0;
default:
- return Group::handle (event);
+ return Fl_Group::handle (event);
}
}
@@ -269,6 +299,8 @@ int FltkViewBase::handle (int event)
void FltkViewBase::setLayout (core::Layout *layout)
{
theLayout = layout;
+ if (usesViewport())
+ theLayout->viewportSizeChanged(this, w(), h());
}
void FltkViewBase::setCanvasSize (int width, int ascent, int descent)
@@ -279,55 +311,32 @@ void FltkViewBase::setCanvasSize (int width, int ascent, int descent)
void FltkViewBase::setCursor (core::style::Cursor cursor)
{
- static Cursor *mapDwToFltk[] = {
- CURSOR_CROSS,
- CURSOR_DEFAULT,
- CURSOR_HAND,
- CURSOR_MOVE,
- CURSOR_WE,
- CURSOR_NESW,
- CURSOR_NWSE,
- CURSOR_NS,
- CURSOR_NWSE,
- CURSOR_NESW,
- CURSOR_NS,
- CURSOR_WE,
- CURSOR_INSERT,
- CURSOR_WAIT,
- CURSOR_HELP
- };
-
- /*
- static char *cursorName[] = {
- "CURSOR_CROSS",
- "CURSOR_DEFAULT",
- "CURSOR_HAND",
- "CURSOR_MOVE",
- "CURSOR_WE",
- "CURSOR_NESW",
- "CURSOR_NWSE",
- "CURSOR_NS",
- "CURSOR_NWSE",
- "CURSOR_NESW",
- "CURSOR_NS",
- "CURSOR_WE",
- "CURSOR_INSERT",
- "CURSOR_WAIT",
- "CURSOR_HELP"
+ static Fl_Cursor mapDwToFltk[] = {
+ FL_CURSOR_CROSS,
+ FL_CURSOR_DEFAULT,
+ FL_CURSOR_HAND,
+ FL_CURSOR_MOVE,
+ FL_CURSOR_WE,
+ FL_CURSOR_NESW,
+ FL_CURSOR_NWSE,
+ FL_CURSOR_NS,
+ FL_CURSOR_NWSE,
+ FL_CURSOR_NESW,
+ FL_CURSOR_NS,
+ FL_CURSOR_WE,
+ FL_CURSOR_INSERT,
+ FL_CURSOR_WAIT,
+ FL_CURSOR_HELP
};
- MSG("Cursor changes to '%s'.\n", cursorName[cursor]);
- */
-
- /** \bug Does not work */
- this->cursor (mapDwToFltk[cursor]);
+ fl_cursor (mapDwToFltk[cursor]);
}
void FltkViewBase::setBgColor (core::style::Color *color)
{
bgColor = color ?
((FltkColor*)color)->colors[dw::core::style::Color::SHADING_NORMAL] :
- WHITE;
+ FL_WHITE;
}
void FltkViewBase::startDrawing (core::Rectangle *area)
@@ -342,12 +351,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 (DAMAGE_EXPOSE);
+ damage (FL_DAMAGE_EXPOSE);
}
void FltkViewBase::cancelQueueDraw ()
@@ -364,9 +373,16 @@ 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]);
+ // we clip with a large border (5000px), as clipping causes artefacts
+ // with non-solid line styles.
+ // However it's still better than no clipping at all.
+ clipPoint (&x1, &y1, 5000);
+ clipPoint (&x2, &y2, 5000);
+ fl_line (translateCanvasXToViewX (x1),
+ translateCanvasYToViewY (y1),
+ translateCanvasXToViewX (x2),
+ translateCanvasYToViewY (y2));
}
void FltkViewBase::drawTypedLine (core::style::Color *color,
@@ -385,42 +401,42 @@ 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(::fltk::DASH + ::fltk::CAP_ROUND, w, dashes);
+ fl_line_style(FL_DASH + FL_CAP_ROUND, w, dashes);
/* These formulas also work, but ain't pretty ;)
- * line_style(::fltk::DOT + ::fltk::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(::fltk::DASH + ::fltk::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(::fltk::SOLID);
+ fl_line_style(FL_SOLID);
}
void FltkViewBase::drawRectangle (core::style::Color *color,
core::style::Color::Shading shading,
bool filled,
- int x, int y, int width, int height)
+ int X, int Y, int width, int height)
{
- setcolor(((FltkColor*)color)->colors[shading]);
+ fl_color(((FltkColor*)color)->colors[shading]);
if (width < 0) {
- x += width;
+ X += width;
width = -width;
}
if (height < 0) {
- y += height;
+ Y += height;
height = -height;
}
- int x1 = translateCanvasXToViewX (x);
- int y1 = translateCanvasYToViewY (y);
- int x2 = translateCanvasXToViewX (x + width);
- int y2 = translateCanvasYToViewY (y + height);
+ int x1 = X;
+ int y1 = Y;
+ int x2 = X + width;
+ int y2 = Y + height;
// We only support rectangles with line width 1px, so we clip with
// a rectangle 1px wider and higher than what we actually expose.
@@ -428,11 +444,15 @@ void FltkViewBase::drawRectangle (core::style::Color *color,
clipPoint (&x1, &y1, 1);
clipPoint (&x2, &y2, 1);
- ::fltk::Rectangle rect (x1, y1, x2 - x1, y2 - y1);
+ x1 = translateCanvasXToViewX (x1);
+ y1 = translateCanvasYToViewY (y1);
+ x2 = translateCanvasXToViewX (x2);
+ y2 = translateCanvasYToViewY (y2);
+
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,
@@ -440,47 +460,55 @@ 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]);
int x = translateCanvasXToViewX (centerX) - width / 2;
int y = translateCanvasYToViewY (centerY) - height / 2;
- ::fltk::Rectangle rect (x, y, width, height);
- addchord(rect, angle1, angle2);
- closepath();
+
+ fl_arc(x, y, width, height, 0.0, 360.0);
if (filled)
- fillpath();
- else
- strokepath();
+ fl_pie(x, y, width, height, 0.0, 360.0);
}
void FltkViewBase::drawPolygon (core::style::Color *color,
core::style::Color::Shading shading,
- bool filled, int points[][2], int npoints)
+ bool filled, bool convex, int points[][2],
+ int npoints)
{
if (npoints > 0) {
+ fl_color(((FltkColor*)color)->colors[shading]);
+
+ if (filled) {
+ if (convex)
+ fl_begin_polygon();
+ else
+ fl_begin_complex_polygon();
+ } else
+ fl_begin_loop();
+
for (int i = 0; i < npoints; i++) {
- points[i][0] = translateCanvasXToViewX(points[i][0]);
- points[i][1] = translateCanvasYToViewY(points[i][1]);
+ fl_vertex(translateCanvasXToViewX(points[i][0]),
+ translateCanvasYToViewY(points[i][1]));
}
- setcolor(((FltkColor*)color)->colors[shading]);
- addvertices(npoints, points);
- closepath();
- if (filled)
- fillpath();
- else
- strokepath();
+ if (filled) {
+ if (convex)
+ fl_end_polygon();
+ else
+ fl_end_complex_polygon();
+ } else
+ fl_end_loop();
}
}
core::View *FltkViewBase::getClippingView (int x, int y, int width, int height)
{
- push_clip (translateCanvasXToViewX (x), translateCanvasYToViewY (y),
- width, height);
+ fl_push_clip (translateCanvasXToViewX (x), translateCanvasYToViewY (y),
+ width, height);
return this;
}
void FltkViewBase::mergeClippingView (core::View *clippingView)
{
- pop_clip ();
+ fl_pop_clip ();
}
// ----------------------------------------------------------------------
@@ -495,37 +523,22 @@ FltkWidgetView::~FltkWidgetView ()
{
}
-void FltkWidgetView::layout () {
- /**
- * pass layout to child widgets. This is needed for complex fltk
- * widgets as TextEditor.
- * We can't use Group::layout() as that would rearrange the widgets.
- */
- for (int i = children () - 1; i >= 0; i--) {
- ::fltk::Widget *widget = child (i);
-
- if (widget->layout_damage ()) {
- widget->layout ();
- }
- }
-}
-
void FltkWidgetView::drawText (core::style::Font *font,
core::style::Color *color,
core::style::Color::Shading shading,
- int x, int y, const char *text, int len)
+ 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),
- viewY = translateCanvasYToViewY (y);
+ int viewX = translateCanvasXToViewX (X),
+ viewY = translateCanvasYToViewY (Y);
int curr = 0, next = 0, nb;
char chbuf[4];
wchar_t wc, wcu;
@@ -534,28 +547,28 @@ void FltkWidgetView::drawText (core::style::Font *font,
int sc_fontsize = lout::misc::roundInt(ff->size * 0.78);
for (curr = 0; next < len; curr = next) {
next = theLayout->nextGlyph(text, curr);
- wc = utf8decode(text + curr, text + next, &nb);
+ 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 {
/* make utf8 string for converted char */
- nb = utf8encode(wcu, chbuf);
- setfont(ff->font, sc_fontsize);
- drawtext(chbuf, nb, viewX, viewY);
+ nb = fl_utf8encode(wcu, chbuf);
+ 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;
}
}
@@ -563,12 +576,12 @@ void FltkWidgetView::drawText (core::style::Font *font,
}
void FltkWidgetView::drawImage (core::Imgbuf *imgbuf, int xRoot, int yRoot,
- int x, int y, int width, int height)
+ int X, int Y, int width, int height)
{
((FltkImgbuf*)imgbuf)->draw (this,
translateCanvasXToViewX (xRoot),
translateCanvasYToViewY (yRoot),
- x, y, width, height);
+ X, Y, width, height);
}
bool FltkWidgetView::usesFltkWidgets ()
@@ -576,33 +589,28 @@ 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);
-
- /* widgets created tiny and later resized need this flag to display */
- uchar damage = widget->layout_damage ();
- damage |= LAYOUT_XYWH;
- widget->layout_damage (damage);
+ widget->resize (translateCanvasXToViewX (allocation->x),
+ translateCanvasYToViewY (allocation->y),
+ allocation->width,
+ allocation->ascent + allocation->descent);
}
-void FltkWidgetView::drawFltkWidget (::fltk::Widget *widget,
+void FltkWidgetView::drawFltkWidget (Fl_Widget *widget,
core::Rectangle *area)
{
draw_child (*widget);