moved combobox styles from defs.to to combobox.h; added wxTE/wxCB_FILENAME styles (MSW only for now); show them in the widgets sample and use for file/dir pickers text controls

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40367 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-07-29 19:19:50 +00:00
parent 54aa3821fc
commit 5f6475c145
17 changed files with 136 additions and 39 deletions

View File

@@ -97,6 +97,7 @@ All (GUI):
- Added wxDC::GradientFillLinear/Concentric(). - Added wxDC::GradientFillLinear/Concentric().
- Added wxHyperlinkCtrl (Francesco Montorsi). - Added wxHyperlinkCtrl (Francesco Montorsi).
- Added clipboard events (wxEVT_COMMAND_TEXT_COPY/CUT/PASTE). - 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). - Allow to reorder wxGrid columns by drag-and-drop (Santiago Palacios).
- Added wxRadioBox::SetItemToolTip(). - Added wxRadioBox::SetItemToolTip().
- Added support for CMYK JPEG images loading (Robert Wruck). - Added support for CMYK JPEG images loading (Robert Wruck).

View 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 the event wxEVT\_COMMAND\_TEXT\_ENTER (otherwise pressing Enter key
is either processed internally by the control or used for navigation between is either processed internally by the control or used for navigation between
dialog controls). Windows only.} 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} \end{twocollist}
See also \helpref{window styles overview}{windowstyles}. See also \helpref{window styles overview}{windowstyles}.

View 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\_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\_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\_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} \end{twocollist}
See also \helpref{window styles overview}{windowstyles} and \helpref{wxTextCtrl::wxTextCtrl}{wxtextctrlctor}. See also \helpref{window styles overview}{windowstyles} and \helpref{wxTextCtrl::wxTextCtrl}{wxtextctrlctor}.

View File

@@ -16,6 +16,15 @@
#if wxUSE_COMBOBOX #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[]; extern WXDLLEXPORT_DATA(const wxChar) wxComboBoxNameStr[];
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -1570,14 +1570,6 @@ enum wxBorder
#define wxPASSWORD 0x0800 /* wxTE_PASSWORD */ #define wxPASSWORD 0x0800 /* wxTE_PASSWORD */
#endif #endif
/*
* wxComboBox style flags
*/
#define wxCB_SIMPLE 0x0004
#define wxCB_SORT 0x0008
#define wxCB_READONLY 0x0010
#define wxCB_DROPDOWN 0x0020
/* /*
* wxRadioBox style flags * wxRadioBox style flags
*/ */

View File

@@ -20,6 +20,8 @@
#include <shlobj.h> #include <shlobj.h>
#include "wx/msw/winundef.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxItemIdList implements RAII on top of ITEMIDLIST // wxItemIdList implements RAII on top of ITEMIDLIST
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -77,5 +79,12 @@ private:
DECLARE_NO_COPY_CLASS(wxItemIdList) 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_ #endif // _WX_MSW_WRAPSHL_H_

View File

@@ -41,12 +41,15 @@ public:
// if present, intercepts wxPB_USE_TEXTCTRL style and creates the text control // 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 // The 3rd argument is the initial wxString to display in the text control
bool CreateBase(wxWindow *parent, wxWindowID id, bool CreateBase(wxWindow *parent,
wxWindowID id,
const wxString& text = wxEmptyString, const wxString& text = wxEmptyString,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr); const wxString& name = wxButtonNameStr,
long textstyle = 0);
public: // public API public: // public API

View File

@@ -73,10 +73,7 @@ const wxTextCoord wxInvalidTextCoord = -2;
// wxTextCtrl style flags // wxTextCtrl style flags
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// the flag bit 0x0001 s free but should be used only for the things which #define wxTE_FILENAME 0x0001
// don't make sense for a text control used by wxTextEntryDialog because they
// would otherwise conflict with wxOK, wxCANCEL, wxCENTRE
#define wxTE_NO_VSCROLL 0x0002 #define wxTE_NO_VSCROLL 0x0002
#define wxTE_AUTO_SCROLL 0x0008 #define wxTE_AUTO_SCROLL 0x0008

View File

@@ -134,7 +134,8 @@ protected:
// the checkboxes for styles // the checkboxes for styles
wxCheckBox *m_chkSort, wxCheckBox *m_chkSort,
*m_chkReadonly; *m_chkReadonly,
*m_chkFilename;
// the combobox itself and the sizer it is in // the combobox itself and the sizer it is in
wxComboBox *m_combobox; wxComboBox *m_combobox;
@@ -211,7 +212,8 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(WidgetsBookCtrl *book,
{ {
// init everything // init everything
m_chkSort = m_chkSort =
m_chkReadonly = (wxCheckBox *)NULL; m_chkReadonly =
m_chkFilename = (wxCheckBox *)NULL;
m_combobox = (wxComboBox *)NULL; m_combobox = (wxComboBox *)NULL;
m_sizerCombo = (wxSizer *)NULL; m_sizerCombo = (wxSizer *)NULL;
@@ -247,6 +249,7 @@ void ComboboxWidgetsPage::CreateContent()
m_chkSort = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Sort items")); m_chkSort = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Sort items"));
m_chkReadonly = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Read only")); 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(5, 5, 0, wxGROW | wxALL, 5); // spacer
sizerLeft->Add(m_radioKind, 0, wxGROW | wxALL, 5); sizerLeft->Add(m_radioKind, 0, wxGROW | wxALL, 5);
@@ -343,6 +346,7 @@ void ComboboxWidgetsPage::Reset()
{ {
m_chkSort->SetValue(false); m_chkSort->SetValue(false);
m_chkReadonly->SetValue(false); m_chkReadonly->SetValue(false);
m_chkFilename->SetValue(false);
} }
void ComboboxWidgetsPage::CreateCombo() void ComboboxWidgetsPage::CreateCombo()
@@ -353,6 +357,8 @@ void ComboboxWidgetsPage::CreateCombo()
flags |= wxCB_SORT; flags |= wxCB_SORT;
if ( m_chkReadonly->GetValue() ) if ( m_chkReadonly->GetValue() )
flags |= wxCB_READONLY; flags |= wxCB_READONLY;
if ( m_chkFilename->GetValue() )
flags |= wxCB_FILENAME;
switch ( m_radioKind->GetSelection() ) switch ( m_radioKind->GetSelection() )
{ {
@@ -509,8 +515,9 @@ void ComboboxWidgetsPage::OnUpdateUIInsertionPointText(wxUpdateUIEvent& event)
void ComboboxWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event) void ComboboxWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
{ {
if (m_combobox) event.Enable( m_chkSort->GetValue() ||
event.Enable( m_chkSort->GetValue() || m_chkReadonly->GetValue() ); m_chkReadonly->GetValue() ||
m_chkFilename->GetValue() );
} }
void ComboboxWidgetsPage::OnUpdateUIInsert(wxUpdateUIEvent& event) void ComboboxWidgetsPage::OnUpdateUIInsert(wxUpdateUIEvent& event)

View File

@@ -106,6 +106,7 @@ static const struct ControlValues
bool password; bool password;
bool readonly; bool readonly;
bool filename;
WrapStyle wrapStyle; WrapStyle wrapStyle;
@@ -117,6 +118,7 @@ static const struct ControlValues
TextLines_Multi, // multiline TextLines_Multi, // multiline
false, // not password false, // not password
false, // not readonly false, // not readonly
false, // not filename
WrapStyle_Word, // wrap on word boundaries WrapStyle_Word, // wrap on word boundaries
#ifdef __WXMSW__ #ifdef __WXMSW__
TextKind_Plain // plain EDIT control TextKind_Plain // plain EDIT control
@@ -201,7 +203,8 @@ protected:
// the checkboxes controlling text ctrl styles // the checkboxes controlling text ctrl styles
wxCheckBox *m_chkPassword, wxCheckBox *m_chkPassword,
*m_chkReadonly; *m_chkReadonly,
*m_chkFilename;
// under MSW we test rich edit controls as well here // under MSW we test rich edit controls as well here
#ifdef __WXMSW__ #ifdef __WXMSW__
@@ -359,7 +362,8 @@ TextWidgetsPage::TextWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist)
m_radioTextLines = (wxRadioBox *)NULL; m_radioTextLines = (wxRadioBox *)NULL;
m_chkPassword = m_chkPassword =
m_chkReadonly = (wxCheckBox *)NULL; m_chkReadonly =
m_chkFilename = (wxCheckBox *)NULL;
m_text = m_text =
m_textPosCur = m_textPosCur =
@@ -405,6 +409,9 @@ void TextWidgetsPage::CreateContent()
m_chkReadonly = CreateCheckBoxAndAddToSizer( m_chkReadonly = CreateCheckBoxAndAddToSizer(
sizerLeft, _T("&Read-only mode") sizerLeft, _T("&Read-only mode")
); );
m_chkFilename = CreateCheckBoxAndAddToSizer(
sizerLeft, _T("&Filename control")
);
sizerLeft->AddSpacer(5); sizerLeft->AddSpacer(5);
static const wxString wrap[] = static const wxString wrap[] =
@@ -604,6 +611,7 @@ void TextWidgetsPage::Reset()
m_chkPassword->SetValue(DEFAULTS.password); m_chkPassword->SetValue(DEFAULTS.password);
m_chkReadonly->SetValue(DEFAULTS.readonly); m_chkReadonly->SetValue(DEFAULTS.readonly);
m_chkFilename->SetValue(DEFAULTS.filename);
m_radioWrap->SetSelection(DEFAULTS.wrapStyle); m_radioWrap->SetSelection(DEFAULTS.wrapStyle);
@@ -633,6 +641,8 @@ void TextWidgetsPage::CreateText()
flags |= wxTE_PASSWORD; flags |= wxTE_PASSWORD;
if ( m_chkReadonly->GetValue() ) if ( m_chkReadonly->GetValue() )
flags |= wxTE_READONLY; flags |= wxTE_READONLY;
if ( m_chkFilename->GetValue() )
flags |= wxTE_FILENAME;
switch ( m_radioWrap->GetSelection() ) switch ( m_radioWrap->GetSelection() )
{ {
@@ -870,8 +880,9 @@ void TextWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
#ifdef __WXMSW__ #ifdef __WXMSW__
(m_radioKind->GetSelection() != DEFAULTS.textKind) || (m_radioKind->GetSelection() != DEFAULTS.textKind) ||
#endif // __WXMSW__ #endif // __WXMSW__
(m_chkReadonly->GetValue() != DEFAULTS.readonly) ||
(m_chkPassword->GetValue() != DEFAULTS.password) || (m_chkPassword->GetValue() != DEFAULTS.password) ||
(m_chkReadonly->GetValue() != DEFAULTS.readonly) ||
(m_chkFilename->GetValue() != DEFAULTS.filename) ||
(m_radioWrap->GetSelection() != DEFAULTS.wrapStyle) ); (m_radioWrap->GetSelection() != DEFAULTS.wrapStyle) );
} }

View File

@@ -45,17 +45,21 @@ IMPLEMENT_DYNAMIC_CLASS(wxFileDirPickerEvent, wxCommandEvent)
// wxFileDirPickerCtrlBase // wxFileDirPickerCtrlBase
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxFileDirPickerCtrlBase::CreateBase( wxWindow *parent, wxWindowID id, bool wxFileDirPickerCtrlBase::CreateBase(wxWindow *parent,
const wxString &path, const wxString &message, wxWindowID id,
const wxString &path,
const wxString &message,
const wxString &wildcard, const wxString &wildcard,
const wxPoint &pos, const wxSize &size, const wxPoint &pos,
long style, const wxValidator& validator, const wxSize &size,
long style,
const wxValidator& validator,
const wxString &name ) const wxString &name )
{ {
wxASSERT_MSG(path.empty() || CheckPath(path), wxT("Invalid initial path!")); wxASSERT_MSG(path.empty() || CheckPath(path), wxT("Invalid initial path!"));
if (!wxPickerBase::CreateBase(parent, id, path, pos, size, if (!wxPickerBase::CreateBase(parent, id, path, pos, size,
style, validator, name)) style, validator, name, wxTE_FILENAME))
return false; return false;
if (!HasFlag(wxFLP_OPEN) && !HasFlag(wxFLP_SAVE)) if (!HasFlag(wxFLP_OPEN) && !HasFlag(wxFLP_SAVE))

View File

@@ -59,7 +59,8 @@ bool wxPickerBase::CreateBase(wxWindow *parent,
const wxSize& size, const wxSize& size,
long style, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name,
long textstyle)
{ {
// remove any border style from our style as wxPickerBase's window must be // 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) // 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 // NOTE: the style of this class (wxPickerBase) and the style of the
// attached text control are different: GetTextCtrlStyle() extracts // attached text control are different: GetTextCtrlStyle() extracts
// the styles related to the textctrl from the styles passed here // the styles related to the textctrl from the styles passed here
m_text = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, m_text = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
wxDefaultSize, GetTextCtrlStyle(style)); wxDefaultPosition, wxDefaultSize,
GetTextCtrlStyle(style) | textstyle);
if (!m_text) if (!m_text)
{ {
wxFAIL_MSG( wxT("wxPickerBase's textctrl creation failed") ); wxFAIL_MSG( wxT("wxPickerBase's textctrl creation failed") );

View File

@@ -42,6 +42,7 @@
// include <commctrl.h> "properly" // include <commctrl.h> "properly"
#include "wx/msw/wrapcctl.h" #include "wx/msw/wrapcctl.h"
#include "wx/msw/wrapshl.h"
#if wxUSE_TOOLTIPS #if wxUSE_TOOLTIPS
#include "wx/tooltip.h" #include "wx/tooltip.h"
@@ -417,8 +418,14 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
// edit control, we must subclass it as well // edit control, we must subclass it as well
if ( !(style & wxCB_READONLY) ) if ( !(style & wxCB_READONLY) )
{ {
gs_wndprocEdit = wxSetWindowProc((HWND)GetEditHWND(), const HWND hwndEdit = (HWND)GetEditHWND();
wxComboEditWndProc);
gs_wndprocEdit = wxSetWindowProc(hwndEdit, wxComboEditWndProc);
if ( style & wxCB_FILENAME )
{
wxEnableFileNameAutoComplete(hwndEdit);
}
} }
// and finally, show the control // and finally, show the control

View File

@@ -50,7 +50,7 @@
#include <windowsx.h> #include <windowsx.h>
#include "wx/msw/private.h" #include "wx/msw/private.h"
#include "wx/msw/winundef.h" #include "wx/msw/wrapshl.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@@ -518,6 +518,9 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
} }
#endif // wxUSE_RICHEDIT #endif // wxUSE_RICHEDIT
if ( style & wxTE_FILENAME )
wxEnableFileNameAutoComplete(GetHwnd());
gs_wndprocEdit = wxSetWindowProc((HWND)GetHwnd(), gs_wndprocEdit = wxSetWindowProc((HWND)GetHwnd(),
wxTextCtrlWndProc); wxTextCtrlWndProc);

View File

@@ -30,6 +30,8 @@
#include "wx/utils.h" #include "wx/utils.h"
#endif //WX_PRECOMP #endif //WX_PRECOMP
#include "wx/dynlib.h"
#include "wx/msw/private.h" // includes <windows.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;
}

View File

@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: src/xrc/xh_combo.cpp // Name: src/xrc/xh_combo.cpp
// Purpose: XRC resource for wxRadioBox // Purpose: XRC resource for wxComboBox
// Author: Bob Mitchell // Author: Bob Mitchell
// Created: 2000/03/21 // Created: 2000/03/21
// RCS-ID: $Id$ // RCS-ID: $Id$
@@ -34,6 +34,7 @@ wxComboBoxXmlHandler::wxComboBoxXmlHandler()
XRC_ADD_STYLE(wxCB_SORT); XRC_ADD_STYLE(wxCB_SORT);
XRC_ADD_STYLE(wxCB_READONLY); XRC_ADD_STYLE(wxCB_READONLY);
XRC_ADD_STYLE(wxCB_DROPDOWN); XRC_ADD_STYLE(wxCB_DROPDOWN);
XRC_ADD_STYLE(wxCB_FILENAME);
AddWindowStyles(); AddWindowStyles();
} }

View File

@@ -27,6 +27,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxTextCtrlXmlHandler, wxXmlResourceHandler)
wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler() wxTextCtrlXmlHandler::wxTextCtrlXmlHandler() : wxXmlResourceHandler()
{ {
XRC_ADD_STYLE(wxTE_FILENAME);
XRC_ADD_STYLE(wxTE_NO_VSCROLL); XRC_ADD_STYLE(wxTE_NO_VSCROLL);
XRC_ADD_STYLE(wxTE_AUTO_SCROLL); XRC_ADD_STYLE(wxTE_AUTO_SCROLL);
XRC_ADD_STYLE(wxTE_PROCESS_ENTER); XRC_ADD_STYLE(wxTE_PROCESS_ENTER);