diff --git a/ZRCola/ZRCola.fbp b/ZRCola/ZRCola.fbp new file mode 100644 index 0000000..5bef685 --- /dev/null +++ b/ZRCola/ZRCola.fbp @@ -0,0 +1,281 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + zrcolagui + 1000 + wxHelpControllerHelpProvider + 1 + ZRCola + + . + #include "stdafx.h" + 1 + 1 + 1 + 1 + UI + 1 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + wxZRColaDialogBase + + 500,200 + wxCAPTION|wxCLOSE_BOX|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU + ; + ZRCola + + + + + + + + + + + + + + OnClose + + + + + + + + + + + + + + + + + + + + + + + + + + + + 100,100 + bSizerEditor + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 50 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + 00 ZRCola,90,90,20,70,0 + 0 + 0 + wxID_DECOMPOSED + + 0 + + + + 0 + + 1 + m_decomposed + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_CENTRE + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnDecomposedText + + + + + + + + 5 + wxALL|wxEXPAND + 50 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + 00 ZRCola,90,90,20,70,0 + 0 + 0 + wxID_COMPOSED + + 0 + + + + 0 + + 1 + m_composed + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_CENTRE + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnComposedText + + + + + + + + + + diff --git a/ZRCola/ZRCola.vcxproj b/ZRCola/ZRCola.vcxproj index 9234d47..ff10b70 100644 --- a/ZRCola/ZRCola.vcxproj +++ b/ZRCola/ZRCola.vcxproj @@ -74,7 +74,6 @@ - Create Create @@ -82,12 +81,14 @@ Create - + + - + + diff --git a/ZRCola/ZRCola.vcxproj.filters b/ZRCola/ZRCola.vcxproj.filters index e6ca11b..559f8d9 100644 --- a/ZRCola/ZRCola.vcxproj.filters +++ b/ZRCola/ZRCola.vcxproj.filters @@ -18,13 +18,13 @@ Source Files - - Source Files - Source Files - + + Source Files + + Source Files @@ -35,7 +35,10 @@ Header Files - + + Header Files + + Header Files diff --git a/ZRCola/main.cpp b/ZRCola/main.cpp deleted file mode 100644 index 5aaafa9..0000000 --- a/ZRCola/main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - 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" - - - - - - - - -//int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) -//{ -// UNREFERENCED_PARAMETER(hInstance); -// UNREFERENCED_PARAMETER(hPrevInstance); -// UNREFERENCED_PARAMETER(lpCmdLine); -// UNREFERENCED_PARAMETER(nCmdShow); -// -// Sleep(10000); -// -// { -// INPUT input[2]; -// -// input[0].type = INPUT_KEYBOARD; -// input[0].ki.wVk = 0; -// input[0].ki.wScan = 0x00d2; -// input[0].ki.dwFlags = KEYEVENTF_UNICODE; -// input[0].ki.time = 0; -// input[0].ki.dwExtraInfo = 0; -// -// input[1].type = INPUT_KEYBOARD; -// input[1].ki.wVk = 0; -// input[1].ki.wScan = 0x00d2; -// input[1].ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP; -// input[1].ki.time = 0; -// input[1].ki.dwExtraInfo = 0; -// -// SendInput(_countof(input), input, sizeof(INPUT)); -// } -// -// return 0; -//} diff --git a/ZRCola/stdafx.h b/ZRCola/stdafx.h index 68cab4e..b6f09fe 100644 --- a/ZRCola/stdafx.h +++ b/ZRCola/stdafx.h @@ -21,11 +21,9 @@ #include "../include/ZRCola.h" #include "zrcolaapp.h" -#include "zrcolaframe.h" +#include "zrcoladlg.h" -#include #include -#include #include #include diff --git a/ZRCola/zrcolaapp.cpp b/ZRCola/zrcolaapp.cpp index 6b3d96d..cdb4751 100644 --- a/ZRCola/zrcolaapp.cpp +++ b/ZRCola/zrcolaapp.cpp @@ -35,11 +35,7 @@ bool ZRColaApp::OnInit() if (wxLocale::IsAvailable(wxLANGUAGE_SLOVENIAN)) wxVERIFY(m_locale.AddCatalog(wxT("ZRCola"))); - wxZRColaFrame* mainFrame = new wxZRColaFrame(); - if (!mainFrame->Create()) { - delete mainFrame; - return false; - } + wxZRColaDialog* mainFrame = new wxZRColaDialog(); mainFrame->Show(); diff --git a/ZRCola/zrcolaframe.cpp b/ZRCola/zrcoladlg.cpp similarity index 51% rename from ZRCola/zrcolaframe.cpp rename to ZRCola/zrcoladlg.cpp index 120ffd1..70da867 100644 --- a/ZRCola/zrcolaframe.cpp +++ b/ZRCola/zrcoladlg.cpp @@ -21,57 +21,22 @@ ////////////////////////////////////////////////////////////////////////// -// wxZRColaFrame +// wxZRColaDialog ////////////////////////////////////////////////////////////////////////// -wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxAppBarFrame) - EVT_TEXT (wxZRColaFrame::wxID_DECOMPOSED , wxZRColaFrame::OnDecomposedText ) - EVT_TEXT (wxZRColaFrame::wxID_COMPOSED , wxZRColaFrame::OnComposedText ) - 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 ) +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 ) wxEND_EVENT_TABLE() -wxZRColaFrame::wxZRColaFrame() : +wxZRColaDialog::wxZRColaDialog() : m_hWndSource(NULL), - wxAppBarFrame() + wxZRColaDialogBase(NULL) { -} - - -bool wxZRColaFrame::Create() -{ - wxImage::AddHandler(new wxICOHandler); - - wxCHECK(wxAppBarFrame::Create(NULL, wxID_ANY, _("ZRCola"), wxABS_FLOAT, wxABF_ALLOWFLOAT | wxABF_ALLOWDOCKHORIZONTAL | wxABF_ALLOWSIZING | wxABF_HIDETASKBARTABWHENDOCKED, wxDefaultPosition, wxSize(400, 150)), false); - - wxFont fontZRCola(20, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("00 ZRCola")); - - wxCHECK(m_decomposed.Create(this, wxID_DECOMPOSED, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE), false); - m_decomposed.SetFont(fontZRCola); - - wxCHECK(m_composed.Create(this, wxID_COMPOSED, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE), false); - m_composed.SetFont(fontZRCola); - - wxBoxSizer - *boxH = new wxBoxSizer(wxHORIZONTAL), - *boxV = new wxBoxSizer(wxVERTICAL); - - boxV->Add(&m_decomposed, 1, wxEXPAND, 5); - boxV->Add(&m_composed, 1, wxEXPAND, 5); - boxH->Add(boxV, 1, wxEXPAND, 5); - - m_toolBar.Create(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL); - m_toolBar.AddTool(wxID_SEND_COMPOSED, _("Send"), wxBitmap(wxIcon(wxICON(send.ico)))); - m_toolBar.Realize(); - - boxH->Add(&m_toolBar, 0, wxEXPAND, 5); - - SetSizer(boxH); - Layout(); - Centre(wxBOTH); + SetIcon(wxIcon(wxICON(send.ico))); // Register global hotkey(s). if (!RegisterHotKey(wxZRColaHKID_INVOKE, MOD_ALT | MOD_CONTROL, 'Z')) @@ -84,49 +49,51 @@ bool wxZRColaFrame::Create() entries[1].Set(wxACCEL_NORMAL, WXK_ESCAPE, wxID_SEND_ABORT); SetAcceleratorTable(wxAcceleratorTable(_countof(entries), entries)); } - - return true; } -bool wxZRColaFrame::Destroy() +wxZRColaDialog::~wxZRColaDialog() { // Unregister global hotkey(s). UnregisterHotKey(wxZRColaHKID_INVOKE); - - return wxAppBarFrame::Destroy(); } -void wxZRColaFrame::OnDecomposedText(wxCommandEvent& event) +void wxZRColaDialog::OnClose(wxCloseEvent& event) +{ + Destroy(); +} + + +void wxZRColaDialog::OnDecomposedText(wxCommandEvent& event) { // TODO: Do the real ZRCola composition here. - m_composed.SetValue(m_decomposed.GetValue()); + m_composed->SetValue(m_decomposed->GetValue()); event.Skip(); } -void wxZRColaFrame::OnComposedText(wxCommandEvent& event) +void wxZRColaDialog::OnComposedText(wxCommandEvent& event) { // TODO: Do the real ZRCola decomposition here. - m_decomposed.SetValue(m_composed.GetValue()); + m_decomposed->SetValue(m_composed->GetValue()); event.Skip(); } -void wxZRColaFrame::OnSendComposedUpdate(wxUpdateUIEvent& event) +void wxZRColaDialog::OnSendComposedUpdate(wxUpdateUIEvent& event) { event.Enable(m_hWndSource ? true : false); } -void wxZRColaFrame::OnSendComposed(wxCommandEvent& event) +void wxZRColaDialog::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_composed->GetValue(); std::vector::size_type i = 0, n = text.length(); wxString::const_iterator i_text = text.begin(); std::vector input(n); @@ -147,15 +114,15 @@ void wxZRColaFrame::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_decomposed->SelectAll(); + m_composed->SelectAll(); } event.Skip(); } -void wxZRColaFrame::OnSendAbort(wxCommandEvent& event) +void wxZRColaDialog::OnSendAbort(wxCommandEvent& event) { if (m_hWndSource) { // Return focus to the source window. @@ -164,48 +131,48 @@ void wxZRColaFrame::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_decomposed->SelectAll(); + m_composed->SelectAll(); } event.Skip(); } -void wxZRColaFrame::OnAbout(wxCommandEvent& event) +void wxZRColaDialog::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 wxZRColaFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) +WXLRESULT wxZRColaDialog::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(); - if (m_state == wxABS_FLOAT) { + m_decomposed->SetFocus(); + //if (m_state == wxABS_FLOAT) { if (IsIconized()) { ::SendMessage(m_hWnd, WM_SYSCOMMAND, SC_RESTORE, 0); } else { ::SetActiveWindow(m_hWnd); ::SetForegroundWindow(m_hWnd); } - } else if (wxAppBarIsDocked(m_state)) { - // ZRCola window is currently docked. + //} else if (wxAppBarIsDocked(m_state)) { + // // ZRCola window is currently docked. - if (GetAutoHidden()) { - // Unhide it. - ShowAutoHideAppBar(); - } + // if (GetAutoHidden()) { + // // Unhide it. + // ShowAutoHideAppBar(); + // } - ::SetActiveWindow(m_hWnd); - ::SetForegroundWindow(m_hWnd); - } else - wxFAIL_MSG(wxT("unsupported application bar state")); + // ::SetActiveWindow(m_hWnd); + // ::SetForegroundWindow(m_hWnd); + //} else + // wxFAIL_MSG(wxT("unsupported application bar state")); return 0; } else - return wxAppBarFrame::MSWWindowProc(message, wParam, lParam); + return wxZRColaDialogBase::MSWWindowProc(message, wParam, lParam); } diff --git a/ZRCola/zrcolaframe.h b/ZRCola/zrcoladlg.h similarity index 70% rename from ZRCola/zrcolaframe.h rename to ZRCola/zrcoladlg.h index d940473..cb86a1b 100644 --- a/ZRCola/zrcolaframe.h +++ b/ZRCola/zrcoladlg.h @@ -19,10 +19,7 @@ #pragma once -#include -#include -#include - +#include "zrcolagui.h" /// /// Global hotkey message identifiers @@ -33,24 +30,23 @@ /// /// ZRCola main frame /// -class wxZRColaFrame : public wxAppBarFrame +class wxZRColaDialog : public wxZRColaDialogBase { protected: enum { wxID_SEND_COMPOSED = wxID_HIGHEST, wxID_SEND_ABORT, - wxID_DECOMPOSED, - wxID_COMPOSED, }; public: - wxZRColaFrame(); - bool Create(); - virtual bool Destroy(); + wxZRColaDialog(); + virtual ~wxZRColaDialog(); protected: - void OnDecomposedText(wxCommandEvent& event); - void OnComposedText(wxCommandEvent& event); + 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); @@ -61,9 +57,5 @@ protected: virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); protected: - wxTextCtrl m_decomposed; ///< ZRCola decomposed text window - wxTextCtrl m_composed; ///< ZRCola composed text window - wxToolBar m_toolBar; ///< The toolbar - WXHWND m_hWndSource; ///< handle of the active window, when the ZRCola hotkey was pressed }; diff --git a/ZRCola/zrcolagui.cpp b/ZRCola/zrcolagui.cpp new file mode 100644 index 0000000..fe8a218 --- /dev/null +++ b/ZRCola/zrcolagui.cpp @@ -0,0 +1,62 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Jun 17 2015) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" + +#include "zrcolagui.h" + +// Using the construction of a static object to ensure that the help provider is set +class wxFBContextSensitiveHelpSetter +{ +public: +wxFBContextSensitiveHelpSetter() +{ +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 ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + 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") ) ); + + bSizerEditor->Add( m_decomposed, 50, wxALL|wxEXPAND, 5 ); + + m_composed = new wxTextCtrl( this, wxID_COMPOSED, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE ); + m_composed->SetFont( wxFont( 20, 70, 90, 90, false, wxT("00 ZRCola") ) ); + + bSizerEditor->Add( m_composed, 50, wxALL|wxEXPAND, 5 ); + + + this->SetSizer( bSizerEditor ); + this->Layout(); + + this->Centre( wxBOTH ); + + // 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 ); +} + +wxZRColaDialogBase::~wxZRColaDialogBase() +{ + // 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 ); + +} diff --git a/ZRCola/zrcolagui.h b/ZRCola/zrcolagui.h new file mode 100644 index 0000000..f1f2a97 --- /dev/null +++ b/ZRCola/zrcolagui.h @@ -0,0 +1,56 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Jun 17 2015) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __ZRCOLAGUI_H__ +#define __ZRCOLAGUI_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class wxZRColaDialogBase +/////////////////////////////////////////////////////////////////////////////// +class wxZRColaDialogBase : public wxDialog +{ + private: + + protected: + enum + { + wxID_DECOMPOSED = 1000, + wxID_COMPOSED + }; + + wxTextCtrl* m_decomposed; + 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(); + +}; + +#endif //__ZRCOLAGUI_H__