view src/preview.cpp @ 0:615a15029602 default tip

first commit.
author pyon@macmini
date Sun, 10 Nov 2019 08:39:41 +0900
parents
children
line wrap: on
line source

/* Filename   : preview.cpp
   Last Change: 2019-11-08 金 14:25:42.
                     by Takayuki Mutoh
*/
#include "preview.h"

PreviewFrame::PreviewFrame(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) 
	: wxFrame(parent, id, title, pos, size, style)
{
	this->SetSizeHints(wxDefaultSize, wxDefaultSize);
	this->SetBackgroundColour(wxColour(180, 200, 140));

	wxGridBagSizer* gbSizer;
	gbSizer = new wxGridBagSizer(0, 0);
	gbSizer->SetFlexibleDirection(wxBOTH);
	gbSizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);

	m_scrolledWindowCanvas = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL);
	m_scrolledWindowCanvas->SetScrollRate(5, 5);
	gbSizer->Add(m_scrolledWindowCanvas, wxGBPosition(0, 0), wxGBSpan(9, 1), wxEXPAND | wxALL, 5);

	wxArrayString m_choiceDateChoices;
	m_choiceDate = new wxChoice(this, ID_PRV_DATE, wxDefaultPosition, wxDefaultSize, m_choiceDateChoices, 0);
	m_choiceDate->SetSelection(0);
	gbSizer->Add(m_choiceDate, wxGBPosition(0, 1), wxGBSpan(1, 2), wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5);

	m_buttonPriv = new wxButton(this, ID_PRV_PRIV, wxT("< 前へ"), wxDefaultPosition, wxSize(50,-1), 0);
	gbSizer->Add(m_buttonPriv, wxGBPosition(1, 1), wxGBSpan(1, 1), wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);

	m_buttonNext = new wxButton(this, ID_PRV_NEXT, wxT("次へ >"), wxDefaultPosition, wxSize(50,-1), 0);
	gbSizer->Add(m_buttonNext, wxGBPosition(1, 2), wxGBSpan(1, 1), wxALL|wxALIGN_CENTER_VERTICAL, 5);

	m_sliderZoom = new wxSlider(this, ID_PRV_ZOOM, 0, 0, 100, wxDefaultPosition, wxSize(100,-1), wxSL_HORIZONTAL);
	gbSizer->Add(m_sliderZoom, wxGBPosition(2, 1), wxGBSpan(1, 2), wxALL|wxALIGN_CENTER_HORIZONTAL, 5);

	wxString m_choiceMaskChoices[] = { wxT("マスクしない"), wxT("マスクする") };
	int m_choiceMaskNChoices = sizeof(m_choiceMaskChoices) / sizeof(wxString);
	m_choiceMask = new wxChoice(this, ID_PRV_MASK, wxDefaultPosition, wxSize(100,-1), m_choiceMaskNChoices, m_choiceMaskChoices, 0);
	m_choiceMask->SetSelection(0);
	gbSizer->Add(m_choiceMask, wxGBPosition(4, 1), wxGBSpan(1, 2), wxALL|wxALIGN_CENTER_VERTICAL, 5);

	wxString m_choicePageChoices[] = { wxT("すべて"), wxT("表示ページのみ") };
	int m_choicePageNChoices = sizeof(m_choicePageChoices) / sizeof(wxString);
	m_choicePage = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxSize(100,-1), m_choicePageNChoices, m_choicePageChoices, 0);
	m_choicePage->SetSelection(0);
	gbSizer->Add(m_choicePage, wxGBPosition(5, 1), wxGBSpan(1, 2), wxALL|wxALIGN_CENTER_VERTICAL, 5);

	m_spinCtrlPZoom = new wxSpinCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(50,-1), wxSP_ARROW_KEYS, 50, 150, 100);
	gbSizer->Add(m_spinCtrlPZoom, wxGBPosition(6, 1), wxGBSpan(1, 2), wxALL|wxALIGN_CENTER_VERTICAL, 5);

	m_buttonPrint = new wxButton(this, ID_PRV_PRINT, wxT("印刷"), wxDefaultPosition, wxSize(100,-1), 0);
	gbSizer->Add(m_buttonPrint, wxGBPosition(7, 1), wxGBSpan(1, 2), wxALL|wxALIGN_CENTER_VERTICAL, 5);


	gbSizer->AddGrowableCol(0);
	gbSizer->AddGrowableRow(3);

	this->SetSizer(gbSizer);
	this->Layout();

	this->Centre(wxBOTH);

	// Connect Events
	m_buttonPriv->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PreviewFrame::OnPriv), NULL, this);
	m_buttonNext->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PreviewFrame::OnNext), NULL, this);
	m_sliderZoom->Connect(wxEVT_SCROLL_TOP, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Connect(wxEVT_SCROLL_BOTTOM, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Connect(wxEVT_SCROLL_LINEUP, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Connect(wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Connect(wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Connect(wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Connect(wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Connect(wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Connect(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_choiceMask->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(PreviewFrame::OnMaskChoice), NULL, this);
	m_choicePage->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(PreviewFrame::OnPageChoice), NULL, this);
	m_buttonPrint->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PreviewFrame::OnPrint), NULL, this);
}

PreviewFrame::~PreviewFrame()
{
	// Disconnect Events
	m_buttonPriv->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PreviewFrame::OnPriv), NULL, this);
	m_buttonNext->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PreviewFrame::OnNext), NULL, this);
	m_sliderZoom->Disconnect(wxEVT_SCROLL_TOP, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Disconnect(wxEVT_SCROLL_BOTTOM, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Disconnect(wxEVT_SCROLL_LINEUP, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Disconnect(wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Disconnect(wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Disconnect(wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Disconnect(wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Disconnect(wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_sliderZoom->Disconnect(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(PreviewFrame::OnScroll), NULL, this);
	m_choiceMask->Disconnect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(PreviewFrame::OnMaskChoice), NULL, this);
	m_choicePage->Disconnect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(PreviewFrame::OnPageChoice), NULL, this);
	m_buttonPrint->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PreviewFrame::OnPrint), NULL, this);

}