/[svn]/gigedit/trunk/src/gigedit/global.h
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/global.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3089 by schoenebeck, Sun Jan 15 19:18:39 2017 UTC revision 3155 by schoenebeck, Sun May 7 15:32:43 2017 UTC
# Line 24  Line 24 
24  # include <config.h>  # include <config.h>
25  #endif  #endif
26    
27    #include <cstring>
28    
29    #include <glibmmconfig.h>
30    // threads.h must be included first to be able to build with
31    // G_DISABLE_DEPRECATED
32    #if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \
33        (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2
34    #include <glibmm/threads.h>
35    #endif
36    
37  #if !defined(WIN32)  #if !defined(WIN32)
38  # include <unistd.h>  # include <unistd.h>
39  # include <errno.h>  # include <errno.h>
# Line 54  Line 64 
64    
65  #define UNICODE_RIGHT_ARROW     Glib::ustring(1, gunichar(0x2192))  #define UNICODE_RIGHT_ARROW     Glib::ustring(1, gunichar(0x2192))
66  #define UNICODE_LEFT_ARROW      Glib::ustring(1, gunichar(0x2190))  #define UNICODE_LEFT_ARROW      Glib::ustring(1, gunichar(0x2190))
67    #define UNICODE_SHIFT_KEY_SYMBOL    Glib::ustring("\xe2\x87\xa7")
68    #if defined(__APPLE__)
69    # define UNICODE_ALT_KEY_SYMBOL     Glib::ustring("\xe2\x8c\xa5")
70    #else
71    # define UNICODE_ALT_KEY_SYMBOL     Glib::ustring("Alt")
72    #endif
73    #define UNICODE_ERASE_KEY_SYMBOL    Glib::ustring("\xe2\x8c\xab")
74    #define UNICODE_CTRL_KEY_SYMBOL     Glib::ustring("Ctrl")
75    #define UNICODE_CMD_KEY_SYMBOL      Glib::ustring(1, gunichar(0x2318))
76    #if defined(__APPLE__)
77    # define UNICODE_PRIMARY_KEY_SYMBOL     UNICODE_CMD_KEY_SYMBOL
78    #else
79    # define UNICODE_PRIMARY_KEY_SYMBOL     UNICODE_CTRL_KEY_SYMBOL
80    #endif
81    
82    // taken from gdk/gdkkeysyms.h
83    // (define on demand, to avoid unnecessary dev lib package build dependency)
84    #ifndef GDK_KEY_Control_L
85    # define GDK_KEY_Control_L 0xffe3
86    #endif
87    #ifndef GDK_KEY_Control_R
88    # define GDK_KEY_Control_R 0xffe4
89    #endif
90    #ifndef GDK_KEY_Left
91    # define GDK_KEY_Left 0xff51
92    #endif
93    #ifndef GDK_KEY_Right
94    # define GDK_KEY_Right 0xff53
95    #endif
96    #ifndef GDK_KEY_Up
97    # define GDK_KEY_Up 0xff52
98    #endif
99    #ifndef GDK_KEY_Down
100    # define GDK_KEY_Down 0xff54
101    #endif
102    
103    #include <glibmm/convert.h>
104    
105    #define GIG_STR_ENCODING "CP1252"
106    
107    static inline
108    Glib::ustring gig_to_utf8(const gig::String& gig_string) {
109        return Glib::convert_with_fallback(gig_string, "UTF-8", GIG_STR_ENCODING, "?");
110    }
111    
112    static inline
113    gig::String gig_from_utf8(const Glib::ustring& utf8_string) {
114        return Glib::convert_with_fallback(utf8_string, GIG_STR_ENCODING, "UTF-8", "?");
115    }
116    
117  template<class T> inline std::string ToString(T o) {  template<class T> inline std::string ToString(T o) {
118      std::stringstream ss;      std::stringstream ss;
# Line 115  public: Line 174  public:
174          }          }
175          return false;          return false;
176      }      }
177    
178        // prevent passing gig::dimension_none from creating a new pair
179        // (TODO: other invalid gig::dimension_t values should be filtered here as well)
180        int& operator[](const gig::dimension_t& k) {
181            static int unused = 0;
182            if (k == gig::dimension_none) {
183                unused = 0;
184                return unused;
185            }
186            return std::map<gig::dimension_t,int>::operator[](k);
187        }
188  };  };
189    
190    //TODO: this function and caseOfDimRegion() from dimregionchooser.h are duplicates, eliminate either one of them!
191  inline DimensionCase dimensionCaseOf(gig::DimensionRegion* dr) {  inline DimensionCase dimensionCaseOf(gig::DimensionRegion* dr) {
192      DimensionCase dimCase;      DimensionCase dimCase;
193      int idr = getDimensionRegionIndex(dr);      int idr = getDimensionRegionIndex(dr);
# Line 142  inline std::vector<gig::DimensionRegion* Line 213  inline std::vector<gig::DimensionRegion*
213      return v;      return v;
214  }  }
215    
216    inline gig::DimensionRegion* dimensionRegionMatching(const DimensionCase& dimCase, gig::Region* rgn) {
217        for (int idr = 0; idr < 256; ++idr) {
218            if (!rgn->pDimensionRegions[idr]) continue;
219            DimensionCase c = dimensionCaseOf(rgn->pDimensionRegions[idr]);
220            if (c == dimCase) return rgn->pDimensionRegions[idr];
221        }
222        return NULL;
223    }
224    
225  #endif // GIGEDIT_GLOBAL_H  #endif // GIGEDIT_GLOBAL_H

Legend:
Removed from v.3089  
changed lines
  Added in v.3155

  ViewVC Help
Powered by ViewVC