diff --git a/ZRCola/ZRCola.fbp b/ZRCola/ZRCola.fbp index 5bef685..40f4582 100644 --- a/ZRCola/ZRCola.fbp +++ b/ZRCola/ZRCola.fbp @@ -26,7 +26,7 @@ UI 1 0 - + 0 wxAUI_MGR_DEFAULT @@ -41,17 +41,18 @@ 0 wxID_ANY - - wxZRColaDialogBase + 100,100 + wxZRColaFrameBase 500,200 - wxCAPTION|wxCLOSE_BOX|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU - ; + wxDEFAULT_FRAME_STYLE + ZRCola - + wxTAB_TRAVERSAL + 1 @@ -61,12 +62,64 @@ - OnClose + + + + + + + + + + + + + + + + + + + + + + + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + + + wxZRColaComposerPanelBase + + -1,-1 + + + + + wxTAB_TRAVERSAL + + + + + + + + + @@ -89,7 +142,7 @@ - 100,100 + bSizerEditor wxVERTICAL none diff --git a/ZRCola/ZRCola.vcxproj b/ZRCola/ZRCola.vcxproj index db2e1ed..cb887d2 100644 --- a/ZRCola/ZRCola.vcxproj +++ b/ZRCola/ZRCola.vcxproj @@ -81,13 +81,15 @@ Create - + + - + + diff --git a/ZRCola/ZRCola.vcxproj.filters b/ZRCola/ZRCola.vcxproj.filters index bf0a0e3..61540d1 100644 --- a/ZRCola/ZRCola.vcxproj.filters +++ b/ZRCola/ZRCola.vcxproj.filters @@ -28,7 +28,10 @@ Source Files - + + Source Files + + Source Files @@ -42,7 +45,10 @@ Header Files - + + Header Files + + Header Files diff --git a/ZRCola/stdafx.h b/ZRCola/stdafx.h index 978c94d..5966711 100644 --- a/ZRCola/stdafx.h +++ b/ZRCola/stdafx.h @@ -21,7 +21,8 @@ #include "../include/zrcola.h" #include "zrcolaapp.h" -#include "zrcoladlg.h" +#include "zrcolacomppnl.h" +#include "zrcolafrm.h" #include #include diff --git a/ZRCola/zrcolaapp.cpp b/ZRCola/zrcolaapp.cpp index cdb4751..536a55a 100644 --- a/ZRCola/zrcolaapp.cpp +++ b/ZRCola/zrcolaapp.cpp @@ -35,7 +35,7 @@ bool ZRColaApp::OnInit() if (wxLocale::IsAvailable(wxLANGUAGE_SLOVENIAN)) wxVERIFY(m_locale.AddCatalog(wxT("ZRCola"))); - wxZRColaDialog* mainFrame = new wxZRColaDialog(); + wxZRColaFrame* mainFrame = new wxZRColaFrame(); mainFrame->Show(); diff --git a/ZRCola/zrcolacomppnl.cpp b/ZRCola/zrcolacomppnl.cpp new file mode 100644 index 0000000..24ebb92 --- /dev/null +++ b/ZRCola/zrcolacomppnl.cpp @@ -0,0 +1,52 @@ +/* + Copyright 2015-2016 Amebis + + This file is part of ZRCola. + + ZRCola is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + ZRCola is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with ZRCola. If not, see . +*/ + +#include "stdafx.h" + + +////////////////////////////////////////////////////////////////////////// +// wxZRColaComposerPanel +////////////////////////////////////////////////////////////////////////// + +wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) : wxZRColaComposerPanelBase(parent) +{ +} + + +wxZRColaComposerPanel::~wxZRColaComposerPanel() +{ +} + + +void wxZRColaComposerPanel::OnDecomposedText(wxCommandEvent& event) +{ + // TODO: Do the real ZRCola composition here. + m_composed->SetValue(m_decomposed->GetValue()); + + event.Skip(); +} + + +void wxZRColaComposerPanel::OnComposedText(wxCommandEvent& event) +{ + // TODO: Do the real ZRCola decomposition here. + m_decomposed->SetValue(m_composed->GetValue()); + + event.Skip(); +} diff --git a/ZRCola/zrcolacomppnl.h b/ZRCola/zrcolacomppnl.h new file mode 100644 index 0000000..31dc631 --- /dev/null +++ b/ZRCola/zrcolacomppnl.h @@ -0,0 +1,46 @@ +/* + Copyright 2015-2016 Amebis + + This file is part of ZRCola. + + ZRCola is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + ZRCola is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with ZRCola. If not, see . +*/ + +#pragma once + +#include "zrcolagui.h" + + +/// +/// Global hotkey message identifiers +/// +#define wxZRColaHKID_INVOKE 0 + + +/// +/// ZRCola composer panel +/// +class wxZRColaComposerPanel : public wxZRColaComposerPanelBase +{ +public: + wxZRColaComposerPanel(wxWindow* parent); + virtual ~wxZRColaComposerPanel(); + + // Allow main frame direct access to our members. + friend class wxZRColaFrame; + +protected: + virtual void OnDecomposedText(wxCommandEvent& event); + virtual void OnComposedText(wxCommandEvent& event); +}; diff --git a/ZRCola/zrcoladlg.cpp b/ZRCola/zrcolafrm.cpp similarity index 71% rename from ZRCola/zrcoladlg.cpp rename to ZRCola/zrcolafrm.cpp index 605a585..e6816a8 100644 --- a/ZRCola/zrcoladlg.cpp +++ b/ZRCola/zrcolafrm.cpp @@ -21,20 +21,20 @@ ////////////////////////////////////////////////////////////////////////// -// wxZRColaDialog +// wxZRColaFrame ////////////////////////////////////////////////////////////////////////// -wxBEGIN_EVENT_TABLE(wxZRColaDialog, wxZRColaDialogBase) - EVT_UPDATE_UI(wxZRColaDialog::wxID_SEND_COMPOSED, wxZRColaDialog::OnSendComposedUpdate) - EVT_MENU (wxZRColaDialog::wxID_SEND_COMPOSED, wxZRColaDialog::OnSendComposed ) - EVT_MENU (wxZRColaDialog::wxID_SEND_ABORT , wxZRColaDialog::OnSendAbort ) - EVT_MENU ( wxID_ABOUT , wxZRColaDialog::OnAbout ) +wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxZRColaFrameBase) + EVT_UPDATE_UI(wxZRColaFrame::wxID_SEND_COMPOSED, wxZRColaFrame::OnSendComposedUpdate) + EVT_MENU (wxZRColaFrame::wxID_SEND_COMPOSED, wxZRColaFrame::OnSendComposed ) + EVT_MENU (wxZRColaFrame::wxID_SEND_ABORT , wxZRColaFrame::OnSendAbort ) + EVT_MENU ( wxID_ABOUT , wxZRColaFrame::OnAbout ) wxEND_EVENT_TABLE() -wxZRColaDialog::wxZRColaDialog() : +wxZRColaFrame::wxZRColaFrame() : m_hWndSource(NULL), - wxZRColaDialogBase(NULL) + wxZRColaFrameBase(NULL) { // Load main window icons. #ifdef __WINDOWS__ @@ -46,6 +46,9 @@ wxZRColaDialog::wxZRColaDialog() : SetIcon(wxICON(00_zrcola.ico)); #endif + // Create the composer panel. + m_panel = new wxZRColaComposerPanel(this); + // Register global hotkey(s). if (!RegisterHotKey(wxZRColaHKID_INVOKE, MOD_ALT | MOD_CONTROL, 'Z')) wxMessageBox(_("ZRCola keyboard shortcut Ctrl+Alt+Z could not be registered. Some functionality will not be available."), _("Warning"), wxOK | wxICON_WARNING); @@ -60,48 +63,24 @@ wxZRColaDialog::wxZRColaDialog() : } -wxZRColaDialog::~wxZRColaDialog() +wxZRColaFrame::~wxZRColaFrame() { // Unregister global hotkey(s). UnregisterHotKey(wxZRColaHKID_INVOKE); } -void wxZRColaDialog::OnClose(wxCloseEvent& event) -{ - Destroy(); -} - - -void wxZRColaDialog::OnDecomposedText(wxCommandEvent& event) -{ - // TODO: Do the real ZRCola composition here. - m_composed->SetValue(m_decomposed->GetValue()); - - event.Skip(); -} - - -void wxZRColaDialog::OnComposedText(wxCommandEvent& event) -{ - // TODO: Do the real ZRCola decomposition here. - m_decomposed->SetValue(m_composed->GetValue()); - - event.Skip(); -} - - -void wxZRColaDialog::OnSendComposedUpdate(wxUpdateUIEvent& event) +void wxZRColaFrame::OnSendComposedUpdate(wxUpdateUIEvent& event) { event.Enable(m_hWndSource ? true : false); } -void wxZRColaDialog::OnSendComposed(wxCommandEvent& event) +void wxZRColaFrame::OnSendComposed(wxCommandEvent& event) { if (m_hWndSource) { // Get text and its length (in Unicode characters). Prepare the INPUT table. - wxString text = m_composed->GetValue(); + wxString text = m_panel->m_composed->GetValue(); std::vector::size_type i = 0, n = text.length(); wxString::const_iterator i_text = text.begin(); std::vector input(n); @@ -122,15 +101,15 @@ void wxZRColaDialog::OnSendComposed(wxCommandEvent& event) m_hWndSource = NULL; // Select all input in composer to prepare for the overwrite next time. - m_decomposed->SelectAll(); - m_composed->SelectAll(); + m_panel->m_decomposed->SelectAll(); + m_panel->m_composed->SelectAll(); } event.Skip(); } -void wxZRColaDialog::OnSendAbort(wxCommandEvent& event) +void wxZRColaFrame::OnSendAbort(wxCommandEvent& event) { if (m_hWndSource) { // Return focus to the source window. @@ -139,27 +118,27 @@ void wxZRColaDialog::OnSendAbort(wxCommandEvent& event) m_hWndSource = NULL; // Select all input in composer to prepare for the overwrite next time. - m_decomposed->SelectAll(); - m_composed->SelectAll(); + m_panel->m_decomposed->SelectAll(); + m_panel->m_composed->SelectAll(); } event.Skip(); } -void wxZRColaDialog::OnAbout(wxCommandEvent& event) +void wxZRColaFrame::OnAbout(wxCommandEvent& event) { wxMessageBox(wxString::Format(_("ZRCola v%s\nCopyright 2015-%s Amebis"), wxT(ZRCOLA_VERSION_STR), wxT(ZRCOLA_BUILD_YEAR_STR)), _("About ZRCola"), wxOK | wxICON_INFORMATION); } -WXLRESULT wxZRColaDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) +WXLRESULT wxZRColaFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { if (message == WM_HOTKEY && wParam == wxZRColaHKID_INVOKE) { // ZRCola hotkey was pressed. Remember the source window and focus ours. m_hWndSource = ::GetForegroundWindow(); - m_decomposed->SetFocus(); + m_panel->m_decomposed->SetFocus(); //if (m_state == wxABS_FLOAT) { if (IsIconized()) { ::SendMessage(m_hWnd, WM_SYSCOMMAND, SC_RESTORE, 0); @@ -182,5 +161,5 @@ WXLRESULT wxZRColaDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARA return 0; } else - return wxZRColaDialogBase::MSWWindowProc(message, wParam, lParam); + return wxZRColaFrameBase::MSWWindowProc(message, wParam, lParam); } diff --git a/ZRCola/zrcoladlg.h b/ZRCola/zrcolafrm.h similarity index 75% rename from ZRCola/zrcoladlg.h rename to ZRCola/zrcolafrm.h index cb86a1b..310b524 100644 --- a/ZRCola/zrcoladlg.h +++ b/ZRCola/zrcolafrm.h @@ -20,6 +20,7 @@ #pragma once #include "zrcolagui.h" +#include "zrcolacomppnl.h" /// /// Global hotkey message identifiers @@ -30,7 +31,7 @@ /// /// ZRCola main frame /// -class wxZRColaDialog : public wxZRColaDialogBase +class wxZRColaFrame : public wxZRColaFrameBase { protected: enum { @@ -39,14 +40,10 @@ protected: }; public: - wxZRColaDialog(); - virtual ~wxZRColaDialog(); + wxZRColaFrame(); + virtual ~wxZRColaFrame(); protected: - virtual void OnClose(wxCloseEvent& event); - virtual void OnDecomposedText(wxCommandEvent& event); - virtual void OnComposedText(wxCommandEvent& event); - void OnSendComposedUpdate(wxUpdateUIEvent& event); void OnSendComposed(wxCommandEvent& event); void OnSendAbort(wxCommandEvent& event); @@ -57,5 +54,6 @@ protected: virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); protected: - WXHWND m_hWndSource; ///< handle of the active window, when the ZRCola hotkey was pressed + WXHWND m_hWndSource; ///< handle of the active window, when the ZRCola hotkey was pressed + wxZRColaComposerPanel *m_panel; ///< composer panel }; diff --git a/ZRCola/zrcolagui.cpp b/ZRCola/zrcolagui.cpp index fe8a218..a852066 100644 --- a/ZRCola/zrcolagui.cpp +++ b/ZRCola/zrcolagui.cpp @@ -22,14 +22,23 @@ wxHelpProvider::Set( new wxHelpControllerHelpProvider ); static wxFBContextSensitiveHelpSetter s_wxFBSetTheHelpProvider; /////////////////////////////////////////////////////////////////////////// -wxZRColaDialogBase::wxZRColaDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +wxZRColaFrameBase::wxZRColaFrameBase( 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->SetSizeHints( wxSize( 100,100 ), wxDefaultSize ); + + this->Centre( wxBOTH ); +} + +wxZRColaFrameBase::~wxZRColaFrameBase() +{ +} + +wxZRColaComposerPanelBase::wxZRColaComposerPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) +{ wxBoxSizer* bSizerEditor; bSizerEditor = new wxBoxSizer( wxVERTICAL ); - bSizerEditor->SetMinSize( wxSize( 100,100 ) ); m_decomposed = new wxTextCtrl( this, wxID_DECOMPOSED, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE ); m_decomposed->SetFont( wxFont( 20, 70, 90, 90, false, wxT("00 ZRCola") ) ); @@ -43,20 +52,17 @@ wxZRColaDialogBase::wxZRColaDialogBase( wxWindow* parent, wxWindowID id, const w this->SetSizer( bSizerEditor ); this->Layout(); - - this->Centre( wxBOTH ); + bSizerEditor->Fit( this ); // Connect Events - this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( wxZRColaDialogBase::OnClose ) ); - m_decomposed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaDialogBase::OnDecomposedText ), NULL, this ); - m_composed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaDialogBase::OnComposedText ), NULL, this ); + m_decomposed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDecomposedText ), NULL, this ); + m_composed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this ); } -wxZRColaDialogBase::~wxZRColaDialogBase() +wxZRColaComposerPanelBase::~wxZRColaComposerPanelBase() { // Disconnect Events - this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( wxZRColaDialogBase::OnClose ) ); - m_decomposed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaDialogBase::OnDecomposedText ), NULL, this ); - m_composed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaDialogBase::OnComposedText ), NULL, this ); + m_decomposed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDecomposedText ), NULL, this ); + m_composed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this ); } diff --git a/ZRCola/zrcolagui.h b/ZRCola/zrcolagui.h index f1f2a97..1afa567 100644 --- a/ZRCola/zrcolagui.h +++ b/ZRCola/zrcolagui.h @@ -13,20 +13,38 @@ #include #include #include -#include +#include #include #include #include #include +#include #include -#include +#include /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -/// Class wxZRColaDialogBase +/// Class wxZRColaFrameBase /////////////////////////////////////////////////////////////////////////////// -class wxZRColaDialogBase : public wxDialog +class wxZRColaFrameBase : public wxFrame +{ + private: + + protected: + + public: + + wxZRColaFrameBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("ZRCola"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,200 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); + + ~wxZRColaFrameBase(); + +}; + +/////////////////////////////////////////////////////////////////////////////// +/// Class wxZRColaComposerPanelBase +/////////////////////////////////////////////////////////////////////////////// +class wxZRColaComposerPanelBase : public wxPanel { private: @@ -41,15 +59,14 @@ class wxZRColaDialogBase : public wxDialog wxTextCtrl* m_composed; // Virtual event handlers, overide them in your derived class - virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } virtual void OnDecomposedText( wxCommandEvent& event ) { event.Skip(); } virtual void OnComposedText( wxCommandEvent& event ) { event.Skip(); } public: - wxZRColaDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("ZRCola"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,200 ), long style = wxCAPTION|wxCLOSE_BOX|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); - ~wxZRColaDialogBase(); + wxZRColaComposerPanelBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL ); + ~wxZRColaComposerPanelBase(); };