]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/text/text.cpp
Added SetDefaultXXX methods
[wxWidgets.git] / samples / text / text.cpp
index 6c8c47677a9959a3c58958ff2f48b06bb09c7949..3f699879570429c9dfe41ba9f46f3f88353414ed 100644 (file)
@@ -8,10 +8,6 @@
 // Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-    #pragma implementation "text.cpp"
-#endif
-
 // For compilers that support precompilation, includes "wx/wx.h".
 #include "wx/wxprec.h"
 
@@ -153,47 +149,47 @@ public:
 #endif // wxUSE_TOOLTIPS
 
 #if wxUSE_CLIPBOARD
-    void OnPasteFromClipboard( wxCommandEvent &event )
+    void OnPasteFromClipboard( wxCommandEvent& WXUNUSED(event) )
         { m_panel->DoPasteFromClipboard(); }
-    void OnCopyToClipboard( wxCommandEvent &event )
+    void OnCopyToClipboard( wxCommandEvent& WXUNUSED(event) )
         { m_panel->DoCopyToClipboard(); }
 #endif // wxUSE_CLIPBOARD
 
-    void OnAddTextFreeze( wxCommandEvent& event )
+    void OnAddTextFreeze( wxCommandEvent& WXUNUSED(event) )
         { DoAddText(true); }
-    void OnAddText( wxCommandEvent& event )
+    void OnAddText( wxCommandEvent& WXUNUSED(event) )
         { DoAddText(false); }
-    void OnRemoveText( wxCommandEvent& event )
+    void OnRemoveText( wxCommandEvent& WXUNUSED(event) )
         { m_panel->DoRemoveText(); }
-    void OnReplaceText( wxCommandEvent& event )
+    void OnReplaceText( wxCommandEvent& WXUNUSED(event) )
         { m_panel->DoReplaceText(); }
-    void OnSelectText( wxCommandEvent& event )
+    void OnSelectText( wxCommandEvent& WXUNUSED(event) )
         { m_panel->DoSelectText(); }
 
-    void OnMoveToEndOfText( wxCommandEvent &event )
+    void OnMoveToEndOfText( wxCommandEvent& WXUNUSED(event) )
         { m_panel->DoMoveToEndOfText(); }
-    void OnMoveToEndOfEntry( wxCommandEvent &event )
+    void OnMoveToEndOfEntry( wxCommandEvent& WXUNUSED(event) )
         { m_panel->DoMoveToEndOfEntry(); }
 
-    void OnScrollLineDown(wxCommandEvent& event)
+    void OnScrollLineDown(wxCommandEvent& WXUNUSED(event))
     {
         if ( !m_panel->m_textrich->LineDown() )
             wxLogMessage(_T("Already at the bottom"));
     }
 
-    void OnScrollLineUp(wxCommandEvent& event)
+    void OnScrollLineUp(wxCommandEvent& WXUNUSED(event))
     {
         if ( !m_panel->m_textrich->LineUp() )
             wxLogMessage(_T("Already at the top"));
     }
 
-    void OnScrollPageDown(wxCommandEvent& event)
+    void OnScrollPageDown(wxCommandEvent& WXUNUSED(event))
     {
         if ( !m_panel->m_textrich->PageDown() )
             wxLogMessage(_T("Already at the bottom"));
     }
 
-    void OnScrollPageUp(wxCommandEvent& event)
+    void OnScrollPageUp(wxCommandEvent& WXUNUSED(event))
     {
         if ( !m_panel->m_textrich->PageUp() )
             wxLogMessage(_T("Already at the top"));
@@ -232,7 +228,7 @@ public:
         MyTextCtrl::ms_logFocus = event.IsChecked();
     }
 
-    void OnSetText(wxCommandEvent& event)
+    void OnSetText(wxCommandEvent& WXUNUSED(event))
     {
         m_panel->m_text->SetValue(_T("Hello, world (what else did you expect)?"));
     }
@@ -700,7 +696,7 @@ void MyTextCtrl::OnText(wxCommandEvent& event)
     }
 }
 
-void MyTextCtrl::OnTextMaxLen(wxCommandEvent& event)
+void MyTextCtrl::OnTextMaxLen(wxCommandEvent& WXUNUSED(event))
 {
     wxLogMessage(_T("You can't enter more characters into this control."));
 }
@@ -928,17 +924,13 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
       wxPoint(180,170), wxSize(240,70), wxTE_MULTILINE);
     m_enter->SetClientData((void *)_T("enter"));
 
-#if 0
     m_textrich = new MyTextCtrl(this, -1, _T("Allows more than 30Kb of text\n")
                                 _T("(even under broken Win9x)\n")
                                 _T("and a very very very very very ")
                                 _T("very very very long line to test ")
                                 _T("wxHSCROLL style"),
                                 wxPoint(450, 10), wxSize(230, 230),
-                                wxTE_RICH2 |
-                                wxTE_MULTILINE |
-                                // wxTE_AUTO_URL |
-                                wxHSCROLL);
+                                wxTE_RICH | wxTE_MULTILINE | wxHSCROLL);
     m_textrich->SetStyle(0, 10, *wxRED);
     m_textrich->SetStyle(10, 20, *wxBLUE);
     m_textrich->SetStyle(30, 40,
@@ -953,19 +945,13 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
     m_textrich->SetDefaultStyle(wxTextAttr(*wxBLUE, *wxWHITE));
     m_textrich->AppendText(_T("And this should be in blue and the text you ")
                            _T("type should be in blue as well"));
-#else
-    m_textrich = new MyTextCtrl(this, -1, _T(""),
-                                wxPoint(450, 10), wxSize(230, 230),
-                                wxTE_RICH2 |
-                                wxTE_MULTILINE |
-                                wxHSCROLL);
-#endif
 }
 
 void MyPanel::OnSize( wxSizeEvent &event )
 {
     wxSize client_area( GetClientSize() );
-    m_log->SetSize( 0, 260, client_area.x, client_area.y - 260 );
+    if (m_log)
+      m_log->SetSize( 0, 260, client_area.x, client_area.y - 260 );
     event.Skip();
 }
 
@@ -1174,7 +1160,8 @@ void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
 }
 
 #if wxUSE_TOOLTIPS
-void MyFrame::OnSetTooltipDelay(wxCommandEvent& event)
+
+void MyFrame::OnSetTooltipDelay(wxCommandEvent& WXUNUSED(event))
 {
     static long s_delay = 5000;
 
@@ -1195,7 +1182,7 @@ void MyFrame::OnSetTooltipDelay(wxCommandEvent& event)
     wxLogStatus(this, _T("Tooltip delay set to %ld milliseconds"), s_delay);
 }
 
-void MyFrame::OnToggleTooltips(wxCommandEvent& event)
+void MyFrame::OnToggleTooltips(wxCommandEvent& WXUNUSED(event))
 {
     static bool s_enabled = TRUE;
 
@@ -1236,7 +1223,7 @@ void MyFrame::OnSetEnabled(wxCommandEvent& WXUNUSED(event))
     m_panel->m_textrich->Enable(enabled);
 }
 
-void MyFrame::OnFileSave(wxCommandEvent& event)
+void MyFrame::OnFileSave(wxCommandEvent& WXUNUSED(event))
 {
     if ( m_panel->m_textrich->SaveFile(_T("dummy.txt")) )
     {
@@ -1253,7 +1240,7 @@ void MyFrame::OnFileSave(wxCommandEvent& event)
         wxLogStatus(this, _T("Couldn't save the file"));
 }
 
-void MyFrame::OnFileLoad(wxCommandEvent& event)
+void MyFrame::OnFileLoad(wxCommandEvent& WXUNUSED(event))
 {
     if ( m_panel->m_textrich->LoadFile(_T("dummy.txt")) )
         wxLogStatus(this, _T("Successfully loaded file"));
@@ -1261,7 +1248,7 @@ void MyFrame::OnFileLoad(wxCommandEvent& event)
         wxLogStatus(this, _T("Couldn't load the file"));
 }
 
-void MyFrame::OnRichTextTest(wxCommandEvent& event)
+void MyFrame::OnRichTextTest(wxCommandEvent& WXUNUSED(event))
 {
     RichTextFrame* frame = new RichTextFrame(this, _T("Rich Text Editor"));
     frame->Show(TRUE);
@@ -1371,12 +1358,12 @@ RichTextFrame::RichTextFrame(wxWindow* parent, const wxString& title):
 
 // Event handlers
 
-void RichTextFrame::OnClose(wxCommandEvent& event)
+void RichTextFrame::OnClose(wxCommandEvent& WXUNUSED(event))
 {
     Close(TRUE);
 }
 
-void RichTextFrame::OnLeftAlign(wxCommandEvent& event)
+void RichTextFrame::OnLeftAlign(wxCommandEvent& WXUNUSED(event))
 {
     wxTextAttr attr;
     attr.SetAlignment(wxTEXT_ALIGNMENT_LEFT);
@@ -1388,7 +1375,7 @@ void RichTextFrame::OnLeftAlign(wxCommandEvent& event)
     m_currentPosition = -1;
 }
 
-void RichTextFrame::OnRightAlign(wxCommandEvent& event)
+void RichTextFrame::OnRightAlign(wxCommandEvent& WXUNUSED(event))
 {
     wxTextAttr attr;
     attr.SetAlignment(wxTEXT_ALIGNMENT_RIGHT);
@@ -1400,7 +1387,7 @@ void RichTextFrame::OnRightAlign(wxCommandEvent& event)
     m_currentPosition = -1;
 }
 
-void RichTextFrame::OnJustify(wxCommandEvent& event)
+void RichTextFrame::OnJustify(wxCommandEvent& WXUNUSED(event))
 {
     wxTextAttr attr;
     attr.SetAlignment(wxTEXT_ALIGNMENT_JUSTIFIED);
@@ -1412,7 +1399,7 @@ void RichTextFrame::OnJustify(wxCommandEvent& event)
     m_currentPosition = -1;
 }
 
-void RichTextFrame::OnCentre(wxCommandEvent& event)
+void RichTextFrame::OnCentre(wxCommandEvent& WXUNUSED(event))
 {
     wxTextAttr attr;
     attr.SetAlignment(wxTEXT_ALIGNMENT_CENTRE);
@@ -1424,7 +1411,7 @@ void RichTextFrame::OnCentre(wxCommandEvent& event)
     m_currentPosition = -1;
 }
 
-void RichTextFrame::OnChangeFont(wxCommandEvent& event)
+void RichTextFrame::OnChangeFont(wxCommandEvent& WXUNUSED(event))
 {
     wxFontData data;
 
@@ -1446,7 +1433,7 @@ void RichTextFrame::OnChangeFont(wxCommandEvent& event)
     }
 }
 
-void RichTextFrame::OnChangeTextColour(wxCommandEvent& event)
+void RichTextFrame::OnChangeTextColour(wxCommandEvent& WXUNUSED(event))
 {
     wxColourData data;
     data.SetColour(* wxBLACK);
@@ -1475,7 +1462,7 @@ void RichTextFrame::OnChangeTextColour(wxCommandEvent& event)
     }
 }
 
-void RichTextFrame::OnChangeBackgroundColour(wxCommandEvent& event)
+void RichTextFrame::OnChangeBackgroundColour(wxCommandEvent& WXUNUSED(event))
 {
     wxColourData data;
     data.SetColour(* wxWHITE);
@@ -1504,10 +1491,13 @@ void RichTextFrame::OnChangeBackgroundColour(wxCommandEvent& event)
     }
 }
 
-void RichTextFrame::OnLeftIndent(wxCommandEvent& event)
+void RichTextFrame::OnLeftIndent(wxCommandEvent& WXUNUSED(event))
 {
-    wxString indentStr = wxGetTextFromUser(_("Please enter the left indent in tenths of a millimetre."),
-        _("Left Indent"));
+    wxString indentStr = wxGetTextFromUser
+                         (
+                            _("Please enter the left indent in tenths of a millimetre."),
+                            _("Left Indent")
+                         );
     if (!indentStr.IsEmpty())
     {
         int indent = wxAtoi(indentStr);
@@ -1523,10 +1513,13 @@ void RichTextFrame::OnLeftIndent(wxCommandEvent& event)
     }
 }
 
-void RichTextFrame::OnRightIndent(wxCommandEvent& event)
+void RichTextFrame::OnRightIndent(wxCommandEvent& WXUNUSED(event))
 {
-    wxString indentStr = wxGetTextFromUser(_("Please enter the right indent in tenths of a millimetre."),
-        _("Right Indent"));
+    wxString indentStr = wxGetTextFromUser
+                         (
+                            _("Please enter the right indent in tenths of a millimetre."),
+                            _("Right Indent")
+                         );
     if (!indentStr.IsEmpty())
     {
         int indent = wxAtoi(indentStr);
@@ -1542,7 +1535,7 @@ void RichTextFrame::OnRightIndent(wxCommandEvent& event)
     }
 }
 
-void RichTextFrame::OnIdle(wxIdleEvent& event)
+void RichTextFrame::OnIdle(wxIdleEvent& WXUNUSED(event))
 {
     long insertionPoint = m_textCtrl->GetInsertionPoint();
     if (insertionPoint != m_currentPosition)