Debian Codegraph @

wxcrafter/top_level_windows/image_list_wrapper.cpp

raw
1 #include "image_list_wrapper.h"
2
3 #include "allocator_mgr.h"
4 #include "bool_property.h"
5 #include "category_property.h"
6 #include "int_property.h"
7 #include "virtual_folder_property.h"
8
9 ImageListWrapper::ImageListWrapper()
10 : TopLevelWinWrapper(ID_WXIMAGELIST)
11 {
12 m_properties.DeleteValues();
13 m_styles.Clear();
14 m_sizerFlags.Clear();
15
16 SetPropertyString(_("Common Settings"), "wxImageList");
17 AddProperty(new CategoryProperty(_("Inherited C++ Class Properties")));
18 AddProperty(new StringProperty(PROP_NAME, "", _("The generated C++ class name")));
19 AddProperty(new StringProperty(PROP_FILE, "", _("The filenames for the generated files")));
20 AddProperty(
21 new VirtualFolderProperty(PROP_VIRTUAL_FOLDER, "", _("codelite's virtual folder for the generated files")));
22 AddProperty(new StringProperty(PROP_CLASS_DECORATOR, "",
23 _("MSW Only\nC++ macro decorator - allows exporting this class from a DLL")));
24 AddProperty(new CategoryProperty(_("wxImageList")));
25 AddProperty(new IntProperty(PROP_BITMAP_SIZE, 16, _("The bitmaps size")));
26 AddProperty(new BoolProperty(PROP_IMGLIST_MASK, true, _("True if masks should be created for all images")));
27 }
28
29 ImageListWrapper::~ImageListWrapper() {}
30
31 wxcWidget* ImageListWrapper::Clone() const { return new ImageListWrapper(); }
32
33 wxString ImageListWrapper::BaseCtorDecl() const
34 {
35 wxString code;
36 code << " " << CreateBaseclassName() << "();\n";
37 code << " const wxBitmap& Bitmap(const wxString &name) const {\n"
38 << " if ( !m_bitmaps.count(name + m_resolution) )\n"
39 << " return wxNullBitmap;\n"
40 << " return m_bitmaps.find(name + m_resolution)->second;\n"
41 << " }\n\n";
42
43 code << " void SetBitmapResolution(const wxString &res = wxEmptyString) {\n"
44 << " m_resolution = res;\n"
45 << " }\n\n";
46
47 return code;
48 }
49
50 wxString ImageListWrapper::BaseCtorImplPrefix() const
51 {
52 wxString code;
53
54 code << CreateBaseclassName() << "::" << CreateBaseclassName() << "()\n";
55 code << " : " << GetRealClassName() << "(" << PropertyInt(PROP_BITMAP_SIZE) << ", "
56 << PropertyInt(PROP_BITMAP_SIZE) << ", " << PropertyBool(PROP_IMGLIST_MASK) << ")\n"
57 << " , m_imagesWidth(" << PropertyInt(PROP_BITMAP_SIZE) << ")\n"
58 << " , m_imagesHeight(" << PropertyInt(PROP_BITMAP_SIZE) << ")\n";
59 return code;
60 }
61
62 wxString ImageListWrapper::DesignerXRC(bool forPreviewDialog) const
63 {
64 wxUnusedVar(forPreviewDialog);
65 wxString text;
66 text << "<object class=\"wxPanel\" name=\"PreviewPanel\">"
67 << "<size>-1,-1</size>"
68 // Fake a sizer
69 << "<object class=\"wxBoxSizer\">"
70 << "<orient>wxVERTICAL</orient>";
71
72 ChildrenXRC(text, XRC_DESIGNER);
73 text << "</object>" // wxBoxSizer
74 << "</object>"; // PreviewPanel
75
76 WrapXRC(text);
77 return text;
78 }
79
80 wxString ImageListWrapper::CppCtorCode() const { return ""; }
81
82 void ImageListWrapper::GetIncludeFile(wxArrayString& headers) const
83 {
84 headers.Add("#include <wx/imaglist.h>");
85 headers.Add("#include <wx/bitmap.h>");
86 headers.Add("#include <wx/artprov.h>");
87 headers.Add("#include <map>");
88 }
89
90 wxString ImageListWrapper::DoGenerateClassMember() const
91 {
92 wxString memberCode;
93 memberCode << " // Maintain a map of all bitmaps representd by their name\n";
94 memberCode << " std::map<wxString, wxBitmap> m_bitmaps;\n";
95 memberCode
96 << " // The requested image resolution (can be one of @2x, @1.5x, @1.25x or an empty string (the default)\n";
97 memberCode << " wxString m_resolution;\n";
98 memberCode << " int m_imagesWidth;\n";
99 memberCode << " int m_imagesHeight;\n";
100 return memberCode;
101 }
102
103 wxString ImageListWrapper::GetWxClassName() const { return "wxImageList"; }
104
105 void ImageListWrapper::ToXRC(wxString& text, XRC_TYPE type) const
106 {
107 if(type == XRC_DESIGNER) {
108 ChildrenXRC(text, type);
109 WrapXRC(text);
110 }
111 }