// 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);
// 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>
*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__)
#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;
}
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
wxTheBitmapList->AddBitmap(this);
}
-wxBitmap::wxBitmap(const wxBitmap& bitmap)
+wxBitmap::wxBitmap(const wxIcon& icon)
{
- 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());
+ if ( wxTheBitmapList )
+ wxTheBitmapList->AddBitmap(this);
- ::DeleteDC(hdc);
+ if ( !icon.Ok() )
+ return;
- SetHBITMAP((WXHBITMAP)hbitmap);
- }
- else
- {
- Ref(bitmap);
- }
+ 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)
+{
+ Ref(bitmap);
if ( wxTheBitmapList )
wxTheBitmapList->AddBitmap(this);
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);
}
}
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;
}
{
// 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;
}
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--;
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;
}
// 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() ) {
// 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");
::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)
{
wxString valueDos = wxTextFile::Translate(value, wxTextFileType_Dos);
- SetWindowText(GetHwnd(), valueDos);
+ if ( valueDos != GetValue() )
+ {
+ SetWindowText(GetHwnd(), valueDos);
- AdjustSpaceLimit();
+ AdjustSpaceLimit();
+ }
}
void wxTextCtrl::WriteText(const wxString& value)