| 1 | /* |
|---|
| 2 | ----------------------------------------------------------------------------- |
|---|
| 3 | This source file is part of LEXIExporter |
|---|
| 4 | |
|---|
| 5 | Copyright 2006 NDS Limited |
|---|
| 6 | |
|---|
| 7 | Author(s): |
|---|
| 8 | Bo Krohn |
|---|
| 9 | |
|---|
| 10 | This program is free software; you can redistribute it and/or modify it under |
|---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software |
|---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later |
|---|
| 13 | version. |
|---|
| 14 | |
|---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
|---|
| 18 | |
|---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with |
|---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
|---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
|---|
| 22 | http://www.gnu.org/copyleft/lesser.txt. |
|---|
| 23 | ----------------------------------------------------------------------------- |
|---|
| 24 | */ |
|---|
| 25 | |
|---|
| 26 | ///////////////////////////////////////////////// |
|---|
| 27 | // |
|---|
| 28 | // Max Exporter - GDI ComboBox |
|---|
| 29 | // |
|---|
| 30 | ///////////////////////////////////////////////// |
|---|
| 31 | |
|---|
| 32 | #include "stdafx.h" |
|---|
| 33 | |
|---|
| 34 | // |
|---|
| 35 | |
|---|
| 36 | namespace GDI { |
|---|
| 37 | |
|---|
| 38 | // |
|---|
| 39 | |
|---|
| 40 | ComboBox::ComboBox() |
|---|
| 41 | { |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | ComboBox::~ComboBox() |
|---|
| 45 | { |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | // |
|---|
| 49 | |
|---|
| 50 | void ComboBox::Clear() |
|---|
| 51 | { |
|---|
| 52 | SendMessage(WM_CLEAR, 0, 0); |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | // |
|---|
| 56 | |
|---|
| 57 | void ComboBox::Copy() |
|---|
| 58 | { |
|---|
| 59 | SendMessage(WM_COPY, 0, 0); |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | // |
|---|
| 63 | |
|---|
| 64 | void ComboBox::Cut() |
|---|
| 65 | { |
|---|
| 66 | SendMessage(WM_CUT, 0, 0); |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | // |
|---|
| 70 | |
|---|
| 71 | bool ComboBox::GetComboBoxInfo(COMBOBOXINFO* pCBI) const |
|---|
| 72 | { |
|---|
| 73 | return ::GetComboBoxInfo(m_hWnd, pCBI) ? true : false; |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | // |
|---|
| 77 | |
|---|
| 78 | unsigned int ComboBox::GetCount() const |
|---|
| 79 | { |
|---|
| 80 | return (unsigned int)SendMessage(CB_GETCOUNT, 0, 0); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | // |
|---|
| 84 | |
|---|
| 85 | int ComboBox::GetCurSel() const |
|---|
| 86 | { |
|---|
| 87 | return (int)SendMessage(CB_GETCURSEL, 0, 0); |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | // |
|---|
| 91 | |
|---|
| 92 | void ComboBox::GetDroppedControlRect(RECT* pRect) const |
|---|
| 93 | { |
|---|
| 94 | SendMessage(CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)pRect); |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | // |
|---|
| 98 | |
|---|
| 99 | bool ComboBox::GetDroppedState() const |
|---|
| 100 | { |
|---|
| 101 | return SendMessage(CB_GETDROPPEDSTATE, 0, 0) ? true : false; |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | // |
|---|
| 105 | |
|---|
| 106 | unsigned int ComboBox::GetDroppedWidth() const |
|---|
| 107 | { |
|---|
| 108 | return (unsigned int)SendMessage(CB_GETDROPPEDWIDTH, 0, 0); |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | // |
|---|
| 112 | |
|---|
| 113 | unsigned int ComboBox::GetEditSel() const |
|---|
| 114 | { |
|---|
| 115 | return (unsigned int)SendMessage(CB_GETEDITSEL, 0, 0); |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | // |
|---|
| 119 | |
|---|
| 120 | bool ComboBox::GetExtendedUI() const |
|---|
| 121 | { |
|---|
| 122 | return SendMessage(CB_GETEXTENDEDUI, 0, 0) ? true : false; |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | // |
|---|
| 126 | |
|---|
| 127 | unsigned int ComboBox::GetHorizontalExtent() const |
|---|
| 128 | { |
|---|
| 129 | return (unsigned int)SendMessage(CB_GETHORIZONTALEXTENT, 0, 0); |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | // |
|---|
| 133 | |
|---|
| 134 | DWORD_PTR ComboBox::GetItemData(int iIndex) const |
|---|
| 135 | { |
|---|
| 136 | return SendMessage(CB_GETITEMDATA, iIndex, 0); |
|---|
| 137 | } |
|---|
| 138 | |
|---|
| 139 | // |
|---|
| 140 | |
|---|
| 141 | void* ComboBox::GetItemDataPtr(int iIndex) const |
|---|
| 142 | { |
|---|
| 143 | return (void*)GetItemData(iIndex); |
|---|
| 144 | } |
|---|
| 145 | |
|---|
| 146 | // |
|---|
| 147 | |
|---|
| 148 | unsigned int ComboBox::GetItemHeight(int iIndex) const |
|---|
| 149 | { |
|---|
| 150 | return (unsigned int)SendMessage(CB_GETITEMHEIGHT, iIndex, 0L); |
|---|
| 151 | } |
|---|
| 152 | |
|---|
| 153 | // |
|---|
| 154 | |
|---|
| 155 | unsigned int ComboBox::GetLBText(int iIndex, char* pszText) const |
|---|
| 156 | { |
|---|
| 157 | return (unsigned int)SendMessage(CB_GETLBTEXT, iIndex, (LPARAM)pszText); |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | void ComboBox::GetLBText(int iIndex, std::string& sString) const |
|---|
| 161 | { |
|---|
| 162 | char text[4096]; |
|---|
| 163 | GetLBText(iIndex, text); |
|---|
| 164 | sString = text; |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | // |
|---|
| 168 | |
|---|
| 169 | unsigned int ComboBox::GetLBTextLen(int iIndex) const |
|---|
| 170 | { |
|---|
| 171 | return (unsigned int)SendMessage(CB_GETLBTEXTLEN, iIndex, 0); |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | // |
|---|
| 175 | |
|---|
| 176 | LCID ComboBox::GetLocale() const |
|---|
| 177 | { |
|---|
| 178 | return (LCID)SendMessage(CB_GETLOCALE, 0, 0); |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | // |
|---|
| 182 | |
|---|
| 183 | int ComboBox::GetTopIndex() const |
|---|
| 184 | { |
|---|
| 185 | return (int)SendMessage(CB_GETTOPINDEX, 0, 0); |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | // |
|---|
| 189 | |
|---|
| 190 | bool ComboBox::LimitText(unsigned int iMaxChars) |
|---|
| 191 | { |
|---|
| 192 | return SendMessage(CB_LIMITTEXT, iMaxChars, 0) ? true : false; |
|---|
| 193 | } |
|---|
| 194 | |
|---|
| 195 | // |
|---|
| 196 | |
|---|
| 197 | void ComboBox::Paste() |
|---|
| 198 | { |
|---|
| 199 | SendMessage(WM_PASTE, 0, 0); |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | // |
|---|
| 203 | |
|---|
| 204 | unsigned int ComboBox::SetCurSel(int iSelect) |
|---|
| 205 | { |
|---|
| 206 | return (unsigned int)SendMessage(CB_SETCURSEL, iSelect, 0); |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | // |
|---|
| 210 | |
|---|
| 211 | unsigned int ComboBox::SetDroppedWidth(unsigned int iWidth) |
|---|
| 212 | { |
|---|
| 213 | return (unsigned int)SendMessage(CB_SETDROPPEDWIDTH, iWidth, 0); |
|---|
| 214 | } |
|---|
| 215 | |
|---|
| 216 | // |
|---|
| 217 | |
|---|
| 218 | bool ComboBox::SetEditSel(int iStartChar, int iEndChar) |
|---|
| 219 | { |
|---|
| 220 | return SendMessage(CB_SETEDITSEL, 0, MAKELONG(iStartChar, iEndChar)) ? true : false; |
|---|
| 221 | } |
|---|
| 222 | |
|---|
| 223 | // |
|---|
| 224 | |
|---|
| 225 | bool ComboBox::SetExtendedUI(bool bExtended) |
|---|
| 226 | { |
|---|
| 227 | return SendMessage(CB_SETEXTENDEDUI, bExtended, 0) != CB_ERR ? true : false; |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | // |
|---|
| 231 | |
|---|
| 232 | void ComboBox::SetHorizontalExtent(unsigned int iExtent) |
|---|
| 233 | { |
|---|
| 234 | SendMessage(CB_SETHORIZONTALEXTENT, iExtent, 0); |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | // |
|---|
| 238 | |
|---|
| 239 | bool ComboBox::SetItemData(int iIndex, DWORD_PTR dwItemData) |
|---|
| 240 | { |
|---|
| 241 | return SendMessage(CB_SETITEMDATA, iIndex, (LPARAM)dwItemData) != CB_ERR ? true : false; |
|---|
| 242 | } |
|---|
| 243 | |
|---|
| 244 | // |
|---|
| 245 | |
|---|
| 246 | bool ComboBox::SetItemDataPtr(int iIndex, void* pData) |
|---|
| 247 | { |
|---|
| 248 | return SetItemData(iIndex, (DWORD_PTR)pData); |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 251 | // |
|---|
| 252 | |
|---|
| 253 | bool ComboBox::SetItemHeight(int iIndex, unsigned int iItemHeight) |
|---|
| 254 | { |
|---|
| 255 | return SendMessage(CB_SETITEMHEIGHT, iIndex, MAKELONG(iItemHeight, 0)) != CB_ERR ? true : false; |
|---|
| 256 | } |
|---|
| 257 | |
|---|
| 258 | // |
|---|
| 259 | |
|---|
| 260 | LCID ComboBox::SetLocale(LCID nNewLocale) |
|---|
| 261 | { |
|---|
| 262 | return (LCID)SendMessage(CB_SETLOCALE, (WPARAM)nNewLocale, 0); |
|---|
| 263 | } |
|---|
| 264 | |
|---|
| 265 | // |
|---|
| 266 | |
|---|
| 267 | bool ComboBox::SetTopIndex(int iIndex) |
|---|
| 268 | { |
|---|
| 269 | return SendMessage(CB_SETTOPINDEX, iIndex, 0) != CB_ERR ? true : false; |
|---|
| 270 | } |
|---|
| 271 | |
|---|
| 272 | // |
|---|
| 273 | |
|---|
| 274 | void ComboBox::ShowDropDown(bool bShowIt) |
|---|
| 275 | { |
|---|
| 276 | SendMessage(CB_SHOWDROPDOWN, bShowIt, 0); |
|---|
| 277 | } |
|---|
| 278 | |
|---|
| 279 | // |
|---|
| 280 | |
|---|
| 281 | int ComboBox::AddString(const char* pszString) |
|---|
| 282 | { |
|---|
| 283 | return (int)SendMessage(CB_ADDSTRING, 0, (LPARAM)pszString); |
|---|
| 284 | } |
|---|
| 285 | |
|---|
| 286 | // |
|---|
| 287 | |
|---|
| 288 | int ComboBox::DeleteString(int iIndex) |
|---|
| 289 | { |
|---|
| 290 | return (int)SendMessage(CB_DELETESTRING, iIndex, 0); |
|---|
| 291 | } |
|---|
| 292 | |
|---|
| 293 | // |
|---|
| 294 | |
|---|
| 295 | int ComboBox::Dir(unsigned int attr, const char* pszWildCard) |
|---|
| 296 | { |
|---|
| 297 | return (int)SendMessage(CB_DIR, attr, (LPARAM)pszWildCard); |
|---|
| 298 | } |
|---|
| 299 | |
|---|
| 300 | // |
|---|
| 301 | |
|---|
| 302 | int ComboBox::FindString(int iStartAfter, const char* pszString) const |
|---|
| 303 | { |
|---|
| 304 | return (int)SendMessage(CB_FINDSTRING, iStartAfter, (LPARAM)pszString); |
|---|
| 305 | } |
|---|
| 306 | |
|---|
| 307 | // |
|---|
| 308 | |
|---|
| 309 | int ComboBox::FindStringExact(int iIndexStart, const char* pszFind) const |
|---|
| 310 | { |
|---|
| 311 | return (int)SendMessage(CB_FINDSTRINGEXACT, iIndexStart, (LPARAM)pszFind); |
|---|
| 312 | } |
|---|
| 313 | |
|---|
| 314 | // |
|---|
| 315 | |
|---|
| 316 | int ComboBox::InsertString(int iIndex, const char* pszString) |
|---|
| 317 | { |
|---|
| 318 | return (int)SendMessage(CB_INSERTSTRING, iIndex, (LPARAM)pszString); |
|---|
| 319 | } |
|---|
| 320 | |
|---|
| 321 | // |
|---|
| 322 | |
|---|
| 323 | void ComboBox::ResetContent() |
|---|
| 324 | { |
|---|
| 325 | SendMessage(CB_RESETCONTENT, 0, 0); |
|---|
| 326 | } |
|---|
| 327 | |
|---|
| 328 | // |
|---|
| 329 | |
|---|
| 330 | int ComboBox::SelectString(int iStartAfter, const char* pszString) |
|---|
| 331 | { |
|---|
| 332 | return (int)SendMessage(CB_SELECTSTRING, iStartAfter, (LPARAM)pszString); |
|---|
| 333 | } |
|---|
| 334 | |
|---|
| 335 | // |
|---|
| 336 | |
|---|
| 337 | } // namespace GDI |
|---|
| 338 | |
|---|
| 339 | // |
|---|
| 340 | |
|---|