# HG changeset patch # User pyon@macmini # Date 1538296024 -32400 # Node ID d3b8cd5aeb7006cfe3ca017e447a3f6394e776c6 make repo. diff -r 000000000000 -r d3b8cd5aeb70 Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,104 @@ +# Makefile for wxWidgets Application +# Last Change: 2018-07-17 Tue 04:53:26. +# by Takayuki Mutoh +# + +PROGNAME = grsearcher + +### 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.1 -I/local/include/wx-3.1 -D_LARGEFILE_SOURCE=unknown -D__WXMSW__ -mthreads +WXLIBS =-L/local/lib -Wl,--subsystem,windows -mwindows /local/lib/libwx_mswu_xrc-3.1.a /local/lib/libwx_mswu_qa-3.1.a /local/lib/libwx_baseu_net-3.1.a /local/lib/libwx_mswu_html-3.1.a /local/lib/libwx_mswu_adv-3.1.a /local/lib/libwx_mswu_core-3.1.a /local/lib/libwx_baseu_xml-3.1.a /local/lib/libwx_baseu-3.1.a -lwxtiff-3.1 -lwxjpeg-3.1 -lwxpng-3.1 -lwxregexu-3.1 -lwxscintilla-3.1 -lwxexpat-3.1 -lwxzlib-3.1 -lrpcrt4 -loleaut32 -lole32 -luuid -luxtheme -lwinspool -lwinmm -lshell32 -lshlwapi -lcomctl32 -lcomdlg32 -ladvapi32 -lversion -lwsock32 -lgdi32 -loleacc +LIBS = $(WXLIBS) -static + +EXECUTABLE = $(PROGNAME).exe + +# For Apple OSX +else +WXCXXFLAGS = -I/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.1/lib/wx/include/osx_cocoa-unicode-3.1 -I/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.1/include/wx-3.1 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__ +WXLIBS = -L/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxWidgets/3.1/lib -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lwx_osx_cocoau_xrc-3.1 -lwx_osx_cocoau_html-3.1 -lwx_osx_cocoau_qa-3.1 -lwx_osx_cocoau_adv-3.1 -lwx_osx_cocoau_core-3.1 -lwx_baseu_xml-3.1 -lwx_baseu_net-3.1 -lwx_baseu-3.1 +LIBS = $(WXLIBS) + +EXECUTABLE = $(PROGNAME).app/Contents/PkgInfo + +endif + +CXXFLAGS = $(WXCXXFLAGS) -I./include -I./image + + +OBJ = $(OBJDIR)/main.o \ + $(OBJDIR)/auth.o \ + $(OBJDIR)/rsearcher.o + +ifdef COMSPEC +OBJMSW = $(OBJ) $(OBJDIR)/sample_rc.o +endif + + +### Targets ### + +all: $(EXECUTABLE) + + +$(PROGNAME): $(OBJ) $(OBJMSW) + $(CXX) $^ -o $@ $(LIBS) + + +$(OBJDIR)/main.o: main.cpp main.h rsearcher.h + -mkdir -p $(OBJDIR) + $(CXX) -c $< -o $@ $(CXXFLAGS) + +$(OBJDIR)/rsearcher.o: rsearcher.cpp rsearcher.h + $(CXX) -c $< -o $@ $(CXXFLAGS) + +$(OBJDIR)/auth.o: auth.cpp auth.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.1 +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 "APPL????" > $(EXECUTABLE) + + ln -f $(PROGNAME) $(PROGNAME).app/Contents/MacOS/$(PROGNAME) + cp -f wxmac.icns $(PROGNAME).app/Contents/Resources/wxmac.icns + + open $(PROGNAME).app +endif + +go: + go build -o rsearcher main.go + +tgz: + tar cvfz a.tgz src include Makefile memo.txt + +clean: + rm -f $(PROGNAME) $(PROGNAME).exe + rm -f $(OBJDIR)/*.o + rm -rf $(PROGNAME).app + +.PHONY: all clean + diff -r 000000000000 -r d3b8cd5aeb70 app.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app.conf Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,5 @@ +[Geometry] +x=383 +y=48 +w=1220 +h=967 diff -r 000000000000 -r d3b8cd5aeb70 doc/Todo --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/Todo Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,72 @@ +** client.exe の機能 ************************************************************ +* 手動によりバージョンアップ + * verup.bat をダブルクリック + # verup.bat + client -r 192.168.0.1:3910 + # GET /release/grsearcher.exe, /release/client1.exe + copy client1.exe client.exe + +* 毎回 clientで auth.db と hhs.db を取得 + > client -u 192.168.0.1:3910 + # GET /db/auth.db, /db/hhs.db, /db/index.db (5day) + + GUI(grsearchr) 終了時に auth.db と hhs.db は削除 + * auth.db は任意の、hhs.db は月一のアップデートだが、漏洩防止のため毎回削除 + * 毎月10のつく日に index.db を取得 + +* client で画像取得 + > client.exe 192.168.0.1:3910 0800012345 20170105 + # date:00000000 で最新審査会を取得する構想は廃止 + +** crypto/crypto.exe の機能 ***************************************************** +* crypto.go 作成 + + auth 用 ( ハッシュ化 ) + * -a で plaintext を暗号化 + > crypto.exe -a plaintext -s salt // done. + * -b で auth.csv を暗号化 + > crypto.exe -b auth.csv -s salt > auth.db + * -c で 認証チェック + > crypto.exe -c auth.db -s salt user passwd + + user/passwd が一致したら "39 user" を返す + + 認証なしのテストのときは user/passwd: test/test + + auth.db のための salt は gui に内蔵する + + hhs 用 ( 双方向、キーは crypto.go と gui に内蔵 ) + * -d で復号化、-e で暗号化 + > crypto.exe -d hhs.db key > hhs.csv + > crypto.exe -e hhs.csv > hhs.db + * -f と -g で 認証チェック + > crypto.exe -f hhs.db -g hhs key + + hhs/key が一致したら "39 hhs" を返す + +** imgtgz の機能 **************************************************************** +* jpeg を 1.jpg, ..., 5.jpg とリネームし tgz にする. + +** server の機能 **************************************************************** +* 単なる web-server + + log 機能を追加 ( ver1.1 ) + +** その他 *********************************************************************** +* IP Address + Seibu kai-cl11 192.168.31.202 75-1130 + Rokugo kai-cl26 192.168.14.201 88-8404 + Nishiki kai-cl17 192.168.16.202 49-6210 + #Nishiki kai-cl25 192.168.16.201 + Isono 192.168.21.151 + Fuguta 192.168.21.153 + +* server ( FreeBSD ) + server_root/server, crypto, imgtgz + + db/auth.db, hhs.db, index.db + + release/grsearchr.exe, client.exe + + images/20180707/0800012345.tgz, ... + +* client ( Windows ) + rsearcher_root/grsearcher.exe, client.exe, crypto.exe + auth.db, hhs.db, index.db + + .cache/20180707_1.jpg, ... + + image/*.png + +__DONE__ + +* server は rc で起動する(cron は電源入れ忘れがあるからダメ) + + Handbook の 11.2 + diff -r 000000000000 -r d3b8cd5aeb70 go/client.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/go/client.go Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,173 @@ +/* + client.go : client-program. + Version : 0.0 + Last Change: 2018-09-30 Sun 17:09:04. + + install to: rsearcher_root/ + + rsearcher_root/client.exe + + grsearcher.exe + + app.conf + + verup.bat + + auth.db ( temporary ) + + hhs.db ( temporary ) + + index.db ( 10 days ) + + image/*.png + + doc/ + + .cache/*.jpg ( temporary ) + + $ client.exe -r 192.168.0.1:3910 # get new release + $ client.exe -u 192.168.0.1:3910 # get new dbs + $ client.exe 192.168.0.1:3910 0800012345 20171231 # get images +*/ +package main + +import ( + "archive/tar" + "bytes" + "compress/gzip" + "flag" + "fmt" + "io" + "io/ioutil" + "log" + "net/http" + "os" + "path/filepath" + "regexp" + "time" +) + +func main() { + var upgrade = flag.Bool( "r", false, "" ) // get grsearcher.exe, client.exe + var update = flag.Bool( "u", false, "" ) // get auth.db, hhs.db, index.db(5day) + flag.Parse() + + if *upgrade { + if flag.NArg() != 1 { + fmt.Fprintf( os.Stderr, "no remote host.\n" ) + os.Exit( 1 ) + } + fmt.Println( "Getting grsearcher.exe..." ) + host := flag.Args()[0] + if _, err := get_file( host, "/release/grsearcher.exe", "grsearcher.exe" ); err != nil { + log.Fatal( err ) + } + fmt.Println( "Getting client.exe..." ) + if _, err := get_file( host, "/release/client.exe", "client1.exe" ); err != nil { + log.Fatal( err ) + } + os.Exit( 0 ) + } + + if *update { + if flag.NArg() != 1 { + fmt.Fprintf( os.Stderr, "no remote host.\n" ) + os.Exit( 1 ) + } + fmt.Println( "Getting auth.db..." ) + host := flag.Args()[0] + if _, err := get_file( host, "/db/auth.db", "auth.db" ); err != nil { + log.Fatal( err ) + } + fmt.Println( "Getting hhs.db..." ) + if _, err := get_file( host, "/db/hhs.db", "hhs.db" ); err != nil { + log.Fatal( err ) + } + + if time.Now().Day() % 10 == 0 { + fmt.Println( "Getting index.db..." ) + if _, err := get_file( host, "/db/index.db", "index.db" ); err != nil { + log.Fatal( err ) + } + } + os.Exit( 0 ) + } + + // main + if flag.NArg() != 3 { + fmt.Fprintf( os.Stderr, "bad argument.\n" ) + os.Exit( 1 ) + } + + host := flag.Args()[0] + h := flag.Args()[1] + d := flag.Args()[2] + + r, err := regexp.Compile( "^0[1238][0-9]{8}$" ) + if err != nil { + log.Fatal( err ) + } + m := r.FindString( h ) + if len( m ) == 0 { + fmt.Fprintf( os.Stderr, "bad hno.\n" ) + os.Exit( 1 ) + } + + rfile := "/images/" + d + "/" + h + ".tgz" + b, err := get_file( host, rfile, "" ) + if err != nil { + log.Fatal( err ) + } + if err := untgz_images( d, b ); err != nil { + log.Fatal( err ) + } +} + +/* Subroutines */ +// HTTP GET +func get_file( host, rfile, lfile string ) ( []byte, error ) { + res, err := http.Get( "http://" + host + "/" + rfile ) + if err != nil { + return nil, err + } + b, err := ioutil.ReadAll( res.Body ) + res.Body.Close() + if err != nil { + return nil, err + } + if lfile != "" { + if err := ioutil.WriteFile( lfile, b, 0644 ); err != nil { + return nil, err + } + return nil, nil + } + return b, nil +} + +// Un-Tar/Gzip +func untgz_images( d string, b []byte ) error { + br := bytes.NewReader( b ) + zr, err := gzip.NewReader( br ) + if err != nil { + return err + } + + tr := tar.NewReader( zr ) + for i := 1; ; i++ { + //hdr, err := tr.Next() + _, err := tr.Next() + if err == io.EOF { + break // End of archive + } + if err != nil { + return err + } + //f, _ := os.Create( hdr.Name ) + fn := fmt.Sprintf( "%s_%d.jpg", d, i ) + fn = fmt.Sprintf( "00000000_%d.jpg", i ) // for test + + fn = filepath.Join( ".cache", fn ) + f, _ := os.Create( fn ) + if _, err := io.Copy( f, tr ); err != nil { + return err + } + f.Close() + } + + if err := zr.Close(); err != nil { + return err + } + return nil +} + diff -r 000000000000 -r d3b8cd5aeb70 go/crypto.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/go/crypto.go Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,77 @@ +/* + crypto.go : crypto-program. + Version : 0.0 + Last Change: 2018-09-30 Sun 16:47:45. + + install to: rsearcher_root/ + server_root/ +*/ +package main + +import ( + "crypto/sha256" + "fmt" + "flag" + "os" +) + +func main() { + salt := flag.String( "s", "#!@-", "salt." ) + enca := flag.String( "a", "", "encrypt plaintext." ) + encb := flag.String( "b", "", "encrypt csv-file." ) + coll := flag.String( "c", "", "collate user/password." ) + + decr := flag.String( "d", "", "deecrypt hhs." ) + encr := flag.String( "e", "", "encrypt hhs." ) + chdb := flag.String( "f", "", "collate hhs." ) + chhs := flag.String( "g", "", "collate hhs." ) + + flag.Parse() + + if *enca != "" { + buf := *salt + enc_sha256( *enca ) + *salt + fmt.Println( enc_sha256( buf ) ) + os.Exit( 0 ) // done. + } + + if *encb != "" { + r := csv.NewReader(strings.NewReader(in)) + for { + record, err := r.Read() + if err == io.EOF { + break + } + if err != nil { + log.Fatal( err ) + } + buf := *salt + enc_sha256( record[1] ) + *salt + fmt.Println( record[0], ",", enc_sha256( buf ) ) + } + } + + if *coll != "" { + } + + if *decr != "" { + } + + if *encr != "" { + } + + if *chdb != "" && *chhs != "" { + } + + fmt.Fprintf( os.Stderr, "bad argument\n" ) + os.Exit( 1 ) +} + +func enc_sha256( text string ) string { + h := sha256.New() + h.Write( []byte( text ) ) + return fmt.Sprintf( "%x", h.Sum( nil ) ) +} + +func encrypt( text string ) []byte { + return nil +} + diff -r 000000000000 -r d3b8cd5aeb70 go/imgtgz.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/go/imgtgz.go Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,131 @@ +/* imgtgz + [usage(1) archive images.] + $ mkdir 20170707 + $ cd 20170707 + $ ./imgtgz /mnt/nas/2017/20170702/xxxxx/0300012345 + + [usage(2) list directory.( for archive )] + $ cd /mnt/nas/2017/20170702 + $ ./imgtgz -l + */ +package main + +import ( + "archive/tar" + "compress/gzip" + "fmt" + "io" + "log" + "os" + "path/filepath" + "regexp" + "strings" +) + + +func main() { + if len( os.Args ) == 1 { + help := ` + [usage(1) archive images.] + $ mkdir 20170707 + $ cd 20170707 + $ ./imgtgz /mnt/nas/2017/20170702/xxxxx/0300012345 + + [usage(2) list directory.( for archive )] + $ cd /mnt/nas/2017/20170702 + $ ./imgtgz -l +` + fmt.Fprintf( os.Stderr, help ) + os.Exit( 1 ) + } + + if strings.Compare( os.Args[1], "-l" ) == 0 { + list_dir() + os.Exit( 0 ) + } + + hdir := os.Args[1] //hdir := "Y:\\2014\\20141030\\隗帝、ィシ箪\0100072890" + do_archive( hdir ) +} + +func list_dir() { + r, err := regexp.Compile( "0[1238][0-9]{8}$" ) + if err != nil { + log.Fatal( err ) + } + + filepath.Walk( ".", func( path string, info os.FileInfo, err error ) error { + if info.IsDir() && r.MatchString( path ) { + p, _ := filepath.Abs( "." ) + p = filepath.Join( p, path ) + p = filepath.FromSlash( p ) + fmt.Println( p ) + } + return nil + } ) +} + +func do_archive( hdir string ) { + r, err := regexp.Compile( "0[1238][0-9]{8}$" ) + if err != nil { + log.Fatal( err ) + } + m := r.FindString( hdir ) + if len( m ) == 0 { + log.Fatal( err ) + } + + var images []string + + fi, _ := os.Stat( hdir ) + if fi.IsDir() { + filepath.Walk( hdir, func( path string, info os.FileInfo, err error ) error { + if !info.IsDir() && strings.HasSuffix( path, "jpg" ) { + images = append( images, path ) + } + return nil + } ) + } else { + fmt.Fprintf( os.Stderr, "%s: not directory\n", hdir ) + log.Fatal( err ) + } + + tar_gzip( m + ".tgz", images ) +} + +func tar_gzip( tgzfile string, images []string ) { + + tgz, err := os.Create( tgzfile ) + if err != nil { + log.Fatal( err ) + } + defer tgz.Close() + + gw := gzip.NewWriter( tgz ) + defer gw.Close() + tw := tar.NewWriter( gw ) + defer tw.Close() + + for i, file := range images { + f, err := os.Open( file ) + if err != nil { + log.Fatal( err ) + } + + stat, _ := f.Stat() + header := new( tar.Header ) + header.Name = fmt.Sprintf( "%d.jpg", i ) + header.Size = stat.Size() + header.Mode = int64( stat.Mode() ) + header.ModTime = stat.ModTime() + + if err := tw.WriteHeader( header ); err != nil { + log.Fatal( err ) + } + if _, err := io.Copy( tw, f ); err != nil { + log.Fatal( err ) + } + f.Close() + } +} + diff -r 000000000000 -r d3b8cd5aeb70 go/server.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/go/server.go Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,61 @@ +/* + server.go : server-program. + Version : 1.0 + Last Change: 2018-09-30 Sun 16:03:40. + + install to: server_root/ + + server_root/server + + db/ + + release/ + + images/ +*/ +package main + +import( + "path/filepath" + "fmt" + "io" + "log" + "net" + "net/http" + "os" +) + +func main() { + + var server string + var port = ":3910" + + addrs, err := net.InterfaceAddrs() + if err != nil { + log.Fatal( err ) + } + for _, a := range addrs { + if ipnet, ok := a.( *net.IPNet ); ok && !ipnet.IP.IsLoopback() { + if ipnet.IP.To4() != nil { + server = ipnet.IP.String() + port + } + } + } + + cwd, err := os.Getwd() + if err != nil { + log.Fatal( err ) + } + + fmt.Println( "server start [", server, "]" ) + http.HandleFunc( "/", func( w http.ResponseWriter, r *http.Request ) { + file := filepath.Join( cwd, filepath.FromSlash( r.URL.Path ) ) + fmt.Println( file ) + f, err := os.Open( file ) + if err != nil { + http.NotFound( w, r ) + return + } + defer f.Close() + io.Copy( w, f ) + } ) + log.Fatal( http.ListenAndServe( server, nil ) ) +} + diff -r 000000000000 -r d3b8cd5aeb70 image/blue.png Binary file image/blue.png has changed diff -r 000000000000 -r d3b8cd5aeb70 image/water.png Binary file image/water.png has changed diff -r 000000000000 -r d3b8cd5aeb70 include/auth.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/auth.h Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,50 @@ +// Filename : auth.h +// Last Change: 2018-09-29 Sat 06:18:10. +// + +#ifndef __AUTH_H__ +#define __AUTH_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class AuthDialog : public wxDialog +{ + DECLARE_EVENT_TABLE() + private: + wxArrayString users; + + protected: + enum { + ID_UID = wxID_HIGHEST + 200, + ID_PW, + }; + + wxStaticText* m_staticTextId; + wxTextCtrl* m_textCtrlId; + wxStaticText* m_staticTextIdmsg; + wxStaticText* m_staticTextPw; + wxTextCtrl* m_textCtrlPw; + wxStaticText* m_staticTextPwmsg; + + public: + AuthDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE ); + ~AuthDialog(); + void OnKey( wxKeyEvent& event ); + void OnCheckUserID( wxCommandEvent& event ); + void OnCheckPassword( wxCommandEvent& event ); + void OnEnter( wxCommandEvent& event ); + void CreateControls( void ); + void LoadUserID( void ); + void InDevelop( void ); +}; + +#endif //__AUTH_H__ + diff -r 000000000000 -r d3b8cd5aeb70 include/main.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/main.h Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,37 @@ +// Filename : main.h +// Last Change: 2018-09-17 Mon 21:57:32. +// +#include +#include +#include + +enum { + ID_MAIN = wxID_HIGHEST + 1, +}; + +// private classes +// Define a new application type, each program should derive a class from wxApp +class MyApp : public wxApp +{ + DECLARE_CLASS( MyApp ) + private: + wxFileConfig *config; + wxString conf_file; + + public: + wxRect rect; + + MyApp(); + ~MyApp(); + + virtual bool OnInit(); + virtual int OnExit(); + + void InitSetting(); + void SaveSetting(); + void GetData(); + void DeleteData(); +}; + +DECLARE_APP(MyApp) + diff -r 000000000000 -r d3b8cd5aeb70 include/rsearcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/rsearcher.h Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,115 @@ +// Filename : rsearcher.h +// Last Change: 2018-09-16 Sun 18:07:49. +// + +#ifndef __RSEARCH_H__ +#define __RSEARCH_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class MySearchCtrl : public wxSearchCtrl +{ + DECLARE_EVENT_TABLE() + public: + MySearchCtrl( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ); + ~MySearchCtrl(); + + void OnKey( wxKeyEvent& event ); +}; + +class MyStaticBitmap : public wxStaticBitmap +{ + private: + int m_dragx, m_dragy; + int m_zoom = 0; + wxBitmap m_bmp[5]; + wxScrolledWindow* m_parent; + + public: + MyStaticBitmap( wxScrolledWindow *parent, wxWindowID id, const wxBitmap &label, const wxPoint &pos, const wxSize &size, long style, const wxString &name ); + ~MyStaticBitmap(); + + void OnLeftDown( wxMouseEvent& event ); + void OnLeftUp( wxMouseEvent& event ); + void OnMotion( wxMouseEvent& event ); + void OnWheel( wxMouseEvent& event ); + void SetImage( int i, wxBitmap bmp ) { m_bmp[i] = bmp; }; + void SetZoom( int m_zoom ); +}; + +class MainFrame : public wxFrame +{ + DECLARE_EVENT_TABLE() + private: + + protected: + enum { + ID_SEARCH = wxID_HIGHEST + 100, + ID_LIST, + ID_NBOOK, + ID_SLDR, + ID_PRINT, + ID_TEST, + }; + + MySearchCtrl* m_searchCtrl; + MyStaticBitmap* m_staticBitmap1; + MyStaticBitmap* m_staticBitmap2; + MyStaticBitmap* m_staticBitmap3; + MyStaticBitmap* m_staticBitmap4; + MyStaticBitmap* m_staticBitmap5; + + wxNotebook* m_notebook; + wxScrolledWindow* m_scrolledWindow1; + wxScrolledWindow* m_scrolledWindow2; + wxScrolledWindow* m_scrolledWindow3; + wxScrolledWindow* m_scrolledWindow4; + wxScrolledWindow* m_scrolledWindow5; + wxScrolledWindow* m_scrolledWindow6; + + wxTextCtrl* m_textCtrlName; + wxTextCtrl* m_textCtrlAddr; + wxDataViewListCtrl* m_dataViewListCtrl; + wxDataViewColumn* m_dataViewListColumnNo; + wxDataViewColumn* m_dataViewListColumnDate; + wxTextCtrl* m_textCtrlLog; + wxSlider* m_slider; + wxButton* m_buttonPrint; + wxButton* m_button; + + public: + MainFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT( "Searcher Remote" ), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); + ~MainFrame(); + void OnItemDClicked( wxDataViewEvent& event ); + void OnNBookChanged( wxBookCtrlEvent& event ); + //void OnIdle( wxIdleEvent& event ); + void Cmd( wxString cmd ); + void SaveConfig( wxCloseEvent& event ); + void LoadBitmaps( void ); + void LoadBitmap( wxStaticBitmap* sb, wxString file ); + void GetImage( wxString hhs, wxString no ); + void OnTestButton( wxCommandEvent& event ); + void InDevelop( void ); +}; + + +#endif // __RSEARCH_H__ + diff -r 000000000000 -r d3b8cd5aeb70 sample.ico Binary file sample.ico has changed diff -r 000000000000 -r d3b8cd5aeb70 sample.rc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sample.rc Sun Sep 30 17:27:04 2018 +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 +// 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" + diff -r 000000000000 -r d3b8cd5aeb70 sample.xpm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sample.xpm Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,71 @@ +/* XPM */ +static char *sample_0[] = { +/* columns rows colors chars-per-pixel */ +"32 32 33 1 ", +" c red", +". c #FEFE00001C1C", +"X c #F4F400005252", +"o c #EAEA00007070", +"O c #E8E800007575", +"+ c #E4E400007A7A", +"@ c #12120000F2F2", +"# c #13130000F2F2", +"$ c #12120000F3F3", +"% c #13130000F3F3", +"& c #14140000F2F2", +"* c #14140000F3F3", +"= c #12120000F4F4", +"- c #13130000F4F4", +"; c #14140000F4F4", +": c #3C3C0000EFEF", +"> c #74740000DFDF", +", c #4E4E0000EBEB", +"< c #5F5F0000E7E7", +"1 c #56560000EAEA", +"2 c #BEBE0000B0B0", +"3 c #BABA0000B5B5", +"4 c #B8B80000B6B6", +"5 c #B2B20000BBBB", +"6 c #D9D900008E8E", +"7 c #D3D300009999", +"8 c #9B9B0000CCCC", +"9 c #9A9A0000CDCD", +"0 c #86860000D8D8", +"q c #92920000D1D1", +"w c #90900000D3D3", +"e c #A3A30000C6C6", +"r c None", +/* pixels */ +"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", +"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr", +"rrrrrrrrrr rrrrrrrrrrrrrr", +"rrrrrrr rrrrrrrrrr", +"rrrrrr rrrrrrrrrr", +"rrrrr rrrrrrrrrr", +"rrrr rrrrrrrrrr", +"rrrr rrrrrrr rrrrrrrrrr", +"rrr rrrrrrrrrr rrrrrrrrrr", +"rrr rrrrrrrrrrrrrrrrrrrrrr", +"rrr rrrrrrrrrrrrrrrrrrrrr", +"rrrr rrrrr%%%%%%%%$@rrr", +"rrrr >%%%%%%%%%%%rr", +"rrrr 9%%%%%%%%%%%%r", +"rrrrr <%%%rrrr*%%%%r", +"rrrrrrr X%%%%rrrrr%%%%r", +"rrrrrrrrr 6%%%%Orrrr%%%%r", +"rrrrrrrrrrrrr 3%%%1 rrrr%%%%r", +"rrrrrrrrrrrrrrrr w%%%q rrr*%%%%r", +"rrr rrrrrrrrrrr ,%%%4 rr&%%%%%r", +"rrr rrrrrrrrrr+%%%%%%%%%%%%%rr", +"rrr rrrrrr 7%%%%%%%%%-*rrrr", +"rrr 5%%%%%%%%%%rrrrr", +"rrr 0%%%err%%%%%rrrr", +"rrr .:%%%8rrr%%%%rrrr", +"rrrr o%%%%rrrr%%%%=rrr", +"rrrrrrrr 2%%%%rrrr$%%%%rrr", +"rrrrrrrrrrrrrrr$%%%%rrrr;%%%%rrr", +"rrrrrrrrrrrrrrr$%%%#rrrrr%%%%rrr", +"rrrrrrrrrrrrrrr%%%%rrrrrr%%%%rrr", +"rrrrrrrrrrrrrrr%%%%rrrrrr%%%%-rr", +"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr" +}; diff -r 000000000000 -r d3b8cd5aeb70 searcherR.fbp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/searcherR.fbp Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,2206 @@ + + + + + + C++ + 0 + source_name + 0 + 0 + res + UTF-8 + table + + 1000 + none + + 0 + SearcherRemote + + ./.cache + + 1 + 1 + 1 + 1 + UI + 1 + 0 + + 0 + wxAUI_MGR_DEFAULT + 0,153,227 + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + MainFrame + + 800,600 + wxDEFAULT_FRAME_STYLE + + Searcher Remote + + + + wxTAB_TRAVERSAL + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerTop + wxHORIZONTAL + none + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_notebook + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Image-01 + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_scrolledWindow1 + 1 + + + protected + 1 + + Resizable + 5 + 5 + 1 + + + 0 + + + + wxHSCROLL|wxVSCROLL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Image-02 + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_scrolledWindow2 + 1 + + + protected + 1 + + Resizable + 5 + 5 + 1 + + + 0 + + + + wxHSCROLL|wxVSCROLL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Image-03 + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_scrolledWindow3 + 1 + + + protected + 1 + + Resizable + 5 + 5 + 1 + + + 0 + + + + wxHSCROLL|wxVSCROLL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + a page + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_scrolledWindow4 + 1 + + + protected + 1 + + Resizable + 5 + 5 + 1 + + + 0 + + + + wxHSCROLL|wxVSCROLL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + a page + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_scrolledWindow5 + 1 + + + protected + 1 + + Resizable + 5 + 5 + 1 + + + 0 + + + + wxHSCROLL|wxVSCROLL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Image-06 + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_scrolledWindow6 + 1 + + + protected + 1 + + Resizable + 5 + 5 + 1 + + + 0 + + + + wxHSCROLL|wxVSCROLL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + bSizerRight + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + 0 + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_SEARCH + + 0 + + + 0 + + 1 + m_searchCtrl + 1 + + + protected + 1 + + Resizable + 1 + 1 + + wxTE_PROCESS_ENTER + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + 180,210,240 + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_textCtrlName + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + 180,210,240 + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_textCtrlAddr + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 1 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_dataViewListCtrl + protected + + + wxDV_ROW_LINES|wxDV_SINGLE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + wxALIGN_LEFT + + wxDATAVIEW_COL_RESIZABLE + No + wxDATAVIEW_CELL_INERT + m_dataViewListColumnNo + protected + Text + -1 + + + wxALIGN_LEFT + + wxDATAVIEW_COL_RESIZABLE + Date + wxDATAVIEW_CELL_INERT + m_dataViewListColumnDate + protected + Text + -1 + + + + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_textCtrlLog + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_SLDR + 5 + + 0 + + 1 + + 0 + + 1 + m_slider + 1 + + + protected + 1 + + Resizable + 1 + -1,200 + wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_LABELS|wxSL_VERTICAL + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + ID_PRINT + Print + + 0 + + 0 + + + 0 + + 1 + m_buttonPrint + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + ID_TEST + MyButton + + 0 + + 0 + + + 0 + + 1 + m_button + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + UserDialog + + + wxDEFAULT_DIALOG_STYLE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 3 + 0 + + gSizer + none + 0 + 0 + + 5 + wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + User ID + 0 + + 0 + + + 0 + + 1 + m_staticTextId + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 8 + + 0 + + 1 + m_textCtrlId + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_PROCESS_ENTER + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + 251,1,6 + 1 + + 0 + 0 + wxID_ANY + Input user-id + 0 + + 0 + + + 0 + + 1 + m_staticTextIdmsg + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Password + 0 + + 0 + + + 0 + + 1 + m_staticTextPw + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + ID_PASSWD + + 0 + + + + 0 + + 1 + m_textCtrlPw + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_PASSWORD|wxTE_PROCESS_ENTER + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + 251,2,7 + 1 + + 0 + 0 + wxID_ANY + Input user-password + 0 + + 0 + + + 0 + + 1 + m_staticTextPwmsg + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r d3b8cd5aeb70 src/auth.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/auth.cpp Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,107 @@ +// Filename : auth.cpp +// Last Change: 2018-09-29 Sat 06:18:31. +// + +#include "auth.h" + +AuthDialog::AuthDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) + : wxDialog( parent, id, title, pos, size, style ) +{ + CreateControls(); + LoadUserID(); + InDevelop(); +} + +AuthDialog::~AuthDialog() +{ +} + +// Event Table +BEGIN_EVENT_TABLE( AuthDialog, wxDialog ) + EVT_TEXT( ID_UID, AuthDialog::OnCheckUserID ) + EVT_TEXT( ID_PW, AuthDialog::OnCheckPassword ) + EVT_TEXT_ENTER( ID_UID, AuthDialog::OnEnter ) + EVT_TEXT_ENTER( ID_PW, AuthDialog::OnEnter ) +END_EVENT_TABLE() + +// Event Handler +void AuthDialog::OnCheckUserID( wxCommandEvent& WXUNUSED(event) ) +{ + wxString id = m_textCtrlId->GetValue(); + if ( 1 ) { + m_staticTextIdmsg->SetLabel( "ok" ); + m_staticTextPwmsg->SetLabel( wxT("竊 input") ); + } + else { + m_staticTextIdmsg->SetLabel( wxT("竊 input") ); + m_staticTextIdmsg->SetLabel( wxEmptyString ); + } +} + +void AuthDialog::OnCheckPassword( wxCommandEvent& WXUNUSED(event) ) +{ + wxString pw = m_textCtrlPw->GetValue(); + if ( pw.Len() < 4 ) { + m_staticTextPwmsg->SetLabel( wxT("竊 too short") ); + } + else { + m_staticTextPwmsg->SetLabel( wxEmptyString ); + } +} + +void AuthDialog::OnEnter( wxCommandEvent& WXUNUSED(event) ) +{ + Close(); +} + +// Functions +void AuthDialog::LoadUserID( void ) +{ + // 繝輔ぃ繧、繝ォ縺九i UserID 繧定ェュ縺ソ霎シ繧 +} + +void AuthDialog::InDevelop( void ) +{ + SetTitle( "now on test" ); + m_textCtrlId->SetValue( "test" ); + m_textCtrlPw->SetValue( "test" ); + m_textCtrlPw->SetFocus(); +} + +void AuthDialog::CreateControls( void ) +{ + this->SetIcon( wxIcon( wxT( "sample" ) ) ); + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + this->SetBackgroundColour( wxColour( 0, 150, 230 ) ); + + wxGridSizer* gSizer = new wxGridSizer( 0, 3, 0, 0 ); + + // user id + m_staticTextId = new wxStaticText( this, wxID_ANY, wxT("User ID"), wxDefaultPosition, wxDefaultSize, 0 ); + gSizer->Add( m_staticTextId, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); + + m_textCtrlId = new wxTextCtrl( this, ID_UID, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); + gSizer->Add( m_textCtrlId, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_staticTextIdmsg = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextIdmsg->SetForegroundColour( wxColour( 250, 0, 0 ) ); + gSizer->Add( m_staticTextIdmsg, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + // password + m_staticTextPw = new wxStaticText( this, wxID_ANY, wxT("Password"), wxDefaultPosition, wxDefaultSize, 0 ); + gSizer->Add( m_staticTextPw, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); + + m_textCtrlPw = new wxTextCtrl( this, ID_PW, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD|wxTE_PROCESS_ENTER ); + gSizer->Add( m_textCtrlPw, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_staticTextPwmsg = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextPwmsg->SetForegroundColour( wxColour( 250, 0, 0 ) ); + gSizer->Add( m_staticTextPwmsg, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + this->SetSizer( gSizer ); + this->Layout(); + gSizer->Fit( this ); + + this->Centre( wxBOTH ); +} + diff -r 000000000000 -r d3b8cd5aeb70 src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main.cpp Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,79 @@ +// Filename : main.cpp +// Last Change: 2018-09-29 Sat 15:11:45. +// +#include "main.h" +#include "auth.h" +#include "rsearcher.h" + +IMPLEMENT_APP( MyApp ) + +IMPLEMENT_CLASS( MyApp, wxApp ) + +MyApp::MyApp() +{ +} +MyApp::~MyApp() +{ +} + +bool MyApp::OnInit() +{ + if ( !wxApp::OnInit() ) return false; + + wxImage::AddHandler( new wxJPEGHandler ); + wxImage::AddHandler( new wxPNGHandler ); + InitSetting(); + GetData(); + + AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxT( "" ), wxDefaultPosition, wxDefaultSize ); + authdlg->ShowModal(); + authdlg->Destroy(); + + MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxT( "Re:Searcher" ), wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE ); + mainframe->Show( true ); + + return true; +} + +int MyApp::OnExit() +{ + SaveSetting(); + DeleteData(); + return 0; +} + +void MyApp::InitSetting() +{ + conf_file = wxGetCwd() + wxFILE_SEP_PATH + wxT("app.conf"); + config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); + + config->SetPath( wxT("/Geometry") ); + config->Read( wxT("x"), &rect.x ); + config->Read( wxT("y"), &rect.y ); + config->Read( wxT("w"), &rect.width ); + config->Read( wxT("h"), &rect.height ); + delete config; +} + +void MyApp::SaveSetting() +{ + config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); + + config->SetPath( wxT("/Geometry") ); + config->Write( wxT("x"), rect.x ); + config->Write( wxT("y"), rect.y ); + config->Write( wxT("w"), rect.width ); + config->Write( wxT("h"), rect.height ); + delete config; +} + +void MyApp::GetData() +{ + // Go 縺ョ繝励Ο繧ー繝ゥ繝繧定オキ蜍輔@シ梧囓蜿キ蛹悶&縺 auth, hhs, index 繝繝シ繧ソ繧貞叙蠕 +} + +void MyApp::DeleteData() +{ + // auth.db 縺ィ hhs.db 繧貞炎髯、 +} + diff -r 000000000000 -r d3b8cd5aeb70 src/rsearcher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/rsearcher.cpp Sun Sep 30 17:27:04 2018 +0900 @@ -0,0 +1,412 @@ +// Filename : rsearcher.cpp +// Last Change: 2018-09-16 Sun 18:25:30. +// + +#include "rsearcher.h" +#include "main.h" + +/********************/ +/** MySearchCtrl **/ +/********************/ +MySearchCtrl::MySearchCtrl( wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style ) + : wxSearchCtrl( parent, id, value, pos, size, style ) +{ + m_parent = parent; + SetMaxLength( 10 ); + #ifndef __WXMAC__ + ShowSearchButton( true ); + #endif + ShowCancelButton( false ); + + wxFont font( 12, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD ); + SetFont( font ); +} + +MySearchCtrl::~MySearchCtrl() +{ +} + +// Event Table +BEGIN_EVENT_TABLE( MySearchCtrl, wxSearchCtrl ) + EVT_CHAR( MySearchCtrl::OnKey ) +END_EVENT_TABLE() + +// Event Handlers & Functions +void MySearchCtrl::OnKey( wxKeyEvent& event ) +{ + int kc = event.GetKeyCode(); + + if ( kc == 13 ) { // Enter + // select all + wxString s = GetValue(); + + MainFrame* f = (MainFrame*)FindWindowById( ID_MAIN ); + f->Cmd( s ); + + wxMessageBox( "Enter ed" ); + event.Skip(); + return; + } + + if ( kc == 45 ) { // Num-Key '-' as Backspace + wxString t = GetStringSelection(); + if ( t.IsEmpty() ) { + long p = GetInsertionPoint(); + if ( p > 0 ) Remove( p - 1, p ); + } + else { + Cut(); + } + return; + } + + if ( kc == WXK_ESCAPE ) { // clear by ESC + this->Clear(); + return; + } + + event.Skip(); +} + +/********************/ +/** MyStaticBitmap **/ +/********************/ +MyStaticBitmap::MyStaticBitmap( wxScrolledWindow *parent, wxWindowID id, const wxBitmap &label, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) + : wxStaticBitmap( parent, id, label, pos, size, style, name ) +{ + m_parent = parent; + Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( MyStaticBitmap::OnLeftDown ), NULL, this ); + Connect( wxEVT_LEFT_UP, wxMouseEventHandler( MyStaticBitmap::OnLeftUp ), NULL, this ); + Connect( wxEVT_MOTION, wxMouseEventHandler( MyStaticBitmap::OnMotion ), NULL, this ); + Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( MyStaticBitmap::OnWheel ), NULL, this ); +} + +MyStaticBitmap::~MyStaticBitmap() +{ + Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( MyStaticBitmap::OnLeftDown ), NULL, this ); + Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( MyStaticBitmap::OnLeftUp ), NULL, this ); + Disconnect( wxEVT_MOTION, wxMouseEventHandler( MyStaticBitmap::OnMotion ), NULL, this ); + Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( MyStaticBitmap::OnWheel ), NULL, this ); +} + +// Event Handlers +void MyStaticBitmap::OnWheel( wxMouseEvent& event ) +{ + if ( event.ControlDown() ) { + if ( event.GetWheelRotation() < 0 ) { + if ( m_zoom < 4 ) m_zoom++; + } + else { + if ( m_zoom > 0 ) m_zoom--; + } + SetBitmap( m_bmp[ m_zoom ] ); + m_parent->SetScrollbars( 10, 10, m_bmp[ m_zoom ].GetWidth() / 10, m_bmp[ m_zoom ].GetHeight() / 10 ); + return; + } + event.Skip(); +} + +void MyStaticBitmap::OnLeftDown( wxMouseEvent& event ) +{ + event.GetPosition( &m_dragx, &m_dragy ); + SetCursor( wxCursor( wxCURSOR_SIZING ) ); +} + +void MyStaticBitmap::OnLeftUp( wxMouseEvent& WXUNUSED(event) ) +{ + SetCursor( wxCursor( wxCURSOR_ARROW ) ); +} + +void MyStaticBitmap::OnMotion( wxMouseEvent& event ) +{ + if ( event.Dragging() ) { + int xv, yv, x, y; + m_parent->GetViewStart( &xv, &yv ); + + event.GetPosition( &x, &y ); + + int xa = abs( x - m_dragx ); + int ya = abs( y - m_dragy ); + int xs = x - m_dragx < 0 ? -1 : 1; + int ys = y - m_dragy < 0 ? -1 : 1; + + /* handai dakedo sumu-zu + m_parent->Scroll( xv + xs * log10( xa + 1 ), yv + ys * log10( ya + 1 ) ); + */ + m_parent->Scroll( xv + xs * log10( xa + 1 ), yv + ys * log10( ya + 1 ) ); + + m_dragx = x; m_dragy = y; + } +} + +// Functions + +/********************/ +/** Main Frame **/ +/********************/ +MainFrame::MainFrame( 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( 0, 150, 230 ) ); + + wxBoxSizer* bSizerTop = new wxBoxSizer( wxHORIZONTAL ); + + // Left + wxImageList* imgList = new wxImageList( 16, 16, false, 1 ); + wxBitmap bmp( wxT( "image/blue.png" ), wxBITMAP_TYPE_PNG ); + imgList->Add( bmp, wxNullBitmap ); + bmp.LoadFile( wxT( "image/water.png" ), wxBITMAP_TYPE_PNG ); + imgList->Add( bmp, wxNullBitmap ); + + m_notebook = new wxNotebook( this, ID_NBOOK, wxDefaultPosition, wxDefaultSize, 0 ); + m_notebook->SetImageList( imgList ); + + m_scrolledWindow1 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); + m_scrolledWindow1->SetScrollRate( 5, 5 ); + m_notebook->AddPage( m_scrolledWindow1, wxT( "Image-01" ), false, 0 ); + + m_scrolledWindow2 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); + m_scrolledWindow2->SetScrollRate( 5, 5 ); + m_notebook->AddPage( m_scrolledWindow2, wxT( "Image-02" ), false, 0 ); + + m_scrolledWindow3 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); + m_scrolledWindow3->SetScrollRate( 5, 5 ); + m_notebook->AddPage( m_scrolledWindow3, wxT( "Image-03" ), false, 0 ); + + m_scrolledWindow4 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); + m_scrolledWindow4->SetScrollRate( 5, 5 ); + m_notebook->AddPage( m_scrolledWindow4, wxT( "Image-04" ), false, 0 ); + + m_scrolledWindow5 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); + m_scrolledWindow5->SetScrollRate( 5, 5 ); + m_notebook->AddPage( m_scrolledWindow5, wxT( "Image-05" ), false, 0 ); + + m_scrolledWindow6 = new wxScrolledWindow( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); + m_scrolledWindow6->SetScrollRate( 5, 5 ); + m_notebook->AddPage( m_scrolledWindow6, wxT( "Image-06" ), false, 0 ); + + bSizerTop->Add( m_notebook, 1, wxEXPAND|wxALL, 5 ); + + // Right + wxBoxSizer* bSizerRight = new wxBoxSizer( wxVERTICAL ); + + m_searchCtrl = new MySearchCtrl( this, ID_SEARCH, wxEmptyString, wxDefaultPosition, wxSize( -1, 24 ), wxTE_PROCESS_ENTER ); + bSizerRight->Add( m_searchCtrl, 0, wxALL, 5 ); + m_searchCtrl->SetFocus(); + + m_textCtrlName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 80, -1 ), 0 ); + m_textCtrlName->SetBackgroundColour( wxColour( 180, 210, 240 ) ); + bSizerRight->Add( m_textCtrlName, 0, wxALL, 5 ); + + m_textCtrlAddr = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 120, -1 ), 0 ); + m_textCtrlAddr->SetBackgroundColour( wxColour( 180, 210, 240 ) ); + bSizerRight->Add( m_textCtrlAddr, 0, wxALL|wxEXPAND, 5 ); + + m_dataViewListCtrl = new wxDataViewListCtrl( this, ID_LIST, wxDefaultPosition, wxDefaultSize, wxDV_ROW_LINES|wxDV_SINGLE ); + m_dataViewListColumnNo = m_dataViewListCtrl->AppendTextColumn( wxT( "No" ), wxDATAVIEW_CELL_INERT, 30, wxALIGN_RIGHT, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE ); + m_dataViewListColumnDate = m_dataViewListCtrl->AppendTextColumn( wxT( "Date" ), wxDATAVIEW_CELL_INERT, 120, wxALIGN_CENTER, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE ); + + bSizerRight->Add( m_dataViewListCtrl, 1, wxALL|wxEXPAND, 5 ); + + m_textCtrlLog = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizerRight->Add( m_textCtrlLog, 1, wxALL|wxEXPAND, 5 ); + + m_slider = new wxSlider( this, ID_SLDR, 1, 1, 5, wxDefaultPosition, wxSize( -1,200 ), wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_LABELS|wxSL_VERTICAL ); + bSizerRight->Add( m_slider, 0, wxALL, 5 ); + + m_buttonPrint = new wxButton( this, ID_PRINT, wxT( "Print" ), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerRight->Add( m_buttonPrint, 0, wxALL, 5 ); + + m_button = new wxButton( this, ID_TEST, wxT( "MyButton" ), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerRight->Add( m_button, 0, wxALL, 5 ); + + bSizerTop->Add( bSizerRight, 0, wxEXPAND, 5 ); + + this->SetSizer( bSizerTop ); + this->Layout(); + + //this->Centre( wxBOTH ); + + m_staticBitmap1 = new MyStaticBitmap( m_scrolledWindow1, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); + m_staticBitmap2 = new MyStaticBitmap( m_scrolledWindow2, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); + m_staticBitmap3 = new MyStaticBitmap( m_scrolledWindow3, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); + m_staticBitmap4 = new MyStaticBitmap( m_scrolledWindow4, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); + m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); + + InDevelop(); +} + +MainFrame::~MainFrame() +{ +} + +// Event Table +BEGIN_EVENT_TABLE( MainFrame, wxFrame ) + EVT_DATAVIEW_ITEM_ACTIVATED( ID_LIST, MainFrame::OnItemDClicked ) + EVT_NOTEBOOK_PAGE_CHANGED( ID_NBOOK, MainFrame::OnNBookChanged ) + EVT_BUTTON( ID_TEST, MainFrame::OnTestButton ) + EVT_CLOSE( MainFrame::SaveConfig ) + //EVT_IDLE( MainFrame::OnIdle ) +END_EVENT_TABLE() + + +// Event Handler +void MainFrame::OnItemDClicked( wxDataViewEvent& WXUNUSED(event) ) +{ + wxMessageBox( "dcli" ); + int r = m_dataViewListCtrl->GetSelectedRow(); + wxString no = m_dataViewListCtrl->GetTextValue( r, 0 ); + + LoadBitmaps(); +} + +void MainFrame::OnNBookChanged( wxBookCtrlEvent& WXUNUSED(event) ) +{ + for ( int i = 0; i < m_notebook->GetPageCount(); i++ ) { + m_notebook->SetPageImage( i, 1 ); + } + m_notebook->SetPageImage( m_notebook->GetSelection(), 0 ); +} + +/* +void MainFrame::OnItemSelected( wxDataViewEvent& event ) +{ + dclick or select ? +} +*/ + + +/* +void MainFrame::OnIdle( wxIdleEvent& WXUNUSED(event) ) +{ +} + +*/ +void MainFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) ) +{ + if ( !IsIconized() && !IsMaximized() ) { + wxGetApp().rect = this->GetRect(); + } + Destroy(); +} + +void MainFrame::OnTestButton( wxCommandEvent& WXUNUSED(event) ) +{ + /* ok + Cmd( m_searchCtrl->GetValue() ); + Cmd( wxT( "0100012345" ) ); + */ + + wxBitmap bmp( wxT("db/19970101/img088.jpg"), wxBITMAP_TYPE_JPEG ); + int width = bmp.GetWidth(); + int height = bmp.GetHeight(); + wxImage img = bmp.ConvertToImage(); + + int ww, wh; + m_scrolledWindow1->GetSize( &ww, &wh ); + + float w = ww; + float h = w * height / width; + m_staticBitmap1->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); + m_scrolledWindow1->SetScrollbars( 10, 10, w / 10, h / 10 ); + + for ( int i = 0; i < 5; i++ ) { + w *= 1.1; + h *= 1.1; + m_staticBitmap1->SetImage( i, wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); + } +} + +// Functions +void MainFrame::Cmd( wxString cmd ) +{ + m_dataViewListCtrl->DeleteAllItems(); + + if ( cmd.Cmp( wxT( "q" ) ) == 0 || cmd.Cmp( wxT( "9" ) ) == 0 ) { + Close(); + } + + if ( cmd.Cmp( wxT( "." ) ) == 0 ) { + wxString appdir = wxGetCwd(); + wxString execmd = wxT( "explorer " ) + appdir; + wxExecute( execmd ); + return; + } + + wxRegEx reHhs( wxT( "^0[1238][0-9]{8}$" ) ); + if ( reHhs.Matches( cmd ) ) { + wxArrayString output, errors; + cmd = wxT( "./rsearcher -q " ) + cmd; + wxExecute( cmd, output, errors, wxEXEC_SYNC, NULL ); // ok + + if ( output.GetCount() > 0 ) { + m_textCtrlName->SetValue( output[0] ); + m_textCtrlAddr->SetValue( output[2] ); + for ( int i = 5, n = 1; i < output.GetCount(); i++, n++ ) { + wxVector data; + data.push_back( wxString::Format( wxT( "%02d" ), n ) ); + data.push_back( output[i] ); + m_dataViewListCtrl->AppendItem( data ); + data.clear(); + } + } + + if ( errors.GetCount() > 0 ) { + wxMessageBox( errors[0], wxT( "Error" ) ); + } + } +} + +void MainFrame::LoadBitmap( wxStaticBitmap* sb, wxString file ) +{ + wxBitmap bmp( file, wxBITMAP_TYPE_JPEG ); + int width = bmp.GetWidth(); + int height = bmp.GetHeight(); + wxImage img = bmp.ConvertToImage(); + + int ww, wh; + sb->GetSize( &ww, &wh ); + + float w = ww; + float h = w * height / width; + sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); + //sb->SetScrollbars( 10, 10, w / 10, h / 10 ); + + for ( int i = 0; i < 5; i++ ) { + w *= 1.1; + h *= 1.1; + //sb->SetImage( i, wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); + } +} + +void MainFrame::LoadBitmaps( void ) +{ + int no = 1; + LoadBitmap( m_staticBitmap1, wxString::Format( ".cache/%02d_1", no ) ); + LoadBitmap( m_staticBitmap2, wxString::Format( ".cache/%02d_2", no ) ); + LoadBitmap( m_staticBitmap3, wxString::Format( ".cache/%02d_3", no ) ); + LoadBitmap( m_staticBitmap4, wxString::Format( ".cache/%02d_4", no ) ); + LoadBitmap( m_staticBitmap5, wxString::Format( ".cache/%02d_5", no ) ); +} + +void MainFrame::GetImage( wxString hhs, wxString no ) +{ + // http get +} + +void MainFrame::InDevelop( void ) +{ + LoadBitmaps(); + + m_slider->Enable( false ); + m_slider->Show( false ); + + m_buttonPrint->Enable( false ); + m_buttonPrint->Show( false ); + + m_button->Enable( false ); + m_button->Show( false ); +} +