00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef WIDGET_TYPE_H
00013 #define WIDGET_TYPE_H
00014
00015 #include "core/alloc_type.hpp"
00016 #include "core/bitmath_func.hpp"
00017 #include "core/math_func.hpp"
00018 #include "strings_type.h"
00019 #include "gfx_type.h"
00020 #include "window_type.h"
00021
00022 static const int WIDGET_LIST_END = -1;
00023
00025 enum MatrixWidgetValues {
00026
00027 MAT_COL_START = 0,
00028 MAT_COL_BITS = 8,
00029
00030
00031 MAT_ROW_START = 8,
00032 MAT_ROW_BITS = 8,
00033 };
00034
00036 enum ArrowWidgetValues {
00037 AWV_DECREASE,
00038 AWV_INCREASE,
00039 AWV_LEFT,
00040 AWV_RIGHT,
00041 };
00042
00046 enum WidgetType {
00047
00048 WWT_EMPTY,
00049
00050 WWT_PANEL,
00051 WWT_INSET,
00052 WWT_IMGBTN,
00053 WWT_IMGBTN_2,
00054 WWT_ARROWBTN,
00055 WWT_TEXTBTN,
00056 WWT_TEXTBTN_2,
00057 WWT_LABEL,
00058 WWT_TEXT,
00059 WWT_MATRIX,
00060 WWT_FRAME,
00061 WWT_CAPTION,
00062
00063 WWT_SHADEBOX,
00064 WWT_STICKYBOX,
00065 WWT_DEBUGBOX,
00066 WWT_RESIZEBOX,
00067 WWT_CLOSEBOX,
00068 WWT_DROPDOWN,
00069 WWT_EDITBOX,
00070 WWT_LAST,
00071
00072
00073 NWID_HORIZONTAL,
00074 NWID_HORIZONTAL_LTR,
00075 NWID_VERTICAL,
00076 NWID_MATRIX,
00077 NWID_SPACER,
00078 NWID_SELECTION,
00079 NWID_VIEWPORT,
00080 NWID_BUTTON_DROPDOWN,
00081 NWID_HSCROLLBAR,
00082 NWID_VSCROLLBAR,
00083
00084
00085 WPT_RESIZE,
00086 WPT_MINSIZE,
00087 WPT_MINTEXTLINES,
00088 WPT_FILL,
00089 WPT_DATATIP,
00090 WPT_PADDING,
00091 WPT_PIPSPACE,
00092 WPT_ENDCONTAINER,
00093 WPT_FUNCTION,
00094 WPT_SCROLLBAR,
00095
00096
00097 WWT_MASK = 0x7F,
00098
00099 WWB_PUSHBUTTON = 1 << 7,
00100
00101 WWT_PUSHBTN = WWT_PANEL | WWB_PUSHBUTTON,
00102 WWT_PUSHTXTBTN = WWT_TEXTBTN | WWB_PUSHBUTTON,
00103 WWT_PUSHIMGBTN = WWT_IMGBTN | WWB_PUSHBUTTON,
00104 WWT_PUSHARROWBTN = WWT_ARROWBTN | WWB_PUSHBUTTON,
00105 };
00106
00108 enum SizingType {
00109 ST_SMALLEST,
00110 ST_RESIZE,
00111 };
00112
00113
00114 class NWidgetCore;
00115 class Scrollbar;
00116
00123 class NWidgetBase : public ZeroedMemoryAllocator {
00124 public:
00125 NWidgetBase(WidgetType tp);
00126
00127 virtual void SetupSmallestSize(Window *w, bool init_array) = 0;
00128 virtual void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) = 0;
00129
00130 virtual void FillNestedArray(NWidgetBase **array, uint length) = 0;
00131
00132 virtual NWidgetCore *GetWidgetFromPos(int x, int y) = 0;
00133 virtual NWidgetBase *GetWidgetOfType(WidgetType tp);
00134
00142 FORCEINLINE void SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
00143 {
00144 this->padding_top = top;
00145 this->padding_right = right;
00146 this->padding_bottom = bottom;
00147 this->padding_left = left;
00148 }
00149
00150 FORCEINLINE uint GetHorizontalStepSize(SizingType sizing) const;
00151 FORCEINLINE uint GetVerticalStepSize(SizingType sizing) const;
00152
00153 virtual void Draw(const Window *w) = 0;
00154 virtual void SetDirty(const Window *w) const;
00155
00156 WidgetType type;
00157 uint fill_x;
00158 uint fill_y;
00159 uint resize_x;
00160 uint resize_y;
00161
00162
00163
00164 uint smallest_x;
00165 uint smallest_y;
00166
00167 uint current_x;
00168 uint current_y;
00169
00170 uint pos_x;
00171 uint pos_y;
00172
00173 NWidgetBase *next;
00174 NWidgetBase *prev;
00175
00176 uint8 padding_top;
00177 uint8 padding_right;
00178 uint8 padding_bottom;
00179 uint8 padding_left;
00180
00181 protected:
00182 FORCEINLINE void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height);
00183 };
00184
00189 FORCEINLINE uint NWidgetBase::GetHorizontalStepSize(SizingType sizing) const
00190 {
00191 return (sizing == ST_RESIZE) ? this->resize_x : this->fill_x;
00192 }
00193
00198 FORCEINLINE uint NWidgetBase::GetVerticalStepSize(SizingType sizing) const
00199 {
00200 return (sizing == ST_RESIZE) ? this->resize_y : this->fill_y;
00201 }
00202
00211 FORCEINLINE void NWidgetBase::StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height)
00212 {
00213 this->pos_x = x;
00214 this->pos_y = y;
00215 if (sizing == ST_SMALLEST) {
00216 this->smallest_x = given_width;
00217 this->smallest_y = given_height;
00218 }
00219 this->current_x = given_width;
00220 this->current_y = given_height;
00221 }
00222
00223
00228 class NWidgetResizeBase : public NWidgetBase {
00229 public:
00230 NWidgetResizeBase(WidgetType tp, uint fill_x, uint fill_y);
00231
00232 void SetMinimalSize(uint min_x, uint min_y);
00233 void SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size);
00234 void SetFill(uint fill_x, uint fill_y);
00235 void SetResize(uint resize_x, uint resize_y);
00236
00237 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
00238
00239 uint min_x;
00240 uint min_y;
00241 };
00242
00244 enum NWidgetDisplay {
00245
00246 NDB_LOWERED = 0,
00247 NDB_DISABLED = 1,
00248
00249 NDB_NO_TRANSPARENCY = 2,
00250 NDB_SHADE_GREY = 3,
00251 NDB_SHADE_DIMMED = 4,
00252
00253 NDB_DROPDOWN_ACTIVE = 5,
00254
00255 NDB_SCROLLBAR_UP = 6,
00256 NDB_SCROLLBAR_DOWN = 7,
00257
00258 ND_LOWERED = 1 << NDB_LOWERED,
00259 ND_DISABLED = 1 << NDB_DISABLED,
00260 ND_NO_TRANSPARENCY = 1 << NDB_NO_TRANSPARENCY,
00261 ND_SHADE_GREY = 1 << NDB_SHADE_GREY,
00262 ND_SHADE_DIMMED = 1 << NDB_SHADE_DIMMED,
00263 ND_DROPDOWN_ACTIVE = 1 << NDB_DROPDOWN_ACTIVE,
00264 ND_SCROLLBAR_UP = 1 << NDB_SCROLLBAR_UP,
00265 ND_SCROLLBAR_DOWN = 1 << NDB_SCROLLBAR_DOWN,
00266 ND_SCROLLBAR_BTN = ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN,
00267 };
00268 DECLARE_ENUM_AS_BIT_SET(NWidgetDisplay)
00269
00270
00274 class NWidgetCore : public NWidgetResizeBase {
00275 public:
00276 NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint16 widget_data, StringID tool_tip);
00277
00278 void SetIndex(int index);
00279 void SetDataTip(uint16 widget_data, StringID tool_tip);
00280
00281 inline void SetLowered(bool lowered);
00282 inline bool IsLowered() const;
00283 inline void SetDisabled(bool disabled);
00284 inline bool IsDisabled() const;
00285
00286 void FillNestedArray(NWidgetBase **array, uint length);
00287 NWidgetCore *GetWidgetFromPos(int x, int y);
00288
00289 NWidgetDisplay disp_flags;
00290 Colours colour;
00291 int index;
00292 uint16 widget_data;
00293 StringID tool_tip;
00294 int scrollbar_index;
00295 };
00296
00301 inline void NWidgetCore::SetLowered(bool lowered)
00302 {
00303 this->disp_flags = lowered ? SETBITS(this->disp_flags, ND_LOWERED) : CLRBITS(this->disp_flags, ND_LOWERED);
00304 }
00305
00307 inline bool NWidgetCore::IsLowered() const
00308 {
00309 return HasBit(this->disp_flags, NDB_LOWERED);
00310 }
00311
00316 inline void NWidgetCore::SetDisabled(bool disabled)
00317 {
00318 this->disp_flags = disabled ? SETBITS(this->disp_flags, ND_DISABLED) : CLRBITS(this->disp_flags, ND_DISABLED);
00319 }
00320
00322 inline bool NWidgetCore::IsDisabled() const
00323 {
00324 return HasBit(this->disp_flags, NDB_DISABLED);
00325 }
00326
00327
00332 class NWidgetContainer : public NWidgetBase {
00333 public:
00334 NWidgetContainer(WidgetType tp);
00335 ~NWidgetContainer();
00336
00337 void Add(NWidgetBase *wid);
00338 void FillNestedArray(NWidgetBase **array, uint length);
00339
00341 inline bool IsEmpty() { return head == NULL; }
00342
00343 NWidgetBase *GetWidgetOfType(WidgetType tp);
00344
00345 protected:
00346 NWidgetBase *head;
00347 NWidgetBase *tail;
00348 };
00349
00351 enum StackedZeroSizePlanes {
00352 SZSP_VERTICAL = INT_MAX / 2,
00353 SZSP_HORIZONTAL,
00354 SZSP_NONE,
00355
00356 SZSP_BEGIN = SZSP_VERTICAL,
00357 };
00358
00369 class NWidgetStacked : public NWidgetContainer {
00370 public:
00371 NWidgetStacked();
00372
00373 void SetIndex(int index);
00374
00375 void SetupSmallestSize(Window *w, bool init_array);
00376 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
00377 void FillNestedArray(NWidgetBase **array, uint length);
00378
00379 void Draw(const Window *w);
00380 NWidgetCore *GetWidgetFromPos(int x, int y);
00381
00382 void SetDisplayedPlane(int plane);
00383
00384 int shown_plane;
00385 int index;
00386 };
00387
00389 enum NWidContainerFlags {
00390 NCB_EQUALSIZE = 0,
00391
00392 NC_NONE = 0,
00393 NC_EQUALSIZE = 1 << NCB_EQUALSIZE,
00394 };
00395 DECLARE_ENUM_AS_BIT_SET(NWidContainerFlags)
00396
00397
00398 class NWidgetPIPContainer : public NWidgetContainer {
00399 public:
00400 NWidgetPIPContainer(WidgetType tp, NWidContainerFlags flags = NC_NONE);
00401
00402 void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
00403
00404 void Draw(const Window *w);
00405 NWidgetCore *GetWidgetFromPos(int x, int y);
00406
00407 protected:
00408 NWidContainerFlags flags;
00409 uint8 pip_pre;
00410 uint8 pip_inter;
00411 uint8 pip_post;
00412 };
00413
00418 class NWidgetHorizontal : public NWidgetPIPContainer {
00419 public:
00420 NWidgetHorizontal(NWidContainerFlags flags = NC_NONE);
00421
00422 void SetupSmallestSize(Window *w, bool init_array);
00423 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
00424 };
00425
00430 class NWidgetHorizontalLTR : public NWidgetHorizontal {
00431 public:
00432 NWidgetHorizontalLTR(NWidContainerFlags flags = NC_NONE);
00433
00434 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
00435 };
00436
00441 class NWidgetVertical : public NWidgetPIPContainer {
00442 public:
00443 NWidgetVertical(NWidContainerFlags flags = NC_NONE);
00444
00445 void SetupSmallestSize(Window *w, bool init_array);
00446 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
00447 };
00448
00457 class NWidgetMatrix : public NWidgetPIPContainer {
00458 public:
00459 NWidgetMatrix();
00460
00461 void SetIndex(int index);
00462 void SetColour(Colours colour);
00463 void SetClicked(int clicked);
00464 void SetCount(int count);
00465 void SetScrollbar(Scrollbar *sb);
00466
00467 void SetupSmallestSize(Window *w, bool init_array);
00468 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
00469 void FillNestedArray(NWidgetBase **array, uint length);
00470
00471 NWidgetCore *GetWidgetFromPos(int x, int y);
00472 void Draw(const Window *w);
00473 protected:
00474 int index;
00475 Colours colour;
00476 int clicked;
00477 int count;
00478 Scrollbar *sb;
00479 private:
00480 int widget_w;
00481 int widget_h;
00482 int widgets_x;
00483 int widgets_y;
00484
00485 void GetScrollOffsets(int &start_x, int &start_y, int &base_offs_x, int &base_offs_y);
00486 };
00487
00488
00493 class NWidgetSpacer : public NWidgetResizeBase {
00494 public:
00495 NWidgetSpacer(int length, int height);
00496
00497 void SetupSmallestSize(Window *w, bool init_array);
00498 void FillNestedArray(NWidgetBase **array, uint length);
00499
00500 void Draw(const Window *w);
00501 void SetDirty(const Window *w) const;
00502 NWidgetCore *GetWidgetFromPos(int x, int y);
00503 };
00504
00509 class NWidgetBackground : public NWidgetCore {
00510 public:
00511 NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child = NULL);
00512 ~NWidgetBackground();
00513
00514 void Add(NWidgetBase *nwid);
00515 void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
00516
00517 void SetupSmallestSize(Window *w, bool init_array);
00518 void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
00519
00520 void FillNestedArray(NWidgetBase **array, uint length);
00521
00522 void Draw(const Window *w);
00523 NWidgetCore *GetWidgetFromPos(int x, int y);
00524 NWidgetBase *GetWidgetOfType(WidgetType tp);
00525
00526 private:
00527 NWidgetPIPContainer *child;
00528 };
00529
00539 class NWidgetViewport : public NWidgetCore {
00540 public:
00541 NWidgetViewport(int index);
00542
00543 void SetupSmallestSize(Window *w, bool init_array);
00544 void Draw(const Window *w);
00545
00546 void InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom);
00547 void UpdateViewportCoordinates(Window *w);
00548 };
00549
00553 class Scrollbar {
00554 private:
00555 const bool is_vertical;
00556 uint16 count;
00557 uint16 cap;
00558 uint16 pos;
00559 uint16 stepsize;
00560
00561 public:
00563 enum ScrollbarStepping {
00564 SS_RAW,
00565 SS_SMALL,
00566 SS_BIG,
00567 };
00568
00569 Scrollbar(bool is_vertical) : is_vertical(is_vertical), stepsize(1)
00570 {
00571 }
00572
00577 FORCEINLINE uint16 GetCount() const
00578 {
00579 return this->count;
00580 }
00581
00586 FORCEINLINE uint16 GetCapacity() const
00587 {
00588 return this->cap;
00589 }
00590
00595 FORCEINLINE uint16 GetPosition() const
00596 {
00597 return this->pos;
00598 }
00599
00605 FORCEINLINE bool IsVisible(uint16 item) const
00606 {
00607 return IsInsideBS(item, this->GetPosition(), this->GetCapacity());
00608 }
00609
00614 FORCEINLINE bool IsVertical() const
00615 {
00616 return this->is_vertical;
00617 }
00618
00623 void SetStepSize(uint16 stepsize)
00624 {
00625 assert(stepsize > 0);
00626 this->stepsize = stepsize;
00627 }
00628
00634 void SetCount(int num)
00635 {
00636 assert(num >= 0);
00637 assert(num <= MAX_UVALUE(uint16));
00638
00639 this->count = num;
00640 num -= this->cap;
00641 if (num < 0) num = 0;
00642 if (num < this->pos) this->pos = num;
00643 }
00644
00650 void SetCapacity(int capacity)
00651 {
00652 assert(capacity > 0);
00653 assert(capacity <= MAX_UVALUE(uint16));
00654
00655 this->cap = capacity;
00656 if (this->cap + this->pos > this->count) this->pos = max(0, this->count - this->cap);
00657 }
00658
00659 void SetCapacityFromWidget(Window *w, int widget, int padding = 0);
00660
00665 void SetPosition(int position)
00666 {
00667 assert(position >= 0);
00668 assert(this->count <= this->cap ? (position == 0) : (position + this->cap <= this->count));
00669 this->pos = position;
00670 }
00671
00678 void UpdatePosition(int difference, ScrollbarStepping unit = SS_SMALL)
00679 {
00680 if (difference == 0) return;
00681 switch (unit) {
00682 case SS_SMALL: difference *= this->stepsize; break;
00683 case SS_BIG: difference *= this->cap; break;
00684 default: break;
00685 }
00686 this->SetPosition(Clamp(this->pos + difference, 0, max(this->count - this->cap, 0)));
00687 }
00688
00695 void ScrollTowards(int position)
00696 {
00697 if (position < this->GetPosition()) {
00698
00699 this->SetPosition(position);
00700 } else if (position >= this->GetPosition() + this->GetCapacity()) {
00701
00702 this->SetPosition(position - this->GetCapacity() + 1);
00703 }
00704 }
00705
00706 int GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding = 0, int line_height = -1) const;
00707 };
00708
00714 class NWidgetScrollbar : public NWidgetCore, public Scrollbar {
00715 public:
00716 NWidgetScrollbar(WidgetType tp, Colours colour, int index);
00717
00718 void SetupSmallestSize(Window *w, bool init_array);
00719 void Draw(const Window *w);
00720 };
00721
00726 class NWidgetLeaf : public NWidgetCore {
00727 public:
00728 NWidgetLeaf(WidgetType tp, Colours colour, int index, uint16 data, StringID tip);
00729
00730 void SetupSmallestSize(Window *w, bool init_array);
00731 void Draw(const Window *w);
00732
00733 bool ButtonHit(const Point &pt);
00734
00735 static void InvalidateDimensionCache();
00736 private:
00737 static Dimension shadebox_dimension;
00738 static Dimension debugbox_dimension;
00739 static Dimension stickybox_dimension;
00740 static Dimension resizebox_dimension;
00741 static Dimension closebox_dimension;
00742 };
00743
00751 static FORCEINLINE uint ComputeMaxSize(uint base, uint max_space, uint step)
00752 {
00753 if (base >= max_space || step == 0) return base;
00754 if (step == 1) return max_space;
00755 uint increment = max_space - base;
00756 increment -= increment % step;
00757 return base + increment;
00758 }
00759
00811 struct NWidgetPartDataTip {
00812 uint16 data;
00813 StringID tooltip;
00814 };
00815
00820 struct NWidgetPartWidget {
00821 Colours colour;
00822 int16 index;
00823 };
00824
00829 struct NWidgetPartPaddings {
00830 uint8 top, right, bottom, left;
00831 };
00832
00837 struct NWidgetPartPIP {
00838 uint8 pre, inter, post;
00839 };
00840
00845 struct NWidgetPartTextLines {
00846 uint8 lines;
00847 uint8 spacing;
00848 FontSize size;
00849 };
00850
00857 typedef NWidgetBase *NWidgetFunctionType(int *biggest_index);
00858
00863 struct NWidgetPart {
00864 WidgetType type;
00865 union {
00866 Point xy;
00867 NWidgetPartDataTip data_tip;
00868 NWidgetPartWidget widget;
00869 NWidgetPartPaddings padding;
00870 NWidgetPartPIP pip;
00871 NWidgetPartTextLines text_lines;
00872 NWidgetFunctionType *func_ptr;
00873 NWidContainerFlags cont_flags;
00874 } u;
00875 };
00876
00883 static inline NWidgetPart SetResize(int16 dx, int16 dy)
00884 {
00885 NWidgetPart part;
00886
00887 part.type = WPT_RESIZE;
00888 part.u.xy.x = dx;
00889 part.u.xy.y = dy;
00890
00891 return part;
00892 }
00893
00900 static inline NWidgetPart SetMinimalSize(int16 x, int16 y)
00901 {
00902 NWidgetPart part;
00903
00904 part.type = WPT_MINSIZE;
00905 part.u.xy.x = x;
00906 part.u.xy.y = y;
00907
00908 return part;
00909 }
00910
00918 static inline NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size = FS_NORMAL)
00919 {
00920 NWidgetPart part;
00921
00922 part.type = WPT_MINTEXTLINES;
00923 part.u.text_lines.lines = lines;
00924 part.u.text_lines.spacing = spacing;
00925 part.u.text_lines.size = size;
00926
00927 return part;
00928 }
00929
00936 static inline NWidgetPart SetFill(uint fill_x, uint fill_y)
00937 {
00938 NWidgetPart part;
00939
00940 part.type = WPT_FILL;
00941 part.u.xy.x = fill_x;
00942 part.u.xy.y = fill_y;
00943
00944 return part;
00945 }
00946
00952 static inline NWidgetPart EndContainer()
00953 {
00954 NWidgetPart part;
00955
00956 part.type = WPT_ENDCONTAINER;
00957
00958 return part;
00959 }
00960
00967 static inline NWidgetPart SetDataTip(uint16 data, StringID tip)
00968 {
00969 NWidgetPart part;
00970
00971 part.type = WPT_DATATIP;
00972 part.u.data_tip.data = data;
00973 part.u.data_tip.tooltip = tip;
00974
00975 return part;
00976 }
00977
00987 static inline NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
00988 {
00989 NWidgetPart part;
00990
00991 part.type = WPT_PADDING;
00992 part.u.padding.top = top;
00993 part.u.padding.right = right;
00994 part.u.padding.bottom = bottom;
00995 part.u.padding.left = left;
00996
00997 return part;
00998 }
00999
01005 static inline NWidgetPart SetPadding(uint8 padding)
01006 {
01007 return SetPadding(padding, padding, padding, padding);
01008 }
01009
01017 static inline NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
01018 {
01019 NWidgetPart part;
01020
01021 part.type = WPT_PIPSPACE;
01022 part.u.pip.pre = pre;
01023 part.u.pip.inter = inter;
01024 part.u.pip.post = post;
01025
01026 return part;
01027 }
01028
01036 static inline NWidgetPart SetScrollbar(int index)
01037 {
01038 NWidgetPart part;
01039
01040 part.type = WPT_SCROLLBAR;
01041 part.u.widget.index = index;
01042
01043 return part;
01044 }
01045
01055 static inline NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx = -1)
01056 {
01057 NWidgetPart part;
01058
01059 part.type = tp;
01060 part.u.widget.colour = col;
01061 part.u.widget.index = idx;
01062
01063 return part;
01064 }
01065
01072 static inline NWidgetPart NWidget(WidgetType tp, NWidContainerFlags cont_flags = NC_NONE)
01073 {
01074 NWidgetPart part;
01075
01076 part.type = tp;
01077 part.u.cont_flags = cont_flags;
01078
01079 return part;
01080 }
01081
01087 static inline NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
01088 {
01089 NWidgetPart part;
01090
01091 part.type = WPT_FUNCTION;
01092 part.u.func_ptr = func_ptr;
01093
01094 return part;
01095 }
01096
01097 NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container);
01098 NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *parts, int count, int *biggest_index, NWidgetStacked **shade_select);
01099
01100 NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, int max_length, StringID button_tooltip);
01101
01102 #endif