1
0
Fork 0

(svn r15889) -Codechange: Add pre/inter/post space to nested background widgets

release/1.0
alberth 2009-03-29 13:25:01 +00:00
parent f436a58b5e
commit 64bb0e60e4
2 changed files with 42 additions and 6 deletions

View File

@ -862,6 +862,22 @@ void NWidgetContainer::Add(NWidgetBase *wid)
} }
} }
/**
* Set additional pre/inter/post space for the container.
*
* @param pip_pre Additional space in front of the first child widget (above
* for the vertical container, at the left for the horizontal container).
* @param pip_inter Additional space between two child widgets.
* @param pip_post Additional space after the last child widget (below for the
* vertical container, at the right for the horizontal container).
*/
void NWidgetContainer::SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post)
{
this->pip_pre = pip_pre;
this->pip_inter = pip_inter;
this->pip_post = pip_post;
}
NWidgetHorizontal::NWidgetHorizontal() : NWidgetContainer(NWID_HORIZONTAL) NWidgetHorizontal::NWidgetHorizontal() : NWidgetContainer(NWID_HORIZONTAL)
{ {
} }
@ -1145,6 +1161,24 @@ void NWidgetBackground::Add(NWidgetBase *nwid)
this->child->Add(nwid); this->child->Add(nwid);
} }
/**
* Set additional pre/inter/post space for the background widget.
*
* @param pip_pre Additional space in front of the first child widget (above
* for the vertical container, at the left for the horizontal container).
* @param pip_inter Additional space between two child widgets.
* @param pip_post Additional space after the last child widget (below for the
* vertical container, at the right for the horizontal container).
* @note Using this function implies that the widget has (or will have) child widgets.
*/
void NWidgetBackground::SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post)
{
if (this->child == NULL) {
this->child = new NWidgetVertical();
}
this->child->SetPIP(pip_pre, pip_inter, pip_post);
}
int NWidgetBackground::ComputeMinimalSize() int NWidgetBackground::ComputeMinimalSize()
{ {
int biggest_index = this->index; int biggest_index = this->index;
@ -1476,11 +1510,10 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest)
case WPT_PIPSPACE: { case WPT_PIPSPACE: {
NWidgetContainer *nwc = dynamic_cast<NWidgetContainer *>(*dest); NWidgetContainer *nwc = dynamic_cast<NWidgetContainer *>(*dest);
if (nwc != NULL) { if (nwc != NULL) nwc->SetPIP(parts->u.pip.pre, parts->u.pip.inter, parts->u.pip.post);
nwc->pip_pre = parts->u.pip.pre;
nwc->pip_inter = parts->u.pip.inter; NWidgetBackground *nwb = dynamic_cast<NWidgetBackground *>(*dest);
nwc->pip_post = parts->u.pip.post; if (nwb != NULL) nwb->SetPIP(parts->u.pip.pre, parts->u.pip.inter, parts->u.pip.post);
}
break; break;
} }

View File

@ -209,11 +209,13 @@ public:
~NWidgetContainer(); ~NWidgetContainer();
void Add(NWidgetBase *wid); void Add(NWidgetBase *wid);
void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
protected:
uint8 pip_pre; ///< Amount of space before first widget. uint8 pip_pre; ///< Amount of space before first widget.
uint8 pip_inter; ///< Amount of space between widgets. uint8 pip_inter; ///< Amount of space between widgets.
uint8 pip_post; ///< Amount of space after last widget. uint8 pip_post; ///< Amount of space after last widget.
protected:
NWidgetBase *head; ///< Pointer to first widget in container. NWidgetBase *head; ///< Pointer to first widget in container.
NWidgetBase *tail; ///< Pointer to last widget in container. NWidgetBase *tail; ///< Pointer to last widget in container.
}; };
@ -267,6 +269,7 @@ public:
~NWidgetBackground(); ~NWidgetBackground();
void Add(NWidgetBase *nwid); void Add(NWidgetBase *nwid);
void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
int ComputeMinimalSize(); int ComputeMinimalSize();
void AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl); void AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);