?? mso_multiline_text.c
字號:
/* **************************************************************************************
* Copyright (c) 2004 ZORAN Corporation, All Rights Reserved
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
*
* File: $Workfile: o_text.c $
*
* Description:
* ============
* Project definition of the MSO_NEW_TEXT functions
*
****************************************************************************************/
#include "Config.h" // Global Configuration - do not remove!
#include "include\sysdefs.h"
#ifdef DEBUG_UI_TRACE
#undef IFTRACE
#define IFTRACE if (gTraceUI)
#include "Debug\DbgMain.h"
#endif //DEBUG_UI_TRACE
/////////////////////////////////////////////////////////////////////////////
// Include files
#include <stdio.h>
#include <string.h>
#include "include\math-macro.h"
#include "Playcore\ScPad\SCMGR.h"
#include "GUI\Menu_system\ms_object.h"
#include "gui\menu_system\osd_rendering.h"
#include "gui\menu_system\ms_display.h"
#include "GUI\Menu_system\ms_screen.h"
#include "GUI\Object_class\Multiline\mso_multiline_text.h"
#include "GUI\Object_class\Text\mso_text.h"
#include "Menu\menu_operation_def.h"
#include "Font\fonts.h"
#include "Library\Unicode.h"
#include "Playcore\scpad\scmgr.h"
#include "services\include\_heap.h"
#ifndef DEBUG_UI_TRACE
#undef dbg_printf(sMsg)
#define dbg_printf(sMsg)
#undef dbgm_printf(sMsg, mode)
#define dbgm_printf(sMsg, mode)
#endif
#define pObjectMultilineText ((MSO_MULTILINE_TEXT __NEAR*)pThis)
#define pObjectText ((MSO_TEXT __NEAR*)&(pObjectMultilineText->moObject))
#define pDescriptorMultilineText ((MS_DESCRIPTOR_MULTILINE_TEXT *)(pThis->mpDescriptor))
#define pDescriptorText ((MS_DESCRIPTOR_TEXT *)&(pDescriptorMultilineText->moDescriptorText))
static void OMULTILINETEXT_InitialiseTextTable(MULTILINE_TEXT_TABLE *pTable, UINT8 cNumEntries)
{
// Record the number of entries:
pTable->mcTableEntryCount = cNumEntries;
// Allocate an array to hold each entry:
(SC_PTR*)(pTable->mwEntries) = (SC_PTR*)MEM_Allocate(UI_MEMPOOL, (sizeof(SC_PTR) * cNumEntries));
}
static void OMULTILINETEXT_MallocStrings(MULTILINE_TEXT_TABLE *pTable)
{
int i;
// Allocate memory on the scratch pad for each string:
for(i = 0; i < pTable->mcTableEntryCount; i++)
{
pTable->mwEntries[i] = OSDR_MallocScFormUniStr();
}
}
static void OMULTILINETEXT_ResizeStrings(MULTILINE_TEXT_TABLE *pTable, UINT8 cOriginalMaxItems)
{
int i;
for(i = pTable->mcTableEntryCount; i < cOriginalMaxItems; i++)
{
OSDR_FreeScFormUniStr(pTable->mwEntries[i]);
pTable->mwEntries[i] = NULL_HANDLE;
}
}
static void OMULTILINETEXT_ReleaseStrings(MULTILINE_TEXT_TABLE *pTable)
{
int i;
// Free the SCPAD memory first:
for(i = (pTable->mcTableEntryCount - 1); i >= 0; i--)
{
OSDR_FreeScFormUniStr(pTable->mwEntries[i]);
pTable->mwEntries[i] = NULL_HANDLE;
}
}
static void OMULTILINETEXT_DeleteTextTable(MULTILINE_TEXT_TABLE *pTable)
{
// Free the array holding the SCPAD addresses:
MEM_Free(UI_MEMPOOL, pTable->mwEntries);
pTable->mwEntries = NULL;
pTable->mcTableEntryCount = 0;
}
/**************************************************************************
* Function : _PrepareTextTableItem
*
* In :
* Out :
* Desc :
***************************************************************************/
#pragma argsused
static UINT8 _PrepareTextTableItem(MSO_OBJECT __NEAR* pThis ,
MULTILINE_TEXT_TABLE *pMultilineTextTable,
UINT8 cLineIndex,
FORMATED_UNICODE_STRING *pFormUniStr,
UINT16 *wScByteOffset,
UINT16 wMaxPixelWidth
#ifdef D_GUI_DESCRIPTOR_MULTILINETEXT_EXT1
,
BOOL bRemoveAllNewLines
#endif//D_GUI_DESCRIPTOR_MULTILINETEXT_EXT1
)
{
UINT8 bDone;
UINT8 cStrPrevSpaceIndex;
UINT8 cStrLen;
UINT16 wPixelCount;
UINT8 bUnicodeNewLine = 0;
CONST FONT *pCurrentFont;
bDone = 0;
wPixelCount = 0;
// split multi line strings / strings that are too long
cStrPrevSpaceIndex = 0;
cStrLen = 0;
pCurrentFont = pFonts[pFormUniStr->mtFontIndex];
while (cStrLen < UNISTR_LENGTH_MAX && wPixelCount <= wMaxPixelWidth)
{
if (pFormUniStr->mszUniStr[cStrLen] == 0x0000)
{
bDone = 1;
break;
}
else if(pFormUniStr->mszUniStr[cStrLen] == UNICODE_NEWLINE)
{
cStrPrevSpaceIndex = cStrLen;
bUnicodeNewLine = 1;
#if D_GUI_DESCRIPTOR_MULTILINETEXT_EXT1
if(bRemoveAllNewLines&& MS_MULTI_PREPARE_STR_FIT_1 == pDescriptorMultilineText->mMsMultiDisplayConfig)
{
pFormUniStr->mszUniStr[cStrLen] = UNICODE_SPACE;
continue;
}
// this is for the 0x0000 following the UNICODE_NEWLINE
if( cStrLen < UNISTR_LENGTH_MAX - 1 && pFormUniStr->mszUniStr[cStrLen + 1] == 0x0000)
bDone = 1;
#endif D_GUI_DESCRIPTOR_MULTILINETEXT_EXT1
break;
}
// now all in unicode so can test for unicode space
else if ((pFormUniStr->mszUniStr[cStrLen] == UNICODE_SPACE)
||(pFormUniStr->mszUniStr[cStrLen] == UNICODE_NO_BREAK_SPACE))
{
cStrPrevSpaceIndex = cStrLen;
wPixelCount += pCurrentFont->m_cCharPixelSpace; // calculate pixelwidth
}
else
{
CONST BYTE **poUniPage;
UINT16 wUnichar;
// calculate pixelwidth
wUnichar = pFormUniStr->mszUniStr[cStrLen];
poUniPage = Font_Get_Page(pCurrentFont, wUnichar);
wUnichar &= FONT_UNICODE_POSITION_MASK;// Get the position in current page
#ifdef D_GUI_FONT_TRUE_TYPE_COMBINING
wPixelCount += ((poUniPage[wUnichar][UNI_CHAR_CELLX])) ;
#else
wPixelCount += ((poUniPage[wUnichar][UNI_CHAR_WIDTH]) + pCurrentFont->m_cInterCharPixelSpace);
#endif//D_GUI_FONT_TRUE_TYPE_COMBINING
}
cStrLen++;
}
#ifndef D_GUI_FONT_TRUE_TYPE_COMBINING
wPixelCount -= pCurrentFont->m_cInterCharPixelSpace; // calculate pixelwidth
#endif//D_GUI_FONT_TRUE_TYPE_COMBINING
// If the string is longer than UNISTR_LENGTH_MAX, cut into 2 strings
if (!bDone)
{
if( (UNICODE_NEWLINE == pFormUniStr->mszUniStr[cStrPrevSpaceIndex])
||(UNICODE_SPACE == pFormUniStr->mszUniStr[cStrPrevSpaceIndex])
||(UNICODE_NO_BREAK_SPACE == pFormUniStr->mszUniStr[cStrPrevSpaceIndex]))
{
cStrLen = cStrPrevSpaceIndex;
*wScByteOffset += cStrLen+1;
}
else
{
cStrPrevSpaceIndex = cStrLen;
*wScByteOffset += cStrLen;//>>>>Teddy add this for a long word no interupt.
}
//pFormUniStr->mszUniStr[cStrLen] = 0;
pMultilineTextTable->mcTableEntryCount++;
}
else if(cStrLen > 0)
{
pMultilineTextTable->mcTableEntryCount++;
}
pFormUniStr->mszUniStr[cStrLen] = 0;
OSDR_FormatUniString((FORMATED_UNICODE_STRING __NEAR *)pFormUniStr);
OSDR_SetScFormUniStr((FORMATED_UNICODE_STRING __NEAR*)pFormUniStr, pMultilineTextTable->mwEntries[cLineIndex]);
#ifdef D_GUI_DESCRIPTOR_MULTILINETEXT_EXT1
if( MS_MULTI_PREPARE_STR_DEFAULT == pDescriptorMultilineText->mMsMultiDisplayConfig)
#endif//D_GUI_DESCRIPTOR_MULTILINETEXT_EXT1
{
if(!bDone && !bUnicodeNewLine)
{
int cCount;
// get text
pDescriptorMultilineText->moDescriptorText.mText->mGetStr((FORMATED_UNICODE_STRING __NEAR*)pFormUniStr,
OMULTILINETEXT_GetStrParamMake(pDescriptorMultilineText->moDescriptorText.mText->mParam ,((UINT32)(*wScByteOffset)) ));
for( cCount = 0; cCount < UNISTR_LENGTH_MAX ; cCount++)
{
if(0x00 == pFormUniStr->mszUniStr[cCount] )
{
break;
}
if(UNICODE_NEWLINE == pFormUniStr->mszUniStr[cCount] )
{
*wScByteOffset += cCount + 1;
break;
}
}
}
}
return bDone;
}
/**************************************************************************
* Function : OMultilineTextOperation
*
* In :
*
* Out :
*
* Desc :
***************************************************************************/
MS_OP OMULTILINETEXT_Operation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{
switch (MsOp)
{
// operations to create/resize/delete text table data - provides a handler to allow functions to be hidden
case MS_OP_INIT_TEXT_TABLE:
OMULTILINETEXT_InitialiseTextTable((MULTILINE_TEXT_TABLE*)lParam, ((MS_DESCRIPTOR_MULTILINE_TEXT *)(pThis->mpDescriptor))->mcMaxTableLines);
break;
case MS_OP_ALLOCATE_TEXT_TABLE_SCPAD_MEMORY:
OMULTILINETEXT_MallocStrings((MULTILINE_TEXT_TABLE*)lParam);
break;
case MS_OP_RESIZE_TEXT_TABLE_SCPAD_MEMORY:
OMULTILINETEXT_ResizeStrings((MULTILINE_TEXT_TABLE*)lParam, ((MS_DESCRIPTOR_MULTILINE_TEXT *)(pThis->mpDescriptor))->mcMaxTableLines);
break;
case MS_OP_RELEASE_TEXT_TABLE_SCPAD_MEMORY:
OMULTILINETEXT_ReleaseStrings((MULTILINE_TEXT_TABLE*)lParam);
break;
case MS_OP_DELETE_TEXT_TABLE:
OMULTILINETEXT_DeleteTextTable((MULTILINE_TEXT_TABLE*)lParam);
break;
case MS_OP_POPULATE_TEXT_TABLE:
{
BOOL bDone = 0;
UINT16 wScByteOffset = 0;
UINT8 cLineIndex;
UINT32 lwTextandOffset;
UINT16 wPixelWidth;
#ifdef D_GUI_DESCRIPTOR_MULTILINETEXT_EXT1
BOOL bRemoveAllNewLines= FALSE;
#endif//D_GUI_DESCRIPTOR_MULTILINETEXT_EXT1
// no get string method specified
if(pDescriptorMultilineText->moDescriptorText.mText == NULL) break;
// ABS here allows right align to container xoffset (specified as a -ve number) to be used to limit pixel width
// but also means a negative offsets cannot be used to place text outside area (when align to container)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -