Esempio n. 1
0
/*
 * Class:     org_coolreader_crengine_ReaderView
 * Method:    applySettingsInternal
 * Signature: (Ljava/util/Properties;)Z
 */
JNIEXPORT jboolean JNICALL Java_org_coolreader_crengine_ReaderView_applySettingsInternal
  (JNIEnv * _env, jobject _this, jobject _props)
{
	CRLog::trace("ReaderView_applySettingsInternal");
	CRJNIEnv env(_env);
    ReaderViewNative * p = getNative(_env, _this);
	DocViewCallback callback( _env, p->_docview, _this );
	CRPropRef props = env.fromJavaProperties(_props);
	CRPropRef oldProps = p->_docview->propsGetCurrent();
	p->_docview->propsUpdateDefaults( props );
	//bool oldNightMode = oldProps->getBoolDef(PROP_NIGHT_MODE, false);
	//bool newNightMode = props->getBoolDef(PROP_NIGHT_MODE, false);
	lUInt32 oldTextColor = oldProps->getColorDef(PROP_FONT_COLOR, 0x000000);
	lUInt32 newTextColor = props->getColorDef(PROP_FONT_COLOR, 0x000000);
	lUInt32 oldStatusColor = oldProps->getColorDef(PROP_STATUS_FONT_COLOR, 0xFF000000);
	lUInt32 newStatusColor = props->getColorDef(PROP_STATUS_FONT_COLOR, 0xFF000000);
	//CRLog::debug("Text colors: %x->%x, %x->%x", oldTextColor, newTextColor, oldStatusColor, newStatusColor);
	p->_docview->propsApply( props );
	lUInt32 batteryColor = newStatusColor;
	if ( batteryColor==0xFF000000 )
		batteryColor = newTextColor;
	if ( 1 || oldTextColor!=newTextColor || oldStatusColor!=newStatusColor ) { //oldNightMode!=newNightMode
		//CRLog::debug("%x->%x, %x->%x: Setting Battery icon color = #%06x", oldTextColor, newTextColor, oldStatusColor, newStatusColor, batteryColor);
	    LVRefVec<LVImageSource> icons = getBatteryIcons( batteryColor );
		//CRLog::debug("Setting list of Battery icon bitmats");
	    p->_docview->setBatteryIcons( icons );
		//CRLog::debug("Setting list of Battery icon bitmats - done");
	}
    return JNI_TRUE;
}
Esempio n. 2
0
ReaderViewNative::ReaderViewNative()
{
	_docview = new LVDocView(16); //16bpp

    LVRefVec<LVImageSource> icons = getBatteryIcons( 0x000000 );
    _docview->setBatteryIcons( icons );

    LVArray<int> sizes( cr_font_sizes, sizeof(cr_font_sizes)/sizeof(int) );
    _docview->setShowCover( true );
    _docview->setFontSizes( sizes, true );
	_docview->setFontSize(24);
	_docview->setBatteryFont( fontMan->GetFont( 16, 600, false, css_ff_sans_serif, lString8("Droid Sans") ));
	
	_docview->createDefaultDocument(lString16("Welcome to CoolReader"), lString16("Please select file to open"));
}
Esempio n. 3
0
static int newDocView(lua_State *L) {
	int width = luaL_checkint(L, 1);
	int height = luaL_checkint(L, 2);
	LVDocViewMode view_mode = (LVDocViewMode)luaL_checkint(L, 3);

	CreDocument *doc = (CreDocument*) lua_newuserdata(L, sizeof(CreDocument));
	luaL_getmetatable(L, "credocument");
	lua_setmetatable(L, -2);

	doc->text_view = new LVDocView();
	//doc->text_view->setBackgroundColor(0xFFFFFF);
	//doc->text_view->setTextColor(0x000000);
	//doc->text_view->doCommand(DCMD_SET_DOC_FONTS, 1);
	//doc->text_view->doCommand(DCMD_SET_INTERNAL_STYLES, 1);
	doc->text_view->setViewMode(view_mode, -1);
	doc->text_view->Resize(width, height);
	doc->text_view->setPageHeaderInfo(PGHDR_AUTHOR|PGHDR_TITLE|PGHDR_PAGE_NUMBER|PGHDR_PAGE_COUNT|PGHDR_CHAPTER_MARKS|PGHDR_CLOCK);

	// it will overwrite all settings by values found in ./data/cr3.ini
	CRPropRef props = doc->text_view->propsGetCurrent();
	LVStreamRef stream = LVOpenFileStream("data/cr3.ini", LVOM_READ);
	if ( !stream.isNull() && props->loadFromStream(stream.get()) ) {
		doc->text_view->propsApply(props);
	} else {
		// Tweak the default settings to be slightly less random
		props->setString(PROP_FALLBACK_FONT_FACE, "Noto Sans CJK SC");
		props->setString(PROP_HYPHENATION_DICT, "English_US_hyphen_(Alan).pdb");
		props->setString(PROP_STATUS_FONT_FACE, "Noto Sans");
		props->setString(PROP_FONT_FACE, "Noto Serif");
		props->setInt(PROP_FONT_HINTING, 2);	// autohint, to be conservative (some ttf fonts' bytecode is truly crappy)
		props->setInt(PROP_FONT_KERNING_ENABLED, 1);
		props->setString("styles.pre.font-face", "font-family: \"Droid Sans Mono\"");

		stream = LVOpenFileStream("data/cr3.ini", LVOM_WRITE);
		props->saveToStream(stream.get());
	}

	doc->text_view->setBatteryIcons(getBatteryIcons(0x000000));

	return 1;
}
Esempio n. 4
0
 */JNIEXPORT jint JNICALL Java_com_reader_util_BitmapUtil_DrawBatteryBitmap(
		JNIEnv *e, jclass cls, jobject bitmap, jint which, jint color) {
	SET_ENV(e);
	LVBaseDrawBuf * drawbuf = (LVBaseDrawBuf *)BitmapAccessorInterface::getInstance()->lock(e,
			bitmap);
	AndroidBitmapInfo info;

	getInfo(e,bitmap,&info);
	CRLog::debug("song battery drawbuf lock format %d",info.format);
	if (drawbuf != NULL) {
		drawbuf->Clear(0xFF000000);
		LVRefVec<LVImageSource> batteryicon = getBatteryIcons(0x0);

		drawbuf->Draw(batteryicon[9], 0, 0, info.width, info.height);
		BitmapAccessorInterface::getInstance()->unlock(e, bitmap, drawbuf);
		CRLog::debug("song battery drawbuf lock format battery end");
	} else {
		CRLog::error("bitmap accessor is invalid");
	}
	return 0;
}