| 1 |
/* AbiSource Application Framework |
| 2 |
* Copyright (C) 1998 AbiSource, Inc. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or |
| 5 |
* modify it under the terms of the GNU General Public License |
| 6 |
* as published by the Free Software Foundation; either version 2 |
| 7 |
* of the License, or (at your option) any later version. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program; if not, write to the Free Software |
| 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 17 |
* 02110-1301 USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "ut_types.h" |
| 21 |
#include "ut_vector.h" |
| 22 |
#include "ev_Toolbar.h" |
| 23 |
#include "xap_Toolbar_ControlFactory.h" |
| 24 |
|
| 25 |
/*****************************************************************/ |
| 26 |
|
| 27 |
XAP_Toolbar_ControlFactory::XAP_Toolbar_ControlFactory(int nrElem, const struct _ctl_table * pCtlTable) |
| 28 |
{ |
| 29 |
m_nrElementsCtlTable = nrElem; |
| 30 |
m_ctl_table = pCtlTable; |
| 31 |
} |
| 32 |
|
| 33 |
XAP_Toolbar_ControlFactory::~XAP_Toolbar_ControlFactory(void) |
| 34 |
{ |
| 35 |
} |
| 36 |
|
| 37 |
bool XAP_Toolbar_ControlFactory::_find_ControlInTable(XAP_Toolbar_Id id, UT_uint32 * pIndex) const |
| 38 |
{ |
| 39 |
// search the table and return the index of the entry with this id. |
| 40 |
|
| 41 |
UT_ASSERT(pIndex); |
| 42 |
|
| 43 |
for (UT_uint32 k=0; (k < m_nrElementsCtlTable); k++) |
| 44 |
{ |
| 45 |
if (m_ctl_table[k].m_id == id) |
| 46 |
{ |
| 47 |
*pIndex = k; |
| 48 |
return true; |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
UT_ASSERT(UT_NOT_IMPLEMENTED); |
| 53 |
return false; |
| 54 |
} |
| 55 |
|
| 56 |
/*****************************************************************/ |
| 57 |
|
| 58 |
EV_Toolbar_Control * XAP_Toolbar_ControlFactory::getControl(EV_Toolbar * pToolbar, XAP_Toolbar_Id id) |
| 59 |
{ |
| 60 |
UT_uint32 index; |
| 61 |
EV_Toolbar_Control * pControl = NULL; |
| 62 |
|
| 63 |
_find_ControlInTable(id,&index); |
| 64 |
|
| 65 |
// create a fresh Toolbar_Control object and return it -- no strings attached. |
| 66 |
|
| 67 |
pControl = static_cast<EV_Toolbar_Control *>((m_ctl_table[index].m_pfnStaticConstructor)(pToolbar,id)); |
| 68 |
return pControl; |
| 69 |
} |
| 70 |
|