Add wxAddRemoveCtrl class.
This is a simple high level helper combining an arbitrary control showing multiple items with the buttons allowing to add items to and remove items from this control, but using the buttons and the layout appropriate for the current platform. Add the implementation itself, an example of using it to the dialogs sample and the documentation. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78462 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
92
src/common/addremovectrl.cpp
Normal file
92
src/common/addremovectrl.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/common/addremovectrl.cpp
|
||||
// Purpose: wxAddRemoveCtrl implementation.
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2015-01-29
|
||||
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// for compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_ADDREMOVECTRL
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/addremovectrl.h"
|
||||
|
||||
#include "wx/private/addremovectrl.h"
|
||||
|
||||
// ============================================================================
|
||||
// wxAddRemoveCtrl implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// common part
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
extern
|
||||
WXDLLIMPEXP_DATA_CORE(const char) wxAddRemoveCtrlNameStr[] = "wxAddRemoveCtrl";
|
||||
|
||||
bool
|
||||
wxAddRemoveCtrl::Create(wxWindow* parent,
|
||||
wxWindowID winid,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
if ( !wxPanel::Create(parent, winid, pos, size, style, name) )
|
||||
return false;
|
||||
|
||||
// We don't do anything here, the buttons are created when we're given the
|
||||
// adaptor to use them with in SetAdaptor().
|
||||
return true;
|
||||
}
|
||||
|
||||
wxAddRemoveCtrl::~wxAddRemoveCtrl()
|
||||
{
|
||||
delete m_impl;
|
||||
}
|
||||
|
||||
void wxAddRemoveCtrl::SetAdaptor(wxAddRemoveAdaptor* adaptor)
|
||||
{
|
||||
wxCHECK_RET( !m_impl, wxS("should be only called once") );
|
||||
|
||||
wxCHECK_RET( adaptor, wxS("should have a valid adaptor") );
|
||||
|
||||
wxWindow* const ctrlItems = adaptor->GetItemsCtrl();
|
||||
wxCHECK_RET( ctrlItems, wxS("should have a valid items control") );
|
||||
|
||||
m_impl = new wxAddRemoveImpl(adaptor, this, ctrlItems);
|
||||
}
|
||||
|
||||
void
|
||||
wxAddRemoveCtrl::SetButtonsToolTips(const wxString& addtip,
|
||||
const wxString& removetip)
|
||||
{
|
||||
wxCHECK_RET( m_impl, wxS("can only be called after SetAdaptor()") );
|
||||
|
||||
m_impl->SetButtonsToolTips(addtip, removetip);
|
||||
}
|
||||
|
||||
wxSize wxAddRemoveCtrl::DoGetBestClientSize() const
|
||||
{
|
||||
return m_impl ? m_impl->GetBestClientSize() : wxDefaultSize;
|
||||
}
|
||||
|
||||
#endif // wxUSE_ADDREMOVECTRL
|
||||
Reference in New Issue
Block a user