const int&                  width() const       { return extents_m.width(); }
 int&                        width()             { return extents_m.width(); }
예제 #3
0
void slider_t::measure(extents_t& result)
{
    GG::Pt min_size = control_m->MinUsableSize();
    result.width() = Value(min_size.x);
    result.height() = Value(min_size.y);
}
예제 #4
0
 const long&                 width() const       { return extents_m.width(); }
예제 #5
0
 long&                       width()             { return extents_m.width(); }
예제 #6
0
void popup_t::measure(extents_t& result)
{
    assert(control_m);
    //
    // Make sure that metrics_t is initialized.
    //
    metrics::set_window(control_m);
    //
    // The popup_t has multiple text items. We need to find the one with
    // the widest extents (when drawn). Then we can make sure that we get
    // enough space to draw our largest text item.
    //
    menu_item_set_t::iterator first(menu_items_m.begin());
    menu_item_set_t::iterator last(menu_items_m.end());
    RECT largest_extents = { 0, 0, 0, 0 };
    bool have_extents = false;
    //
    // Now iterate through all of our text.
    //
    while (first != last)
    {
        //
        // Discover the extents of this text!
        //
        RECT extents;
        if (metrics::get_text_extents(CP_DROPDOWNBUTTON, hackery::convert_utf(first->first), extents))
        {
            //
            // Alright, we were able to obtain the required extents.
            // Now we just need to see if they are larger than the
            // ones we already have.
            //
            if ((extents.right - extents.left) > (largest_extents.right - largest_extents.left))
                largest_extents = extents;
            have_extents = true;
        }
        ++first;
    }
    //
    // We don't really use much of UxTheme to discover the bounds of
    // the combobox. We can use the GetComboboxInfo function to get
    // most of the information we require (such as where the text will
    // lie).
    //
    TEXTMETRIC font_metrics;
    int border;
    bool have_metrics = metrics::get_font_metrics(CP_DROPDOWNBUTTON, font_metrics);
    bool have_border = metrics::get_integer(CP_DROPDOWNBUTTON, TMT_BORDERSIZE, border);
    COMBOBOXINFO cbi;
    cbi.cbSize = sizeof(cbi);
    if (GetComboBoxInfo(control_m, &cbi))
    {
        RECT text = { 0, 0, 0, 0 };
        // currently unused
        //  RECT size = { 0, 0, 0, 0 };
        WINDOWINFO wi = { 0 };
        wi.cbSize = sizeof(wi);
        if (!GetWindowInfo(control_m, &wi)) ADOBE_THROW_LAST_ERROR;
        //
        // Figure out the borders around the text entry area.
        //
        text.left = wi.rcClient.left - wi.rcWindow.left + cbi.rcItem.left;
        text.right = wi.rcWindow.right - wi.rcClient.right + cbi.rcItem.right;
        text.top = wi.rcClient.top - wi.rcWindow.top + cbi.rcItem.top;
        text.bottom = wi.rcWindow.bottom - wi.rcWindow.bottom + cbi.rcItem.bottom;
        //
        // Figure out the dimensions for the entire control.
        //
        result.width() = text.left + largest_extents.right - largest_extents.left + cbi.rcButton.right - cbi.rcButton.left;
        result.height() = wi.rcWindow.bottom - wi.rcWindow.top;
        //
        // Deduce the baseline from the text rectangle.
        //
        int baseline = 0;
        if (have_metrics) {
            baseline = text.top + font_metrics.tmAscent;
            if (have_border) baseline += border;
        }
        result.vertical().guide_set_m.push_back(baseline);
    } else ADOBE_THROW_LAST_ERROR;

    //
    // If we have a label (always on our left side?) then we
    // need to add the size of the label to our result. We try
    // to align the label with the popup by baseline. Which is
    // kind of what Eve does, so it's bad that we do this
    // ourselves, really...
    //
    if (!using_label_m)
        return;
    //
    // We store the height of the label, from this we can
    // figure out how much to offset it when positioning
    // the widgets in set_bounds.
    //
    extents_t label_bounds;
    measure_label_text(name_m, label_bounds, ::GetParent(control_m));
    static_height_m = label_bounds.height();
    static_baseline_m = label_bounds.vertical().guide_set_m[0];
    //
    // Now we can align the label within the vertical
    // slice of the result. This doesn't do anything if
    // the label is shorter than the popup.
    //
    align_slices(result.vertical(), label_bounds.vertical());
    //
    // Add the width of the label (plus a gap) to the
    // resulting width.
    //
    result.width() += gap + label_bounds.width();

    //
    // Don't let the width of the popup go too crazy now...
    //
    result.width() = std::min<long>(static_cast<long>(result.width()), 300); // REVISIT (fbrereto) : fixed width

    //
    // Add a point-of-interest where the label ends.
    // We put the label to the left of the popup.
    //
    result.horizontal().guide_set_m.push_back(label_bounds.width());

    return;
}