diff -r 644d0835a358 src/widget.cpp --- a/src/widget.cpp Sat Mar 07 19:40:36 2009 +0100 +++ b/src/widget.cpp Sat Mar 14 11:13:28 2009 +0100 @@ -1471,11 +1471,21 @@ if (nwrb != NULL) nwrb->SetResize(parts->d.xy.x_pos, parts->d.xy.y_pos); break; } + case WPT_RESIZE_PTR: { + NWidgetResizeBase *nwrb = dynamic_cast(*dest); + if (nwrb != NULL) nwrb->SetResize(parts->d.xy_ptr->x_pos, parts->d.xy_ptr->y_pos); + break; + } case WPT_MINSIZE: { NWidgetResizeBase *nwrb = dynamic_cast(*dest); if (nwrb != NULL) nwrb->SetMinimalSize(parts->d.xy.x_pos, parts->d.xy.y_pos); break; } + case WPT_MINSIZE_PTR: { + NWidgetResizeBase *nwrb = dynamic_cast(*dest); + if (nwrb != NULL) nwrb->SetMinimalSize(parts->d.xy_ptr->x_pos, parts->d.xy_ptr->y_pos); + break; + } case WPT_FILL: { NWidgetResizeBase *nwrb = dynamic_cast(*dest); if (nwrb != NULL) nwrb->SetFill(parts->d.xy.x_pos, parts->d.xy.y_pos); @@ -1489,6 +1499,14 @@ } break; } + case WPT_DATATIP_PTR: { + NWidgetCore *nwc = dynamic_cast(*dest); + if (nwc != NULL) { + nwc->widget_data = parts->d.datatip_ptr->data; + nwc->tool_tip = parts->d.datatip_ptr->tooltip; + } + break; + } case WPT_ENDCONTAINER: return num_used; default: diff -r 644d0835a358 src/widget_type.h --- a/src/widget_type.h Sat Mar 07 19:40:36 2009 +0100 +++ b/src/widget_type.h Sat Mar 14 11:13:28 2009 +0100 @@ -263,7 +263,10 @@ /* == Nested widget parts == */ -/** Widget part for storing a x/y size. */ +/** + * Widget part for storing a x/y size. + * @todo Move this to core/geometry_type.hpp, in a Point16 class/struct. + */ struct NWidgetPartDataXY { int16 x_pos; ///< X size. int16 y_pos; ///< Y size. @@ -287,9 +290,12 @@ */ enum NWidgetPartType { WPT_RESIZE = 0xf0, ///< Widget part for specifying resizing. + WPT_RESIZE_PTR, ///< Widget part for specifying resizing via a pointer. WPT_MINSIZE, ///< Widget part for specifying minimal size. + WPT_MINSIZE_PTR, ///< Widget part for specifying minimal size via a pointer. WPT_FILL, ///< Widget part for specifying fill. WPT_DATATIP, ///< Widget part for specifying data and tooltip. + WPT_DATATIP_PTR, ///< Widget part for specifying data and tooltip via a pointer. WPT_ENDCONTAINER, ///< Widget part to denote end of a container. }; @@ -300,7 +306,9 @@ byte type; ///< Type of the part. @see NWidgetPartType. union { NWidgetPartDataXY xy; ///< Part with an x/y size. + NWidgetPartDataXY *xy_ptr; ///< Part with a pointer to an x/y size. NWidgetPartDataTip data_tip; ///< Part with a data/tooltip. + NWidgetPartDataTip *datatip_ptr; ///< Part with a pointer to data/tooltip. NWidgetPartWidget widget; ///< Part with a start of a widget. } d; }; @@ -322,6 +330,20 @@ } /** + * Widget part function for using a pointer to set the resize step. + * @param ptr Pointer to horizontal and vertical resize step. + */ +static inline NWidgetPart SetResize(NWidgetPartDataXY *ptr) +{ + NWidgetPart part; + + part.type = WPT_RESIZE_PTR; + part.d.xy_ptr = ptr; + + return part; +} + +/** * Widget part function for setting the minimal size. * @param dx Horizontal minimal size. * @param dy Vertical minimal size. @@ -338,6 +360,20 @@ } /** + * Widget part function for using a pointer to set the minimal size. + * @param ptr Pointer to horizontal and vertical minimal size. + */ +static inline NWidgetPart SetMinimalSize(NWidgetPartDataXY *ptr) +{ + NWidgetPart part; + + part.type = WPT_MINSIZE_PTR; + part.d.xy_ptr = ptr; + + return part; +} + +/** * Widget part function for setting filling. * @param x_fill Allow horizontal filling from minimal size. * @param y_fill Allow vertical filling from minimal size. @@ -382,6 +418,20 @@ } /** + * Widget part function for setting the data and tooltip via a pointer. + * @param ptr Pointer to the data and tooltip of the widget. + */ +static inline NWidgetPart SetDataTip(NWidgetPartDataTip *ptr) +{ + NWidgetPart part; + + part.type = WPT_DATATIP_PTR; + part.d.datatip_ptr = ptr; + + return part; +} + +/** * Widget part function for starting a new 'real' widget. * @param tp Type of the new nested widget. * @param col Colour of the new widget.