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"
31 #include "FGrp_CoordinateSystemUtils.h"
33 using namespace Tizen::Base::Utility;
37 const int DEFAULT_FONT_SIZE = 42;
40 namespace Tizen { namespace Graphics
46 TextCutLink::TextCutLink(bool isEditable, LinkType cutLinkType, const wchar_t* pText, int length, TextElementSourceType sourceType,
47 Font* pFont, const Color& foregroundColor, const Color& backgroundColor, const Color&
49 : TextSimple(pText, length, sourceType, pFont, foregroundColor, backgroundColor, outlineColor)
51 __linkType = cutLinkType;
52 __isEditable = isEditable;
55 _type = TEXT_ELEMENT_TYPE_CUTLINK;
56 __isColorDefined = false;
57 __linkColor = Color::GetColor(COLOR_ID_BLUE);
58 __linkSelectedColor = Color::GetColor(COLOR_ID_BLUE);
60 __pLinkFont = new (std::nothrow) Font();
61 __pLinkFont->Construct(FONT_STYLE_PLAIN, DEFAULT_FONT_SIZE);
64 TextCutLink::~TextCutLink(void)
74 TextCutLink::Draw(_CanvasImpl& canvasImpl, Rectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment align,
75 const TextObjectActionType action)
78 , displayRect.x >= 0 && displayRect.y >= 0
79 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
81 return TextSimple::Draw(canvasImpl, displayRect, startTextIndex, textLength, align, action);
85 TextCutLink::Draw(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment align,
86 const TextObjectActionType action)
88 Rectangle intDisplayRect = _CoordinateSystemUtils::ConvertToInteger(displayRect);
90 return Draw(canvasImpl, intDisplayRect, startTextIndex, textLength, align, action);
94 TextCutLink::CloneN(TextComponentInfoValueType type, unsigned int value)
96 TextCutLink* pLinkElement = null;
98 pLinkElement = new (std::nothrow) TextCutLink(__isEditable, __linkType, _pText, _length,
99 TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, _pFont, _foregroundColor, _backgroundColor, _outlineColor);
103 , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
105 TextElement::CopyMembers(pLinkElement);
107 pLinkElement->__isEdited = __isEdited;
108 pLinkElement->SetValue(type, value);
114 TextCutLink::CopyN(int textStartIndex, int textLength)
116 const wchar_t* pText = null;
118 TextCutLink* pLinkElement = null;
121 , textStartIndex < _length
122 , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
124 if (textStartIndex + textLength > _length)
126 textLength = _length - textStartIndex;
131 , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
133 pText = &_pText[_offset + textStartIndex];
135 pLinkElement = new (std::nothrow) TextCutLink(__isEditable, __linkType, pText, textLength, _sourceType,
136 _pFont, _foregroundColor, _backgroundColor, _outlineColor);
140 , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
142 pLinkElement->_isBackgroundDrawingModeEnabled = _isBackgroundDrawingModeEnabled;
143 pLinkElement->__isEdited = __isEdited;
149 TextCutLink::SetValue(TextComponentInfoValueType type, unsigned int value)
153 case SET_CUTLINK_TYPE:
155 return E_INVALID_ARG;
157 case SET_CUTLINK_EDITABLE:
159 return E_INVALID_ARG;
161 case SET_CUTLINK_EDITING:
164 __isEdited = (bool) value;
167 return E_INVALID_ARG;
173 if (!__isEdited && type == SET_TEXT_OFFSET)
175 return E_INVALID_ARG;
178 return TextSimple::SetValue(type, value);
182 TextCutLink::GetValue(TextComponentInfoValueType type) const
186 case SET_CUTLINK_TYPE:
188 return (unsigned int) __linkType;
190 case SET_CUTLINK_EDITABLE:
192 return (unsigned int) __isEditable;
194 case SET_CUTLINK_EDITING:
196 return (unsigned int) __isEdited;
200 return TextSimple::GetValue(type);
205 TextCutLink::SetSelect(bool isSelected)
207 __isSelected = isSelected;
211 TextCutLink::GetSelect(void) const
217 TextCutLink::SetUserColor(const Color& color, const Color& colorInSelect)
219 __isColorDefined = true;
221 __linkSelectedColor = colorInSelect;
225 TextCutLink::ResetUserColor(void)
227 __isColorDefined = false;
231 TextCutLink::SetTextOffset(int offset)
235 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
237 return TextSimple::SetTextOffset(offset);
241 TextCutLink::ChangeTextOffset(wchar_t* pText, int gap)
245 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
247 return TextSimple::ChangeTextOffset(pText, gap);
251 TextCutLink::GetCurrentFont(void) const
255 return TextSimple::GetCurrentFont();
262 TextCutLink::GetCurrentForegroundColor(void) const
266 return TextSimple::GetCurrentForegroundColor();
269 if (__isColorDefined)
273 return __linkSelectedColor;
281 return Color::GetColor(COLOR_ID_BLUE);
284 return Color::GetColor(COLOR_ID_BLUE);
288 TextCutLink::GetCurrentBackgroundColor(void) const
292 return TextSimple::GetCurrentBackgroundColor();
297 return Color::GetColor(COLOR_ID_WHITE);
300 return Color::GetColor(COLOR_ID_WHITE);
304 TextCutLink::GetCurrentOutlineColor(void) const
308 return TextSimple::GetCurrentOutlineColor();
311 return Color::GetColor(COLOR_ID_WHITE);
315 TextCutLink::GetEditable(void) const
321 TextCutLink::SetEditModeEnable(bool enable)
327 TextCutLink::IsEditModeEnable(void) const
332 Tizen::Base::Utility::LinkType
333 TextCutLink::GetCutLinkType(void) const
338 }}} // Tizen::Graphics::_Text