Permalink
Browse files

Added missing files

  • Loading branch information...
1 parent 30bf408 commit 7aba02a2498012271bd09d47fec5a8b59ecdb05a Alexander Stigsen committed Oct 13, 2010
Showing with 112 additions and 0 deletions.
  1. +62 −0 src/InputPanel.cpp
  2. +50 −0 src/InputPanel.h
View
@@ -0,0 +1,62 @@
+#include "InputPanel.h"
+#include "CloseButton.h"
+#include "EditorFrame.h"
+#include "EditorCtrl.h"
+
+// Ctrl id's
+enum {
+ INPUTP_CLOSE = 100,
+ INPUTP_BOX,
+};
+
+BEGIN_EVENT_TABLE(InputPanel, wxPanel)
+ EVT_BUTTON(INPUTP_CLOSE, InputPanel::OnCloseButton)
+END_EVENT_TABLE()
+
+InputPanel::InputPanel(EditorFrame& parentFrame, wxWindow* parent)
+: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxCLIP_CHILDREN|wxNO_BORDER|wxNO_FULL_REPAINT_ON_RESIZE),
+ m_parentFrame(parentFrame) {
+ // Create the controls
+ CloseButton* closeButton = new CloseButton(this, INPUTP_CLOSE);
+ m_caption = new wxStaticText(this, wxID_ANY, _("Input: "));
+ m_inputbox = new wxTextCtrl(this, INPUTP_BOX, wxEmptyString, wxDefaultPosition, wxDefaultSize);
+
+ m_inputbox->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(InputPanel::OnInputChanged), NULL, this);
+ m_inputbox->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(InputPanel::OnInputEnter), NULL, this);
+
+ // Create the sizer layout
+ wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
+ sizer->AddSpacer(5);
+ sizer->Add(closeButton, 0, wxALIGN_CENTER|wxRIGHT, 2);
+ sizer->Add(m_caption, 0, wxALIGN_CENTER);
+ sizer->Add(m_inputbox, 3, wxALIGN_CENTER|wxEXPAND|wxTOP|wxBOTTOM, 2);
+ sizer->AddSpacer(5);
+
+ SetSizer(sizer);
+
+ // Set the correct size
+ const wxSize minsize = sizer->GetMinSize();
+ SetSize(minsize);
+
+ // Make sure sizes get the right min/max sizes
+ SetSizeHints(minsize.x, minsize.y, -1, minsize.y);
+}
+
+void InputPanel::Set(unsigned int notifier_id, const wxString& cmd) {
+ m_notifier_id = notifier_id;
+ m_caption->SetLabel(cmd);
+ m_inputbox->Clear();
+}
+
+void InputPanel::OnInputChanged(wxCommandEvent& evt) {
+ m_parentFrame.OnInputPanelChanged(m_notifier_id, evt.GetString());
+ evt.Skip();
+}
+
+void InputPanel::OnInputEnter(wxCommandEvent& WXUNUSED(evt)) {
+ m_parentFrame.HideInputPanel();
+}
+
+void InputPanel::OnCloseButton(wxCommandEvent& WXUNUSED(evt)) {
+ m_parentFrame.HideInputPanel();
+}
View
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ *
+ * Copyright (C) 2009, Alexander Stigsen, e-texteditor.com
+ *
+ * This software is licensed under the Open Company License as described
+ * in the file license.txt, which you should have received as part of this
+ * distribution. The terms are also available at http://opencompany.org/license.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ******************************************************************************/
+
+#ifndef __INPUTPANEL_H__
+#define __INPUTPANEL_H__
+
+#include "wx/wxprec.h"
+#ifndef WX_PRECOMP
+#include <wx/panel.h>
+#include <wx/string.h>
+#endif
+
+// pre-definitions
+class EditorFrame;
+
+class InputPanel : public wxPanel {
+public:
+ InputPanel(EditorFrame& parentFrame, wxWindow* parent);
+ ~InputPanel() {};
+
+ void Set(unsigned int notifier_id, const wxString& cmd);
+ unsigned int GetNotifierId() const {return m_notifier_id;};
+
+private:
+ // Event handlers
+ void OnCloseButton(wxCommandEvent& evt);
+ void OnInputChanged(wxCommandEvent& evt);
+ void OnInputEnter(wxCommandEvent& evt);
+ DECLARE_EVENT_TABLE();
+
+ // Member Ctrls
+ wxTextCtrl* m_inputbox;
+ wxStaticText* m_caption;
+
+ // Member variables
+ EditorFrame& m_parentFrame;
+ unsigned int m_notifier_id;
+};
+
+#endif //__INPUTPANEL_H

0 comments on commit 7aba02a

Please sign in to comment.