view include/rsearcher.h @ 11:799b6008db8e

auto-upgrade.
author pyon@macmini
date Mon, 12 Nov 2018 19:35:50 +0900
parents 36811fd22bd2
children f5ffc34f045a
line wrap: on
line source

// Filename   : rsearcher.h
// Last Change: 2018-11-08 –Ø 13:51:59.
//

#ifndef __RSEARCH_H__
#define __RSEARCH_H__

#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/string.h>
#include <wx/srchctrl.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/notebook.h>
#include <wx/dataview.h>
#include <wx/slider.h>
#include <wx/sizer.h>
#include <wx/html/htmlwin.h>
#include <wx/frame.h>
#include <wx/splitter.h>
#include <wx/statbmp.h>
#include <wx/msgdlg.h> 
#include <wx/filefn.h> 
#include <wx/regex.h>
#include <wx/progdlg.h>
#include <wx/utils.h> 
#include <wx/textfile.h>
#include <wx/timer.h>
#include <wx/hashmap.h>
#include "net.h"

/* Data Class */
class HhsClass {
	public:
		wxString no;
		wxString birth;
		wxString name;
		wxString kana;
		wxString addr;
		wxString sex;

		HhsClass( wxArrayString& buf );
};

WX_DECLARE_HASH_MAP( wxString, HhsClass*, wxStringHash, wxStringEqual, HhsHash );

/* Control-Window Class */
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;	// for image drag
		int cx, cy;             // for mouse-gesture
		bool with_stl = false;
        wxBitmap m_bmp0;
		wxScrolledWindow* m_parent;

	public:
		int zoom = 0;

	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 OnLeftDClick( wxMouseEvent& event );
        void OnRightDClick( wxMouseEvent& event );
		void OnStartRGesture( wxMouseEvent& event );
		void OnEndRGesture( wxMouseEvent& event );
        void OnMotion( wxMouseEvent& event );
        void OnWheel( wxMouseEvent& event );
        void SetOrigImage( wxBitmap bmp ) { m_bmp0 = bmp; };
        wxBitmap GetOrigImage( void ) { return m_bmp0; };
		void ChangeBook( int i );
		void WithSatellite( bool sw ) { with_stl = sw; };
};

class StlFrame : public wxFrame 
{
	private:
		wxScrolledWindow* m_scrolledWindow;
		MyStaticBitmap*   m_staticBitmap;

	public:
		StlFrame( 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 );
		~StlFrame();

		void SetBitmap( wxBitmap bmp ) { m_staticBitmap->SetBitmap( bmp ); };
		void SetScroll( int w, int h ) { m_scrolledWindow->SetScrollbars( 10, 10, (int)w / 10, (int)h / 10 ); };
};

class MainFrame : public wxFrame 
{
	DECLARE_EVENT_TABLE()
	private:
		bool		  startup = true;
		wxString	  m_server;
		wxString	  m_hhs;
		wxString	  m_user;
		wxArrayString m_index;
		wxTimer       m_timer;
		HhsHash       hhash;
		RsHttp		  http;
		bool		  m_dark = false;
	
	protected:
		MySearchCtrl*		m_searchCtrl;
        MyStaticBitmap*     m_staticBitmap1;
        MyStaticBitmap*     m_staticBitmap2;
        MyStaticBitmap*     m_staticBitmap3;
        MyStaticBitmap*     m_staticBitmap4;
        MyStaticBitmap*     m_staticBitmap5;
        MyStaticBitmap*     m_staticBitmap6;

		wxSplitterWindow*	m_splitter;
		wxPanel*			m_panelLeft;
		wxPanel*			m_panelRight;
		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;
		wxDataViewColumn* 	m_dataViewListColumnReady;
		wxDataViewListCtrl* m_dataViewListKana;
		wxDataViewColumn* 	m_dataViewListColumnKNo;
		wxDataViewColumn* 	m_dataViewListColumnName;
		wxDataViewColumn* 	m_dataViewListColumnAddr;
		wxTextCtrl* 		m_textCtrlLog;
		wxButton*           m_buttonPsearch;
		wxButton*           m_buttonPrint;

		// invisible button for shortcut-key
		wxSlider*           m_slider;
		wxButton*           m_buttonFocus;
		wxButton*           m_buttonPzoom;
		wxButton*           m_buttonMzoom;
		wxButton*           m_buttonDark;
		wxButton*           m_buttonSatellite;
		wxButton*           m_buttonHelp;
		wxButton*           m_buttonClose;
		wxButton*           m_buttonLogout;
	
	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 SetServer( wxString addr, int port ) { http.SetServer( addr, port ); m_server = wxString::Format(wxT("%s:%d"),addr,port);};
		bool GetDB( void ) { return http.GetDB(); };
		void SetUser( wxString user ) { m_user = user; WriteLog( wxT( "[login] " ) + m_user ); };
		void CreateControls( void );
		void SetAccelerator( void );
		void Cmd( wxString cmd );
		void Search( void );
		void PasteSearch( void );
		void LoadDB( void );
        bool LoadBitmap( wxScrolledWindow* sc, MyStaticBitmap* sb, wxString file );
        bool LoadBitmaps( wxString date, bool reload );
		void ChangeCZoom( int z );
		void ChangeZoom( wxScrolledWindow* sc, MyStaticBitmap* sb, int z );
		void ChangeColor( MyStaticBitmap* sb );
        void GetImages( wxString hhs, wxString date );
		void PrintImages( void );
		void WriteLog( wxString msg );
		void Close( void );
        void InDevelop( bool );

		void OnSplitWin( wxSplitterEvent & event );
		void OnItemSelected( wxDataViewEvent& event );
		void OnItemDClicked( wxDataViewEvent& event );
		void OnKanaItemSelected( wxDataViewEvent& event );
		void OnKanaItemDClicked( wxDataViewEvent& event );
        void OnNBookChanged( wxBookCtrlEvent& event );
        void OnPasteSearch( wxCommandEvent& event );
        void OnPrint( wxCommandEvent& event );
		void OnClose( wxCloseEvent& event );
		void OnBClose( wxCommandEvent& event );
		void OnIdle( wxIdleEvent& event );
		void OnTimer( wxTimerEvent& event );

		// for shortcut-key
        void OnFocus( wxCommandEvent& event );
        void OnPlusZoom( wxCommandEvent& event );
        void OnMinusZoom( wxCommandEvent& event );
        void OnDark( wxCommandEvent& event );
        void OnSatellite( wxCommandEvent& event );
        void OnHelp( wxCommandEvent& event );
        void OnLogout( wxCommandEvent& event );
};

#endif // __RSEARCH_H__