Fix adding/removing categorized/alphabetic mode buttons in wxPropertyGridManager.
Modify wxPropertyGridManager::RecreateControls() to allow adding/removing categorized/alphabetic mode buttons to/from wxPG manager tool bar at any time (not only when creating the tool bar). Modify wxPropertyGridManager::SetExtraStyle() to fully support manipulating these buttons via wxPG_EX_MODE_BUTTONS flag. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78149 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -88,6 +88,7 @@ All (GUI):
|
|||||||
- Always disable wxWizard "Back" button on the starting page (pmgrace30).
|
- Always disable wxWizard "Back" button on the starting page (pmgrace30).
|
||||||
- Add wxUIActionSimulator::Select().
|
- Add wxUIActionSimulator::Select().
|
||||||
- Add wxOwnerDrawnComboBox::Is{List,Text}Empty() methods.
|
- Add wxOwnerDrawnComboBox::Is{List,Text}Empty() methods.
|
||||||
|
- Fix creating/removing mode buttons in wxPG manager (Artur Wieczorek).
|
||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
|
||||||
|
@@ -672,7 +672,7 @@ void wxPropertyGridManager::SetExtraStyle( long exStyle )
|
|||||||
wxWindow::SetExtraStyle( exStyle );
|
wxWindow::SetExtraStyle( exStyle );
|
||||||
m_pPropGrid->SetExtraStyle( exStyle & 0xFFFFF000 );
|
m_pPropGrid->SetExtraStyle( exStyle & 0xFFFFF000 );
|
||||||
#if wxUSE_TOOLBAR
|
#if wxUSE_TOOLBAR
|
||||||
if ( (exStyle & wxPG_EX_NO_FLAT_TOOLBAR) && m_pToolbar )
|
if ( (exStyle & (wxPG_EX_NO_FLAT_TOOLBAR|wxPG_EX_MODE_BUTTONS)) && m_pToolbar )
|
||||||
RecreateControls();
|
RecreateControls();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1450,7 +1450,6 @@ void wxPropertyGridManager::RefreshProperty( wxPGProperty* p )
|
|||||||
|
|
||||||
void wxPropertyGridManager::RecreateControls()
|
void wxPropertyGridManager::RecreateControls()
|
||||||
{
|
{
|
||||||
|
|
||||||
bool was_shown = IsShown();
|
bool was_shown = IsShown();
|
||||||
if ( was_shown )
|
if ( was_shown )
|
||||||
Show ( false );
|
Show ( false );
|
||||||
@@ -1458,6 +1457,8 @@ void wxPropertyGridManager::RecreateControls()
|
|||||||
#if wxUSE_TOOLBAR
|
#if wxUSE_TOOLBAR
|
||||||
if ( m_windowStyle & wxPG_TOOLBAR )
|
if ( m_windowStyle & wxPG_TOOLBAR )
|
||||||
{
|
{
|
||||||
|
bool tbModified = false;
|
||||||
|
|
||||||
// Has toolbar.
|
// Has toolbar.
|
||||||
if ( !m_pToolbar )
|
if ( !m_pToolbar )
|
||||||
{
|
{
|
||||||
@@ -1489,45 +1490,90 @@ void wxPropertyGridManager::RecreateControls()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_pToolbar->SetCursor ( *wxSTANDARD_CURSOR );
|
m_pToolbar->SetCursor ( *wxSTANDARD_CURSOR );
|
||||||
|
tbModified = true;
|
||||||
|
m_categorizedModeToolId = -1;
|
||||||
|
m_alphabeticModeToolId = -1;
|
||||||
|
}
|
||||||
|
|
||||||
if ( (GetExtraStyle()&wxPG_EX_MODE_BUTTONS) )
|
if ( (GetExtraStyle()&wxPG_EX_MODE_BUTTONS) )
|
||||||
|
{
|
||||||
|
// Add buttons if they don't already exist.
|
||||||
|
if (m_categorizedModeToolId == -1)
|
||||||
{
|
{
|
||||||
wxString desc1(_("Categorized Mode"));
|
wxString desc(_("Categorized Mode"));
|
||||||
wxString desc2(_("Alphabetic Mode"));
|
wxToolBarToolBase* tool = m_pToolbar->InsertTool(0,
|
||||||
|
wxID_ANY,
|
||||||
wxToolBarToolBase* tool;
|
desc,
|
||||||
|
wxBitmap(gs_xpm_catmode),
|
||||||
tool = m_pToolbar->AddTool(wxID_ANY,
|
wxNullBitmap,
|
||||||
desc1,
|
wxITEM_RADIO,
|
||||||
wxBitmap(gs_xpm_catmode),
|
desc);
|
||||||
desc1,
|
|
||||||
wxITEM_RADIO);
|
|
||||||
m_categorizedModeToolId = tool->GetId();
|
m_categorizedModeToolId = tool->GetId();
|
||||||
|
tbModified = true;
|
||||||
tool = m_pToolbar->AddTool(wxID_ANY,
|
|
||||||
desc2,
|
|
||||||
wxBitmap(gs_xpm_noncatmode),
|
|
||||||
desc2,
|
|
||||||
wxITEM_RADIO);
|
|
||||||
m_alphabeticModeToolId = tool->GetId();
|
|
||||||
|
|
||||||
m_pToolbar->Realize();
|
|
||||||
|
|
||||||
Connect(m_categorizedModeToolId,
|
Connect(m_categorizedModeToolId,
|
||||||
wxEVT_TOOL,
|
wxEVT_TOOL,
|
||||||
wxCommandEventHandler(
|
wxCommandEventHandler(
|
||||||
wxPropertyGridManager::OnToolbarClick));
|
wxPropertyGridManager::OnToolbarClick));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_alphabeticModeToolId == -1)
|
||||||
|
{
|
||||||
|
wxString desc(_("Alphabetic Mode"));
|
||||||
|
wxToolBarToolBase* tool = m_pToolbar->InsertTool(1,
|
||||||
|
wxID_ANY,
|
||||||
|
desc,
|
||||||
|
wxBitmap(gs_xpm_noncatmode),
|
||||||
|
wxNullBitmap,
|
||||||
|
wxITEM_RADIO,
|
||||||
|
desc);
|
||||||
|
m_alphabeticModeToolId = tool->GetId();
|
||||||
|
tbModified = true;
|
||||||
|
|
||||||
Connect(m_alphabeticModeToolId,
|
Connect(m_alphabeticModeToolId,
|
||||||
wxEVT_TOOL,
|
wxEVT_TOOL,
|
||||||
wxCommandEventHandler(
|
wxCommandEventHandler(
|
||||||
wxPropertyGridManager::OnToolbarClick));
|
wxPropertyGridManager::OnToolbarClick));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_categorizedModeToolId = -1;
|
|
||||||
m_alphabeticModeToolId = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Both buttons should exist here.
|
||||||
|
wxASSERT( m_categorizedModeToolId != -1 && m_alphabeticModeToolId != -1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Remove buttons if they exist.
|
||||||
|
if (m_categorizedModeToolId != -1)
|
||||||
|
{
|
||||||
|
Disconnect(m_categorizedModeToolId,
|
||||||
|
wxEVT_TOOL,
|
||||||
|
wxCommandEventHandler(
|
||||||
|
wxPropertyGridManager::OnToolbarClick));
|
||||||
|
|
||||||
|
m_pToolbar->DeleteTool(m_categorizedModeToolId);
|
||||||
|
m_categorizedModeToolId = -1;
|
||||||
|
tbModified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_alphabeticModeToolId != -1)
|
||||||
|
{
|
||||||
|
Disconnect(m_alphabeticModeToolId,
|
||||||
|
wxEVT_TOOL,
|
||||||
|
wxCommandEventHandler(
|
||||||
|
wxPropertyGridManager::OnToolbarClick));
|
||||||
|
|
||||||
|
m_pToolbar->DeleteTool(m_alphabeticModeToolId);
|
||||||
|
m_alphabeticModeToolId = -1;
|
||||||
|
tbModified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No button should exist here.
|
||||||
|
wxASSERT( m_categorizedModeToolId == -1 && m_alphabeticModeToolId == -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rebuild toolbar if any changes were applied.
|
||||||
|
if (tbModified)
|
||||||
|
{
|
||||||
|
m_pToolbar->Realize();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (GetExtraStyle() & wxPG_EX_MODE_BUTTONS) )
|
if ( (GetExtraStyle() & wxPG_EX_MODE_BUTTONS) )
|
||||||
@@ -1551,7 +1597,6 @@ void wxPropertyGridManager::RecreateControls()
|
|||||||
m_pToolbar->ToggleTool(toggle_but_on_ind, true);
|
m_pToolbar->ToggleTool(toggle_but_on_ind, true);
|
||||||
m_pToolbar->ToggleTool(toggle_but_off_ind, false);
|
m_pToolbar->ToggleTool(toggle_but_off_ind, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user