]> git.saurik.com Git - wxWidgets.git/blob - utils/dialoged/src/edlist.cpp
don't crash when invalid colour is set as fg/bg colour
[wxWidgets.git] / utils / dialoged / src / edlist.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: edlist.cpp
3 // Purpose: Resource editor project management tree
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "edlist.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/wx.h"
25
26 #include "wx/checkbox.h"
27 #include "wx/button.h"
28 #include "wx/choice.h"
29 #include "wx/listbox.h"
30 #include "wx/radiobox.h"
31 #include "wx/statbox.h"
32 #include "wx/gauge.h"
33 #include "wx/slider.h"
34 #include "wx/textctrl.h"
35 #endif
36
37 #include "edlist.h"
38 #include "reseditr.h"
39
40 BEGIN_EVENT_TABLE(wxResourceEditorControlList, wxListCtrl)
41 END_EVENT_TABLE()
42
43 wxResourceEditorControlList::wxResourceEditorControlList(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
44 long style):
45 wxListCtrl(parent, id, pos, size, style), m_imageList(16, 16, TRUE)
46 {
47 Initialize();
48 }
49
50 wxResourceEditorControlList::~wxResourceEditorControlList()
51 {
52 SetImageList(NULL, wxIMAGE_LIST_SMALL);
53 }
54
55 // Load icons and add to the list
56 void wxResourceEditorControlList::Initialize()
57 {
58 #ifdef __WXMSW__
59 wxIcon icon1("ARROW_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
60 wxIcon icon2("BUTTON_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
61 wxIcon icon3("BMPBUTTON_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
62 wxIcon icon4("STATICTEXT_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
63 wxIcon icon5("STATICBMP_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
64 wxIcon icon6("STATICBOX_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
65 wxIcon icon7("TEXTSING_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
66 wxIcon icon8("TEXTMULT_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
67 wxIcon icon9("LISTBOX_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
68 wxIcon icon10("CHOICE_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
69 wxIcon icon11("COMBOBOX_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
70 wxIcon icon12("CHECKBOX_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
71 wxIcon icon13("SLIDER_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
72 wxIcon icon14("GAUGE_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
73 wxIcon icon15("RADIOBOX_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
74 wxIcon icon16("RADIOBTN_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
75 wxIcon icon17("SCROLBAR_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
76 #else
77
78 #include "bitmaps/arrow.xpm"
79 wxIcon icon1( arrow_xpm );
80 #include "bitmaps/button.xpm"
81 wxIcon icon2( button_xpm );
82 #include "bitmaps/bmpbuttn.xpm"
83 wxIcon icon3( bmpbuttn_xpm );
84 #include "bitmaps/stattext.xpm"
85 wxIcon icon4( stattext_xpm );
86 #include "bitmaps/statbmp.xpm"
87 wxIcon icon5( statbmp_xpm );
88 #include "bitmaps/statbox.xpm"
89 wxIcon icon6( statbox_xpm );
90 #include "bitmaps/textsing.xpm"
91 wxIcon icon7( textsing_xpm );
92 #include "bitmaps/textmult.xpm"
93 wxIcon icon8( textmult_xpm );
94 #include "bitmaps/listbox.xpm"
95 wxIcon icon9( listbox_xpm );
96 #include "bitmaps/choice.xpm"
97 wxIcon icon10( choice_xpm );
98 #include "bitmaps/combobox.xpm"
99 wxIcon icon11( combobox_xpm );
100 #include "bitmaps/checkbox.xpm"
101 wxIcon icon12( checkbox_xpm );
102 #include "bitmaps/slider.xpm"
103 wxIcon icon13( slider_xpm );
104 #include "bitmaps/gauge.xpm"
105 wxIcon icon14( gauge_xpm );
106 #include "bitmaps/radiobox.xpm"
107 wxIcon icon15( radiobox_xpm );
108 #include "bitmaps/radiobtn.xpm"
109 wxIcon icon16( radiobtn_xpm );
110 #include "bitmaps/scrolbar.xpm"
111 wxIcon icon17( scrolbar_xpm );
112 #endif
113
114 m_imageList.Add(icon1);
115 m_imageList.Add(icon2);
116 m_imageList.Add(icon3);
117 m_imageList.Add(icon4);
118 m_imageList.Add(icon5);
119 m_imageList.Add(icon6);
120 m_imageList.Add(icon7);
121 m_imageList.Add(icon8);
122 m_imageList.Add(icon9);
123 m_imageList.Add(icon10);
124 m_imageList.Add(icon11);
125 m_imageList.Add(icon12);
126 m_imageList.Add(icon13);
127 m_imageList.Add(icon14);
128 m_imageList.Add(icon15);
129 m_imageList.Add(icon16);
130 m_imageList.Add(icon17);
131
132 SetImageList(& m_imageList, wxIMAGE_LIST_SMALL);
133
134 long id = InsertItem(0, "Pointer", 0);
135 id = InsertItem(1, "wxButton", 1);
136 id = InsertItem(2, "wxBitmapButton", 2);
137 id = InsertItem(3, "wxStaticText", 3);
138 id = InsertItem(4, "wxStaticBitmap", 4);
139 id = InsertItem(5, "wxStaticBox", 5);
140 id = InsertItem(6, "wxTextCtrl", 6);
141 id = InsertItem(7, "wxTextCtrl", 7);
142 id = InsertItem(8, "wxListBox", 8);
143 id = InsertItem(9, "wxChoice", 9);
144 id = InsertItem(10, "wxComboBox", 10);
145 id = InsertItem(11, "wxCheckBox", 11);
146 id = InsertItem(12, "wxSlider", 12);
147 id = InsertItem(13, "wxGauge", 13);
148 id = InsertItem(14, "wxRadioBox", 14);
149 id = InsertItem(15, "wxRadioButton", 15);
150 id = InsertItem(16, "wxScrollBar", 16);
151
152 /*
153 InsertItem(RESED_TREECTRL, "wxTreeCtrl", 16);
154 InsertItem(RESED_LISTCTRL, "wxListCtrl", 17);
155 InsertItem(RESED_SPINBUTTON, "wxSpinButton", 18);
156 */
157
158 // SetColumnWidth(-1, 80);
159 }
160
161 // Get selection, or -1
162 long wxResourceEditorControlList::GetSelection() const
163 {
164 return GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
165 }
166
167