]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/widgets.cpp
Use wxWindowUpdateLocker to speed up updates of the static widgets sample page.
[wxWidgets.git] / samples / widgets / widgets.cpp
index c858d3f75355e2bb40992ed3ab7689369a46ea5f..7e54947dbd3e5741d79adec7feb9e9c03e079cff 100644 (file)
@@ -99,6 +99,7 @@ enum
     TextEntry_DisableAutoComplete = TextEntry_Begin,
     TextEntry_AutoCompleteFixed,
     TextEntry_AutoCompleteFilenames,
     TextEntry_DisableAutoComplete = TextEntry_Begin,
     TextEntry_AutoCompleteFixed,
     TextEntry_AutoCompleteFilenames,
+    TextEntry_AutoCompleteDirectories,
     TextEntry_AutoCompleteCustom,
 
     TextEntry_SetHint,
     TextEntry_AutoCompleteCustom,
 
     TextEntry_SetHint,
@@ -174,6 +175,7 @@ protected:
     void OnDisableAutoComplete(wxCommandEvent& event);
     void OnAutoCompleteFixed(wxCommandEvent& event);
     void OnAutoCompleteFilenames(wxCommandEvent& event);
     void OnDisableAutoComplete(wxCommandEvent& event);
     void OnAutoCompleteFixed(wxCommandEvent& event);
     void OnAutoCompleteFilenames(wxCommandEvent& event);
+    void OnAutoCompleteDirectories(wxCommandEvent& event);
     void OnAutoCompleteCustom(wxCommandEvent& event);
 
     void OnSetHint(wxCommandEvent& event);
     void OnAutoCompleteCustom(wxCommandEvent& event);
 
     void OnSetHint(wxCommandEvent& event);
@@ -303,6 +305,7 @@ BEGIN_EVENT_TABLE(WidgetsFrame, wxFrame)
     EVT_MENU(TextEntry_DisableAutoComplete,   WidgetsFrame::OnDisableAutoComplete)
     EVT_MENU(TextEntry_AutoCompleteFixed,     WidgetsFrame::OnAutoCompleteFixed)
     EVT_MENU(TextEntry_AutoCompleteFilenames, WidgetsFrame::OnAutoCompleteFilenames)
     EVT_MENU(TextEntry_DisableAutoComplete,   WidgetsFrame::OnDisableAutoComplete)
     EVT_MENU(TextEntry_AutoCompleteFixed,     WidgetsFrame::OnAutoCompleteFixed)
     EVT_MENU(TextEntry_AutoCompleteFilenames, WidgetsFrame::OnAutoCompleteFilenames)
+    EVT_MENU(TextEntry_AutoCompleteDirectories, WidgetsFrame::OnAutoCompleteDirectories)
     EVT_MENU(TextEntry_AutoCompleteCustom,    WidgetsFrame::OnAutoCompleteCustom)
 
     EVT_MENU(TextEntry_SetHint, WidgetsFrame::OnSetHint)
     EVT_MENU(TextEntry_AutoCompleteCustom,    WidgetsFrame::OnAutoCompleteCustom)
 
     EVT_MENU(TextEntry_SetHint, WidgetsFrame::OnSetHint)
@@ -418,6 +421,8 @@ WidgetsFrame::WidgetsFrame(const wxString& title)
                                    wxT("Fixed-&list auto-completion"));
     menuTextEntry->AppendRadioItem(TextEntry_AutoCompleteFilenames,
                                    wxT("&Files names auto-completion"));
                                    wxT("Fixed-&list auto-completion"));
     menuTextEntry->AppendRadioItem(TextEntry_AutoCompleteFilenames,
                                    wxT("&Files names auto-completion"));
+    menuTextEntry->AppendRadioItem(TextEntry_AutoCompleteDirectories,
+                                   wxT("&Directories names auto-completion"));
     menuTextEntry->AppendRadioItem(TextEntry_AutoCompleteCustom,
                                    wxT("&Custom auto-completion"));
     menuTextEntry->AppendSeparator();
     menuTextEntry->AppendRadioItem(TextEntry_AutoCompleteCustom,
                                    wxT("&Custom auto-completion"));
     menuTextEntry->AppendSeparator();
@@ -800,11 +805,11 @@ void WidgetsFrame::OnSetFgCol(wxCommandEvent& WXUNUSED(event))
     // allow for debugging the default colour the first time this is called
     WidgetsPage *page = CurrentPage();
 
     // allow for debugging the default colour the first time this is called
     WidgetsPage *page = CurrentPage();
 
-    if (!m_colFg.Ok())
+    if (!m_colFg.IsOk())
         m_colFg = page->GetForegroundColour();
 
     wxColour col = GetColourFromUser(this, m_colFg);
         m_colFg = page->GetForegroundColour();
 
     wxColour col = GetColourFromUser(this, m_colFg);
-    if ( !col.Ok() )
+    if ( !col.IsOk() )
         return;
 
     m_colFg = col;
         return;
 
     m_colFg = col;
@@ -823,11 +828,11 @@ void WidgetsFrame::OnSetBgCol(wxCommandEvent& WXUNUSED(event))
 {
     WidgetsPage *page = CurrentPage();
 
 {
     WidgetsPage *page = CurrentPage();
 
-    if ( !m_colBg.Ok() )
+    if ( !m_colBg.IsOk() )
         m_colBg = page->GetBackgroundColour();
 
     wxColour col = GetColourFromUser(this, m_colBg);
         m_colBg = page->GetBackgroundColour();
 
     wxColour col = GetColourFromUser(this, m_colBg);
-    if ( !col.Ok() )
+    if ( !col.IsOk() )
         return;
 
     m_colBg = col;
         return;
 
     m_colBg = col;
@@ -845,7 +850,7 @@ void WidgetsFrame::OnSetBgCol(wxCommandEvent& WXUNUSED(event))
 void WidgetsFrame::OnSetPageBg(wxCommandEvent& WXUNUSED(event))
 {
     wxColour col = GetColourFromUser(this, GetBackgroundColour());
 void WidgetsFrame::OnSetPageBg(wxCommandEvent& WXUNUSED(event))
 {
     wxColour col = GetColourFromUser(this, GetBackgroundColour());
-    if ( !col.Ok() )
+    if ( !col.IsOk() )
         return;
 
     CurrentPage()->SetBackgroundColour(col);
         return;
 
     CurrentPage()->SetBackgroundColour(col);
@@ -857,11 +862,11 @@ void WidgetsFrame::OnSetFont(wxCommandEvent& WXUNUSED(event))
 #if wxUSE_FONTDLG
     WidgetsPage *page = CurrentPage();
 
 #if wxUSE_FONTDLG
     WidgetsPage *page = CurrentPage();
 
-    if (!m_font.Ok())
+    if (!m_font.IsOk())
         m_font = page->GetFont();
 
     wxFont font = wxGetFontFromUser(this, m_font);
         m_font = page->GetFont();
 
     wxFont font = wxGetFontFromUser(this, m_font);
-    if ( !font.Ok() )
+    if ( !font.IsOk() )
         return;
 
     m_font = font;
         return;
 
     m_font = font;
@@ -995,6 +1000,21 @@ void WidgetsFrame::OnAutoCompleteFilenames(wxCommandEvent& WXUNUSED(event))
     }
 }
 
     }
 }
 
+void WidgetsFrame::OnAutoCompleteDirectories(wxCommandEvent& WXUNUSED(event))
+{
+    wxTextEntryBase *entry = CurrentPage()->GetTextEntry();
+    wxCHECK_RET( entry, "menu item should be disabled" );
+
+    if ( entry->AutoCompleteDirectories() )
+    {
+        wxLogMessage("Enabled auto completion of directories.");
+    }
+    else
+    {
+        wxLogMessage("AutoCompleteDirectories() failed.");
+    }
+}
+
 void WidgetsFrame::OnAutoCompleteCustom(wxCommandEvent& WXUNUSED(event))
 {
     wxTextEntryBase *entry = CurrentPage()->GetTextEntry();
 void WidgetsFrame::OnAutoCompleteCustom(wxCommandEvent& WXUNUSED(event))
 {
     wxTextEntryBase *entry = CurrentPage()->GetTextEntry();