diff options
author | Stef Walter <stef@thewalter.net> | 2003-09-20 07:12:49 +0000 |
---|---|---|
committer | Stef Walter <stef@thewalter.net> | 2003-09-20 07:12:49 +0000 |
commit | b49d8ebefe9b10c53a6a09ad564e22111b7b25c6 (patch) | |
tree | 1d5dd4abc38170a7bc106dabbc59b915017222f0 /win32/makedrop | |
parent | 1cda9ebbd62916c7c2136722597a86c583e1ecf6 (diff) |
Initial Import
Diffstat (limited to 'win32/makedrop')
-rw-r--r-- | win32/makedrop/MSG00001.bin | bin | 0 -> 512 bytes | |||
-rw-r--r-- | win32/makedrop/Makefile.am | 2 | ||||
-rw-r--r-- | win32/makedrop/dropsheet.cpp | 301 | ||||
-rw-r--r-- | win32/makedrop/dropsheet.h | 72 | ||||
-rw-r--r-- | win32/makedrop/makedrop.cpp | 74 | ||||
-rw-r--r-- | win32/makedrop/makedrop.dsp | 203 | ||||
-rw-r--r-- | win32/makedrop/makedrop.h | 1 | ||||
-rw-r--r-- | win32/makedrop/makedrop.rc | 275 | ||||
-rw-r--r-- | win32/makedrop/processpage.cpp | 239 | ||||
-rw-r--r-- | win32/makedrop/processpage.h | 75 | ||||
-rw-r--r-- | win32/makedrop/resource.h | 32 | ||||
-rw-r--r-- | win32/makedrop/rliberr.h | 136 | ||||
-rw-r--r-- | win32/makedrop/rliberr.rc | 2 | ||||
-rw-r--r-- | win32/makedrop/settingspage.cpp | 100 | ||||
-rw-r--r-- | win32/makedrop/settingspage.h | 65 | ||||
-rw-r--r-- | win32/makedrop/stdafx.cpp | 27 | ||||
-rw-r--r-- | win32/makedrop/stdafx.h | 40 |
17 files changed, 1644 insertions, 0 deletions
diff --git a/win32/makedrop/MSG00001.bin b/win32/makedrop/MSG00001.bin Binary files differnew file mode 100644 index 0000000..83bcd64 --- /dev/null +++ b/win32/makedrop/MSG00001.bin diff --git a/win32/makedrop/Makefile.am b/win32/makedrop/Makefile.am new file mode 100644 index 0000000..f79b2b5 --- /dev/null +++ b/win32/makedrop/Makefile.am @@ -0,0 +1,2 @@ +EXTRA_DIST = dropsheet.cpp dropsheet.h makedrop.cpp makedrop.dsp makedrop.h makedrop.rc processpage.h processpage.cpp resource.h settingspage.cpp settingspage.h stdafx.h stdafx.cpp + diff --git a/win32/makedrop/dropsheet.cpp b/win32/makedrop/dropsheet.cpp new file mode 100644 index 0000000..04801b4 --- /dev/null +++ b/win32/makedrop/dropsheet.cpp @@ -0,0 +1,301 @@ +/* + * AUTHOR + * N. Nielsen + * + * LICENSE + * This software is in the public domain. + * + * The software is provided "as is", without warranty of any kind, + * express or implied, including but not limited to the warranties + * of merchantability, fitness for a particular purpose, and + * noninfringement. In no event shall the author(s) be liable for any + * claim, damages, or other liability, whether in an action of + * contract, tort, or otherwise, arising from, out of, or in connection + * with the software or the use or other dealings in the software. + * + * SUPPORT + * Send bug reports to: <nielsen@memberwebs.com> + */ + +#include "stdafx.h" +#include "DropSheet.h" +#include "common/errutil.h" + + +// Error Macros: ---------------------------------------------------------- +// Context specific macros. Each one jumps to 'cleanup' so any wrapping +// up can be performed + +#define RETURN(v) \ + { ret = (v); goto cleanup; } +#define WINERR(f) \ + RETURN(errorMessage(m_hWnd, HRESULT_FROM_WIN32(::GetLastError()), f)) +#define WINERR_1(f, a) \ + RETURN(errorMessage(m_hWnd, HRESULT_FROM_WIN32(::GetLastError()), f, a)) +#define WINERR_E(e, f) \ + RETURN(errorMessage(m_hWnd, e, f)); +#define REPERR(c, s) \ + RETURN(rlibError(m_hWnd, c, s)); + + + +// (Con|De)struction: ------------------------------------------------------- + +DropSheet::DropSheet() : + CPropertySheet(_T("Rep Droplet")) +{ + m_dirty = false; +} + +DropSheet::~DropSheet() +{ + +} + + + +// CopyResourceToFile: ----------------------------------------------------- +// Dumps raw data from a resource to a file + +bool CopyResourceToFile(LPCTSTR type, LPCTSTR name, LPCTSTR fileName) +{ + // Open the Resource + HRSRC hRsrc = FindResource(_Module.GetResourceInstance(), name, type); + if(!hRsrc) return false; + + HGLOBAL hGlobal = LoadResource(_Module.GetResourceInstance(), hRsrc); + if(!hRsrc) return false; + + void* data = LockResource(hGlobal); + if(!data) return false; + + // Open the file + HANDLE file = CreateFile(fileName, GENERIC_WRITE, 0, NULL, + CREATE_ALWAYS, 0, NULL); + if(file == INVALID_HANDLE_VALUE) return false; + + DWORD size = SizeofResource(_Module.GetResourceInstance(), hRsrc); + + // Write it + DWORD written = 0; + bool ret = WriteFile(file, data, size, &written, NULL) ? true : false; + + if(written != size) + ret = false; + + CloseHandle(file); + + return ret; +} + + + +// saveDroplet: ------------------------------------------------------------- +// Gets property pages to save data, prompts user, saves etc... + +bool DropSheet::saveDroplet(bool force) +{ + HRESULT ret = S_OK; + bool noReturn = false; + + { + // The return value is whether or not an exit can + // take place + + if(!m_dirty && !force) + return true; + + // Prompt the user and see if they want to save + if(m_dirty && !force) + { + switch(MessageBox(_T("You've made changes, would you like to save?"), _T("Rep Droplet"), + MB_YESNOCANCEL | MB_ICONQUESTION)) + { + case IDYES: + break; + case IDNO: + return true; + case IDCANCEL: + return false; + } + } + + // Clear the dirty flag here + m_dirty = false; + + // Now get every page to apply theirs again + // if necessary + PressButton(PSBTN_APPLYNOW); + + // If dirty is set now, then something failed + if(m_dirty) + return false; + + // If the user hasn't saved/loaded yet then get a file name + if(m_fileName.empty()) + { + OPENFILENAME ofn; + memset(&ofn, 0, sizeof(ofn)); + + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = m_hWnd; + ofn.lpstrFilter = _T("Droplet Files (*.exe)\0*.exe\0All Files (*.*)\0*.*\0\0"); + ofn.lpstrFile = m_fileName.get_buffer(MAX_PATH); + ofn.nMaxFile = MAX_PATH; + ofn.lpstrFileTitle = _T("Save Droplet"); + ofn.Flags = OFN_HIDEREADONLY | OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT; + ofn.lpstrDefExt = _T("exe"); + + if(GetSaveFileName(&ofn)) + m_fileName.release_buffer(); + else + return false; + } + + // Okay now we copy out the droplet from our resources + if(!CopyResourceToFile(DROP_RESOURCE_TYPE, DROP_RESOURCE_FILE, + m_fileName)) + WINERR_1("Couldn't write out droplet: %s", m_fileName.c_str()); + + noReturn = true; + + // Now save our droplet data into the stock droplet + if(!m_droplet.save(m_fileName)) + WINERR_1("Couldn't write out droplet: %s", m_fileName.c_str()); + } + +cleanup: + // If failed and we already wrote out the stock + // droplet, then delete it + if(FAILED(ret) && noReturn && + !m_fileName.empty()) + DeleteFile(m_fileName); + + return SUCCEEDED(ret); +} + + +// openDroplet: -------------------------------------------------------- +// Prompt user for file, open it and refresh property pages + +void DropSheet::openDroplet() +{ + HRESULT ret = S_OK; + + { + string file; + OPENFILENAME ofn; + memset(&ofn, 0, sizeof(ofn)); + + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = m_hWnd; + ofn.lpstrFilter = _T("Droplet Files\0*.exe\0All Files\0*.*\0\0"); + ofn.lpstrFile = file.get_buffer(MAX_PATH); + ofn.nMaxFile = MAX_PATH; + ofn.lpstrFileTitle = _T("Choose Rep Script"); + ofn.Flags = OFN_HIDEREADONLY | OFN_EXPLORER | OFN_PATHMUSTEXIST; + ofn.lpstrDefExt = _T("rep");; + + if(GetOpenFileName(&ofn)) + { + file.release_buffer(); + + if(!m_droplet.load(file)) + WINERR_1("Couldn't read droplet: %s", file.c_str()); + + m_fileName = file; + + // Send around a message to the property pages to reload + SendMessage(PSM_QUERYSIBLINGS); + } + } + +cleanup: + ; +} + + +// onInitDialog: ---------------------------------------------------------- +// Initialize basic Property sheet stuff and pass on message + +LRESULT DropSheet::onInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + // Add the menu + HMENU hMenu = LoadMenu(_Module.GetResourceInstance(), + MAKEINTRESOURCE(IDR_MENU)); + SetMenu(hMenu); + + SetIcon(::LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_REP)), TRUE); + SetIcon((HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_REP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR), FALSE); + + + // Base implementations need this message + bHandled = FALSE; + return 0; +} + + +// onClose: ----------------------------------------------------------------- +// Check if save is required, close + +LRESULT DropSheet::onClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + // Make sure user saves first + if(!m_dirty || saveDroplet(false)) + { + // Modeless dialog, so this is right + PostQuitMessage(0); + bHandled = FALSE; + } + else + bHandled = TRUE; + + return 0; +} + + +// onChanged: --------------------------------------------------------------- +// Catch message sent by property pages, so we can update our dirty flag + +LRESULT DropSheet::onChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + m_dirty = true; + bHandled = FALSE; + return 0; +} + + +// onOpen: ------------------------------------------------------------------ +// "Open" menu or keyboard accel + +LRESULT DropSheet::onOpen(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +{ + // Make sure user saves first + if(!m_dirty || saveDroplet(false)) + { + openDroplet(); + } + + return 0; +} + + +// onSave: ------------------------------------------------------------------ +// "Save" menu or keyboard accel + +LRESULT DropSheet::onSave(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +{ + // Force a save + saveDroplet(true); + return 0; +} + + +// onExit: ------------------------------------------------------------------ +// "Exit" menu or keyboard accel + +LRESULT DropSheet::onExit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +{ + onClose(WM_CLOSE, 0, 0, bHandled); + return 0; +} diff --git a/win32/makedrop/dropsheet.h b/win32/makedrop/dropsheet.h new file mode 100644 index 0000000..48ec758 --- /dev/null +++ b/win32/makedrop/dropsheet.h @@ -0,0 +1,72 @@ +/* + * AUTHOR + * N. Nielsen + * + * LICENSE + * This software is in the public domain. + * + * The software is provided "as is", without warranty of any kind, + * express or implied, including but not limited to the warranties + * of merchantability, fitness for a particular purpose, and + * noninfringement. In no event shall the author(s) be liable for any + * claim, damages, or other liability, whether in an action of + * contract, tort, or otherwise, arising from, out of, or in connection + * with the software or the use or other dealings in the software. + * + * SUPPORT + * Send bug reports to: <nielsen@memberwebs.com> + */ + +#ifndef __DROPSHEET_H__ +#define __DROPSHEET_H__ + +#include "resource.h" +#include "common/droplet.h" + +// DropSheet: ------------------------------------------------------ +// The main window property sheet + +class DropSheet + : public CPropertySheet +{ +public: + DropSheet(); + virtual ~DropSheet(); + + BEGIN_MSG_MAP(DropSheet) + MESSAGE_HANDLER(WM_INITDIALOG, onInitDialog) + COMMAND_ID_HANDLER(ID_FILE_OPEN, onOpen) + COMMAND_ID_HANDLER(ID_FILE_SAVE, onSave) + COMMAND_ID_HANDLER(ID_FILE_EXIT, onExit) + MESSAGE_HANDLER(PSM_CHANGED, onChanged) + MESSAGE_HANDLER(WM_CLOSE, onClose) + CHAIN_MSG_MAP(CPropertySheet) + END_MSG_MAP() + + // Get the current internal droplet + Droplet& getDroplet() + { return m_droplet; } + +// Message Handlers +protected: + LRESULT onInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT onClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT onChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT onOpen(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT onSave(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT onExit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + +// Helper Functions +protected: + // Save the droplet, prompt user if not force + bool saveDroplet(bool force); + // Open the a droplet + void openDroplet(); + +protected: + Droplet m_droplet; // The internal loaded droplet + bool m_dirty; // Have changes been made? + string m_fileName; // The filename to save to +}; + +#endif // !defined(AFX_DROPSHEET_H__E3237E90_1FD0_4233_98EE_5991F4FB39F8__INCLUDED_) diff --git a/win32/makedrop/makedrop.cpp b/win32/makedrop/makedrop.cpp new file mode 100644 index 0000000..79a5b19 --- /dev/null +++ b/win32/makedrop/makedrop.cpp @@ -0,0 +1,74 @@ +/* + * AUTHOR + * N. Nielsen + * + * LICENSE + * This software is in the public domain. + * + * The software is provided "as is", without warranty of any kind, + * express or implied, including but not limited to the warranties + * of merchantability, fitness for a particular purpose, and + * noninfringement. In no event shall the author(s) be liable for any + * claim, damages, or other liability, whether in an action of + * contract, tort, or otherwise, arising from, out of, or in connection + * with the software or the use or other dealings in the software. + * + * SUPPORT + * Send bug reports to: <nielsen@memberwebs.com> + */ + +#include "stdafx.h" +#include "resource.h" +#include <initguid.h> +#include "DropSheet.h" +#include "ProcessPage.h" +#include "SettingsPage.h" + +// ATL Support stuff +CComModule _Module; +BEGIN_OBJECT_MAP(ObjectMap) +END_OBJECT_MAP() + + +// _tWinMain: ------------------------------------------------------------ +// Our application entry point +extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, + HINSTANCE /*hPrevInstance*/, LPTSTR /* lpCmdLine */, int /*nShowCmd*/) +{ + // ATL Support Stuff + HRESULT hRes = CoInitialize(NULL); + _ASSERTE(SUCCEEDED(hRes)); + _Module.Init(ObjectMap, hInstance, NULL); + + int nRet = 0; + + // Create and start the property sheet + DropSheet sheet; + ProcessPage page1(sheet.getDroplet()); + SettingsPage page2(sheet.getDroplet()); + sheet.AddPage(&page1); + sheet.AddPage(&page2); + sheet.Create(); + + // Load the keyboard shortcuts + HACCEL accel = LoadAccelerators(_Module.GetResourceInstance(), + MAKEINTRESOURCE(IDR_ACCEL)); + + // Process messages + MSG msg; + while(GetMessage(&msg, NULL, 0, 0)) + { + if(!accel || !TranslateAccelerator(sheet.m_hWnd, accel, &msg)) + { + if(!sheet.IsWindow() || !sheet.IsDialogMessage(&msg)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + } + + _Module.Term(); + CoUninitialize(); + return nRet; +} diff --git a/win32/makedrop/makedrop.dsp b/win32/makedrop/makedrop.dsp new file mode 100644 index 0000000..af603d3 --- /dev/null +++ b/win32/makedrop/makedrop.dsp @@ -0,0 +1,203 @@ +# Microsoft Developer Studio Project File - Name="makedrop" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=makedrop - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "makedrop.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "makedrop.mak" CFG="makedrop - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "makedrop - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE "makedrop - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "makedrop - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "debug" +# PROP Intermediate_Dir "debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\.." /I ".." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 libpcre.a comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x400000" /subsystem:windows /debug /machine:I386 /out:"../debug/makedrop.exe" /pdbtype:sept /libpath:"..\pcre\lib\\" + +!ELSEIF "$(CFG)" == "makedrop - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "release" +# PROP Intermediate_Dir "release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /W3 /GX /O1 /I "..\.." /I ".." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 libpcre.a comctl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x400000" /subsystem:windows /machine:I386 /out:"../release/makedrop.exe" /libpath:"..\pcre\lib\\" /opt:nowin98 +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "makedrop - Win32 Debug" +# Name "makedrop - Win32 Release" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\common\droplet.cpp +# End Source File +# Begin Source File + +SOURCE=.\DropSheet.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\errutil.cpp +# End Source File +# Begin Source File + +SOURCE=.\makedrop.cpp +# End Source File +# Begin Source File + +SOURCE=.\makedrop.rc +# End Source File +# Begin Source File + +SOURCE=.\ProcessPage.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\rliberr.mc + +!IF "$(CFG)" == "makedrop - Win32 Debug" + +# PROP Ignore_Default_Tool 1 +# Begin Custom Build +InputPath=..\common\rliberr.mc +InputName=rliberr + +"$(InputName).rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + mc $(InputPath) + +# End Custom Build + +!ELSEIF "$(CFG)" == "makedrop - Win32 Release" + +# PROP Ignore_Default_Tool 1 + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\SettingsPage.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\common\droplet.h +# End Source File +# Begin Source File + +SOURCE=.\DropSheet.h +# End Source File +# Begin Source File + +SOURCE=.\ProcessPage.h +# End Source File +# Begin Source File + +SOURCE=.\Resource.h +# End Source File +# Begin Source File + +SOURCE=.\SettingsPage.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=..\debug\droplet.exe +# End Source File +# Begin Source File + +SOURCE=.\droplet.exe +# End Source File +# Begin Source File + +SOURCE=..\release\droplet.exe +# End Source File +# Begin Source File + +SOURCE=.\MSG00001.bin +# End Source File +# Begin Source File + +SOURCE=..\common\rep.ico +# End Source File +# End Group +# End Target +# End Project +# Section makedrop : {00000000-0000-0000-0000-800000800000} +# 1:14:IDD_DROPLETDLG:101 +# End Section diff --git a/win32/makedrop/makedrop.h b/win32/makedrop/makedrop.h new file mode 100644 index 0000000..1ef92a3 --- /dev/null +++ b/win32/makedrop/makedrop.h @@ -0,0 +1 @@ +/* MIDL: this ALWAYS GENERATED file contains the definitions for the interfaces */ diff --git a/win32/makedrop/makedrop.rc b/win32/makedrop/makedrop.rc new file mode 100644 index 0000000..0b61072 --- /dev/null +++ b/win32/makedrop/makedrop.rc @@ -0,0 +1,275 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Neutral resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// REP +// + +#if defined(APSTUDIO_INVOKED) || defined(NDEBUG) +#if defined(APSTUDIO_INVOKED) +DROPLET$(NDEBUG) REP DISCARDABLE "..\\release\\droplet.exe" +#else +DROPLET REP DISCARDABLE "..\\release\\droplet.exe" +#endif +#endif +#if defined(APSTUDIO_INVOKED) || defined(_DEBUG) +#if defined(APSTUDIO_INVOKED) +DROPLET$(_DEBUG) REP DISCARDABLE "..\\debug\\droplet.exe" +#else +DROPLET REP DISCARDABLE "..\\debug\\droplet.exe" +#endif +#endif +#endif // Neutral resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 2,2,0,1 + PRODUCTVERSION 2,2,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "\0" + VALUE "CompanyName", "Nate Nielsen\0" + VALUE "FileDescription", "Rep Droplet Maker\0" + VALUE "FileVersion", "2, 2, 0, 1\0" + VALUE "InternalName", "makedrop\0" + VALUE "LegalCopyright", "Copyright Nate Nielsen 2002\0" + VALUE "LegalTrademarks", "\0" + VALUE "OLESelfRegister", "\0" + VALUE "OriginalFilename", "makedrop.exe\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "rep\0" + VALUE "ProductVersion", "2, 2, 0, 1\0" + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_SETTINGS DIALOG DISCARDABLE 0, 0, 227, 210 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Settings" +FONT 8, "Tahoma" +BEGIN + LTEXT "This title is shown in the progress dialog for this droplet.", + IDC_STATIC,17,19,180,8 + EDITTEXT IDC_TITLE,17,32,192,14,ES_AUTOHSCROLL + CONTROL "Backup replaced files.",IDC_BACKUP,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,17,75,167,10 + GROUPBOX "Backups",IDC_STATIC,7,61,213,75 + LTEXT "If this option is checked, then this droplet will backup any files it modifies. It adds a 'x_r' extension to those files.\n\nWhen a backup already exists it is overwritten.", + IDC_STATIC,17,91,192,32 + GROUPBOX "Title",IDC_STATIC,7,7,213,48 +END + +IDD_PROCESS DIALOG DISCARDABLE 0, 0, 227, 210 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Process" +FONT 8, "Tahoma" +BEGIN + CONTROL "Process entire file at once",IDC_USEFILE,"Button", + BS_AUTORADIOBUTTON,18,79,158,10 + CONTROL "Process file in chunks",IDC_USECHUNK,"Button", + BS_AUTORADIOBUTTON,18,126,140,10 + LTEXT "Largest match size:",IDC_STATIC,35,183,63,8 + EDITTEXT IDC_CHUNK,104,182,57,14,ES_AUTOHSCROLL | ES_NUMBER + GROUPBOX "Chunks",IDC_STATIC,7,65,213,138 + LTEXT "This runs replaces on all of the file at once. Although the most reliable method, it's slower, sometimes extremely so. ", + IDC_STATIC,18,94,191,22 + LTEXT "This option breaks up the file into smaller blocks for processing. Processing is much faster in this mode. The largest expected match should be entered below; anything larger won't be replaced.", + IDC_STATIC,18,140,191,34 + GROUPBOX "Script",IDC_STATIC,7,7,213,49 + EDITTEXT IDC_SCRIPT,18,33,170,14,ES_AUTOHSCROLL + PUSHBUTTON "...",IDC_BROWSE,190,33,19,14 + LTEXT "The rep script that will be compiled into the droplet. ", + IDC_STATIC,18,19,191,12 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_SETTINGS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 220 + VERTGUIDE, 17 + VERTGUIDE, 209 + TOPMARGIN, 7 + BOTTOMMARGIN, 203 + END + + IDD_PROCESS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 220 + VERTGUIDE, 18 + VERTGUIDE, 209 + TOPMARGIN, 7 + BOTTOMMARGIN, 203 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MENU MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN + MENUITEM "&Save...\tCtrl+S", ID_FILE_SAVE + MENUITEM SEPARATOR + MENUITEM "E&xit\tCtrl+Q", ID_FILE_EXIT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_ACCEL ACCELERATORS DISCARDABLE +BEGIN + "O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT + "Q", ID_FILE_EXIT, VIRTKEY, CONTROL, NOINVERT + "S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_REP ICON DISCARDABLE "..\\common\\rep.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// 11 +// + +1 11 DISCARDABLE "MSG00001.bin" + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_PROJNAME "makedrop" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/win32/makedrop/processpage.cpp b/win32/makedrop/processpage.cpp new file mode 100644 index 0000000..be3951a --- /dev/null +++ b/win32/makedrop/processpage.cpp @@ -0,0 +1,239 @@ +/* + * AUTHOR + * N. Nielsen + * + * LICENSE + * This software is in the public domain. + * + * The software is provided "as is", without warranty of any kind, + * express or implied, including but not limited to the warranties + * of merchantability, fitness for a particular purpose, and + * noninfringement. In no event shall the author(s) be liable for any + * claim, damages, or other liability, whether in an action of + * contract, tort, or otherwise, arising from, out of, or in connection + * with the software or the use or other dealings in the software. + * + * SUPPORT + * Send bug reports to: <nielsen@memberwebs.com> + */ + +#include "stdafx.h" +#include "ProcessPage.h" +#include "common/errutil.h" +#include "lib/rlib.h" +#include "lib/rep.h" + + +// Error Macros: ---------------------------------------------------------- +// Context specific macros. Each one jumps to 'cleanup' so any wrapping +// up can be performed + +#define RETURN(v) \ + { ret = (v); goto cleanup; } +#define WINERR(f) \ + RETURN(errorMessage(m_hWnd, HRESULT_FROM_WIN32(::GetLastError()), f)) +#define WINERR_1(f, a) \ + RETURN(errorMessage(m_hWnd, HRESULT_FROM_WIN32(::GetLastError()), f, a)) +#define WINERR_E(e, f) \ + RETURN(errorMessage(m_hWnd, e, f)); +#define REPERR(c, s) \ + RETURN(rlibError(m_hWnd, c, s)); +#define CUSTERR(e, s) \ + { errorMessage(m_hWnd, 0, s); RETURN(e); } +#define CUSTERR_1(e, s, a) \ + { errorMessage(m_hWnd, 0, s, a); RETURN(e); } + + +// (Con|De)struction: --------------------------------------------------------- + +ProcessPage::ProcessPage(Droplet& droplet) : + CPropertyPage(IDD_PROCESS, _T("Script")), + m_droplet(droplet) +{ + m_inited = false; +} + +// compileScript: ---------------------------------------------------------- +// Load and possibly compile a script from a file + +HRESULT ProcessPage::compileScript(const string& script) +{ + FILE* file = NULL; + HRESULT ret = S_OK; + int r = R_OK; + + { + file = fopen(script, "rb"); + if(!file) + CUSTERR_1(E_FAIL, "Couldn't open script file: %s", script.c_str()); + + r_context& ctx = m_droplet.getContext(); + + r = repLoad(&ctx, file); + if(r < 0) + REPERR(r, &(ctx.script)); + } + +cleanup: + if(file) + fclose(file); + + return ret; +} + + +// loadData: ------------------------------------------------------------- +// Load data from the droplet onto page + +void ProcessPage::loadData() +{ + m_inited = false; + size_t buffSize = m_droplet.getBuffSize(); + CheckDlgButton(IDC_USEFILE, buffSize == 0); + CheckDlgButton(IDC_USECHUNK, buffSize != 0); + SetDlgItemInt(IDC_CHUNK, buffSize == 0 ? 2000 : buffSize, FALSE); + + if(m_droplet.hasScript()) + { + // By setting both to the same value we prevent rereading + // or compiling + m_script = _T("[compiled script]"); + SetDlgItemText(IDC_SCRIPT, m_script); + } + + m_inited = true; + updateControls(); +} + + +// onInitDialog: ----------------------------------------------------------- +// Dialog initialization + +LRESULT ProcessPage::onInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + loadData(); + return 0; +} + + +// onInitDialog: ----------------------------------------------------------- +// Broadcast by sheet when required to reread droplet info + +LRESULT ProcessPage::onQuerySiblings(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + loadData(); + return 0; +} + + +// onInitDialog: ----------------------------------------------------------- +// Save droplet data from page + +LRESULT ProcessPage::onApply(int idCtrl, LPNMHDR pnmh, BOOL& bHandled) +{ + string script; + GetDlgItemText(IDC_SCRIPT, script.get_buffer(MAX_PATH), MAX_PATH); + script.release_buffer(); + + // Make sure we have a script + if(script.empty()) + { + errorMessage(m_hWnd, 0, _T("You need to provide the filename of a rep script.")); + ::SetFocus(GetDlgItem(IDC_SCRIPT)); + SetModified(TRUE); + return PSNRET_INVALID; + } + + // If the the script changed + if(script != m_script) + { + // Then recompile it + if(SUCCEEDED(compileScript(script))) + { + m_script = script; + } + else + { + // By setting dirty we signal an error to sheet + SetModified(TRUE); + return PSNRET_INVALID; + } + } + + // Do buffer thing + if(IsDlgButtonChecked(IDC_USEFILE)) + { + // Process entire file at once + m_droplet.setBuffSize(0); + } + else + { + // Get the actual buffer size + BOOL translated; + UINT buffSize = GetDlgItemInt(IDC_CHUNK, &translated, FALSE); + if(buffSize < 16 || !translated) + { + errorMessage(m_hWnd, 0, _T("The chunk size must be a valid number greater than 16.")); + ::SetFocus(GetDlgItem(IDC_CHUNK)); + SetModified(TRUE); + return PSNRET_INVALID; + } + + m_droplet.setBuffSize(buffSize); + } + + return PSNRET_NOERROR; +} + + +// onChange: -------------------------------------------------------------- +// Signal dirty to parent sheet + +LRESULT ProcessPage::onChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +{ + if(m_inited) + { + SetModified(TRUE); + updateControls(); + } + return 0; +} + + +// updateControls: -------------------------------------------------------- +// Make sure page remains valid when changes happen + +void ProcessPage::updateControls() +{ + ::EnableWindow(GetDlgItem(IDC_CHUNK), IsDlgButtonChecked(IDC_USECHUNK)); +} + + +// onBrowse: -------------------------------------------------------------- +// Browse for a script file + +LRESULT ProcessPage::onBrowse(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +{ + string file; + OPENFILENAME ofn; + memset(&ofn, 0, sizeof(ofn)); + + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = m_hWnd; + ofn.lpstrFilter = _T("Rep Files (*.rep)\0*.rep\0All Files (*.*)\0*.*\0\0"); + ofn.lpstrFile = file.get_buffer(MAX_PATH); + ofn.nMaxFile = MAX_PATH; + ofn.lpstrFileTitle = _T("Choose Rep Script"); + ofn.Flags = OFN_HIDEREADONLY | OFN_EXPLORER | OFN_PATHMUSTEXIST; + ofn.lpstrDefExt = _T("rep");; + + if(GetOpenFileName(&ofn)) + { + file.release_buffer(); + SetDlgItemText(IDC_SCRIPT, file); + SetModified(TRUE); + updateControls(); + } + + return 0; +} diff --git a/win32/makedrop/processpage.h b/win32/makedrop/processpage.h new file mode 100644 index 0000000..74ad6de --- /dev/null +++ b/win32/makedrop/processpage.h @@ -0,0 +1,75 @@ +/* + * AUTHOR + * N. Nielsen + * + * LICENSE + * This software is in the public domain. + * + * The software is provided "as is", without warranty of any kind, + * express or implied, including but not limited to the warranties + * of merchantability, fitness for a particular purpose, and + * noninfringement. In no event shall the author(s) be liable for any + * claim, damages, or other liability, whether in an action of + * contract, tort, or otherwise, arising from, out of, or in connection + * with the software or the use or other dealings in the software. + * + * SUPPORT + * Send bug reports to: <nielsen@memberwebs.com> + */ + +#ifndef __PROCESSPAGE_H__ +#define __PROCESSPAGE_H__ + +#include "resource.h" // main symbols +#include <atlhost.h> +#include "common/droplet.h" + + +// ProcessPage: ------------------------------------------------------- +// Property page for script and buffer size + +class ProcessPage : + public CPropertyPage +{ +public: + ProcessPage(Droplet& droplet); + + BEGIN_MSG_MAP(ProcessPage) + MESSAGE_HANDLER(WM_INITDIALOG, onInitDialog) + MESSAGE_HANDLER(PSM_QUERYSIBLINGS, onQuerySiblings) + COMMAND_ID_HANDLER(IDC_BROWSE, onBrowse) + COMMAND_CODE_HANDLER(BN_CLICKED, onChange) + COMMAND_CODE_HANDLER(EN_CHANGE, onChange) + NOTIFY_CODE_HANDLER(PSN_APPLY, onApply) + END_MSG_MAP() + +// Message Handlers +protected: + LRESULT onInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT onQuerySiblings(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT onApply(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); + LRESULT onChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT onBrowse(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + +// Helper Functions +protected: + // Updates all status etc... + void updateControls(); + + // Load data from droplet to page + void loadData(); + + // Load an already compiled rep script + HRESULT compileAlready(FILE* f); + + // Load and possibly compile a rep script + HRESULT compileScript(const string& script); + +protected: + Droplet& m_droplet; // Pointer to sheet's main droplet + string m_script; // The script file name last time it was saved + // Will not reload if the same + bool m_inited; // Have we finished being initialized (used by onChange) +}; + +#endif //__PROCESSPAGE_H__ diff --git a/win32/makedrop/resource.h b/win32/makedrop/resource.h new file mode 100644 index 0000000..4783aae --- /dev/null +++ b/win32/makedrop/resource.h @@ -0,0 +1,32 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by makedrop.rc +// +#define IDS_PROJNAME 100 +#define IDR_Makedrop 100 +#define IDC_TITLE 201 +#define IDR_MENU 201 +#define IDD_SETTINGS 202 +#define IDC_BACKUP 202 +#define IDR_ACCEL 202 +#define IDC_USEFILE 203 +#define IDD_PROCESS 203 +#define IDC_USECHUNK 204 +#define IDC_CHUNK 205 +#define IDC_SCRIPT 206 +#define IDC_BROWSE 207 +#define IDI_REP 208 +#define ID_FILE_OPEN 32768 +#define ID_FILE_SAVE 32769 +#define ID_FILE_EXIT 32770 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 210 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 208 +#define _APS_NEXT_SYMED_VALUE 102 +#endif +#endif diff --git a/win32/makedrop/rliberr.h b/win32/makedrop/rliberr.h new file mode 100644 index 0000000..8fe3a80 --- /dev/null +++ b/win32/makedrop/rliberr.h @@ -0,0 +1,136 @@ +/* + * AUTHOR + * N. Nielsen + * + * VERSION + * 2.2.0b + * + * LICENSE + * This software is in the public domain. + * + * The software is provided "as is", without warranty of any kind, + * express or implied, including but not limited to the warranties + * of merchantability, fitness for a particular purpose, and + * noninfringement. In no event shall the author(s) be liable for any + * claim, damages, or other liability, whether in an action of + * contract, tort, or otherwise, arising from, out of, or in connection + * with the software or the use or other dealings in the software. + * + * SUPPORT + * Send bug reports to: <nielsen@memberwebs.com> + */ + +#ifndef _RLIBERR_H_ +#define _RLIBERR_H_ + +#ifndef _WINERROR_ + #error Include winerror.h first. +#endif + +#define HRESULT_FROM_RLIB(code) \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_RLIB, abs(code)) + +/* ------------------------------------------------------------------------ *\ + Rlib Errors +\* ------------------------------------------------------------------------ */ +// +// Values are 32 bit values layed out as follows: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +---+-+-+-----------------------+-------------------------------+ +// |Sev|C|R| Facility | Code | +// +---+-+-+-----------------------+-------------------------------+ +// +// where +// +// Sev - is the severity code +// +// 00 - Success +// 01 - Informational +// 10 - Warning +// 11 - Error +// +// C - is the Customer code flag +// +// R - is a reserved bit +// +// Facility - is the facility code +// +// Code - is the facility's status code +// +// +// Define the facility codes +// +#define FACILITY_RLIB 0x196 + + +// +// Define the severity codes +// + + +// +// MessageId: RLIB_E_NOMEM +// +// MessageText: +// +// Out of Memory. +// +#define RLIB_E_NOMEM ((HRESULT)0x81960001L) + +// +// MessageId: RLIB_E_SYNTAX +// +// MessageText: +// +// Rep script syntax error. +// +#define RLIB_E_SYNTAX ((HRESULT)0x81960002L) + +// +// MessageId: RLIB_E_REGEXP +// +// MessageText: +// +// Regular expression syntax error. +// +#define RLIB_E_REGEXP ((HRESULT)0x81960003L) + +// +// MessageId: RLIB_E_LOOP +// +// MessageText: +// +// Rep encountered an endless loop. +// +#define RLIB_E_LOOP ((HRESULT)0x81960004L) + +// +// MessageId: RLIB_E_USER +// +// MessageText: +// +// User defined error. +// +#define RLIB_E_USER ((HRESULT)0x81960005L) + +// +// MessageId: RLIB_E_IOERR +// +// MessageText: +// +// There was an error reading or writing the data. +// +#define RLIB_E_IOERR ((HRESULT)0x81960006L) + +// +// MessageId: RLIB_E_INVARG +// +// MessageText: +// +// Programmer Error: Invalid argument. +// +#define RLIB_E_INVARG ((HRESULT)0x8196000AL) + +#endif // _RLIBERR_H_
\ No newline at end of file diff --git a/win32/makedrop/rliberr.rc b/win32/makedrop/rliberr.rc new file mode 100644 index 0000000..0885a89 --- /dev/null +++ b/win32/makedrop/rliberr.rc @@ -0,0 +1,2 @@ +LANGUAGE 0x9,0x1 +1 11 MSG00001.bin diff --git a/win32/makedrop/settingspage.cpp b/win32/makedrop/settingspage.cpp new file mode 100644 index 0000000..953eebd --- /dev/null +++ b/win32/makedrop/settingspage.cpp @@ -0,0 +1,100 @@ +/* + * AUTHOR + * N. Nielsen + * + * LICENSE + * This software is in the public domain. + * + * The software is provided "as is", without warranty of any kind, + * express or implied, including but not limited to the warranties + * of merchantability, fitness for a particular purpose, and + * noninfringement. In no event shall the author(s) be liable for any + * claim, damages, or other liability, whether in an action of + * contract, tort, or otherwise, arising from, out of, or in connection + * with the software or the use or other dealings in the software. + * + * SUPPORT + * Send bug reports to: <nielsen@memberwebs.com> + */ + +#include "stdafx.h" +#include "SettingsPage.h" + +// (Con|De)struction: ---------------------------------------------------- + +SettingsPage::SettingsPage(Droplet& droplet) : + CPropertyPage(IDD_SETTINGS, _T("Settings")), + m_droplet(droplet) +{ + m_inited = false; +} + + +// loadData: ------------------------------------------------------------- +// Load info from droplet onto page + +void SettingsPage::loadData() +{ + m_inited = false; + SetDlgItemText(IDC_TITLE, m_droplet.getTitle()); + CheckDlgButton(IDC_BACKUP, m_droplet.keepBackups()); + m_inited = true; + updateControls(); +} + + +// onQuerySiblings: ------------------------------------------------------ +// Broadcast from parent sheet when we have to reload droplet data + +LRESULT SettingsPage::onQuerySiblings(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + loadData(); + return 0; +} + + +// onInitDialog: --------------------------------------------------------- +// Page Initialization + +LRESULT SettingsPage::onInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + loadData(); + return 0; +} + + +// onApply: -------------------------------------------------------------- +// Save data to droplet + +LRESULT SettingsPage::onApply(int idCtrl, LPNMHDR pnmh, BOOL& bHandled) +{ + string title; + GetDlgItemText(IDC_TITLE, title.get_buffer(MAX_PATH), MAX_PATH); + title.release_buffer(); + m_droplet.setTitle(title); + + m_droplet.setBackups(IsDlgButtonChecked(IDC_BACKUP) ? true : false); + return PSNRET_NOERROR; +} + + +// onChange: ------------------------------------------------------------- +// Signal to parent when changes happen + +LRESULT SettingsPage::onChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) +{ + if(m_inited) + { + SetModified(TRUE); + updateControls(); + } + return 0; +} + +// updateControls: ------------------------------------------------------- +// Keep page status in sync + +void SettingsPage::updateControls() +{ + +}
\ No newline at end of file diff --git a/win32/makedrop/settingspage.h b/win32/makedrop/settingspage.h new file mode 100644 index 0000000..f122963 --- /dev/null +++ b/win32/makedrop/settingspage.h @@ -0,0 +1,65 @@ +/* + * AUTHOR + * N. Nielsen + * + * LICENSE + * This software is in the public domain. + * + * The software is provided "as is", without warranty of any kind, + * express or implied, including but not limited to the warranties + * of merchantability, fitness for a particular purpose, and + * noninfringement. In no event shall the author(s) be liable for any + * claim, damages, or other liability, whether in an action of + * contract, tort, or otherwise, arising from, out of, or in connection + * with the software or the use or other dealings in the software. + * + * SUPPORT + * Send bug reports to: <nielsen@memberwebs.com> + */ + +#ifndef __SETTINGSPAGE_H_ +#define __SETTINGSPAGE_H_ + +#include "resource.h" // main symbols +#include <atlhost.h> +#include "common/droplet.h" + +// SettingsPage: ---------------------------------------------------------- +// Property page for misc drop settings + +class SettingsPage : + public CPropertyPage +{ +public: + SettingsPage(Droplet& droplet); + + BEGIN_MSG_MAP(SettingsPage) + MESSAGE_HANDLER(WM_INITDIALOG, onInitDialog) + MESSAGE_HANDLER(PSM_QUERYSIBLINGS, onQuerySiblings) + COMMAND_CODE_HANDLER(BN_CLICKED, onChange) + COMMAND_CODE_HANDLER(EN_CHANGE, onChange) + NOTIFY_CODE_HANDLER(PSN_APPLY, onApply) + END_MSG_MAP() + +// Message Handlers +protected: + LRESULT onInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT onQuerySiblings(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT onApply(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); + LRESULT onChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + +// Helper Functions +protected: + // Updates all status etc... + void updateControls(); + + // Load data from droplet to page + void loadData(); + +// Data +protected: + Droplet& m_droplet; // The Property sheet's internal droplet + bool m_inited; // Have we been initialized (used by onChange) +}; + +#endif //__SETTINGSPAGE_H_ diff --git a/win32/makedrop/stdafx.cpp b/win32/makedrop/stdafx.cpp new file mode 100644 index 0000000..ba86b3c --- /dev/null +++ b/win32/makedrop/stdafx.cpp @@ -0,0 +1,27 @@ +/* + * AUTHOR + * N. Nielsen + * + * LICENSE + * This software is in the public domain. + * + * The software is provided "as is", without warranty of any kind, + * express or implied, including but not limited to the warranties + * of merchantability, fitness for a particular purpose, and + * noninfringement. In no event shall the author(s) be liable for any + * claim, damages, or other liability, whether in an action of + * contract, tort, or otherwise, arising from, out of, or in connection + * with the software or the use or other dealings in the software. + * + * SUPPORT + * Send bug reports to: <nielsen@memberwebs.com> + */ + +#include "stdafx.h" + +#ifdef _ATL_STATIC_REGISTRY +#include <statreg.h> +#include <statreg.cpp> +#endif + +#include <atlimpl.cpp> diff --git a/win32/makedrop/stdafx.h b/win32/makedrop/stdafx.h new file mode 100644 index 0000000..2de0b77 --- /dev/null +++ b/win32/makedrop/stdafx.h @@ -0,0 +1,40 @@ +/* + * AUTHOR + * N. Nielsen + * + * LICENSE + * This software is in the public domain. + * + * The software is provided "as is", without warranty of any kind, + * express or implied, including but not limited to the warranties + * of merchantability, fitness for a particular purpose, and + * noninfringement. In no event shall the author(s) be liable for any + * claim, damages, or other liability, whether in an action of + * contract, tort, or otherwise, arising from, out of, or in connection + * with the software or the use or other dealings in the software. + * + * SUPPORT + * Send bug reports to: <nielsen@memberwebs.com> + */ + +#if !defined(AFX_STDAFX_H__7FCAFA12_CBDF_41CC_98D1_56D72C99E1C5__INCLUDED_) +#define AFX_STDAFX_H__7FCAFA12_CBDF_41CC_98D1_56D72C99E1C5__INCLUDED_ + +#define STRICT +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0400 +#endif +#define _ATL_APARTMENT_THREADED + +#include <atlbase.h> +extern CComModule _Module; +#include <atlcom.h> +#include <atlwin.h> + +#include "config.win32.h" +#include "common/compat.h" +#include "common/usuals.h" +#include "common/atlprsht.h" +#include "common/mystring.h" + +#endif // !defined(AFX_STDAFX_H__7FCAFA12_CBDF_41CC_98D1_56D72C99E1C5__INCLUDED) |