neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
header_view.hpp
Go to the documentation of this file.
1// header_view.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2015, 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
24#include "splitter.hpp"
25#include "i_item_model.hpp"
27
28namespace neogfx
29{
35
36 class header_view;
37
39 {
40 public:
41 virtual bool updating_models() const = 0;
42 public:
43 virtual void header_view_updated(header_view& aHeaderView, header_view_update_reason aUpdateReason) = 0;
44 };
45
46 enum class header_view_type : uint32_t
47 {
48 Horizontal = 0x0001,
49 Vertical = 0x0002
50 };
51
52 class header_view : public splitter
53 {
55 private:
56 struct section_dimension
57 {
58 optional_dimension manual;
59 dimension calculated;
60 };
61 public:
66 public:
68 bool has_model() const;
69 const i_item_model& model() const;
70 i_item_model& model();
71 void set_model(i_item_model& aModel);
74 const i_item_presentation_model& presentation_model() const;
75 i_item_presentation_model& presentation_model();
76 void set_presentation_model(i_item_presentation_model& aPresentationModel);
78 bool expand_last_column() const;
79 void set_expand_last_column(bool aExpandLastColumn);
80 public:
83 uint32_t section_count() const;
84 dimension section_width(uint32_t aSectionIndex, bool aForHeaderButton = false) const;
86 public:
87 bool is_managing_layout() const override;
88 public:
89 void panes_resized() override;
90 void reset_pane_sizes_requested(const std::optional<uint32_t>& aPane = {}) override;
91 protected:
92 virtual void column_info_changed(item_presentation_model_index::column_type aColumnIndex);
93 virtual void item_model_changed(const i_item_model& aItemModel);
94 virtual void item_added(item_presentation_model_index const& aItemIndex);
95 virtual void item_changed(item_presentation_model_index const& aItemIndex);
96 virtual void item_removed(item_presentation_model_index const& aItemIndex);
97 virtual void items_updated();
98 virtual void items_sorting();
99 virtual void items_sorted();
100 virtual void items_filtering();
101 virtual void items_filtered();
102 private:
103 void init();
104 void full_update();
105 bool update_section_width(uint32_t aColumn, dimension aColumnWidth);
106 private:
107 i_header_view_owner& iOwner;
108 sink iSink;
109 std::vector<std::array<sink, 2>> iButtonSinks;
110 header_view_type iType;
112 ref_ptr<i_item_presentation_model> iPresentationModel;
113 sink iPresentationModelSink;
114 bool iExpandLastColumn;
115 optional_dimension iSeparatorWidth;
116 std::vector<section_dimension> iSectionWidths;
117 bool iUpdatingSectionWidth;
118 };
119}
virtual void column_info_changed(item_presentation_model_index::column_type aColumnIndex)
uint32_t section_count() const
header_view_type type() const
i_item_model & model()
virtual void items_sorted()
void set_model(ref_ptr< i_item_model > aModel)
virtual void item_model_changed(const i_item_model &aItemModel)
virtual void items_updated()
i_item_presentation_model & presentation_model()
virtual void items_filtering()
void set_presentation_model(ref_ptr< i_item_presentation_model > aPresentationModel)
void set_model(i_item_model &aModel)
virtual void item_changed(item_presentation_model_index const &aItemIndex)
void set_separator_width(const optional_dimension &aWidth)
header_view(i_widget &aParent, i_header_view_owner &aOwner, header_view_type aType=header_view_type::Horizontal)
bool has_model() const
dimension separator_width() const
const i_item_presentation_model & presentation_model() const
dimension total_width() const
dimension section_width(uint32_t aSectionIndex, bool aForHeaderButton=false) const
void set_expand_last_column(bool aExpandLastColumn)
header_view(i_header_view_owner &aOwner, header_view_type aType=header_view_type::Horizontal)
void set_presentation_model(i_item_presentation_model &aPresentationModel)
virtual void items_filtered()
bool is_managing_layout() const override
header_view(i_layout &aLayout, i_header_view_owner &aOwner, header_view_type aType=header_view_type::Horizontal)
virtual void item_removed(item_presentation_model_index const &aItemIndex)
bool has_presentation_model() const
virtual void items_sorting()
virtual void item_added(item_presentation_model_index const &aItemIndex)
void reset_pane_sizes_requested(const std::optional< uint32_t > &aPane={}) override
void panes_resized() override
bool expand_last_column() const
const i_item_model & model() const
virtual void header_view_updated(header_view &aHeaderView, header_view_update_reason aUpdateReason)=0
virtual bool updating_models() const =0
header_view_update_reason
default_geometry_value_type dimension
#define meta_object(...)
Definition i_object.hpp:28