debian: made the changelog more verbose as per intrigeri's feedback
[barry.git] / desktop / src / util.h
blob6215ea15f6afa864f00bb65065f492739250f5e6
1 ///
2 /// \file util.h
3 /// Utility functions specific to Barry Desktop
4 ///
6 /*
7 Copyright (C) 2009-2012, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRYDESKTOP_UTIL_H__
23 #define __BARRYDESKTOP_UTIL_H__
25 #include <wx/wx.h>
26 #include <barry/barry.h>
28 #define BUTTON_STATE_NORMAL 0
29 #define BUTTON_STATE_FOCUS 1
30 #define BUTTON_STATE_PUSHED 2
32 template <class IteratorT, class StrFn>
33 int GetMaxWidth(wxWindow *win, IteratorT begin, IteratorT end, StrFn sfn)
35 int max_width = 0;
36 for( ; begin != end(); ++begin ) {
37 int this_width = 0;
38 int this_height = 0;
39 win->GetTextExtent(wxString(sfn(*begin).c_str(), wxConvUTF8),
40 &this_width, &this_height);
42 max_width = std::max(max_width, this_width);
45 return max_width;
48 std::string GetBaseFilename(const std::string &filename);
49 wxString GetImageFilename(const wxString &filename);
50 wxString GetButtonFilename(int id, int state);
51 bool IsButtonEnabled(int id);
52 class wxDatePickerCtrl;
53 void MakeDateRecent(bool checked, wxDatePickerCtrl *picker);
55 bool IsParsable(const std::string &dbname);
56 bool IsBuildable(const std::string &dbname);
58 // Determine parsable classes via template specialization
59 template <class RecordT>
60 inline bool IsParsable()
62 return false;
64 #undef HANDLE_PARSER
65 #define HANDLE_PARSER(dbname) \
66 template <> \
67 inline bool IsParsable<Barry::dbname>() \
68 { \
69 return true; \
71 ALL_KNOWN_PARSER_TYPES
73 // Determine buildable classes via template specialization
74 template <class RecordT>
75 inline bool IsBuildable()
77 return false;
79 #undef HANDLE_BUILDER
80 #define HANDLE_BUILDER(dbname) \
81 template <> \
82 inline bool IsBuildable<Barry::dbname>() \
83 { \
84 return true; \
86 ALL_KNOWN_BUILDER_TYPES
88 #endif