#include "wx/tooltip.h"
#endif
-#if defined(__WXGTK__) || defined(__WXMOTIF__)
- #include "mondrian.xpm"
-#endif
-
// We test for wxUSE_DRAG_AND_DROP also, because data objects may not be
// implemented for compilers that can't cope with the OLE parts in
// wxUSE_DRAG_AND_DROP.
public:
MyTextCtrl(wxWindow *parent, wxWindowID id, const wxString &value,
const wxPoint &pos, const wxSize &size, int style = 0)
- : wxTextCtrl(parent, id, value, pos, size, style) { }
+ : wxTextCtrl(parent, id, value, pos, size, style) { m_hasCapture = FALSE; }
void OnKeyDown(wxKeyEvent& event);
void OnKeyUp(wxKeyEvent& event);
void OnChar(wxKeyEvent& event);
+ bool m_hasCapture;
+
private:
static inline wxChar GetChar(bool on, wxChar c) { return on ? c : _T('-'); }
void LogEvent(const wxChar *name, wxKeyEvent& event) const;
void OnMoveToEndOfEntry( wxCommandEvent &event )
{ m_panel->DoMoveToEndOfEntry(); }
+ void OnLogClear(wxCommandEvent& event);
void OnFileLoad(wxCommandEvent& event);
void OnIdle( wxIdleEvent& event );
TEXT_QUIT = 100,
TEXT_ABOUT,
TEXT_LOAD,
+ TEXT_CLEAR,
// clipboard menu
TEXT_CLIPBOARD_COPY = 200,
{
// Create the main frame window
MyFrame *frame = new MyFrame((wxFrame *) NULL,
- "Text wxWindows App",
- 50, 50, 640, 420);
+ "Text wxWindows sample", 50, 50, 640, 420);
frame->SetSizeHints( 500, 400 );
wxMenu *file_menu = new wxMenu;
+ file_menu->Append(TEXT_CLEAR, "&Clear the log\tCtrl-C",
+ "Clear the log window contents");
file_menu->Append(TEXT_LOAD, "&Load file\tCtrl-O",
"Load the sample file into text control");
file_menu->AppendSeparator();
{
LogEvent( _T("Char"), event);
+/* How are we supposed to test wxTE_PROCESS_TAB with this code?
+
if ( event.KeyCode() == WXK_TAB )
{
WriteText("\t");
{
event.Skip();
}
+*/
+ event.Skip();
}
void MyTextCtrl::OnKeyUp(wxKeyEvent& event)
// go to position 10
SetInsertionPoint(10);
break;
+
+ case WXK_F4:
+ if (!m_hasCapture)
+ {
+ wxLogDebug( wxT("Now capturing mouse and events.") );
+ m_hasCapture = TRUE;
+ CaptureMouse();
+ }
+ else
+ {
+ wxLogDebug( wxT("Stopped capturing mouse and events.") );
+ m_hasCapture = TRUE;
+ ReleaseMouse();
+ }
+ break;
}
LogEvent( _("Key down"), event);
m_horizontal = new MyTextCtrl( this, -1, "Multiline text control with a horizontal scrollbar.",
wxPoint(10,170), wxSize(140,70), wxTE_MULTILINE | wxHSCROLL );
- m_horizontal->SetFont(wxFont(18, wxSWISS, wxNORMAL, wxBOLD));
+ m_horizontal->SetFont(wxFont(18, wxSWISS, wxNORMAL, wxNORMAL,
+ FALSE, "", wxFONTENCODING_KOI8));
m_multitext = new MyTextCtrl( this, -1, "Multi line.",
wxPoint(180,10), wxSize(240,70), wxTE_MULTILINE );
m_multitext->WriteText( "Prepended. " );
#if wxUSE_TOOLTIPS
- m_multitext->SetToolTip("Press F1 here.");
+ m_multitext->SetToolTip("Press F1 here for statitics, F4 for capture and uncapture mouse.");
#endif
m_tab = new MyTextCtrl( this, -1, "Multiline, allow <TAB> processing.",
{
*m_log << "Clipboard supports requested format.\n";
- if (wxTheClipboard->GetData( &data ))
+ if (wxTheClipboard->GetData( data ))
{
*m_log << "Successfully retrieved data from the clipboard.\n";
*m_multitext << data.GetText() << "\n";
void MyPanel::DoCopyToClipboard()
{
+ // On X11, we want to get the data from the primary selection instead
+ // of the normal clipboard (which isn't normal under X11 at all). This
+ // call has no effect under MSW.
+ wxTheClipboard->UsePrimarySelection();
+
wxString text( m_multitext->GetLineText(0) );
if (text.IsEmpty())
EVT_MENU(TEXT_QUIT, MyFrame::OnQuit)
EVT_MENU(TEXT_ABOUT, MyFrame::OnAbout)
EVT_MENU(TEXT_LOAD, MyFrame::OnFileLoad)
+ EVT_MENU(TEXT_CLEAR, MyFrame::OnLogClear)
#if wxUSE_TOOLTIPS
EVT_MENU(TEXT_TOOLTIPS_SETDELAY, MyFrame::OnSetTooltipDelay)
void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
{
+ SetSize(40, 40, 200, 200);
+ return;
+
wxBeginBusyCursor();
wxMessageDialog dialog(this,
}
#endif // tooltips
+void MyFrame::OnLogClear(wxCommandEvent& WXUNUSED(event))
+{
+ m_panel->m_log->Clear();
+}
+
void MyFrame::OnFileLoad(wxCommandEvent& event)
{
- if ( m_panel->m_multitext->LoadFile("text.cpp") )
+ if ( m_panel->m_multitext->LoadFile("text.rc") )
wxLogStatus(this, _T("Successfully loaded file"));
else
wxLogStatus(this, _T("Couldn't load the file"));