changeset 0:79a92ddc3546

first release.
author pyon@macmini
date Wed, 16 Apr 2014 01:08:11 +0900
parents
children 9f0e0d0ae5de
files Makefile main.cpp main.h myframe.cpp myframe.h sample.ico sample.rc sample.xpm
diffstat 8 files changed, 412 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Wed Apr 16 01:08:11 2014 +0900
@@ -0,0 +1,92 @@
+# Makefile for wxWidgets Application
+# Last Change: 11-Apr-2014.
+# by Takayuki Mutoh
+#
+
+PROGNAME = hanzen
+
+### Variables ###
+OBJDIR = ./obj
+CXX = g++
+vpath %.cpp ./src
+vpath %.h   ./include
+
+# For Microsoft Windows
+ifdef COMSPEC
+WXCXXFLAGS = -I/local/lib/wx/include/msw-unicode-static-3.0 -I/local/include/wx-3.0 -D_LARGEFILE_SOURCE=unknown -D__WXMSW__ -mthreads
+WXLIBS = -L/local/lib -Wl,--subsystem,windows -mwindows /local/lib/libwx_mswu_richtext-3.0.a /local/lib/libwx_mswu_xrc-3.0.a /local/lib/libwx_mswu_webview-3.0.a /local/lib/libwx_mswu_qa-3.0.a /local/lib/libwx_baseu_net-3.0.a /local/lib/libwx_mswu_html-3.0.a /local/lib/libwx_mswu_adv-3.0.a /local/lib/libwx_mswu_core-3.0.a /local/lib/libwx_baseu_xml-3.0.a /local/lib/libwx_baseu-3.0.a -lwxregexu-3.0 -lwxexpat-3.0 -lwxtiff-3.0 -lwxjpeg-3.0 -lwxpng-3.0 -lwxzlib-3.0 -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -ladvapi32 -lwsock32 -lgdi32
+EXECUTABLE = $(PROGNAME).exe
+
+# For Apple OSX
+else 
+WXCXXFLAGS = -I/opt/local/lib/wx/include/osx_cocoa-unicode-2.9 -I/opt/local/include/wx-2.9 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__ 
+WXLIBS = -L/opt/local/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -framework QuickTime -lwx_osx_cocoau_richtext-2.9 -lwx_osx_cocoau_xrc-2.9 -lwx_osx_cocoau_webview-2.9 -lwx_osx_cocoau_html-2.9 -lwx_osx_cocoau_qa-2.9 -lwx_osx_cocoau_adv-2.9 -lwx_osx_cocoau_core-2.9 -lwx_baseu_xml-2.9 -lwx_baseu_net-2.9 -lwx_baseu-2.9 
+
+EXECUTABLE = $(PROGNAME).app/Contents/Pkginfo
+
+endif
+
+CXXFLAGS = $(WXCXXFLAGS) -I./include -I./image
+LIBS = $(WXLIBS) -static-libgcc -static-libstdc++
+
+
+OBJ = $(OBJDIR)/main.o \
+	  $(OBJDIR)/myframe.o
+
+ifdef COMSPEC
+OBJMSW = $(OBJ) $(OBJDIR)/sample_rc.o
+endif
+
+
+### Targets ###
+
+all: $(EXECUTABLE)
+
+
+$(PROGNAME): $(OBJMSW)
+	$(CXX) $^ -o $@ $(LIBS)
+
+
+$(OBJDIR)/main.o: main.cpp main.h myframe.h
+	-mkdir -p $(OBJDIR)
+	$(CXX) -c $< -o $@ $(CXXFLAGS)
+
+$(OBJDIR)/myframe.o: myframe.cpp myframe.h
+	$(CXX) -c $< -o $@ $(CXXFLAGS)
+
+
+# for icon
+ifdef COMSPEC
+$(OBJDIR)/sample_rc.o: sample.rc
+	windres -i sample.rc -o $@ -I/local/include/wx-3.0
+endif
+
+$(EXECUTABLE): $(PROGNAME)
+ifdef COMSPEC
+	strip --strip-all $(EXECUTABLE)
+	./$(PROGNAME).exe
+else
+	-mkdir -p $(PROGNAME).app/Contents
+	-mkdir -p $(PROGNAME).app/Contents/MacOS
+	-mkdir -p $(PROGNAME).app/Contents/Resources
+	
+	sed -e "s/IDENTIFIER/$(PROGNAME)/" \
+	-e "s/EXECUTABLE/$(PROGNAME)/" \
+	-e "s/VERSION/0.0/" \
+	Info.plist.in > $(PROGNAME).app/Contents/Info.plist
+	
+	echo -n "APPL????" > $(EXECUTABLE)
+	
+	ln -f $(PROGNAME) $(PROGNAME).app/Contents/MacOS/$(PROGNAME)
+	cp -f wxmac.icns $(PROGNAME).app/Contents/Resources/wxmac.icns
+
+	open $(PROGNAME).app
+endif
+
+clean:
+	rm -f $(PROGNAME) $(PROGNAME).exe
+	rm -f $(OBJDIR)/*.o
+	rm -rf $(PROGNAME).app
+
+.PHONY:	all clean
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Apr 16 01:08:11 2014 +0900
@@ -0,0 +1,34 @@
+// Filename   : main.cpp
+// Last Change: 14-Apr-2014.
+//
+#include "main.h"
+#include "myframe.h"
+
+IMPLEMENT_APP(MyApp)
+
+IMPLEMENT_CLASS( MyApp, wxApp )
+
+MyApp::MyApp()
+{
+}
+MyApp::~MyApp()
+{
+}
+
+bool MyApp::OnInit()
+{
+    if ( !wxApp::OnInit() ) return false;
+
+    long style = wxDEFAULT_FRAME_STYLE;
+    style = style & ~( wxMAXIMIZE_BOX );
+    MyFrame *mainframe = new MyFrame( NULL, wxID_ANY, wxT("HanZen - Hankaku Zenkaku Converter -"), wxDefaultPosition, wxSize( 600, 400 ), style );
+    mainframe->Show(true);
+
+    return true;
+}
+
+int MyApp::OnExit()
+{
+    return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.h	Wed Apr 16 01:08:11 2014 +0900
@@ -0,0 +1,20 @@
+// Filename   : main.h
+// Last Change: 15-Jan-2014.
+//
+#include "wx/wx.h"
+
+// private classes
+// Define a new application type, each program should derive a class from wxApp
+class MyApp : public wxApp
+{
+    DECLARE_CLASS( MyApp )
+public:
+    MyApp();
+    ~MyApp();
+
+    virtual bool OnInit();
+    virtual int  OnExit();
+};
+
+DECLARE_APP(MyApp)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/myframe.cpp	Wed Apr 16 01:08:11 2014 +0900
@@ -0,0 +1,137 @@
+// Filename   : myframe.cpp
+// Last Change: 15-Apr-2014.
+//
+
+#include "myframe.h"
+#include "sample.xpm"
+
+MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) 
+    : wxFrame( parent, id, title, pos, size, style )
+{
+    this->SetIcon( wxIcon( wxT("sample") ) );
+	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
+	this->SetBackgroundColour( wxColour( 23, 181, 63 ) );
+	
+	wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL );
+	
+	wxBoxSizer* bSizerButton = new wxBoxSizer( wxHORIZONTAL );
+	
+	m_buttonPaste = new wxButton( this, ID_PASTE, wxT("Paste"), wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerButton->Add( m_buttonPaste, 0, wxALL, 5 );
+	
+	m_comboBoxDirection = new wxComboBox( this, wxID_ANY, wxT("select direction !"), wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
+	m_comboBoxDirection->Append( wxT("Zenkaku to Hankaku") );
+	m_comboBoxDirection->Append( wxT("Hankaku to Zenkaku") );
+	bSizerButton->Add( m_comboBoxDirection, 0, wxALL, 5 );
+	
+	m_buttonConvert = new wxButton( this, ID_CONVERT, wxT("Convert"), wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerButton->Add( m_buttonConvert, 0, wxALL, 5 );
+	
+	m_buttonCopy = new wxButton( this, ID_COPY, wxT("Copy"), wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerButton->Add( m_buttonCopy, 0, wxALL, 5 );
+	
+	m_buttonClear = new wxButton( this, ID_CLEAR, wxT("Clear"), wxDefaultPosition, wxDefaultSize, 0 );
+	bSizerButton->Add( m_buttonClear, 0, wxALL, 5 );
+	
+	bSizerTop->Add( bSizerButton, 0, wxEXPAND, 5 );
+	
+	m_textCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
+	bSizerTop->Add( m_textCtrl, 1, wxALL|wxEXPAND, 5 );
+	
+	this->SetSizer( bSizerTop );
+	this->Layout();
+	
+	this->Centre( wxBOTH );
+}
+
+MyFrame::~MyFrame()
+{
+}
+
+// Event Table
+BEGIN_EVENT_TABLE( MyFrame, wxFrame )
+    EVT_BUTTON( ID_PASTE,   MyFrame::OnPaste   )
+    EVT_BUTTON( ID_CONVERT, MyFrame::OnConvert )
+    EVT_BUTTON( ID_COPY,    MyFrame::OnCopy    )
+    EVT_BUTTON( ID_CLEAR,   MyFrame::OnClear   )
+END_EVENT_TABLE()
+
+// Functions
+void MyFrame::OnPaste( wxCommandEvent& WXUNUSED(event) )
+{
+    m_textCtrl->Clear();
+    if ( wxTheClipboard->Open() ) {
+        if( wxTheClipboard->IsSupported( wxDF_TEXT ) ) {
+            wxTextDataObject data;
+            wxTheClipboard->GetData( data );
+            m_textCtrl->ChangeValue( data.GetText() );
+        }
+        wxTheClipboard->Close();
+    }
+}
+
+void MyFrame::OnConvert( wxCommandEvent& WXUNUSED(event) )
+{
+    wxArrayString han, zen;
+    han.Add( wxT("0") ); zen.Add( wxT("0") );
+    han.Add( wxT("1") ); zen.Add( wxT("1") );
+    han.Add( wxT("2") ); zen.Add( wxT("2") );
+    han.Add( wxT("3") ); zen.Add( wxT("3") );
+    han.Add( wxT("4") ); zen.Add( wxT("4") );
+    han.Add( wxT("5") ); zen.Add( wxT("5") );
+    han.Add( wxT("6") ); zen.Add( wxT("6") );
+    han.Add( wxT("7") ); zen.Add( wxT("7") );
+    han.Add( wxT("8") ); zen.Add( wxT("8") );
+    han.Add( wxT("9") ); zen.Add( wxT("9") );
+    han.Add( wxT("-") ); zen.Add( wxT("-") );
+    //han.Add( wxT("+") ); zen.Add( wxT("+") );
+    han.Add( wxT("=") ); zen.Add( wxT("=") );
+    han.Add( wxT("/") ); zen.Add( wxT("/") );
+    han.Add( wxT("@") ); zen.Add( wxT("@") );
+    //han.Add( wxT("(") ); zen.Add( wxT("(") );
+    //han.Add( wxT(")") ); zen.Add( wxT(")") );
+    han.Add( wxT("<") ); zen.Add( wxT("<") );
+    han.Add( wxT(">") ); zen.Add( wxT(">") );
+    //han.Add( wxT("*") ); zen.Add( wxT("*") );
+    han.Add( wxT("#") ); zen.Add( wxT("#") );
+    han.Add( wxT("!") ); zen.Add( wxT("!") );
+    //han.Add( wxT("?") ); zen.Add( wxT("?") );
+    han.Add( wxT(":") ); zen.Add( wxT(":") );
+    han.Add( wxT(";") ); zen.Add( wxT(";") );
+    //han.Add( wxT(".") ); zen.Add( wxT(".") );
+    //han.Add( wxT(",") ); zen.Add( wxT(",") );
+
+    wxString buf = m_textCtrl->GetValue();
+
+    // Z -> H ok
+    if ( m_comboBoxDirection->GetSelection() == 0 ) {
+        for ( int i = 0; i < zen.GetCount(); i++ ) {
+            wxRegEx z( zen[i] );
+            z.ReplaceAll( &buf, han[i] );
+        }
+    }
+    // H -> Z
+    else if ( m_comboBoxDirection->GetSelection() == 1 ){
+        for ( int i = 0; i < han.GetCount(); i++ ) {
+            wxRegEx h( han[i] );
+            h.ReplaceAll( &buf, zen[i] );
+        }
+    }
+    else {
+        return;
+    }
+
+    m_textCtrl->ChangeValue( buf );
+}
+
+void MyFrame::OnCopy( wxCommandEvent& WXUNUSED(event) )
+{
+    m_textCtrl->SelectAll();
+    m_textCtrl->Copy();
+}
+
+void MyFrame::OnClear( wxCommandEvent& WXUNUSED(event) )
+{
+    m_textCtrl->Clear();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/myframe.h	Wed Apr 16 01:08:11 2014 +0900
@@ -0,0 +1,54 @@
+// Filename   : myframe.cpp
+// Last Change: 15-Apr-2014.
+//
+
+#ifndef __MYFRAME_H__
+#define __MYFRAME_H__
+
+#include <wx/artprov.h>
+#include <wx/xrc/xmlres.h>
+#include <wx/string.h>
+#include <wx/button.h>
+#include <wx/gdicmn.h>
+#include <wx/font.h>
+#include <wx/colour.h>
+#include <wx/settings.h>
+#include <wx/combobox.h>
+#include <wx/sizer.h>
+#include <wx/textctrl.h>
+#include <wx/clipbrd.h>
+#include <wx/frame.h>
+#include <wx/regex.h>
+
+class MyFrame : public wxFrame 
+{
+    DECLARE_EVENT_TABLE()
+	private:
+	
+	protected:
+		wxButton*   m_buttonPaste;
+		wxComboBox* m_comboBoxDirection;
+		wxButton*   m_buttonConvert;
+		wxButton*   m_buttonCopy;
+		wxButton*   m_buttonClear;
+		wxTextCtrl* m_textCtrl;
+	
+	public:
+		MyFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("HanZen"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
+		~MyFrame();
+        void OnPaste( wxCommandEvent& WXUNUSED(event) );
+        void OnConvert( wxCommandEvent& WXUNUSED(event) );
+        void OnCopy( wxCommandEvent& WXUNUSED(event) );
+        void OnClear( wxCommandEvent& WXUNUSED(event) );
+};
+
+enum
+{
+    ID_PASTE = wxID_HIGHEST + 1,
+    ID_CONVERT,
+    ID_COPY,
+    ID_CLEAR,
+};
+
+#endif //__MYFRAME_H__
+
Binary file sample.ico has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sample.rc	Wed Apr 16 01:08:11 2014 +0900
@@ -0,0 +1,32 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        samples/samples.rc
+// Purpose:     a standard Win32 .rc file for the wxWindows samples
+// Author:      Vadim Zeitlin
+// Modified by:
+// Created:     04.08.03
+// RCS-ID:      $Id: sample.rc 22863 2003-08-14 14:08:53Z VS $
+// Copyright:   (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// this minimal resource file is all what is needed for most of the wxWindows
+// samples
+
+// note that the icon used by the Explorer (i.e. the programs icon) is the
+// first icon in the executable and the icons are sorted both by their order
+// (Win9x) and by alphabetically (!) (NT), so put this icon first and give it
+// a name starting with "a"
+aaaaaaaa ICON "sample.ico"
+
+// this icon is used with wxFrame::SetIcon()
+sample ICON "sample.ico"
+
+// set this to 1 if you don't want to use manifest resource (manifest resource
+// is needed to enable visual styles on Windows XP - see docs/msw/winxp.txt
+// for more information)
+#define wxUSE_NO_MANIFEST 0
+
+// this is not always needed but doesn't hurt (except making the executable
+// very slightly larger): this file contains the standard icons, cursors, ...
+#include "wx/msw/wx.rc"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sample.xpm	Wed Apr 16 01:08:11 2014 +0900
@@ -0,0 +1,43 @@
+/* XPM */
+static const char *sample_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"32 32 5 1",
+". c #FCFEFC",
+"O c #EC1E24",
+"X c #3C4ACC",
+"  c #22B14C",
+"o c #FFF200",
+/* pixels */
+"                ................",
+"                .XXXX......XXXX.",
+"                .XXXX......XXXX.",
+"                .XXXX......XXXX.",
+"                .XXXX......XXXX.",
+"                .XXXX......XXXX.",
+"                .XXXXXXXXXXXXXX.",
+"                .XXXXXXXXXXXXXX.",
+"                .XXXXXXXXXXXXXX.",
+"                .XXXXXXXXXXXXXX.",
+"                .XXXX......XXXX.",
+"                .XXXX......XXXX.",
+"                .XXXX......XXXX.",
+"                .XXXX......XXXX.",
+"                .XXXX......XXXX.",
+"                ................",
+"................oooooooooooooooo",
+".OOOOOOOOOOOOOO.oooooooooooooooo",
+".OOOOOOOOOOOOOO.oooooooooooooooo",
+".OOOOOOOOOOOOOO.oooooooooooooooo",
+".OOOOOOOOOOOOO..oooooooooooooooo",
+"........OOOOO...oooooooooooooooo",
+".......OOOOO....oooooooooooooooo",
+"......OOOOO.....oooooooooooooooo",
+".....OOOOO......oooooooooooooooo",
+"....OOOOO.......oooooooooooooooo",
+"...OOOOO........oooooooooooooooo",
+"..OOOOOOOOOOOOO.oooooooooooooooo",
+".OOOOOOOOOOOOOO.oooooooooooooooo",
+".OOOOOOOOOOOOOO.oooooooooooooooo",
+".OOOOOOOOOOOOOO.oooooooooooooooo",
+"................oooooooooooooooo"
+};