Ardour  9.0-pre0-582-g084a23a80d
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 #ifndef COMPILER_MSVC
27 #pragma GCC diagnostic push
28 #pragma GCC diagnostic ignored "-Wdeprecated-copy"
29 #include <glibmm.h>
30 #pragma GCC diagnostic pop
31 #else
32 #include <glibmm.h>
33 #endif
34 
35 namespace Gtk
36 {
37 
38 struct BuiltinStockID;
39 
42 class StockID
43 {
44 public:
47  StockID(); //TODO: This was added for Action::Action, but there might be a better way to do this.
48 
53  StockID(const BuiltinStockID& id);
54 
58  explicit StockID(const Glib::ustring& id);
59 
65  explicit StockID(const char* id);
67 
71  StockID(const StockID& other);
72 
76  StockID& operator=(const StockID& other);
77 
80  operator bool() const;
81 
87  bool equal(const StockID& rhs) const;
88 
93  Glib::ustring get_string() const;
94 
99  const char* get_c_str() const;
100 
101 protected:
102  Glib::ustring id_;
103 };
104 
106 inline bool operator==(const StockID& lhs, const StockID& rhs)
107  { return lhs.equal(rhs); }
108 
110 inline bool operator!=(const StockID& lhs, const StockID& rhs)
111  { return !lhs.equal(rhs); }
112 
113 
114 #ifndef DOXYGEN_SHOULD_SKIP_THIS
115 struct StockID_Traits : public Glib::Container_Helpers::TypeTraits<Glib::ustring>
116 {
117  typedef Gtk::StockID CppType;
118 
119  static const char* to_c_type(const StockID& id) { return id.get_c_str(); }
120  static StockID to_cpp_type(const char* str) { return StockID(str); }
121 };
122 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
123 
124 } // namespace Gtk
125 
126 
127 #ifndef DOXYGEN_SHOULD_SKIP_THIS
128 namespace Glib
129 {
130 
131 template <>
132 class Value<Gtk::StockID> : public Glib::ValueBase_String
133 {
134 public:
135  typedef Gtk::StockID CppType;
136 
137  void set(const Gtk::StockID& data) { set_cstring(data.get_c_str()); }
138  Gtk::StockID get() const { return Gtk::StockID(get_cstring()); }
139 };
140 
141 } // namespace Glib
142 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
143 
144 
145 #endif /* _GTKMM_STOCKID_H */
146 
StockID(const Glib::ustring &id)
Glib::ustring id_
Definition: stockid.h:102
bool equal(const StockID &rhs) const
StockID(const StockID &other)
bool operator!=(const StockID &lhs, const StockID &rhs)
Definition: stockid.h:110
bool operator==(const StockID &lhs, const StockID &rhs)
Definition: stockid.h:106
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