Applied patch [ 603858 ] wxTextCtrl text alignment patch
Benjamin I. Williams This patch implements three new flags for the wxTextCtrl control. The flags are wxTE_LEFT, wxTE_CENTRE, and wxTE_RIGHT. These flags can change the way text is aligned inside an edit control, which is useful when the user is editing numbers or dates. At Vadim's recommendation, the patch implements the alignment flags so they are equal to the corresponding wxALIGN_* value. wxTE_LEFT is actually 0x0000, and is just a place holder. wxTE_CENTRE is equal to wx_ALIGN_CENTER_HORIZONTAL (0x0100), and wxTE_RIGHT is equal to wxALIGN_RIGHT (0x0100). I couldn't agree more with this idea. As Vadim pointed out, choosing to set the text alignment flags to the corresponding wxALIGN_* flags has a slight negative side effect: the values 0x0100 and 0x0200 collide with the existing flags wxTE_NO_VSCROLL and wxTE_AUTO_SCROLL. A valid point was raised, however, which stated that the flags would never really be used at the same time, and also that wxTE_AUTO_SCROLL is (possibly) going to be deprecated anyway. While this collision is not really a problem, I didn't like the idea of someone specifying wxTE_NO_VSCROLL and ending up with with a centered text control ! Thus, I chose to move both wxTE_NO_VSCROLL and wxTE_AUTO_SCROLL down to the free bits 0x0002 and 0x0008, respectively. I'll leave the final say up to Vadim and the rest of you whether you want to move these flags down or keep them where they are (with collisions). What truly matters to me is that I can now create text controls with the proper alignment! This patch also updates the documentation. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16989 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
85d5e282e9
commit
e015d1f7da
@ -41,3 +41,5 @@ src/mac/macsock/*.lib
|
|||||||
include/wx_pb.h
|
include/wx_pb.h
|
||||||
include/wx/mac/*.h
|
include/wx/mac/*.h
|
||||||
|
|
||||||
|
samples/minimal/minimal.pbproj/project.pbxproj
|
||||||
|
|
||||||
|
@ -56,6 +56,8 @@ src/common/*.rc
|
|||||||
src/msw/*.cpp
|
src/msw/*.cpp
|
||||||
src/msw/*.h
|
src/msw/*.h
|
||||||
src/msw/makefile.*
|
src/msw/makefile.*
|
||||||
|
src/msw/makebase.b32
|
||||||
|
src/msw/makeuniv.b32
|
||||||
src/msw/*.lst
|
src/msw/*.lst
|
||||||
src/msw/*.def
|
src/msw/*.def
|
||||||
src/msw/*.inc
|
src/msw/*.inc
|
||||||
|
@ -281,6 +281,8 @@ wxMSW:
|
|||||||
- don't fail to register remaining window classes if one fails to register
|
- don't fail to register remaining window classes if one fails to register
|
||||||
- wxFontDialog effects only turned on if a valid colour was
|
- wxFontDialog effects only turned on if a valid colour was
|
||||||
provided in wxFontData
|
provided in wxFontData
|
||||||
|
- Added wxTE_LEFT, wxTE_CENTRE and wxTE_RIGHT flags for text
|
||||||
|
control alignment.
|
||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
|
||||||
|
@ -114,9 +114,12 @@ under Win32 only and requires wxTE\_RICH.}
|
|||||||
doesn't show the selection when it doesn't have focus - use this style to force
|
doesn't show the selection when it doesn't have focus - use this style to force
|
||||||
it to always show it. It doesn't do anything under other platforms.}
|
it to always show it. It doesn't do anything under other platforms.}
|
||||||
\twocolitem{\windowstyle{wxHSCROLL}}{A horizontal scrollbar will be created. No effect under GTK+.}
|
\twocolitem{\windowstyle{wxHSCROLL}}{A horizontal scrollbar will be created. No effect under GTK+.}
|
||||||
|
\twocolitem{\windowstyle{wxTE\_LEFT}}{The text control will be left-justified (default).}
|
||||||
|
\twocolitem{\windowstyle{wxTE\_CENTRE}}{The text control will be centre-justified.}
|
||||||
|
\twocolitem{\windowstyle{wxTE\_RIGHT}}{The text control will be right-justified.}
|
||||||
\twocolitem{\windowstyle{wxTE\_DONTWRAP}}{Same as {\tt wxHSCROLL} style.}
|
\twocolitem{\windowstyle{wxTE\_DONTWRAP}}{Same as {\tt wxHSCROLL} style.}
|
||||||
\twocolitem{\windowstyle{wxTE\_LINEWRAP}}{Wrap the lines too long to be shown entirely at any position (wxUniv only currently)}
|
\twocolitem{\windowstyle{wxTE\_LINEWRAP}}{Wrap the lines too long to be shown entirely at any position (wxUniv only currently).}
|
||||||
\twocolitem{\windowstyle{wxTE\_WORDWRAP}}{Wrap the lines too long to be shown entirely at word boundaries only (wxUniv only currently)}
|
\twocolitem{\windowstyle{wxTE\_WORDWRAP}}{Wrap the lines too long to be shown entirely at word boundaries only (wxUniv only currently).}
|
||||||
\end{twocollist}
|
\end{twocollist}
|
||||||
|
|
||||||
See also \helpref{window styles overview}{windowstyles} and
|
See also \helpref{window styles overview}{windowstyles} and
|
||||||
|
@ -58,18 +58,27 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
|
|||||||
// wxTextCtrl style flags
|
// wxTextCtrl style flags
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// the flag bits 0x0001, 2, 4 and 8 are free but should be used only for the
|
// the flag bits 0x0001, and 0x0004 are free but should be used only for the
|
||||||
// things which don't make sense for a text control used by wxTextEntryDialog
|
// things which don't make sense for a text control used by wxTextEntryDialog
|
||||||
// because they would otherwise conflict with wxOK, wxCANCEL, wxCENTRE
|
// because they would otherwise conflict with wxOK, wxCANCEL, wxCENTRE
|
||||||
|
|
||||||
|
#define wxTE_NO_VSCROLL 0x0002
|
||||||
|
#define wxTE_AUTO_SCROLL 0x0008
|
||||||
|
|
||||||
#define wxTE_READONLY 0x0010
|
#define wxTE_READONLY 0x0010
|
||||||
#define wxTE_MULTILINE 0x0020
|
#define wxTE_MULTILINE 0x0020
|
||||||
#define wxTE_PROCESS_TAB 0x0040
|
#define wxTE_PROCESS_TAB 0x0040
|
||||||
|
|
||||||
|
// alignment flags
|
||||||
|
#define wxTE_LEFT 0x0000 // 0x0000
|
||||||
|
#define wxTE_CENTER wxALIGN_CENTER_HORIZONTAL // 0x0100
|
||||||
|
#define wxTE_RIGHT wxALIGN_RIGHT // 0x0200
|
||||||
|
#define wxTE_CENTRE wxTE_CENTER
|
||||||
|
|
||||||
// this style means to use RICHEDIT control and does something only under wxMSW
|
// this style means to use RICHEDIT control and does something only under wxMSW
|
||||||
// and Win32 and is silently ignored under all other platforms
|
// and Win32 and is silently ignored under all other platforms
|
||||||
#define wxTE_RICH 0x0080
|
#define wxTE_RICH 0x0080
|
||||||
#define wxTE_NO_VSCROLL 0x0100
|
|
||||||
#define wxTE_AUTO_SCROLL 0x0200
|
|
||||||
#define wxTE_PROCESS_ENTER 0x0400
|
#define wxTE_PROCESS_ENTER 0x0400
|
||||||
#define wxTE_PASSWORD 0x0800
|
#define wxTE_PASSWORD 0x0800
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "wx/wx.h"
|
#include "wx/wx.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/msw/taskbar.h"
|
#include "wx/taskbar.h"
|
||||||
#include "tbtest.h"
|
#include "tbtest.h"
|
||||||
|
|
||||||
// Declare two frames
|
// Declare two frames
|
||||||
|
@ -362,6 +362,10 @@ void wxTextCtrl::AdoptAttributesFromHWND()
|
|||||||
m_windowStyle |= wxTE_READONLY;
|
m_windowStyle |= wxTE_READONLY;
|
||||||
if (style & ES_WANTRETURN)
|
if (style & ES_WANTRETURN)
|
||||||
m_windowStyle |= wxTE_PROCESS_ENTER;
|
m_windowStyle |= wxTE_PROCESS_ENTER;
|
||||||
|
if (style & ES_CENTER)
|
||||||
|
m_windowStyle |= wxTE_CENTRE;
|
||||||
|
if (style & ES_RIGHT)
|
||||||
|
m_windowStyle |= wxTE_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
|
WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
|
||||||
@ -410,6 +414,12 @@ WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
|
|||||||
if ( style & wxTE_NOHIDESEL )
|
if ( style & wxTE_NOHIDESEL )
|
||||||
msStyle |= ES_NOHIDESEL;
|
msStyle |= ES_NOHIDESEL;
|
||||||
|
|
||||||
|
if ( style & wxTE_CENTRE )
|
||||||
|
msStyle |= ES_CENTER;
|
||||||
|
|
||||||
|
if ( style & wxTE_RIGHT )
|
||||||
|
msStyle |= ES_RIGHT;
|
||||||
|
|
||||||
return msStyle;
|
return msStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user