diff options
-rw-r--r-- | INSTALL | 10 | ||||
-rw-r--r-- | LICENSE | 341 | ||||
-rw-r--r-- | doc/.cvsignore | 1 | ||||
-rw-r--r-- | src/GNUmakefile | 89 | ||||
-rw-r--r-- | src/autocheck.cpp | 74 | ||||
-rw-r--r-- | src/button.cpp | 55 | ||||
-rw-r--r-- | src/common.cpp | 112 | ||||
-rw-r--r-- | src/control.cpp | 118 | ||||
-rw-r--r-- | src/dialog.cpp | 153 | ||||
-rw-r--r-- | src/text.cpp | 45 | ||||
-rw-r--r-- | src/w32dlib/Doxyfile | 254 | ||||
-rw-r--r-- | src/w32dlib/autocheck.h | 92 | ||||
-rw-r--r-- | src/w32dlib/base.h | 39 | ||||
-rw-r--r-- | src/w32dlib/button.h | 65 | ||||
-rw-r--r-- | src/w32dlib/common.h | 110 | ||||
-rw-r--r-- | src/w32dlib/control.h | 111 | ||||
-rw-r--r-- | src/w32dlib/dialog.h | 128 | ||||
-rw-r--r-- | src/w32dlib/text.h | 59 | ||||
-rw-r--r-- | src/w32dlib/w32dlib.h | 34 |
19 files changed, 1890 insertions, 0 deletions
@@ -0,0 +1,10 @@ +This library is geared towards being compiled with MINGW, using MSYS and GNU +Make. + +Feel free to try it with other environments, but YMMV. + + + + +---------------------------------------------------------------------- +$Id: INSTALL,v 1.1 2005-03-22 01:43:54 ianc Exp $ @@ -0,0 +1,341 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) 19yy <name of author> + + 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 + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + diff --git a/doc/.cvsignore b/doc/.cvsignore new file mode 100644 index 0000000..724f4d4 --- /dev/null +++ b/doc/.cvsignore @@ -0,0 +1 @@ +html
\ No newline at end of file diff --git a/src/GNUmakefile b/src/GNUmakefile new file mode 100644 index 0000000..a1cbcfb --- /dev/null +++ b/src/GNUmakefile @@ -0,0 +1,89 @@ +# w32dlib - Win32 Dialog 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 +# +# ------------------------------------------------------------------------- +# +# $Id: GNUmakefile,v 1.1 2005-03-22 01:43:54 ianc Exp $ +# + + +# **************************************** START OF CONFIGURATION +# + +# The directory to install the built library, headers and docs into. +# *** NB: USE FORWARD SLASHES *** +# +INSTALLDIR = C:/w32dlib + +# Set this to one to generate a wd32lib-config and copy it to /usr/local/bin +# when installing. +# +CREATECONF = 1 + +# +# **************************************** END OF CONFIGURATION + + +# Do not change past here. +# Well, unless something doesn't work of course... +# +TARGET = w32dlib.a + +SOURCES = autocheck.cpp \ + button.cpp \ + common.cpp \ + control.cpp \ + dialog.cpp \ + text.cpp + +HEADERS = w32dlib/*.h + +OBJECTS = $(SOURCES:.cpp=.o) + +FLAGS = -I. # -Wall + +DEPEND = depend.mak + +DOCDIR = ../doc + + +$(TARGET): depend $(OBJECTS) GNUMakefile + ar rcusv $(TARGET) $(OBJECTS) + +doc: $(DOCDIR)/html/index.html + +$(DOCDIR)/html/index.html: $(HEADERS) + -rm -rf $(DOCDIR)/* + cd w32dlib ; doxygen + +%.o: %.cpp + $(CXX) -c $(FLAGS) $< -o $@ + +-include depend.mak + +clean: + -rm -f $(TARGET) $(OBJECTS) depend.mak + +depend: $(DEPEND) + +$(DEPEND): $(SOURCES) $(HEADERS) GNUMakefile + @echo Dependencies updated.... + $(CXX) -MM $(FLAGS) $(SOURCES) > $(DEPEND) + + +# END OF FILE diff --git a/src/autocheck.cpp b/src/autocheck.cpp new file mode 100644 index 0000000..dfa1bf5 --- /dev/null +++ b/src/autocheck.cpp @@ -0,0 +1,74 @@ +// 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 +// +// ------------------------------------------------------------------------- +// +// $Log$ +// +#include "w32dlib/autocheck.h" +#include "w32dlib/dialog.h" + +namespace W32DLib +{ + + +// ------------------------------------------------------------ +// +AutoCheck::AutoCheck(Dialog *parent, int resource_id) : + Control(parent,resource_id) +{ +} + + +// ------------------------------------------------------------ +// +AutoCheck::~AutoCheck() +{ +} + + +// ------------------------------------------------------------ +// +void AutoCheck::OnPress(W32DLibCallback callback) +{ + m_parent->AddCallback(WM_COMMAND,callback); +} + + +// ------------------------------------------------------------ +// +void AutoCheck::SetState(EState state) +{ + CheckDlgButton(m_parent->GetHWND(), + m_resid, + static_cast<UINT>(state)); +} + + +// ------------------------------------------------------------ +// +AutoCheck::EState AutoCheck::GetState() +{ + return static_cast<EState>(IsDlgButtonChecked(m_parent->GetHWND(),m_resid)); +} + +}; // namespace W32DLib + + + +// END OF FILE diff --git a/src/button.cpp b/src/button.cpp new file mode 100644 index 0000000..047d9d6 --- /dev/null +++ b/src/button.cpp @@ -0,0 +1,55 @@ +// 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 +// +// ------------------------------------------------------------------------- +// +// $Log$ +// + +#include "w32dlib/button.h" +#include "w32dlib/dialog.h" + +namespace W32DLib +{ + +// ------------------------------------------------------------ +// +Button::Button(Dialog *parent, int resource_id) : + Control(parent,resource_id) +{ +} + + +// ------------------------------------------------------------ +// +Button::~Button() +{ +} + + +// ------------------------------------------------------------ +// +void Button::OnPress(W32DLibCallback callback) +{ + Dialog::AddCallback(WM_COMMAND,callback); +} + + +}; // namespace W32DLib + +// END OF FILE diff --git a/src/common.cpp b/src/common.cpp new file mode 100644 index 0000000..a096fe6 --- /dev/null +++ b/src/common.cpp @@ -0,0 +1,112 @@ +// w32dlib - Win32 Dialog 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 +// +// ------------------------------------------------------------------------- +// +// $Log$ +// +#include "w32dlib/common.h" + +namespace W32DLib +{ + +// ------------------------------------------------------------ +// +void Common::Message(HWND parent, const char *msg) +{ + ::MessageBox(parent,msg,"Message",MB_ICONINFORMATION|MB_OK); +} + + +// ------------------------------------------------------------ +// +void Common::Error(HWND parent, const char *msg) +{ + ::MessageBox(parent,msg,"Error",MB_ICONSTOP|MB_OK); +} + + +// ------------------------------------------------------------ +// +bool Common::Query(HWND parent, const char *msg) +{ + return ::MessageBox(parent,msg,"Question",MB_ICONQUESTION|MB_YESNO)==IDOK; +} + + +// ------------------------------------------------------------ +// +std::string OpenFile(const char *filter) +{ + return std::string(); +} + + +// ------------------------------------------------------------ +// +std::string SaveFile(const char *filter) +{ + return std::string(); +} + + +// ------------------------------------------------------------ +// +std::string SelectDirectory() +{ + return std::string(); +} + + +// ------------------------------------------------------------ +// +std::string Common::GetOSError() +{ + std::string res; + LPVOID msg; + DWORD dw=GetLastError(); + + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + dw, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &msg, + 0, NULL ); + + res=static_cast<char*>(msg); + + LocalFree(msg); + + return res; +} + + +// ------------------------------------------------------------ +// +HINSTANCE Common::GetInstance() +{ + MEMORY_BASIC_INFORMATION mbi; + VirtualQuery((void *)GetInstance, &mbi, sizeof(mbi)); + return (HINSTANCE)mbi.AllocationBase; +} + + +}; // namespace W32DLib + +// END OF FILE diff --git a/src/control.cpp b/src/control.cpp new file mode 100644 index 0000000..abcf8fb --- /dev/null +++ b/src/control.cpp @@ -0,0 +1,118 @@ +// 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 +// +// ------------------------------------------------------------------------- +// +// $Log$ +// +#include "w32dlib/control.h" +#include "w32dlib/dialog.h" + +namespace W32DLib +{ + + +// ------------------------------------------------------------ +// +Control::Control(Dialog *parent, int resource_id) : + m_parent(parent), + m_resid(resource_id), + m_cblist() +{ +} + + +// ------------------------------------------------------------ +// +Control::~Control() +{ +} + + +// ------------------------------------------------------------ +// +int Control::ResourceID() +{ + return m_resid; +} + + +// ------------------------------------------------------------ +// +void Control::SetText(const char *text) +{ +} + + +// ------------------------------------------------------------ +// +std::string Control::GetText(int maxlen) +{ + char *buff=new char[maxlen+1]; + std::string res; + + if (GetDlgItemText(m_parent->GetHWND(),m_resid,buff,maxlen)) + { + res=buff; + } + + delete[] buff; + + return res; +} + + +// ------------------------------------------------------------ +// +BOOL Control::ProcessMessage(UINT msg, WPARAM wp, LPARAM lp) +{ + if (m_cblist.count(msg)>0) + { + W32DLibCallback cb=m_cblist[msg]; + + if (cb) + { + return cb(msg,wp,lp); + } + } + + return false; +} + + +// ------------------------------------------------------------ +// +void Control::AddCallback(UINT msg, W32DLibCallback callback) +{ + if (callback) + { + m_cblist[msg]=callback; + } + else + { + if (m_cblist.count(msg)) + { + m_cblist.remove(msg); + } + } +} + + +}; // namespace W32DLib + +// END OF FILE diff --git a/src/dialog.cpp b/src/dialog.cpp new file mode 100644 index 0000000..75b7e04 --- /dev/null +++ b/src/dialog.cpp @@ -0,0 +1,153 @@ +// w32dlib - Win32 Dialog 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 +// +// ------------------------------------------------------------------------- +// +// $Log$ +// +#include "w32dlib/dialog.h" +#include "w32dlib/control.h" + +namespace W32DLib +{ +// ------------------------------------------------------------ +// +Dialog::ProcSet Dialog::m_procset; + + +// ------------------------------------------------------------ +// +Dialog::Dialog() +{ +} + + +// ------------------------------------------------------------ +// +Dialog::~Dialog() +{ +} + + +// ------------------------------------------------------------ +// +void Dialog::OnInit() +{ +} + + +// ------------------------------------------------------------ +// +void Dialog::OnClose() +{ +} + + +// ------------------------------------------------------------ +// +HWND Dialog::GetHWND() +{ + return m_wnd; +} + + +// ------------------------------------------------------------ +// +INT_PTR Dialog::ShowModal(HINSTANCE inst, HWND parent) +{ + return ::DialogBox(inst, + MAKEINTRESOURCE(ResourceID()), + NULL, + &this->DialogProc); +} + + +// ------------------------------------------------------------ +// +void Dialog::Close(INT_PTR result) +{ + EndDialog(m_wnd,result); +} + + +// ------------------------------------------------------------ +// +void Dialog::AddControl(Control *control) +{ + m_cset.push_back(control); +} + + +// ------------------------------------------------------------ +// + +BOOL Dialog::InstanceDialogProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) +{ + BOOL ret=FALSE; + WORD lo=LOWORD(wp); + + switch(msg) + { + case WM_INITDIALOG: + m_wnd=wnd; + m_procset[wnd]=this; + OnInit(); + break; + + case WM_CLOSE: + OnClose(); + m_procset.erase(wnd); + break; + + case WM_COMMAND: + for(ControlSet::iterator i=m_cset.begin();i!=m_cset.end();++i) + { + if (lo==(*i)->ResourceID()) + { + ret=(*i)->ProcessMessage(msg,wp,lp); + break; + } + } + break; + + default: + break; + } + + return ret; +} + +// ------------------------------------------------------------ +// + +BOOL CALLBACK Dialog::DialogProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) +{ + if (m_procset.count(wnd)) + { + return m_procset[wnd]->InstanceDialogProc(wnd,msg,wp,lp); + } + else + { + return FALSE; + } +} + + +}; // namespace w32dlib + +// END OF FILE diff --git a/src/text.cpp b/src/text.cpp new file mode 100644 index 0000000..8f8d1eb --- /dev/null +++ b/src/text.cpp @@ -0,0 +1,45 @@ +// 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 +// +// ------------------------------------------------------------------------- +// +// $Log$ +// +#include "w32dlib/text.h" + +namespace W32DLib +{ + +// ------------------------------------------------------------ +// +Text::Text(Dialog *parent, int resource_id) : + Control(parent,resource_id) +{ +} + + +// ------------------------------------------------------------ +// +Text::~Text() +{ +} + + +}; // namespace W32DLib + +// END OF FILE diff --git a/src/w32dlib/Doxyfile b/src/w32dlib/Doxyfile new file mode 100644 index 0000000..55febc5 --- /dev/null +++ b/src/w32dlib/Doxyfile @@ -0,0 +1,254 @@ +# Doxyfile 1.4.1 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = W32DLib +PROJECT_NUMBER = +OUTPUT_DIRECTORY = ../../doc +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = YES +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = .. +STRIP_FROM_INC_PATH = .. +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 8 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = NO +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = YES +HIDE_UNDOC_CLASSES = YES +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = NO +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = YES +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = . +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox +RECURSIVE = NO +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = NO +REFERENCES_RELATION = NO +VERBATIM_HEADERS = NO +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = YES +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 1000 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/src/w32dlib/autocheck.h b/src/w32dlib/autocheck.h new file mode 100644 index 0000000..0246c03 --- /dev/null +++ b/src/w32dlib/autocheck.h @@ -0,0 +1,92 @@ +// 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_AUTOCHECK_H + +#define W32DLIB_AUTOCHECK_H "$Id$" + +#include "w32dlib/base.h" +#include "w32dlib/control.h" + +namespace W32DLib +{ + + /// \brief The AutoCheck class. + /// + class AutoCheck : public Control + { + public: + + /// \brief Describes the checkstate + /// + enum EState + { + eError =0, ///< Error getting state + eChecked =BST_CHECKED, ///< Checked + eUnchecked =BST_UNCHECKED, ///< Unchecked + eIndeterminate =BST_INDETERMINATE ///< Indeterminate + }; + + /// \brief Constructor + /// + /// \param parent The dialog the control belongs to. + /// \param resource_id The ID of the control in the resource file. + /// + AutoCheck(Dialog *parent, int resource_id); + + /// \brief Destructor + /// + virtual ~AutoCheck(); + + + /// \brief Sets a callback for a button press + /// + /// \param callback The callback. Set to NULL to clear the callback. + /// + void OnPress(W32DLibCallback callback); + + + /// \brief Sets the tickstate. + /// + /// \param state The tick state + /// \sa GetState() + /// + void SetState(EState state); + + + /// \brief Gets the tickstate. + /// + /// \return The tick state + /// \sa SetState() + /// + EState GetState(); + + protected: + + private: + + }; // class AutoCheck + +}; // namespace w32dlib + +#endif // W32DLIB_AUTOCHECK_H + + +// END OF FILE diff --git a/src/w32dlib/base.h b/src/w32dlib/base.h new file mode 100644 index 0000000..5dfcbfc --- /dev/null +++ b/src/w32dlib/base.h @@ -0,0 +1,39 @@ +// w32dlib - Win32 Dialog 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_BASE_H + +#define W32DLIB_BASE_H "$Id$" + +#include <windows.h> +#include <vector> +#include <map> +#include <string> + +namespace W32DLib +{ +class Dialog; +class Control; +}; + +#endif // W32DLIB_BASE_H + + +// END OF FILE diff --git a/src/w32dlib/button.h b/src/w32dlib/button.h new file mode 100644 index 0000000..0ab0b8d --- /dev/null +++ b/src/w32dlib/button.h @@ -0,0 +1,65 @@ +// 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_BUTTON_H + +#define W32DLIB_BUTTON_H "$Id$" + +#include "w32dlib/base.h" +#include "w32dlib/control.h" + +namespace W32DLib +{ + + /// \brief The Button class. + /// + class Button : public Control + { + public: + + /// \brief Constructor + /// + /// \param parent The dialog the control belongs to. + /// \param resource_id The ID of the control in the resource file. + /// + Button(Dialog *parent, int resource_id); + + /// \brief Destructor + /// + virtual ~Button(); + + /// \brief Sets a callback for a button press + /// + /// \param callback The callback. Set to NULL to clear the callback. + /// + void OnPress(W32DLibCallback callback); + + protected: + + private: + + }; // class Button + +}; // namespace w32dlib + +#endif // W32DLIB_BUTTON_H + + +// END OF FILE diff --git a/src/w32dlib/common.h b/src/w32dlib/common.h new file mode 100644 index 0000000..004d81f --- /dev/null +++ b/src/w32dlib/common.h @@ -0,0 +1,110 @@ +// w32dlib - Win32 Dialog 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_COMMON_H + +#define W32DLIB_COMMON_H "$Id$" + +#include "w32dlib/base.h" + +namespace W32DLib +{ + + /// \brief The Common class. + /// + /// This class provides common dialogs and useful routines. + /// + class Common + { + public: + + /// \brief Displays a message box. + /// + /// \param parent Parent window (NULL for none) + /// \param msg The message to display. + /// + static void Message(HWND parent, const char *msg); + + + /// \brief Displays an error message box. + /// + /// \param parent Parent window (NULL for none) + /// \param msg The error message to display. + /// + static void Error(HWND parent, const char *msg); + + + /// \brief Displays a Yes/No message box. + /// + /// \param parent Parent window (NULL for none) + /// \param msg The message to display. + /// \return True if the user selects Yes. + /// + static bool Query(HWND parent, const char *msg); + + + /// \brief Requests a file to open. + /// + /// \param filter The file selector filter. + /// \return The path, or an empty string if non selected. + /// + static std::string OpenFile(const char *filter); + + + /// \brief Requests a file to save. + /// + /// \param filter The file selector filter. + /// \return The path, or an empty string if non selected. + /// + static std::string SaveFile(const char *filter); + + + /// \brief Selects a directory + /// + /// \return The path, or an empty string if non selected. + /// + static std::string SelectDirectory(); + + + /// \brief Returns the last error as a readable string. + /// + /// \return The error message + /// + static std::string GetOSError(); + + + /// \brief Get the application HINSTANCE. + /// + /// \return The HINSTANCE + /// + static HINSTANCE GetInstance(); + + + private: + Common(); + + }; // class Common + +}; // namespace w32dlib + +#endif // W32DLIB_COMMON_H + + +// END OF FILE 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 diff --git a/src/w32dlib/dialog.h b/src/w32dlib/dialog.h new file mode 100644 index 0000000..fbe36e3 --- /dev/null +++ b/src/w32dlib/dialog.h @@ -0,0 +1,128 @@ +// w32dlib - Win32 Dialog 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_DIALOG_H + +#define W32DLIB_DIALOG_H "$Id$" + +#include "w32dlib/base.h" + +namespace W32DLib +{ + /// \brief The base Dialog class. + /// + class Dialog + { + public: + + /// \brief Constructor + /// + Dialog(); + + /// \brief Destructor + /// + virtual ~Dialog(); + + /// \brief Returns the Resource ID for the dialog. + /// + /// All derived classes must implement this. This should return + /// the ID of the dialog in the resource file. + /// + virtual int ResourceID()=0; + + /// \brief Called when the dialog is displaying. + /// + /// Override this call to initialise dialog controls. + /// + virtual void OnInit(); + + /// \brief Called when the dialog is closing. + /// + /// Override this call to pick up this event. + /// + virtual void OnClose(); + + /// \brief Returns the HWND for the dialog. + /// + /// This call will only work while the dialog is on display. + /// The behaviour is undefined if it is called at any other time. + /// + HWND GetHWND(); + + /// \brief Displays a modal dialog. + /// + /// Call this to display the dialog. + /// + /// \param instance The HINSTANCE. Call Common::GetInstance() + /// to get the applications instance (from a DLL, for example). + /// \param parent The parent window of the dialog (NULL for none). + /// \return The result from Close(). + /// \sa Close() + /// \sa Common::GetInstance() + /// + INT_PTR ShowModal(HINSTANCE instance, HWND parent); + + /// \brief Closes the dialog. + /// + /// Closes the dialog. Silently ignored if the dialog is not open. + /// + /// \param result The result to return. + /// \sa ShowModal() + /// + void Close(INT_PTR result); + + protected: + + /// \brief Adds a control to the dialog. + /// + /// Note that the pointer to the control is stored, so the control + /// must exist as long as the dialog is in use. + /// + void AddControl(Control *control); + + private: + + typedef std::vector<Control*> ControlSet; + typedef std::map<HWND,Dialog*> ProcSet; + + HWND m_wnd; + bool m_open; + ControlSet m_cset; + + static ProcSet m_procset; + + BOOL InstanceDialogProc(HWND wnd, + UINT msg, + WPARAM wp, + LPARAM lp); + + static BOOL CALLBACK DialogProc(HWND wnd, + UINT msg, + WPARAM wp, + LPARAM lp); + + }; // class Dialog + +}; // namespace w32dlib + +#endif // W32DLIB_DIALOG_H + + +// END OF FILE diff --git a/src/w32dlib/text.h b/src/w32dlib/text.h new file mode 100644 index 0000000..fa00705 --- /dev/null +++ b/src/w32dlib/text.h @@ -0,0 +1,59 @@ +// 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_TEXT_H + +#define W32DLIB_TEXT_H "$Id$" + +#include "w32dlib/base.h" +#include "w32dlib/control.h" + +namespace W32DLib +{ + + /// \brief The Text class. + /// + class Text : public Control + { + public: + + /// \brief Constructor + /// + /// \param parent The dialog the control belongs to. + /// \param resource_id The ID of the control in the resource file. + /// + Text(Dialog *parent, int resource_id); + + /// \brief Destructor + /// + virtual ~Text(); + + protected: + + private: + + }; // class Text + +}; // namespace w32dlib + +#endif // W32DLIB_TEXT_H + + +// END OF FILE diff --git a/src/w32dlib/w32dlib.h b/src/w32dlib/w32dlib.h new file mode 100644 index 0000000..6c6947f --- /dev/null +++ b/src/w32dlib/w32dlib.h @@ -0,0 +1,34 @@ +// w32dlib - Win32 Dialog 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_H + +#define W32DLIB_H "$Id$" + +#include "w32dlib/dialog.h" +#include "w32dlib/control.h" +#include "w32dlib/button.h" +#include "w32dlib/text.h" +#include "w32dlib/autocheck.h" + +#endif // W32DLIB_H + + +// END OF FILE |