lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] [PATCH 1/2] Make InputSequenceEntry friendly to embedding in wxDVC


From: Vaclav Slavik
Subject: [lmi] [PATCH 1/2] Make InputSequenceEntry friendly to embedding in wxDVC.
Date: Wed, 29 Jun 2011 18:34:19 +0200
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9

Hi,

this patch makes the InputSequenceEntry composite control behave more like a 
"normal" control with regard to focus changes and input events. wxDataViewCtrl 
wants to intercept these events so that it knows when to close an inline editor 
control and this change makes it handle InputSequenceEntry correctly.

Regards,
Vaclav

---
 input_sequence_entry.cpp |   82 ++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 72 insertions(+), 10 deletions(-)

diff --git a/input_sequence_entry.cpp b/input_sequence_entry.cpp
index 14edca9..b42003f 100644
--- a/input_sequence_entry.cpp
+++ b/input_sequence_entry.cpp
@@ -1002,6 +1002,76 @@ void InputSequenceEditor::UponAddRow(wxCommandEvent& 
event)
 
     duration_num_field(new_row).SetFocus();
 }
+
+class InputSequenceTextCtrl
+    :public wxTextCtrl
+{
+  public:
+    InputSequenceTextCtrl(wxWindow* parent, wxWindowID id);
+
+  private:
+    void UponKillFocus(wxFocusEvent& event);
+    void UponChar(wxKeyEvent& event);
+};
+
+InputSequenceTextCtrl::InputSequenceTextCtrl(wxWindow* parent, wxWindowID id)
+    :wxTextCtrl(parent, id)
+{
+    ::Connect
+            (this
+            ,wxEVT_KILL_FOCUS
+            ,&InputSequenceTextCtrl::UponKillFocus
+            );
+    ::Connect
+            (this
+            ,wxEVT_CHAR
+            ,&InputSequenceTextCtrl::UponChar
+            );
+}
+
+void InputSequenceTextCtrl::UponKillFocus(wxFocusEvent& event)
+{
+    if(0 == event.GetWindow() || event.GetWindow()->GetParent() != GetParent())
+        GetParent()->ProcessWindowEvent(event);
+    event.Skip();
+}
+
+void InputSequenceTextCtrl::UponChar(wxKeyEvent& event)
+{
+    if(!GetParent()->ProcessWindowEvent(event))
+        event.Skip();
+}
+
+
+class InputSequenceButton
+    :public wxButton
+{
+  public:
+    InputSequenceButton(wxWindow* parent, wxWindowID id);
+
+  private:
+    void UponKillFocus(wxFocusEvent& event);
+};
+
+InputSequenceButton::InputSequenceButton(wxWindow* parent, wxWindowID id)
+    :wxButton(parent, id, "...", wxDefaultPosition, wxDefaultSize, 
wxBU_EXACTFIT)
+{
+    ::Connect
+            (this
+            ,wxEVT_KILL_FOCUS
+            ,&InputSequenceButton::UponKillFocus
+            );
+
+    SetToolTip("Open sequence editor");
+}
+
+void InputSequenceButton::UponKillFocus(wxFocusEvent& event)
+{
+    if(0 == event.GetWindow() || event.GetWindow()->GetParent() != GetParent())
+        GetParent()->ProcessWindowEvent(event);
+    event.Skip();
+}
+
 } // Unnamed namespace.
 
 InputSequenceEntry::InputSequenceEntry()
@@ -1034,16 +1104,8 @@ bool InputSequenceEntry::Create
 
     wxSizer* sizer = new(wx) wxBoxSizer(wxHORIZONTAL);
 
-    text_ = new(wx) wxTextCtrl(this, wxID_ANY);
-    button_ = new(wx) wxButton
-        (this
-        ,wxID_ANY
-        ,"..."
-        ,wxDefaultPosition
-        ,wxDefaultSize
-        ,wxBU_EXACTFIT
-        );
-    button_->SetToolTip("Open sequence editor");
+    text_ = new(wx) InputSequenceTextCtrl(this, wxID_ANY);
+    button_ = new(wx) InputSequenceButton(this, wxID_ANY);
 
     sizer->Add(text_, wxSizerFlags(1).Expand());
     sizer->Add(button_, wxSizerFlags().Expand().Border(wxLEFT, 1));
-- 
1.7.5.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]