emailuis/nmailuiwidgets/src/nmeditortextedit.cpp
changeset 48 10eaf342f539
parent 47 f83bd4ae1fe3
child 51 d845db10c0d4
equal deleted inserted replaced
47:f83bd4ae1fe3 48:10eaf342f539
    31     HbStyleLoader::registerFilePath(FILE_PATH_WIDGETML);
    31     HbStyleLoader::registerFilePath(FILE_PATH_WIDGETML);
    32     HbStyleLoader::registerFilePath(FILE_PATH_CSS);
    32     HbStyleLoader::registerFilePath(FILE_PATH_CSS);
    33 
    33 
    34     mCustomTextColor = QPair<bool, QColor>(false, Qt::black);
    34     mCustomTextColor = QPair<bool, QColor>(false, Qt::black);
    35     
    35     
    36     // Enable scrolling using cursor
    36     // Disable HbTextEdit scrolling. Background scroll area will handle scrolling.
    37     setScrollable(true);
    37     setScrollable(false);
    38     scrollArea()->setScrollDirections(Qt::Horizontal);
    38     scrollArea()->setScrollDirections(0);
    39 
    39 
    40     // set background colour to plain white
    40     // set background colour to plain white
    41     QPixmap whitePixmap(10,10);
    41     QPixmap whitePixmap(10,10);
    42     whitePixmap.fill(Qt::white);
    42     whitePixmap.fill(Qt::white);
    43     QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem (whitePixmap);
    43     QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem (whitePixmap);
    44     setBackgroundItem(pixmapItem); 
    44     setBackgroundItem(pixmapItem); 
    45     
    45     
    46     // disables highlight frame for now - new api to set the frame item should be release somewhere wk26
    46     // disables highlight frame for now - new api to set the frame item should be release somewhere wk26
    47     setFocusHighlight(HbStyle::P_TextEdit_frame_highlight, HbWidget::FocusHighlightNone);
    47     setFocusHighlight(HbStyle::P_TextEdit_frame_highlight, HbWidget::FocusHighlightNone);
    48     
    48     
       
    49     // Create custom palette based on the current one
       
    50     QPalette testPalette = QApplication::palette();
       
    51 
       
    52     // Sets the selection background colour
       
    53     testPalette.setColor(QPalette::Active, QPalette::Highlight, Qt::cyan);
       
    54     testPalette.setColor(QPalette::Inactive, QPalette::Highlight, Qt::cyan);
       
    55 
       
    56     // Sets the link and visited link colours
       
    57     testPalette.setColor(QPalette::Active, QPalette::Link, Qt::darkBlue);
       
    58     testPalette.setColor(QPalette::Inactive, QPalette::Link, Qt::darkBlue);
       
    59     testPalette.setColor(QPalette::Active, QPalette::LinkVisited, Qt::darkMagenta);
       
    60     testPalette.setColor(QPalette::Inactive, QPalette::LinkVisited, Qt::darkMagenta);
       
    61 
       
    62     // Update custom palette for this widget
       
    63     setPalette(testPalette);
       
    64 
    49     connect(this, SIGNAL(contentsChanged()), this, SLOT(updateCustomTextColor()));
    65     connect(this, SIGNAL(contentsChanged()), this, SLOT(updateCustomTextColor()));
    50 }
    66 }
    51 
    67 
    52 /*!
    68 /*!
    53     Destructor
    69     Destructor
   133     
   149     
   134     return mCustomTextColor;
   150     return mCustomTextColor;
   135 }
   151 }
   136 
   152 
   137 /*!
   153 /*!
   138  *  Returns the calculated rect in item coordinates of the editor for the the given \a position inside a document.
   154  *  Returns the rectangle for the cursor.
   139  */
   155  */
   140 QRectF NmEditorTextEdit::rectForPosition(int position)
   156 QRectF NmEditorTextEdit::rectForCursorPosition() const
   141 {
   157 {
   142     return HbTextEdit::rectForPosition(position);
   158     NM_FUNCTION;
       
   159     
       
   160     return HbTextEdit::rectForPosition(cursorPosition());
   143 }
   161 }
   144 
   162