Main window is wxFrame based now

This commit is contained in:
Simon Rozman 2016-02-08 12:56:13 +01:00
parent efc1746db1
commit 208ef894a7
11 changed files with 246 additions and 86 deletions

View File

@ -26,7 +26,7 @@
<property name="ui_table">UI</property>
<property name="use_enum">1</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
<object class="Frame" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
@ -41,17 +41,18 @@
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">wxZRColaDialogBase</property>
<property name="minimum_size">100,100</property>
<property name="name">wxZRColaFrameBase</property>
<property name="pos"></property>
<property name="size">500,200</property>
<property name="style">wxCAPTION|wxCLOSE_BOX|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU</property>
<property name="subclass">; </property>
<property name="style">wxDEFAULT_FRAME_STYLE</property>
<property name="subclass"></property>
<property name="title">ZRCola</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<property name="xrc_skip_sizer">1</property>
<event name="OnActivate"></event>
<event name="OnActivateApp"></event>
<event name="OnAuiFindManager"></event>
@ -61,12 +62,64 @@
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnChar"></event>
<event name="OnClose">OnClose</event>
<event name="OnClose"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnHibernate"></event>
<event name="OnIconize"></event>
<event name="OnIdle"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
<object class="Panel" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">wxZRColaComposerPanelBase</property>
<property name="pos"></property>
<property name="size">-1,-1</property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<event name="OnAuiFindManager"></event>
<event name="OnAuiPaneButton"></event>
<event name="OnAuiPaneClose"></event>
<event name="OnAuiPaneMaximize"></event>
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnInitDialog"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
@ -89,7 +142,7 @@
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size">100,100</property>
<property name="minimum_size"></property>
<property name="name">bSizerEditor</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>

View File

@ -81,13 +81,15 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="zrcolaapp.cpp" />
<ClCompile Include="zrcoladlg.cpp" />
<ClCompile Include="zrcolacomppnl.cpp" />
<ClCompile Include="zrcolafrm.cpp" />
<ClCompile Include="zrcolagui.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="zrcolaapp.h" />
<ClInclude Include="zrcoladlg.h" />
<ClInclude Include="zrcolacomppnl.h" />
<ClInclude Include="zrcolafrm.h" />
<ClInclude Include="zrcolagui.h" />
</ItemGroup>
<ItemGroup>

View File

@ -28,7 +28,10 @@
<ClCompile Include="zrcolagui.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="zrcoladlg.cpp">
<ClCompile Include="zrcolacomppnl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="zrcolafrm.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@ -42,7 +45,10 @@
<ClInclude Include="zrcolagui.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="zrcoladlg.h">
<ClInclude Include="zrcolacomppnl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="zrcolafrm.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>

View File

@ -21,7 +21,8 @@
#include "../include/zrcola.h"
#include "zrcolaapp.h"
#include "zrcoladlg.h"
#include "zrcolacomppnl.h"
#include "zrcolafrm.h"
#include <wx/msgdlg.h>
#include <wxex/common.h>

View File

@ -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();

52
ZRCola/zrcolacomppnl.cpp Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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();
}

46
ZRCola/zrcolacomppnl.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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);
};

View File

@ -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<INPUT>::size_type i = 0, n = text.length();
wxString::const_iterator i_text = text.begin();
std::vector<INPUT> 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);
}

View File

@ -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);
@ -58,4 +55,5 @@ protected:
protected:
WXHWND m_hWndSource; ///< handle of the active window, when the ZRCola hotkey was pressed
wxZRColaComposerPanel *m_panel; ///< composer panel
};

View File

@ -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 );
}

View File

@ -13,20 +13,38 @@
#include <wx/cshelp.h>
#include <wx/intl.h>
#include <wx/string.h>
#include <wx/textctrl.h>
#include <wx/frame.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/dialog.h>
#include <wx/panel.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// 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();
};