Esempio n. 1
0
void CRBookmarkMenuItem::Draw( LVDrawBuf & buf, lvRect & rc, CRRectSkinRef skin, CRRectSkinRef valueSkin, bool selected )
{
    _itemDirty = false;
    if ( !_bookmark ) {
        CRMenuItem::Draw( buf, rc, skin, valueSkin, selected );
        return;
    }
    lvRect itemBorders = skin->getBorderWidths();
    skin->draw( buf, rc );
    buf.SetTextColor( 0x000000 );
    buf.SetBackgroundColor( 0xFFFFFF );
    int imgWidth = DrawIcon( buf, rc, itemBorders );

    lvRect textRect = rc;
    textRect.left += imgWidth;
    lvRect posRect = textRect;
    lString16 text = _bookmark->getPosText();
    if ( !text.empty() ) {
        posRect.bottom = posRect.top + skin->getFont()->getHeight() + itemBorders.top + itemBorders.bottom;
        textRect.top = posRect.bottom - itemBorders.bottom;
    }
    lString16 postext(_("Page $1 ($2%)"));
    postext.replaceIntParam(1, _page+1);
    postext.replaceParam(2, lString16::itoa( _bookmark->getPercent()/100 ) << "." << fmt::decimal(_bookmark->getPercent()%100));
    postext << "  " << _bookmark->getTitleText();
    skin->drawText( buf, posRect, postext );
    if ( !text.empty() )
        valueSkin->drawText( buf, textRect, text );
}
Esempio n. 2
0
void CRBookmarkMenu::showContextMenu()
{
	CRBookmarkMenuItem *item = static_cast<CRBookmarkMenuItem *>(_items[_selectedItem]);
	CRMenuSkinRef skin = getSkin();
	CRRectSkinRef separatorSkin = skin->getSeparatorSkin();
    int separatorHeight = 0;
    if ( !separatorSkin.isNull() )
        separatorHeight = separatorSkin->getMinSize().y;

    lvRect clientRect;
    getClientRect(clientRect);
    lvPoint itemSize = getMaxItemSize();
	_contextMenu[2].type = item->getBookmark() ? ITEM_ACTIVE : ITEM_INACTIVE;
        int y = clientRect.top + (itemSize.y + separatorHeight) * (_selectedItem - _topItem) +
			((itemSize.y + separatorHeight)/4);
	if (_contextMenu[0].text == NULL) {
		_contextMenu[0].text = (char *)_("Set bookmark");
		_contextMenu[1].text = (char *)_("Go to bookmark");
		_contextMenu[2].text = (char *)_("Delete bookmark");
	}
	OpenMenu(_contextMenu, 
		_goToMode ? DCMD_BOOKMARK_GO_N : DCMD_BOOKMARK_SAVE_N,
		ScreenWidth()/4, 
		y, 
		handle_contextMenu);
}
Esempio n. 3
0
    virtual void draw()
    {
        BackgroundFitWindow::draw();
        CRRectSkinRef skin = _wm->getSkin()->getWindowSkin( L"#dialog" )->getClientSkin();
        LVDrawBuf * buf = _wm->getScreen()->getCanvas().get();
        skin->draw( *buf, _rect );
        lvRect borders = skin->getBorderWidths();
#ifdef CR_POCKETBOOK
        lString16 prompt;
        switch (_selectedIndex) {
        case 0:
            prompt = lString16(_("Select next/prev paragraph"));
            break;
        case 1:
            prompt = lString16(_("Select one more paragraph"));
            break;
        case 2:
            prompt = lString16(_("Deselect paragraph"));
            break;
        case 3:
            prompt = lString16(_("Select one more phrase"));
            break;
        case 4:
            prompt = lString16(_("Deselect phrase"));
            break;

        }
        lvRect keyRect = _rect;
        int promptWidth = skin->measureText(prompt).x;
        keyRect.right = keyRect.left + promptWidth + borders.left + borders.right;
        if ( !keyRect.isEmpty() ) {
            skin->draw( *_wm->getScreen()->getCanvas(), keyRect );
            skin->drawText( *_wm->getScreen()->getCanvas(), keyRect, prompt );
        }
        CRToolBarSkinRef tbSkin = _wm->getSkin()->getToolBarSkin( L"#cite-toolbar" );
        if (!tbSkin.isNull()) {
            keyRect.left += (borders.right + _wm->getScreen()->getWidth() * 2/3/*promptWidth*/);
            keyRect.right = _rect.right;
            CRButtonListRef buttons = tbSkin->getButtons();
            if (!(buttons.isNull() || _itemsCount != buttons->length()))
                tbSkin->drawToolBar(*_wm->getScreen()->getCanvas(), keyRect, true, _selectedIndex);
        }
#else
                lString16 prompt(_("Select text"));
		buf->FillRect( _rect, 0xAAAAAA );
		lvRect keyRect = _rect;
		LVFontRef font = fontMan->GetFont( 20, 600, false, css_ff_sans_serif, lString8("Arial")); //skin->getFont();
//        int margin = 4;
		keyRect.right = _rect.right;
		if ( !keyRect.isEmpty() ) {
			skin->draw( *_wm->getScreen()->getCanvas(), keyRect );
			skin->drawText( *_wm->getScreen()->getCanvas(), keyRect, prompt );
		}
#endif
    }
Esempio n. 4
0
void CRCitesMenu::showContextMenu()
{
    CRBookmarkMenuItem *item = static_cast<CRBookmarkMenuItem *>(_items[_selectedItem]);
    if (item->getBookmark() == NULL)
        return;
    CRMenuSkinRef skin = getSkin();
    CRRectSkinRef separatorSkin = skin->getSeparatorSkin();
    int separatorHeight = 0;
    if ( !separatorSkin.isNull() )
        separatorHeight = separatorSkin->getMinSize().y;
    lvRect clientRect;
    getClientRect(clientRect);
    lvPoint itemSize = getMaxItemSize();
    int y = clientRect.top + (itemSize.y + separatorHeight) * (_selectedItem - _topItem) +
                        ((itemSize.y + separatorHeight)/4);
    if (_cites_contextMenu[0].text == NULL) {
        _cites_contextMenu[0].text = (char *)_("Go to citation");
        _cites_contextMenu[1].text = (char *)_("Delete citation");
    }
    OpenMenu(_cites_contextMenu, DCMD_BOOKMARK_GO_N, ScreenWidth()/4, y,
                handle_citesContextMenu);
}
Esempio n. 5
0
void CRRecentBookMenuItem::Draw( LVDrawBuf & buf, lvRect & rc, CRRectSkinRef skin, CRRectSkinRef valueSkin, bool selected )
{
    if ( !_book ) {
        CRMenuItem::Draw( buf, rc, skin, valueSkin, selected );
        return;
    }
    lvRect itemBorders = skin->getBorderWidths();
    skin->draw( buf, rc );
    buf.SetTextColor( 0x000000 );
    buf.SetBackgroundColor( 0xFFFFFF );
    int imgWidth = 0;
    int hh = rc.bottom - rc.top - itemBorders.top - itemBorders.bottom;
    if ( !_image.isNull() ) {
        int w = _image->GetWidth();
        int h = _image->GetHeight();
        buf.Draw( _image, rc.left + hh/2-w/2 + itemBorders.left, rc.top + hh/2 - h/2 + itemBorders.top, w, h );
        imgWidth = w + 8;
    }
    lvRect textRect = rc;
    textRect.left += imgWidth;

    lString16 author = _book->getAuthor();
    lString16 title = _book->getTitle();
    lString16 series = _book->getSeries();
    if ( title.empty() )
        title = _book->getFileName();
    else if ( !series.empty() )
        title << " - " << series;

    lvRect posRect = textRect;
    if ( !author.empty() ) {
        posRect.bottom = posRect.top + skin->getFont()->getHeight() + itemBorders.top + itemBorders.bottom;
        textRect.top = posRect.bottom - itemBorders.bottom;
        skin->drawText( buf, posRect, author );
    }
    if ( !title.empty() )
        valueSkin->drawText( buf, textRect, title );
}
Esempio n. 6
0
void CRRecentBooksMenu::showContextMenu()
{
	CRRecentBookMenuItem *item = static_cast<CRRecentBookMenuItem *>(getItems()[_selectedItem]);
	CRMenuSkinRef skin = getSkin();
	CRRectSkinRef separatorSkin = skin->getSeparatorSkin();
    int separatorHeight = 0;
    if ( !separatorSkin.isNull() )
        separatorHeight = separatorSkin->getMinSize().y;

    lvRect clientRect;
    getClientRect(clientRect);
    lvPoint itemSize = getMaxItemSize();
        int y = clientRect.top + (itemSize.y + separatorHeight) * (_selectedItem - _topItem) +
			((itemSize.y + separatorHeight)/4);
	if (_contextMenu[0].text == NULL) {
		_contextMenu[0].text = (char *)_("Open book");
		_contextMenu[1].text = (char *)_("Delete record");
	}
	OpenMenu(_contextMenu, MCMD_OPEN_RECENT_BOOK,
		ScreenWidth()/4, 
		y, 
		handle_contextMenu);
}
Esempio n. 7
0
void CRT9Keyboard::draw()
{
    BackgroundFitWindow::draw();
    CRMenuSkinRef skin = _wm->getSkin()->getMenuSkin( L"#t9input" );
    CRRectSkinRef shortcutSkin = skin->getItemShortcutSkin();
    CRRectSkinRef itemSkin = skin->getItemSkin();
    CRRectSkinRef clientSkin = skin->getClientSkin();
    LVDrawBuf * buf = _wm->getScreen()->getCanvas().get();
    skin->draw( *buf, _rect );
    lString16 prompt = Utf8ToUnicode(selector_.getPrefix());
    prompt << L"_";
    skin->draw( *buf, _rect );
    //buf->FillRect( _rect, 0xAAAAAA );
    lvRect rect = _rect;
    lvRect borders = skin->getBorderWidths();
    rect.shrinkBy( borders );
    lvRect keyRect = rect;
    // lvPoint minSizeN = shortcutSkin->getMinSize();
    for ( int i=0; i<encoding_.length(); i++ ) {
        lString16 txtN = lString16::itoa(i);
        lString16 txt = encoding_[i];
        if ( txt.empty() )
            continue;
        // label 0..9
        lvPoint sz = shortcutSkin->measureTextItem( txtN );
        keyRect.right = keyRect.left + sz.x; //borders.left + borders.right;
        shortcutSkin->draw( *buf, keyRect );
        shortcutSkin->drawText( *buf, keyRect, txtN );
        keyRect.left = keyRect.right;
        // chars (abc)
        sz = itemSkin->measureTextItem( txt );
        keyRect.right = keyRect.left + sz.x; //borders.left + borders.right;
        itemSkin->draw( *buf, keyRect );
        itemSkin->drawText( *buf, keyRect, txt );
        keyRect.left = keyRect.right; //borders.left;
    }
    keyRect.right = rect.right;
    if ( !clientSkin.isNull() && !keyRect.isEmpty() ) {
        clientSkin->draw( *buf, keyRect );
        clientSkin->drawText( *buf, keyRect, prompt );
    }
}
Esempio n. 8
0
void CRScreenKeyboard::draw()
{
    CRRectSkinRef titleSkin = _skin->getTitleSkin();
    CRRectSkinRef clientSkin = _skin->getClientSkin();
    CRRectSkinRef itemSkin = _skin->getItemSkin();
    CRRectSkinRef shortcutSkin = _skin->getItemShortcutSkin();
    lvRect borders = clientSkin->getBorderWidths();
    LVRef<LVDrawBuf> drawbuf = _wm->getScreen()->getCanvas();
    _skin->draw( *drawbuf, _rect );
    lvRect titleRect = _skin->getTitleRect( _rect );
    titleSkin->draw( *drawbuf, titleRect );
    titleSkin->drawText( *drawbuf, titleRect, _title );
    // draw toc
    lvRect inputRect = _skin->getClientRect( _rect );
    inputRect.shrinkBy( borders );
    lvRect kbdRect = inputRect;
    inputRect.bottom = inputRect.top + 40; // TODO
    kbdRect.top = inputRect.bottom;

    //clientSkin->draw( *drawbuf, kbdRect );
    int dx = kbdRect.width() / (_cols+1);
    int dy = kbdRect.height() / (_rows+1);
    for ( int y = 0; y<=_rows; y++ ) {
        for ( int x = 0; x<=_cols; x++ ) {
            lString16 txt;
            bool header = true;
            if ( y==0 && x>0 ) {
                txt = lString16::itoa( x<10 ? x : 0 );
            } else if ( x==0 && y>0 ) {
                txt = lString16::itoa( y );
            } else if ( x>0 && y>0 ) {
                header = false;
                lString16 s = _keymap[ y - 1 ];
                if ( x-1 < (int)s.length() )
                    txt = lString16(&s[ x - 1 ], 1);
                else
                    txt = L" ";
            }
            lvRect rc = kbdRect;
            rc.top += dy * y;
            rc.left += dx * x;
            rc.bottom = rc.top + dy;
            rc.right = rc.left + dx;
            if ( header )
                shortcutSkin->draw( *drawbuf, rc );
            else
                itemSkin->draw( *drawbuf, rc );
            //drawbuf->FillRect( rc, header ? 0xAAAAAA : 0xFFFFFF );
            //drawbuf->Rect( rc, header ? 0x000000 : 0x555555 );
            if ( !txt.empty() ) {
                if ( header )
                    shortcutSkin->drawText( *drawbuf, rc, txt );
                else
                    itemSkin->drawText( *drawbuf, rc, txt );
            }
        }
    }
    // draw input area
    clientSkin->draw( *drawbuf, inputRect );
    clientSkin->drawText( *drawbuf, inputRect, lString16(" ") + _value+L"_" );
}