ChefZ -- 磨劍錄 (A Coder's Log)

慣看秋月春風 一壺濁酒喜相逢 古今多少事 皆賦談笑中
posts - 42, comments - 3, trackbacks - 0, articles - 6

1). Run script to replace items in *.cpp, *.h  to correspondent names in wxWidgets first.
you can do this under cygwin if you have it installed. Or, alternatively, you can download http://unixutils.sourceforge.net and
have it installed. add the directory to the system and user path in your environment variable.

copy convert.sh and replacements to the target directory.

Under cygwin, navigate to your target direcotry, type ./convert.sh, or sh convert.sh if you use unixutils.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#!/bin/sh
#this has been tested under cygwin and tested just with unixutils - gs
for i in $(ls *.cpp *.h);
do
 echo "Replacing "$i;
 mv $i $i.bak
sed -f replacements $i.tmp >$i
rm $i.tmp
done
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

*replacement is attached at the end.


2). Redesign GUI in wxWidgets with wxSizer. There are tools available,  like DialogBlocks, wxFormBuilder, wx-Dsgn etc.

3). Replace all events with wxWidgets or using connect instead EVT_ tables.

4). Replace classes have MFC or QT dependencies.

5). add compiled pre-headers:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
stdwxh.h
///
#ifndef STDWXH_H
#define STDWXH_H
#include "wx/wxprec.h"              
#include "wx/notebook.h"            
#include "wx/statline.h"
#include "wx/tglbtn.h"
#include "wx/statusbar.h"

#ifdef _DEBUG
#include <crtdbg.h>
#define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
#else
#define DEBUG_NEW new
#endif

#pragma warning (disable:4089)
#include <map>
#include <vector>

using namespace std;

#endif

stdwxh.cpp
///
#include "stdwxh.h"

step 1: 將此 stdwxh.h 及 stdwxh.cpp 加入編程計劃
           在 stdwxh.cpp 屬性中作以下設定:
           所有配置 -> 創建/使用預編譯頭 = /Yc ->  預編譯頭文件 = $(ConfigurationName)\stdwxh.pch
step 2: 編譯 stdwxh.cpp
step 3: 在計劃屬性中作以下設定:
          所有配置 -> 創建/使用預編譯頭 = /Yu -> 通過文件創建/使用 PCH = stdwxh.h  -> 預編譯頭文件 =   
          $(ConfigurationName)\stdwxh.pch


$(ConfigurationName) 可改為自己的任何位址.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

These are not bit tasks but most require manual editing. This is the only draw back I can see. However, to extend old good applications running, it's worthy.


Appendix  replacments:
(This is for reference to MFC only, I didn't check carefully about validity for all applications. You create similar one for/with QT)

#
s/ON_BN_CLICKED/EVT_BUTTON/g
s/CWinApp/wxApp/g
s/AfxGetApp\(\)/\:\:wxGetApp\(\)/g
s/CObject/wxObject/g
s/CSize/wxSize/g
s/CDC/wxDC/g
s/CPoint/wxPoint/g
s/CFont/wxFont/g
s/CPen/wxPen/g
s/CBrush/wxBrush/g
s/CMetaFileDC/wxMetaFileDC/g
s/CWnd/wxWindow/g
s/CDialog/wxDialog/g
s/CButton/wxButton/g
s/CListBox/wxListBox/g
s/CComboBox/wxComboBox/g
s/CToolBar/wxToolBar/g
s/CStatusBar/wxStatusBar/g
s/CTreeCtrl/wxTreeCtrl/g
s/MywxListBox/CB_ListBox/g
s/afx_msg//g
s/CString/wxString/g
s/CDocument/wxDocument/g
s/CPropertyPage/wxPropertyGrid/g
s/AfxMessageBox/wxMessageBox/g
s/DECLARE_MESSAGE_MAP/DECLARE_EVENT_TABLE/g
s/BEGIN_MESSAGE_MAP/BEGIN_EVENT_TABLE/g
s/END_MESSAGE_MAP/END_EVENT_TABLE/g
s/IMPLEMENT_SERIAL_CLASS_CLASS/IMPLEMENT_SERIAL_CLASS/g
s/DECLARE_SERIAL_CLASS/DECLARE_SERIAL_CLASS/g
s/IMPLEMENT_SERIAL/IMPLEMENT_SERIAL_CLASS/g
s/DECLARE_DYNCREATE/DECLARE_DYNAMIC_CLASS/g
s/IMPLEMENT_DYNCREATE/IMPLEMENT_DYNAMIC_CLASS/g
s/OnInitDialog/InitDialog/g
s/IDOK/wxOK/g
s/IDCANCEL/wxCANCEL/g
s/IDYES/wxYES/g
s/IDNO/wxNO/g
s/MB_YESNO/wxYES_NO/g
s/MB_OK/wxOK/g
s/MB_CENTRE/wxCENTRE/g
s/MB_ICONEXCLAMATION/wxICON_EXCLAMATION/g
s/MB_ICONHAND/wxICON_HAND/g
s/MB_ICONERROR/wxICON_ERROR/g
s/MB_ICONQUESTION/wxICON_QUESTION/g
s/MB_ICONINFORMATION/wxICON_INFORMATION/g

s/CAnimateCtrl/wxMediaCtrl/g
s/CArchive//g
s/CArchiveException//g
s/CArray/wxArray/g
s/CAsyncMonikerFile/wxFile/g
s/CAsyncSocket/wxSocketBase/g
s/CBitmap/wxBitmap/g
s/CBitmapButton/wxBitmapButton/g
s/CBrush/wxBrush/g
s/CButton/wxButton/g
s/CCachedDataPathProperty//g
s/CCheckListBox/wxCheckListBox/g
s/CClientDC/wxClientDC/g
s/CColorDialog/wxColourDialog/g
s/CCmdTarget/wxEvtHandler/g
s/CComboBox/wxComboBox/g
s/CComboBoxEx/wxComboBox/g
s/CCommandLineInfo/wxCmdLineParser/g
s/CCommonDialog/wxDialog/g
s/CCriticalSection/wxCriticalSection/g
s/CDialog/wxDialog/g
s/CDatabase/wxDb/g
s/CDC/wxDC/g
s/CEdit/wxTextCtrl/g
s/CEditView/wxTextCtrl/g
s/CEvent/wxCondition/g
s/CFile/wxFile/g
s/CFileStatus/wxFSFile/g
s/CFrameWnd/wxFrame/g
s/CImageList/wxImageList/g
s/CList/wxList/g
s/CListBox/wxListBox/g
s/CMap/wxHashMap/g
s/CMapPtrToPtr/wxHashMap/g
s/CMapPtrToWord/wxHashMap/g
s/CMDIChildWnd/wxDocMDIChildFrame/g
s/CMDIFrameWnd/wxDocMDIParentFrame/g
s/CMenu/wxMenu/g
s/CMenuItemInfo/wxMenuItem/g
s/CMultiDocTemplate/wxDocTemplate/g
s/CMutex/wxMutex/g
s/CObject/wxObject/g
s/COleDropSource/wxDropSource/g
s/CPen/wxPen/g
s/CPropertySheet/wxNotebook/g
s/CRecentFileList/wxFileHistory/g
s/CRect/wxRect/g
s/CSemaphore/wxSemaphore/g
s/CSpinButtonCtrl/wxSpinButton/g
s/CStatic/wxStaticText/g
s/CTime/wxDateTime/g
s/CTreeCtrl/wxTreeCtrl/g
s/CTreeView/wxTreeView/g
s/CTypedPtrArray/wxPtrArray/g
s/CTypedPtrList/wxPtrList/g
s/CTypedPtrMap/wxMap/g
s/CUIntArray/wxArrayUint/g
s/CView/wxView/g
s/CWaitCursor/wxBusyCursor/g
s/CWindowDC/wxWindowDC/g
s/CWinThread/wxThread/g
s/CWnd/wxWindow/g
s/CWordArray/wxArray/g

s/ID_FILE_OPEN/wxID_OPEN/g
s/ID_FILE_CLOSE/wxID_CLOSE/g
s/ID_FILE_NEW/wxID_NEW/g
s/ID_FILE_SAVE/wxID_SAVE/g
s/ID_FILE_SAVE_AS/wxID_SAVEAS/g
s/ID_EDIT_CUT/wxID_CUT/g
s/ID_EDIT_COPY/wxID_COPY/g
s/ID_EDIT_PASTE/wxID_PASTE/g
s/ID_APP_EXIT/wxID_EXIT/g
s/ID_EDIT_UNDO/wxID_UNDO/g
s/ID_EDIT_REDO/wxID_REDO/g
s/ID_HELP_INDEX/wxID_HELP/g
s/ID_FILE_PRINT/wxID_PRINT/g
s/ID_FILE_PRINT_SETUP/wxID_PRINT_SETUP/g
s/ID_FILE_PRINT_PREVIEW/wxID_PREVIEW/g
#
s/BEGIN_MESSAGE_MAP/BEGIN_EVENT_TABLE/g
s/END_MESSAGE_MAP/END_EVENT_TABLE/g
s/DECLARE_DYNAMIC/DECLARE_CLASS/g
s/DECLARE_DYNCREATE/DECLARE_DYMAMIC_CLASS/g
s/IMPLEMENT_DYNAMIC/IMPLEMENT_CLASS/g
s/IMPLEMENT_DYNCREATE/IMPLEMENT_DYNAMIC_CLASS/g
s/IsKindOf\(RUNTIME_CLASS\(CWindow\)\)/IsKindOf(CLASSINFO\(wxWindow\)\)/g
s/CWinApp/wxApp/g
s/CObject/wxObject/g
s/CCmdTarget/wxEvtHandler/g
s/CCommandLineInfo/wxCmdLineParser/g
s/CMenu/wxMenu/g
s/CWaitCursor/wxBusyCursor/g
s/CDataExchange/wxGenericValidator/g
s/CFrameWnd/wxFrame/g
s/CMDIFrameWnd/wxMDIParentFrame/g
s/CMDIChildWnd/wxMDIChildFrame/g
s/CSplitterWnd/wxSplitterWindow/g
s/CToolBar/wxToolBar/g
s/CStatusBar/wxStatusBar/g
s/CPropertyPage/wxPanel/g
s/CPropertySheet/wwxPropertySheetDialog/g
s/CDialog/wxDialog/g
s/CColorDialog/wxColourDialog/g
s/CFileDialog/wxFileDialog/g
s/CFindReplaceDialog/wxFindReplaceDialog/g
s/CFontDialog/wxFontDialog/g
s/CPageSetupDialog/wxPageSetupDialog/g
s/CPrintDialog/wxPrintDialog/g
s/CAnimateCtrl/wxAnimationCtrl/g
s/CButton/wxButton/g
s/CBitmapButton/wxBitmapButton/g
s/CComboBox/wxComboBox/g
s/CDateTimeCtrl/wxDatePickerCtrl/g
s/CEdit/wxTextCtrl/g
s/CDragListBox/wxListBox/g
s/CListBox,/wxListBox/g
s/CCheckListBox/wxCheckListBox/g
s/CListCtrl/wxListCtrl/g
s/CMonthCalCtrl/wxCalendarCtrl/g
s/CProgressCtrl/wxGauge/g
s/CRichEditCtrl/wxTextCtrl/g
s/CScrollBar/wxScrollBar/g
s/CSliderCtrl/wxSlider/g
s/CSpinButtonCtrl/wxSpinCtrl/g
s/CStatusBarCtrl/wxStatusBar/g
s/CTabCtrl/wxNotebook/g
s/CToolBarCtrl/wxToolBar/g
s/CToolTipCtrl/wxToolTip/g
s/CTreeCtrl/wxtreeCtrl/g
s/CBitmap/wxImage/g
s/CBrush/wxBrush/g
s/CPen/wxPen/g
s/CFont/wxFont/g
s/CImageList/wxImageList/g
s/CPalette/wxPalette/g
s/CRgn/wxRegion/g
s/CClientDC/wxClientDC/g
s/CMetaFileDC/wxMetaFileDC/g
s/CPaintDC/wxPaintDC/g
s/CWindowDC/wxWindowDC/g
s/CDC/wxMemoryDC/g
s/CObArray/WX_DEFINE_ARRAY(/g
s/CPtrArray/WX_DEFINE_ARRAY(/g
s/CArray,/wxArray/g
s/CStringArray/wxArrayString/g
s/CUIntArray/wxArrayInt/g
s/CByteArray/wxArrayInt/g
s/CDWordArray,/wxArrayInt/g
s/CList/wxList/g
s/CStringList/wxArrayString/g
s/CMap/wxHashMap/g
s/CString/wxString/g
s/CPoint/wxPoint/g
s/CRect/wxRect/g
s/CSize/wxSize/g
s/CTime/wxDateTime/g
s/CTimeSpan/wxTimeSpan/g
s/COleVariant/wxVariant/g
s/CSocket/wxSocket/g
s/CFtpConnection/wxFTP/g
s/CHttpConnection/wxHTTP/g
s/CDocument/wxDocument/g
s/CView/wxView/g
s/CSingleDocTemplate/wxDocTemplate/g
s/CMultiDocTemplate/wxDocTemplate/g
s/CDocTemplate/wxDocTemplate/g
s/COleDataSource/wxDataObject/g
s/COleDropSource/wxDropSource/g
s/COleDropTarget/wxDropTarget/g
s/CFile/wxFile/g
s/CRecentFileList/wxFileHistory/g
s/CWinThread/wxThread/g
s/CCriticalSection/wxCriticalSection/g
s/CMutex/wxMutex/g
s/CSemaphore/wxSemaphore/g
s/ASSERT/wxASSERT/g
s/CCmdUI* pCmdUI/wxCommandEvent& event/g
s/ON_COMMAND/EVT_MENU/g
s/ON_UPDATE_COMMAND_UI/EVT_UPDATE_UI/g
s/OffsetRect/Offset/g
s/ON_WM_CLOSE/EVT_CLOSE/g
s/ON_WM_DESTROY/EVT_DESTROY/g
s/SetWindowText/SetTitle/g
s/EnableWindow/Show/g
s/AfxGetMainWnd\(\)/::wxGetApp\(\)->GetTopWindow\(\)/g
s/ON_WM_CONTEXTMENU/EVT_CONTEXT_MENU/g
s/ON_WM_SIZE/EVT_SIZE/g
s/virtual BOOL InitInstance/bool OnInit/g
s/virtual int ExitInstance/int OnExit/g
s/RUNTIME_CLASS/CLASSINFO/g


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理