23 ** |
23 ** |
24 ****************************************************************************/ |
24 ****************************************************************************/ |
25 |
25 |
26 #include "hbtextedit.h" |
26 #include "hbtextedit.h" |
27 #include "hbtextedit_p.h" |
27 #include "hbtextedit_p.h" |
|
28 #include "hbsmileyengine_p.h" |
28 |
29 |
29 #include <QTextCursor> |
30 #include <QTextCursor> |
30 |
31 |
31 #ifdef HB_TEXT_MEASUREMENT_UTILITY |
32 #ifdef HB_TEXT_MEASUREMENT_UTILITY |
32 #include "hbtextmeasurementutility_p.h" |
33 #include "hbtextmeasurementutility_p.h" |
183 */ |
184 */ |
184 void HbTextEdit::polish( HbStyleParameters& params ) |
185 void HbTextEdit::polish( HbStyleParameters& params ) |
185 { |
186 { |
186 Q_D(HbTextEdit); |
187 Q_D(HbTextEdit); |
187 |
188 |
188 const QString KTextRowLinesColorCSSName = "line-color"; |
189 if (isVisible()) { |
189 const QString KTextRowLinesWidthCSSName = "line-width"; |
190 |
190 const QString KTextRowLinesEnabledCSSName = "line-enabled"; |
191 // const QString KTextRowLinesColorCSSName = "line-color"; |
191 |
192 const QString KTextRowLinesWidthCSSName = "line-width"; |
192 // ------ adding css parameters ------ |
193 const QString KSmileyScaleCSSName = "smiley-scale"; |
193 params.addParameter(KTextRowLinesColorCSSName, Qt::magenta); |
194 const QString KTextRowLinesStyleCSSName = "line-style"; |
194 params.addParameter(KTextRowLinesWidthCSSName, 0.0); |
195 |
195 params.addParameter(KTextRowLinesEnabledCSSName); |
196 // ------ adding css parameters ------ |
196 |
197 // params.addParameter(KTextRowLinesColorCSSName, Qt::black); |
197 HbAbstractEdit::polish(params); |
198 params.addParameter(KTextRowLinesWidthCSSName, 0.0); |
198 |
199 params.addParameter(KSmileyScaleCSSName); |
199 // ------ interpreting css parameters ------ |
200 params.addParameter(KTextRowLinesStyleCSSName); |
200 QVariant param = params.value( KTextRowLinesEnabledCSSName ); |
201 |
201 d->mShowTextBaseLine = param.toBool(); |
202 HbAbstractEdit::polish(params); |
202 |
203 |
203 param = params.value(KTextRowLinesColorCSSName); |
204 // ------ interpreting css parameters ------ |
204 if(param.canConvert(QVariant::Color)) { |
205 // QVariant param = params.value(KTextRowLinesColorCSSName); |
205 d->mTextBaseLinePen.setColor(param.value<QColor>()); |
206 // if(param.canConvert(QVariant::Color)) { |
|
207 // d->mTextBaseLinePen.setColor(param.value<QColor>()); |
|
208 // } |
|
209 |
|
210 QVariant param = params.value(KTextRowLinesWidthCSSName); |
|
211 if(param.canConvert(QVariant::Double)) { |
|
212 d->mTextBaseLinePen.setWidthF(qMax(param.toDouble(), 0.0)); |
|
213 } |
|
214 |
|
215 param = params.value(KSmileyScaleCSSName); |
|
216 if(param.canConvert(QVariant::Double)) { |
|
217 d->smileyEngineInstance()->setSmileyScaleFactor(param.toDouble()); |
|
218 } |
|
219 |
|
220 param = params.value(KTextRowLinesStyleCSSName); |
|
221 if(param.canConvert(QVariant::String)) { |
|
222 d->setBaseLineStyleFromString(param.toString()); |
|
223 } |
|
224 } else { |
|
225 HbAbstractEdit::polish(params); |
206 } |
226 } |
207 |
227 } |
208 param = params.value(KTextRowLinesWidthCSSName); |
228 |
209 if(param.canConvert(QVariant::Double)) { |
229 |
210 d->mTextBaseLinePen.setWidthF(qMax(param.toDouble(), 0.0)); |
230 /*! |
|
231 @proto |
|
232 |
|
233 Sets if row lines to be visible or not. |
|
234 |
|
235 \sa HbTextEdit::isLined() const |
|
236 */ |
|
237 void HbTextEdit::setLined(bool visible) |
|
238 { |
|
239 Q_D(HbTextEdit); |
|
240 |
|
241 if (d->mShowTextBaseLine!=visible) { |
|
242 d->mShowTextBaseLine=visible; |
|
243 d->mShowTextBaseLineApiProtectionFlag = true; |
|
244 update(); |
211 } |
245 } |
212 } |
246 } |
213 |
247 |
214 /*! |
248 /*! |
215 \reimp |
249 @proto |
216 */ |
250 |
217 void HbTextEdit::focusOutEvent(QFocusEvent * event) |
251 Returns true if row lines are visble. |
218 { |
252 |
219 HbAbstractEdit::focusOutEvent(event); |
253 \sa HbTextEdit::setLined(bool) |
220 setBackgroundItem(HbStyle::P_TextEdit_frame_normal); |
254 */ |
221 } |
255 bool HbTextEdit::isLined() const |
222 |
256 { |
223 /*! |
257 Q_D(const HbTextEdit); |
224 \reimp |
258 |
225 */ |
259 return d->mShowTextBaseLine; |
226 void HbTextEdit::focusInEvent(QFocusEvent * event) |
260 } |
227 { |
|
228 HbAbstractEdit::focusInEvent(event); |
|
229 setBackgroundItem(HbStyle::P_TextEdit_frame_highlight); |
|
230 } |
|
231 |
|