diff options
author | Ian C <ianc@noddybox.co.uk> | 2005-03-22 01:43:54 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2005-03-22 01:43:54 +0000 |
commit | 0f8dbe3295b88c7f3fea8d2219a6b0fe895f2250 (patch) | |
tree | ae69ecbcfaf87f2f238142a884b5b9d574e5011f /src/w32dlib/control.h | |
parent | 1716bfab9f2e710dfa205e279986f9e29d85dddf (diff) |
Initial checkin
Diffstat (limited to 'src/w32dlib/control.h')
-rw-r--r-- | src/w32dlib/control.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/src/w32dlib/control.h b/src/w32dlib/control.h new file mode 100644 index 0000000..bd1d39c --- /dev/null +++ b/src/w32dlib/control.h @@ -0,0 +1,111 @@ +// 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 +// +// ------------------------------------------------------------------------- +// +#ifndef W32DLIB_CONTROL_H + +#define W32DLIB_CONTROL_H "$Id$" + +#include "w32dlib/base.h" + +namespace W32DLib +{ + + /// \brief Defines a callback. + /// + /// Return TRUE if the message was handled. + /// + typedef BOOL (*W32DLibCallback)(UINT msg, WPARAM wp, LPARAM lp); + + /// \brief The base Control class. + /// + class Control + { + public: + + /// \brief Constructor + /// + /// \param parent The Dialog the control belongs to. + /// \param resource_id The ID of the control in the resource file. + /// + Control(Dialog *parent, int resource_id); + + /// \brief Destructor + /// + virtual ~Control(); + + /// \brief Returns the Resource ID for the control. + /// + int ResourceID(); + + /// \brief Sets the text in a control + /// + /// \param text The control's text + /// \sa GetText() + /// + void SetText(const char *text); + + /// \brief Gets the text in a control + /// + /// \param maxlen The maximum length to fetch + /// \return The control's text + /// \sa SetText() + /// + std::string GetText(int maxlen); + + /// \brief Processes a windows event. + /// + /// \param msg The Windows event parameters + /// \param wp The Windows event parameters + /// \param lp The Windows event parameters + /// \return True if the message was processed. + /// + BOOL ProcessMessage(UINT msg, WPARAM wp, LPARAM lp); + + protected: + + /// \brief Add or remove a callback for the control. + /// + /// \param msg The Windows event message to respond to. + /// \param callback The callback. Pass NULL to remove the callback. + /// + void AddCallback(UINT msg, W32DLibCallback callback); + + /// \brief Filled in by the constructor with the parent dialog. + /// + Dialog *m_parent; + + /// \brief Filled in by the constructor with the resource ID. + /// + int m_resid; + + private: + + typedef std::map<UINT,W32DLibCallback> CallbackList; + + CallbackList m_cblist; + + }; // class Control + +}; // namespace w32dlib + +#endif // W32DLIB_CONTROL_H + + +// END OF FILE |