]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied patch [ 603858 ] wxTextCtrl text alignment patch
authorJulian Smart <julian@anthemion.co.uk>
Thu, 5 Sep 2002 16:15:30 +0000 (16:15 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 5 Sep 2002 16:15:30 +0000 (16:15 +0000)
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
distrib/msw/msw.rsp
docs/changes.txt
docs/latex/wx/text.tex
include/wx/textctrl.h
samples/taskbar/tbtest.cpp
src/msw/textctrl.cpp

index 095432ae2e354940bdcf4f2e330948a3145c4bac..9780ebb7bf97b2b283fe91cf1f32c16285be2ff4 100644 (file)
@@ -41,3 +41,5 @@ src/mac/macsock/*.lib
 include/wx_pb.h
 include/wx/mac/*.h
 
+samples/minimal/minimal.pbproj/project.pbxproj
+
index b705079f2a04aaa85110a4946ef4a3ce47035480..f4568c89594281adaf2a57eea48907a79782b420 100644 (file)
@@ -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
index b8e47da76cdd3f433b916e4205d0c3c559dc4124..30398ec0249333a1178eaef5111ac597549cc938 100644 (file)
@@ -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:
 
index 8bc4647878c6578b6dcb42aff461c9beb32af6c5..c7f58237a3607bd22535b07b776403335cc73297 100644 (file)
@@ -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
index 61240469af4fea367def5e563ed0d735412fca04..358e30495861f1f3d5590e91795027d7f39d4a14 100644 (file)
@@ -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
 
index 8e868f2a82a7733651352032ed3a970a6a091db3..99d07a61a107c9775f8686ced3d5e6eaf9a27ba9 100644 (file)
@@ -20,7 +20,7 @@
 #include "wx/wx.h"
 #endif
 
-#include "wx/msw/taskbar.h"
+#include "wx/taskbar.h"
 #include "tbtest.h"
 
 // Declare two frames
index 6e285fabad1faacd4bd0c1f5ebf0b4db2db4c652..882a6f60e9fad54fe7799e3f7a48b7673f302c31 100644 (file)
@@ -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;
 }