summaryrefslogtreecommitdiff
path: root/src/combobox.cpp
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-03-28 01:42:58 +0000
committerIan C <ianc@noddybox.co.uk>2005-03-28 01:42:58 +0000
commit82f1d860690dc0a2d0210db12344f7ea5e88b6a4 (patch)
tree517481a81e64cc70b5187ce6eeb20d8fa326fa54 /src/combobox.cpp
parent4f54380eb1f7574bf9cc147cb8870508da09e10c (diff)
Added ComboBox. Also improved callback filtering and made controls auto register themselves.
Diffstat (limited to 'src/combobox.cpp')
-rw-r--r--src/combobox.cpp170
1 files changed, 170 insertions, 0 deletions
diff --git a/src/combobox.cpp b/src/combobox.cpp
new file mode 100644
index 0000000..9f1108e
--- /dev/null
+++ b/src/combobox.cpp
@@ -0,0 +1,170 @@
+// w32dlib - Win32 Control Helpers
+//
+// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk)
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// -------------------------------------------------------------------------
+//
+#include "w32dlib/window.h"
+#include "w32dlib/combobox.h"
+
+namespace W32DLib
+{
+
+// ------------------------------------------------------------
+//
+ComboBox::ComboBox(Dialog *parent, int resource_id) :
+ Control(parent,resource_id)
+{
+}
+
+
+// ------------------------------------------------------------
+//
+ComboBox::~ComboBox()
+{
+}
+
+
+// ------------------------------------------------------------
+//
+void ComboBox::OnSelection(Window *owner, W32DLibCallback callback)
+{
+ Control::AddCallback(WM_COMMAND,CBN_SELCHANGE,owner,callback);
+}
+
+
+// ------------------------------------------------------------
+//
+void ComboBox::OnDoubleClick(Window *owner, W32DLibCallback callback)
+{
+ Control::AddCallback(WM_COMMAND,CBN_DBLCLK,owner,callback);
+}
+
+
+// ------------------------------------------------------------
+//
+void ComboBox::OnTextChanged(Window *owner, W32DLibCallback callback)
+{
+ Control::AddCallback(WM_COMMAND,CBN_EDITCHANGE,owner,callback);
+}
+
+
+// ------------------------------------------------------------
+//
+void ComboBox::Reset()
+{
+ SendMsg(CB_RESETCONTENT,0,0);
+}
+
+
+// ------------------------------------------------------------
+//
+void ComboBox::MaxLen(int count)
+{
+ SendMsg(CB_LIMITTEXT,count,0);
+}
+
+
+// ------------------------------------------------------------
+//
+int ComboBox::Count()
+{
+ return SendMsg(CB_GETCOUNT,0,0);
+}
+
+
+// ------------------------------------------------------------
+//
+int ComboBox::AddString(const char *text)
+{
+ return SendMsg(CB_ADDSTRING,0,reinterpret_cast<LPARAM>(text));
+}
+
+
+// ------------------------------------------------------------
+//
+int ComboBox::AddString(const char *text, int index)
+{
+ return SendMsg(CB_INSERTSTRING,index,reinterpret_cast<LPARAM>(text));
+}
+
+
+// ------------------------------------------------------------
+//
+int ComboBox::RemoveString(int index)
+{
+ return SendMsg(CB_DELETESTRING,index,0);
+}
+
+
+// ------------------------------------------------------------
+//
+std::string ComboBox::GetString(int index)
+{
+ std::string result;
+ LRESULT len=SendMsg(CB_GETLBTEXTLEN,index,0);
+
+ if (len!=CB_ERR)
+ {
+ char *text=new char[len+1];
+
+ SendMsg(CB_GETLBTEXT,index,reinterpret_cast<LPARAM>(text));
+
+ result=text;
+
+ delete[] text;
+ }
+
+ return result;
+}
+
+
+// ------------------------------------------------------------
+//
+int ComboBox::TopRowIndex()
+{
+ return SendMsg(CB_GETTOPINDEX,0,0);
+}
+
+
+// ------------------------------------------------------------
+//
+void ComboBox::TopRowIndex(int index)
+{
+ SendMsg(CB_SETTOPINDEX,index,0);
+}
+
+
+// ------------------------------------------------------------
+//
+int ComboBox::SelectedIndex()
+{
+ return SendMsg(CB_GETCURSEL,0,0);
+}
+
+
+// ------------------------------------------------------------
+//
+void ComboBox::SelectedIndex(int index)
+{
+ SendMsg(CB_SETCURSEL,index,0);
+}
+
+
+}; // namespace W32DLib
+
+// END OF FILE