made radio buttons and the toolbat text work for Win32 toolbar
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14788 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -111,9 +111,10 @@ Unix (Base/GUI):
|
|||||||
|
|
||||||
All (GUI):
|
All (GUI):
|
||||||
|
|
||||||
|
- implemented radio menu items and radio toolbar buttons
|
||||||
|
- added possibility to show text in the toolbar buttons
|
||||||
- added wxArtProvider class that can be used to customize the look of standard
|
- added wxArtProvider class that can be used to customize the look of standard
|
||||||
wxWindows dialogs
|
wxWindows dialogs
|
||||||
- implemented radio menu items
|
|
||||||
- significantly improved native font support
|
- significantly improved native font support
|
||||||
- wxImage::ComputeHistogram() now uses wxImageHistogram instead of type-unsafe
|
- wxImage::ComputeHistogram() now uses wxImageHistogram instead of type-unsafe
|
||||||
wxHashTable
|
wxHashTable
|
||||||
|
@@ -42,9 +42,6 @@ ignore the values for explicit placement and use their own layout and the meanin
|
|||||||
of a "separator" is a vertical line under Windows95 vs. simple space under GTK etc.
|
of a "separator" is a vertical line under Windows95 vs. simple space under GTK etc.
|
||||||
|
|
||||||
{\bf wxToolBar95:} Note that this toolbar paints tools to reflect user-selected colours.
|
{\bf wxToolBar95:} Note that this toolbar paints tools to reflect user-selected colours.
|
||||||
The toolbar orientation must always be {\bf wxHORIZONTAL}.
|
|
||||||
|
|
||||||
{\bf wxToolBarGtk:} The toolbar orientation is ignored and is always {\bf wxHORIZONTAL}.
|
|
||||||
|
|
||||||
\wxheading{Window styles}
|
\wxheading{Window styles}
|
||||||
|
|
||||||
@@ -60,7 +57,9 @@ toolbar).}
|
|||||||
\twocolitem{\windowstyle{wxTB\_NOICONS}}{Doesn't show the icons in the toolbar buttons, by default they are shown}
|
\twocolitem{\windowstyle{wxTB\_NOICONS}}{Doesn't show the icons in the toolbar buttons, by default they are shown}
|
||||||
\end{twocollist}
|
\end{twocollist}
|
||||||
|
|
||||||
See also \helpref{window styles overview}{windowstyles}.
|
See also \helpref{window styles overview}{windowstyles}. Note that the Win32
|
||||||
|
native toolbar ignores {\tt wxTB\_NOICONS} style. Also, toggling the
|
||||||
|
{\tt wxTB\_TEXT} works only if the style was initially on.
|
||||||
|
|
||||||
\wxheading{Event handling}
|
\wxheading{Event handling}
|
||||||
|
|
||||||
|
@@ -60,6 +60,8 @@ public:
|
|||||||
// implementation only from now on
|
// implementation only from now on
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
|
||||||
|
virtual void SetWindowStyleFlag(long style);
|
||||||
|
|
||||||
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
||||||
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
||||||
|
|
||||||
|
@@ -178,7 +178,7 @@ public:
|
|||||||
void SetNormalBitmap(const wxBitmap& bmp) { m_bmpNormal = bmp; }
|
void SetNormalBitmap(const wxBitmap& bmp) { m_bmpNormal = bmp; }
|
||||||
void SetDisabledBitmap(const wxBitmap& bmp) { m_bmpDisabled = bmp; }
|
void SetDisabledBitmap(const wxBitmap& bmp) { m_bmpDisabled = bmp; }
|
||||||
|
|
||||||
void SetLabel(const wxString& label) { m_label = label; }
|
virtual void SetLabel(const wxString& label) { m_label = label; }
|
||||||
|
|
||||||
void SetClientData(wxObject *clientData)
|
void SetClientData(wxObject *clientData)
|
||||||
{
|
{
|
||||||
|
@@ -152,7 +152,7 @@ private:
|
|||||||
|
|
||||||
const int ID_TOOLBAR = 500;
|
const int ID_TOOLBAR = 500;
|
||||||
|
|
||||||
static const long TOOLBAR_STYLE = wxNO_BORDER | wxTB_FLAT | wxTB_DOCKABLE;
|
static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@@ -227,7 +227,7 @@ bool MyApp::OnInit()
|
|||||||
// Create the main frame window
|
// Create the main frame window
|
||||||
MyFrame* frame = new MyFrame((wxFrame *) NULL, -1,
|
MyFrame* frame = new MyFrame((wxFrame *) NULL, -1,
|
||||||
"wxToolBar Sample",
|
"wxToolBar Sample",
|
||||||
wxPoint(100, 100), wxSize(450, 300));
|
wxPoint(100, 100), wxSize(550, 300));
|
||||||
|
|
||||||
frame->Show(TRUE);
|
frame->Show(TRUE);
|
||||||
|
|
||||||
@@ -397,6 +397,8 @@ MyFrame::MyFrame(wxFrame* parent,
|
|||||||
// Associate the menu bar with the frame
|
// Associate the menu bar with the frame
|
||||||
SetMenuBar(menuBar);
|
SetMenuBar(menuBar);
|
||||||
|
|
||||||
|
menuBar->Check(IDM_TOOLBAR_SHOW_BOTH, TRUE);
|
||||||
|
|
||||||
// Create the toolbar
|
// Create the toolbar
|
||||||
RecreateToolbar();
|
RecreateToolbar();
|
||||||
}
|
}
|
||||||
@@ -464,8 +466,8 @@ void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event))
|
|||||||
style);
|
style);
|
||||||
|
|
||||||
m_tbar->AddRadioTool(wxID_NEW, _T("First"), wxBITMAP(new));
|
m_tbar->AddRadioTool(wxID_NEW, _T("First"), wxBITMAP(new));
|
||||||
m_tbar->AddRadioTool(wxID_NEW, _T("Second"), wxBITMAP(new));
|
m_tbar->AddRadioTool(wxID_OPEN, _T("Second"), wxBITMAP(open));
|
||||||
m_tbar->AddRadioTool(wxID_NEW, _T("Third"), wxBITMAP(new));
|
m_tbar->AddRadioTool(wxID_SAVE, _T("Third"), wxBITMAP(save));
|
||||||
m_tbar->AddSeparator();
|
m_tbar->AddSeparator();
|
||||||
m_tbar->AddTool(wxID_HELP, _T("Help"), wxBITMAP(help));
|
m_tbar->AddTool(wxID_HELP, _T("Help"), wxBITMAP(help));
|
||||||
|
|
||||||
|
@@ -161,6 +161,19 @@ public:
|
|||||||
m_nSepCount = 1;
|
m_nSepCount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void SetLabel(const wxString& label)
|
||||||
|
{
|
||||||
|
if ( label == m_label )
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxToolBarToolBase::SetLabel(label);
|
||||||
|
|
||||||
|
// we need to update the label shown in the toolbar because it has a
|
||||||
|
// pointer to the internal buffer of the old label
|
||||||
|
//
|
||||||
|
// TODO: use TB_SETBUTTONINFO
|
||||||
|
}
|
||||||
|
|
||||||
// set/get the number of separators which we use to cover the space used by
|
// set/get the number of separators which we use to cover the space used by
|
||||||
// a control in the toolbar
|
// a control in the toolbar
|
||||||
void SetSeparatorsCount(size_t count) { m_nSepCount = count; }
|
void SetSeparatorsCount(size_t count) { m_nSepCount = count; }
|
||||||
@@ -543,7 +556,6 @@ bool wxToolBar::Realize()
|
|||||||
wxLogDebug(wxT("TB_DELETEBUTTON failed"));
|
wxLogDebug(wxT("TB_DELETEBUTTON failed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( addBitmap ) // no old bitmap or we can't replace it
|
if ( addBitmap ) // no old bitmap or we can't replace it
|
||||||
@@ -566,6 +578,7 @@ bool wxToolBar::Realize()
|
|||||||
// this array will hold the indices of all controls in the toolbar
|
// this array will hold the indices of all controls in the toolbar
|
||||||
wxArrayInt controlIds;
|
wxArrayInt controlIds;
|
||||||
|
|
||||||
|
bool lastWasRadio = FALSE;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
|
for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
|
||||||
{
|
{
|
||||||
@@ -579,6 +592,7 @@ bool wxToolBar::Realize()
|
|||||||
|
|
||||||
wxZeroMemory(button);
|
wxZeroMemory(button);
|
||||||
|
|
||||||
|
bool isRadio = FALSE;
|
||||||
switch ( tool->GetStyle() )
|
switch ( tool->GetStyle() )
|
||||||
{
|
{
|
||||||
case wxTOOL_STYLE_CONTROL:
|
case wxTOOL_STYLE_CONTROL:
|
||||||
@@ -592,6 +606,12 @@ bool wxToolBar::Realize()
|
|||||||
|
|
||||||
case wxTOOL_STYLE_BUTTON:
|
case wxTOOL_STYLE_BUTTON:
|
||||||
button.iBitmap = bitmapId;
|
button.iBitmap = bitmapId;
|
||||||
|
|
||||||
|
if ( HasFlag(wxTB_TEXT) && !tool->GetLabel().empty() )
|
||||||
|
{
|
||||||
|
button.iString = (int)tool->GetLabel().c_str();
|
||||||
|
}
|
||||||
|
|
||||||
button.idCommand = tool->GetId();
|
button.idCommand = tool->GetId();
|
||||||
|
|
||||||
if ( tool->IsEnabled() )
|
if ( tool->IsEnabled() )
|
||||||
@@ -599,13 +619,40 @@ bool wxToolBar::Realize()
|
|||||||
if ( tool->IsToggled() )
|
if ( tool->IsToggled() )
|
||||||
button.fsState |= TBSTATE_CHECKED;
|
button.fsState |= TBSTATE_CHECKED;
|
||||||
|
|
||||||
button.fsStyle = tool->CanBeToggled() ? TBSTYLE_CHECK
|
switch ( tool->GetKind() )
|
||||||
: TBSTYLE_BUTTON;
|
{
|
||||||
|
case wxITEM_RADIO:
|
||||||
|
button.fsStyle = TBSTYLE_CHECKGROUP;
|
||||||
|
|
||||||
|
if ( !lastWasRadio )
|
||||||
|
{
|
||||||
|
// the first item in the radio group is checked by
|
||||||
|
// default to be consistent with wxGTK and the menu
|
||||||
|
// radio items
|
||||||
|
button.fsState |= TBSTATE_CHECKED;
|
||||||
|
}
|
||||||
|
|
||||||
|
isRadio = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxITEM_CHECK:
|
||||||
|
button.fsStyle = TBSTYLE_CHECK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG( _T("unexpected toolbar button kind") );
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case wxITEM_NORMAL:
|
||||||
|
button.fsStyle = TBSTYLE_BUTTON;
|
||||||
|
}
|
||||||
|
|
||||||
bitmapId++;
|
bitmapId++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastWasRadio = isRadio;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -981,6 +1028,67 @@ void wxToolBar::UpdateSize()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// toolbar styles
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxToolBar::SetWindowStyleFlag(long style)
|
||||||
|
{
|
||||||
|
// there doesn't seem to be any reasonably simple way to prevent the
|
||||||
|
// toolbar from showing the icons so for now we don't honour wxTB_NOICONS
|
||||||
|
if ( (style & wxTB_TEXT) != (GetWindowStyle() & wxTB_TEXT) )
|
||||||
|
{
|
||||||
|
// update the strings of all toolbar buttons
|
||||||
|
//
|
||||||
|
// NB: we can only do it using TB_SETBUTTONINFO which is available
|
||||||
|
// in comctl32.dll >= 4.71 only
|
||||||
|
#if defined(_WIN32_IE) && (_WIN32_IE >= 0x400 )
|
||||||
|
if ( wxTheApp->GetComCtl32Version() >= 471 )
|
||||||
|
{
|
||||||
|
// set the (underlying) separators width to be that of the
|
||||||
|
// control
|
||||||
|
TBBUTTONINFO tbbi;
|
||||||
|
tbbi.cbSize = sizeof(tbbi);
|
||||||
|
tbbi.dwMask = TBIF_TEXT;
|
||||||
|
if ( !(style & wxTB_TEXT) )
|
||||||
|
{
|
||||||
|
// don't show the text - remove the labels
|
||||||
|
tbbi.pszText = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( wxToolBarToolsList::Node *node = m_tools.GetFirst();
|
||||||
|
node;
|
||||||
|
node = node->GetNext() )
|
||||||
|
{
|
||||||
|
wxToolBarToolBase *tool = node->GetData();
|
||||||
|
if ( !tool->IsButton() )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( style & wxTB_TEXT )
|
||||||
|
{
|
||||||
|
// cast is harmless
|
||||||
|
tbbi.pszText = (wxChar *)tool->GetLabel().c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !SendMessage(GetHwnd(), TB_SETBUTTONINFO,
|
||||||
|
tool->GetId(), (LPARAM)&tbbi) )
|
||||||
|
{
|
||||||
|
// the id is probably invalid?
|
||||||
|
wxLogLastError(wxT("TB_SETBUTTONINFO"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateSize();
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
#endif // comctl32.dll 4.71
|
||||||
|
}
|
||||||
|
|
||||||
|
wxToolBarBase::SetWindowStyleFlag(style);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// tool state
|
// tool state
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user