working popups for moving/resizing

This commit is contained in:
Dana Jansens 2003-01-30 21:11:04 +00:00
parent 225d4302d0
commit bb6ac36d41
6 changed files with 77 additions and 4 deletions

View file

@ -29,10 +29,37 @@ void FocusLabel::setStyle(RenderStyle *style)
setUnfocusTexture(style->labelUnfocusBackground());
}
void FocusLabel::fitString(const std::string &str)
{
const Font *ft = style()->labelFont();
fitSize(ft->measureString(str), ft->height());
}
void FocusLabel::fitSize(int w, int h)
{
unsigned int sidemargin = style()->bevelWidth() * 2;
resize(w + sidemargin * 2, h);
}
void FocusLabel::update()
{
if (_dirty) {
int w = _rect.width(), h = _rect.height();
const Font *ft = style()->labelFont();
unsigned int sidemargin = style()->bevelWidth() * 2;
if (!_fixed_width)
w = ft->measureString(_text) + sidemargin * 2;
if (!_fixed_height)
h = ft->height();
internalResize(w, h);
}
FocusWidget::update();
}
void FocusLabel::renderForeground()
{
otk::Widget::renderForeground();
FocusWidget::renderForeground();
const Font *ft = style()->labelFont();
RenderColor *text_color = (isFocused() ? style()->textFocusColor()

View file

@ -18,6 +18,11 @@ public:
virtual void renderForeground();
virtual void update();
void fitString(const std::string &str);
void fitSize(int w, int h);
virtual void setStyle(RenderStyle *style);
private:

View file

@ -25,10 +25,37 @@ void Label::setStyle(RenderStyle *style)
setTexture(style->labelUnfocusBackground());
}
void Label::fitString(const std::string &str)
{
const Font *ft = style()->labelFont();
fitSize(ft->measureString(str), ft->height());
}
void Label::fitSize(int w, int h)
{
unsigned int sidemargin = style()->bevelWidth() * 2;
resize(w + sidemargin * 2, h);
}
void Label::update()
{
if (_dirty) {
int w = _rect.width(), h = _rect.height();
const Font *ft = style()->labelFont();
unsigned int sidemargin = style()->bevelWidth() * 2;
if (!_fixed_width)
w = ft->measureString(_text) + sidemargin * 2;
if (!_fixed_height)
h = ft->height();
internalResize(w, h);
}
Widget::update();
}
void Label::renderForeground(void)
{
otk::Widget::renderForeground();
Widget::renderForeground();
const Font *ft = style()->labelFont();
unsigned int sidemargin = style()->bevelWidth() * 2;

View file

@ -18,6 +18,11 @@ public:
virtual void renderForeground(void);
virtual void update();
void fitString(const std::string &str);
void fitSize(int w, int h);
virtual void setStyle(RenderStyle *style);
private:

View file

@ -203,12 +203,12 @@ def _create_popup_list(data):
t = t[:24] + "..." + t[-24:]
titles.append(t)
_list_windows.append(c)
l = font.measureString(t) + 10 # add margin
l = font.measureString(t)
if l > longest: longest = l
if len(titles) > 1:
for t in titles:
w = otk.FocusLabel(_list_widget)
w.resize(longest, height)
w.fitSize(longest, height)
w.setText(t)
w.unfocus()
_list_labels.append(w)

View file

@ -569,6 +569,15 @@ BB @param window The window id that the Client class should handle
//! Returns the window's stacking layer
inline StackLayer layer() const { return _layer; }
//! Returns the logical size of the window
/*!
The "logical" size of the window is refers to the user's perception of the
size of the window, and is the value that should be displayed to the user.
For example, with xterms, this value it the number of characters being
displayed in the terminal, instead of the number of pixels.
*/
const otk::Point &logicalSize() const { return _logical_size; }
//! Applies the states requested when the window mapped
/*!
This should be called only once, during the window mapping process. It