signed ints instead of unsigned ints again. less pain. pain bad.

This commit is contained in:
Dana Jansens 2003-02-09 22:40:47 +00:00
parent 9e05db9518
commit 74cfb1b4c1
15 changed files with 114 additions and 125 deletions

View file

@ -71,11 +71,12 @@ void Label::setFont(const Font *f)
void Label::calcDefaultSizes() void Label::calcDefaultSizes()
{ {
unsigned int longest = 0; int longest = 0;
// find the longest line // find the longest line
std::vector<ustring>::iterator it, end = _parsedtext.end(); std::vector<ustring>::iterator it, end = _parsedtext.end();
for (it = _parsedtext.begin(); it != end; ++it) { for (it = _parsedtext.begin(); it != end; ++it) {
unsigned int length = _font->measureString(*it); int length = _font->measureString(*it);
if (length < 0) continue; // lines too long get skipped
if (length > longest) longest = length; if (length > longest) longest = length;
} }
setMinSize(Size(longest + borderWidth() * 2 + bevel() * 4, setMinSize(Size(longest + borderWidth() * 2 + bevel() * 4,
@ -101,10 +102,10 @@ void Label::styleChanged(const RenderStyle &style)
void Label::renderForeground(Surface &surface) void Label::renderForeground(Surface &surface)
{ {
const RenderControl *control = display->renderControl(screen()); const RenderControl *control = display->renderControl(screen());
unsigned int sidemargin = bevel() * 2; int sidemargin = bevel() * 2;
int y = bevel(); int y = bevel();
unsigned int w = area().width() - borderWidth() * 2 - sidemargin * 2; int w = area().width() - borderWidth() * 2 - sidemargin * 2;
unsigned int h = area().height() - borderWidth() * 2 - bevel() * 2; int h = area().height() - borderWidth() * 2 - bevel() * 2;
switch (_justify_vert) { switch (_justify_vert) {
case RenderStyle::RightBottomJustify: case RenderStyle::RightBottomJustify:
@ -128,12 +129,13 @@ void Label::renderForeground(Surface &surface)
// find a string that will fit inside the area for text // find a string that will fit inside the area for text
ustring::size_type text_len = t.size(); ustring::size_type text_len = t.size();
unsigned int length; int length;
do { do {
t.resize(text_len); t.resize(text_len);
length = _font->measureString(t); length = _font->measureString(t);
} while (length > w && text_len-- > 0); } while (length > w && text_len-- > 0);
if (length < 0) continue; // lines too long get skipped
if (text_len <= 0) continue; // won't fit anything if (text_len <= 0) continue; // won't fit anything

View file

@ -14,13 +14,13 @@ public:
Rect() : _p(), _s() {} Rect() : _p(), _s() {}
Rect(const Point &p, const Size &s) : _p(p), _s(s) {} Rect(const Point &p, const Size &s) : _p(p), _s(s) {}
Rect(const Rect &r) : _p(r._p), _s(r._s) {} Rect(const Rect &r) : _p(r._p), _s(r._s) {}
Rect(int x, int y, unsigned int w, unsigned int h) Rect(int x, int y, int w, int h)
: _p(x, y), _s(w, h) {} : _p(x, y), _s(w, h) {}
inline int x() const { return _p.x(); } inline int x() const { return _p.x(); }
inline int y() const { return _p.y(); } inline int y() const { return _p.y(); }
inline unsigned int width() const { return _s.width(); } inline int width() const { return _s.width(); }
inline unsigned int height() const { return _s.height(); } inline int height() const { return _s.height(); }
inline int left() const { return _p.x(); } inline int left() const { return _p.x(); }
inline int top() const { return _p.y(); } inline int top() const { return _p.y(); }

View file

@ -56,8 +56,8 @@ RenderStyle::RenderStyle(int screen, const std::string &stylefile)
_file(stylefile) _file(stylefile)
{ {
// pick one.. // pick one..
#define FIERON //#define FIERON
//#define MERRY #define MERRY
#ifdef FIERON #ifdef FIERON
_root_color = new RenderColor(_screen, 0x272a2f); _root_color = new RenderColor(_screen, 0x272a2f);

View file

@ -17,7 +17,9 @@ using std::string;
namespace otk { namespace otk {
ScreenInfo::ScreenInfo(unsigned int num) { ScreenInfo::ScreenInfo(int num) {
assert(num >= 0 && num < ScreenCount(**display));
_screen = num; _screen = num;
_root_window = RootWindow(**display, _screen); _root_window = RootWindow(**display, _screen);

View file

@ -21,7 +21,7 @@ private:
Colormap _colormap; Colormap _colormap;
int _depth; int _depth;
unsigned int _screen; int _screen;
std::string _display_string; std::string _display_string;
Size _size; Size _size;
#ifdef XINERAMA #ifdef XINERAMA
@ -30,13 +30,13 @@ private:
#endif #endif
public: public:
ScreenInfo(unsigned int num); ScreenInfo(int num);
inline Visual *visual() const { return _visual; } inline Visual *visual() const { return _visual; }
inline Window rootWindow() const { return _root_window; } inline Window rootWindow() const { return _root_window; }
inline Colormap colormap() const { return _colormap; } inline Colormap colormap() const { return _colormap; }
inline int depth() const { return _depth; } inline int depth() const { return _depth; }
inline unsigned int screen() const { return _screen; } inline int screen() const { return _screen; }
inline const Size& size() const { return _size; } inline const Size& size() const { return _size; }
inline const std::string& displayString() const { return _display_string; } inline const std::string& displayString() const { return _display_string; }
#ifdef XINERAMA #ifdef XINERAMA

View file

@ -2,17 +2,19 @@
#ifndef __size_hh #ifndef __size_hh
#define __size_hh #define __size_hh
#include <cassert>
namespace otk { namespace otk {
class Size { class Size {
unsigned int _w, _h; int _w, _h;
public: public:
Size() : _w(1), _h(1) {} Size() : _w(1), _h(1) {}
Size(unsigned int w, unsigned int h) : _w(w), _h(h) {} Size(int w, int h) : _w(w), _h(h) { assert(_w >= 0 && _h >= 0); }
Size(const Size &s) : _w(s._w), _h(s._h) {} Size(const Size &s) : _w(s._w), _h(s._h) { assert(_w >= 0 && _h >= 0); }
inline unsigned int width() const { return _w; } inline int width() const { return _w; }
inline unsigned int height() const { return _h; } inline int height() const { return _h; }
bool operator==(const Size &o) const { return _w == o._w && _h == o._h; } bool operator==(const Size &o) const { return _w == o._w && _h == o._h; }
bool operator!=(const Size &o) const { return _w != o._w || _h != o._h; } bool operator!=(const Size &o) const { return _w != o._w || _h != o._h; }

View file

@ -39,8 +39,8 @@ void Surface::setPixmap(const RenderColor &color)
void Surface::setPixmap(XImage *image) void Surface::setPixmap(XImage *image)
{ {
assert((unsigned)image->width == _size.width()); assert(image->width == _size.width());
assert((unsigned)image->height == _size.height()); assert(image->height == _size.height());
if (_pixmap == None) if (_pixmap == None)
createObjects(); createObjects();

View file

@ -59,8 +59,8 @@ void TrueRenderControl::drawGradientBackground(
Surface &sf, const RenderTexture &texture) const Surface &sf, const RenderTexture &texture) const
{ {
unsigned int r,g,b; unsigned int r,g,b;
unsigned int w = sf.size().width(), h = sf.size().height(); int w = sf.size().width(), h = sf.size().height();
unsigned int off, x; int off, x;
const ScreenInfo *info = display->screenInfo(_screen); const ScreenInfo *info = display->screenInfo(_screen);
XImage *im = XCreateImage(**display, info->visual(), info->depth(), XImage *im = XCreateImage(**display, info->visual(), info->depth(),
@ -102,29 +102,25 @@ void TrueRenderControl::drawGradientBackground(
if (texture.relief() != RenderTexture::Flat) { if (texture.relief() != RenderTexture::Flat) {
if (texture.bevel() == RenderTexture::Bevel1) { if (texture.bevel() == RenderTexture::Bevel1) {
if (w >= 1 && h >= 1) { for (off = 1, x = 1; x < w - 1; ++x, off++)
for (off = 1, x = 1; x < w - 1; ++x, off++) highlight(data + off,
highlight(data + off, data + off + (h-1) * w,
data + off + (h-1) * w, texture.relief()==RenderTexture::Raised);
texture.relief()==RenderTexture::Raised); for (off = 0, x = 0; x < h; ++x, off++)
for (off = 0, x = 0; x < h; ++x, off++) highlight(data + off * w,
highlight(data + off * w, data + off * w + w - 1,
data + off * w + w - 1, texture.relief()==RenderTexture::Raised);
texture.relief()==RenderTexture::Raised);
}
} }
if (texture.bevel() == RenderTexture::Bevel2) { if (texture.bevel() == RenderTexture::Bevel2) {
if (w >= 2 && h >= 2) { for (off = 2, x = 2; x < w - 2; ++x, off++)
for (off = 2, x = 2; x < w - 2; ++x, off++) highlight(data + off + w,
highlight(data + off + w, data + off + (h-2) * w,
data + off + (h-2) * w, texture.relief()==RenderTexture::Raised);
texture.relief()==RenderTexture::Raised); for (off = 1, x = 1; x < h-1; ++x, off++)
for (off = 1, x = 1; x < h-1; ++x, off++) highlight(data + off * w + 1,
highlight(data + off * w + 1, data + off * w + w - 2,
data + off * w + w - 2, texture.relief()==RenderTexture::Raised);
texture.relief()==RenderTexture::Raised);
}
} }
} }
@ -146,7 +142,7 @@ void TrueRenderControl::verticalGradient(Surface &sf,
pixel32 current; pixel32 current;
float dr, dg, db; float dr, dg, db;
unsigned int r,g,b; unsigned int r,g,b;
unsigned int w = sf.size().width(), h = sf.size().height(); int w = sf.size().width(), h = sf.size().height();
dr = (float)(texture.secondary_color().red() - texture.color().red()); dr = (float)(texture.secondary_color().red() - texture.color().red());
dr/= (float)h; dr/= (float)h;
@ -157,14 +153,14 @@ void TrueRenderControl::verticalGradient(Surface &sf,
db = (float)(texture.secondary_color().blue() - texture.color().blue()); db = (float)(texture.secondary_color().blue() - texture.color().blue());
db/= (float)h; db/= (float)h;
for (unsigned int y = 0; y < h; ++y) { for (int y = 0; y < h; ++y) {
r = texture.color().red() + (int)(dr * y); r = texture.color().red() + (int)(dr * y);
g = texture.color().green() + (int)(dg * y); g = texture.color().green() + (int)(dg * y);
b = texture.color().blue() + (int)(db * y); b = texture.color().blue() + (int)(db * y);
current = (r << default_red_shift) current = (r << default_red_shift)
+ (g << default_green_shift) + (g << default_green_shift)
+ (b << default_blue_shift); + (b << default_blue_shift);
for (unsigned int x = 0; x < w; ++x, ++data) for (int x = 0; x < w; ++x, ++data)
*data = current; *data = current;
} }
} }
@ -176,9 +172,9 @@ void TrueRenderControl::diagonalGradient(Surface &sf,
pixel32 current; pixel32 current;
float drx, dgx, dbx, dry, dgy, dby; float drx, dgx, dbx, dry, dgy, dby;
unsigned int r,g,b; unsigned int r,g,b;
unsigned int w = sf.size().width(), h = sf.size().height(); int w = sf.size().width(), h = sf.size().height();
for (unsigned int y = 0; y < h; ++y) { for (int y = 0; y < h; ++y) {
drx = (float)(texture.secondary_color().red() - texture.color().red()); drx = (float)(texture.secondary_color().red() - texture.color().red());
dry = drx/(float)h; dry = drx/(float)h;
drx/= (float)w; drx/= (float)w;
@ -190,7 +186,7 @@ void TrueRenderControl::diagonalGradient(Surface &sf,
dbx = (float)(texture.secondary_color().blue() - texture.color().blue()); dbx = (float)(texture.secondary_color().blue() - texture.color().blue());
dby = dbx/(float)h; dby = dbx/(float)h;
dbx/= (float)w; dbx/= (float)w;
for (unsigned int x = 0; x < w; ++x, ++data) { for (int x = 0; x < w; ++x, ++data) {
r = texture.color().red() + ((int)(drx * x) + (int)(dry * y))/2; r = texture.color().red() + ((int)(drx * x) + (int)(dry * y))/2;
g = texture.color().green() + ((int)(dgx * x) + (int)(dgy * y))/2; g = texture.color().green() + ((int)(dgx * x) + (int)(dgy * y))/2;
b = texture.color().blue() + ((int)(dbx * x) + (int)(dby * y))/2; b = texture.color().blue() + ((int)(dbx * x) + (int)(dby * y))/2;
@ -209,9 +205,9 @@ void TrueRenderControl::crossDiagonalGradient(Surface &sf,
pixel32 current; pixel32 current;
float drx, dgx, dbx, dry, dgy, dby; float drx, dgx, dbx, dry, dgy, dby;
unsigned int r,g,b; unsigned int r,g,b;
unsigned int w = sf.size().width(), h = sf.size().height(); int w = sf.size().width(), h = sf.size().height();
for (unsigned int y = 0; y < h; ++y) { for (int y = 0; y < h; ++y) {
drx = (float)(texture.secondary_color().red() - texture.color().red()); drx = (float)(texture.secondary_color().red() - texture.color().red());
dry = drx/(float)h; dry = drx/(float)h;
drx/= (float)w; drx/= (float)w;

View file

@ -26,7 +26,7 @@ Widget::Widget(int screen, EventDispatcher *ed, Direction direction, int bevel,
ExposureMask | StructureNotifyMask), ExposureMask | StructureNotifyMask),
_alignment(RenderStyle::CenterJustify), _alignment(RenderStyle::CenterJustify),
_direction(direction), _direction(direction),
_max_size(UINT_MAX, UINT_MAX), _max_size(INT_MAX, INT_MAX),
_visible(false), _visible(false),
_bordercolor(0), _bordercolor(0),
_borderwidth(0), _borderwidth(0),
@ -49,7 +49,7 @@ Widget::Widget(Widget *parent, Direction direction, int bevel)
ExposureMask | StructureNotifyMask), ExposureMask | StructureNotifyMask),
_alignment(RenderStyle::CenterJustify), _alignment(RenderStyle::CenterJustify),
_direction(direction), _direction(direction),
_max_size(UINT_MAX, UINT_MAX), _max_size(INT_MAX, INT_MAX),
_visible(false), _visible(false),
_bordercolor(0), _bordercolor(0),
_borderwidth(0), _borderwidth(0),
@ -120,7 +120,7 @@ void Widget::update()
void Widget::moveresize(const Rect &r) void Widget::moveresize(const Rect &r)
{ {
unsigned int w, h; int w, h;
w = std::min(std::max(r.width(), minSize().width()), maxSize().width()); w = std::min(std::max(r.width(), minSize().width()), maxSize().width());
h = std::min(std::max(r.height(), minSize().height()), maxSize().height()); h = std::min(std::max(r.height(), minSize().height()), maxSize().height());
@ -134,7 +134,7 @@ void Widget::moveresize(const Rect &r)
update(); update();
} }
void Widget::internal_moveresize(int x, int y, unsigned w, unsigned int h) void Widget::internal_moveresize(int x, int y, int w, int h)
{ {
assert(w > 0); assert(w > 0);
assert(h > 0); assert(h > 0);
@ -248,18 +248,15 @@ void Widget::layoutHorz()
if (visible.empty()) return; if (visible.empty()) return;
if ((unsigned)(_borderwidth * 2 + _bevel * 2) > _area.width() || int x, y, w, h; // working area
(unsigned)(_borderwidth * 2 + _bevel * 2) > _area.height())
return; // not worth laying anything out!
int x, y; unsigned int w, h; // working area
x = y = _bevel; x = y = _bevel;
w = _area.width() - _borderwidth * 2 - _bevel * 2; w = _area.width() - _borderwidth * 2 - _bevel * 2;
h = _area.height() - _borderwidth * 2 - _bevel * 2; h = _area.height() - _borderwidth * 2 - _bevel * 2;
if (w < 0 || h < 0) return; // not worth laying anything out!
int free = w - (visible.size() - 1) * _bevel; int free = w - (visible.size() - 1) * _bevel;
if (free < 0) free = 0; if (free < 0) free = 0;
unsigned int each; int each;
std::list<Widget*> adjustable = visible; std::list<Widget*> adjustable = visible;
@ -279,7 +276,7 @@ void Widget::layoutHorz()
each = free / adjustable.size(); each = free / adjustable.size();
for (it = adjustable.begin(), end = adjustable.end(); it != end;) { for (it = adjustable.begin(), end = adjustable.end(); it != end;) {
std::list<Widget*>::iterator next = it; ++next; std::list<Widget*>::iterator next = it; ++next;
unsigned int m = (*it)->maxSize().width() - (*it)->minSize().width(); int m = (*it)->maxSize().width() - (*it)->minSize().width();
if (m > 0 && m < each) { if (m > 0 && m < each) {
free -= m; free -= m;
if (free < 0) free = 0; if (free < 0) free = 0;
@ -298,7 +295,7 @@ void Widget::layoutHorz()
else else
each = 0; each = 0;
for (it = visible.begin(), end = visible.end(); it != end; ++it) { for (it = visible.begin(), end = visible.end(); it != end; ++it) {
unsigned int w; int w;
// is the widget adjustable? // is the widget adjustable?
std::list<Widget*>::const_iterator std::list<Widget*>::const_iterator
found = std::find(adjustable.begin(), adjustable.end(), *it); found = std::find(adjustable.begin(), adjustable.end(), *it);
@ -311,8 +308,8 @@ void Widget::layoutHorz()
} }
// align it vertically // align it vertically
int yy = y; int yy = y;
unsigned int hh = std::max(std::min(h, (*it)->_max_size.height()), int hh = std::max(std::min(h, (*it)->_max_size.height()),
(*it)->_min_size.height()); (*it)->_min_size.height());
if (hh < h) { if (hh < h) {
switch(_alignment) { switch(_alignment) {
case RenderStyle::RightBottomJustify: case RenderStyle::RightBottomJustify:
@ -347,18 +344,15 @@ void Widget::layoutVert()
if (visible.empty()) return; if (visible.empty()) return;
if ((unsigned)(_borderwidth * 2 + _bevel * 2) > _area.width() || int x, y, w, h; // working area
(unsigned)(_borderwidth * 2 + _bevel * 2) > _area.height())
return; // not worth laying anything out!
int x, y; unsigned int w, h; // working area
x = y = _bevel; x = y = _bevel;
w = _area.width() - _borderwidth * 2 - _bevel * 2; w = _area.width() - _borderwidth * 2 - _bevel * 2;
h = _area.height() - _borderwidth * 2 - _bevel * 2; h = _area.height() - _borderwidth * 2 - _bevel * 2;
if (w < 0 || h < 0) return; // not worth laying anything out!
int free = h - (visible.size() - 1) * _bevel; int free = h - (visible.size() - 1) * _bevel;
if (free < 0) free = 0; if (free < 0) free = 0;
unsigned int each; int each;
std::list<Widget*> adjustable = visible; std::list<Widget*> adjustable = visible;
@ -378,7 +372,7 @@ void Widget::layoutVert()
each = free / adjustable.size(); each = free / adjustable.size();
for (it = adjustable.begin(), end = adjustable.end(); it != end;) { for (it = adjustable.begin(), end = adjustable.end(); it != end;) {
std::list<Widget*>::iterator next = it; ++next; std::list<Widget*>::iterator next = it; ++next;
unsigned int m = (*it)->maxSize().height() - (*it)->minSize().height(); int m = (*it)->maxSize().height() - (*it)->minSize().height();
if (m > 0 && m < each) { if (m > 0 && m < each) {
free -= m; free -= m;
if (free < 0) free = 0; if (free < 0) free = 0;
@ -397,7 +391,7 @@ void Widget::layoutVert()
else else
each = 0; each = 0;
for (it = visible.begin(), end = visible.end(); it != end; ++it) { for (it = visible.begin(), end = visible.end(); it != end; ++it) {
unsigned int h; int h;
// is the widget adjustable? // is the widget adjustable?
std::list<Widget*>::const_iterator std::list<Widget*>::const_iterator
found = std::find(adjustable.begin(), adjustable.end(), *it); found = std::find(adjustable.begin(), adjustable.end(), *it);
@ -410,8 +404,8 @@ void Widget::layoutVert()
} }
// align it horizontally // align it horizontally
int xx = x; int xx = x;
unsigned int ww = std::max(std::min(w, (*it)->_max_size.width()), int ww = std::max(std::min(w, (*it)->_max_size.width()),
(*it)->_min_size.width()); (*it)->_min_size.width());
if (ww < w) { if (ww < w) {
switch(_alignment) { switch(_alignment) {
case RenderStyle::RightBottomJustify: case RenderStyle::RightBottomJustify:
@ -434,8 +428,8 @@ void Widget::layoutVert()
void Widget::render() void Widget::render()
{ {
if (!_texture || !_dirty) return; if (!_texture || !_dirty) return;
if ((unsigned)_borderwidth * 2 > _area.width() || if (_borderwidth * 2 > _area.width() ||
(unsigned)_borderwidth * 2 > _area.height()) _borderwidth * 2 > _area.height())
return; // no surface to draw on return; // no surface to draw on
Surface *s = new Surface(_screen, Size(_area.width() - _borderwidth * 2, Surface *s = new Surface(_screen, Size(_area.width() - _borderwidth * 2,
@ -481,8 +475,8 @@ void Widget::configureHandler(const XConfigureEvent &e)
ev.xconfigure.height = e.height; ev.xconfigure.height = e.height;
while (XCheckTypedWindowEvent(**display, window(), ConfigureNotify, &ev)); while (XCheckTypedWindowEvent(**display, window(), ConfigureNotify, &ev));
if (!((unsigned)ev.xconfigure.width == area().width() && if (!(ev.xconfigure.width == area().width() &&
(unsigned)ev.xconfigure.height == area().height())) { ev.xconfigure.height == area().height())) {
_area = Rect(_area.position(), Size(e.width, e.height)); _area = Rect(_area.position(), Size(e.width, e.height));
update(); update();
} }

View file

@ -102,7 +102,7 @@ protected:
RenderTexture *_texture; RenderTexture *_texture;
private: private:
void internal_moveresize(int x, int y, unsigned w, unsigned int h); void internal_moveresize(int x, int y, int w, int h);
int _screen; int _screen;
Widget *_parent; Widget *_parent;

View file

@ -214,8 +214,6 @@ def _do_resize():
w = _cw + dx w = _cw + dx
h = _ch + dy h = _ch + dy
if w < 0: w = 0
if h < 0: h = 0
if RESIZE_RUBBERBAND: if RESIZE_RUBBERBAND:
# draw the outline ... # draw the outline ...

View file

@ -480,7 +480,7 @@ void Client::updateNormalHints()
_size_inc = otk::Size(1, 1); _size_inc = otk::Size(1, 1);
_base_size = otk::Size(0, 0); _base_size = otk::Size(0, 0);
_min_size = otk::Size(0, 0); _min_size = otk::Size(0, 0);
_max_size = otk::Size(UINT_MAX, UINT_MAX); _max_size = otk::Size(INT_MAX, INT_MAX);
// get the hints from the window // get the hints from the window
if (XGetWMNormalHints(**otk::display, _window, &size, &ret)) { if (XGetWMNormalHints(**otk::display, _window, &size, &ret)) {
@ -833,6 +833,7 @@ void Client::setModal(bool modal)
while (c->_transient_for) // go up the tree while (c->_transient_for) // go up the tree
c = c->_transient_for; c = c->_transient_for;
replacement = c->findModalChild(this); // find a modal child, skipping this replacement = c->findModalChild(this); // find a modal child, skipping this
assert(replacement != this);
c = this; c = this;
while (c->_transient_for) { while (c->_transient_for) {
@ -1120,33 +1121,26 @@ void Client::shapeHandler(const XShapeEvent &e)
#endif #endif
void Client::resize(Corner anchor, unsigned int w, unsigned int h) void Client::resize(Corner anchor, int w, int h)
{ {
if (!(_functions & Func_Resize)) return; if (!(_functions & Func_Resize)) return;
internal_resize(anchor, w, h); internal_resize(anchor, w, h);
} }
void Client::internal_resize(Corner anchor, unsigned int w, unsigned int h, void Client::internal_resize(Corner anchor, int w, int h,
bool user, int x, int y) bool user, int x, int y)
{ {
if (_base_size.width() < w) w -= _base_size.width();
w -= _base_size.width(); h -= _base_size.height();
else
w = 0;
if (_base_size.height() < h)
h -= _base_size.height();
else
h = 0;
if (user) { if (user) {
// for interactive resizing. have to move half an increment in each // for interactive resizing. have to move half an increment in each
// direction. // direction.
unsigned int mw = w % _size_inc.width(); // how far we are towards the next int mw = w % _size_inc.width(); // how far we are towards the next size inc
// size inc int mh = h % _size_inc.height();
unsigned int mh = h % _size_inc.height(); int aw = _size_inc.width() / 2; // amount to add
unsigned int aw = _size_inc.width() / 2; // amount to add int ah = _size_inc.height() / 2;
unsigned int ah = _size_inc.height() / 2;
// don't let us move into a new size increment // don't let us move into a new size increment
if (mw + aw >= _size_inc.width()) aw = _size_inc.width() - mw - 1; if (mw + aw >= _size_inc.width()) aw = _size_inc.width() - mw - 1;
if (mh + ah >= _size_inc.height()) ah = _size_inc.height() - mh - 1; if (mh + ah >= _size_inc.height()) ah = _size_inc.height() - mh - 1;

View file

@ -479,7 +479,7 @@ private:
The x and y coordinates must both be sepcified together, or they will have The x and y coordinates must both be sepcified together, or they will have
no effect. When they are specified, the anchor is ignored. no effect. When they are specified, the anchor is ignored.
*/ */
void internal_resize(Corner anchor, unsigned int w, unsigned int h, void internal_resize(Corner anchor, int w, int h,
bool user = true, int x = INT_MIN, int y = INT_MIN); bool user = true, int x = INT_MIN, int y = INT_MIN);
//! Attempts to find and return a modal child of this window, recursively. //! Attempts to find and return a modal child of this window, recursively.
@ -651,7 +651,7 @@ BB @param window The window id that the Client class should handle
@param w The width component of the new size for the client. @param w The width component of the new size for the client.
@param h The height component of the new size for the client. @param h The height component of the new size for the client.
*/ */
void resize(Corner anchor, unsigned int w, unsigned int h); void resize(Corner anchor, int w, int h);
//! Reapplies the maximized state to the window //! Reapplies the maximized state to the window
/*! /*!

View file

@ -88,8 +88,8 @@ Frame::Frame(Client *client)
_numbuttons = 0; _numbuttons = 0;
_buttons = new Window[0]; _buttons = new Window[0];
_buttons_sur = new otk::Surface*[0]; _buttons_sur = new otk::Surface*[0];
_titleorder = new unsigned int[1]; _titleorder = new int[1];
_titleorder[0] = (unsigned)-1; _titleorder[0] = -1;
// register all of the windows with the event dispatcher // register all of the windows with the event dispatcher
Window *w = allWindows(); Window *w = allWindows();
@ -106,7 +106,7 @@ Frame::~Frame()
openbox->clearHandler(w[i]); openbox->clearHandler(w[i]);
delete [] w; delete [] w;
for (unsigned int i = 0; i < _numbuttons; ++i) { for (int i = 0; i < _numbuttons; ++i) {
XDestroyWindow(**otk::display, _buttons[i]); XDestroyWindow(**otk::display, _buttons[i]);
delete _buttons_sur[i]; delete _buttons_sur[i];
} }
@ -167,7 +167,7 @@ Window *Frame::allWindows() const
w[i++] = _handle; w[i++] = _handle;
w[i++] = _lgrip; w[i++] = _lgrip;
w[i++] = _rgrip; w[i++] = _rgrip;
for (unsigned int j = 0; j < _numbuttons; ++j) for (int j = 0; j < _numbuttons; ++j)
w[j + i++] = _buttons[j]; w[j + i++] = _buttons[j];
w[i] = 0; w[i] = 0;
return w; return w;
@ -194,7 +194,7 @@ void Frame::applyStyle(const otk::RenderStyle &style)
XResizeWindow(**otk::display, _lgrip, geom.grip_width(), geom.handle_height); XResizeWindow(**otk::display, _lgrip, geom.grip_width(), geom.handle_height);
XResizeWindow(**otk::display, _rgrip, geom.grip_width(), geom.handle_height); XResizeWindow(**otk::display, _rgrip, geom.grip_width(), geom.handle_height);
for (unsigned int i = 0; i < _numbuttons; ++i) for (int i = 0; i < _numbuttons; ++i)
XResizeWindow(**otk::display, _buttons[i], XResizeWindow(**otk::display, _buttons[i],
geom.button_size, geom.button_size); geom.button_size, geom.button_size);
} }
@ -350,16 +350,17 @@ void Frame::renderLabel()
otk::ustring t = _client->title(); // the actual text to draw otk::ustring t = _client->title(); // the actual text to draw
int x = geom.bevel; // x coord for the text int x = geom.bevel; // x coord for the text
if ((unsigned)x * 2 > geom.label_width) return; // no room at all if (x * 2 > geom.label_width) return; // no room at all
// find a string that will fit inside the area for text // find a string that will fit inside the area for text
otk::ustring::size_type text_len = t.size(); otk::ustring::size_type text_len = t.size();
unsigned int length; int length;
unsigned int maxsize = geom.label_width - geom.bevel * 2; int maxsize = geom.label_width - geom.bevel * 2;
do { do {
t.resize(text_len); t.resize(text_len);
length = font->measureString(t); length = font->measureString(t); // this returns an unsigned, so check < 0
if (length < 0) length = maxsize; // if the string's that long just adjust
} while (length > maxsize && text_len-- > 0); } while (length > maxsize && text_len-- > 0);
if (text_len <= 0) return; // won't fit anything if (text_len <= 0) return; // won't fit anything

View file

@ -25,18 +25,18 @@ class Client;
//! Varius geometry settings in the frame decorations //! Varius geometry settings in the frame decorations
struct FrameGeometry { struct FrameGeometry {
unsigned int width; // title and handle int width; // title and handle
unsigned int font_height; int font_height;
unsigned int title_height() { return font_height + bevel*2; } int title_height() { return font_height + bevel*2; }
unsigned int label_width; int label_width;
unsigned int label_height() { return font_height; } int label_height() { return font_height; }
unsigned int handle_height; // static, from the style int handle_height; // static, from the style
int handle_y; int handle_y;
unsigned int button_size; // static, from the style int button_size; // static, from the style
unsigned grip_width() { return button_size * 2; } int grip_width() { return button_size * 2; }
unsigned bevel; // static, from the style int bevel; // static, from the style
unsigned bwidth; // frame elements' border width int bwidth; // frame elements' border width
unsigned cbwidth; // client border width int cbwidth; // client border width
}; };
//! Holds and decorates a frame around an Client (client window) //! Holds and decorates a frame around an Client (client window)
@ -74,10 +74,10 @@ private:
Window _lgrip; // lefthand resize grab on the handle Window _lgrip; // lefthand resize grab on the handle
Window _rgrip; // righthand resize grab on the handle Window _rgrip; // righthand resize grab on the handle
Window *_buttons; // all of the titlebar buttons Window *_buttons; // all of the titlebar buttons
unsigned int _numbuttons; // number of buttons, size of _buttons array int _numbuttons; // number of buttons, size of _buttons array
unsigned int *_titleorder; // order of the buttons and the label (always int *_titleorder; // order of the buttons and the label (always
// holds '_numbuttons + 1' elements (for the // holds '_numbuttons + 1' elements (for the
// label, which is coded as '-1') // label, which is coded as '-1')
// surfaces for each // surfaces for each
otk::Surface *_frame_sur; otk::Surface *_frame_sur;