]> git.saurik.com Git - wxWidgets.git/commitdiff
moved combobox styles from defs.to to combobox.h; added wxTE/wxCB_FILENAME styles...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 29 Jul 2006 19:19:50 +0000 (19:19 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 29 Jul 2006 19:19:50 +0000 (19:19 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40367 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

17 files changed:
docs/changes.txt
docs/latex/wx/combobox.tex
docs/latex/wx/text.tex
include/wx/combobox.h
include/wx/defs.h
include/wx/msw/wrapshl.h
include/wx/pickerbase.h
include/wx/textctrl.h
samples/widgets/combobox.cpp
samples/widgets/textctrl.cpp
src/common/filepickercmn.cpp
src/common/pickerbase.cpp
src/msw/combobox.cpp
src/msw/textctrl.cpp
src/msw/utilsgui.cpp
src/xrc/xh_combo.cpp
src/xrc/xh_text.cpp

index 68ebeca0f8aa58fc7ec81f0863eb1e3bca5c0797..b76b7c8695334970a521639b9cd70bbddb99c59b 100644 (file)
@@ -97,6 +97,7 @@ All (GUI):
 - Added wxDC::GradientFillLinear/Concentric().
 - Added wxHyperlinkCtrl (Francesco Montorsi).
 - Added clipboard events (wxEVT_COMMAND_TEXT_COPY/CUT/PASTE).
+- Added wxTE_FILENAME and wxCB_FILENAME (MSW-only for now)
 - Allow to reorder wxGrid columns by drag-and-drop (Santiago Palacios).
 - Added wxRadioBox::SetItemToolTip().
 - Added support for CMYK JPEG images loading (Robert Wruck).
index c74acfe298906d271e15d7b0f559f17123a370f0..3272ba83a26cd3cdc876837bb91ec355c45b7ed4 100644 (file)
@@ -31,6 +31,9 @@ select (even from a program) a string which is not in the choices list.}
 the event wxEVT\_COMMAND\_TEXT\_ENTER (otherwise pressing Enter key
 is either processed internally by the control or used for navigation between
 dialog controls). Windows only.}
+\twocolitem{\windowstyle{wxTE\_FILENAME}}{Should be used for the controls
+containing file names. This currently just enables file names auto-completion
+(and only under Windows for now) but can have other effects in the future.}
 \end{twocollist}
 
 See also \helpref{window styles overview}{windowstyles}.
index 599285884395c280a1ef0ba628cc1341e09f4a74..e44427d4ff6250e2b5f5ddb1d875e7274dbb65a6 100644 (file)
@@ -53,6 +53,9 @@ used, so that text won't be wrapped. No effect under wxGTK1.}
 \twocolitem{\windowstyle{wxTE\_WORDWRAP}}{Wrap the lines too long to be shown entirely at word boundaries (wxUniv and wxGTK2 only).}
 \twocolitem{\windowstyle{wxTE\_BESTWRAP}}{Wrap the lines at word boundaries or at any other character if there are words longer than the window width (this is the default).}
 \twocolitem{\windowstyle{wxTE\_CAPITALIZE}}{On PocketPC and Smartphone, causes the first letter to be capitalized.}
+\twocolitem{\windowstyle{wxTE\_FILENAME}}{Should be used for the text controls
+containing file names. This currently just enables file names auto-completion
+(and only under Windows for now) but can have other effects in the future.}
 \end{twocollist}
 
 See also \helpref{window styles overview}{windowstyles} and \helpref{wxTextCtrl::wxTextCtrl}{wxtextctrlctor}.
index 6b361163eac045a7ab14128417025fa123781a78..c4ce9f63dae0d1fd1a6a792fbb33a0abfeb9b904 100644 (file)
 
 #if wxUSE_COMBOBOX
 
+/*
+ * wxComboBox style flags
+ */
+#define wxCB_SIMPLE         0x0004
+#define wxCB_SORT           0x0008
+#define wxCB_READONLY       0x0010
+#define wxCB_DROPDOWN       0x0020
+#define wxCB_FILENAME       0x0040
+
 extern WXDLLEXPORT_DATA(const wxChar) wxComboBoxNameStr[];
 
 // ----------------------------------------------------------------------------
index 021c098b396faf7258eff3b48fd1b70ecc74661b..ce4b3748d3cc878522f5e754e10db73279303f30 100644 (file)
@@ -1570,14 +1570,6 @@ enum wxBorder
     #define wxPASSWORD        0x0800  /*  wxTE_PASSWORD */
 #endif
 
-/*
- * wxComboBox style flags
- */
-#define wxCB_SIMPLE         0x0004
-#define wxCB_SORT           0x0008
-#define wxCB_READONLY       0x0010
-#define wxCB_DROPDOWN       0x0020
-
 /*
  * wxRadioBox style flags
  */
index 3a0e143d768bc4501be5ec8119a54a19a8f08e86..5cef66c0333baca5dd628f572ce469703e8bef9f 100644 (file)
@@ -20,6 +20,8 @@
 
 #include <shlobj.h>
 
+#include "wx/msw/winundef.h"
+
 // ----------------------------------------------------------------------------
 // wxItemIdList implements RAII on top of ITEMIDLIST
 // ----------------------------------------------------------------------------
@@ -77,5 +79,12 @@ private:
     DECLARE_NO_COPY_CLASS(wxItemIdList)
 };
 
+// enable autocompleting filenames in the text control with given HWND
+//
+// this only works on systems with shlwapi.dll 5.0 or later
+//
+// implemented in src/msw/utilsgui.cpp
+extern bool wxEnableFileNameAutoComplete(HWND hwnd);
+
 #endif // _WX_MSW_WRAPSHL_H_
 
index 2176cfc5dd0e95d89140683343726c9a65923e58..e6a441fc265d7e15512226aee01a40f632f0257b 100644 (file)
@@ -41,12 +41,15 @@ public:
 
     // if present, intercepts wxPB_USE_TEXTCTRL style and creates the text control
     // The 3rd argument is the initial wxString to display in the text control
-    bool CreateBase(wxWindow *parent, wxWindowID id,
-        const wxString& text = wxEmptyString,
-        const wxPoint& pos = wxDefaultPosition,
-        const wxSize& size = wxDefaultSize, long style = 0,
-        const wxValidator& validator = wxDefaultValidator,
-        const wxString& name = wxButtonNameStr);
+    bool CreateBase(wxWindow *parent,
+                    wxWindowID id,
+                    const wxString& text = wxEmptyString,
+                    const wxPoint& pos = wxDefaultPosition,
+                    const wxSize& size = wxDefaultSize,
+                    long style = 0,
+                    const wxValidator& validator = wxDefaultValidator,
+                    const wxString& name = wxButtonNameStr,
+                    long textstyle = 0);
 
 
 public:     // public API
index 65e6b90d54d7863bd44cc1936db7116b22218df8..86079e2ded318fabec0af72fdb6ddba823fb3ba2 100644 (file)
@@ -73,10 +73,7 @@ const wxTextCoord wxInvalidTextCoord    = -2;
 // wxTextCtrl style flags
 // ----------------------------------------------------------------------------
 
-// the flag bit 0x0001 s free but should be used only for the things which
-// don't make sense for a text control used by wxTextEntryDialog because they
-// would otherwise conflict with wxOK, wxCANCEL, wxCENTRE
-
+#define wxTE_FILENAME       0x0001
 #define wxTE_NO_VSCROLL     0x0002
 #define wxTE_AUTO_SCROLL    0x0008
 
index 14e4333cafa8833859860689e7169c9382b58608..4d2e59e1c69faaa4b04d1771a9aad6db11d9caa3 100644 (file)
@@ -134,7 +134,8 @@ protected:
 
     // the checkboxes for styles
     wxCheckBox *m_chkSort,
-               *m_chkReadonly;
+               *m_chkReadonly,
+               *m_chkFilename;
 
     // the combobox itself and the sizer it is in
     wxComboBox *m_combobox;
@@ -211,7 +212,8 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(WidgetsBookCtrl *book,
 {
     // init everything
     m_chkSort =
-    m_chkReadonly = (wxCheckBox *)NULL;
+    m_chkReadonly =
+    m_chkFilename = (wxCheckBox *)NULL;
 
     m_combobox = (wxComboBox *)NULL;
     m_sizerCombo = (wxSizer *)NULL;
@@ -247,6 +249,7 @@ void ComboboxWidgetsPage::CreateContent()
 
     m_chkSort = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Sort items"));
     m_chkReadonly = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Read only"));
+    m_chkFilename = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&File name"));
 
     sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
     sizerLeft->Add(m_radioKind, 0, wxGROW | wxALL, 5);
@@ -343,6 +346,7 @@ void ComboboxWidgetsPage::Reset()
 {
     m_chkSort->SetValue(false);
     m_chkReadonly->SetValue(false);
+    m_chkFilename->SetValue(false);
 }
 
 void ComboboxWidgetsPage::CreateCombo()
@@ -353,6 +357,8 @@ void ComboboxWidgetsPage::CreateCombo()
         flags |= wxCB_SORT;
     if ( m_chkReadonly->GetValue() )
         flags |= wxCB_READONLY;
+    if ( m_chkFilename->GetValue() )
+        flags |= wxCB_FILENAME;
 
     switch ( m_radioKind->GetSelection() )
     {
@@ -509,8 +515,9 @@ void ComboboxWidgetsPage::OnUpdateUIInsertionPointText(wxUpdateUIEvent& event)
 
 void ComboboxWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
 {
-    if (m_combobox)
-        event.Enable( m_chkSort->GetValue() || m_chkReadonly->GetValue() );
+    event.Enable( m_chkSort->GetValue() ||
+                    m_chkReadonly->GetValue() ||
+                        m_chkFilename->GetValue() );
 }
 
 void ComboboxWidgetsPage::OnUpdateUIInsert(wxUpdateUIEvent& event)
index 0d2e8e293c966b098b2a8e8e08193f0d74d9e64d..7d0536507ac3ad38669a0cf7e39714047949a029 100644 (file)
@@ -106,6 +106,7 @@ static const struct ControlValues
 
     bool password;
     bool readonly;
+    bool filename;
 
     WrapStyle wrapStyle;
 
@@ -117,6 +118,7 @@ static const struct ControlValues
     TextLines_Multi,    // multiline
     false,              // not password
     false,              // not readonly
+    false,              // not filename
     WrapStyle_Word,     // wrap on word boundaries
 #ifdef __WXMSW__
     TextKind_Plain      // plain EDIT control
@@ -201,7 +203,8 @@ protected:
 
     // the checkboxes controlling text ctrl styles
     wxCheckBox *m_chkPassword,
-               *m_chkReadonly;
+               *m_chkReadonly,
+               *m_chkFilename;
 
     // under MSW we test rich edit controls as well here
 #ifdef __WXMSW__
@@ -359,7 +362,8 @@ TextWidgetsPage::TextWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist)
     m_radioTextLines = (wxRadioBox *)NULL;
 
     m_chkPassword =
-    m_chkReadonly = (wxCheckBox *)NULL;
+    m_chkReadonly =
+    m_chkFilename = (wxCheckBox *)NULL;
 
     m_text =
     m_textPosCur =
@@ -405,6 +409,9 @@ void TextWidgetsPage::CreateContent()
     m_chkReadonly = CreateCheckBoxAndAddToSizer(
                         sizerLeft, _T("&Read-only mode")
                     );
+    m_chkFilename = CreateCheckBoxAndAddToSizer(
+                        sizerLeft, _T("&Filename control")
+                    );
     sizerLeft->AddSpacer(5);
 
     static const wxString wrap[] =
@@ -604,6 +611,7 @@ void TextWidgetsPage::Reset()
 
     m_chkPassword->SetValue(DEFAULTS.password);
     m_chkReadonly->SetValue(DEFAULTS.readonly);
+    m_chkFilename->SetValue(DEFAULTS.filename);
 
     m_radioWrap->SetSelection(DEFAULTS.wrapStyle);
 
@@ -633,6 +641,8 @@ void TextWidgetsPage::CreateText()
         flags |= wxTE_PASSWORD;
     if ( m_chkReadonly->GetValue() )
         flags |= wxTE_READONLY;
+    if ( m_chkFilename->GetValue() )
+        flags |= wxTE_FILENAME;
 
     switch ( m_radioWrap->GetSelection() )
     {
@@ -870,8 +880,9 @@ void TextWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
 #ifdef __WXMSW__
                   (m_radioKind->GetSelection() != DEFAULTS.textKind) ||
 #endif // __WXMSW__
-                  (m_chkReadonly->GetValue() != DEFAULTS.readonly) ||
                   (m_chkPassword->GetValue() != DEFAULTS.password) ||
+                  (m_chkReadonly->GetValue() != DEFAULTS.readonly) ||
+                  (m_chkFilename->GetValue() != DEFAULTS.filename) ||
                   (m_radioWrap->GetSelection() != DEFAULTS.wrapStyle) );
 }
 
index 53514e3643014a6d99e58db0323ed0cc10a08b77..1282f2386d5586ebcf562e16d44b218d2a0fb338 100644 (file)
@@ -45,17 +45,21 @@ IMPLEMENT_DYNAMIC_CLASS(wxFileDirPickerEvent, wxCommandEvent)
 // wxFileDirPickerCtrlBase
 // ----------------------------------------------------------------------------
 
-bool wxFileDirPickerCtrlBase::CreateBase( wxWindow *parent, wxWindowID id,
-                        const wxString &path, const wxString &message,
-                        const wxString &wildcard,
-                        const wxPoint &pos, const wxSize &size,
-                        long style, const wxValidator& validator,
-                        const wxString &name )
+bool wxFileDirPickerCtrlBase::CreateBase(wxWindow *parent,
+                                         wxWindowID id,
+                                         const wxString &path,
+                                         const wxString &message,
+                                         const wxString &wildcard,
+                                         const wxPoint &pos,
+                                         const wxSize &size,
+                                         long style,
+                                         const wxValidator& validator,
+                                         const wxString &name )
 {
     wxASSERT_MSG(path.empty() || CheckPath(path), wxT("Invalid initial path!"));
 
     if (!wxPickerBase::CreateBase(parent, id, path, pos, size,
-                                   style, validator, name))
+                                   style, validator, name, wxTE_FILENAME))
         return false;
 
     if (!HasFlag(wxFLP_OPEN) && !HasFlag(wxFLP_SAVE))
index e550e651c77c069d5baa959bd01aaa2cc23c55ae..db435a8ecab69e7f9bfb1469b8db040f6c6409c2 100644 (file)
@@ -59,7 +59,8 @@ bool wxPickerBase::CreateBase(wxWindow *parent,
                          const wxSize& size,
                          long style,
                          const wxValidator& validator,
-                         const wxString& name)
+                         const wxString& name,
+                         long textstyle)
 {
     // remove any border style from our style as wxPickerBase's window must be
     // invisible (user styles must be set on the textctrl or the platform-dependent picker)
@@ -75,8 +76,9 @@ bool wxPickerBase::CreateBase(wxWindow *parent,
         // NOTE: the style of this class (wxPickerBase) and the style of the
         //       attached text control are different: GetTextCtrlStyle() extracts
         //       the styles related to the textctrl from the styles passed here
-        m_text = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
-                                wxDefaultSize, GetTextCtrlStyle(style));
+        m_text = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
+                                wxDefaultPosition, wxDefaultSize,
+                                GetTextCtrlStyle(style) | textstyle);
         if (!m_text)
         {
             wxFAIL_MSG( wxT("wxPickerBase's textctrl creation failed") );
index 25a2c9cd672550027b7bd64b0d87f99fe942099d..8d049cb564694ca5be8e68c6e92986cfb570b426 100644 (file)
@@ -42,6 +42,7 @@
 
 // include <commctrl.h> "properly"
 #include "wx/msw/wrapcctl.h"
+#include "wx/msw/wrapshl.h"
 
 #if wxUSE_TOOLTIPS
     #include "wx/tooltip.h"
@@ -417,8 +418,14 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
     // edit control, we must subclass it as well
     if ( !(style & wxCB_READONLY) )
     {
-        gs_wndprocEdit = wxSetWindowProc((HWND)GetEditHWND(),
-                                         wxComboEditWndProc);
+        const HWND hwndEdit = (HWND)GetEditHWND();
+
+        gs_wndprocEdit = wxSetWindowProc(hwndEdit, wxComboEditWndProc);
+
+        if ( style & wxCB_FILENAME )
+        {
+            wxEnableFileNameAutoComplete(hwndEdit);
+        }
     }
 
     // and finally, show the control
index 1b08d80b6d5dea4623a30bbcd48f20f3a39acfb3..15311c9683ddc2775dc65738bb44360c7a11230f 100644 (file)
@@ -50,7 +50,7 @@
 #include <windowsx.h>
 
 #include "wx/msw/private.h"
-#include "wx/msw/winundef.h"
+#include "wx/msw/wrapshl.h"
 
 #include <string.h>
 #include <stdlib.h>
@@ -518,6 +518,9 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
     }
 #endif // wxUSE_RICHEDIT
 
+    if ( style & wxTE_FILENAME )
+        wxEnableFileNameAutoComplete(GetHwnd());
+
     gs_wndprocEdit = wxSetWindowProc((HWND)GetHwnd(),
                                      wxTextCtrlWndProc);
 
index 7926bdb3307ca5410804b6aba71e7100a25478bf..ee1e45a8f9456e30a1f5f8578ed527fd4dc49c6b 100644 (file)
@@ -30,6 +30,8 @@
     #include "wx/utils.h"
 #endif //WX_PRECOMP
 
+#include "wx/dynlib.h"
+
 #include "wx/msw/private.h"     // includes <windows.h>
 
 // ============================================================================
@@ -452,3 +454,45 @@ void wxDrawLine(HDC hdc, int x1, int y1, int x2, int y2)
 }
 
 
+// ----------------------------------------------------------------------------
+// Shell API wrappers
+// ----------------------------------------------------------------------------
+
+extern bool wxEnableFileNameAutoComplete(HWND hwnd)
+{
+    typedef HRESULT (WINAPI *SHAutoComplete_t)(HWND, DWORD);
+
+    static SHAutoComplete_t s_pfnSHAutoComplete = NULL;
+    static bool s_initialized = false;
+
+    if ( !s_initialized )
+    {
+        s_initialized = true;
+
+        wxLogNull nolog;
+        wxDynamicLibrary dll(_T("shlwapi.dll"));
+        if ( dll.IsLoaded() )
+        {
+            s_pfnSHAutoComplete =
+                (SHAutoComplete_t)dll.GetSymbol(_T("SHAutoComplete"));
+            if ( s_pfnSHAutoComplete )
+            {
+                // won't be unloaded until the process termination, no big deal
+                dll.Detach();
+            }
+        }
+    }
+
+    if ( !s_pfnSHAutoComplete )
+        return false;
+
+    HRESULT hr = s_pfnSHAutoComplete(hwnd, 0x10 /* SHACF_FILESYS_ONLY */);
+    if ( FAILED(hr) )
+    {
+        wxLogApiError(_T("SHAutoComplete"), hr);
+        return false;
+    }
+
+    return true;
+}
+
index f8d20a69009b9ec488b9c64128ccbbf94e50ab80..119afc17fe793f5c50fd60627426f8f3a5604afe 100644 (file)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        src/xrc/xh_combo.cpp
-// Purpose:     XRC resource for wxRadioBox
+// Purpose:     XRC resource for wxComboBox
 // Author:      Bob Mitchell
 // Created:     2000/03/21
 // RCS-ID:      $Id$
@@ -34,6 +34,7 @@ wxComboBoxXmlHandler::wxComboBoxXmlHandler()
     XRC_ADD_STYLE(wxCB_SORT);
     XRC_ADD_STYLE(wxCB_READONLY);
     XRC_ADD_STYLE(wxCB_DROPDOWN);
+    XRC_ADD_STYLE(wxCB_FILENAME);
     AddWindowStyles();
 }
 
index e369cb4f790662e8511c19bf276949d9a6f5c30d..0fa4c91eb0f77ff78517a2d7d8e0d4729f9ce76e 100644 (file)
@@ -27,6 +27,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxTextCtrlXmlHandler, wxXmlResourceHandler)
 
 wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler()
 {
+    XRC_ADD_STYLE(wxTE_FILENAME);
     XRC_ADD_STYLE(wxTE_NO_VSCROLL);
     XRC_ADD_STYLE(wxTE_AUTO_SCROLL);
     XRC_ADD_STYLE(wxTE_PROCESS_ENTER);