From e015d1f7da1bff9cc3993519ef06ce7fe49dc64f Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 5 Sep 2002 16:15:30 +0000 Subject: [PATCH] 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 --- distrib/msw/mac.rsp | 2 ++ distrib/msw/msw.rsp | 2 ++ docs/changes.txt | 2 ++ docs/latex/wx/text.tex | 7 +++++-- include/wx/textctrl.h | 15 ++++++++++++--- samples/taskbar/tbtest.cpp | 2 +- src/msw/textctrl.cpp | 10 ++++++++++ 7 files changed, 34 insertions(+), 6 deletions(-) diff --git a/distrib/msw/mac.rsp b/distrib/msw/mac.rsp index 095432ae2e..9780ebb7bf 100644 --- a/distrib/msw/mac.rsp +++ b/distrib/msw/mac.rsp @@ -41,3 +41,5 @@ src/mac/macsock/*.lib include/wx_pb.h include/wx/mac/*.h +samples/minimal/minimal.pbproj/project.pbxproj + diff --git a/distrib/msw/msw.rsp b/distrib/msw/msw.rsp index b705079f2a..f4568c8959 100644 --- a/distrib/msw/msw.rsp +++ b/distrib/msw/msw.rsp @@ -56,6 +56,8 @@ src/common/*.rc src/msw/*.cpp src/msw/*.h src/msw/makefile.* +src/msw/makebase.b32 +src/msw/makeuniv.b32 src/msw/*.lst src/msw/*.def src/msw/*.inc diff --git a/docs/changes.txt b/docs/changes.txt index b8e47da76c..30398ec024 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -281,6 +281,8 @@ wxMSW: - don't fail to register remaining window classes if one fails to register - wxFontDialog effects only turned on if a valid colour was provided in wxFontData +- Added wxTE_LEFT, wxTE_CENTRE and wxTE_RIGHT flags for text + control alignment. wxGTK: diff --git a/docs/latex/wx/text.tex b/docs/latex/wx/text.tex index 8bc4647878..c7f58237a3 100644 --- a/docs/latex/wx/text.tex +++ b/docs/latex/wx/text.tex @@ -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 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{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\_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\_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).} \end{twocollist} See also \helpref{window styles overview}{windowstyles} and diff --git a/include/wx/textctrl.h b/include/wx/textctrl.h index 61240469af..358e304958 100644 --- a/include/wx/textctrl.h +++ b/include/wx/textctrl.h @@ -58,18 +58,27 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString; // 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 // 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_MULTILINE 0x0020 #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 // and Win32 and is silently ignored under all other platforms #define wxTE_RICH 0x0080 -#define wxTE_NO_VSCROLL 0x0100 -#define wxTE_AUTO_SCROLL 0x0200 + #define wxTE_PROCESS_ENTER 0x0400 #define wxTE_PASSWORD 0x0800 diff --git a/samples/taskbar/tbtest.cpp b/samples/taskbar/tbtest.cpp index 8e868f2a82..99d07a61a1 100644 --- a/samples/taskbar/tbtest.cpp +++ b/samples/taskbar/tbtest.cpp @@ -20,7 +20,7 @@ #include "wx/wx.h" #endif -#include "wx/msw/taskbar.h" +#include "wx/taskbar.h" #include "tbtest.h" // Declare two frames diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 6e285fabad..882a6f60e9 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -362,6 +362,10 @@ void wxTextCtrl::AdoptAttributesFromHWND() m_windowStyle |= wxTE_READONLY; if (style & ES_WANTRETURN) 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 @@ -410,6 +414,12 @@ WXDWORD wxTextCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const if ( style & wxTE_NOHIDESEL ) msStyle |= ES_NOHIDESEL; + if ( style & wxTE_CENTRE ) + msStyle |= ES_CENTER; + + if ( style & wxTE_RIGHT ) + msStyle |= ES_RIGHT; + return msStyle; } -- 2.45.2