/src/libreoffice/include/vcl/weld/ItemView.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | */ |
9 | | |
10 | | #pragma once |
11 | | |
12 | | #include <vcl/dllapi.h> |
13 | | #include <vcl/weld/weld.hxx> |
14 | | |
15 | | namespace weld |
16 | | { |
17 | | /* Abstract base class for TreeView and IconView. */ |
18 | | class VCL_DLLPUBLIC ItemView : virtual public Widget |
19 | | { |
20 | | OUString m_sSavedValue; |
21 | | |
22 | | protected: |
23 | | virtual void do_set_cursor(const TreeIter& rIter) = 0; |
24 | | |
25 | | virtual void do_select(const TreeIter& rIter) = 0; |
26 | | virtual void do_unselect(const TreeIter& rIter) = 0; |
27 | | |
28 | | virtual void do_select_all() = 0; |
29 | | virtual void do_unselect_all() = 0; |
30 | | |
31 | | virtual void do_remove(const TreeIter& rIter) = 0; |
32 | | |
33 | | virtual void do_clear() = 0; |
34 | | |
35 | | public: |
36 | | virtual std::unique_ptr<TreeIter> make_iterator(const TreeIter* pOrig = nullptr) const = 0; |
37 | | |
38 | | virtual bool get_iter_first(TreeIter& rIter) const = 0; |
39 | | // set iter to point to next node at the current level |
40 | | virtual bool iter_next_sibling(TreeIter& rIter) const = 0; |
41 | | |
42 | | virtual int get_iter_index_in_parent(const TreeIter& rIter) const = 0; |
43 | | |
44 | | virtual std::unique_ptr<TreeIter> get_iterator(int nPos) const = 0; |
45 | | |
46 | | OUString get_id(int pos) const; |
47 | | virtual OUString get_id(const TreeIter& rIter) const = 0; |
48 | | void set_id(int pos, const OUString& rId); |
49 | | virtual void set_id(const TreeIter& rIter, const OUString& rId) = 0; |
50 | | |
51 | | virtual OUString get_selected_id() const = 0; |
52 | | virtual OUString get_selected_text() const = 0; |
53 | | |
54 | | virtual std::unique_ptr<weld::TreeIter> get_selected() const = 0; |
55 | | |
56 | | int get_cursor_index() const; |
57 | | virtual std::unique_ptr<TreeIter> get_cursor() const = 0; |
58 | | void set_cursor(const TreeIter& rIter); |
59 | | |
60 | | // Don't select when frozen, select after thaw. Note selection doesn't survive a freeze. |
61 | | void select(int pos); |
62 | | void select(const TreeIter& rIter); |
63 | | |
64 | | void unselect(int pos); |
65 | | void unselect(const TreeIter& rIter); |
66 | | |
67 | | void select_all(); |
68 | | void unselect_all(); |
69 | | |
70 | | // return the number of toplevel nodes |
71 | | virtual int n_children() const = 0; |
72 | | |
73 | | void remove(int pos); |
74 | | void remove(const TreeIter& rIter); |
75 | | |
76 | | void clear(); |
77 | | |
78 | | // call func on each selected element until func returns true or we run out of elements |
79 | | virtual void selected_foreach(const std::function<bool(TreeIter&)>& func) = 0; |
80 | | |
81 | 0 | void save_value() { m_sSavedValue = get_selected_text(); } |
82 | 0 | OUString const& get_saved_value() const { return m_sSavedValue; } |
83 | 0 | bool get_value_changed_from_saved() const { return m_sSavedValue != get_selected_text(); } |
84 | | }; |
85 | | } |
86 | | |
87 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |