#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
+
+// 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
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
// ----------------------------------------------------------------------------
#define CONST_CAST ((wxFileConfig *)this)->
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+#ifndef MAX_PATH
+ #define MAX_PATH 512
+#endif
+
// ----------------------------------------------------------------------------
// global functions declarations
// ----------------------------------------------------------------------------
#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 << '\\';
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;
}
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();
#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))
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;
((wxLogWindow *)m_pOldLog)->DoLog(level, szString);
}
- // 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 ) {
- // and this will format it nicely and call our DoLogString()
- wxLog::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
+ case wxLOG_Trace:
+ break;
+
+ default:
+ // and this will format it nicely and call our DoLogString()
+ wxLog::DoLog(level, szString);
+ }
}
m_bHasMessages = TRUE;
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
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);
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
{
// 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;
}
}
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);
+ MoveWindow((HWND)GetHWND(), x1, y1,
+ control_width, control_height, TRUE);
}
WXHBRUSH wxChoice::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
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)
}
// 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);
*/
}
-void wxComboBox::SetInsertionPointEnd(void)
+void wxComboBox::SetInsertionPointEnd()
{
/*
long pos = GetLastPosition();
*/
}
-long wxComboBox::GetInsertionPoint(void) const
+long wxComboBox::GetInsertionPoint() const
{
/*
DWORD Pos=(DWORD)SendMessage((HWND) GetHWND(), EM_GETSEL, 0, 0L);
return 0;
}
-long wxComboBox::GetLastPosition(void) const
+long wxComboBox::GetLastPosition() const
{
/*
HWND hWnd = (HWND) GetHWND();
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);
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;
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;
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;
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;
// 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);
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());
- if (w1 < 0)
- w1 = (int)(current_width + 3*cx) ;
- if (h1<0)
- h1 = (int)(cyf*EDIT_CONTROL_FACTOR) ;
- MoveWindow(button, x1, y1, w1, h1, TRUE);
+ GetTextExtent(wxGetWindowText(m_hWnd), ¤t_width, &cyf,
+ NULL,NULL,GetFont());
+ if ( w1 < 0 )
+ w1 = current_width + 3*cx;
+ if ( h1 < 0 )
+ 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,
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))
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);
#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