aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
Diffstat (limited to 'dw')
-rw-r--r--dw/fltkplatform.cc43
-rw-r--r--dw/fltkplatform.hh9
-rw-r--r--dw/layout.hh17
-rw-r--r--dw/platform.hh20
-rw-r--r--dw/style.cc58
-rw-r--r--dw/style.hh23
-rw-r--r--dw/textblock.cc18
7 files changed, 87 insertions, 101 deletions
diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc
index 337f4dba..94a5dd70 100644
--- a/dw/fltkplatform.cc
+++ b/dw/fltkplatform.cc
@@ -25,6 +25,7 @@
#include <fltk/draw.h>
#include <fltk/run.h>
#include <fltk/events.h>
+#include <fltk/Monitor.h>
#include <fltk/utf.h>
#include <stdio.h>
@@ -54,7 +55,7 @@ FltkFont::FltkFont (core::style::FontAttrs *attrs)
font = ::fltk::font(name, fa);
if(font == NULL) {
- fprintf(stderr, "No font '%s', using default sans-serif font.\n", name);
+ //fprintf(stderr, "No font '%s', using default sans-serif font.\n",name);
/*
* If using xft, fltk::HELVETICA just means sans, fltk::COURIER
* means mono, and fltk::TIMES means serif.
@@ -100,11 +101,9 @@ container::typed::HashTable <dw::core::style::ColorAttrs,
new container::typed::HashTable <dw::core::style::ColorAttrs,
FltkColor> (false, false);
-FltkColor::FltkColor (int color, core::style::Color::Type type):
- Color (color, type)
+FltkColor::FltkColor (int color): Color (color)
{
this->color = color;
- this->type = type;
/*
* fltk/setcolor.cxx:
@@ -122,13 +121,10 @@ FltkColor::FltkColor (int color, core::style::Color::Type type):
colors[SHADING_NORMAL] = ::fltk::BLACK;
if (!(colors[SHADING_INVERSE] = shadeColor (color, SHADING_INVERSE) << 8))
colors[SHADING_INVERSE] = ::fltk::BLACK;
-
- if(type == core::style::Color::TYPE_SHADED) {
- if (!(colors[SHADING_DARK] = shadeColor (color, SHADING_DARK) << 8))
- colors[SHADING_DARK] = ::fltk::BLACK;
- if (!(colors[SHADING_LIGHT] = shadeColor (color, SHADING_LIGHT) << 8))
- colors[SHADING_LIGHT] = ::fltk::BLACK;
- }
+ if (!(colors[SHADING_DARK] = shadeColor (color, SHADING_DARK) << 8))
+ colors[SHADING_DARK] = ::fltk::BLACK;
+ if (!(colors[SHADING_LIGHT] = shadeColor (color, SHADING_LIGHT) << 8))
+ colors[SHADING_LIGHT] = ::fltk::BLACK;
}
FltkColor::~FltkColor ()
@@ -136,13 +132,13 @@ FltkColor::~FltkColor ()
colorsTable->remove (this);
}
-FltkColor * FltkColor::create (int col, core::style::Color::Type type)
+FltkColor * FltkColor::create (int col)
{
- ColorAttrs attrs(col, type);
+ ColorAttrs attrs(col);
FltkColor *color = colorsTable->get (&attrs);
if (color == NULL) {
- color = new FltkColor (col, type);
+ color = new FltkColor (col);
colorsTable->put (color, color);
}
@@ -301,6 +297,16 @@ int FltkPlatform::prevGlyph (const char *text, int idx)
return utf8back (&text[idx - 1], text, &text[strlen (text)]) - text;
}
+float FltkPlatform::dpiX ()
+{
+ return ::fltk::Monitor::all ().dpi_x ();
+}
+
+float FltkPlatform::dpiY ()
+{
+ return ::fltk::Monitor::all ().dpi_y ();
+}
+
void FltkPlatform::generalStaticIdle (void *data)
{
((FltkPlatform*)data)->generalIdle();
@@ -374,14 +380,9 @@ core::style::Font *FltkPlatform::createFont (core::style::FontAttrs
return FltkFont::create (attrs);
}
-core::style::Color *FltkPlatform::createSimpleColor (int color)
-{
- return FltkColor::create (color, core::style::Color::TYPE_SIMPLE);
-}
-
-core::style::Color *FltkPlatform::createShadedColor (int color)
+core::style::Color *FltkPlatform::createColor (int color)
{
- return FltkColor::create (color, core::style::Color::TYPE_SHADED);
+ return FltkColor::create (color);
}
void FltkPlatform::copySelection(const char *text)
diff --git a/dw/fltkplatform.hh b/dw/fltkplatform.hh
index 7b3d3e73..e4600516 100644
--- a/dw/fltkplatform.hh
+++ b/dw/fltkplatform.hh
@@ -34,13 +34,13 @@ class FltkColor: public core::style::Color
static lout::container::typed::HashTable <dw::core::style::ColorAttrs,
FltkColor> *colorsTable;
- FltkColor (int color, core::style::Color::Type type);
+ FltkColor (int color);
~FltkColor ();
public:
int colors[SHADING_NUM];
- static FltkColor *create(int color, core::style::Color::Type type);
+ static FltkColor *create(int color);
};
@@ -125,14 +125,15 @@ public:
int textWidth (core::style::Font *font, const char *text, int len);
int nextGlyph (const char *text, int idx);
int prevGlyph (const char *text, int idx);
+ float dpiX ();
+ float dpiY ();
int addIdle (void (core::Layout::*func) ());
void removeIdle (int idleId);
core::style::Font *createFont (core::style::FontAttrs *attrs,
bool tryEverything);
- core::style::Color *createSimpleColor (int color);
- core::style::Color *createShadedColor (int color);
+ core::style::Color *createColor (int color);
core::Imgbuf *createImgbuf (core::Imgbuf::Type type, int width, int height);
diff --git a/dw/layout.hh b/dw/layout.hh
index 13b8f312..ce9786f1 100644
--- a/dw/layout.hh
+++ b/dw/layout.hh
@@ -216,19 +216,24 @@ public:
return platform->prevGlyph (text, idx);
}
- inline style::Font *createFont (style::FontAttrs *attrs, bool tryEverything)
+ inline float dpiX ()
{
- return platform->createFont (attrs, tryEverything);
+ return platform->dpiX ();
}
- inline style::Color *createSimpleColor (int color)
+ inline float dpiY ()
{
- return platform->createSimpleColor (color);
+ return platform->dpiY ();
+ }
+
+ inline style::Font *createFont (style::FontAttrs *attrs, bool tryEverything)
+ {
+ return platform->createFont (attrs, tryEverything);
}
- inline style::Color *createShadedColor (int color)
+ inline style::Color *createColor (int color)
{
- return platform->createShadedColor (color);
+ return platform->createColor (color);
}
inline Imgbuf *createImgbuf (Imgbuf::Type type, int width, int height)
diff --git a/dw/platform.hh b/dw/platform.hh
index 0ae5d508..156a602a 100644
--- a/dw/platform.hh
+++ b/dw/platform.hh
@@ -66,6 +66,16 @@ public:
* \brief Return the index of the previous glyph in string text.
*/
virtual int prevGlyph (const char *text, int idx) = 0;
+
+ /**
+ * \brief Return screen resolution in x-direction.
+ */
+ virtual float dpiX () = 0;
+
+ /**
+ * \brief Return screen resolution in y-direction.
+ */
+ virtual float dpiY () = 0;
/*
* ---------------------------------------------------------
@@ -110,15 +120,9 @@ public:
bool tryEverything) = 0;
/**
- * \brief Create a simple color resource for a given 0xrrggbb value.
+ * \brief Create a color resource for a given 0xrrggbb value.
*/
- virtual style::Color *createSimpleColor (int color) = 0;
-
- /**
- * \brief Create a shaded color resource for a given 0xrrggbb value.
- */
- virtual style::Color *createShadedColor (int color) = 0;
-
+ virtual style::Color *createColor (int color) = 0;
/*
* --------------------
diff --git a/dw/style.cc b/dw/style.cc
index 52092593..106f2592 100644
--- a/dw/style.cc
+++ b/dw/style.cc
@@ -64,11 +64,9 @@ void StyleAttrs::initValues ()
*/
void StyleAttrs::resetValues ()
{
- x_link = -1;
x_img = -1;
x_tooltip = NULL;
- textAlign = TEXT_ALIGN_LEFT; /* ??? */
valign = VALIGN_MIDDLE;
textAlignChar = '.';
backgroundColor = NULL;
@@ -84,8 +82,6 @@ void StyleAttrs::resetValues ()
vBorderSpacing = 0;
display = DISPLAY_INLINE;
- whiteSpace = WHITE_SPACE_NORMAL;
- cursor = CURSOR_DEFAULT; /** \todo Check CSS specification again. */
}
/**
@@ -338,12 +334,12 @@ Font *Font::createFromList (Layout *layout, FontAttrs *attrs,
bool ColorAttrs::equals(object::Object *other)
{
ColorAttrs *oc = (ColorAttrs*)other;
- return this == oc || (color == oc->color && type == oc->type);
+ return this == oc || (color == oc->color);
}
int ColorAttrs::hashValue()
{
- return color ^ type;
+ return color;
}
Color::~Color ()
@@ -407,21 +403,11 @@ int Color::shadeColor (int color, Shading shading)
}
-Color *Color::create (Layout *layout, int col, Type type)
+Color *Color::create (Layout *layout, int col)
{
- ColorAttrs attrs(col, type);
- Color *color = NULL;
+ ColorAttrs attrs(col);
- switch (type) {
- case TYPE_SIMPLE:
- color = layout->createSimpleColor (col);
- break;
- case TYPE_SHADED:
- color = layout->createShadedColor (col);
- break;
- }
-
- return color;
+ return layout->createColor (col);
}
// ----------------------------------------------------------------------
@@ -488,9 +474,6 @@ void drawBorder (View *view, Rectangle *area,
Color::Shading top, right, bottom, left;
int xb1, yb1, xb2, yb2, xp1, yp1, xp2, yp2;
- if (style->borderStyle.top == BORDER_NONE)
- return;
-
xb1 = x + style->margin.left;
yb1 = y + style->margin.top;
xb2 = xb1 + width - style->margin.left - style->margin.right;
@@ -521,18 +504,25 @@ void drawBorder (View *view, Rectangle *area,
break;
}
- drawPolygon (view, style->borderColor.top, top, xb1, yb1, xb2, yb1,
- style->borderWidth.top, style->borderWidth.left,
- - style->borderWidth.right);
- drawPolygon (view, style->borderColor.right, right, xb2, yb1, xb2, yb2,
- - style->borderWidth.right, style->borderWidth.top,
- - style->borderWidth.bottom);
- drawPolygon (view, style->borderColor.bottom, bottom, xb1, yb2, xb2, yb2,
- - style->borderWidth.bottom, style->borderWidth.left,
- - style->borderWidth.right);
- drawPolygon (view, style->borderColor.left, left, xb1, yb1, xb1, yb2,
- style->borderWidth.left, style->borderWidth.top,
- - style->borderWidth.bottom);
+ if (style->borderStyle.top != BORDER_NONE && style->borderColor.top)
+ drawPolygon (view, style->borderColor.top, top, xb1, yb1, xb2, yb1,
+ style->borderWidth.top, style->borderWidth.left,
+ - style->borderWidth.right);
+
+ if (style->borderStyle.right != BORDER_NONE && style->borderColor.right)
+ drawPolygon (view, style->borderColor.right, right, xb2, yb1, xb2, yb2,
+ - style->borderWidth.right, style->borderWidth.top,
+ - style->borderWidth.bottom);
+
+ if (style->borderStyle.bottom != BORDER_NONE && style->borderColor.bottom)
+ drawPolygon (view, style->borderColor.bottom, bottom, xb1, yb2, xb2, yb2,
+ - style->borderWidth.bottom, style->borderWidth.left,
+ - style->borderWidth.right);
+
+ if (style->borderStyle.left != BORDER_NONE && style->borderColor.left)
+ drawPolygon (view, style->borderColor.left, left, xb1, yb1, xb1, yb2,
+ style->borderWidth.left, style->borderWidth.top,
+ - style->borderWidth.bottom);
}
diff --git a/dw/style.hh b/dw/style.hh
index 0dd7fbd4..9e6672bb 100644
--- a/dw/style.hh
+++ b/dw/style.hh
@@ -591,22 +591,16 @@ public:
*/
class ColorAttrs: public object::Object
{
-public:
- enum Type { TYPE_SIMPLE, TYPE_SHADED };
-
protected:
int color;
- Type type;
public:
- inline ColorAttrs(int color, Type type)
+ inline ColorAttrs(int color)
{
this->color = color;
- this->type = type;
}
inline int getColor () { return color; }
- inline Type getType () { return type; }
bool equals(object::Object *other);
int hashValue();
@@ -621,12 +615,11 @@ class Color: public ColorAttrs
private:
int refCount;
- static Color *create (Layout *layout, int color, Type type);
void remove(dw::core::Layout *layout);
- int shadeColor (int color, int d);
+ int shadeColor (int color, int d);
protected:
- inline Color (int color, Type type): ColorAttrs (color, type) {
+ inline Color (int color): ColorAttrs (color) {
refCount = 0; }
virtual ~Color ();
@@ -638,15 +631,7 @@ protected:
int shadeColor (int color, Shading shading);
public:
- inline static Color *createSimple (Layout *layout, int color)
- {
- return create (layout, color, TYPE_SIMPLE);
- }
-
- inline static Color *createShaded (Layout *layout, int color)
- {
- return create (layout, color, TYPE_SHADED);
- }
+ static Color *create (Layout *layout, int color);
inline void ref () { refCount++; }
inline void unref ()
diff --git a/dw/textblock.cc b/dw/textblock.cc
index d80a7ad4..2f5c66ae 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -1077,8 +1077,8 @@ void Textblock::calcWidgetSize (core::Widget *widget, core::Requisition *size)
widget->setAscent (availAscent);
widget->setDescent (availDescent);
widget->sizeRequest (size);
- size->ascent -= widget->getStyle()->margin.top;
- size->descent -= widget->getStyle()->margin.bottom;
+// size->ascent -= widget->getStyle()->margin.top;
+// size->descent -= widget->getStyle()->margin.bottom;
} else {
/* TODO: Use margin.{top|bottom} here, like above.
* (No harm for the next future.) */
@@ -1921,14 +1921,14 @@ void Textblock::changeLinkColor (int link, int newColor)
case core::Content::TEXT:
{ core::style::Style *old_style = word->style;
styleAttrs = *old_style;
- styleAttrs.color = core::style::Color::createSimple (layout,
- newColor);
+ styleAttrs.color = core::style::Color::create (layout,
+ newColor);
word->style = core::style::Style::create (layout, &styleAttrs);
old_style->unref();
old_style = word->spaceStyle;
styleAttrs = *old_style;
- styleAttrs.color = core::style::Color::createSimple (layout,
- newColor);
+ styleAttrs.color = core::style::Color::create (layout,
+ newColor);
word->spaceStyle =
core::style::Style::create(layout, &styleAttrs);
old_style->unref();
@@ -1937,10 +1937,10 @@ void Textblock::changeLinkColor (int link, int newColor)
case core::Content::WIDGET:
{ core::Widget *widget = word->content.widget;
styleAttrs = *widget->getStyle();
- styleAttrs.color = core::style::Color::createSimple (layout,
- newColor);
+ styleAttrs.color = core::style::Color::create (layout,
+ newColor);
styleAttrs.setBorderColor(
- core::style::Color::createShaded(layout, newColor));
+ core::style::Color::create (layout, newColor));
widget->setStyle(
core::style::Style::create (layout, &styleAttrs));
break;