1. undid my wrong fix to wxWindowBase::Centre
2. corrected fatal bug in wxCheckLstBox (double deletion of items) 3. wxTextCtrl::SetValue() only does it if the new text is different from the old one 4. wxBitmap(const wxIcon&) ctor added 5. compilation fixes for VC++ and generic Win32 implementation of wxGetCurrentTime() in timercmn.cpp git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4534 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
fd69e87d25
commit
07cf98cb8e
@ -140,6 +140,11 @@ public:
|
||||
|
||||
// If depth is omitted, will create a bitmap compatible with the display
|
||||
wxBitmap(int width, int height, int depth = -1);
|
||||
|
||||
// we must have this, otherwise icons are silently copied into bitmaps using
|
||||
// the copy ctor but the resulting bitmap is invalid!
|
||||
wxBitmap(const wxIcon& icon);
|
||||
|
||||
~wxBitmap();
|
||||
|
||||
virtual bool Create(int width, int height, int depth = -1);
|
||||
|
@ -40,12 +40,15 @@
|
||||
// configure might have found it already for us
|
||||
#ifndef HAVE_LOCALTIME
|
||||
#define HAVE_LOCALTIME
|
||||
|
||||
// TODO add test for broken compilers here if needed
|
||||
#define WX_GMTOFF_IN_TM
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// TODO: #define WX_GMTOFF_IN_TM for Windows compilers which have it here
|
||||
|
||||
#if defined(__WIN32__) && !defined(WX_GMTOFF_IN_TM)
|
||||
#include <winbase.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_GETTIMEOFDAY)
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
@ -198,11 +201,9 @@ bool wxGetLocalTime(long *timeZone, int *dstObserved)
|
||||
*timeZone = 60*tb.timezone;
|
||||
*dstObserved = tb.dstflag;
|
||||
}
|
||||
#else
|
||||
// special hacks for known compilers - I wonder if this is still needed,
|
||||
// i.e. if there are any of them which don't support localtime()? (VZ)
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
#else // no standard function return tz info
|
||||
// special hacks for known compilers
|
||||
#if defined(__BORLANDC__) || defined(__VISUALC__)
|
||||
*timeZone = _timezone;
|
||||
*dstObserved = _daylight;
|
||||
#elif defined(__SALFORDC__)
|
||||
@ -211,10 +212,29 @@ bool wxGetLocalTime(long *timeZone, int *dstObserved)
|
||||
#elif defined(__VISAGECPP__)
|
||||
*timeZone = _timezone;
|
||||
*dstObserved = daylight;
|
||||
#elif defined(__WIN32__)
|
||||
TIME_ZONE_INFORMATION tzInfo;
|
||||
switch ( GetTimeZoneInformation(&tzInfo) )
|
||||
{
|
||||
default:
|
||||
wxFAIL_MSG(_T("unknown GetTimeZoneInformation return code"));
|
||||
// fall through
|
||||
|
||||
case TIME_ZONE_ID_UNKNOWN:
|
||||
case TIME_ZONE_ID_STANDARD:
|
||||
*dstObserved = FALSE;
|
||||
break;
|
||||
|
||||
case TIME_ZONE_ID_DAYLIGHT:
|
||||
*dstObserved = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
*timeZone = 60*tzInfo.Bias;
|
||||
#else
|
||||
wxFAIL_MSG(_T("wxGetLocalTime() not implemented"));
|
||||
#endif // compiler
|
||||
#endif
|
||||
#endif // all ways in the known Universe to get tz info
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -354,9 +354,8 @@ void wxWindowBase::Centre(int direction)
|
||||
yNew += posParent.y;
|
||||
}
|
||||
|
||||
// move the centre of this window to this position (not the upper left
|
||||
// corner as it was done before)
|
||||
Move(xNew - width / 2, yNew - height / 2);
|
||||
// move the centre of this window to this position
|
||||
Move(xNew, yNew);
|
||||
}
|
||||
|
||||
// fits the window around the children
|
||||
|
@ -99,26 +99,44 @@ wxBitmap::wxBitmap()
|
||||
wxTheBitmapList->AddBitmap(this);
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap(const wxIcon& icon)
|
||||
{
|
||||
if ( wxTheBitmapList )
|
||||
wxTheBitmapList->AddBitmap(this);
|
||||
|
||||
if ( !icon.Ok() )
|
||||
return;
|
||||
|
||||
int width = icon.GetWidth(),
|
||||
height = icon.GetHeight();
|
||||
|
||||
HDC hdc = ::CreateCompatibleDC(NULL); // screen DC
|
||||
HBITMAP hbitmap = ::CreateCompatibleBitmap(hdc, width, height);
|
||||
HBITMAP hbmpOld = (HBITMAP)::SelectObject(hdc, hbitmap);
|
||||
|
||||
HICON hicon = (HICON) icon.GetHICON();
|
||||
#if defined(__WIN32__) && !defined(__SC__) && !defined(__TWIN32__)
|
||||
::DrawIconEx(hdc, 0, 0, hicon, width, height, 0, 0, DI_NORMAL);
|
||||
#else
|
||||
::DrawIcon(hdc, 0, 0, hicon);
|
||||
#endif
|
||||
|
||||
::SelectObject(hdc, hbmpOld);
|
||||
::DeleteDC(hdc);
|
||||
|
||||
m_refData = new wxBitmapRefData;
|
||||
M_BITMAPDATA->m_width = width;
|
||||
M_BITMAPDATA->m_height = height;
|
||||
M_BITMAPDATA->m_depth = wxDisplayDepth();
|
||||
M_BITMAPDATA->m_numColors = 0;
|
||||
|
||||
M_BITMAPDATA->m_hBitmap = (WXHBITMAP)hbitmap;
|
||||
M_BITMAPDATA->m_ok = TRUE;
|
||||
}
|
||||
|
||||
wxBitmap::wxBitmap(const wxBitmap& bitmap)
|
||||
{
|
||||
wxIcon *icon = wxDynamicCast(&bitmap, wxIcon);
|
||||
if ( icon )
|
||||
{
|
||||
HDC hdc = ::CreateCompatibleDC(NULL); // screen DC
|
||||
HBITMAP hbitmap = ::CreateCompatibleBitmap(hdc,
|
||||
icon->GetWidth(),
|
||||
icon->GetHeight());
|
||||
::SelectObject(hdc, hbitmap);
|
||||
::DrawIcon(hdc, 0, 0, (HICON)icon->GetHICON());
|
||||
|
||||
::DeleteDC(hdc);
|
||||
|
||||
SetHBITMAP((WXHBITMAP)hbitmap);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ref(bitmap);
|
||||
}
|
||||
Ref(bitmap);
|
||||
|
||||
if ( wxTheBitmapList )
|
||||
wxTheBitmapList->AddBitmap(this);
|
||||
|
@ -314,7 +314,10 @@ void wxCheckListBox::InsertItems(int nItems, const wxString items[], int pos)
|
||||
for ( i = 0; i < nItems; i++ ) {
|
||||
wxOwnerDrawn *pNewItem = CreateItem((size_t)(pos + i));
|
||||
pNewItem->SetName(items[i]);
|
||||
pNewItem->SetFont(GetFont());
|
||||
|
||||
m_aItems.Insert(pNewItem, (size_t)(pos + i));
|
||||
|
||||
ListBox_SetItemData((HWND)GetHWND(), i + pos, pNewItem);
|
||||
}
|
||||
}
|
||||
@ -323,9 +326,11 @@ void wxCheckListBox::InsertItems(int nItems, const wxString items[], int pos)
|
||||
bool wxCheckListBox::SetFont( const wxFont &font )
|
||||
{
|
||||
size_t i;
|
||||
for (i=0; i < m_aItems.GetCount(); i++)
|
||||
for ( i = 0; i < m_aItems.GetCount(); i++ )
|
||||
m_aItems[i]->SetFont(font);
|
||||
|
||||
wxListBox::SetFont(font);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -200,8 +200,6 @@ bool wxFont::RealizeResource()
|
||||
{
|
||||
// VZ: the old code returned FALSE in this case, but it doesn't seem
|
||||
// to make sense because the font _was_ created
|
||||
wxLogDebug(wxT("Calling wxFont::RealizeResource() twice"));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -256,15 +256,15 @@ void wxListBox::Delete(int N)
|
||||
wxCHECK_RET( N >= 0 && N < m_noItems,
|
||||
wxT("invalid index in wxListBox::Delete") );
|
||||
|
||||
#if wxUSE_OWNER_DRAWN
|
||||
delete m_aItems[N];
|
||||
m_aItems.Remove(N);
|
||||
#else // !wxUSE_OWNER_DRAWN
|
||||
if ( HasClientObjectData() )
|
||||
{
|
||||
delete GetClientObject(N);
|
||||
}
|
||||
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
|
||||
// for owner drawn objects, the data is used for storing wxOwnerDrawn
|
||||
// pointers and we shouldn't touch it
|
||||
#if !wxUSE_OWNER_DRAWN
|
||||
if ( !(m_windowStyle & wxLB_OWNERDRAW) )
|
||||
#endif // !wxUSE_OWNER_DRAWN
|
||||
if ( HasClientObjectData() )
|
||||
{
|
||||
delete GetClientObject(N);
|
||||
}
|
||||
|
||||
SendMessage(GetHwnd(), LB_DELETESTRING, N, 0);
|
||||
m_noItems--;
|
||||
@ -747,13 +747,19 @@ bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item)
|
||||
|
||||
MEASUREITEMSTRUCT *pStruct = (MEASUREITEMSTRUCT *)item;
|
||||
|
||||
HDC hdc = CreateIC(wxT("DISPLAY"), NULL, NULL, 0);
|
||||
|
||||
wxDC dc;
|
||||
dc.SetHDC((WXHDC)CreateIC(wxT("DISPLAY"), NULL, NULL, 0));
|
||||
dc.SetHDC((WXHDC)hdc);
|
||||
dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_ANSI_VAR_FONT));
|
||||
|
||||
pStruct->itemHeight = dc.GetCharHeight() + 2*OWNER_DRAWN_LISTBOX_EXTRA_SPACE;
|
||||
pStruct->itemWidth = dc.GetCharWidth();
|
||||
|
||||
dc.SetHDC(0);
|
||||
|
||||
DeleteDC(hdc);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -140,12 +140,14 @@ bool wxOwnerDrawn::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODSt
|
||||
// using native API because it reckognizes '&'
|
||||
#ifdef O_DRAW_NATIVE_API
|
||||
int nPrevMode = SetBkMode(hdc, TRANSPARENT);
|
||||
HBRUSH hbr = CreateSolidBrush(colBack),
|
||||
hPrevBrush = (HBRUSH) SelectObject(hdc, hbr);
|
||||
HBRUSH hbr = CreateSolidBrush(colBack),
|
||||
hPrevBrush = (HBRUSH)SelectObject(hdc, hbr);
|
||||
|
||||
RECT rectAll = { rc.GetLeft(), rc.GetTop(), rc.GetRight(), rc.GetBottom() };
|
||||
FillRect(hdc, &rectAll, hbr);
|
||||
|
||||
DeleteObject(hbr);
|
||||
|
||||
// use default font if no font set
|
||||
HFONT hfont;
|
||||
if ( m_font.Ok() ) {
|
||||
@ -186,14 +188,19 @@ bool wxOwnerDrawn::OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODSt
|
||||
|
||||
// then draw a check mark into it
|
||||
RECT rect = { 0, 0, GetMarginWidth(), m_nHeight };
|
||||
if ( m_nHeight > 0 )
|
||||
{
|
||||
#ifndef __SC__
|
||||
DrawFrameControl(hdcMem, &rect, DFC_MENU, DFCS_MENUCHECK);
|
||||
DrawFrameControl(hdcMem, &rect, DFC_MENU, DFCS_MENUCHECK);
|
||||
#endif
|
||||
}
|
||||
|
||||
// finally copy it to screen DC and clean up
|
||||
BitBlt(hdc, rc.x, rc.y, GetMarginWidth(), m_nHeight,
|
||||
hdcMem, 0, 0, SRCCOPY);
|
||||
|
||||
DeleteDC(hdcMem);
|
||||
DeleteObject(hbmpCheck);
|
||||
#else
|
||||
// #### to do: perhaps using Marlett font (create equiv. font under X)
|
||||
// wxFAIL("not implemented");
|
||||
|
@ -114,47 +114,16 @@ WXHBRUSH wxStaticBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
||||
::SetBkColor(hdc, wxColourToRGB(colBack));
|
||||
::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
|
||||
|
||||
wxBrush *brush= wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
|
||||
wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
|
||||
|
||||
return (WXHBRUSH)brush->GetResourceHandle();
|
||||
}
|
||||
|
||||
// VZ: this is probably the most commented function in wxWindows, but I still
|
||||
// don't understand what it does and why. Wouldn't it be better to _never_
|
||||
// erase the background here? What would we lose if we didn't do it?
|
||||
// (FIXME)
|
||||
|
||||
// Shouldn't erase the whole window, since the static box must only paint its
|
||||
// outline.
|
||||
void wxStaticBox::OnEraseBackground(wxEraseEvent& event)
|
||||
{
|
||||
// If we don't have this (call Default()), we don't paint the background properly.
|
||||
// If we do have this, we seem to overwrite enclosed controls.
|
||||
// Is it the WS_CLIPCHILDREN style that's causing the problems?
|
||||
// Probably - without this style, the background of the window will show through,
|
||||
// so the control doesn't have to paint it. The window background will always be
|
||||
// painted before all other controls, therefore there are no problems with
|
||||
// controls being hidden by the static box.
|
||||
// So, if we could specify wxCLIP_CHILDREN in window, or not, we could optimise painting better.
|
||||
// We would assume wxCLIP_CHILDREN in a frame and a scrolled window, but not in a panel.
|
||||
// Is this too platform-specific?? What else can we do? Not a lot, since we have to pass
|
||||
// this information from arbitrary wxWindow derivatives, and it depends on what you wish to
|
||||
// do with the windows.
|
||||
// Alternatively, just make sure that wxStaticBox is always at the back! There are probably
|
||||
// few other circumstances where it matters about child clipping. But what about painting onto
|
||||
// to panel, inside a groupbox? Doesn't appear, because the box wipes it out.
|
||||
wxWindow *parent = GetParent();
|
||||
if ( parent && parent->GetHWND() &&
|
||||
(::GetWindowLong(GetHwndOf(parent), GWL_STYLE) & WS_CLIPCHILDREN) )
|
||||
{
|
||||
// TODO: May in fact need to generate a paint event for inside this
|
||||
// control's rectangle, otherwise all controls are going to be clipped -
|
||||
// ugh.
|
||||
|
||||
// let wxControl::OnEraseBackground() do the job
|
||||
event.Skip();
|
||||
}
|
||||
//else: do *not* call event.Skip() or wxControl will erase the background
|
||||
// do nothing - the aim of having this function is to prevent
|
||||
// wxControl::OnEraseBackground() to paint over the control inside the
|
||||
// static box
|
||||
}
|
||||
|
||||
long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
|
@ -296,9 +296,12 @@ void wxTextCtrl::SetValue(const wxString& value)
|
||||
{
|
||||
wxString valueDos = wxTextFile::Translate(value, wxTextFileType_Dos);
|
||||
|
||||
SetWindowText(GetHwnd(), valueDos);
|
||||
if ( valueDos != GetValue() )
|
||||
{
|
||||
SetWindowText(GetHwnd(), valueDos);
|
||||
|
||||
AdjustSpaceLimit();
|
||||
AdjustSpaceLimit();
|
||||
}
|
||||
}
|
||||
|
||||
void wxTextCtrl::WriteText(const wxString& value)
|
||||
|
Loading…
Reference in New Issue
Block a user