From 21114d818cd450e5f16013aed42cd1f96c65cc17 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 22 Apr 2016 16:12:59 +0200 Subject: [PATCH] On-screen Unicode dump added (closes #14) --- ZRCola/ZRCola.fbp | 764 +++++++++++++++++++++++++++++++++++++-- ZRCola/zrcolacomppnl.cpp | 144 +++++++- ZRCola/zrcolacomppnl.h | 23 +- ZRCola/zrcolafrm.cpp | 6 +- ZRCola/zrcolagui.cpp | 78 +++- ZRCola/zrcolagui.h | 23 ++ 6 files changed, 964 insertions(+), 74 deletions(-) diff --git a/ZRCola/ZRCola.fbp b/ZRCola/ZRCola.fbp index 7912864..421997c 100644 --- a/ZRCola/ZRCola.fbp +++ b/ZRCola/ZRCola.fbp @@ -839,14 +839,14 @@ - bSizerEditor + bSizerMain wxVERTICAL none - + 5 wxALL|wxEXPAND 50 - + 1 1 1 @@ -870,19 +870,19 @@ 1 1 - 00 ZRCola,90,90,20,70,0 + 0 0 wxID_ANY 0 - + 5 0 - 100,25 + 1 - m_decomposed + m_splitterDecomposed 1 @@ -890,17 +890,16 @@ 1 Resizable + 1 + -5 + -1 1 - wxTE_CENTRE|wxTE_MULTILINE + wxSPLIT_VERTICAL + wxSP_3D|wxSP_LIVE_UPDATE 0 - - wxFILTER_NONE - wxDefaultValidator - - @@ -920,24 +919,372 @@ - OnDecomposedPaint + - OnDecomposedText - - - + + + + + + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelDecomposedEdit + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerDecomposedEdit + 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_ANY + + 0 + + + + 0 + 100,25 + 1 + m_decomposed + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_MULTILINE + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + OnDecomposedPaint + + + + + + OnDecomposedText + + + + + + + + + + + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelDecomposedHex + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerDecomposedHex + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 50 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,90,-1,76,0 + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_decomposedHex + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_MULTILINE|wxTE_READONLY + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + OnDecomposedHexPaint + + + + + + + + + + + + + + + - + 5 wxALL|wxEXPAND 50 - + 1 1 1 @@ -961,19 +1308,19 @@ 1 1 - 00 ZRCola,90,90,20,70,0 + 0 0 wxID_ANY 0 - + 5 0 - 100,25 + 1 - m_composed + m_splitterComposed 1 @@ -981,17 +1328,16 @@ 1 Resizable + 1 + -5 + -1 1 - wxTE_CENTRE|wxTE_MULTILINE + wxSPLIT_VERTICAL + wxSP_3D|wxSP_LIVE_UPDATE 0 - - wxFILTER_NONE - wxDefaultValidator - - @@ -1011,17 +1357,365 @@ - OnComposedPaint + - OnComposedText - - - + + + + + + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelComposedEdit + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerComposedEdit + 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_ANY + + 0 + + + + 0 + 100,25 + 1 + m_composed + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_MULTILINE + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + OnComposedPaint + + + + + + OnComposedText + + + + + + + + + + + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelComposedHex + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerComposedHex + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 50 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,90,-1,76,0 + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_composedHex + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_MULTILINE|wxTE_READONLY + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + OnComposedHexPaint + + + + + + + + + + + + + + + diff --git a/ZRCola/zrcolacomppnl.cpp b/ZRCola/zrcolacomppnl.cpp index 61efcdd..edca3b2 100644 --- a/ZRCola/zrcolacomppnl.cpp +++ b/ZRCola/zrcolacomppnl.cpp @@ -97,7 +97,27 @@ void wxZRColaComposerPanel::OnDecomposedPaint(wxPaintEvent& event) // Save new selection first, to avoid loop. m_selDecomposed.first = from; m_selDecomposed.second = to; - m_composed->SetSelection(m_mapping2.to_dst(m_mapping1.to_dst(from)), m_mapping2.to_dst(m_mapping1.to_dst(to))); + m_decomposedHex->SetSelection(m_mappingDecomposedHex.to_dst(from), m_mappingDecomposedHex.to_dst(to)); + m_composed->SetSelection(from = m_mapping2.to_dst(m_mapping1.to_dst(from)), to = m_mapping2.to_dst(m_mapping1.to_dst(to))); + m_composedHex->SetSelection(m_mappingComposedHex.to_dst(from), m_mappingComposedHex.to_dst(to)); + } +} + + +void wxZRColaComposerPanel::OnDecomposedHexPaint(wxPaintEvent& event) +{ + event.Skip(); + + long from, to; + m_decomposedHex->GetSelection(&from, &to); + + if (m_selDecomposedHex.first != from || m_selDecomposedHex.second != to) { + // Save new selection first, to avoid loop. + m_selDecomposedHex.first = from; + m_selDecomposedHex.second = to; + m_decomposed->SetSelection(from = m_mappingDecomposedHex.to_src(from), to = m_mappingDecomposedHex.to_src(to)); + m_composed->SetSelection(from = m_mapping2.to_dst(m_mapping1.to_dst(from)), to = m_mapping2.to_dst(m_mapping1.to_dst(to))); + m_composedHex->SetSelection(m_mappingComposedHex.to_dst(from), m_mappingComposedHex.to_dst(to)); } } @@ -113,14 +133,16 @@ void wxZRColaComposerPanel::OnDecomposedText(wxCommandEvent& event) #ifdef __WINDOWS__ // Use Windows GetWindowText() function to avoid line ending conversion incompletely imposed by wxWidgets. WXHWND hWnd = m_decomposed->GetHWND(); - std::vector src((std::vector::size_type)::GetWindowTextLengthW(hWnd) + 1); + size_t len = ::GetWindowTextLengthW(hWnd); + std::vector src(len + 1); ::GetWindowTextW(hWnd, src.data(), src.size()); #else wxString src(m_decomposed->GetValue()); + size_t len = src.Length(); #endif std::wstring norm; - ((ZRColaApp*)wxTheApp)->m_t_db.Decompose(src.data(), src.size(), norm, &m_mapping1); + ((ZRColaApp*)wxTheApp)->m_t_db.Decompose(src.data(), len, norm, &m_mapping1); std::wstring dst; ((ZRColaApp*)wxTheApp)->m_t_db.Compose(norm.data(), norm.size(), dst, &m_mapping2); @@ -128,10 +150,22 @@ void wxZRColaComposerPanel::OnDecomposedText(wxCommandEvent& event) long from, to; m_decomposed->GetSelection(&from, &to); + // Update decomposed HEX dump. + wxString hex; + GetHex(hex, m_mappingDecomposedHex, src.data(), len); + m_decomposedHex->SetValue(hex); + m_decomposedHex->SetSelection(m_mappingDecomposedHex.to_dst(from), m_mappingDecomposedHex.to_dst(to)); + // Update composed text. m_progress = true; m_composed->SetValue(dst); - m_composed->SetSelection(m_mapping2.to_dst(m_mapping1.to_dst(from)), m_mapping2.to_dst(m_mapping1.to_dst(to))); + m_composed->SetSelection(from = m_mapping2.to_dst(m_mapping1.to_dst(from)), to = m_mapping2.to_dst(m_mapping1.to_dst(to))); + + // Update composed HEX dump. + GetHex(hex, m_mappingComposedHex, dst.data(), dst.length()); + m_composedHex->SetValue(hex); + m_composedHex->SetSelection(m_mappingComposedHex.to_dst(from), m_mappingComposedHex.to_dst(to)); + event.Skip(); m_progress = false; @@ -152,7 +186,27 @@ void wxZRColaComposerPanel::OnComposedPaint(wxPaintEvent& event) // Save new selection first, to avoid loop. m_selComposed.first = from; m_selComposed.second = to; - m_decomposed->SetSelection(m_mapping1.to_src(m_mapping2.to_src(from)), m_mapping1.to_src(m_mapping2.to_src(to))); + m_composedHex->SetSelection(m_mappingComposedHex.to_dst(from), m_mappingComposedHex.to_dst(to)); + m_decomposed->SetSelection(from = m_mapping1.to_src(m_mapping2.to_src(from)), to = m_mapping1.to_src(m_mapping2.to_src(to))); + m_decomposedHex->SetSelection(m_mappingDecomposedHex.to_dst(from), m_mappingDecomposedHex.to_dst(to)); + } +} + + +void wxZRColaComposerPanel::OnComposedHexPaint(wxPaintEvent& event) +{ + event.Skip(); + + long from, to; + m_composedHex->GetSelection(&from, &to); + + if (m_selComposedHex.first != from || m_selComposedHex.second != to) { + // Save new selection first, to avoid loop. + m_selComposedHex.first = from; + m_selComposedHex.second = to; + m_composed->SetSelection(from = m_mappingComposedHex.to_src(from), to = m_mappingComposedHex.to_src(to)); + m_decomposed->SetSelection(from = m_mapping1.to_src(m_mapping2.to_src(from)), to = m_mapping1.to_src(m_mapping2.to_src(to))); + m_decomposedHex->SetSelection(m_mappingDecomposedHex.to_dst(from), m_mappingDecomposedHex.to_dst(to)); } } @@ -168,19 +222,21 @@ void wxZRColaComposerPanel::OnComposedText(wxCommandEvent& event) #ifdef __WINDOWS__ // Use Windows GetWindowTextLength() function to avoid line ending conversion incompletely imposed by wxWidgets. WXHWND hWnd = m_composed->GetHWND(); - std::vector src((std::vector::size_type)::GetWindowTextLengthW(hWnd) + 1); + size_t len = ::GetWindowTextLengthW(hWnd); + std::vector src(len + 1); ::GetWindowTextW(hWnd, src.data(), src.size()); #else wxString src(m_composed->GetValue()); + size_t len = src.Length(); #endif ZRColaApp *app = (ZRColaApp*)wxTheApp; std::wstring dst; wxZRColaFrame *mainWnd = dynamic_cast(wxGetActiveWindow()); if (mainWnd) - app->m_t_db.Decompose(src.data(), src.size(), &app->m_lc_db, mainWnd->m_lang, dst, &m_mapping2); + app->m_t_db.Decompose(src.data(), len, &app->m_lc_db, mainWnd->m_lang, dst, &m_mapping2); else - app->m_t_db.Decompose(src.data(), src.size(), dst, &m_mapping2); + app->m_t_db.Decompose(src.data(), len, dst, &m_mapping2); m_mapping1.clear(); m_mapping2.invert(); @@ -188,10 +244,22 @@ void wxZRColaComposerPanel::OnComposedText(wxCommandEvent& event) long from, to; m_composed->GetSelection(&from, &to); + // Update composed HEX dump. + wxString hex; + GetHex(hex, m_mappingComposedHex, src.data(), len); + m_composedHex->SetValue(hex); + m_composedHex->SetSelection(m_mappingComposedHex.to_dst(from), m_mappingComposedHex.to_dst(to)); + // Update decomposed text. m_progress = true; m_decomposed->SetValue(dst); - m_decomposed->SetSelection(m_mapping1.to_src(m_mapping2.to_src(from)), m_mapping1.to_src(m_mapping2.to_src(to))); + m_decomposed->SetSelection(from = m_mapping1.to_src(m_mapping2.to_src(from)), to = m_mapping1.to_src(m_mapping2.to_src(to))); + + // Update decomposed HEX dump. + GetHex(hex, m_mappingDecomposedHex, dst.data(), dst.length()); + m_decomposedHex->SetValue(hex); + m_decomposedHex->SetSelection(m_mappingDecomposedHex.to_dst(from), m_mappingDecomposedHex.to_dst(to)); + event.Skip(); m_progress = false; @@ -211,15 +279,15 @@ void wxZRColaComposerPanel::OnTimerTimeout(wxTimerEvent& event) #ifdef __WINDOWS__ // Use Windows GetWindowText() function to avoid line ending conversion incompletely imposed by wxWidgets. WXHWND hWnd = m_decomposed->GetHWND(); - std::vector text((std::vector::size_type)::GetWindowTextLengthW(hWnd) + 1); + unsigned __int64 len = ::GetWindowTextLengthW(hWnd); + std::vector text(len + 1); ::GetWindowTextW(hWnd, text.data(), text.size()); - unsigned __int64 n = text.size() - 1; #else wxString text(m_decomposed->GetValue()); - unsigned __int64 n = text.size(); + unsigned __int64 len = text.Length(); #endif - file.Write(&n, sizeof(n)); - file.Write(text.data(), sizeof(wchar_t)*n); + file.Write(&len, sizeof(len)); + file.Write(text.data(), sizeof(wchar_t)*len); } // Save composed text. @@ -227,15 +295,15 @@ void wxZRColaComposerPanel::OnTimerTimeout(wxTimerEvent& event) #ifdef __WINDOWS__ // Use Windows GetWindowText() function to avoid line ending conversion incompletely imposed by wxWidgets. WXHWND hWnd = m_composed->GetHWND(); - std::vector text((std::vector::size_type)::GetWindowTextLengthW(hWnd) + 1); + unsigned __int64 len = ::GetWindowTextLengthW(hWnd); + std::vector text(len + 1); ::GetWindowTextW(hWnd, text.data(), text.size()); - unsigned __int64 n = text.size() - 1; #else wxString text(m_composed->GetValue()); - unsigned __int64 n = text.size(); + unsigned __int64 len = text.Length(); #endif - file.Write(&n, sizeof(n)); - file.Write(text.data(), sizeof(wchar_t)*n); + file.Write(&len, sizeof(len)); + file.Write(text.data(), sizeof(wchar_t)*len); } } @@ -243,7 +311,7 @@ void wxZRColaComposerPanel::OnTimerTimeout(wxTimerEvent& event) } -wxString wxZRColaComposerPanel::GetStateFileName() const +wxString wxZRColaComposerPanel::GetStateFileName() { wxString path; @@ -261,6 +329,25 @@ wxString wxZRColaComposerPanel::GetStateFileName() const } +void wxZRColaComposerPanel::GetHex(wxString &hex, ZRCola::mapping_vector &mapping, const wchar_t *src, size_t len) +{ + bool first = true; + hex.clear(); + mapping.clear(); + for (size_t i = 0; i < len && src[i]; i++) { + wchar_t c = src[i]; + if (c == L'\n' || c == '\r') { + hex += c; + first = true; + } else { + hex += wxString::Format(first ? wxT("%04X") : wxT(" %04X"), src[i]); + mapping.push_back(ZRCola::mapping(i + 1, hex.Length())); + first = false; + } + } +} + + ////////////////////////////////////////////////////////////////////////// // wxPersistentZRColaComposerPanel ////////////////////////////////////////////////////////////////////////// @@ -279,6 +366,9 @@ wxString wxPersistentZRColaComposerPanel::GetKind() const void wxPersistentZRColaComposerPanel::Save() const { const wxZRColaComposerPanel * const wnd = static_cast(GetWindow()); + + SaveValue(wxT("splitDecomposed"), wnd->m_splitterDecomposed->GetSashPosition()); + SaveValue(wxT("splitComposed" ), wnd->m_splitterComposed ->GetSashPosition()); } @@ -286,5 +376,19 @@ bool wxPersistentZRColaComposerPanel::Restore() { wxZRColaComposerPanel * const wnd = static_cast(GetWindow()); + int sashVal; + + if (RestoreValue(wxT("splitDecomposed"), &sashVal)) { + // wxFormBuilder sets initial splitter stash in idle event handler after GUI settles. Overriding our loaded value. Disconnect it's idle event handler. + wnd->m_splitterDecomposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDecomposedOnIdle ), NULL, wnd ); + wnd->m_splitterDecomposed->SetSashPosition(sashVal); + } + + if (RestoreValue(wxT("splitComposed"), &sashVal)) { + // wxFormBuilder sets initial splitter stash in idle event handler after GUI settles. Overriding our loaded value. Disconnect it's idle event handler. + wnd->m_splitterComposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterComposedOnIdle ), NULL, wnd ); + wnd->m_splitterComposed->SetSashPosition(sashVal); + } + return true; } diff --git a/ZRCola/zrcolacomppnl.h b/ZRCola/zrcolacomppnl.h index 8912d58..12fd3ce 100644 --- a/ZRCola/zrcolacomppnl.h +++ b/ZRCola/zrcolacomppnl.h @@ -51,23 +51,30 @@ public: protected: virtual void OnDecomposedPaint(wxPaintEvent& event); + virtual void OnDecomposedHexPaint(wxPaintEvent& event); virtual void OnDecomposedText(wxCommandEvent& event); virtual void OnComposedPaint(wxPaintEvent& event); + virtual void OnComposedHexPaint(wxPaintEvent& event); virtual void OnComposedText(wxCommandEvent& event); virtual void OnTimerTimeout(wxTimerEvent& event); DECLARE_EVENT_TABLE() - wxString GetStateFileName() const; + static wxString GetStateFileName(); + static void GetHex(wxString &hex, ZRCola::mapping_vector &mapping, const wchar_t *src, size_t len); protected: - bool m_progress; ///< Boolean flag to avoid recursive updates of composed and decomposed text controls - ZRCola::mapping_vector m_mapping1; ///< Character index mapping vector between decomposed and normalized text - ZRCola::mapping_vector m_mapping2; ///< Character index mapping vector between normalized and composed text + bool m_progress; ///< Boolean flag to avoid recursive updates of composed and decomposed text controls + ZRCola::mapping_vector m_mapping1; ///< Character index mapping vector between decomposed and normalized text + ZRCola::mapping_vector m_mapping2; ///< Character index mapping vector between normalized and composed text std::pair - m_selDecomposed, ///< Character index of selected text in decomposed text control - m_selComposed; ///< Character index of selected text in composed text control - wxZRColaKeyHandler m_keyhandler; ///< Key handler for decomposed window - wxTimer *m_timer; ///< Timer to trigger the state save + m_selDecomposed, ///< Character index of selected text in decomposed text control + m_selDecomposedHex, ///< Character index of selected text in decomposed HEX dump text control + m_selComposed, ///< Character index of selected text in composed text control + m_selComposedHex; ///< Character index of selected text in composed HEX dump text control + wxZRColaKeyHandler m_keyhandler; ///< Key handler for decomposed window + wxTimer *m_timer; ///< Timer to trigger the state save + ZRCola::mapping_vector m_mappingDecomposedHex; ///< Character index mapping vector between decomposed text and its HEX dump + ZRCola::mapping_vector m_mappingComposedHex; ///< Character index mapping vector between composed text and its HEX dump }; diff --git a/ZRCola/zrcolafrm.cpp b/ZRCola/zrcolafrm.cpp index f9aa5a8..d689b0a 100644 --- a/ZRCola/zrcolafrm.cpp +++ b/ZRCola/zrcolafrm.cpp @@ -76,9 +76,6 @@ wxZRColaFrame::wxZRColaFrame() : // Set focus. m_panel->m_decomposed->SetFocus(); - // Arrange composer panel persistence. - wxPersistentRegisterAndRestore(m_panel); - // Register global hotkey(s). if (!RegisterHotKey(wxZRColaHKID_INVOKE_COMPOSE, wxMOD_WIN, VK_F5)) wxMessageBox(_("ZRCola keyboard shortcut Win+F5 could not be registered. Some functionality will not be available."), _("Warning"), wxOK | wxICON_WARNING); @@ -303,6 +300,7 @@ void wxPersistentZRColaFrame::Save() const { const wxZRColaFrame * const wnd = static_cast(GetWindow()); + wxPersistentZRColaComposerPanel(wnd->m_panel).Save(); SaveValue(wxT("lang"), wxString::FromAscii(wnd->m_lang, sizeof(wnd->m_lang))); wxPersistentTLW::Save(); } @@ -335,5 +333,7 @@ bool wxPersistentZRColaFrame::Restore() } } + wxPersistentZRColaComposerPanel(wnd->m_panel).Restore(); + return r; } diff --git a/ZRCola/zrcolagui.cpp b/ZRCola/zrcolagui.cpp index 394497a..d19b575 100644 --- a/ZRCola/zrcolagui.cpp +++ b/ZRCola/zrcolagui.cpp @@ -162,31 +162,91 @@ wxZRColaFrameBase::~wxZRColaFrameBase() wxZRColaComposerPanelBase::wxZRColaComposerPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) { - wxBoxSizer* bSizerEditor; - bSizerEditor = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizerMain; + bSizerMain = new wxBoxSizer( wxVERTICAL ); - m_decomposed = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE|wxTE_MULTILINE ); + m_splitterDecomposed = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE ); + m_splitterDecomposed->SetSashGravity( 1 ); + m_splitterDecomposed->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDecomposedOnIdle ), NULL, this ); + m_splitterDecomposed->SetMinimumPaneSize( 5 ); + + m_panelDecomposedEdit = new wxPanel( m_splitterDecomposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerDecomposedEdit; + bSizerDecomposedEdit = new wxBoxSizer( wxVERTICAL ); + + m_decomposed = new wxTextCtrl( m_panelDecomposedEdit, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); m_decomposed->SetFont( wxFont( 20, 70, 90, 90, false, wxT("00 ZRCola") ) ); m_decomposed->SetMinSize( wxSize( 100,25 ) ); - bSizerEditor->Add( m_decomposed, 50, wxALL|wxEXPAND, 5 ); + bSizerDecomposedEdit->Add( m_decomposed, 50, wxALL|wxEXPAND, 5 ); - m_composed = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE|wxTE_MULTILINE ); + + m_panelDecomposedEdit->SetSizer( bSizerDecomposedEdit ); + m_panelDecomposedEdit->Layout(); + bSizerDecomposedEdit->Fit( m_panelDecomposedEdit ); + m_panelDecomposedHex = new wxPanel( m_splitterDecomposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerDecomposedHex; + bSizerDecomposedHex = new wxBoxSizer( wxVERTICAL ); + + m_decomposedHex = new wxTextCtrl( m_panelDecomposedHex, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); + m_decomposedHex->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) ); + + bSizerDecomposedHex->Add( m_decomposedHex, 50, wxALL|wxEXPAND, 5 ); + + + m_panelDecomposedHex->SetSizer( bSizerDecomposedHex ); + m_panelDecomposedHex->Layout(); + bSizerDecomposedHex->Fit( m_panelDecomposedHex ); + m_splitterDecomposed->SplitVertically( m_panelDecomposedEdit, m_panelDecomposedHex, -5 ); + bSizerMain->Add( m_splitterDecomposed, 50, wxALL|wxEXPAND, 5 ); + + m_splitterComposed = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE ); + m_splitterComposed->SetSashGravity( 1 ); + m_splitterComposed->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterComposedOnIdle ), NULL, this ); + m_splitterComposed->SetMinimumPaneSize( 5 ); + + m_panelComposedEdit = new wxPanel( m_splitterComposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerComposedEdit; + bSizerComposedEdit = new wxBoxSizer( wxVERTICAL ); + + m_composed = new wxTextCtrl( m_panelComposedEdit, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); m_composed->SetFont( wxFont( 20, 70, 90, 90, false, wxT("00 ZRCola") ) ); m_composed->SetMinSize( wxSize( 100,25 ) ); - bSizerEditor->Add( m_composed, 50, wxALL|wxEXPAND, 5 ); + bSizerComposedEdit->Add( m_composed, 50, wxALL|wxEXPAND, 5 ); - this->SetSizer( bSizerEditor ); + m_panelComposedEdit->SetSizer( bSizerComposedEdit ); + m_panelComposedEdit->Layout(); + bSizerComposedEdit->Fit( m_panelComposedEdit ); + m_panelComposedHex = new wxPanel( m_splitterComposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizerComposedHex; + bSizerComposedHex = new wxBoxSizer( wxVERTICAL ); + + m_composedHex = new wxTextCtrl( m_panelComposedHex, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); + m_composedHex->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) ); + + bSizerComposedHex->Add( m_composedHex, 50, wxALL|wxEXPAND, 5 ); + + + m_panelComposedHex->SetSizer( bSizerComposedHex ); + m_panelComposedHex->Layout(); + bSizerComposedHex->Fit( m_panelComposedHex ); + m_splitterComposed->SplitVertically( m_panelComposedEdit, m_panelComposedHex, -5 ); + bSizerMain->Add( m_splitterComposed, 50, wxALL|wxEXPAND, 5 ); + + + this->SetSizer( bSizerMain ); this->Layout(); - bSizerEditor->Fit( this ); + bSizerMain->Fit( this ); // Connect Events m_decomposed->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedPaint ), NULL, this ); m_decomposed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDecomposedText ), NULL, this ); + m_decomposedHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedHexPaint ), NULL, this ); m_composed->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedPaint ), NULL, this ); m_composed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this ); + m_composedHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this ); } wxZRColaComposerPanelBase::~wxZRColaComposerPanelBase() @@ -194,7 +254,9 @@ wxZRColaComposerPanelBase::~wxZRColaComposerPanelBase() // Disconnect Events m_decomposed->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedPaint ), NULL, this ); m_decomposed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDecomposedText ), NULL, this ); + m_decomposedHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedHexPaint ), NULL, this ); m_composed->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedPaint ), NULL, this ); m_composed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this ); + m_composedHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this ); } diff --git a/ZRCola/zrcolagui.h b/ZRCola/zrcolagui.h index 7523308..343cb18 100644 --- a/ZRCola/zrcolagui.h +++ b/ZRCola/zrcolagui.h @@ -30,6 +30,7 @@ #include #include #include +#include /////////////////////////////////////////////////////////////////////////// @@ -84,20 +85,42 @@ class wxZRColaComposerPanelBase : public wxPanel private: protected: + wxSplitterWindow* m_splitterDecomposed; + wxPanel* m_panelDecomposedEdit; wxTextCtrl* m_decomposed; + wxPanel* m_panelDecomposedHex; + wxTextCtrl* m_decomposedHex; + wxSplitterWindow* m_splitterComposed; + wxPanel* m_panelComposedEdit; wxTextCtrl* m_composed; + wxPanel* m_panelComposedHex; + wxTextCtrl* m_composedHex; // Virtual event handlers, overide them in your derived class virtual void OnDecomposedPaint( wxPaintEvent& event ) { event.Skip(); } virtual void OnDecomposedText( wxCommandEvent& event ) { event.Skip(); } + virtual void OnDecomposedHexPaint( wxPaintEvent& event ) { event.Skip(); } virtual void OnComposedPaint( wxPaintEvent& event ) { event.Skip(); } virtual void OnComposedText( wxCommandEvent& event ) { event.Skip(); } + virtual void OnComposedHexPaint( wxPaintEvent& event ) { event.Skip(); } public: wxZRColaComposerPanelBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxT("ZRColaComposerPanel") ); ~wxZRColaComposerPanelBase(); + + void m_splitterDecomposedOnIdle( wxIdleEvent& ) + { + m_splitterDecomposed->SetSashPosition( -5 ); + m_splitterDecomposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDecomposedOnIdle ), NULL, this ); + } + + void m_splitterComposedOnIdle( wxIdleEvent& ) + { + m_splitterComposed->SetSashPosition( -5 ); + m_splitterComposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterComposedOnIdle ), NULL, this ); + } };