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:
@@ -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).
|
||||
|
@@ -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}.
|
||||
|
@@ -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}.
|
||||
|
@@ -16,6 +16,15 @@
|
||||
|
||||
#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[];
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -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
|
||||
*/
|
||||
|
@@ -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_
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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) );
|
||||
}
|
||||
|
||||
|
@@ -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))
|
||||
|
@@ -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") );
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user