1. some more notes about Unicode compilation
2. wxUSE_WCHAR_T is not always (re)defined as 1 in wxchar.h (grrr..) 3. added wxDllLoader test to console sample 4. wxComboBox now gets WM_CHAR git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@6990 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -156,5 +156,16 @@ useful, is wc\_str() function which always returns
|
||||
the Unicode string.
|
||||
|
||||
% TODO describe fn_str(), wx_str(), wxCharBuf classes, ...
|
||||
% Please remember to put a blank line at the end of each file! (Tex2RTF 'issue')
|
||||
|
||||
\subsection{Unicode-related compilation settings}
|
||||
|
||||
You should define {\tt wxUSE\_UNICODE} to $1$ to compile your program in
|
||||
Unicode mode. Note that it currently only works in Win32 and that some parts of
|
||||
wxWindows are not Unicode-compliant yet (ODBC classes, for example). If you
|
||||
compile your program in ANSI mode you can still define {\tt wxUSE\_WCHAR\_T}
|
||||
to get some limited support for {\tt wchar\_t} type.
|
||||
|
||||
This will allow your program to perform conversions between Unicode strings and
|
||||
ANSI ones (\helpref{wxEncodingConverter}{wxencodingconverter} depends on this
|
||||
partially) and construct wxString objects from Unicode strings (presumably read
|
||||
from some external file or elsewhere).
|
||||
|
@@ -22,6 +22,10 @@
|
||||
// # error "MBCS is not supported by wxChar"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// first deal with Unicode setting
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// set wxUSE_UNICODE to 1 if UNICODE or _UNICODE is defined
|
||||
#if defined(_UNICODE) || defined(UNICODE)
|
||||
# undef wxUSE_UNICODE
|
||||
@@ -30,7 +34,7 @@
|
||||
# ifndef wxUSE_UNICODE
|
||||
# define wxUSE_UNICODE 0
|
||||
# endif
|
||||
#endif
|
||||
#endif // Unicode
|
||||
|
||||
// and vice versa: define UNICODE and _UNICODE if wxUSE_UNICODE is 1...
|
||||
#if wxUSE_UNICODE
|
||||
@@ -40,7 +44,13 @@
|
||||
# ifndef UNICODE
|
||||
# define UNICODE
|
||||
# endif
|
||||
#endif
|
||||
#endif // Unicode
|
||||
|
||||
// Unicode support requires wchar_t
|
||||
#if wxUSE_UNICODE
|
||||
# undef wxUSE_WCHAR_T
|
||||
# define wxUSE_WCHAR_T 1
|
||||
#endif // Unicode
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// define wxHAVE_TCHAR_FUNCTIONS for the compilers which support the
|
||||
@@ -98,9 +108,7 @@
|
||||
// time.h functions -- none defined in tchar.h
|
||||
#define wxAsctime asctime
|
||||
#define wxCtime ctime
|
||||
|
||||
|
||||
#endif
|
||||
#endif // compilers with (good) TCHAR support
|
||||
|
||||
#ifdef wxHAVE_TCHAR_FUNCTIONS
|
||||
# define HAVE_WCSLEN 1
|
||||
@@ -116,9 +124,11 @@ typedef _TUCHAR wxUChar;
|
||||
# define wxSChar signed char
|
||||
# define wxUChar unsigned char
|
||||
# endif
|
||||
|
||||
// wchar_t is available
|
||||
# undef wxUSE_WCHAR_T
|
||||
# define wxUSE_WCHAR_T 1
|
||||
#ifndef wxUSE_WCHAR_T
|
||||
#define wxUSE_WCHAR_T 1
|
||||
#endif // !defined(wxUSE_WCHAR_T)
|
||||
|
||||
// ctype.h functions
|
||||
#ifndef wxNO_TCHAR_CTYPE
|
||||
@@ -239,10 +249,7 @@ typedef _TUCHAR wxUChar;
|
||||
#else // !TCHAR-aware compilers
|
||||
|
||||
// check whether we should include wchar.h or equivalent
|
||||
# if wxUSE_UNICODE
|
||||
# undef wxUSE_WCHAR_T
|
||||
# define wxUSE_WCHAR_T 1 // wchar_t *must* be available in Unicode mode
|
||||
# elif !defined(wxUSE_WCHAR_T)
|
||||
# if !defined(wxUSE_WCHAR_T)
|
||||
# if defined(__VISUALC__) && (__VISUALC__ < 900)
|
||||
# define wxUSE_WCHAR_T 0 // wchar_t is not available for MSVC++ 1.5
|
||||
# elif defined(__UNIX__)
|
||||
@@ -263,7 +270,7 @@ typedef _TUCHAR wxUChar;
|
||||
// add additional compiler checks if this fails
|
||||
# define wxUSE_WCHAR_T 1
|
||||
# endif
|
||||
# endif//wxUSE_UNICODE
|
||||
# endif // !defined(wxUSE_WCHAR_T)
|
||||
|
||||
# if wxUSE_WCHAR_T
|
||||
# ifdef HAVE_WCSTR_H
|
||||
@@ -628,6 +635,10 @@ WXDLLEXPORT int wxSystem(const wxChar *psz);
|
||||
WXDLLEXPORT size_t wxStrftime(wxChar *s, size_t max, const wxChar *fmt, const struct tm *tm);
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// common macros which are always defined
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// although global macros with such names are really bad, we want to have
|
||||
// another name for _T() which should be used to avoid confusion between _T()
|
||||
// and _() in wxWindows sources
|
||||
|
@@ -9,6 +9,14 @@
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "strconv.h"
|
||||
#endif
|
||||
@@ -31,24 +39,21 @@
|
||||
#include "wx/debug.h"
|
||||
#include "wx/strconv.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// wxConvCurrent
|
||||
//----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// globals
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WXDLLEXPORT_DATA(wxMBConv *) wxConvCurrent = &wxConvLibc;
|
||||
|
||||
#if !wxUSE_WCHAR_T
|
||||
//----------------------------------------------------------------------------
|
||||
// stand-ins in absence of wchar_t
|
||||
//----------------------------------------------------------------------------
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
WXDLLEXPORT_DATA(wxMBConv) wxConvLibc, wxConvFile;
|
||||
#if wxUSE_WCHAR_T
|
||||
|
||||
#else
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMBConv
|
||||
//----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WXDLLEXPORT_DATA(wxMBConv) wxConvLibc;
|
||||
|
||||
@@ -88,9 +93,9 @@ const wxCharBuffer wxMBConv::cWC2MB(const wchar_t *psz) const
|
||||
return wxCharBuffer((char *) NULL);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// standard file conversion
|
||||
//----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WXDLLEXPORT_DATA(wxMBConvFile) wxConvFile;
|
||||
|
||||
@@ -105,11 +110,11 @@ size_t wxMBConvFile::WC2MB(char *buf, const wchar_t *psz, size_t n) const
|
||||
return wxWC2MB(buf, psz, n);
|
||||
}
|
||||
|
||||
#ifdef __WXGTK12__
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// standard gdk conversion
|
||||
//----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __WXGTK12__
|
||||
|
||||
WXDLLEXPORT_DATA(wxMBConvGdk) wxConvGdk;
|
||||
|
||||
@@ -138,6 +143,7 @@ size_t wxMBConvGdk::WC2MB(char *buf, const wchar_t *psz, size_t n) const
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
#endif // GTK > 1.0
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -171,9 +177,9 @@ size_t wxMBConvUTF7::WC2MB(char * WXUNUSED(buf),
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
// UTF-8
|
||||
//----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WXDLLEXPORT_DATA(wxMBConvUTF8) wxConvUTF8;
|
||||
|
||||
@@ -352,7 +358,14 @@ size_t wxCSConv::WC2MB(char *buf, const wchar_t *psz, size_t n) const
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
//wxUSE_WCHAR_T
|
||||
#else // !wxUSE_WCHAR_T
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// stand-ins in absence of wchar_t
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WXDLLEXPORT_DATA(wxMBConv) wxConvLibc, wxConvFile;
|
||||
|
||||
#endif // wxUSE_WCHAR_T
|
||||
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: combobox.cpp
|
||||
// Name: msw/combobox.cpp
|
||||
// Purpose: wxComboBox class
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
@@ -9,6 +9,14 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "combobox.h"
|
||||
#endif
|
||||
@@ -30,8 +38,56 @@
|
||||
#include "wx/clipbrd.h"
|
||||
#include "wx/msw/private.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxWin macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// function prototypes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
LRESULT APIENTRY _EXPORT wxComboEditWndProc(HWND hWnd,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// global vars
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// the pointer to standard radio button wnd proc
|
||||
static WXFARPROC gs_wndprocEdit = (WXFARPROC)NULL;
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wnd proc for subclassed edit control
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
LRESULT APIENTRY _EXPORT wxComboEditWndProc(HWND hWnd,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
if ( message == WM_CHAR )
|
||||
{
|
||||
HWND hwndCombo = ::GetParent(hWnd);
|
||||
wxCHECK_MSG( hwndCombo, 0, _T("should have combo as parent") );
|
||||
|
||||
::SendMessage(hwndCombo, message, wParam, lParam);
|
||||
}
|
||||
|
||||
return ::CallWindowProc(CASTWNDPROC gs_wndprocEdit, hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxComboBox
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxComboBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
|
||||
{
|
||||
switch ( param )
|
||||
@@ -71,90 +127,72 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
SetName(name);
|
||||
#if wxUSE_VALIDATORS
|
||||
SetValidator(validator);
|
||||
#endif // wxUSE_VALIDATORS
|
||||
if (parent) parent->AddChild(this);
|
||||
// SetBackgroundColour(parent->GetBackgroundColour()) ;
|
||||
// first create wxWin object
|
||||
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
|
||||
return FALSE;
|
||||
|
||||
// get the right style
|
||||
long msStyle = WS_TABSTOP | WS_VSCROLL | WS_HSCROLL |
|
||||
CBS_AUTOHSCROLL | CBS_NOINTEGRALHEIGHT;
|
||||
if ( style & wxCB_READONLY )
|
||||
msStyle |= CBS_DROPDOWNLIST;
|
||||
else if ( style & wxCB_SIMPLE )
|
||||
msStyle |= CBS_SIMPLE; // A list (shown always) and edit control
|
||||
else
|
||||
msStyle |= CBS_DROPDOWN;
|
||||
|
||||
if ( style & wxCB_SORT )
|
||||
msStyle |= CBS_SORT;
|
||||
|
||||
// and now create the MSW control
|
||||
if ( !MSWCreateControl(_T("COMBOBOX"), msStyle) )
|
||||
return FALSE;
|
||||
|
||||
SetSize(pos.x, pos.y, size.x, size.y);
|
||||
|
||||
// A choice/combobox normally has a white background (or other, depending
|
||||
// on global settings) rather than inheriting the parent's background colour.
|
||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
|
||||
|
||||
SetForegroundColour(parent->GetForegroundColour()) ;
|
||||
|
||||
m_windowStyle = style;
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
int x = pos.x;
|
||||
int y = pos.y;
|
||||
int width = size.x;
|
||||
int height = size.y;
|
||||
|
||||
long msStyle = WS_CHILD | WS_TABSTOP | WS_VISIBLE |
|
||||
WS_VSCROLL | WS_HSCROLL | CBS_AUTOHSCROLL | CBS_NOINTEGRALHEIGHT;
|
||||
|
||||
if (m_windowStyle & wxCB_READONLY)
|
||||
msStyle |= CBS_DROPDOWNLIST;
|
||||
else if (m_windowStyle & wxCB_SIMPLE)
|
||||
msStyle |= CBS_SIMPLE; // A list (shown always) and edit control
|
||||
else
|
||||
msStyle |= CBS_DROPDOWN;
|
||||
|
||||
if (m_windowStyle & wxCB_SORT)
|
||||
msStyle |= CBS_SORT;
|
||||
|
||||
bool want3D;
|
||||
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
|
||||
|
||||
// Even with extended styles, need to combine with WS_BORDER
|
||||
// for them to look right.
|
||||
if ( want3D || wxStyleHasBorder(m_windowStyle) )
|
||||
msStyle |= WS_BORDER;
|
||||
|
||||
m_hWnd = (WXHWND)::CreateWindowEx(exStyle, wxT("COMBOBOX"), NULL,
|
||||
msStyle,
|
||||
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
|
||||
wxGetInstance(), NULL);
|
||||
|
||||
wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create combobox") );
|
||||
|
||||
/*
|
||||
#if wxUSE_CTL3D
|
||||
if (want3D)
|
||||
{
|
||||
Ctl3dSubclassCtl(wx_combo);
|
||||
m_useCtl3D = TRUE;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
// Subclass again for purposes of dialog editing mode
|
||||
SubclassWin(m_hWnd);
|
||||
|
||||
SetFont(parent->GetFont());
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
for ( int i = 0; i < n; i++ )
|
||||
{
|
||||
Append(choices[i]);
|
||||
}
|
||||
|
||||
SetSelection(i);
|
||||
|
||||
SetSize(x, y, width, height);
|
||||
if ( !value.IsEmpty() )
|
||||
{
|
||||
SetValue(value);
|
||||
}
|
||||
|
||||
// a (not read only) combobox is, in fact, 2 controls: the combobox itself
|
||||
// and an edit control inside it and if we want to catch events from this
|
||||
// edit control, we must subclass it as well
|
||||
if ( !(style & wxCB_READONLY) )
|
||||
{
|
||||
// first find the child edit
|
||||
POINT pt;
|
||||
pt.x = pt.y = 4;
|
||||
HWND hwndEdit = ::ChildWindowFromPoint(GetHwnd(), pt);
|
||||
if ( !hwndEdit || hwndEdit == GetHwnd() )
|
||||
{
|
||||
wxFAIL_MSG(_T("not read only combobox without edit control?"));
|
||||
}
|
||||
else
|
||||
{
|
||||
gs_wndprocEdit = (WXFARPROC)::SetWindowLong
|
||||
(
|
||||
hwndEdit,
|
||||
GWL_WNDPROC,
|
||||
(LPARAM)wxComboEditWndProc
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// TODO: update and clear all this horrible mess (VZ)
|
||||
|
||||
void wxComboBox::SetValue(const wxString& value)
|
||||
{
|
||||
// If newlines are denoted by just 10, must stick 13 in front.
|
||||
|
@@ -109,9 +109,8 @@ bool wxControl::MSWCreateControl(const wxChar *classname,
|
||||
|
||||
if ( !m_hWnd )
|
||||
{
|
||||
#ifdef __WXDEBUG__
|
||||
wxLogError(wxT("Failed to create a control of class '%s'"), classname);
|
||||
#endif // DEBUG
|
||||
wxLogDebug(wxT("Failed to create a control of class '%s'"), classname);
|
||||
wxFAIL_MSG(_T("something is very wrong"));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user