/// functional constraints for a model of the SequenceViewConcept void constraints() { refresh(*view, index, value); extend(*view, index, index, value); extend_set(*view, index, key_set); erase(*view, key_set); }
void reveal_t::measure(extents_t& result) { using adobe::measure; // REVISIT (fbrereto) : hardwired defaults result.width() = 16; result.height() = 17; if (!using_label_m) return; extents_t label_extents; measure(name_m, label_extents); place_data_t label_place; width(label_place) = label_extents.width(); height(label_place) = label_extents.height(); measure_vertical(name_m, label_extents, label_place); result.width() += 4 /* gap */ + label_extents.width(); result.height() = (std::max)(result.height(), label_extents.height()); }
/// notifes the SequenceView of the elimination of elements from the sequence static void erase(SequenceView& view, const std::vector<key_type>& key_set) { using adobe::erase; erase(view, key_set); }
void reveal_t::place(const place_data_t& place_data) { using adobe::place; assert(control_m); if (!using_label_m) { implementation::set_control_bounds(control_m, place_data); } else { place_data_t tmp(place_data); // REVISIT (fbrereto) : hardwired defaults width(tmp) = 16; height(tmp) = 17; implementation::set_control_bounds(control_m, tmp); width(tmp) = width(place_data) - 16 - 4 /* gap */; left(tmp) = left(place_data) + 16 + 4 /* gap */; place(name_m, tmp); } }
/// refreshes the SequenceView at a given position in the sequence static void refresh(SequenceView& view, key_type index, cow_value_type value) { using adobe::refresh; refresh(view, index, value); }
/// functional constraints for a model of the DragAndDropConverterConcept void constraints() { // associated types: typedef typename dnd_converter_source_type<DragAndDropConverter>::type associated_type1; typedef typename dnd_converter_dest_type<DragAndDropConverter>::type associated_type2; using adobe::convert; convert(*converter, *src_value); }
/// notifes the SequenceView of the insertion of elements into the sequence static void extend_set(SequenceView& view, key_type before, const std::vector<key_type>& key_set) { using adobe::extend_set; extend_set(view, before, key_set); }
void edit_text_t::enable(bool active) { using adobe::enable; assert(control_m); ::EnableWindow(control_m, active); if (using_label_m) enable(get_label(), active); }
void edit_number_t::measure(extents_t& result) { // REVISIT (fbrereto) : This whole measure/place suite needs better // handling of the baseline alignment issue; we // skirt it currently and we should not. using adobe::measure; measure(edit_text_m, result); if (!using_popup()) return; edit_text_width_m = result.width(); extents_t popup_extents; measure(popup_m, popup_extents); // REVISIT (fbrereto) : constant value result.width() += 4 /*gap*/ + popup_extents.width(); result.height() = (std::max)(result.height(), popup_extents.height()); }
void edit_number_t::place(const place_data_t& place_data) { using adobe::place; place_data_t edit_place(place_data); place_data_t popup_place(place_data); if (using_popup()) width(edit_place) = static_cast<long>(edit_text_width_m); place(edit_text_m, edit_place); if (!using_popup()) return; // REVISIT (fbrereto) : constant value long offset(static_cast<long>(edit_text_width_m + 4 /*gap*/)); popup_place.horizontal().guide_set_m.clear(); width(popup_place) -= offset; left(popup_place) += offset; place(popup_m, popup_place); }
void edit_text_t::place(const place_data_t& place_data) { using adobe::place; assert(control_m); place_data_t local_place_data(place_data); long baseline = local_place_data.vertical().guide_set_m[0]; if (using_label_m) { // // We're using a label. We need to extract the label width from the // points of interest in the given geometry, and make sure that we // correctly translate the label for baseline alignment. // place_data_t label_place_data; label_place_data.horizontal().position_m = left(local_place_data); label_place_data.vertical().position_m = top(local_place_data); // // We stored the height of the label in best_bounds. The width of // the label can be discovered via the first horizontal point of // interest. // height(label_place_data) = static_height_m; width(label_place_data) = local_place_data.horizontal().guide_set_m[0]; // // Translate the label vertically for baseline alignment with the // edit widget. We stored the label's baseline in best_bounds. // label_place_data.vertical().position_m += baseline - static_baseline_m; place(get_label(), label_place_data); local_place_data.horizontal().position_m += width(label_place_data) + gap; width(local_place_data) -= width(label_place_data) + gap; } // // We might need to translate the edit widget vertically, for baseline // alignment. // local_place_data.vertical().position_m += baseline - edit_baseline_m; // REVISIT (thw) : Do we need to adapt the height for baseline alignment? implementation::set_control_bounds(control_m, local_place_data); }
void edit_text_t::place(const place_data_t& place_data) { using adobe::place; assert(control_m); place_data_t placement(place_data); long baseline(place_data.vertical().guide_set_m.empty() ? 0 : place_data.vertical().guide_set_m[0]); if (using_label_m) { place_data_t label_placement; top(label_placement) = top(place_data); left(label_placement) = left(place_data); height(label_placement) = static_height_m; width(label_placement) = place_data.horizontal().guide_set_m[0]; top(label_placement) += baseline - static_baseline_m; place(get_label(), label_placement); left(placement) += width(label_placement) + implementation::global_metrics()(implementation::k_metric_gap); width(placement) -= width(label_placement) + implementation::global_metrics()(implementation::k_metric_gap); } top(placement) += baseline - edit_baseline_m; if (scrollable_m) { implementation::shed_fudges(*this, placement); implementation::set_bounds(scroll_control_m, to_Rect(placement)); } else { implementation::set_bounds(*this, placement); } }
void any_regular_test() { using adobe::any_regular_t; using adobe::runtime_cast; { any_regular_t x(10.0); double y = runtime_cast<double&>(x); BOOST_CHECK_EQUAL(y, 10.0); runtime_cast<double&>(x) = 11.0; y = runtime_cast<double&>(x); BOOST_CHECK_EQUAL(y, 11.0); BOOST_CHECK(runtime_cast(x, y)); BOOST_CHECK_EQUAL(*runtime_cast<double*>(&x), 11.0); BOOST_CHECK(!runtime_cast<char*>(&x)); } { const any_regular_t x(10.0); double y = runtime_cast<const double&>(x); BOOST_CHECK_EQUAL(y, 10.0); } { const any_regular_t x; const any_regular_t y(10.0); BOOST_CHECK(adobe::empty(x)); BOOST_CHECK(!adobe::empty(y)); } #if 0 { any_regular_t x(1); int y = runtime_cast<int&>(x); } #endif }
void popup_t::place(const place_data_t& place_data) { using adobe::place; assert(control_m); place_data_t local_place_data(place_data); // // If we have a label then we need to allocate space for it // out of the space we have been given. // if (using_label_m) { // // The vertical offset of the label is the geometry's // baseline - the label's baseline. // assert(place_data.vertical().guide_set_m.empty() == false); long baseline = place_data.vertical().guide_set_m[0]; // // Apply the vertical offset. // place_data_t label_place_data; label_place_data.horizontal().position_m = left(place_data); label_place_data.vertical().position_m = top(place_data) + (baseline - static_baseline_m); // // The width of the label is the first horizontal // point of interest. // assert(place_data.horizontal().guide_set_m.empty() == false); width(label_place_data) = place_data.horizontal().guide_set_m[0]; height(label_place_data) = static_height_m; // // Set the label dimensions. // place(name_m, label_place_data); // // Now we need to adjust the position of the popup // widget. // long width = gap + adobe::width(label_place_data); local_place_data.horizontal().position_m += width; adobe::width(local_place_data) -= width; } // // On Win32, you give a combo box the height it should have // when it's fully extended (which seems a bit like a hackish // implementation detail poking through). Here we ensure that // the combo box is maximally the size of 10 elements (so that // we don't go over the edges of the screen if we have a huge // number of elements). // // REVISIT (ralpht) : fixed value. // height(local_place_data) = height(place_data) + std::min<long>(static_cast<long>((menu_items_m.size() + 1)), 10) * height(place_data); implementation::set_control_bounds(control_m, local_place_data); }
/// notifes the SequenceView of the elimination of all elements from the sequence static void clear(SequenceView& view) { using adobe::clear; clear(view); }
/// notifies the converter whether or not it should /// be enabled (and thus able to modify the model) static dest_type convert(const DragAndDropConverter& converter, const source_type& src_value) { using adobe::convert; return convert(converter, src_value); }
void equal_range_test() { using std::pair; using adobe::less; using adobe::equal_range; using adobe::equal_range_n; using adobe::aggregate_pair; using boost::begin; using boost::end; using boost::size; aggregate_pair<int> a[] = {{0, 0}, {0, 1}, {1, 2}, {1, 3}, {3, 4}, {3, 5}}; const aggregate_pair<int> c[] = {{0, 0}, {0, 1}, {1, 2}, {1, 3}, {3, 4}, {3, 5}}; BOOST_CHECK_EQUAL(equal_range_n(begin(a), size(a), a[0]).first, &a[0]); BOOST_CHECK_EQUAL(equal_range_n(begin(a), size(a), a[1], less()).first, &a[1]); BOOST_CHECK_EQUAL( equal_range_n(begin(a), size(a), 1, less(), &aggregate_pair<int>::first).first, &a[2]); BOOST_CHECK_EQUAL(equal_range(begin(a), end(a), a[0]).first, &a[0]); BOOST_CHECK_EQUAL(adobe::equal_range(begin(a), end(a), a[1], less()).first, &a[1]); BOOST_CHECK_EQUAL(equal_range(begin(a), end(a), 1, less(), &aggregate_pair<int>::first).first, &a[2]); BOOST_CHECK_EQUAL(equal_range(a, a[2]).first, &a[2]); BOOST_CHECK_EQUAL(equal_range(c, c[3]).first, &c[3]); BOOST_CHECK_EQUAL(equal_range(a, a[4], less()).first, &a[4]); BOOST_CHECK_EQUAL(equal_range(c, c[5], less()).first, &c[5]); BOOST_CHECK_EQUAL(equal_range(a, 1, less(), &aggregate_pair<int>::first).first, &a[2]); BOOST_CHECK_EQUAL(equal_range(c, 1, less(), &aggregate_pair<int>::first).first, &c[2]); }