diff --git a/contrib/include/wx/fl/newbmpbtn.h b/contrib/include/wx/fl/newbmpbtn.h index 455b54aad5..fac871be73 100644 --- a/contrib/include/wx/fl/newbmpbtn.h +++ b/contrib/include/wx/fl/newbmpbtn.h @@ -19,6 +19,9 @@ #include "wx/button.h" #include "wx/string.h" +// defaults +#define NB_DEFAULT_MARGIN 2 + // button label-text alignment types #define NB_ALIGN_TEXT_RIGHT 0 @@ -111,8 +114,8 @@ public: bool isFlat = TRUE, // this is the default type of fired events int firedEventType = wxEVT_COMMAND_MENU_SELECTED, - int marginX = 2, - int marginY = 2, + int marginX = NB_DEFAULT_MARGIN, + int marginY = NB_DEFAULT_MARGIN, int textToLabelGap = 2, bool isSticky = FALSE ); @@ -125,8 +128,8 @@ public: bool isFlat = TRUE, // this is the default type of fired events int firedEventType = wxEVT_COMMAND_MENU_SELECTED, - int marginX = 2, - int marginY = 2, + int marginX = NB_DEFAULT_MARGIN, + int marginY = NB_DEFAULT_MARGIN, int textToLabelGap = 2, bool isSticky = FALSE ); @@ -143,8 +146,8 @@ public: // Sets the text alignment and margins. virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM, - int marginX = 2, - int marginY = 2, + int marginX = NB_DEFAULT_MARGIN, + int marginY = NB_DEFAULT_MARGIN, int textToLabelGap = 2); // Draws the decorations. @@ -194,6 +197,11 @@ public: // Responds to a kill focus event. void OnKillFocus( wxFocusEvent& event ); + // Maps bitmap to current system colours on Windows +#ifdef __WXMSW__ + WXHBITMAP MapBitmap(WXHBITMAP bitmap, int width, int height); +#endif + DECLARE_EVENT_TABLE() }; diff --git a/contrib/src/fl/newbmpbtn.cpp b/contrib/src/fl/newbmpbtn.cpp index b811e40c12..138e9cf1c6 100644 --- a/contrib/src/fl/newbmpbtn.cpp +++ b/contrib/src/fl/newbmpbtn.cpp @@ -27,6 +27,10 @@ #include "wx/fl/newbmpbtn.h" #include "wx/utils.h" // import wxMin,wxMax macros +#ifdef __WXMSW__ +#include "wx/msw/private.h" +#endif + ///////////// button-label rendering helpers ////////////////// static int* create_array( int width, int height, int fill = 0 ) @@ -516,7 +520,14 @@ void wxNewBitmapButton::RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp, destBmp->GetHeight() + mMarginY*2, 0 ); } + destDc.SelectObject( wxNullBitmap ); + +#ifdef __WXMSW__ + // Map to system colours + (void) MapBitmap(destBmp->GetHBITMAP(), destBmp->GetWidth(), destBmp->GetHeight()); +#endif } + void wxNewBitmapButton::RenderAllLabelImages() { if ( !mIsCreated ) @@ -802,3 +813,49 @@ void wxNewBitmapButton::OnKillFocus( wxFocusEvent& event ) wxMessageBox("kill-focus for button!"); } +#ifdef __WXMSW__ +WXHBITMAP wxNewBitmapButton::MapBitmap(WXHBITMAP bitmap, int width, int height) +{ + MemoryHDC hdcMem; + + if ( !hdcMem ) + { + wxLogLastError(_T("CreateCompatibleDC")); + + return bitmap; + } + + SelectInHDC bmpInHDC(hdcMem, (HBITMAP)bitmap); + + if ( !bmpInHDC ) + { + wxLogLastError(_T("SelectObject")); + + return bitmap; + } + + wxCOLORMAP *cmap = wxGetStdColourMap(); + + for ( int i = 0; i < width; i++ ) + { + for ( int j = 0; j < height; j++ ) + { + COLORREF pixel = ::GetPixel(hdcMem, i, j); + + for ( size_t k = 0; k < wxSTD_COL_MAX; k++ ) + { + COLORREF col = cmap[k].from; + if ( abs(GetRValue(pixel) - GetRValue(col)) < 10 && + abs(GetGValue(pixel) - GetGValue(col)) < 10 && + abs(GetBValue(pixel) - GetBValue(col)) < 10 ) + { + ::SetPixel(hdcMem, i, j, cmap[k].to); + break; + } + } + } + } + + return bitmap; +} +#endif diff --git a/distrib/msw/tmake/filelist.txt b/distrib/msw/tmake/filelist.txt index 9f182dd531..9b8a71cffb 100644 --- a/distrib/msw/tmake/filelist.txt +++ b/distrib/msw/tmake/filelist.txt @@ -306,7 +306,7 @@ helpchm.cpp MSW Win32Only helpwin.cpp MSW icon.cpp MSW LowLevel imaglist.cpp MSW Win32Only,LowLevel -iniconf.cpp MSW NotWin32 +iniconf.cpp MSW joystick.cpp MSW listbox.cpp MSW listctrl.cpp MSW Win32Only diff --git a/docs/changes.txt b/docs/changes.txt index f016dfaf96..0313ed5c8d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -151,6 +151,8 @@ wxMSW: - the separators are not seen behind the controls added to the toolbar any more - wxLB_SORT style can be used with wxCheckListBox - wxWindowDC and wxClientDC::GetSize() works correctly now +- Added wxTB_NODIVIDER and wxTB_NOALIGN so native toolbar can + be used in FL wxGTK: diff --git a/docs/latex/wx/toolbar.tex b/docs/latex/wx/toolbar.tex index 314f6af404..c0daf6f9ed 100644 --- a/docs/latex/wx/toolbar.tex +++ b/docs/latex/wx/toolbar.tex @@ -53,8 +53,10 @@ of a "separator" is a vertical line under Windows95 vs. simple space under GTK e \twocolitem{\windowstyle{wxTB\_VERTICAL}}{Specifies vertical layout (not available for the GTK and Windows 95 toolbar).} \twocolitem{\windowstyle{wxTB\_3DBUTTONS}}{Gives wxToolBarSimple a mild 3D look to its buttons.} -\twocolitem{\windowstyle{wxTB\_TEXT}}{Show the text in the toolbar buttons, by default only icons are shown} -\twocolitem{\windowstyle{wxTB\_NOICONS}}{Doesn't show the icons in the toolbar buttons, by default they are shown} +\twocolitem{\windowstyle{wxTB\_TEXT}}{Show the text in the toolbar buttons; by default only icons are shown.} +\twocolitem{\windowstyle{wxTB\_NOICONS}}{Specifies no icons in the toolbar buttons; by default they are shown.} +\twocolitem{\windowstyle{wxTB\_NODIVIDER}}{Specifies no divider above the toolbar; by default it is shown. Windows only.} +\twocolitem{\windowstyle{wxTB\_NOALIGN}}{Specifies no alignment with the parent window. Windows only.} \end{twocollist} See also \helpref{window styles overview}{windowstyles}. Note that the Win32 diff --git a/include/wx/defs.h b/include/wx/defs.h index 8033d8540d..464d617096 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1122,6 +1122,8 @@ enum wxBorder #define wxTB_DOCKABLE 0x0040 // use native docking under GTK #define wxTB_NOICONS 0x0080 // don't show the icons #define wxTB_TEXT 0x0100 // show the text +#define wxTB_NODIVIDER 0x0200 // don't show the divider (Windows) +#define wxTB_NOALIGN 0x0400 // no automatic alignment (Windows) /* * wxStatusBar95 flags diff --git a/include/wx/strconv.h b/include/wx/strconv.h index 9ed3790af0..a329062f5c 100644 --- a/include/wx/strconv.h +++ b/include/wx/strconv.h @@ -131,6 +131,8 @@ public: virtual size_t MB2WC(wchar_t *buf, const char *psz, size_t n) const; virtual size_t WC2MB(char *buf, const wchar_t *psz, size_t n) const; + void Clear() ; + private: void SetName(const wxChar *charset); diff --git a/src/common/fontmap.cpp b/src/common/fontmap.cpp index 022d92d0e3..ab990ef8eb 100644 --- a/src/common/fontmap.cpp +++ b/src/common/fontmap.cpp @@ -36,6 +36,7 @@ #include "wx/intl.h" #endif // PCH +#include "wx/module.h" #include "wx/fontmap.h" #if wxUSE_CONFIG @@ -181,11 +182,23 @@ static const wxChar* gs_encodingNames[] = // global data // ---------------------------------------------------------------------------- -// private object -static wxFontMapper gs_fontMapper; +wxFontMapper * wxTheFontMapper = NULL; -// and public pointer -wxFontMapper * wxTheFontMapper = &gs_fontMapper; +class wxFontMapperModule: public wxModule +{ +public: + wxFontMapperModule() : wxModule() { } + virtual bool OnInit() { wxTheFontMapper = new wxFontMapper; return TRUE; } + virtual void OnExit() + { + delete wxTheFontMapper; + wxTheFontMapper = NULL; + } + + DECLARE_DYNAMIC_CLASS(wxFontMapperModule) +}; + +IMPLEMENT_DYNAMIC_CLASS(wxFontMapperModule, wxModule) // ---------------------------------------------------------------------------- // private classes diff --git a/src/common/mimecmn.cpp b/src/common/mimecmn.cpp index 6ee6a7a7fa..a760575ad9 100644 --- a/src/common/mimecmn.cpp +++ b/src/common/mimecmn.cpp @@ -626,6 +626,7 @@ public: { delete gs_mimeTypesManager.m_impl; gs_mimeTypesManager.m_impl = NULL; + gs_mimeTypesManager.m_fallbacks.Clear(); } } diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index c8207ca44e..d613e6174a 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -42,6 +42,7 @@ #include #include +#include "wx/module.h" #include "wx/strconv.h" // ---------------------------------------------------------------------------- @@ -58,6 +59,22 @@ WXDLLEXPORT_DATA(wxMBConv *) wxConvCurrent = &wxConvLibc; +class wxStrConvModule: public wxModule +{ +public: + wxStrConvModule() : wxModule() { } + virtual bool OnInit() { return TRUE; } + virtual void OnExit() + { + wxConvLocal.Clear(); + } + + DECLARE_DYNAMIC_CLASS(wxStrConvModule) +}; + +IMPLEMENT_DYNAMIC_CLASS(wxStrConvModule, wxModule) + + // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- @@ -898,8 +915,17 @@ wxCSConv::wxCSConv(const wxChar *charset) wxCSConv::~wxCSConv() { - free(m_name); - delete m_cset; + Clear(); +} + +void wxCSConv::Clear() +{ + if (m_name) + free(m_name); + if (m_cset) + delete m_cset; + m_name = NULL; + m_cset = NULL; } void wxCSConv::SetName(const wxChar *charset) diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 004af499a5..7c6515ff12 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -262,6 +262,10 @@ bool wxToolBar::Create(wxWindow *parent, msflags |= TBSTYLE_FLAT | TBSTYLE_TRANSPARENT; } } + if (style & wxTB_NODIVIDER) + msflags |= CCS_NODIVIDER; + if (style & wxTB_NOALIGN) + msflags |= CCS_NOPARENTALIGN; // MSW-specific initialisation if ( !wxControl::MSWCreateControl(TOOLBARCLASSNAME, msflags) ) @@ -1184,7 +1188,11 @@ bool wxToolBar::HandleSize(WXWPARAM wParam, WXLPARAM lParam) if ( m_maxRows ) { // FIXME: 6 is hardcoded separator line height... - h += 6; + //h += 6; + if (HasFlag(wxTB_NODIVIDER)) + h += 3; + else + h += 6; h *= m_maxRows; } }