1) minor modifications in fileconf.cpp
2) new MSW function (private.h): wxGetWindowText() which works with wxString instead of (horror) fixed size buffers. All calls to ::GetWindowText() should be replaced with this! 3) remains of casts to float in different wxControl classes removed, (EDIT|BUTTON)_HEIGHT_FROM_CHAR_HEIGHT macros introduced (could be made inline functions as well...) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@765 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -126,8 +126,9 @@ VOID WINAPI ibAdjustWindowRect( HWND hWnd, LPRECT lprc ) ;
|
||||
#define MEANING_CHARACTER '0'
|
||||
#define DEFAULT_ITEM_WIDTH 200
|
||||
#define DEFAULT_ITEM_HEIGHT 80
|
||||
#define EDIT_CONTROL_FACTOR (15.0/10.0)
|
||||
|
||||
// Scale font to get edit control height
|
||||
#define EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy) (3*(cy)/2)
|
||||
|
||||
// Generic subclass proc, for panel item moving/sizing and intercept
|
||||
// EDIT control VK_RETURN messages
|
||||
@@ -147,6 +148,9 @@ WXDLLEXPORT_DATA(extern HINSTANCE) wxhInstance;
|
||||
wxWindow* WXDLLEXPORT wxFindControlFromHandle(WXHWND hWnd);
|
||||
void WXDLLEXPORT wxAddControlHandle(WXHWND hWnd, wxWindow *item);
|
||||
|
||||
// Safely get the window text (i.e. without using fixed size buffer)
|
||||
extern wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd);
|
||||
|
||||
#if !defined(__WIN32__) && !defined(WS_EX_CLIENTEDGE)
|
||||
#define WS_EX_CLIENTEDGE 0
|
||||
#endif
|
||||
|
@@ -54,6 +54,13 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
#define CONST_CAST ((wxFileConfig *)this)->
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 512
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global functions declarations
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -87,15 +94,10 @@ wxString wxFileConfig::GetGlobalDir()
|
||||
#ifdef __UNIX__
|
||||
strDir = "/etc/";
|
||||
#elif defined(__WXSTUBS__)
|
||||
// TODO
|
||||
wxASSERT( TRUE ) ;
|
||||
wxASSERT_MSG( FALSE, "TODO" ) ;
|
||||
#else // Windows
|
||||
#ifndef _MAX_PATH
|
||||
#define _MAX_PATH 512
|
||||
#endif
|
||||
|
||||
char szWinDir[_MAX_PATH];
|
||||
::GetWindowsDirectory(szWinDir, _MAX_PATH);
|
||||
char szWinDir[MAX_PATH];
|
||||
::GetWindowsDirectory(szWinDir, MAX_PATH);
|
||||
|
||||
strDir = szWinDir;
|
||||
strDir << '\\';
|
||||
@@ -108,29 +110,7 @@ wxString wxFileConfig::GetLocalDir()
|
||||
{
|
||||
wxString strDir;
|
||||
|
||||
#ifdef __UNIX__
|
||||
const char *szHome = getenv("HOME");
|
||||
if ( szHome == NULL ) {
|
||||
// we're homeless...
|
||||
wxLogWarning(_("can't find user's HOME, using current directory."));
|
||||
strDir = ".";
|
||||
}
|
||||
else
|
||||
strDir = szHome;
|
||||
strDir << '/'; // a double slash is no problem, a missin one yes
|
||||
#else // Windows
|
||||
#ifdef __WIN32__
|
||||
const char *szHome = getenv("HOMEDRIVE");
|
||||
if ( szHome != NULL )
|
||||
strDir << szHome;
|
||||
szHome = getenv("HOMEPATH");
|
||||
if ( szHome != NULL )
|
||||
strDir << szHome;
|
||||
#else // Win16
|
||||
// Win16 has no idea about home, so use the current directory instead
|
||||
strDir = ".\\";
|
||||
#endif // WIN16/32
|
||||
#endif // UNIX/Win
|
||||
wxGetHomeDir(&strDir);
|
||||
|
||||
return strDir;
|
||||
}
|
||||
|
@@ -256,7 +256,11 @@ void wxColourDatabase::Initialize ()
|
||||
|
||||
wxColour *wxColourDatabase::FindColour(const wxString& colour)
|
||||
{
|
||||
wxNode *node = Find((char *) (const char *)colour);
|
||||
// VZ: make the comparaison case insensitive
|
||||
wxString str = colour;
|
||||
str.MakeUpper();
|
||||
|
||||
wxNode *node = Find(str);
|
||||
if (node)
|
||||
return (wxColour *)node->Data();
|
||||
|
||||
@@ -290,6 +294,11 @@ wxColour *wxColourDatabase::FindColour(const wxString& colour)
|
||||
#ifdef __WXMOTIF__
|
||||
Display *display = XtDisplay((Widget) wxTheApp->GetTopLevelWidget()) ;
|
||||
#endif
|
||||
#ifdef __XVIEW__
|
||||
Xv_Screen screen = xv_get(xview_server, SERVER_NTH_SCREEN, 0);
|
||||
Xv_opaque root_window = xv_get(screen, XV_ROOT);
|
||||
Display *display = (Display *)xv_get(root_window, XV_DISPLAY);
|
||||
#endif
|
||||
|
||||
/* MATTHEW: [4] Use wxGetMainColormap */
|
||||
if (!XParseColor(display, (Colormap) wxTheApp->GetMainColormap((WXDisplay*) display), colour,&xcolour))
|
||||
|
@@ -268,8 +268,9 @@ wxLog *wxLog::GetActiveTarget()
|
||||
wxLog *wxLog::SetActiveTarget(wxLog *pLogger, bool bNoFlashOld)
|
||||
{
|
||||
// flush the old messages before changing
|
||||
if ( (ms_pLogger != NULL) && !bNoFlashOld )
|
||||
if ( (ms_pLogger != NULL) && !bNoFlashOld ) {
|
||||
ms_pLogger->Flush();
|
||||
}
|
||||
|
||||
wxLog *pOldLogger = ms_pLogger;
|
||||
ms_pLogger = pLogger;
|
||||
@@ -737,14 +738,30 @@ void wxLogWindow::DoLog(wxLogLevel level, const char *szString)
|
||||
((wxLogWindow *)m_pOldLog)->DoLog(level, szString);
|
||||
}
|
||||
|
||||
if ( m_pLogFrame ) {
|
||||
switch ( level ) {
|
||||
case wxLOG_Status:
|
||||
// by default, these messages are ignored by wxLog, so process
|
||||
// them ourselves
|
||||
{
|
||||
wxString str = TimeStamp();
|
||||
str << _("Status: ") << szString;
|
||||
DoLogString(str);
|
||||
}
|
||||
break;
|
||||
|
||||
// don't put trace messages in the text window for 2 reasons:
|
||||
// 1) there are too many of them
|
||||
// 2) they may provoke other trace messages thus sending a program into an
|
||||
// infinite loop
|
||||
if ( m_pLogFrame && level != wxLOG_Trace ) {
|
||||
// 2) they may provoke other trace messages thus sending a program
|
||||
// into an infinite loop
|
||||
case wxLOG_Trace:
|
||||
break;
|
||||
|
||||
default:
|
||||
// and this will format it nicely and call our DoLogString()
|
||||
wxLog::DoLog(level, szString);
|
||||
}
|
||||
}
|
||||
|
||||
m_bHasMessages = TRUE;
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
|
||||
#endif
|
||||
|
||||
#define BUTTON_HEIGHT_FACTOR (EDIT_CONTROL_FACTOR * 1.1)
|
||||
#define BUTTON_HEIGHT_FROM_CHAR_HEIGHT(cy) (11*EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)/10)
|
||||
|
||||
// Buttons
|
||||
|
||||
@@ -135,7 +135,7 @@ void wxButton::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
actualHeight = hh;
|
||||
else if (height == -1)
|
||||
{
|
||||
actualHeight = (int)(cyf*BUTTON_HEIGHT_FACTOR) ;
|
||||
actualHeight = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(cyf);
|
||||
}
|
||||
|
||||
MoveWindow((HWND) GetHWND(), x1, y1, actualWidth, actualHeight, TRUE);
|
||||
|
@@ -204,7 +204,7 @@ void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
int cy;
|
||||
wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
|
||||
|
||||
float control_width, control_height;
|
||||
int control_width, control_height;
|
||||
|
||||
// Ignore height parameter because height doesn't
|
||||
// mean 'initially displayed' height, it refers to the
|
||||
@@ -219,20 +219,23 @@ void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
// Find the longest string
|
||||
if (m_noStrings == 0)
|
||||
control_width = (float)100.0;
|
||||
{
|
||||
control_width = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
int len, ht;
|
||||
float longest = (float)0.0;
|
||||
int longest = 0;
|
||||
int i;
|
||||
for (i = 0; i < m_noStrings; i++)
|
||||
{
|
||||
wxString str(GetString(i));
|
||||
GetTextExtent(str, &len, &ht, NULL, NULL,GetFont());
|
||||
if ( len > longest) longest = len;
|
||||
if ( len > longest)
|
||||
longest = len;
|
||||
}
|
||||
|
||||
control_width = (float)(int)(longest + cx*5);
|
||||
control_width = longest + cx*5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,25 +243,26 @@ void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
if (h1 <= 0)
|
||||
{
|
||||
if (m_noStrings == 0)
|
||||
h1 = (int)(EDIT_CONTROL_FACTOR*cy*10.0);
|
||||
else h1 = (int)(EDIT_CONTROL_FACTOR*cy*(wxMin(10, m_noStrings) + 1));
|
||||
h1 = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*10;
|
||||
else
|
||||
h1 = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*(wxMin(10, m_noStrings) + 1);
|
||||
}
|
||||
|
||||
// If non-default width...
|
||||
if (w1 >= 0)
|
||||
control_width = (float)w1;
|
||||
control_width = w1;
|
||||
|
||||
control_height = (float)h1;
|
||||
control_height = h1;
|
||||
|
||||
// Calculations may have made text size too small
|
||||
if (control_height <= 0)
|
||||
control_height = (float)(int)(cy*EDIT_CONTROL_FACTOR) ;
|
||||
control_height = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
|
||||
|
||||
if (control_width <= 0)
|
||||
control_width = (float)100.0;
|
||||
control_width = 100;
|
||||
|
||||
MoveWindow((HWND)GetHWND(), x1, y1,
|
||||
(int)control_width, (int)control_height, TRUE);
|
||||
control_width, control_height, TRUE);
|
||||
}
|
||||
|
||||
WXHBRUSH wxChoice::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
||||
|
@@ -139,10 +139,9 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxString wxComboBox::GetValue(void) const
|
||||
wxString wxComboBox::GetValue() const
|
||||
{
|
||||
GetWindowText((HWND) GetHWND(), wxBuffer, 500);
|
||||
return wxString(wxBuffer);
|
||||
return wxGetWindowText(GetHWND());
|
||||
}
|
||||
|
||||
void wxComboBox::SetValue(const wxString& value)
|
||||
@@ -179,19 +178,19 @@ void wxComboBox::SetValue(const wxString& value)
|
||||
}
|
||||
|
||||
// Clipboard operations
|
||||
void wxComboBox::Copy(void)
|
||||
void wxComboBox::Copy()
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
SendMessage(hWnd, WM_COPY, 0, 0L);
|
||||
}
|
||||
|
||||
void wxComboBox::Cut(void)
|
||||
void wxComboBox::Cut()
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
SendMessage(hWnd, WM_CUT, 0, 0L);
|
||||
}
|
||||
|
||||
void wxComboBox::Paste(void)
|
||||
void wxComboBox::Paste()
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
SendMessage(hWnd, WM_PASTE, 0, 0L);
|
||||
@@ -219,7 +218,7 @@ void wxComboBox::SetInsertionPoint(long pos)
|
||||
*/
|
||||
}
|
||||
|
||||
void wxComboBox::SetInsertionPointEnd(void)
|
||||
void wxComboBox::SetInsertionPointEnd()
|
||||
{
|
||||
/*
|
||||
long pos = GetLastPosition();
|
||||
@@ -227,7 +226,7 @@ void wxComboBox::SetInsertionPointEnd(void)
|
||||
*/
|
||||
}
|
||||
|
||||
long wxComboBox::GetInsertionPoint(void) const
|
||||
long wxComboBox::GetInsertionPoint() const
|
||||
{
|
||||
/*
|
||||
DWORD Pos=(DWORD)SendMessage((HWND) GetHWND(), EM_GETSEL, 0, 0L);
|
||||
@@ -236,7 +235,7 @@ long wxComboBox::GetInsertionPoint(void) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
long wxComboBox::GetLastPosition(void) const
|
||||
long wxComboBox::GetLastPosition() const
|
||||
{
|
||||
/*
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
|
@@ -198,7 +198,7 @@ int wxNotebook::GetRowCount() const
|
||||
|
||||
int wxNotebook::SetSelection(int nPage)
|
||||
{
|
||||
wxASSERT( IS_VALID_PAGE(nPage) );
|
||||
wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, "notebook page out of range" );
|
||||
|
||||
ChangePage(m_nSelection, nPage);
|
||||
|
||||
@@ -217,7 +217,7 @@ void wxNotebook::AdvanceSelection(bool bForward)
|
||||
|
||||
bool wxNotebook::SetPageText(int nPage, const wxString& strText)
|
||||
{
|
||||
wxASSERT( IS_VALID_PAGE(nPage) );
|
||||
wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, "notebook page out of range" );
|
||||
|
||||
TC_ITEM tcItem;
|
||||
tcItem.mask = TCIF_TEXT;
|
||||
@@ -228,7 +228,7 @@ bool wxNotebook::SetPageText(int nPage, const wxString& strText)
|
||||
|
||||
wxString wxNotebook::GetPageText(int nPage) const
|
||||
{
|
||||
wxASSERT( IS_VALID_PAGE(nPage) );
|
||||
wxCHECK_MSG( IS_VALID_PAGE(nPage), "", "notebook page out of range" );
|
||||
|
||||
char buf[256];
|
||||
TC_ITEM tcItem;
|
||||
@@ -245,7 +245,7 @@ wxString wxNotebook::GetPageText(int nPage) const
|
||||
|
||||
int wxNotebook::GetPageImage(int nPage) const
|
||||
{
|
||||
wxASSERT( IS_VALID_PAGE(nPage) );
|
||||
wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, "notebook page out of range" );
|
||||
|
||||
TC_ITEM tcItem;
|
||||
tcItem.mask = TCIF_IMAGE;
|
||||
@@ -255,7 +255,7 @@ int wxNotebook::GetPageImage(int nPage) const
|
||||
|
||||
bool wxNotebook::SetPageImage(int nPage, int nImage)
|
||||
{
|
||||
wxASSERT( IS_VALID_PAGE(nPage) );
|
||||
wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, "notebook page out of range" );
|
||||
|
||||
TC_ITEM tcItem;
|
||||
tcItem.mask = TCIF_IMAGE;
|
||||
@@ -277,7 +277,7 @@ void wxNotebook::SetImageList(wxImageList* imageList)
|
||||
// remove one page from the notebook
|
||||
bool wxNotebook::DeletePage(int nPage)
|
||||
{
|
||||
wxCHECK( IS_VALID_PAGE(nPage), FALSE );
|
||||
wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, "notebook page out of range" );
|
||||
|
||||
TabCtrl_DeleteItem(m_hwnd, nPage);
|
||||
|
||||
|
@@ -125,24 +125,22 @@ void wxStaticBox::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
GetSize(&w1, &h1);
|
||||
}
|
||||
|
||||
char buf[300];
|
||||
|
||||
int current_width;
|
||||
|
||||
int cx;
|
||||
int cy;
|
||||
int cyf;
|
||||
|
||||
HWND button = (HWND)m_hWnd;
|
||||
wxGetCharSize(GetHWND(), &cx, &cy,GetFont());
|
||||
|
||||
GetWindowText(button, buf, 300);
|
||||
GetTextExtent(buf, ¤t_width, &cyf,NULL,NULL,GetFont());
|
||||
GetTextExtent(wxGetWindowText(m_hWnd), ¤t_width, &cyf,
|
||||
NULL,NULL,GetFont());
|
||||
if ( w1 < 0 )
|
||||
w1 = (int)(current_width + 3*cx) ;
|
||||
w1 = current_width + 3*cx;
|
||||
if ( h1 < 0 )
|
||||
h1 = (int)(cyf*EDIT_CONTROL_FACTOR) ;
|
||||
MoveWindow(button, x1, y1, w1, h1, TRUE);
|
||||
h1 = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cyf);
|
||||
|
||||
MoveWindow((HWND)m_hWnd, x1, y1, w1, h1, TRUE);
|
||||
}
|
||||
|
||||
WXHBRUSH wxStaticBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
||||
|
@@ -321,7 +321,7 @@ void wxTextCtrl::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
|
||||
wxGetCharSize(GetHWND(), &cx, &cy,GetFont());
|
||||
|
||||
float control_width, control_height, control_x, control_y;
|
||||
int control_width, control_height, control_x, control_y;
|
||||
|
||||
// If we're prepared to use the existing size, then...
|
||||
if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
|
||||
@@ -333,17 +333,17 @@ void wxTextCtrl::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
if (w1<=0)
|
||||
w1 = DEFAULT_ITEM_WIDTH;
|
||||
|
||||
control_x = (float)x1;
|
||||
control_y = (float)y1;
|
||||
control_width = (float)w1;
|
||||
control_height = (float)h1;
|
||||
control_x = x1;
|
||||
control_y = y1;
|
||||
control_width = w1;
|
||||
control_height = h1;
|
||||
|
||||
// Calculations may have made text size too small
|
||||
if (control_height <= 0)
|
||||
control_height = (float)(int)(cy*EDIT_CONTROL_FACTOR) ;
|
||||
control_height = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
|
||||
|
||||
if (control_width <= 0)
|
||||
control_width = (float)DEFAULT_ITEM_WIDTH;
|
||||
control_width = DEFAULT_ITEM_WIDTH;
|
||||
|
||||
MoveWindow((HWND) GetHWND(), (int)control_x, (int)control_y,
|
||||
(int)control_width, (int)control_height, TRUE);
|
||||
|
@@ -731,6 +731,16 @@ bool wxDirExists(const wxString& dir)
|
||||
#endif
|
||||
}
|
||||
|
||||
wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd)
|
||||
{
|
||||
wxString str;
|
||||
int len = GetWindowTextLength((HWND)hWnd) + 1;
|
||||
GetWindowText((HWND)hWnd, str.GetWriteBuf(len), len);
|
||||
str.UngetWriteBuf();
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
#if 0
|
||||
//------------------------------------------------------------------------
|
||||
// wild character routines
|
||||
|
Reference in New Issue
Block a user