tbx  0.7.6
restreeview.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2020 Alan Buckley All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
25 #ifndef TBX_RES_RESTREEVIEW_H
26 #define TBX_RES_RESTREEVIEW_H
27 
28 #include "tbx/res/resgadget.h"
29 
30 namespace tbx {
31 namespace ext {
32 namespace res {
33 
38 {
39 
40 public:
41  enum {TYPE_ID = 0x402c };
42 
49  ResTreeView(const tbx::res::ResGadget &other) : tbx::res::ResGadget(other)
50  {
51  check_type(TYPE_ID);
52  }
53 
59  ResTreeView(const ResTreeView &other) : tbx::res::ResGadget(other)
60  {
61  }
62 
63  virtual ~ResTreeView() {}
64 
72  {
73  other.check_type(TYPE_ID);
75  return *this;
76  }
77 
84  {
86  return *this;
87  }
88 
95  : tbx::res::ResGadget(0x4028,52)
96  {
97  foreground(7); // Black
98  background(1); // grey
99  linecolour(3);
100  version(1);
101  vertical_spacing(12);
102  horizontal_spacing(256);
103  flags(0); // Turn off all flags
104  // Note: offset 44 is in the header, but unused
105  }
106 
107  bool allow_vscroll() const {return flag(0, 1);}
108  void allow_vscroll(bool value) {flag(0, 1, value);}
109  bool allow_hscroll() const {return flag(0, 2);}
110  void allow_hscroll(bool value) {flag(0, 2, value);}
111  bool auto_update() const {return flag(0, 4);}
112  void auto_update(bool value) {flag(0, 4, value);}
113  bool show_current_node() const {return flag(0, 8);}
114  void show_current_node(bool value) {flag(0, 8, value);}
115  bool plot_lines() const {return flag(0, 16);}
116  void plot_lines(bool value) {flag(0, 16, value);}
117  bool allow_selection() const {return flag(0, 32);}
118  void allow_selection(bool value) {flag(0, 32,value);}
119  bool notify_selection() const {return flag(0, 64);}
120  void notify_selection(bool value) {flag(0, 64, value);}
121  bool select_children() const {return flag(0, 1u<<7);}
122  void select_children(bool value) {flag(0, 1u<<7, value);}
123  bool allow_expand() const {return flag(0, 1u<<8);}
124  void allow_expand(bool value) {flag(0, 1u<<8, value);}
125  bool notify_expansion() const {return flag(0, 1u<<9);}
126  void notify_expansion(bool value) {flag(0, 1u<<9, value);}
127  bool expand_by_default() const {return flag(0, 1u<<10);}
128  void expand_by_default(bool value) {flag(0, 1u<<10, value);}
129  bool allow_rename() const {return flag(0, 1u<<11);}
130  void allow_rename(bool value) {flag(0, 1u<<11, value);}
131  bool notify_rename() const {return flag(0, 1u<<12);}
132  void notify_rename(bool value) {flag(0, 1u<<12, value);}
133  bool allow_drags() const {return flag(0, 1u<<13);}
134  void allow_drags(bool value) {flag(0, 1u<<13, value);}
135  bool notify_drag_end() const {return flag(0, 1u<<14);}
136  void notify_drag_end(bool value) {flag(0, 1u<<14, value);}
137  bool all_events() const {return flag(0, 1u<<15);}
138  void all_events(bool value) {flag(0, 1u<<15,value);}
139  bool double_click_expands() const {return flag(0, 1u<<16);}
140  void double_click_expands(bool value) {flag(0, 1u<<16,value);}
141  bool flat_mode() const {return flag(0, 1u<<17);}
142  void flat_mode(bool value) {flag(0, 1u<<17,value);}
143  bool text_below_sprite() const {return flag(0, 1u<<18);}
144  void text_below_sprite(bool value) {flag(0, 1u<<18,value);}
145  bool sort_display() const {return flag(0, 1u<<19);}
146  void sort_display(bool value) {flag(0, 1u<<19,value);}
147  bool sort_reversed() const {return flag(0, 1u<<20);}
148  void sort_reversed(bool value) {flag(0, 1u<<20,value);}
149  bool sort_by_sprite() const {return flag(0, 1u<<21);}
150  void sort_by_sprite(bool value) {flag(0, 1u<<21,value);}
156  int foreground() const {return flag_value(36,0xF);}
162  void foreground(int value) {flag_value(36,0xF,value);}
168  int background() const {return flag_value(36,0xF0)>>4;}
174  void background(int value) {flag_value(36,0xF0, value<<4);}
180  int linecolour() const {return flag_value(36,0xF00)>>8;}
186  void linecolour(int value) {flag_value(36,0xF00, value<<8);}
192  int version() const {return byte_value(39);}
198  void version(int value) {byte_value(39, value);}
199 
200  unsigned int vertical_spacing() const {return uint_value(40);}
201  void vertical_spacing(unsigned int value) {return uint_value(40,value);}
202  unsigned int horizontal_spacing() const {return uint_value(44);}
203  void horizontal_spacing(unsigned int value) {return uint_value(44,value);}
204 };
205 
206 }
207 }
208 }
209 
210 #endif // TBX_RES_RESTREEVIEW_H
211 
tbx::res::ResBase::operator=
ResBase & operator=(const ResBase &other)
Assignment.
Definition: resbase.cc:1534
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::ext::res::ResTreeView::ResTreeView
ResTreeView(const ResTreeView &other)
Construct a tree view gadget resource.
Definition: restreeview.h:59
tbx::ext::res::ResTreeView::version
int version() const
Get tree view version.
Definition: restreeview.h:192
tbx::ext::res::ResTreeView::background
void background(int value)
Set background colour for the Tabs.
Definition: restreeview.h:174
tbx::ext::res::ResTreeView::background
int background() const
Get background colour for the Tabs.
Definition: restreeview.h:168
tbx::res::ResGadget
Base class for gadget memory resources.
Definition: resgadget.h:43
tbx::res::ResBase::byte_value
unsigned char byte_value(int offset) const
Get a byte value.
Definition: resbase.h:333
tbx::ext::res::ResTreeView
Class for Tabs gadget template.
Definition: restreeview.h:38
tbx::ext::res::ResTreeView::foreground
int foreground() const
Get foreground/text colour for the Tabs.
Definition: restreeview.h:156
tbx::res::ResGadget::flags
unsigned int flags() const
Get all flags as a word raw access.
Definition: resgadget.h:102
tbx::ext::res::ResTreeView::operator=
ResTreeView & operator=(const tbx::res::ResGadget &other)
Assign from a ResGadget.
Definition: restreeview.h:71
tbx::ext::res::ResTreeView::version
void version(int value)
Set tree view version.
Definition: restreeview.h:198
tbx::res::ResGadget::ResGadget
ResGadget(const ResGadget &other)
Construct a resource gadget as a copy of another.
Definition: resgadget.h:59
tbx::res::ResBase::flag_value
int flag_value(int offset, int mask) const
Get the bits for the given mask.
Definition: resbase.h:362
tbx::res::ResBase::flag
bool flag(int offset, int mask) const
Check if any of the bits in a mask are set.
Definition: resbase.h:352
tbx::res::ResBase::uint_value
unsigned int uint_value(int offset) const
Get an unsigned integer value.
Definition: resbase.h:324
tbx::ext::res::ResTreeView::foreground
void foreground(int value)
Set foreground/text colour for the Tabs.
Definition: restreeview.h:162
tbx::ext::res::ResTreeView::linecolour
int linecolour() const
Get linecolour colour for the Tabs.
Definition: restreeview.h:180
tbx::ext::res::ResTreeView::ResTreeView
ResTreeView()
Construct a tree view gadget resource.
Definition: restreeview.h:94
tbx::ext::res::ResTreeView::operator=
ResTreeView & operator=(const ResTreeView &other)
Assign from another tree view gadget resource.
Definition: restreeview.h:83
tbx::ext::res::ResTreeView::ResTreeView
ResTreeView(const tbx::res::ResGadget &other)
Construct a tree view gadget resource.
Definition: restreeview.h:49
tbx::res::ResGadget::check_type
void check_type(int type) const
Check if this gadgets type is as specified.
Definition: reswindow.cc:97
tbx::ext::res::ResTreeView::linecolour
void linecolour(int value)
Set linecolour colour for the Tabs.
Definition: restreeview.h:186