219 */ |
219 */ |
220 void NmEditorContent::setEditorContentHeight() |
220 void NmEditorContent::setEditorContentHeight() |
221 { |
221 { |
222 NM_FUNCTION; |
222 NM_FUNCTION; |
223 |
223 |
224 // the height of the margin between the title bar and the header |
224 HbStyle* style = mScrollAreaContents->style(); |
225 qreal topMargin = 0; |
225 |
226 HbStyle().parameter("hb-param-margin-gene-top", topMargin); |
226 if (style) { |
227 |
227 // the height of the margin between the title bar and the header |
228 // header height |
228 qreal topMargin = 0; |
229 qreal headerHeight = mHeader->headerHeight(); |
229 style->parameter("hb-param-margin-gene-top", topMargin); |
230 |
230 |
231 // body area editor's document height with margins added |
231 // header height |
232 qreal documentHeightAndMargins = mEditorWidget->document()->size().height() + |
232 qreal headerHeight = mHeader->headerHeight(); |
233 (mEditorWidget->document()->documentMargin() * 2); |
233 |
234 |
234 // body area editor's document height with margins added |
235 // chrome height |
235 qreal documentHeightAndMargins = mEditorWidget->document()->size().height() + |
236 qreal chromeHeight = 0; |
236 (mEditorWidget->document()->documentMargin() * 2); |
237 HbStyle().parameter("hb-param-widget-chrome-height", chromeHeight); |
237 |
238 |
238 // chrome height |
239 // screen height |
239 qreal chromeHeight = 0; |
240 qreal screenHeight = mApplication.screenSize().height(); |
240 style->parameter("hb-param-widget-chrome-height", chromeHeight); |
241 |
241 |
242 // set min size for the body area so that at least the screen area is always filled |
242 // screen height |
243 qreal bodyAreaMinSize = screenHeight - chromeHeight - topMargin - headerHeight; |
243 qreal screenHeight = mApplication.screenSize().height(); |
244 |
244 |
245 qreal bodyAreaSize = fmax(bodyAreaMinSize, documentHeightAndMargins); |
245 // set min size for the body area so that at least the screen area is always filled |
246 |
246 qreal bodyAreaMinSize = screenHeight - chromeHeight - topMargin - headerHeight; |
247 mScrollAreaContents->setPreferredHeight(topMargin + headerHeight + bodyAreaSize); |
247 |
|
248 qreal bodyAreaSize = fmax(bodyAreaMinSize, documentHeightAndMargins); |
|
249 |
|
250 mScrollAreaContents->setPreferredHeight(topMargin + headerHeight + bodyAreaSize); |
|
251 } |
248 } |
252 } |
249 |
253 |
250 /*! |
254 /*! |
251 This slot is used to set width for the body field. |
255 This slot is used to set width for the body field. |
252 For some reason HbTextEdit does not set it's width, so we need to se it here. |
256 For some reason HbTextEdit does not set it's width, so we need to se it here. |
299 if (!notFound) { |
303 if (!notFound) { |
300 QPointF topLeftPos = focused->mapToItem(mScrollAreaContents, localRect.topLeft()); |
304 QPointF topLeftPos = focused->mapToItem(mScrollAreaContents, localRect.topLeft()); |
301 QPointF bottomRightPos = |
305 QPointF bottomRightPos = |
302 focused->mapToItem(mScrollAreaContents, localRect.bottomRight()); |
306 focused->mapToItem(mScrollAreaContents, localRect.bottomRight()); |
303 qreal marginRight = 0; |
307 qreal marginRight = 0; |
304 HbStyle().parameter("hb-param-margin-gene-right", marginRight); |
308 mScrollArea->style()->parameter("hb-param-margin-gene-right", marginRight); |
305 bottomRightPos.rx() += marginRight; |
309 bottomRightPos.rx() += marginRight; |
306 mScrollArea->ensureVisible(topLeftPos); |
310 mScrollArea->ensureVisible(topLeftPos); |
307 mScrollArea->ensureVisible(bottomRightPos); |
311 mScrollArea->ensureVisible(bottomRightPos); |
308 } |
312 } |
309 } |
313 } |
328 { |
332 { |
329 NM_FUNCTION; |
333 NM_FUNCTION; |
330 |
334 |
331 // Get the layout's left margin |
335 // Get the layout's left margin |
332 qreal margin = 0; |
336 qreal margin = 0; |
333 HbStyle().parameter("hb-param-margin-gene-left", margin); |
337 HbInstance::instance()->style()->parameter("hb-param-margin-gene-left", margin); |
334 |
338 |
335 // Calculate header width. (Screen width minus left and right margins. |
339 // Calculate header width. (Screen width minus left and right margins. |
336 qreal headerWidth = mApplication.screenSize().width() - margin - margin; |
340 qreal headerWidth = mApplication.screenSize().width() - margin - margin; |
337 |
341 |
338 // Create translation object for header position adjustment. |
342 // Create translation object for header position adjustment. |
339 QRectF editorBodyRect = mEditorWidget->geometry(); |
343 QRectF editorBodyRect = mEditorWidget->geometry(); |