Ardour  8.7-14-g57a6773833
stockid.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 #ifndef _GTKMM_STOCKID_H
3 #define _GTKMM_STOCKID_H
4 
5 /* $Id$ */
6 
7 /* stockid.h
8  *
9  * Copyright (C) 2002 The gtkmm Development Team
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free
23  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25 
26 #pragma GCC diagnostic push
27 #pragma GCC diagnostic ignored "-Wdeprecated-copy"
28 #include <glibmm.h>
29 #pragma GCC diagnostic pop
30 
31 namespace Gtk
32 {
33 
34 struct BuiltinStockID;
35 
38 class StockID
39 {
40 public:
43  StockID(); //TODO: This was added for Action::Action, but there might be a better way to do this.
44 
49  StockID(const BuiltinStockID& id);
50 
54  explicit StockID(const Glib::ustring& id);
55 
61  explicit StockID(const char* id);
63 
67  StockID(const StockID& other);
68 
72  StockID& operator=(const StockID& other);
73 
76  operator bool() const;
77 
83  bool equal(const StockID& rhs) const;
84 
89  Glib::ustring get_string() const;
90 
95  const char* get_c_str() const;
96 
97 protected:
98  Glib::ustring id_;
99 };
100 
102 inline bool operator==(const StockID& lhs, const StockID& rhs)
103  { return lhs.equal(rhs); }
104 
106 inline bool operator!=(const StockID& lhs, const StockID& rhs)
107  { return !lhs.equal(rhs); }
108 
109 
110 #ifndef DOXYGEN_SHOULD_SKIP_THIS
111 struct StockID_Traits : public Glib::Container_Helpers::TypeTraits<Glib::ustring>
112 {
113  typedef Gtk::StockID CppType;
114 
115  static const char* to_c_type(const StockID& id) { return id.get_c_str(); }
116  static StockID to_cpp_type(const char* str) { return StockID(str); }
117 };
118 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
119 
120 } // namespace Gtk
121 
122 
123 #ifndef DOXYGEN_SHOULD_SKIP_THIS
124 namespace Glib
125 {
126 
127 template <>
128 class Value<Gtk::StockID> : public Glib::ValueBase_String
129 {
130 public:
131  typedef Gtk::StockID CppType;
132 
133  void set(const Gtk::StockID& data) { set_cstring(data.get_c_str()); }
134  Gtk::StockID get() const { return Gtk::StockID(get_cstring()); }
135 };
136 
137 } // namespace Glib
138 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
139 
140 
141 #endif /* _GTKMM_STOCKID_H */
142 
StockID(const Glib::ustring &id)
Glib::ustring id_
Definition: stockid.h:98
bool equal(const StockID &rhs) const
StockID(const StockID &other)
bool operator!=(const StockID &lhs, const StockID &rhs)
Definition: stockid.h:106
bool operator==(const StockID &lhs, const StockID &rhs)
Definition: stockid.h:102
const char * get_c_str() const
Glib::ustring get_string() const
StockID & operator=(const StockID &other)
StockID(const char *id)
StockID(const BuiltinStockID &id)
Definition: ardour_ui.h:188
Definition: lobject.h:100