From: j.m.maurer (j.m.maurer@student.utwente.nl)
Date: Wed Jul 10 2002 - 12:11:57 EDT
Great work Jordi, commited!
Marc
Win32 Insert Table Dialog
CVS:
----------------------------------------------------------------------
CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS:    Makefile src/wp/ap/win/Makefile
CVS:    src/wp/ap/win/ap_Win32Dialog_All.h
CVS:    src/wp/ap/win/ap_Win32Resources.rc2
CVS: Added Files:
CVS:    src/wp/ap/win/ap_Win32Dialog_InsertTable.cpp
CVS:    src/wp/ap/win/ap_Win32Dialog_InsertTable.h
CVS:    src/wp/ap/win/ap_Win32Res_InsertTable.rc2
CVS:
----------------------------------------------------------------------
Op wo 10-07-2002, om 16:16 schreef Jordi Mas:
> Hi guys,
> 
> I have implented the InsertTable class for win32. The  tree new files that 
> implement the class and also the diff.txt that should be applied (makefiles, etc)
> 
> Can any one commit these changes?
> 
> Best Regards,
> 
> Jordi,
> -- 
> 
> Jordi Mas
> http://www.softcatala.org
> 
> 
> 
> ----
> 
> /* AbiWord
>  * Copyright (C) 2002 Jordi Mas i Hernāndez <jmas@softcatala.org>
>  * 
>  * This program is free software; you can redistribute it and/or
>  * modify it under the terms of the GNU General Public License
>  * as published by the Free Software Foundation; either version 2
>  * of the License, or (at your option) any later version.
>  * 
>  * This program is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU General Public License for more details.
>  * 
>  * You should have received a copy of the GNU General Public License
>  * along with this program; if not, write to the Free Software
>  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  
>  * 02111-1307, USA.
>  */
> 
> #include <windows.h>
> #include <commdlg.h>
> #include <commctrl.h>
> 
> #include "ut_types.h"
> #include "ut_string.h"
> #include "ut_assert.h"
> #include "ut_debugmsg.h"
> #include "ut_Win32OS.h"
> 
> #include "xap_App.h"
> #include "xap_Win32App.h"
> #include "xap_Win32Frame.h"
> 
> #include "ap_Win32App.h"
> #include "ap_Win32Frame.h"
> #include "ap_Strings.h"
> #include "ap_Dialog_Id.h"
> 
> #include "AP_Win32Dialog_InsertTable.h"
> #include "ap_Win32Resources.rc2"
> 
> #define BUFSIZE		128
> 
> /*****************************************************************/
> 
> XAP_Dialog* AP_Win32Dialog_InsertTable::static_constructor(XAP_DialogFactory* pDlgFactory, XAP_Dialog_Id id)
> {
> 	AP_Win32Dialog_InsertTable* dlg = new AP_Win32Dialog_InsertTable (pDlgFactory, id);
> 	return dlg;
> }
> 
> //
> // Init
> //
> AP_Win32Dialog_InsertTable::AP_Win32Dialog_InsertTable (XAP_DialogFactory *pDlgFactory, XAP_Dialog_Id id)
> : AP_Dialog_InsertTable (pDlgFactory, id), m_pWin32Frame(NULL), m_hwndDlg(NULL)
> {
> 	
> }
> AP_Win32Dialog_InsertTable::~AP_Win32Dialog_InsertTable()
> {
> }
> 
> 
> void AP_Win32Dialog_InsertTable::runModal(XAP_Frame *pFrame)
> {
> 	UT_ASSERT(pFrame);	
> 	
> 	// raise the dialog
> 	XAP_Win32App * pWin32App = static_cast<XAP_Win32App *>(m_pApp);
> 	m_pWin32Frame = static_cast<XAP_Win32Frame *>(pFrame);
> 
> 	LPCTSTR lpTemplate = NULL;
> 
> 	UT_ASSERT(m_id == AP_DIALOG_ID_INSERT_TABLE);
> 
> 	lpTemplate = MAKEINTRESOURCE(AP_RID_DIALOG_INSERT_TABLE);
> 
> 	int result = DialogBoxParam(pWin32App->getInstance(),lpTemplate,
> 								m_pWin32Frame->getTopLevelWindow(),
> 								(DLGPROC)s_dlgProc,(LPARAM)this);
> 	UT_ASSERT((result != -1));
> 
> }
> 
> /*****************************************************************/
> 
> #define GWL(hwnd)		(AP_Win32Dialog_InsertTable*)GetWindowLong((hwnd), DWL_USER)
> #define SWL(hwnd, d)	(AP_Win32Dialog_InsertTable*)SetWindowLong((hwnd), DWL_USER,(LONG)(d))
> 
> 
> BOOL CALLBACK AP_Win32Dialog_InsertTable::s_dlgProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
> {
> 		
> 	AP_Win32Dialog_InsertTable * pThis;
> 	
> 	switch (msg)
> 	{
> 	case WM_INITDIALOG:
> 		pThis = (AP_Win32Dialog_InsertTable *)lParam;
> 		SWL(hWnd,lParam);
> 		return pThis->_onInitDialog(hWnd,wParam,lParam);
> 		
> 	case WM_COMMAND:
> 		pThis = GWL(hWnd);
> 		return pThis->_onCommand(hWnd,wParam,lParam);
> 	default:
> 		return 0;
> 	}
> }
> 
> 
> #define _DS(c,s)	SetDlgItemText(hWnd,AP_RID_DIALOG_INSERTTABLE_##c,pSS->getValue(AP_STRING_ID_##s))
> #define _DSX(c,s)	SetDlgItemText(hWnd,AP_RID_DIALOG_INSERTTABLE_##c,pSS->getValue(XAP_STRING_ID_##s))
> 
> 
> // This handles the WM_INITDIALOG message for the top-level dialog.
> BOOL AP_Win32Dialog_InsertTable::_onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
> {	
> 	const XAP_StringSet * pSS = m_pApp->getStringSet();
> 	
> 	m_hwndDlg = hWnd;
> 		
> 	// localize controls (TODO: add the missing controls)
> 	_DSX(BTN_OK,		DLG_OK);
> 	_DSX(BTN_CANCEL,	DLG_Cancel);		
> 
> 	// Set Spin range (TODO: check if the max value is correct, copied from the unix version)
> 	SendMessage(GetDlgItem(hWnd,AP_RID_DIALOG_INSERTTABLE_SPIN_COLUMN),UDM_SETRANGE,(WPARAM)1,(WPARAM)9999);
> 	SendMessage(GetDlgItem(hWnd,AP_RID_DIALOG_INSERTTABLE_SPIN_ROW),UDM_SETRANGE,(WPARAM)1,(WPARAM)9999);
> 	
> 	// Limit to four chars
> 	SendMessage(GetDlgItem(hWnd,AP_RID_DIALOG_INSERTTABLE_TEXT_COLUMN),EM_LIMITTEXT,(WPARAM)5,(WPARAM)0);
> 	SendMessage(GetDlgItem(hWnd,AP_RID_DIALOG_INSERTTABLE_TEXT_ROW),EM_LIMITTEXT,(WPARAM)5,(WPARAM)0);
> 	
> 	return 1;		
> }
> 
> //
> // Gets the values from the spin controls
> //
> void AP_Win32Dialog_InsertTable::getCtrlValues(void)
> {	
> 	char 	szValue[BUFSIZE];
> 		
> 	if (GetDlgItemText(m_hwndDlg, AP_RID_DIALOG_INSERTTABLE_VAL_COLUMN, szValue, BUFSIZE ))	
> 		m_numCols = atoi(szValue);
> 	
> 	if (GetDlgItemText(m_hwndDlg, AP_RID_DIALOG_INSERTTABLE_VAL_ROW, szValue, BUFSIZE ))	
> 		m_numRows = atoi(szValue);
> 	
> 	
> }
> 
> BOOL AP_Win32Dialog_InsertTable::_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
> {
> 	WORD wNotifyCode = HIWORD(wParam);
> 	WORD wId = LOWORD(wParam);
> 	HWND hWndCtrl = (HWND)lParam;	
> 
> 	switch (wId)
> 	{
> 	case IDCANCEL:						
> 		m_answer = a_CANCEL;		
> 		// fall through
> 
> 	case IDOK:		
> 	
> 	 	m_answer = a_OK;
> 		getCtrlValues();		
> 		EndDialog(hWnd,0);
> 		return 1;
> 
> 	default:							// we did not handle this notification
> 		UT_DEBUGMSG(("WM_Command for id %ld\n",wId));
> 		return 0;						// return zero to let windows take care of it.
> 	}
> }
> 
> ----
> 
> // AbiWord
> // Copyright (C) 2000 AbiSource, Inc.
> // 
> // 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.
> //////////////////////////////////////////////////////////////////
> 
> //////////////////////////////////////////////////////////////////
> // THIS FILE IS INCLUDED BY .cpp AND .rc FILES.
> //
> // *** RC.exe IS BRAIN-DAMAGED.  GIVING THIS FILE AN .rc2
> // *** EXTENSION MAKES #INCLUDING THIS FILE FROM Win32Main.rc
> // *** WORK -- IF THE SUFFIX IS .h ONLY THE #DEFINES WORK, THE
> // *** DIALOGS DO NOT GET COMPILED.
> //
> //////////////////////////////////////////////////////////////////
> 
> #define AP_RID_DIALOG_INSERTTABLE_BTN_CANCEL			IDCANCEL
> #define AP_RID_DIALOG_INSERTTABLE_BTN_OK			IDOK
> 
> #define AP_RID_DIALOG_INSERTTABLE_COLUMN			1200
> #define AP_RID_DIALOG_INSERTTABLE_SPIN_COLUMN			1201
> #define AP_RID_DIALOG_INSERTTABLE_VAL_COLUMN			1202
> #define AP_RID_DIALOG_INSERTTABLE_TEXT_COLUMN			1203
> #define AP_RID_DIALOG_INSERTTABLE_SPIN_ROW			1204
> #define AP_RID_DIALOG_INSERTTABLE_TEXT_ROW			1205
> #define AP_RID_DIALOG_INSERTTABLE_VAL_ROW			1206
> 
> #ifdef RC_INVOKED
> // NOTE -- these placeholder strings get overridden at runtime 
> // NOTE -- they're just here to make sizing easier
> 
> //AP_RID_DIALOG_INSERT_TABLE DIALOG DISCARDABLE  0, 0, 200, 120
> //STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
> //CAPTION "Insert Table"
> //FONT 8, "MS Sans Serif"
> //BEGIN
> //    LTEXT           "Statistics:",		AP_RID_DIALOG_WORDCOUNT_TEXT_STATS,	7,19,43,8
> //    GROUPBOX        "",					AP_RID_DIALOG_WORDCOUNT_BOX,		7,24,119,70
> //    LTEXT           "Pages",			AP_RID_DIALOG_WORDCOUNT_TEXT_PAGE,	12,32,109,8
> //    LTEXT           "Words",			AP_RID_DIALOG_WORDCOUNT_TEXT_WORD,	12,42,109,8
> //    LTEXT           "Characters (no spaces)",	
> //										AP_RID_DIALOG_WORDCOUNT_TEXT_CH,	12,52,109,8
> //    LTEXT           "Characters (with spaces)",	
> //										AP_RID_DIALOG_WORDCOUNT_TEXT_CHSP,	12,62,109,8
> //    LTEXT           "Paragraphs",		AP_RID_DIALOG_WORDCOUNT_TEXT_PARA,	12,72,109,8
> //    LTEXT           "Lines",			AP_RID_DIALOG_WORDCOUNT_TEXT_LINE,	12,82,109,8
> //    GROUPBOX        "",					AP_RID_DIALOG_WORDCOUNT_BOX,		125,24,67,70
> //    RTEXT           "100,000,000",		AP_RID_DIALOG_WORDCOUNT_VAL_PAGE,	136,32,51,8
> //    RTEXT           "100,000,000",		AP_RID_DIALOG_WORDCOUNT_VAL_WORD,	136,42,51,8
> //    RTEXT           "100,000,000",		AP_RID_DIALOG_WORDCOUNT_VAL_CH,		136,52,51,8
> //    RTEXT           "100,000,000",		AP_RID_DIALOG_WORDCOUNT_VAL_CHSP,	136,62,51,8
> //    RTEXT           "100,000,000",		AP_RID_DIALOG_WORDCOUNT_VAL_PARA,	136,72,51,8
> //    RTEXT           "100,000,000",		AP_RID_DIALOG_WORDCOUNT_VAL_LINE,	136,82,51,8
> //    DEFPUSHBUTTON   "&Close",			AP_RID_DIALOG_WORDCOUNT_BTN_CLOSE,	130,101,62,14
> //    PUSHBUTTON      "&Update",			AP_RID_DIALOG_WORDCOUNT_BTN_UPDATE,	7,101,62,14
> //    AUTOCHECKBOX    "&Auto Update",	AP_RID_DIALOG_WORDCOUNT_CHK_AUTOUPDATE,7,7,60,10
> //    EDITTEXT        					AP_RID_DIALOG_WORDCOUNT_EDIT_RATE,69,7,23,10, ES_LEFT | WS_BORDER | WS_TABSTOP
> //    CONTROL         "Spin",				AP_RID_DIALOG_WORDCOUNT_SPIN_RATE,	
> //										"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | 
> //										UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,94,7,8,8
> //	LTEXT           "Seconds between updates",AP_RID_DIALOG_WORDCOUNT_TEXT_RATE,93,8,114,8
> //END
> 
> 
> AP_RID_DIALOG_INSERT_TABLE DIALOG DISCARDABLE  0, 0, 157, 87
> STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
> CAPTION "Insert Table"
> FONT 8, "MS Sans Serif"
> BEGIN
>     DEFPUSHBUTTON   "OK!",AP_RID_DIALOG_INSERTTABLE_BTN_OK,17,65,50,14
>     PUSHBUTTON      "Cancel",AP_RID_DIALOG_INSERTTABLE_BTN_CANCEL,77,65,50,14
>     EDITTEXT        AP_RID_DIALOG_INSERTTABLE_VAL_COLUMN,103,19,20,14,ES_AUTOHSCROLL
>     CONTROL         "Spin2",AP_RID_DIALOG_INSERTTABLE_SPIN_COLUMN,"msctls_updown32",UDS_SETBUDDYINT | 
>                     UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS ,122,19,
>                     11,14
>     LTEXT           "Number of columns",AP_RID_DIALOG_INSERTTABLE_TEXT_COLUMN,13,21,82,12
>     EDITTEXT        AP_RID_DIALOG_INSERTTABLE_VAL_ROW,103,39,20,14,ES_AUTOHSCROLL
>     CONTROL         "Spin2",AP_RID_DIALOG_INSERTTABLE_SPIN_ROW,"msctls_updown32",UDS_SETBUDDYINT | 
>                     UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,123,39,
>                     11,14
>     LTEXT           "Number of rows", AP_RID_DIALOG_INSERTTABLE_TEXT_ROW,14,42,80,12
>     LTEXT           "Table size", -1,5,5,37,8
> END
> 
> #endif /* RC_INVOKED */
> 
> ----
> 
> /* AbiWord
>  * Copyright (C) 2001 AbiSource, Inc.
>  * 
>  * 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 AP_Win32Dialog_InsertTable_H
> #define AP_Win32Dialog_InsertTable_H
> 
> #include "ap_Dialog_InsertTable.h"
> 
> class AP_Win32Dialog_InsertTable : public AP_Dialog_InsertTable
> {
> public:
> 	
> 	AP_Win32Dialog_InsertTable (XAP_DialogFactory *pDlgFactory, XAP_Dialog_Id id);
> 	virtual ~AP_Win32Dialog_InsertTable (void);
> 
> 	virtual void			runModal(XAP_Frame * pFrame);
> 
> 	static XAP_Dialog *		static_constructor(XAP_DialogFactory *, XAP_Dialog_Id id);
> 	
> 
> 	static BOOL CALLBACK		s_dlgProc(HWND,UINT,WPARAM,LPARAM);	
> 
> protected:
> 
> 	XAP_Win32Frame *	m_pWin32Frame;		
> 	HWND			m_hwndDlg;	//  dialog box Windows
> 	
> 	
> 	BOOL			_onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam);
> 	BOOL			_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam);   
> 	
> 	void 			getCtrlValues(void);
> };
> 
> #endif
> 
> ----
> 
> Index: src/wp/ap/win/Makefile
> ===================================================================
> RCS file: /cvsroot/abi/src/wp/ap/win/Makefile,v
> retrieving revision 1.54
> diff -c -r1.54 Makefile
> *** src/wp/ap/win/Makefile	25 May 2002 17:42:33 -0000	1.54
> --- src/wp/ap/win/Makefile	10 Jul 2002 14:07:22 -0000
> ***************
> *** 29,34 ****
> --- 29,35 ----
>   			ap_$(ABI_FE)DialogFactory.cpp		\
>   			ap_$(ABI_FE)Dialog_New.cpp		\
>   			ap_$(ABI_FE)Dialog_Break.cpp		\
> + 			ap_$(ABI_FE)Dialog_InsertTable.cpp	\
>   			ap_$(ABI_FE)Dialog_Field.cpp		\
>   			ap_$(ABI_FE)Dialog_Insert_DateTime.cpp	\
>   			ap_$(ABI_FE)Dialog_Lists.cpp		\
> Index: src/wp/ap/win/ap_Win32Dialog_All.h
> ===================================================================
> RCS file: /cvsroot/abi/src/wp/ap/win/ap_Win32Dialog_All.h,v
> retrieving revision 1.47
> diff -c -r1.47 ap_Win32Dialog_All.h
> *** src/wp/ap/win/ap_Win32Dialog_All.h	25 May 2002 17:42:32 -0000	1.47
> --- src/wp/ap/win/ap_Win32Dialog_All.h	10 Jul 2002 14:07:22 -0000
> ***************
> *** 65,72 ****
>   #	include "ap_Win32Dialog_InsertBookmark.h"
>   #	include "ap_Win32Dialog_InsertHyperlink.h"
>   #	include "ap_Win32Dialog_New.h"
> ! #   include "ap_Win32Dialog_MarkRevisions.h"
> ! #   include "ap_Win32Dialog_ListRevisions.h"
>   	// ... add new dialogs here ...
>   
>   #else
> --- 65,73 ----
>   #	include "ap_Win32Dialog_InsertBookmark.h"
>   #	include "ap_Win32Dialog_InsertHyperlink.h"
>   #	include "ap_Win32Dialog_New.h"
> ! #  	include "ap_Win32Dialog_MarkRevisions.h"
> ! #  	include "ap_Win32Dialog_ListRevisions.h"
> ! #   	include "ap_Win32Dialog_InsertTable.h"
>   	// ... add new dialogs here ...
>   
>   #else
> ***************
> *** 115,120 ****
> --- 116,122 ----
>   	DeclareDialog(AP_DIALOG_ID_FILE_NEW,		AP_Win32Dialog_New)
>   	DeclareDialog(AP_DIALOG_ID_MARK_REVISIONS,	AP_Win32Dialog_MarkRevisions)
>   	DeclareDialog(AP_DIALOG_ID_LIST_REVISIONS,	AP_Win32Dialog_ListRevisions)
> + 	DeclareDialog(AP_DIALOG_ID_INSERT_TABLE,	AP_Win32Dialog_InsertTable)
>    	// ... also add new dialogs here ...
>   
>   #endif
> Index: src/wp/ap/win/ap_Win32Resources.rc2
> ===================================================================
> RCS file: /cvsroot/abi/src/wp/ap/win/ap_Win32Resources.rc2,v
> retrieving revision 1.31
> diff -c -r1.31 ap_Win32Resources.rc2
> *** src/wp/ap/win/ap_Win32Resources.rc2	25 May 2002 17:42:33 -0000	1.31
> --- src/wp/ap/win/ap_Win32Resources.rc2	10 Jul 2002 14:07:22 -0000
> ***************
> *** 59,64 ****
> --- 59,65 ----
>   #define AP_RID_DIALOG_NEW						229
>   #define AP_RID_DIALOG_MARK_REVISIONS            230
>   #define AP_RID_DIALOG_LIST_REVISIONS            231
> + #define AP_RID_DIALOG_INSERT_TABLE		232
>   
>   
>   #include "ap_Win32Res_DlgPageSetup.rc2"
> ***************
> *** 85,87 ****
> --- 86,89 ----
>   #include "ap_Win32Res_DlgNew.rc2"
>   #include "ap_Win32Res_DlgMarkRevisions.rc2"
>   #include "ap_Win32Res_DlgListRevisions.rc2"
> + #include "ap_Win32Res_InsertTable.rc2"
> 
This archive was generated by hypermail 2.1.4 : Wed Jul 10 2002 - 12:16:07 EDT