Added wxTB_NODIVIDER and wxTB_NOALIGN so native Windows toolbar can

used in FL.
Adjusted Windows toolbar height for wxTB_NODIVIDER style.
Removed some false memory leak reporting from fontmap.cpp, mimecmn.cpp,
strconv.cpp.
Added and used MapBitmap function in newbmpbtn.cpp so the right
colours are used under Windows.
<controversial>Added iniconf.cpp to WIN32 compilation</conroversial>


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14936 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2002-04-04 13:13:51 +00:00
parent 4069916857
commit 65e5084827
11 changed files with 137 additions and 16 deletions

View File

@@ -19,6 +19,9 @@
#include "wx/button.h" #include "wx/button.h"
#include "wx/string.h" #include "wx/string.h"
// defaults
#define NB_DEFAULT_MARGIN 2
// button label-text alignment types // button label-text alignment types
#define NB_ALIGN_TEXT_RIGHT 0 #define NB_ALIGN_TEXT_RIGHT 0
@@ -111,8 +114,8 @@ public:
bool isFlat = TRUE, bool isFlat = TRUE,
// this is the default type of fired events // this is the default type of fired events
int firedEventType = wxEVT_COMMAND_MENU_SELECTED, int firedEventType = wxEVT_COMMAND_MENU_SELECTED,
int marginX = 2, int marginX = NB_DEFAULT_MARGIN,
int marginY = 2, int marginY = NB_DEFAULT_MARGIN,
int textToLabelGap = 2, int textToLabelGap = 2,
bool isSticky = FALSE bool isSticky = FALSE
); );
@@ -125,8 +128,8 @@ public:
bool isFlat = TRUE, bool isFlat = TRUE,
// this is the default type of fired events // this is the default type of fired events
int firedEventType = wxEVT_COMMAND_MENU_SELECTED, int firedEventType = wxEVT_COMMAND_MENU_SELECTED,
int marginX = 2, int marginX = NB_DEFAULT_MARGIN,
int marginY = 2, int marginY = NB_DEFAULT_MARGIN,
int textToLabelGap = 2, int textToLabelGap = 2,
bool isSticky = FALSE bool isSticky = FALSE
); );
@@ -143,8 +146,8 @@ public:
// Sets the text alignment and margins. // Sets the text alignment and margins.
virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM, virtual void SetAlignments( int alignText = NB_ALIGN_TEXT_BOTTOM,
int marginX = 2, int marginX = NB_DEFAULT_MARGIN,
int marginY = 2, int marginY = NB_DEFAULT_MARGIN,
int textToLabelGap = 2); int textToLabelGap = 2);
// Draws the decorations. // Draws the decorations.
@@ -194,6 +197,11 @@ public:
// Responds to a kill focus event. // Responds to a kill focus event.
void OnKillFocus( wxFocusEvent& 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() DECLARE_EVENT_TABLE()
}; };

View File

@@ -27,6 +27,10 @@
#include "wx/fl/newbmpbtn.h" #include "wx/fl/newbmpbtn.h"
#include "wx/utils.h" // import wxMin,wxMax macros #include "wx/utils.h" // import wxMin,wxMax macros
#ifdef __WXMSW__
#include "wx/msw/private.h"
#endif
///////////// button-label rendering helpers ////////////////// ///////////// button-label rendering helpers //////////////////
static int* create_array( int width, int height, int fill = 0 ) 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 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() void wxNewBitmapButton::RenderAllLabelImages()
{ {
if ( !mIsCreated ) if ( !mIsCreated )
@@ -802,3 +813,49 @@ void wxNewBitmapButton::OnKillFocus( wxFocusEvent& event )
wxMessageBox("kill-focus for button!"); 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

View File

@@ -306,7 +306,7 @@ helpchm.cpp MSW Win32Only
helpwin.cpp MSW helpwin.cpp MSW
icon.cpp MSW LowLevel icon.cpp MSW LowLevel
imaglist.cpp MSW Win32Only,LowLevel imaglist.cpp MSW Win32Only,LowLevel
iniconf.cpp MSW NotWin32 iniconf.cpp MSW
joystick.cpp MSW joystick.cpp MSW
listbox.cpp MSW listbox.cpp MSW
listctrl.cpp MSW Win32Only listctrl.cpp MSW Win32Only

View File

@@ -151,6 +151,8 @@ wxMSW:
- the separators are not seen behind the controls added to the toolbar any more - the separators are not seen behind the controls added to the toolbar any more
- wxLB_SORT style can be used with wxCheckListBox - wxLB_SORT style can be used with wxCheckListBox
- wxWindowDC and wxClientDC::GetSize() works correctly now - wxWindowDC and wxClientDC::GetSize() works correctly now
- Added wxTB_NODIVIDER and wxTB_NOALIGN so native toolbar can
be used in FL
wxGTK: wxGTK:

View File

@@ -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 \twocolitem{\windowstyle{wxTB\_VERTICAL}}{Specifies vertical layout (not available for the GTK and Windows 95
toolbar).} toolbar).}
\twocolitem{\windowstyle{wxTB\_3DBUTTONS}}{Gives wxToolBarSimple a mild 3D look to its buttons.} \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\_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\_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} \end{twocollist}
See also \helpref{window styles overview}{windowstyles}. Note that the Win32 See also \helpref{window styles overview}{windowstyles}. Note that the Win32

View File

@@ -1122,6 +1122,8 @@ enum wxBorder
#define wxTB_DOCKABLE 0x0040 // use native docking under GTK #define wxTB_DOCKABLE 0x0040 // use native docking under GTK
#define wxTB_NOICONS 0x0080 // don't show the icons #define wxTB_NOICONS 0x0080 // don't show the icons
#define wxTB_TEXT 0x0100 // show the text #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 * wxStatusBar95 flags

View File

@@ -131,6 +131,8 @@ public:
virtual size_t MB2WC(wchar_t *buf, const char *psz, size_t n) const; 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; virtual size_t WC2MB(char *buf, const wchar_t *psz, size_t n) const;
void Clear() ;
private: private:
void SetName(const wxChar *charset); void SetName(const wxChar *charset);

View File

@@ -36,6 +36,7 @@
#include "wx/intl.h" #include "wx/intl.h"
#endif // PCH #endif // PCH
#include "wx/module.h"
#include "wx/fontmap.h" #include "wx/fontmap.h"
#if wxUSE_CONFIG #if wxUSE_CONFIG
@@ -181,11 +182,23 @@ static const wxChar* gs_encodingNames[] =
// global data // global data
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// private object wxFontMapper * wxTheFontMapper = NULL;
static wxFontMapper gs_fontMapper;
// and public pointer class wxFontMapperModule: public wxModule
wxFontMapper * wxTheFontMapper = &gs_fontMapper; {
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 // private classes

View File

@@ -626,6 +626,7 @@ public:
{ {
delete gs_mimeTypesManager.m_impl; delete gs_mimeTypesManager.m_impl;
gs_mimeTypesManager.m_impl = NULL; gs_mimeTypesManager.m_impl = NULL;
gs_mimeTypesManager.m_fallbacks.Clear();
} }
} }

View File

@@ -42,6 +42,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "wx/module.h"
#include "wx/strconv.h" #include "wx/strconv.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -58,6 +59,22 @@
WXDLLEXPORT_DATA(wxMBConv *) wxConvCurrent = &wxConvLibc; 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 // headers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -898,8 +915,17 @@ wxCSConv::wxCSConv(const wxChar *charset)
wxCSConv::~wxCSConv() wxCSConv::~wxCSConv()
{ {
free(m_name); Clear();
delete m_cset; }
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) void wxCSConv::SetName(const wxChar *charset)

View File

@@ -262,6 +262,10 @@ bool wxToolBar::Create(wxWindow *parent,
msflags |= TBSTYLE_FLAT | TBSTYLE_TRANSPARENT; msflags |= TBSTYLE_FLAT | TBSTYLE_TRANSPARENT;
} }
} }
if (style & wxTB_NODIVIDER)
msflags |= CCS_NODIVIDER;
if (style & wxTB_NOALIGN)
msflags |= CCS_NOPARENTALIGN;
// MSW-specific initialisation // MSW-specific initialisation
if ( !wxControl::MSWCreateControl(TOOLBARCLASSNAME, msflags) ) if ( !wxControl::MSWCreateControl(TOOLBARCLASSNAME, msflags) )
@@ -1184,7 +1188,11 @@ bool wxToolBar::HandleSize(WXWPARAM wParam, WXLPARAM lParam)
if ( m_maxRows ) if ( m_maxRows )
{ {
// FIXME: 6 is hardcoded separator line height... // FIXME: 6 is hardcoded separator line height...
h += 6; //h += 6;
if (HasFlag(wxTB_NODIVIDER))
h += 3;
else
h += 6;
h *= m_maxRows; h *= m_maxRows;
} }
} }