* Nested leaf widget. * @param tp Type of leaf widget. * @param colour Colour of the leaf widget. * @param index Index of the widget. * @param data Data of the widget. * @param tip Tooltip of the widget. */
| 2695 | * @param tip Tooltip of the widget. |
| 2696 | */ |
| 2697 | NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, WidgetID index, const WidgetData &data, StringID tip) : NWidgetCore(tp, colour, index, 1, 1, data, tip) |
| 2698 | { |
| 2699 | assert(index >= 0 || tp == WWT_LABEL || tp == WWT_TEXT || tp == WWT_CAPTION || tp == WWT_RESIZEBOX || tp == WWT_SHADEBOX || tp == WWT_DEFSIZEBOX || tp == WWT_DEBUGBOX || tp == WWT_STICKYBOX || tp == WWT_CLOSEBOX); |
| 2700 | this->min_x = 0; |
| 2701 | this->min_y = 0; |
| 2702 | this->SetResize(0, 0); |
| 2703 | |
| 2704 | switch (tp) { |
| 2705 | case WWT_EMPTY: |
| 2706 | if (colour != INVALID_COLOUR) [[unlikely]] throw std::runtime_error("WWT_EMPTY should not have a colour"); |
| 2707 | break; |
| 2708 | |
| 2709 | case WWT_TEXT: |
| 2710 | if (colour != INVALID_COLOUR) [[unlikely]] throw std::runtime_error("WWT_TEXT should not have a colour"); |
| 2711 | this->SetFill(0, 0); |
| 2712 | this->SetAlignment(SA_LEFT | SA_VERT_CENTER); |
| 2713 | break; |
| 2714 | |
| 2715 | case WWT_LABEL: |
| 2716 | if (colour != INVALID_COLOUR) [[unlikely]] throw std::runtime_error("WWT_LABEL should not have a colour"); |
| 2717 | [[fallthrough]]; |
| 2718 | |
| 2719 | case WWT_PUSHBTN: |
| 2720 | case WWT_IMGBTN: |
| 2721 | case WWT_PUSHIMGBTN: |
| 2722 | case WWT_IMGBTN_2: |
| 2723 | case WWT_TEXTBTN: |
| 2724 | case WWT_PUSHTXTBTN: |
| 2725 | case WWT_TEXTBTN_2: |
| 2726 | case WWT_IMGTEXTBTN: |
| 2727 | case WWT_PUSHIMGTEXTBTN: |
| 2728 | case WWT_BOOLBTN: |
| 2729 | case WWT_MATRIX: |
| 2730 | case NWID_BUTTON_DROPDOWN: |
| 2731 | case NWID_PUSHBUTTON_DROPDOWN: |
| 2732 | this->SetFill(0, 0); |
| 2733 | break; |
| 2734 | |
| 2735 | case WWT_ARROWBTN: |
| 2736 | case WWT_PUSHARROWBTN: |
| 2737 | this->SetFill(0, 0); |
| 2738 | this->SetAspect(WidgetDimensions::ASPECT_LEFT_RIGHT_BUTTON); |
| 2739 | break; |
| 2740 | |
| 2741 | case WWT_EDITBOX: |
| 2742 | this->SetFill(0, 0); |
| 2743 | break; |
| 2744 | |
| 2745 | case WWT_CAPTION: |
| 2746 | this->SetFill(1, 0); |
| 2747 | this->SetResize(1, 0); |
| 2748 | this->SetMinimalSize(0, WidgetDimensions::WD_CAPTION_HEIGHT); |
| 2749 | this->SetMinimalTextLines(1, WidgetDimensions::unscaled.captiontext.Vertical(), FS_NORMAL); |
| 2750 | this->SetToolTip(STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS); |
| 2751 | break; |
| 2752 | |
| 2753 | case WWT_STICKYBOX: |
| 2754 | this->SetFill(0, 0); |
nothing calls this directly
no test coverage detected