view src/rsearcher.cpp @ 3:db4813125eb8

many changes.
author pyon@macmini
date Thu, 11 Oct 2018 22:11:09 +0900
parents 7fe3417cefc8
children 06342fc544e4
line wrap: on
line source

// Filename   : rsearcher.cpp
// Last Change: 2018-10-11 –Ø 18:28:07.
//

#include <wx/arrstr.h> 
#include <wx/html/htmprint.h>
#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
		SelectAll();

		MainFrame* f = (MainFrame*)FindWindowById( ID_MAIN );
		f->Cmd( GetValue() );

        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( OnLeftDown ), NULL, this );
    Connect( wxEVT_LEFT_UP,    wxMouseEventHandler( OnLeftUp   ), NULL, this );
    Connect( wxEVT_MOTION,     wxMouseEventHandler( OnMotion   ), NULL, this );
    Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( OnWheel    ), NULL, this );

    Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OnStartRGesture ), NULL, this );
    Connect( wxEVT_RIGHT_UP,   wxMouseEventHandler( OnEndRGesture   ), NULL, this );
}

MyStaticBitmap::~MyStaticBitmap()
{
    Disconnect( wxEVT_LEFT_DOWN,  wxMouseEventHandler( OnLeftDown ), NULL, this );
    Disconnect( wxEVT_LEFT_UP,    wxMouseEventHandler( OnLeftUp   ), NULL, this );
    Disconnect( wxEVT_MOTION,     wxMouseEventHandler( OnMotion   ), NULL, this );
    Disconnect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( OnWheel    ), NULL, this );

    Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OnStartRGesture ), NULL, this );
    Disconnect( wxEVT_RIGHT_UP,   wxMouseEventHandler( OnEndRGesture   ), 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;
    }
}

/* right-gesture: start detect */
void MyStaticBitmap::OnStartRGesture( wxMouseEvent& event )
{
    event.GetPosition( &cx, &cy );
}

/* right-gesture: judge */
void MyStaticBitmap::OnEndRGesture( wxMouseEvent& event )
{
    int x, y;
    event.GetPosition( &x, &y );

    int dx = x - cx;
    int dy = y - cy;
    float rad = fabs( atan2( dy, dx ) );
    float pi = 3.14159;

    // to right
    if ( rad < pi/8 && dx > 0 ) {
		wxMessageBox("right");
    }
    // to left
    else if ( rad > pi/8*7 && rad < pi && dx < 0 ) { 
		wxMessageBox("left");
    }
    // to up-right
    else if ( rad > pi/8 && rad < pi/8*3 && dx > 0 ) {
		wxMessageBox("right-up");
        //Close();
    }
}

// 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 )
{
	CreateControls();
	LoadDB();
    LoadBitmaps( wxEmptyString );
	m_timer.SetOwner( this, ID_TIMER );
}

MainFrame::~MainFrame()
{
	RemoveFile( wxT( "auth.db" ) );
	RemoveFile( wxT( "hhs.db" ) );
	RemoveFile( wxT( ".cache/*" )  );
}

// Event Table
BEGIN_EVENT_TABLE( MainFrame, wxFrame )
    EVT_DATAVIEW_SELECTION_CHANGED( ID_LIST, MainFrame::OnItemSelected )
    EVT_DATAVIEW_ITEM_ACTIVATED( ID_LIST, MainFrame::OnItemDClicked )
    EVT_NOTEBOOK_PAGE_CHANGED( ID_NBOOK, MainFrame::OnNBookChanged )
	EVT_BUTTON( wxID_PRINT, MainFrame::OnPrint )
	EVT_BUTTON( ID_LOGOUT, MainFrame::OnLogout )
	EVT_BUTTON( ID_TEST, MainFrame::OnTestButton )
	EVT_CLOSE( MainFrame::OnClose )
    EVT_IDLE( MainFrame::OnIdle )
    EVT_TIMER( ID_TIMER, MainFrame::OnTimer )
END_EVENT_TABLE()


// Event Handler
void MainFrame::OnItemSelected( wxDataViewEvent& WXUNUSED(event) )
{
    int r = m_dataViewListCtrl->GetSelectedRow();
    wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 );
	if ( ready.IsSameAs( wxT( "OK" ), true ) ) {
		wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
		date.Replace( wxT( "-" ), wxEmptyString, true );
		LoadBitmaps( date );
	} else {
		LoadBitmaps( wxEmptyString );
	}
}

void MainFrame::OnItemDClicked( wxDataViewEvent& WXUNUSED(event) )
{
    int r = m_dataViewListCtrl->GetSelectedRow();
	wxString status = m_dataViewListCtrl->GetTextValue( r, 2 );
	if ( status.IsSameAs( wxT( "OK" ), true ) )	return;

    wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
	date.Replace( wxT( "-" ), wxEmptyString, true );
	GetImages( m_hhs, date );
	LoadBitmaps( date );

    m_dataViewListCtrl->SetTextValue( wxT( "OK" ), r, 2 );
}

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::OnClose( wxCloseEvent& WXUNUSED(event) )	// save config
{
    if ( !IsIconized() && !IsMaximized() ) {
        wxGetApp().rect = this->GetRect();
    }
    Destroy();
}

void MainFrame::OnPrint( wxCommandEvent& WXUNUSED(event) )
{
	PrintImages();
}

void MainFrame::OnLogout( wxCommandEvent& WXUNUSED(event) )
{
	wxMessageBox("logout");
	return;
}

void MainFrame::OnTestButton( wxCommandEvent& WXUNUSED(event) )
{
	return;
}


void MainFrame::OnTimer( wxTimerEvent& WXUNUSED(event) )
{
	wxMessageBox( "timer !" );
	// logout
}

void MainFrame::OnIdle( wxIdleEvent& event )
{
	if ( !m_timer.IsRunning() ) {
        m_timer.Start( 300 * 1000, wxTIMER_ONE_SHOT );
    }
    event.RequestMore();
    event.Skip();
}

// Functions
void MainFrame::CreateControls( void )
{
    this->SetIcon( wxIcon( wxT( "sample" ) ) );
	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
	//this->SetBackgroundColour( wxColour( 0, 150, 230 ) );
	this->SetBackgroundColour( wxColour( 153, 153, 153 ) );

	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( 160, -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, 80, wxALIGN_CENTER, wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
	m_dataViewListColumnDate = m_dataViewListCtrl->AppendTextColumn( wxT( "Ready" ), wxDATAVIEW_CELL_INERT, 60, 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, wxID_PRINT, wxT( "Print" ), wxDefaultPosition, wxDefaultSize, 0 );
	bSizerRight->Add( m_buttonPrint, 0, wxALL, 5 );
	
	m_buttonLogout = new wxButton( this, ID_LOGOUT, wxT( "Logout" ), wxDefaultPosition, wxDefaultSize, 0 );
	bSizerRight->Add( m_buttonLogout, 0, wxALL, 5 );
	
	m_buttonTest = new wxButton( this, ID_TEST, wxT( "Test" ), wxDefaultPosition, wxDefaultSize, 0 );
	bSizerRight->Add( m_buttonTest, 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 );
}

void MainFrame::Cmd( wxString cmd )
{
	m_dataViewListCtrl->DeleteAllItems();
	LoadBitmaps( wxEmptyString );

    if ( cmd.IsSameAs( wxT( "q" ), true ) || cmd.IsSameAs( wxT( "9" ), true ) ) {
        Close();
		return;
    }

    if ( cmd.IsSameAs( wxT( "c" ), true ) || cmd.IsSameAs( wxT( "cmd" ), true ) ) {
        Close();
		return;
    }

    if ( cmd.IsSameAs( wxT( "k" ), true ) ) {
		// hiragana kensaku
        return;
	}

    if ( cmd.IsSameAs( wxT( "." ), false ) ) {
        wxString appdir = wxGetCwd();
        wxString execmd = wxT( "explorer " ) + appdir;
        wxExecute( execmd );
        return;
    }

    if ( cmd.IsSameAs( wxT( "*" ), false ) ) {
		// cmd = clipboard // paste clipboard
	}

    if ( cmd.IsSameAs( wxT( "+" ), false ) ) {
		// print
        return;
	}

    wxRegEx reHhs( wxT( "^0[1238][0-9]{8}$" ) );
    if ( reHhs.Matches( cmd ) ) {
		m_hhs = m_searchCtrl->GetValue();
		Search();
		return;
	}

	wxMessageBox( wxT( "Bad Input !!" ) );
}

void MainFrame::LoadBitmap( wxScrolledWindow* sc, wxStaticBitmap* sb, wxString file )
{
	if ( startup ) {
		file = wxT( "image/hw201810.jpg" );
		startup = false;
	}
	if ( !wxFileExists( file ) ) file = wxT( "image/testpattern.jpg" );
    wxBitmap bmp( file, wxBITMAP_TYPE_JPEG );
    int width  = bmp.GetWidth();
    int height = bmp.GetHeight();
    wxImage img = bmp.ConvertToImage();

    int ww, wh;
    sc->GetSize( &ww, &wh );

    float w = ww - 30;
    float h = w * height / width;
    sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) );
    sc->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( wxString date )
{
    LoadBitmap( m_scrolledWindow1, m_staticBitmap1, wxString::Format( wxT( ".cache/%08s_1" ), date ) );
    LoadBitmap( m_scrolledWindow2, m_staticBitmap2, wxString::Format( wxT( ".cache/%08s_2" ), date ) );
    LoadBitmap( m_scrolledWindow3, m_staticBitmap3, wxString::Format( wxT( ".cache/%08s_3" ), date ) );
    LoadBitmap( m_scrolledWindow4, m_staticBitmap4, wxString::Format( wxT( ".cache/%08s_4" ), date ) );
    LoadBitmap( m_scrolledWindow5, m_staticBitmap5, wxString::Format( wxT( ".cache/%08s_5" ), date ) );
}

void MainFrame::GetImages( wxString hhs, wxString date )
{
	wxArrayString args;	// http get
	args.Add( wxT( "client.exe" ) );
	args.Add( m_server );
	args.Add( hhs );
	args.Add( date );

	//wxMessageBox( wxJoin( args, ' ', '\\' ) );
	int estimate = 5;
    wxProgressDialog pd( wxT( "Connecting Server" ), wxT( "Start..." ), estimate, NULL, wxPD_APP_MODAL|wxPD_ELAPSED_TIME|wxPD_REMAINING_TIME|wxPD_AUTO_HIDE );
    pd.SetSize( wxSize( 320, 140 ) );
	
	wxExecute( wxJoin( args, ' ', '\\' ), wxEXEC_ASYNC|wxEXEC_HIDE_CONSOLE );
	for ( int i = 0; i < estimate; i++ ) {
		wxSleep( 1 );
		pd.Update( i, wxT( "Now Loading..." ) );
	}
}

void MainFrame::Search( void )
{
	wxString date;
	int match_cnt = 0;
	for ( int i = 0; i < m_index.GetCount(); i++ ) {
		if ( m_index[i].StartsWith( m_hhs, &date ) ) {
			wxVector<wxVariant> data;
			data.push_back( wxString::Format( wxT( "%02d" ), ++match_cnt ) );
			date = date.Mid( 1, 4 ) + wxT( "-" ) + date.Mid( 5, 2 ) + wxT( "-" ) + date.Mid( 7, 2 );
			data.push_back( date );
			data.push_back( wxEmptyString );
			m_dataViewListCtrl->AppendItem( data );
			data.clear();
		}
	}
	if ( match_cnt == 0 ) wxMessageBox( wxT( "Not Matched !!" ) );
}

void MainFrame::LoadDB( void )
{
	wxTextFile file;
	file.Open( wxT( "index.db" ) );
	for ( int i = 0; i < file.GetLineCount(); i++ )
		m_index.Add( file.GetLine( i ) );
	file.Close();
	m_index.Sort( true );

	/*
	file.Open( wxT( "hhs.db" ) );
	for ( int i = 0; i < file.GetLineCount(); i++ ) {
	//
	}
	file.Close();
	*/
}

void MainFrame::PrintImages( void )
{
    int r = m_dataViewListCtrl->GetSelectedRow();
    wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 );

	if ( !ready.IsSameAs( wxT( "OK" ), true ) ) {
		wxMessageBox( wxT( "Not Ready for Print !!" ) );
		return;
	}

	wxDateTime now = wxDateTime::Now();
	wxString nowstr = now.Format( "%Y/%m/%d %H:%M", wxDateTime::GMT9 ).c_str();

	wxString date = m_dataViewListCtrl->GetTextValue( r, 1 );
	date.Replace( wxT( "-" ), wxEmptyString, true );

	wxString html, file;
	html = wxT( "<html><body>\n" );

	for ( int i = 1; i < 6; i++ ) {
		file = wxString::Format( wxT( ".cache/%08s_%d" ), date, i );
		html = html + wxT( "<img src=\"" ) + file + wxT( "\" width=\"750\" height=\"1060\"/>\n" );
		html = html + wxT( "<div align=right><font size=-2><u>" ) + m_hhs + wxT( "@" ) + m_user + wxT( "#" ) + nowstr + wxT( "</u></font></div>\n\n" );
	}
	html = html + wxT( "</body></html>" );

	// start printing
	wxHtmlPrintout hpout( wxT( "Re:Searcher" ) );
	hpout.SetMargins( 0, 0, 0, 0, 0 );
	wxPrintDialogData pd;
	wxPrinter p( &pd );

	hpout.SetHtmlText( html, wxEmptyString, false );
	p.Print( NULL, &hpout, true );
}

void MainFrame::RemoveFile( wxString pattern )
{
	wxString file = wxFindFirstFile( pattern );
	while ( !file.empty() ) {
		wxRemoveFile( file  );
		file = wxFindNextFile();
	}
}

void MainFrame::InDevelop( bool flag )
{
    if ( !flag ) return;
    
	bool lo = false;
	m_buttonLogout->Enable( lo );
	m_buttonLogout->Show( lo );

	bool sl = false;
	m_slider->Enable( sl );
	m_slider->Show( sl );

	bool tb = false;
	m_buttonTest->Enable( tb );
	m_buttonTest->Show( tb );

	// search
	m_searchCtrl->SetValue( wxT( "0100122642" ) );
}