2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FGrp_TextTextCutLink.cpp
20 * @brief This is the implementation file for TextCutLink class.
24 #include <FBaseSysLog.h>
25 #include "FGrp_TextCommon.h"
26 #include "FGrp_TextTextUtility.h"
27 #include "FGrp_TextTextElement.h"
28 #include "FGrp_TextTextSimple.h"
29 #include "FGrp_TextTextCutLink.h"
30 #include "FGrp_CanvasImpl.h"
32 using namespace Tizen::Base::Utility;
36 const int DEFAULT_FONT_SIZE = 42;
39 namespace Tizen { namespace Graphics
45 TextCutLink::TextCutLink(bool isEditable, LinkType cutLinkType, const wchar_t* pText, int length, TextElementSourceType sourceType,
46 Font* pFont, const Color& foregroundColor, const Color& backgroundColor, const Color&
48 : TextSimple(pText, length, sourceType, pFont, foregroundColor, backgroundColor, outlineColor)
50 __linkType = cutLinkType;
51 __isEditable = isEditable;
54 _type = TEXT_ELEMENT_TYPE_CUTLINK;
55 __isColorDefined = false;
56 __linkColor = Color::GetColor(COLOR_ID_BLUE);
57 __linkSelectedColor = Color::GetColor(COLOR_ID_BLUE);
59 __pLinkFont = new (std::nothrow) Font();
60 __pLinkFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE);
63 TextCutLink::~TextCutLink(void)
73 TextCutLink::Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment align,
74 const TextObjectActionType action)
77 , displayRect.x >= 0 && displayRect.y >= 0
78 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
80 return TextSimple::Draw(canvasImpl, displayRect, startTextIndex, textLength, align, action);
84 TextCutLink::CloneN(TextComponentInfoValueType type, unsigned int value)
86 TextCutLink* pLinkElement = null;
88 pLinkElement = new (std::nothrow) TextCutLink(__isEditable, __linkType, _pText, _length,
89 TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, _pFont, _foregroundColor, _backgroundColor, _outlineColor);
93 , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
95 TextElement::CopyMembers(pLinkElement);
97 pLinkElement->__isEdited = __isEdited;
98 pLinkElement->SetValue(type, value);
104 TextCutLink::CopyN(int textStartIndex, int textLength)
106 const wchar_t* pText = null;
108 TextCutLink* pLinkElement = null;
111 , textStartIndex < _length
112 , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
114 if (textStartIndex + textLength > _length)
116 textLength = _length - textStartIndex;
121 , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
123 pText = &_pText[_offset + textStartIndex];
125 pLinkElement = new (std::nothrow) TextCutLink(__isEditable, __linkType, pText, textLength, _sourceType,
126 _pFont, _foregroundColor, _backgroundColor, _outlineColor);
130 , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
132 pLinkElement->_isBackgroundDrawingModeEnabled = _isBackgroundDrawingModeEnabled;
133 pLinkElement->__isEdited = __isEdited;
139 TextCutLink::SetValue(TextComponentInfoValueType type, unsigned int value)
143 case SET_CUTLINK_TYPE:
145 return E_INVALID_ARG;
147 case SET_CUTLINK_EDITABLE:
149 return E_INVALID_ARG;
151 case SET_CUTLINK_EDITING:
154 __isEdited = (bool) value;
157 return E_INVALID_ARG;
163 if (!__isEdited && type == SET_TEXT_OFFSET)
165 return E_INVALID_ARG;
168 return TextSimple::SetValue(type, value);
172 TextCutLink::GetValue(TextComponentInfoValueType type) const
176 case SET_CUTLINK_TYPE:
178 return (unsigned int) __linkType;
180 case SET_CUTLINK_EDITABLE:
182 return (unsigned int) __isEditable;
184 case SET_CUTLINK_EDITING:
186 return (unsigned int) __isEdited;
190 return TextSimple::GetValue(type);
195 TextCutLink::SetSelect(bool isSelected)
197 __isSelected = isSelected;
201 TextCutLink::GetSelect(void) const
207 TextCutLink::SetUserColor(const Color& color, const Color& colorInSelect)
209 __isColorDefined = true;
211 __linkSelectedColor = colorInSelect;
215 TextCutLink::ResetUserColor(void)
217 __isColorDefined = false;
221 TextCutLink::SetTextOffset(int offset)
225 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
227 return TextSimple::SetTextOffset(offset);
231 TextCutLink::ChangeTextOffset(wchar_t* pText, int gap)
235 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
237 return TextSimple::ChangeTextOffset(pText, gap);
241 TextCutLink::GetCurrentFont(void) const
245 return TextSimple::GetCurrentFont();
252 TextCutLink::GetCurrentForegroundColor(void) const
256 return TextSimple::GetCurrentForegroundColor();
259 if (__isColorDefined)
263 return __linkSelectedColor;
271 return Color::GetColor(COLOR_ID_BLUE);
274 return Color::GetColor(COLOR_ID_BLUE);
278 TextCutLink::GetCurrentBackgroundColor(void) const
282 return TextSimple::GetCurrentBackgroundColor();
287 return Color::GetColor(COLOR_ID_WHITE);
290 return Color::GetColor(COLOR_ID_WHITE);
294 TextCutLink::GetCurrentOutlineColor(void) const
298 return TextSimple::GetCurrentOutlineColor();
301 return Color::GetColor(COLOR_ID_WHITE);
305 TextCutLink::GetEditable(void) const
311 TextCutLink::SetEditModeEnable(bool enable)
317 TextCutLink::IsEditModeEnable(void) const
322 Tizen::Base::Utility::LinkType
323 TextCutLink::GetCutLinkType(void) const
328 }}} // Tizen::Graphics::_Text