Exemple #1
0
/*********************************************************************\
	Function name    : TreeViewItem::RemoveChild
	Description      :
	Created at       : 23.08.01, @ 21:37:30
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
void TreeViewItem::RemoveChild(Int32 lChildIndex, DeleteTreeViewItemCallback cb)
{
	if (lChildIndex < 0 || lChildIndex >= m_lChildren) return;

	if (cb)
		cb(m_ppChildren[lChildIndex]->GetData());

	DeleteObj(m_ppChildren[lChildIndex]);

	if (m_lChildren == 1)
	{
		m_lChildren = 0;
		bDelete(m_ppChildren);
		return;
	}

	TreeViewItem** ppNewChild = bNewDeprecatedUseArraysInstead<TreeViewItem*>(m_lChildren - 1);
	for (Int32 d = 0, s = 0; s < m_lChildren; s++)
	{
		if (s != lChildIndex)
			ppNewChild[d++] = m_ppChildren[s];
	}
	bDelete(m_ppChildren);
	m_ppChildren = ppNewChild;
	m_lChildren--;
}
Exemple #2
0
/*********************************************************************\
	Function name    : TreeViewItem::ChangeParent
	Description      :
	Created at       : 15.08.01, @ 11:23:57
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
void TreeViewItem::ChangeParent(TreeViewItem* pNewParent, TreeViewItem* pInsertBefore, TreeViewItem* pInsertAfter)
{
	if (pNewParent->IsChildOf(this)) return;

	if (m_pParent->m_lChildren > 1)
	{
		TreeViewItem** ppNewChildren = bNewDeprecatedUseArraysInstead<TreeViewItem*>(m_pParent->m_lChildren - 1);
		for (Int32 s = 0, d = 0; s < m_pParent->m_lChildren; s++)
		{
			if (m_pParent->m_ppChildren[s] != this)
				ppNewChildren[d++] = m_pParent->m_ppChildren[s];
		}
		bDelete(m_pParent->m_ppChildren);
		m_pParent->m_ppChildren = ppNewChildren;
	}
	else
		bDelete(m_pParent->m_ppChildren);

	m_pParent->m_lChildren--;

	TreeViewItem** ppNewChildren = bNewDeprecatedUseArraysInstead<TreeViewItem*>(pNewParent->m_lChildren + 1);

	Bool bInserted = false;
	for (Int32 s = 0, d = 0; s < pNewParent->m_lChildren; s++, d++)
	{
		if (pNewParent->m_ppChildren[s] == pInsertBefore)
		{
			ppNewChildren[d++] = this;
			bInserted = true;
		}
		ppNewChildren[d] = pNewParent->m_ppChildren[s];
		if (pNewParent->m_ppChildren[s] == pInsertAfter)
		{
			ppNewChildren[++d] = this;
			bInserted = true;
		}
	}
	if (!bInserted)
	{
		for (Int32 a = pNewParent->m_lChildren; a >= 1; a--)
			ppNewChildren[a] = ppNewChildren[a - 1];
		ppNewChildren[0] = this;
	}

	bDelete(pNewParent->m_ppChildren);
	pNewParent->m_ppChildren = ppNewChildren;

	pNewParent->m_lChildren++;
	m_pParent = pNewParent;
}
Exemple #3
0
/*********************************************************************\
	Function name    : WriteString
	Description      : writes a string without length information into a file
										 bReplace == true : ä ö ü will be replaced
	Created at       : 30.08.01, @ 10:35:54
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
Bool WriteString(BaseFile* pFile, String str, Bool bReplace)
{
	Int32 lPos, lStart = 0;
	Int32 lLen = str.GetLength();
	if (bReplace)
	{
		while (str.FindFirst('\"', &lPos, lStart))
		{
			str = str.SubStr(0, lPos) + "$\"" + str.SubStr(lPos + 1, lLen - lPos - 1);
			lStart = lPos + 2;
			lLen++;
		}
	}

	lLen = str.GetCStringLen(STRINGENCODING_7BITHEX);
	char* pCh = bNewDeprecatedUseArraysInstead<char>(lLen + 2);
	str.GetCString(pCh, lLen + 1, STRINGENCODING_7BITHEX);

	for (Int32 l = 0; l < lLen; l++)
		pFile->WriteChar(pCh[l]);

	bDelete(pCh);

	return true;
}
Exemple #4
0
CLanguageList::~CLanguageList()
{
	for (Int32 l = 0; l < m_lLanguages; l++)
	{
		DeleteObj(m_ppLanguages[l]);
	}
	bDelete(m_ppLanguages);
}
Exemple #5
0
/*********************************************************************\
	Function name    : TRACE_STRING
	Description      :
	Created at       : 21.08.01, @ 17:36:17
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
void TRACE_STRING(String str)
{
	Int32 lLen = str.GetCStringLen();
	char* pCh = bNewDeprecatedUseArraysInstead<char>(lLen + 2);
	str.GetCString(pCh, lLen + 1);
	TRACE("%s\n", pCh);
	bDelete(pCh);
}
Exemple #6
0
/*********************************************************************\
	Function name    : TreeViewItem::DestroyAllChildren
	Description      :
	Created at       : 14.08.01, @ 19:11:49
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
void TreeViewItem::DestroyAllChildren(DeleteTreeViewItemCallback func)
{
	for (Int32 a = 0; a < m_lChildren; a++) {
		m_ppChildren[a]->DestroyAllChildren(func);
		if (func)
			func(m_ppChildren[a]->GetData());

		DeleteObj(m_ppChildren[a]);
	}
	bDelete(m_ppChildren);
	m_lChildren = 0;
}
Exemple #7
0
/*********************************************************************\
	Function name    : CLanguageList::AddLanguage
	Description      :
	Created at       : 26.09.01, @ 16:27:08
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
void CLanguageList::AddLanguage(String strName, String strSuffix)
{
	//TRACE("Found Language\n");
	//TRACE("    Name: "); TRACE_STRING(strName);
	//TRACE("  Suffix: "); TRACE_STRING(strSuffix);

	tagLanguage* pNewLang = NewObjClear(tagLanguage);
	tagLanguage** ppNewLang = bNewDeprecatedUseArraysInstead<tagLanguage*>(m_lLanguages + 1);
	CopyMemType(m_ppLanguages, ppNewLang, m_lLanguages);
	ppNewLang[m_lLanguages] = pNewLang;
	bDelete(m_ppLanguages);
	m_ppLanguages = ppNewLang;
	m_lLanguages++;
	pNewLang->strLanguageName = strName;
	pNewLang->strLanguageSuffix = strSuffix;
}
Exemple #8
0
/*********************************************************************\
	Function name    : TreeViewItem::AddItem
	Description      :
	Created at       : 14.08.01, @ 19:05:03
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
TreeViewItem* TreeViewItem::AddItem(const BaseContainer &data, TreeViewItem* pInsertAfter)
{
	TreeViewItem* pNewItem = NewObjClear(TreeViewItem);
	pNewItem->m_Data = data;

	TreeViewItem** pNewChildren = bNewDeprecatedUseArraysInstead<TreeViewItem*>(m_lChildren + 1);
	Int32 a, b;
	for (a = 0, b = 0; a < m_lChildren; a++, b++)
	{
		pNewChildren[b] = m_ppChildren[a];
		if ((m_ppChildren[a] == pInsertAfter) && b == a)
			pNewChildren[++b] = pNewItem;
	}

	//CopyMem(m_ppChildren, pNewChildren, sizeof(TreeViewItem*) * m_lChildren);

	bDelete(m_ppChildren);
	m_ppChildren = pNewChildren;
	if (b <= m_lChildren)
		m_ppChildren[m_lChildren] = pNewItem;
	m_lChildren++;

	return pNewItem;
}
/*********************************************************************\
	Function name    : CDialogCustomElement::~CDialogCustomElement
	Description      :
	Created at       : 28.03.02, @ 14:59:05
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
CDialogCustomElement::~CDialogCustomElement()
{
    bDelete(m_pData);
    bDelete(m_pbcGUI);
}
/*********************************************************************\
	Function name    : CCompareTableDialog::InitValues
	Description      :
	Created at       : 09.10.01, @ 21:07:22
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
Bool CCompareTableDialog::InitValues(void)
{
	BaseContainer bcLayout;
	Int32 a, b;

	bcLayout.SetInt32(COMPARE_LIST_NAME, LV_COLUMN_TEXT);
	bcLayout.SetInt32(COMPARE_LIST_DATA, LV_COLUMN_TEXT);
	m_wndOutputList.SetLayout(2, bcLayout);

	// the tbles are loaded, so write some important information
	Int32 lItemCount = 0;
	BaseContainer data;

	CStringTable* pTable;
	StringTableType stt;

	for (b = 0; b < 2; b++)
	{
		if (b == 0)
		{
			data.SetString(COMPARE_LIST_NAME, GeLoadString(IDS_COMPARE_ORIGINAL_FILE)); data.SetString(COMPARE_LIST_DATA, m_fnOriginal.GetString()); m_wndOutputList.SetItem(lItemCount++, data);
			pTable = m_pOriginalTable;
			stt = m_OriginalDoc.m_StringTableType;
		}
		else
		{
			data.SetString(COMPARE_LIST_NAME, GeLoadString(IDS_COMPARE_NEW_FILE)); data.SetString(COMPARE_LIST_DATA, m_fnNew.GetString()); m_wndOutputList.SetItem(lItemCount++, data);
			pTable = m_pNewTable;
			stt = m_NewDoc.m_StringTableType;
		}

		data.SetString(COMPARE_LIST_NAME, GeLoadString(IDS_COMPARE_STT));
		if (stt == typeDialogStrings)
			data.SetString(COMPARE_LIST_DATA, GeLoadString(IDS_COMPARE_TYPE_DLG));
		else if (stt == typeStringTable)
			data.SetString(COMPARE_LIST_DATA, GeLoadString(IDS_COMPARE_TYPE_STT));
		else if (stt == typeCommandStrings)
			data.SetString(COMPARE_LIST_DATA, GeLoadString(IDS_COMPARE_TYE_COMMAND));
		m_wndOutputList.SetItem(lItemCount++, data);


		data.SetString(COMPARE_LIST_NAME, GeLoadString(IDS_COMPARE_NUM_LANG)); data.SetString(COMPARE_LIST_DATA, String::IntToString(pTable->GetUsedLanguages())); m_wndOutputList.SetItem(lItemCount++, data);

		for (a = 0; a < pTable->GetUsedLanguages(); a++)
		{
			if (a == 0)
			{
				data.SetString(COMPARE_LIST_NAME, GeLoadString(IDS_COMPARE_LANGUAGES));
			}
			else
			{
				data.SetString(COMPARE_LIST_NAME, "");
			}

			String strSuffix = pTable->GetSuffix(a);
			data.SetString(COMPARE_LIST_DATA, String("") + g_LanguageList.GetName(strSuffix) + String("(") + strSuffix + String(")")); m_wndOutputList.SetItem(lItemCount++, data);
		}
		data.SetString(COMPARE_LIST_DATA, String("")); data.SetString(COMPARE_LIST_NAME, String("")); m_wndOutputList.SetItem(lItemCount++, data);
	}

	// search all strings that are in the original table, but not in the new table
	data.SetString(COMPARE_LIST_NAME, GeLoadString(IDS_COMPARE_REMOVED_ITEMS)); data.SetString(COMPARE_LIST_DATA, String("")); m_wndOutputList.SetItem(lItemCount++, data);
	data.SetString(COMPARE_LIST_NAME, String(""));
	for (a = 0; a < m_pOriginalTable->GetNumElements(); a++)
	{
		String strID = m_pOriginalTable->GetElementID(a);
		if (!m_pNewTable->ContainsElement(strID))
		{
			data.SetString(COMPARE_LIST_DATA, strID); m_wndOutputList.SetItem(lItemCount++, data);
		}
	}

	// now, find all items that were added in the new table
	data.SetString(COMPARE_LIST_NAME, GeLoadString(IDS_COMPARE_ADDED_ITEMS)); data.SetString(COMPARE_LIST_DATA, String("")); m_wndOutputList.SetItem(lItemCount++, data);
	data.SetString(COMPARE_LIST_NAME, String(""));
	for (a = 0; a < m_pNewTable->GetNumElements(); a++)
	{
		String strID = m_pNewTable->GetElementID(a);
		if (!m_pOriginalTable->ContainsElement(strID))
		{
			data.SetString(COMPARE_LIST_DATA, strID); m_wndOutputList.SetItem(lItemCount++, data);
		}
	}

	// search for all modified languages
	data.SetString(COMPARE_LIST_NAME, GeLoadString(IDS_COMPARE_MODIFIED_ITEMS)); data.SetString(COMPARE_LIST_DATA, String("")); m_wndOutputList.SetItem(lItemCount++, data);
	data.SetString(COMPARE_LIST_NAME, String(""));

	Int32 lLanguages = m_pOriginalTable->GetUsedLanguages();

	Int32 lBothLang = 0;
	Int32 *plLangIDO = bNewDeprecatedUseArraysInstead<Int32>(lLanguages);
	Int32 *plLangIDN = bNewDeprecatedUseArraysInstead<Int32>(lLanguages);
	Bool *pbChanged = bNewDeprecatedUseArraysInstead<Bool>(lLanguages);

	// check for all languages that are available in both tables
	for (a = 0; a < lLanguages; a++)
	{
		String strLangID = m_pOriginalTable->GetSuffix(a);
		Int32 lLangID = m_pNewTable->GetLanguageID(strLangID);
		if (lLangID < 0) continue;

		plLangIDO[lBothLang] = a;
		plLangIDN[lBothLang] = lLangID;

		lBothLang++;
	}

	for (a = 0; a < m_pOriginalTable->GetNumElements(); a++)
	{
		String strID = m_pOriginalTable->GetElementID(a);
		if (m_pNewTable->ContainsElement(strID))
		{
			Bool bChanged = false;
			ClearMemType(pbChanged, lLanguages);

			for (b = 0; b < lBothLang; b++)
			{
				if (m_bIsCommandTable)
				{
					String str1, str2, strCommand1, strCommand2;
					Bool bFound;

					str1 = m_pOriginalTable->GetString(a, plLangIDO[b], &strCommand1);
					str2 = m_pNewTable->GetString(m_pOriginalTable->GetElementID(a), plLangIDN[b], bFound, &strCommand2);

					if ((str1 != str2) || (strCommand1 != strCommand2))
					{
						pbChanged[b] = true;
						bChanged = true;
					}
				}
				else
				{
					String str = m_pOriginalTable->GetString(a, plLangIDO[b]);
					Bool bFound;
					if (str != m_pNewTable->GetString(m_pOriginalTable->GetElementID(a), plLangIDN[b], bFound))
					{
						pbChanged[b] = true;
						bChanged = true;
					}
				}
			}
			if (bChanged)
			{
				String str = m_pOriginalTable->GetElementID(a);
				for (b = 0; b < lBothLang; b++)
				{
					if (pbChanged[b])
						str += String("  ") + m_pOriginalTable->GetSuffix(plLangIDO[b]);
				}
				data.SetString(COMPARE_LIST_DATA, str); m_wndOutputList.SetItem(lItemCount++, data);
			}
		}
	}

	bDelete(plLangIDO);
	bDelete(plLangIDN);
	bDelete(pbChanged);

	m_wndOutputList.DataChanged();

	return true;
}