<commit_before>#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include "RPNCalc.h"
#include "RPNTestHelper.h"

using namespace P4_RPNCALC;

TEST_CASE("Operation Methods")
{
	RPNTestHelper test;

	SECTION("Method: clearAll()")
	{
		REQUIRE(test.expectedInputOutput("50", "50"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("50 100 +", "150"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("50", "50"));
		REQUIRE(test.expectedInputOutput("C", ""));
		REQUIRE(test.expectedInputOutput("50 100 +", "150"));
		REQUIRE(test.expectedInputOutput("C", ""));
	}

	SECTION("Method: clearEntry()")
	{
		REQUIRE(test.expectedInputOutput("50", "50"));
		REQUIRE(test.expectedInputOutput("ce", ""));
		REQUIRE(test.expectedInputOutput("50 100 +", "150"));
		REQUIRE(test.expectedInputOutput("ce", ""));
		REQUIRE(test.expectedInputOutput("50 100 + 200", "200"));
		REQUIRE(test.expectedInputOutput("ce", "150"));
		REQUIRE(test.expectedInputOutput("ce", ""));
		REQUIRE(test.expectedInputOutput("50", "50"));
		REQUIRE(test.expectedInputOutput("CE", ""));
		REQUIRE(test.expectedInputOutput("50 100 +", "150"));
		REQUIRE(test.expectedInputOutput("CE", ""));
		REQUIRE(test.expectedInputOutput("50 100 + 200", "200"));
		REQUIRE(test.expectedInputOutput("CE", "150"));
		REQUIRE(test.expectedInputOutput("CE", ""));
	}

	SECTION("Method: add()")
	{
		REQUIRE(test.expectedInputOutput("3 5 +", "8"));
		REQUIRE(test.expectedInputOutput("2 4 3 +", "7"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("3 4 + 6", "6"));
		REQUIRE(test.expectedInputOutput("4 +", "10"));
		REQUIRE(test.expectedInputOutput("-12 +", "-2"));
		REQUIRE(test.expectedInputOutput("5 +", "3"));
		REQUIRE(test.expectedInputOutput("3 +", "6"));
		REQUIRE(test.expectedInputOutput("10 100 +", "110"));
		REQUIRE(test.expectedInputOutput("10 100+", "110"));
		REQUIRE(test.expectedInputOutput("+", "<<error>>"));
	}

	SECTION("Method: combinations of add() & subtract()")
	{
		REQUIRE(test.expectedInputOutput("40 50 + 60 -", "30"));
		REQUIRE(test.expectedInputOutput("40 50 - 60 +", "50"));
		REQUIRE(test.expectedInputOutput("40 50 60 + -", "-70"));
		REQUIRE(test.expectedInputOutput("40 50 60 - +", "30"));
		REQUIRE(test.expectedInputOutput("-40 -50 + 60 -", "-150"));
		REQUIRE(test.expectedInputOutput("-40 -50 + -60 -", "-30"));
		REQUIRE(test.expectedInputOutput("-40 -50 - 60 +", "70"));
		REQUIRE(test.expectedInputOutput("-40 -50 - -60 +", "-50"));
	}

	SECTION("Method: subtract()")
	{
		REQUIRE(test.expectedInputOutput("5 6 -", "-1"));
		REQUIRE(test.expectedInputOutput("3 9 4 -", "5"));
		REQUIRE(test.expectedInputOutput("-", "-2"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("-1 5 -", "-6"));
		REQUIRE(test.expectedInputOutput("10 100 -", "-90"));
		REQUIRE(test.expectedInputOutput("10 100-", "-90"));
		REQUIRE(test.expectedInputOutput("-", "<<error>>"));
	}

	SECTION("Method: multiply()")
	{
		REQUIRE(test.expectedInputOutput("3 9 7 2 4 *", "8"));
		REQUIRE(test.expectedInputOutput("*", "56"));
		REQUIRE(test.expectedInputOutput("*", "504"));
		REQUIRE(test.expectedInputOutput("*", "1512"));
		REQUIRE(test.expectedInputOutput("*", "<<error>>"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("-4 -6 *", "24"));
		REQUIRE(test.expectedInputOutput("-2 *", "-48"));
		REQUIRE(test.expectedInputOutput("10 100 *", "1000"));
		REQUIRE(test.expectedInputOutput("10 100*", "1000"));
	}

	SECTION("Method: divide()")
	{
		REQUIRE(test.expectedInputOutput("16 4 2 /", "2"));
		REQUIRE(test.expectedInputOutput("/", "8"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("2 5 /", "0.4"));
		REQUIRE(test.expectedInputOutput("9 3 7 /", "0.428571"));
		REQUIRE(test.expectedInputOutput("-1 /", "-0.428571"));
		REQUIRE(test.expectedInputOutput("-1 / ", "0.428571"));
		REQUIRE(test.expectedInputOutput("100 10 /", "10"));
		REQUIRE(test.expectedInputOutput("100 10/", "10"));
		REQUIRE(test.expectedInputOutput("/", "<<error>>"));
	}

	SECTION("Method: mod()")
	{
		REQUIRE(test.expectedInputOutput("16 8 6 %", "2"));
		REQUIRE(test.expectedInputOutput("%", "0"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("%", "<<error>>"));
		REQUIRE(test.expectedInputOutput("10 1 %", "0"));
		REQUIRE(test.expectedInputOutput("10 2 %", "0"));
		REQUIRE(test.expectedInputOutput("10 3 %", "1"));
		REQUIRE(test.expectedInputOutput("10 4 %", "2"));
		REQUIRE(test.expectedInputOutput("10 5 %", "0"));
		REQUIRE(test.expectedInputOutput("10 6 %", "4"));
		REQUIRE(test.expectedInputOutput("10 7 %", "3"));
		REQUIRE(test.expectedInputOutput("10 8 %", "2"));
		REQUIRE(test.expectedInputOutput("10 9 %", "1"));
		REQUIRE(test.expectedInputOutput("10 10 %", "0"));
		REQUIRE(test.expectedInputOutput("100 70 %", "30"));
		REQUIRE(test.expectedInputOutput("100 70%", "30"));
	}

	SECTION("Method: exp()")
	{
		REQUIRE(test.expectedInputOutput("10 2 ^", "100"));
		REQUIRE(test.expectedInputOutput("10 2 2 ^", "4"));
		REQUIRE(test.expectedInputOutput("^", "10000"));
		REQUIRE(test.expectedInputOutput("-10 2 ^", "100"));
		REQUIRE(test.expectedInputOutput("-10 3 ^", "-1000"));
		REQUIRE(test.expectedInputOutput("-10 3^", "-1000"));
		REQUIRE(test.expectedInputOutput("0^", "1"));
		REQUIRE(test.expectedInputOutput("^", "<<error>>"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("100 100^", "1e+200"));
	}

	SECTION("Method: neg()")
	{
		REQUIRE(test.expectedInputOutput("-1000", "-1000"));
		REQUIRE(test.expectedInputOutput("M", "1000"));
		REQUIRE(test.expectedInputOutput("-1000 -1*", "1000"));
		REQUIRE(test.expectedInputOutput("M", "-1000"));
		REQUIRE(test.expectedInputOutput("-4/", "-250"));
		REQUIRE(test.expectedInputOutput("m", "250"));
		REQUIRE(test.expectedInputOutput("-2*", "-500"));
		REQUIRE(test.expectedInputOutput("m", "500"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("m", "<<error>>"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("M", "<<error>>"));
	}

	SECTION("Method: rotateDown()")
	{
		REQUIRE(test.expectedInputOutput("100 200", "200"));
		REQUIRE(test.expectedInputOutput("D", "100"));
		REQUIRE(test.expectedInputOutput("D", "200"));
		REQUIRE(test.expectedInputOutput("d", "100"));
		REQUIRE(test.expectedInputOutput("d", "200"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("D", "<<error>>"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("d", "<<error>>"));
	}

	SECTION("Method: rotateUp()")
	{
		REQUIRE(test.expectedInputOutput("300 500", "500"));
		REQUIRE(test.expectedInputOutput("U", "300"));
		REQUIRE(test.expectedInputOutput("U", "500"));
		REQUIRE(test.expectedInputOutput("u", "300"));
		REQUIRE(test.expectedInputOutput("u", "500"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("U", "<<error>>"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("u", "<<error>>"));
	}
}
<commit_msg>Create RPN_UnitTests.cpp<commit_after>#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include "RPNCalc.h"
#include "RPNTestHelper.h"

using namespace P4_RPNCALC;

TEST_CASE("Operation Methods")
{
	RPNTestHelper test;

	SECTION("Method: clearAll()")
	{
		REQUIRE(test.expectedInputOutput("50", "50"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("50 100 +", "150"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("50 100 + 200", "200"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("CE", ""));
		REQUIRE(test.expectedInputOutput("50", "50"));
		REQUIRE(test.expectedInputOutput("C", ""));
		REQUIRE(test.expectedInputOutput("50 100 +", "150"));
		REQUIRE(test.expectedInputOutput("C", ""));
		REQUIRE(test.expectedInputOutput("50 100 + 200", "200"));
		REQUIRE(test.expectedInputOutput("C", ""));
	}

	SECTION("Method: clearEntry()")
	{
		REQUIRE(test.expectedInputOutput("50", "50"));
		REQUIRE(test.expectedInputOutput("ce", ""));
		REQUIRE(test.expectedInputOutput("50 100 +", "150"));
		REQUIRE(test.expectedInputOutput("ce", ""));
		REQUIRE(test.expectedInputOutput("50 100 + 200", "200"));
		REQUIRE(test.expectedInputOutput("ce", "150"));
		REQUIRE(test.expectedInputOutput("ce", ""));
		REQUIRE(test.expectedInputOutput("50", "50"));
		REQUIRE(test.expectedInputOutput("CE", ""));
		REQUIRE(test.expectedInputOutput("50 100 +", "150"));
		REQUIRE(test.expectedInputOutput("CE", ""));
		REQUIRE(test.expectedInputOutput("50 100 + 200", "200"));
		REQUIRE(test.expectedInputOutput("CE", "150"));
		REQUIRE(test.expectedInputOutput("CE", ""));
	}

	SECTION("Method: add()")
	{
		REQUIRE(test.expectedInputOutput("3 5 +", "8"));
		REQUIRE(test.expectedInputOutput("2 4 3 +", "7"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("3 4 + 6", "6"));
		REQUIRE(test.expectedInputOutput("4 +", "10"));
		REQUIRE(test.expectedInputOutput("-12 +", "-2"));
		REQUIRE(test.expectedInputOutput("5 +", "3"));
		REQUIRE(test.expectedInputOutput("3 +", "6"));
		REQUIRE(test.expectedInputOutput("10 100 +", "110"));
		REQUIRE(test.expectedInputOutput("10 100+", "110"));
		REQUIRE(test.expectedInputOutput("+", "<<error>>"));
	}

	SECTION("Method: combinations of add() & subtract()")
	{
		REQUIRE(test.expectedInputOutput("40 50 + 60 -", "30"));
		REQUIRE(test.expectedInputOutput("40 50 - 60 +", "50"));
		REQUIRE(test.expectedInputOutput("40 50 60 + -", "-70"));
		REQUIRE(test.expectedInputOutput("40 50 60 - +", "30"));
		REQUIRE(test.expectedInputOutput("-40 -50 + 60 -", "-150"));
		REQUIRE(test.expectedInputOutput("-40 -50 + -60 -", "-30"));
		REQUIRE(test.expectedInputOutput("-40 -50 - 60 +", "70"));
		REQUIRE(test.expectedInputOutput("-40 -50 - -60 +", "-50"));
	}

	SECTION("Method: subtract()")
	{
		REQUIRE(test.expectedInputOutput("5 6 -", "-1"));
		REQUIRE(test.expectedInputOutput("3 9 4 -", "5"));
		REQUIRE(test.expectedInputOutput("-", "-2"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("-1 5 -", "-6"));
		REQUIRE(test.expectedInputOutput("10 100 -", "-90"));
		REQUIRE(test.expectedInputOutput("10 100-", "-90"));
		REQUIRE(test.expectedInputOutput("-", "<<error>>"));
	}

	SECTION("Method: multiply()")
	{
		REQUIRE(test.expectedInputOutput("3 9 7 2 4 *", "8"));
		REQUIRE(test.expectedInputOutput("*", "56"));
		REQUIRE(test.expectedInputOutput("*", "504"));
		REQUIRE(test.expectedInputOutput("*", "1512"));
		REQUIRE(test.expectedInputOutput("*", "<<error>>"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("-4 -6 *", "24"));
		REQUIRE(test.expectedInputOutput("-2 *", "-48"));
		REQUIRE(test.expectedInputOutput("10 100 *", "1000"));
		REQUIRE(test.expectedInputOutput("10 100*", "1000"));
	}

	SECTION("Method: divide()")
	{
		REQUIRE(test.expectedInputOutput("16 4 2 /", "2"));
		REQUIRE(test.expectedInputOutput("/", "8"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("2 5 /", "0.4"));
		REQUIRE(test.expectedInputOutput("9 3 7 /", "0.428571"));
		REQUIRE(test.expectedInputOutput("-1 /", "-0.428571"));
		REQUIRE(test.expectedInputOutput("-1 / ", "0.428571"));
		REQUIRE(test.expectedInputOutput("100 10 /", "10"));
		REQUIRE(test.expectedInputOutput("100 10/", "10"));
		REQUIRE(test.expectedInputOutput("/", "<<error>>"));
	}

	SECTION("Method: mod()")
	{
		REQUIRE(test.expectedInputOutput("16 8 6 %", "2"));
		REQUIRE(test.expectedInputOutput("%", "0"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("%", "<<error>>"));
		REQUIRE(test.expectedInputOutput("10 1 %", "0"));
		REQUIRE(test.expectedInputOutput("10 2 %", "0"));
		REQUIRE(test.expectedInputOutput("10 3 %", "1"));
		REQUIRE(test.expectedInputOutput("10 4 %", "2"));
		REQUIRE(test.expectedInputOutput("10 5 %", "0"));
		REQUIRE(test.expectedInputOutput("10 6 %", "4"));
		REQUIRE(test.expectedInputOutput("10 7 %", "3"));
		REQUIRE(test.expectedInputOutput("10 8 %", "2"));
		REQUIRE(test.expectedInputOutput("10 9 %", "1"));
		REQUIRE(test.expectedInputOutput("10 10 %", "0"));
		REQUIRE(test.expectedInputOutput("100 70 %", "30"));
		REQUIRE(test.expectedInputOutput("100 70%", "30"));
	}

	SECTION("Method: exp()")
	{
		REQUIRE(test.expectedInputOutput("10 2 ^", "100"));
		REQUIRE(test.expectedInputOutput("10 2 2 ^", "4"));
		REQUIRE(test.expectedInputOutput("^", "10000"));
		REQUIRE(test.expectedInputOutput("-10 2 ^", "100"));
		REQUIRE(test.expectedInputOutput("-10 3 ^", "-1000"));
		REQUIRE(test.expectedInputOutput("-10 3^", "-1000"));
		REQUIRE(test.expectedInputOutput("0^", "1"));
		REQUIRE(test.expectedInputOutput("^", "<<error>>"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("100 100^", "1e+200"));
	}

	SECTION("Method: neg()")
	{
		REQUIRE(test.expectedInputOutput("-1000", "-1000"));
		REQUIRE(test.expectedInputOutput("M", "1000"));
		REQUIRE(test.expectedInputOutput("-1000 -1*", "1000"));
		REQUIRE(test.expectedInputOutput("M", "-1000"));
		REQUIRE(test.expectedInputOutput("-4/", "-250"));
		REQUIRE(test.expectedInputOutput("m", "250"));
		REQUIRE(test.expectedInputOutput("-2*", "-500"));
		REQUIRE(test.expectedInputOutput("m", "500"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("m", "<<error>>"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("M", "<<error>>"));
	}

	SECTION("Method: rotateDown()")
	{
		REQUIRE(test.expectedInputOutput("100 200", "200"));
		REQUIRE(test.expectedInputOutput("D", "100"));
		REQUIRE(test.expectedInputOutput("D", "200"));
		REQUIRE(test.expectedInputOutput("d", "100"));
		REQUIRE(test.expectedInputOutput("d", "200"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("D", "<<error>>"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("d", "<<error>>"));
	}

	SECTION("Method: rotateUp()")
	{
		REQUIRE(test.expectedInputOutput("300 500", "500"));
		REQUIRE(test.expectedInputOutput("U", "300"));
		REQUIRE(test.expectedInputOutput("U", "500"));
		REQUIRE(test.expectedInputOutput("u", "300"));
		REQUIRE(test.expectedInputOutput("u", "500"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("U", "<<error>>"));
		REQUIRE(test.expectedInputOutput("c", ""));
		REQUIRE(test.expectedInputOutput("u", "<<error>>"));
	}
}
<|endoftext|>


<commit_before>#include "soundController.h"
#include "DataSetting.h"

using namespace CocosDenshion;

//constructor
soundController::soundController()
{

}
soundController::~soundController()
{}

//preload
void soundController::initAudio()
{
	auto audio = SimpleAudioEngine::getInstance();

	//opening background
	audio->setBackgroundMusicVolume(0.5);
	//audio->preloadBackgroundMusic("sound/opening_back.wav");

	//opening
	audio->preloadEffect("sound/op1_k.mp3");
	audio->preloadEffect("sound/op2_k.mp3");
	audio->preloadEffect("sound/op3_k.mp3");
	audio->preloadEffect("sound/op1_e.mp3");
	audio->preloadEffect("sound/op2_e.mp3");
	audio->preloadEffect("sound/op3_e.mp3");

	//game background
	audio->preloadBackgroundMusic("sound/game_back.wav");

	//puzzle sound
	audio->preloadEffect("sound/wrong.wav");			//wrong

	//narations
	//korea narations
	audio->preloadEffect("sound/p1_n_k.mp3");	//p1Scene
	audio->preloadEffect("sound/p2_n_k.mp3");	//p2Scene
	audio->preloadEffect("sound/p3_n_k.mp3");	//p3Scene
	audio->preloadEffect("sound/p4_n_k.mp3");	//p4Scene
	audio->preloadEffect("sound/p5_n_k.mp3");	//p5Scene
	audio->preloadEffect("sound/p6_n_k.mp3");	//p6Scene
	//english narations
	audio->preloadEffect("sound/p1_n_e.mp3");	//p1Scene
	audio->preloadEffect("sound/p2_n_e.mp3");	//p2Scene
	audio->preloadEffect("sound/p3_n_e.mp3");	//p3Scene
	audio->preloadEffect("sound/p4_n_e.mp3");	//p4Scene
	audio->preloadEffect("sound/p5_n_e.mp3");	//p5Scene
	audio->preloadEffect("sound/p6_n_e.mp3");	//p6Scene

	//door open
	audio->preloadEffect("sound/door.wav"); //door open
	//end effect
	audio->preloadEffect("sound/tada.mp3");	//each game finish

	//correct eff
	audio->preloadEffect("sound/good_k.mp3");	//good
	audio->preloadEffect("sound/excellent_k.mp3");	//welldone
	audio->preloadEffect("sound/good_e.mp3");	//good
	audio->preloadEffect("sound/excellent_e.mp3");	//welldone

	//splashScene sound
	audio->preloadEffect("sound/start_k.mp3");
	audio->preloadEffect("sound/start_e.mp3");

	//finishing
	audio->preloadBackgroundMusic("sound/ending.wav"); //ending

}
void soundController::splashSound()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();
	isKorea = UserDefault::getInstance()->getBoolForKey("kor");

	//stop background sound
	backgroundSoundStop();

	if (isKorea)
		audio->playEffect("sound/start_k.mp3");
	else
		audio->playEffect("sound/start_e.mp3");
}
//puzzle - pick up
void soundController::puzzlePickUp()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();
	//no sound
}
//puzzle - wrong location
void soundController::puzzleWrong()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();

	audio->playEffect("sound/wrong.wav");
}
//puzzle - correct location
void soundController::puzzleCorrect()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();
	isKorea = UserDefault::getInstance()->getBoolForKey("kor");
	if (isKorea)
	{//random good or excellent sound
		RandomHelper::random_int(0,1) ? audio->playEffect("sound/good_k.mp3") : audio->playEffect("sound/excellent_k.mp3");
	}
	else
	{
		RandomHelper::random_int(0, 1) ? audio->playEffect("sound/good_e.mp3") : audio->playEffect("sound/excellent_e.mp3");
	}
}
//game opening scene
void soundController::gameOpening(int num)
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();
	isKorea = UserDefault::getInstance()->getBoolForKey("kor");

	//opening background sound start
	//udio->playBackgroundMusic("sound/opening_back.wav", true);

	switch (num)
	{
	case 1:
		if (isKorea)
			audio->playEffect("sound/op1_k.mp3");
		else
			audio->playEffect("sound/op1_e.mp3");
		break;
	case 2:
		if (isKorea)
			audio->playEffect("sound/op2_k.mp3");
		else
			audio->playEffect("sound/op2_e.mp3");
		break;
	case 3:
		if (isKorea)
			audio->playEffect("sound/op3_k.mp3");
		else
			audio->playEffect("sound/op3_e.mp3");
		break;
	default:
		break;
	}

}
void soundController::openingEffectSound(char* soundName)
{
	if (soundName == "monster")
	{//monster sound
		SimpleAudioEngine::getInstance()->playEffect("sound/op_monster.mp3");
	}
	else if (soundName == "siren")
	{//siren sound
		SimpleAudioEngine::getInstance()->playEffect("sound/op_siren.mp3");
	}
}
void soundController::startGameBackgroundSound()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();
	audio->playBackgroundMusic("sound/game_back.wav", true);
}
//game ending scene
void soundController::gameEnding()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();

	audio->playBackgroundMusic("sound/ending.mp3", true);
}

//puzzle opening door
void soundController::doorOpen()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();

	audio->playEffect("sound/door.wav");
}
//puzzle naration
void soundController::puzzleNaration(int sceneNum)
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();
	isKorea = UserDefault::getInstance()->getBoolForKey("kor");

	startGameBackgroundSound();

	switch (sceneNum)
	{
	case 1:
		if (isKorea)
			audio->playEffect("sound/p1_n_k.mp3");
		else
			audio->playEffect("sound/p1_n_e.mp3");
		break;
	case 2:
		if (isKorea)
			audio->playEffect("sound/p2_n_k.mp3");
		else
			audio->playEffect("sound/p2_n_e.mp3");
		break;
	case 3:
		if (isKorea)
			audio->playEffect("sound/p3_n_k.mp3");
		else
			audio->playEffect("sound/p3_n_e.mp3");
		break;
	case 4:
		if (isKorea)
			audio->playEffect("sound/p4_n_k.mp3");
		else
			audio->playEffect("sound/p4_n_e.mp3");
		break;
	case 5:
		if (isKorea)
			audio->playEffect("sound/p5_n_k.mp3");
		else
			audio->playEffect("sound/p5_n_e.mp3");
		break;
	case 6:
		if (isKorea)
			audio->playEffect("sound/p6_n_k.mp3");
		else
			audio->playEffect("sound/p6_n_e.mp3");
		break;
	default:
		break;
	}
}
//ending pop up
void soundController::popUp()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();
	audio->playEffect("sound/tada.mp3");
}

void soundController::soundStop()
{
	SimpleAudioEngine::getInstance()->stopAllEffects();
}

void soundController::backgroundSoundStop()
{
	SimpleAudioEngine::getInstance()->stopBackgroundMusic();
}
<commit_msg>soundCotroller filename error fix<commit_after>#include "soundController.h"
#include "DataSetting.h"

using namespace CocosDenshion;

//constructor
soundController::soundController()
{

}
soundController::~soundController()
{}

//preload
void soundController::initAudio()
{
	auto audio = SimpleAudioEngine::getInstance();

	//opening background
	audio->setBackgroundMusicVolume(0.5);
	//audio->preloadBackgroundMusic("sound/opening_back.wav");

	//opening
	audio->preloadEffect("sound/op1_k.mp3");
	audio->preloadEffect("sound/op2_k.mp3");
	audio->preloadEffect("sound/op3_k.mp3");
	audio->preloadEffect("sound/op1_e.mp3");
	audio->preloadEffect("sound/op2_e.mp3");
	audio->preloadEffect("sound/op3_e.mp3");

	//game background
	audio->preloadBackgroundMusic("sound/game_back.wav");

	//puzzle sound
	audio->preloadEffect("sound/wrong.wav");			//wrong

	//narations
	//korea narations
	audio->preloadEffect("sound/p1_n_k.mp3");	//p1Scene
	audio->preloadEffect("sound/p2_n_k.mp3");	//p2Scene
	audio->preloadEffect("sound/p3_n_k.mp3");	//p3Scene
	audio->preloadEffect("sound/p4_n_k.mp3");	//p4Scene
	audio->preloadEffect("sound/p5_n_k.mp3");	//p5Scene
	audio->preloadEffect("sound/p6_n_k.mp3");	//p6Scene
	//english narations
	audio->preloadEffect("sound/p1_n_e.mp3");	//p1Scene
	audio->preloadEffect("sound/p2_n_e.mp3");	//p2Scene
	audio->preloadEffect("sound/p3_n_e.mp3");	//p3Scene
	audio->preloadEffect("sound/p4_n_e.mp3");	//p4Scene
	audio->preloadEffect("sound/p5_n_e.mp3");	//p5Scene
	audio->preloadEffect("sound/p6_n_e.mp3");	//p6Scene

	//door open
	audio->preloadEffect("sound/door.wav"); //door open
	//end effect
	audio->preloadEffect("sound/tada.mp3");	//each game finish

	//correct eff
	audio->preloadEffect("sound/good_k.mp3");	//good
	audio->preloadEffect("sound/excellent_k.mp3");	//welldone
	audio->preloadEffect("sound/good_e.mp3");	//good
	audio->preloadEffect("sound/excellent_e.mp3");	//welldone

	//splashScene sound
	audio->preloadEffect("sound/start_k.mp3");
	audio->preloadEffect("sound/start_e.mp3");

	//finishing
	audio->preloadBackgroundMusic("sound/ending.mp3"); //ending

}
void soundController::splashSound()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();
	isKorea = UserDefault::getInstance()->getBoolForKey("kor");

	//stop background sound
	backgroundSoundStop();

	if (isKorea)
		audio->playEffect("sound/start_k.mp3");
	else
		audio->playEffect("sound/start_e.mp3");
}
//puzzle - pick up
void soundController::puzzlePickUp()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();
	//no sound
}
//puzzle - wrong location
void soundController::puzzleWrong()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();

	audio->playEffect("sound/wrong.wav");
}
//puzzle - correct location
void soundController::puzzleCorrect()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();
	isKorea = UserDefault::getInstance()->getBoolForKey("kor");
	if (isKorea)
	{//random good or excellent sound
		RandomHelper::random_int(0,1) ? audio->playEffect("sound/good_k.mp3") : audio->playEffect("sound/excellent_k.mp3");
	}
	else
	{
		RandomHelper::random_int(0, 1) ? audio->playEffect("sound/good_e.mp3") : audio->playEffect("sound/excellent_e.mp3");
	}
}
//game opening scene
void soundController::gameOpening(int num)
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();
	isKorea = UserDefault::getInstance()->getBoolForKey("kor");

	//opening background sound start
	//udio->playBackgroundMusic("sound/opening_back.wav", true);

	switch (num)
	{
	case 1:
		if (isKorea)
			audio->playEffect("sound/op1_k.mp3");
		else
			audio->playEffect("sound/op1_e.mp3");
		break;
	case 2:
		if (isKorea)
			audio->playEffect("sound/op2_k.mp3");
		else
			audio->playEffect("sound/op2_e.mp3");
		break;
	case 3:
		if (isKorea)
			audio->playEffect("sound/op3_k.mp3");
		else
			audio->playEffect("sound/op3_e.mp3");
		break;
	default:
		break;
	}

}
void soundController::openingEffectSound(char* soundName)
{
	if (soundName == "monster")
	{//monster sound
		SimpleAudioEngine::getInstance()->playEffect("sound/op_monster.mp3");
	}
	else if (soundName == "siren")
	{//siren sound
		SimpleAudioEngine::getInstance()->playEffect("sound/op_siren.mp3");
	}
}
void soundController::startGameBackgroundSound()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();
	audio->playBackgroundMusic("sound/game_back.wav", true);
}
//game ending scene
void soundController::gameEnding()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();

	audio->playBackgroundMusic("sound/ending.mp3", true);
}

//puzzle opening door
void soundController::doorOpen()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();

	audio->playEffect("sound/door.wav");
}
//puzzle naration
void soundController::puzzleNaration(int sceneNum)
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();
	isKorea = UserDefault::getInstance()->getBoolForKey("kor");

	startGameBackgroundSound();

	switch (sceneNum)
	{
	case 1:
		if (isKorea)
			audio->playEffect("sound/p1_n_k.mp3");
		else
			audio->playEffect("sound/p1_n_e.mp3");
		break;
	case 2:
		if (isKorea)
			audio->playEffect("sound/p2_n_k.mp3");
		else
			audio->playEffect("sound/p2_n_e.mp3");
		break;
	case 3:
		if (isKorea)
			audio->playEffect("sound/p3_n_k.mp3");
		else
			audio->playEffect("sound/p3_n_e.mp3");
		break;
	case 4:
		if (isKorea)
			audio->playEffect("sound/p4_n_k.mp3");
		else
			audio->playEffect("sound/p4_n_e.mp3");
		break;
	case 5:
		if (isKorea)
			audio->playEffect("sound/p5_n_k.mp3");
		else
			audio->playEffect("sound/p5_n_e.mp3");
		break;
	case 6:
		if (isKorea)
			audio->playEffect("sound/p6_n_k.mp3");
		else
			audio->playEffect("sound/p6_n_e.mp3");
		break;
	default:
		break;
	}
}
//ending pop up
void soundController::popUp()
{
	if (UserDefault::getInstance()->getBoolForKey("sound") == false)
		return;
	auto audio = SimpleAudioEngine::getInstance();
	audio->playEffect("sound/tada.mp3");
}

void soundController::soundStop()
{
	SimpleAudioEngine::getInstance()->stopAllEffects();
}

void soundController::backgroundSoundStop()
{
	SimpleAudioEngine::getInstance()->stopBackgroundMusic();
}
<|endoftext|>


<commit_before>/*
 * Copyright (c) 2009, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU Lesser General Public License,
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include <locale.h>
#include <glib/gi18n.h>
#include <clutter/clutter.h>
#include <clutter/x11/clutter-x11.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <mx/mx.h>
#include <moblin-panel/mpl-panel-clutter.h>
#include <moblin-panel/mpl-panel-common.h>
#include "moblin-netbook-netpanel.h"
#include "chrome-profile-provider.h"

#include <config.h>

// chrome header
#include "app/app_paths.h"
#include "app/resource_bundle.h"
#include "base/at_exit.h"
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/i18n/icu_util.h"
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/scoped_vector.h"
#include "base/string_util.h"
#include "base/command_line.h"
#include "chrome/browser/pref_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/browser/browser_prefs.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/user_data_manager.h"

static void
_client_set_size_cb (MplPanelClient *client,
                     guint           width,
                     guint           height,
                     gpointer        userdata)
{
  g_debug (G_STRLOC ": %d %d", width, height);
  clutter_actor_set_size ((ClutterActor *)userdata,
                          width,
                          height);
}

static gboolean
stage_button_press_event (ClutterStage          *stage,
                          ClutterEvent          *event,
                          MoblinNetbookNetpanel *netpanel)
{
  moblin_netbook_netpanel_button_press (netpanel);
  return TRUE;
}

static gboolean
stage_delete_event (ClutterStage *stage,
                    ClutterEvent *event,
                    gpointer* userdata)
{
  MessageLoopForUI::current()->Quit();
  return TRUE;
}

static gboolean standalone = FALSE;

static GOptionEntry entries[] = {
  {"standalone", 's', 0, G_OPTION_ARG_NONE, &standalone, "Do not embed into the mutter-moblin panel", NULL}
};

#define CHROME_EXE_PATH "/opt/google/chrome/"
#define CHROME_BUNDLE_PATH CHROME_EXE_PATH "/chrome.pak"
#define CHROME_LOCALE_PATH CHROME_EXE_PATH "/locales"

#define CHROMIUM_EXE_PATH "/usr/lib/chromium-browser/"
#define CHROMIUM_BUNDLE_PATH CHROMIUM_EXE_PATH "/chrome.pak"
#define CHROMIUM_LOCALE_PATH CHROMIUM_EXE_PATH "/locales"

int
main (int    argc,
      char **argv)
{
  MplPanelClient *client;
  ClutterActor *stage;
  MoblinNetbookNetpanel *netpanel;
  GOptionContext *context;
  std::string browser_name;
  GError *error = NULL;

  // Init chrome environment variables
  base::AtExitManager at_exit_manager;
  CommandLine::Init(argc, argv);
  CommandLine* cmd_line = CommandLine::ForCurrentProcess();

  chrome::RegisterPathProvider();
  app::RegisterPathProvider();

  if (g_file_test (CHROMIUM_BUNDLE_PATH, G_FILE_TEST_EXISTS)
     && g_file_test (CHROMIUM_LOCALE_PATH, G_FILE_TEST_EXISTS)) {
    FilePath bundle_path(CHROMIUM_BUNDLE_PATH);
    FilePath locale_path(CHROMIUM_LOCALE_PATH);
    ResourceBundle::InitSharedInstance(L"en-US", bundle_path, locale_path);
    if (g_file_test(CHROMIUM_EXE_PATH "chrome", G_FILE_TEST_EXISTS)) {
      browser_name = "google-chrome";
    } else {
      browser_name = "chromium";
    }
  }
  else {
    g_warning("Chrome browser is not installed\n");
  }

  g_thread_init(NULL);
  g_type_init();
  gtk_init(&argc, &argv);

  MessageLoop main_message_loop(MessageLoop::TYPE_UI);

  scoped_ptr<BrowserProcessImpl> browser_process;
  browser_process.reset(new BrowserProcessImpl(*cmd_line));

  ChromeThread main_thread(ChromeThread::UI, MessageLoop::current());

  PrefService* local_state = browser_process->local_state();
  local_state->RegisterStringPref(prefs::kApplicationLocale, L"");

  scoped_ptr<UserDataManager> user_data_manager(UserDataManager::Create());

  // Initialize the prefs of the local state.
  browser::RegisterLocalState(local_state);
  g_browser_process->SetApplicationLocale("en-US");

  // Create the child threads.  We need to do this since ChromeThread::PostTask
  // silently deletes a posted task if the target message loop isn't created.
  browser_process->db_thread();
  browser_process->file_thread();
  browser_process->process_launcher_thread();
  browser_process->io_thread();

  // XXX: have to init chrome profile prover after thread creation
  // Init chrome profile provider
  ChromeProfileProvider::GetInstance()->Initialize(browser_name.c_str());

  setlocale (LC_ALL, "");
  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);

  context = g_option_context_new ("- mutter-moblin myzone panel");
  g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
  g_option_context_add_group (context, clutter_get_option_group_without_init ());
  g_option_context_add_group (context, gtk_get_option_group (FALSE));
  if (!g_option_context_parse (context, &argc, &argv, &error))
  {
    g_critical (G_STRLOC ": Error parsing option: %s", error->message);
    g_clear_error (&error);
  }

  g_option_context_free (context);

  MPL_PANEL_CLUTTER_INIT_WITH_GTK (&argc, &argv);

  mx_texture_cache_load_cache (mx_texture_cache_get_default (),
                                 MX_CACHE);
  mx_style_load_from_file (mx_style_get_default (),
                             THEMEDIR "/panel.css",
                             NULL);

  if (!standalone)
  {
    client = mpl_panel_clutter_new (MPL_PANEL_INTERNET,
                                    _("internet"),
                                    NULL,
                                    "internet-button",
                                    TRUE);

    MPL_PANEL_CLUTTER_SETUP_EVENTS_WITH_GTK (client);

    stage = mpl_panel_clutter_get_stage (MPL_PANEL_CLUTTER (client));
    netpanel = MOBLIN_NETBOOK_NETPANEL (moblin_netbook_netpanel_new ());
    moblin_netbook_netpanel_set_browser(netpanel, browser_name.c_str());

    ClutterActor  *content_pane;
    ClutterActor  *base_pane;
    ClutterActor  *label;

    base_pane = mx_box_layout_new();
    clutter_actor_set_name (base_pane, "base-pane");
    mx_box_layout_set_orientation (MX_BOX_LAYOUT (base_pane), MX_ORIENTATION_VERTICAL);
    clutter_container_add_actor (CLUTTER_CONTAINER (stage), base_pane);

    label = mx_label_new_with_text (_("Internet"));
    clutter_actor_set_name (label, "panel-label");
    clutter_container_add_actor (CLUTTER_CONTAINER (base_pane), label);

    content_pane = mx_box_layout_new ();
    clutter_actor_set_name (content_pane, "pane");
    mx_box_layout_set_orientation (MX_BOX_LAYOUT (content_pane), MX_ORIENTATION_VERTICAL);
    clutter_container_add_actor (CLUTTER_CONTAINER (base_pane), content_pane);
    clutter_container_child_set (CLUTTER_CONTAINER (base_pane), content_pane,
                                 "expand", TRUE,
                                 "x-fill", TRUE,
                                 "y-fill", TRUE,
                                 NULL);

    clutter_container_add_actor (CLUTTER_CONTAINER (content_pane),
                                 CLUTTER_ACTOR (netpanel));
    clutter_container_child_set (CLUTTER_CONTAINER (content_pane), CLUTTER_ACTOR (netpanel),
                                 "expand", TRUE,
                                 "x-fill", TRUE,
                                 "y-fill", TRUE,
                                 NULL);

    moblin_netbook_netpanel_set_panel_client (netpanel, client);
    g_signal_connect (client,
                      "set-size",
                      (GCallback)_client_set_size_cb,
                      base_pane);
  } else {
    Window xwin;
    ClutterActor  *content_pane;
    ClutterActor  *base_pane;
    ClutterActor  *label;

    stage = clutter_stage_get_default ();
    clutter_actor_realize (stage);
    xwin = clutter_x11_get_stage_window (CLUTTER_STAGE (stage));

    MPL_PANEL_CLUTTER_SETUP_EVENTS_WITH_GTK_FOR_XID (xwin);
    netpanel = MOBLIN_NETBOOK_NETPANEL (moblin_netbook_netpanel_new ());
    moblin_netbook_netpanel_set_browser(netpanel, browser_name.c_str());

    base_pane = mx_box_layout_new();
    clutter_actor_set_name (base_pane, "base-pane");
    mx_box_layout_set_orientation (MX_BOX_LAYOUT (base_pane), MX_ORIENTATION_VERTICAL);
    clutter_container_add_actor (CLUTTER_CONTAINER (stage), base_pane);

    label = mx_label_new_with_text (_("Internet"));
    clutter_actor_set_name (label, "panel-label");
    clutter_container_add_actor (CLUTTER_CONTAINER (base_pane), label);

    content_pane = mx_box_layout_new ();
    clutter_actor_set_name (content_pane, "pane");
    mx_box_layout_set_orientation (MX_BOX_LAYOUT (content_pane), MX_ORIENTATION_VERTICAL);
    clutter_container_add_actor (CLUTTER_CONTAINER (base_pane), content_pane);
    clutter_container_child_set (CLUTTER_CONTAINER (base_pane), content_pane,
                                 "expand", TRUE,
                                 "x-fill", TRUE,
                                 "y-fill", TRUE,
                                 NULL);

    clutter_container_add_actor (CLUTTER_CONTAINER (content_pane),
                                 CLUTTER_ACTOR (netpanel));
    clutter_container_child_set (CLUTTER_CONTAINER (content_pane), CLUTTER_ACTOR (netpanel),
                                 "expand", TRUE,
                                 "x-fill", TRUE,
                                 "y-fill", TRUE,
                                 NULL);
    clutter_actor_set_size (stage, 1016, 500);
    clutter_actor_set_size (base_pane, 1016, 500);
    clutter_actor_show (CLUTTER_ACTOR (netpanel));
    clutter_actor_show_all (stage);

    g_signal_connect (stage,
                    "delete-event",
                    (GCallback)stage_delete_event,
                    NULL);
  }

  g_signal_connect (stage,
                    "button-press-event",
                    (GCallback)stage_button_press_event,
                    netpanel);

  // run chromium's message loop
  MessageLoopForUI::current()->Run(NULL);

  return 0;
}
<commit_msg>fix a bug in chrome/chromium dual support patch<commit_after>/*
 * Copyright (c) 2009, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU Lesser General Public License,
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include <locale.h>
#include <glib/gi18n.h>
#include <clutter/clutter.h>
#include <clutter/x11/clutter-x11.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <mx/mx.h>
#include <moblin-panel/mpl-panel-clutter.h>
#include <moblin-panel/mpl-panel-common.h>
#include "moblin-netbook-netpanel.h"
#include "chrome-profile-provider.h"

#include <config.h>

// chrome header
#include "app/app_paths.h"
#include "app/resource_bundle.h"
#include "base/at_exit.h"
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/i18n/icu_util.h"
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/scoped_vector.h"
#include "base/string_util.h"
#include "base/command_line.h"
#include "chrome/browser/pref_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/browser/browser_prefs.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/user_data_manager.h"

static void
_client_set_size_cb (MplPanelClient *client,
                     guint           width,
                     guint           height,
                     gpointer        userdata)
{
  g_debug (G_STRLOC ": %d %d", width, height);
  clutter_actor_set_size ((ClutterActor *)userdata,
                          width,
                          height);
}

static gboolean
stage_button_press_event (ClutterStage          *stage,
                          ClutterEvent          *event,
                          MoblinNetbookNetpanel *netpanel)
{
  moblin_netbook_netpanel_button_press (netpanel);
  return TRUE;
}

static gboolean
stage_delete_event (ClutterStage *stage,
                    ClutterEvent *event,
                    gpointer* userdata)
{
  MessageLoopForUI::current()->Quit();
  return TRUE;
}

static gboolean standalone = FALSE;

static GOptionEntry entries[] = {
  {"standalone", 's', 0, G_OPTION_ARG_NONE, &standalone, "Do not embed into the mutter-moblin panel", NULL}
};

#define CHROME_EXE_PATH "/opt/google/chrome/"
#define CHROME_BUNDLE_PATH CHROME_EXE_PATH "/chrome.pak"
#define CHROME_LOCALE_PATH CHROME_EXE_PATH "/locales"

#define CHROMIUM_EXE_PATH "/usr/lib/chromium-browser/"
#define CHROMIUM_BUNDLE_PATH CHROMIUM_EXE_PATH "/chrome.pak"
#define CHROMIUM_LOCALE_PATH CHROMIUM_EXE_PATH "/locales"

int
main (int    argc,
      char **argv)
{
  MplPanelClient *client;
  ClutterActor *stage;
  MoblinNetbookNetpanel *netpanel;
  GOptionContext *context;
  std::string browser_name;
  GError *error = NULL;

  // Init chrome environment variables
  base::AtExitManager at_exit_manager;
  CommandLine::Init(argc, argv);
  CommandLine* cmd_line = CommandLine::ForCurrentProcess();

  chrome::RegisterPathProvider();
  app::RegisterPathProvider();

  if (g_file_test (CHROMIUM_BUNDLE_PATH, G_FILE_TEST_EXISTS)
     && g_file_test (CHROMIUM_LOCALE_PATH, G_FILE_TEST_EXISTS)) {
    FilePath bundle_path(CHROMIUM_BUNDLE_PATH);
    FilePath locale_path(CHROMIUM_LOCALE_PATH);
    ResourceBundle::InitSharedInstance(L"en-US", bundle_path, locale_path);
    if (g_file_test(CHROME_EXE_PATH "chrome", G_FILE_TEST_EXISTS) == TRUE) {
      browser_name = "google-chrome";
    } else {
      browser_name = "chromium";
    }
  }
  else {
    g_warning("Chrome browser is not installed\n");
  }

  g_thread_init(NULL);
  g_type_init();
  gtk_init(&argc, &argv);

  MessageLoop main_message_loop(MessageLoop::TYPE_UI);

  scoped_ptr<BrowserProcessImpl> browser_process;
  browser_process.reset(new BrowserProcessImpl(*cmd_line));

  ChromeThread main_thread(ChromeThread::UI, MessageLoop::current());

  PrefService* local_state = browser_process->local_state();
  local_state->RegisterStringPref(prefs::kApplicationLocale, L"");

  scoped_ptr<UserDataManager> user_data_manager(UserDataManager::Create());

  // Initialize the prefs of the local state.
  browser::RegisterLocalState(local_state);
  g_browser_process->SetApplicationLocale("en-US");

  // Create the child threads.  We need to do this since ChromeThread::PostTask
  // silently deletes a posted task if the target message loop isn't created.
  browser_process->db_thread();
  browser_process->file_thread();
  browser_process->process_launcher_thread();
  browser_process->io_thread();

  // XXX: have to init chrome profile prover after thread creation
  // Init chrome profile provider
  ChromeProfileProvider::GetInstance()->Initialize(browser_name.c_str());

  setlocale (LC_ALL, "");
  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);

  context = g_option_context_new ("- mutter-moblin myzone panel");
  g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
  g_option_context_add_group (context, clutter_get_option_group_without_init ());
  g_option_context_add_group (context, gtk_get_option_group (FALSE));
  if (!g_option_context_parse (context, &argc, &argv, &error))
  {
    g_critical (G_STRLOC ": Error parsing option: %s", error->message);
    g_clear_error (&error);
  }

  g_option_context_free (context);

  MPL_PANEL_CLUTTER_INIT_WITH_GTK (&argc, &argv);

  mx_texture_cache_load_cache (mx_texture_cache_get_default (),
                                 MX_CACHE);
  mx_style_load_from_file (mx_style_get_default (),
                             THEMEDIR "/panel.css",
                             NULL);

  if (!standalone)
  {
    client = mpl_panel_clutter_new (MPL_PANEL_INTERNET,
                                    _("internet"),
                                    NULL,
                                    "internet-button",
                                    TRUE);

    MPL_PANEL_CLUTTER_SETUP_EVENTS_WITH_GTK (client);

    stage = mpl_panel_clutter_get_stage (MPL_PANEL_CLUTTER (client));
    netpanel = MOBLIN_NETBOOK_NETPANEL (moblin_netbook_netpanel_new ());
    moblin_netbook_netpanel_set_browser(netpanel, browser_name.c_str());

    ClutterActor  *content_pane;
    ClutterActor  *base_pane;
    ClutterActor  *label;

    base_pane = mx_box_layout_new();
    clutter_actor_set_name (base_pane, "base-pane");
    mx_box_layout_set_orientation (MX_BOX_LAYOUT (base_pane), MX_ORIENTATION_VERTICAL);
    clutter_container_add_actor (CLUTTER_CONTAINER (stage), base_pane);

    label = mx_label_new_with_text (_("Internet"));
    clutter_actor_set_name (label, "panel-label");
    clutter_container_add_actor (CLUTTER_CONTAINER (base_pane), label);

    content_pane = mx_box_layout_new ();
    clutter_actor_set_name (content_pane, "pane");
    mx_box_layout_set_orientation (MX_BOX_LAYOUT (content_pane), MX_ORIENTATION_VERTICAL);
    clutter_container_add_actor (CLUTTER_CONTAINER (base_pane), content_pane);
    clutter_container_child_set (CLUTTER_CONTAINER (base_pane), content_pane,
                                 "expand", TRUE,
                                 "x-fill", TRUE,
                                 "y-fill", TRUE,
                                 NULL);

    clutter_container_add_actor (CLUTTER_CONTAINER (content_pane),
                                 CLUTTER_ACTOR (netpanel));
    clutter_container_child_set (CLUTTER_CONTAINER (content_pane), CLUTTER_ACTOR (netpanel),
                                 "expand", TRUE,
                                 "x-fill", TRUE,
                                 "y-fill", TRUE,
                                 NULL);

    moblin_netbook_netpanel_set_panel_client (netpanel, client);
    g_signal_connect (client,
                      "set-size",
                      (GCallback)_client_set_size_cb,
                      base_pane);
  } else {
    Window xwin;
    ClutterActor  *content_pane;
    ClutterActor  *base_pane;
    ClutterActor  *label;

    stage = clutter_stage_get_default ();
    clutter_actor_realize (stage);
    xwin = clutter_x11_get_stage_window (CLUTTER_STAGE (stage));

    MPL_PANEL_CLUTTER_SETUP_EVENTS_WITH_GTK_FOR_XID (xwin);
    netpanel = MOBLIN_NETBOOK_NETPANEL (moblin_netbook_netpanel_new ());
    moblin_netbook_netpanel_set_browser(netpanel, browser_name.c_str());

    base_pane = mx_box_layout_new();
    clutter_actor_set_name (base_pane, "base-pane");
    mx_box_layout_set_orientation (MX_BOX_LAYOUT (base_pane), MX_ORIENTATION_VERTICAL);
    clutter_container_add_actor (CLUTTER_CONTAINER (stage), base_pane);

    label = mx_label_new_with_text (_("Internet"));
    clutter_actor_set_name (label, "panel-label");
    clutter_container_add_actor (CLUTTER_CONTAINER (base_pane), label);

    content_pane = mx_box_layout_new ();
    clutter_actor_set_name (content_pane, "pane");
    mx_box_layout_set_orientation (MX_BOX_LAYOUT (content_pane), MX_ORIENTATION_VERTICAL);
    clutter_container_add_actor (CLUTTER_CONTAINER (base_pane), content_pane);
    clutter_container_child_set (CLUTTER_CONTAINER (base_pane), content_pane,
                                 "expand", TRUE,
                                 "x-fill", TRUE,
                                 "y-fill", TRUE,
                                 NULL);

    clutter_container_add_actor (CLUTTER_CONTAINER (content_pane),
                                 CLUTTER_ACTOR (netpanel));
    clutter_container_child_set (CLUTTER_CONTAINER (content_pane), CLUTTER_ACTOR (netpanel),
                                 "expand", TRUE,
                                 "x-fill", TRUE,
                                 "y-fill", TRUE,
                                 NULL);
    clutter_actor_set_size (stage, 1016, 500);
    clutter_actor_set_size (base_pane, 1016, 500);
    clutter_actor_show (CLUTTER_ACTOR (netpanel));
    clutter_actor_show_all (stage);

    g_signal_connect (stage,
                    "delete-event",
                    (GCallback)stage_delete_event,
                    NULL);
  }

  g_signal_connect (stage,
                    "button-press-event",
                    (GCallback)stage_button_press_event,
                    netpanel);

  // run chromium's message loop
  MessageLoopForUI::current()->Run(NULL);

  return 0;
}
<|endoftext|>


<commit_before>/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "gm.h"
#include "SkCanvas.h"
#include "SkPath.h"
#include "SkGradientShader.h"
#include "SkTypeface.h"

static SkShader* make_heatGradient(const SkPoint pts[2]) {
    const SkColor colors[] = {
        SK_ColorBLACK, SK_ColorBLUE, SK_ColorCYAN, SK_ColorGREEN,
        SK_ColorYELLOW, SK_ColorRED, SK_ColorWHITE
    };
    const SkColor bw[] = { SK_ColorBLACK, SK_ColorWHITE };

    return SkGradientShader::CreateLinear(pts, bw, NULL,
                                          SK_ARRAY_COUNT(bw),
                                          SkShader::kClamp_TileMode);
}

static bool setFont(SkPaint* paint, const char name[]) {
    SkTypeface* tf = SkTypeface::CreateFromName(name, SkTypeface::kNormal);
    if (tf) {
        paint->setTypeface(tf)->unref();
        return true;
    }
    return false;
}

#ifdef SK_BUILD_FOR_MAC
#import <ApplicationServices/ApplicationServices.h>
#define BITMAP_INFO_RGB     (kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host)

static CGContextRef makeCG(const SkBitmap& bm) {
    if (SkBitmap::kARGB_8888_Config != bm.config() ||
        NULL == bm.getPixels()) {
        return NULL;
    }
    CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
    CGContextRef cg = CGBitmapContextCreate(bm.getPixels(), bm.width(), bm.height(),
                                            8, bm.rowBytes(), space, BITMAP_INFO_RGB);
    CFRelease(space);

    CGContextSetAllowsFontSubpixelQuantization(cg, false);
    CGContextSetShouldSubpixelQuantizeFonts(cg, false);

    return cg;
}

extern CTFontRef SkTypeface_GetCTFontRef(const SkTypeface* face);

static CGFontRef typefaceToCGFont(const SkTypeface* face) {
    if (NULL == face) {
        return 0;
    }

    CTFontRef ct = SkTypeface_GetCTFontRef(face);
    return CTFontCopyGraphicsFont(ct, NULL);
}

static void cgSetPaintForText(CGContextRef cg, const SkPaint& paint) {
    SkColor c = paint.getColor();
    CGFloat rgba[] = {
        SkColorGetB(c) / 255.0,
        SkColorGetG(c) / 255.0,
        SkColorGetR(c) / 255.0,
        SkColorGetA(c) / 255.0,
    };
    CGContextSetRGBFillColor(cg, rgba[0], rgba[1], rgba[2], rgba[3]);

    CGContextSetTextDrawingMode(cg, kCGTextFill);
    CGContextSetFont(cg, typefaceToCGFont(paint.getTypeface()));
    CGContextSetFontSize(cg, SkScalarToFloat(paint.getTextSize()));

    CGContextSetAllowsFontSubpixelPositioning(cg, paint.isSubpixelText());
    CGContextSetShouldSubpixelPositionFonts(cg, paint.isSubpixelText());

    CGContextSetShouldAntialias(cg, paint.isAntiAlias());
    CGContextSetShouldSmoothFonts(cg, paint.isLCDRenderText());
}

static void cgDrawText(CGContextRef cg, const void* text, size_t len,
                       float x, float y, const SkPaint& paint) {
    if (cg) {
        cgSetPaintForText(cg, paint);

        uint16_t glyphs[200];
        int count = paint.textToGlyphs(text, len, glyphs);

        CGContextShowGlyphsAtPoint(cg, x, y, glyphs, count);
    }
}
#endif

namespace skiagm {

/**
   Test a set of clipping problems discovered while writing blitAntiRect,
   and test all the code paths through the clipping blitters.
   Each region should show as a blue center surrounded by a 2px green
   border, with no red.
*/

#define HEIGHT 480

class GammaTextGM : public GM {
public:
    GammaTextGM() {

    }

protected:
    virtual SkString onShortName() {
        return SkString("gammatext");
    }

    virtual SkISize onISize() {
        return make_isize(1024, HEIGHT);
    }

    static void drawGrad(SkCanvas* canvas) {
        SkPoint pts[] = { { 0, 0 }, { 0, SkIntToScalar(HEIGHT) } };
#if 0
        const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
        SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
#else
        SkShader* s = make_heatGradient(pts);
#endif

        canvas->clear(SK_ColorRED);
        SkPaint paint;
        paint.setShader(s)->unref();
        SkRect r = { 0, 0, SkIntToScalar(1024), SkIntToScalar(HEIGHT) };
        canvas->drawRect(r, paint);
    }

    virtual void onDraw(SkCanvas* canvas) {
#ifdef SK_BUILD_FOR_MAC
        CGContextRef cg = makeCG(canvas->getDevice()->accessBitmap(false));
#endif

        drawGrad(canvas);

        const SkColor fg[] = {
            0xFFFFFFFF,
            0xFFFFFF00, 0xFFFF00FF, 0xFF00FFFF,
            0xFFFF0000, 0xFF00FF00, 0xFF0000FF,
            0xFF000000,
        };

        const char* text = "Hamburgefons";
        size_t len = strlen(text);

        SkPaint paint;
        setFont(&paint, "Times");
        paint.setTextSize(SkIntToScalar(16));
        paint.setAntiAlias(true);
        paint.setLCDRenderText(true);

        SkScalar x = SkIntToScalar(10);
        for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) {
            paint.setColor(fg[i]);

            SkScalar y = SkIntToScalar(40);
            SkScalar stopy = SkIntToScalar(HEIGHT);
            while (y < stopy) {
#if 1
                canvas->drawText(text, len, x, y, paint);
#else
                cgDrawText(cg, text, len, x, SkIntToScalar(HEIGHT) - y, paint);
#endif
                y += paint.getTextSize() * 2;
            }
            x += SkIntToScalar(1024) / SK_ARRAY_COUNT(fg);
        }
    }

private:
    typedef GM INHERITED;
};

//////////////////////////////////////////////////////////////////////////////

static GM* MyFactory(void*) { return new GammaTextGM; }
static GMRegistry reg(MyFactory);

}
<commit_msg>Fix some float/scalar/int confusion.<commit_after>/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "gm.h"
#include "SkCanvas.h"
#include "SkPath.h"
#include "SkGradientShader.h"
#include "SkTypeface.h"

static SkShader* make_heatGradient(const SkPoint pts[2]) {
    const SkColor colors[] = {
        SK_ColorBLACK, SK_ColorBLUE, SK_ColorCYAN, SK_ColorGREEN,
        SK_ColorYELLOW, SK_ColorRED, SK_ColorWHITE
    };
    const SkColor bw[] = { SK_ColorBLACK, SK_ColorWHITE };

    return SkGradientShader::CreateLinear(pts, bw, NULL,
                                          SK_ARRAY_COUNT(bw),
                                          SkShader::kClamp_TileMode);
}

static bool setFont(SkPaint* paint, const char name[]) {
    SkTypeface* tf = SkTypeface::CreateFromName(name, SkTypeface::kNormal);
    if (tf) {
        paint->setTypeface(tf)->unref();
        return true;
    }
    return false;
}

#ifdef SK_BUILD_FOR_MAC
#import <ApplicationServices/ApplicationServices.h>
#define BITMAP_INFO_RGB     (kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host)

static CGContextRef makeCG(const SkBitmap& bm) {
    if (SkBitmap::kARGB_8888_Config != bm.config() ||
        NULL == bm.getPixels()) {
        return NULL;
    }
    CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
    CGContextRef cg = CGBitmapContextCreate(bm.getPixels(), bm.width(), bm.height(),
                                            8, bm.rowBytes(), space, BITMAP_INFO_RGB);
    CFRelease(space);

    CGContextSetAllowsFontSubpixelQuantization(cg, false);
    CGContextSetShouldSubpixelQuantizeFonts(cg, false);

    return cg;
}

extern CTFontRef SkTypeface_GetCTFontRef(const SkTypeface* face);

static CGFontRef typefaceToCGFont(const SkTypeface* face) {
    if (NULL == face) {
        return 0;
    }

    CTFontRef ct = SkTypeface_GetCTFontRef(face);
    return CTFontCopyGraphicsFont(ct, NULL);
}

static void cgSetPaintForText(CGContextRef cg, const SkPaint& paint) {
    SkColor c = paint.getColor();
    CGFloat rgba[] = {
        SkColorGetB(c) / 255.0,
        SkColorGetG(c) / 255.0,
        SkColorGetR(c) / 255.0,
        SkColorGetA(c) / 255.0,
    };
    CGContextSetRGBFillColor(cg, rgba[0], rgba[1], rgba[2], rgba[3]);

    CGContextSetTextDrawingMode(cg, kCGTextFill);
    CGContextSetFont(cg, typefaceToCGFont(paint.getTypeface()));
    CGContextSetFontSize(cg, SkScalarToFloat(paint.getTextSize()));

    CGContextSetAllowsFontSubpixelPositioning(cg, paint.isSubpixelText());
    CGContextSetShouldSubpixelPositionFonts(cg, paint.isSubpixelText());

    CGContextSetShouldAntialias(cg, paint.isAntiAlias());
    CGContextSetShouldSmoothFonts(cg, paint.isLCDRenderText());
}

static void cgDrawText(CGContextRef cg, const void* text, size_t len,
                       float x, float y, const SkPaint& paint) {
    if (cg) {
        cgSetPaintForText(cg, paint);

        uint16_t glyphs[200];
        int count = paint.textToGlyphs(text, len, glyphs);

        CGContextShowGlyphsAtPoint(cg, x, y, glyphs, count);
    }
}
#endif

namespace skiagm {

/**
   Test a set of clipping problems discovered while writing blitAntiRect,
   and test all the code paths through the clipping blitters.
   Each region should show as a blue center surrounded by a 2px green
   border, with no red.
*/

#define HEIGHT 480

class GammaTextGM : public GM {
public:
    GammaTextGM() {

    }

protected:
    virtual SkString onShortName() {
        return SkString("gammatext");
    }

    virtual SkISize onISize() {
        return make_isize(1024, HEIGHT);
    }

    static void drawGrad(SkCanvas* canvas) {
        SkPoint pts[] = { { 0, 0 }, { 0, SkIntToScalar(HEIGHT) } };
#if 0
        const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
        SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
#else
        SkShader* s = make_heatGradient(pts);
#endif

        canvas->clear(SK_ColorRED);
        SkPaint paint;
        paint.setShader(s)->unref();
        SkRect r = { 0, 0, SkIntToScalar(1024), SkIntToScalar(HEIGHT) };
        canvas->drawRect(r, paint);
    }

    virtual void onDraw(SkCanvas* canvas) {
#ifdef SK_BUILD_FOR_MAC
        CGContextRef cg = makeCG(canvas->getDevice()->accessBitmap(false));
#endif

        drawGrad(canvas);

        const SkColor fg[] = {
            0xFFFFFFFF,
            0xFFFFFF00, 0xFFFF00FF, 0xFF00FFFF,
            0xFFFF0000, 0xFF00FF00, 0xFF0000FF,
            0xFF000000,
        };

        const char* text = "Hamburgefons";
        size_t len = strlen(text);

        SkPaint paint;
        setFont(&paint, "Times");
        paint.setTextSize(SkIntToScalar(16));
        paint.setAntiAlias(true);
        paint.setLCDRenderText(true);

        SkScalar x = SkIntToScalar(10);
        for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) {
            paint.setColor(fg[i]);

            SkScalar y = SkIntToScalar(40);
            SkScalar stopy = SkIntToScalar(HEIGHT);
            while (y < stopy) {
#if 1
                canvas->drawText(text, len, x, y, paint);
#else
                cgDrawText(cg, text, len, SkScalarToFloat(x),
                           static_cast<float>(HEIGHT) - SkScalarToFloat(y),
                           paint);
#endif
                y += paint.getTextSize() * 2;
            }
            x += SkIntToScalar(1024) / SK_ARRAY_COUNT(fg);
        }
    }

private:
    typedef GM INHERITED;
};

//////////////////////////////////////////////////////////////////////////////

static GM* MyFactory(void*) { return new GammaTextGM; }
static GMRegistry reg(MyFactory);

}
<|endoftext|>


<commit_before>
/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#include "gm.h"

#include "SkColorPriv.h"
#include "SkGeometry.h"
#include "SkShader.h"

static void tesselate(const SkPath& src, SkPath* dst) {
    SkPath::Iter iter(src, true);
    SkPoint pts[4];
    SkPath::Verb verb;
    while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
        switch (verb) {
            case SkPath::kMove_Verb:
                dst->moveTo(pts[0]);
                break;
            case SkPath::kLine_Verb:
                dst->lineTo(pts[1]);
                break;
            case SkPath::kQuad_Verb: {
                SkPoint p;
                for (int i = 1; i <= 8; ++i) {
                    SkEvalQuadAt(pts, i / 8.0f, &p, NULL);
                    dst->lineTo(p);
                }
            } break;
            case SkPath::kCubic_Verb: {
                SkPoint p;
                for (int i = 1; i <= 8; ++i) {
                    SkEvalCubicAt(pts, i / 8.0f, &p, NULL, NULL);
                    dst->lineTo(p);
                }
            } break;
        }
    }
}

static void setFade(SkPaint* paint, bool showGL) {
    paint->setAlpha(showGL ? 0x66 : 0xFF);
}

static void setGLFrame(SkPaint* paint) {
    paint->setColor(0xFFFF0000);
    paint->setStyle(SkPaint::kStroke_Style);
    paint->setAntiAlias(true);
    paint->setStrokeWidth(1.1f);
}

static void show_mesh(SkCanvas* canvas, const SkRect& r) {
    SkPaint paint;
    setGLFrame(&paint);

    canvas->drawRect(r, paint);
    canvas->drawLine(r.fLeft, r.fTop, r.fRight, r.fBottom, paint);
}

static void drawLine(SkCanvas* canvas, const SkPoint& p0, const SkPoint& p1,
                     const SkPaint& paint) {
    canvas->drawLine(p0.fX, p0.fY, p1.fX, p1.fY, paint);
}

static void show_mesh(SkCanvas* canvas, const SkPoint pts[],
                      const uint16_t indices[], int count) {
    SkPaint paint;
    setGLFrame(&paint);

    for (int i = 0; i < count - 2; ++i) {
        drawLine(canvas, pts[indices[i]], pts[indices[i+1]], paint);
        drawLine(canvas, pts[indices[i+1]], pts[indices[i+2]], paint);
        drawLine(canvas, pts[indices[i+2]], pts[indices[i]], paint);
    }
}

static void show_glframe(SkCanvas* canvas, const SkPath& path) {
    SkPaint paint;
    setGLFrame(&paint);
    canvas->drawPath(path, paint);
}

static void show_mesh_between(SkCanvas* canvas, const SkPath& p0, const SkPath& p1) {
    SkPath d0, d1;
    tesselate(p0, &d0);
    tesselate(p1, &d1);

    SkPoint pts0[256*2], pts1[256];
    int count = d0.getPoints(pts0, SK_ARRAY_COUNT(pts0));
    int count1 = d1.getPoints(pts1, SK_ARRAY_COUNT(pts1));
    SkASSERT(count == count1);
    memcpy(&pts0[count], pts1, count * sizeof(SkPoint));

    uint16_t indices[256*6];
    uint16_t* ndx = indices;
    for (int i = 0; i < count; ++i) {
        *ndx++ = i;
        *ndx++ = i + count;
    }
    *ndx++ = 0;

    show_mesh(canvas, pts0, indices, ndx - indices);
}

static void show_fan(SkCanvas* canvas, const SkPath& path, SkScalar cx, SkScalar cy) {
    SkPaint paint;
    setGLFrame(&paint);

    canvas->drawPath(path, paint);

    SkPoint pts[256];
    int count = path.getPoints(pts, SK_ARRAY_COUNT(pts));
    for (int i = 0; i < count; ++i) {
        canvas->drawLine(pts[i].fX, pts[i].fY, cx, cy, paint);
    }
}

///////////////////////////////////////////////////////////////////////////////

typedef void (*DrawProc)(SkCanvas* canvas, bool showGL, int flags);

static void draw_line(SkCanvas* canvas, bool showGL, int flags) {
    SkPaint paint;
    paint.setAntiAlias(true);

    canvas->drawLine(50, 50, 400, 100, paint);

    canvas->rotate(40);
    setFade(&paint, showGL);
    paint.setStrokeWidth(40);
    canvas->drawLine(100, 50, 450, 50, paint);
    if (showGL) {
        show_mesh(canvas, SkRect::MakeLTRB(100, 50-20, 450, 50+20));
    }
}

static void draw_rect(SkCanvas* canvas, bool showGL, int flags) {
    SkPaint paint;
    paint.setAntiAlias(true);

    SkRect r = SkRect::MakeLTRB(50, 50, 250, 350);

    setFade(&paint, showGL);
    canvas->drawRect(r, paint);
    if (showGL) {
        show_mesh(canvas, r);
    }

    canvas->translate(320, 0);

    paint.setStyle(SkPaint::kStroke_Style);
    paint.setStrokeWidth(25);
    canvas->drawRect(r, paint);
    if (showGL) {
        SkScalar rad = paint.getStrokeWidth() / 2;
        SkPoint pts[8];
        r.outset(rad, rad);
        r.toQuad(&pts[0]);
        r.inset(rad*2, rad*2);
        r.toQuad(&pts[4]);

        const uint16_t indices[] = {
            0, 4, 1, 5, 2, 6, 3, 7, 0, 4
        };
        show_mesh(canvas, pts, indices, SK_ARRAY_COUNT(indices));
    }
}

static void draw_oval(SkCanvas* canvas, bool showGL, int flags) {
    SkPaint paint;
    paint.setAntiAlias(true);

    SkRect r = SkRect::MakeLTRB(50, 50, 250, 350);

    setFade(&paint, showGL);
    canvas->drawOval(r, paint);
    if (showGL) {
        switch (flags) {
            case 0: {
                SkPath path;
                path.addOval(r);
                show_glframe(canvas, path);
            } break;
            case 1: {
                SkPath src, dst;
                src.addOval(r);
                tesselate(src, &dst);
                show_fan(canvas, dst, r.centerX(), r.centerY());
            } break;
        }
    }

    canvas->translate(320, 0);

    paint.setStyle(SkPaint::kStroke_Style);
    paint.setStrokeWidth(25);
    canvas->drawOval(r, paint);
    if (showGL) {
        switch (flags) {
            case 0: {
                SkPath path;
                SkScalar rad = paint.getStrokeWidth() / 2;
                r.outset(rad, rad);
                path.addOval(r);
                r.inset(rad*2, rad*2);
                path.addOval(r);
                show_glframe(canvas, path);
            } break;
            case 1: {
                SkPath path0, path1;
                SkScalar rad = paint.getStrokeWidth() / 2;
                r.outset(rad, rad);
                path0.addOval(r);
                r.inset(rad*2, rad*2);
                path1.addOval(r);
                show_mesh_between(canvas, path0, path1);
            } break;
        }
    }
}

static void draw_image(SkCanvas* canvas, bool showGL, int flags) {
    SkPaint paint;
    paint.setAntiAlias(true);

    canvas->drawLine(10, 10, 400, 30, paint);
    paint.setStrokeWidth(10);
    canvas->drawLine(50, 50, 400, 400, paint);
}

static void draw_text(SkCanvas* canvas, bool showGL, int flags) {
    SkPaint paint;
    paint.setAntiAlias(true);

    canvas->drawLine(10, 10, 400, 30, paint);
    paint.setStrokeWidth(10);
    canvas->drawLine(50, 50, 400, 400, paint);
}

static const struct {
    DrawProc    fProc;
    const char* fName;
} gRec[] = {
    {   draw_line,  "Lines" },
    {   draw_rect,  "Rects" },
    {   draw_oval,  "Ovals" },
    {   draw_image, "Images" },
    {   draw_text,  "Text" },
};

class TalkGM : public skiagm::GM {
    DrawProc fProc;
    SkString fName;
    bool     fShowGL;
    int      fFlags;

public:
    TalkGM(int index, bool showGL, int flags = 0) {
        fProc = gRec[index].fProc;
        fName.set(gRec[index].fName);
        if (showGL) {
            fName.append("-gl");
        }
        fShowGL = showGL;
        fFlags = flags;
    }

protected:
    virtual SkString onShortName() {
        return fName;
    }

    virtual SkISize onISize() {
        return SkISize::Make(640, 480);
    }

    virtual void onDraw(SkCanvas* canvas) {
        SkRect dst = SkRect::MakeWH(canvas->getDevice()->width(), canvas->getDevice()->height());
        SkRect src = SkRect::MakeWH(640, 480);
        SkMatrix matrix;
        matrix.setRectToRect(src, dst, SkMatrix::kCenter_ScaleToFit);

        canvas->concat(matrix);
        fProc(canvas, fShowGL, fFlags);
    }

private:
    typedef skiagm::GM INHERITED;
};

//////////////////////////////////////////////////////////////////////////////

#define GM_CONCAT(X,Y) GM_CONCAT_IMPL(X,Y)
#define GM_CONCAT_IMPL(X,Y) X##Y

#define FACTORY_NAME  GM_CONCAT(Factory, __LINE__)
#define REGISTRY_NAME  GM_CONCAT(gReg, __LINE__)

#define ADD_GM(Class, args)    \
    static skiagm::GM* FACTORY_NAME(void*) { return new Class args; } \
    static skiagm::GMRegistry REGISTRY_NAME(FACTORY_NAME);

ADD_GM(TalkGM, (0, false))
ADD_GM(TalkGM, (0, true))
ADD_GM(TalkGM, (1, false))
ADD_GM(TalkGM, (1, true))
ADD_GM(TalkGM, (2, false))
ADD_GM(TalkGM, (2, true))
ADD_GM(TalkGM, (2, true, 1))
ADD_GM(TalkGM, (3, false))
ADD_GM(TalkGM, (3, true))
ADD_GM(TalkGM, (4, false))
ADD_GM(TalkGM, (4, true))

//static GM* MyFactory(void*) { return new TalkGM(0, false); }
//static GMRegistry reg(MyFactory);

<commit_msg>update<commit_after>
/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#include "gm.h"

#include "SkColorPriv.h"
#include "SkGeometry.h"
#include "SkShader.h"

static void tesselate(const SkPath& src, SkPath* dst) {
    SkPath::Iter iter(src, true);
    SkPoint pts[4];
    SkPath::Verb verb;
    while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
        switch (verb) {
            case SkPath::kMove_Verb:
                dst->moveTo(pts[0]);
                break;
            case SkPath::kLine_Verb:
                dst->lineTo(pts[1]);
                break;
            case SkPath::kQuad_Verb: {
                SkPoint p;
                for (int i = 1; i <= 8; ++i) {
                    SkEvalQuadAt(pts, i / 8.0f, &p, NULL);
                    dst->lineTo(p);
                }
            } break;
            case SkPath::kCubic_Verb: {
                SkPoint p;
                for (int i = 1; i <= 8; ++i) {
                    SkEvalCubicAt(pts, i / 8.0f, &p, NULL, NULL);
                    dst->lineTo(p);
                }
            } break;
        }
    }
}

static void setFade(SkPaint* paint, bool showGL) {
    paint->setAlpha(showGL ? 0x66 : 0xFF);
}

static void setGLFrame(SkPaint* paint) {
    paint->setColor(0xFFFF0000);
    paint->setStyle(SkPaint::kStroke_Style);
    paint->setAntiAlias(true);
    paint->setStrokeWidth(1.1f);
}

static void show_mesh(SkCanvas* canvas, const SkRect& r) {
    SkPaint paint;
    setGLFrame(&paint);

    canvas->drawRect(r, paint);
    canvas->drawLine(r.fLeft, r.fTop, r.fRight, r.fBottom, paint);
}

static void drawLine(SkCanvas* canvas, const SkPoint& p0, const SkPoint& p1,
                     const SkPaint& paint) {
    canvas->drawLine(p0.fX, p0.fY, p1.fX, p1.fY, paint);
}

static void show_mesh(SkCanvas* canvas, const SkPoint pts[],
                      const uint16_t indices[], int count) {
    SkPaint paint;
    setGLFrame(&paint);

    for (int i = 0; i < count - 2; ++i) {
        drawLine(canvas, pts[indices[i]], pts[indices[i+1]], paint);
        drawLine(canvas, pts[indices[i+1]], pts[indices[i+2]], paint);
        drawLine(canvas, pts[indices[i+2]], pts[indices[i]], paint);
    }
}

static void show_glframe(SkCanvas* canvas, const SkPath& path) {
    SkPaint paint;
    setGLFrame(&paint);
    canvas->drawPath(path, paint);
}

static void show_mesh_between(SkCanvas* canvas, const SkPath& p0, const SkPath& p1) {
    SkPath d0, d1;
    tesselate(p0, &d0);
    tesselate(p1, &d1);

    SkPoint pts0[256*2], pts1[256];
    int count = d0.getPoints(pts0, SK_ARRAY_COUNT(pts0));
    int count1 = d1.getPoints(pts1, SK_ARRAY_COUNT(pts1));
    SkASSERT(count == count1);
    memcpy(&pts0[count], pts1, count * sizeof(SkPoint));

    uint16_t indices[256*6];
    uint16_t* ndx = indices;
    for (int i = 0; i < count; ++i) {
        *ndx++ = i;
        *ndx++ = i + count;
    }
    *ndx++ = 0;

    show_mesh(canvas, pts0, indices, ndx - indices);
}

static void show_fan(SkCanvas* canvas, const SkPath& path, SkScalar cx, SkScalar cy) {
    SkPaint paint;
    setGLFrame(&paint);

    canvas->drawPath(path, paint);

    SkPoint pts[256];
    int count = path.getPoints(pts, SK_ARRAY_COUNT(pts));
    for (int i = 0; i < count; ++i) {
        canvas->drawLine(pts[i].fX, pts[i].fY, cx, cy, paint);
    }
}

///////////////////////////////////////////////////////////////////////////////

typedef void (*DrawProc)(SkCanvas* canvas, bool showGL, int flags);

static void draw_line(SkCanvas* canvas, bool showGL, int flags) {
    SkPaint paint;
    paint.setAntiAlias(true);

    canvas->drawLine(50, 50, 400, 100, paint);

    canvas->rotate(40);
    setFade(&paint, showGL);
    paint.setStrokeWidth(40);
    canvas->drawLine(100, 50, 450, 50, paint);
    if (showGL) {
        show_mesh(canvas, SkRect::MakeLTRB(100, 50-20, 450, 50+20));
    }
}

static void draw_rect(SkCanvas* canvas, bool showGL, int flags) {
    SkPaint paint;
    paint.setAntiAlias(true);

    SkRect r = SkRect::MakeLTRB(50, 70, 250, 370);

    setFade(&paint, showGL);
    canvas->drawRect(r, paint);
    if (showGL) {
        show_mesh(canvas, r);
    }

    canvas->translate(320, 0);

    paint.setStyle(SkPaint::kStroke_Style);
    paint.setStrokeWidth(25);
    canvas->drawRect(r, paint);
    if (showGL) {
        SkScalar rad = paint.getStrokeWidth() / 2;
        SkPoint pts[8];
        r.outset(rad, rad);
        r.toQuad(&pts[0]);
        r.inset(rad*2, rad*2);
        r.toQuad(&pts[4]);

        const uint16_t indices[] = {
            0, 4, 1, 5, 2, 6, 3, 7, 0, 4
        };
        show_mesh(canvas, pts, indices, SK_ARRAY_COUNT(indices));
    }
}

static void draw_oval(SkCanvas* canvas, bool showGL, int flags) {
    SkPaint paint;
    paint.setAntiAlias(true);

    SkRect r = SkRect::MakeLTRB(50, 70, 250, 370);

    setFade(&paint, showGL);
    canvas->drawOval(r, paint);
    if (showGL) {
        switch (flags) {
            case 0: {
                SkPath path;
                path.addOval(r);
                show_glframe(canvas, path);
            } break;
            case 1:
            case 2: {
                SkPath src, dst;
                src.addOval(r);
                tesselate(src, &dst);
                show_fan(canvas, dst, r.centerX(), r.centerY());
            } break;
        }
    }

    canvas->translate(320, 0);

    paint.setStyle(SkPaint::kStroke_Style);
    paint.setStrokeWidth(25);
    canvas->drawOval(r, paint);
    if (showGL) {
        switch (flags) {
            case 0: {
                SkPath path;
                SkScalar rad = paint.getStrokeWidth() / 2;
                r.outset(rad, rad);
                path.addOval(r);
                r.inset(rad*2, rad*2);
                path.addOval(r);
                show_glframe(canvas, path);
            } break;
            case 1: {
                SkPath path0, path1;
                SkScalar rad = paint.getStrokeWidth() / 2;
                r.outset(rad, rad);
                path0.addOval(r);
                r.inset(rad*2, rad*2);
                path1.addOval(r);
                show_mesh_between(canvas, path0, path1);
            } break;
            case 2: {
                SkScalar rad = paint.getStrokeWidth() / 2;
                r.outset(rad, rad);
                SkPaint paint;
                paint.setAlpha(0x33);
                canvas->drawRect(r, paint);
                show_mesh(canvas, r);
            } break;
        }
    }
}

#include "SkImageDecoder.h"
static void draw_image(SkCanvas* canvas, bool showGL, int flags) {
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);
    setFade(&paint, showGL);

    SkBitmap bm;
    SkImageDecoder::DecodeFile("/skimages/startrek.png", &bm);
    SkRect r = SkRect::MakeWH(bm.width(), bm.height());

    canvas->save();
    canvas->translate(30, 30);
    canvas->scale(0.8f, 0.8f);
    canvas->drawBitmap(bm, 0, 0, &paint);
    if (showGL) {
        show_mesh(canvas, r);
    }
    canvas->restore();

    canvas->translate(210, 290);
    canvas->rotate(-35);
    canvas->drawBitmap(bm, 0, 0, &paint);
    if (showGL) {
        show_mesh(canvas, r);
    }
}

static void draw_text(SkCanvas* canvas, bool showGL, int flags) {
    SkPaint paint;
    paint.setAntiAlias(true);
    const char text[] = "Graphics at Google";
    size_t len = strlen(text);
    setFade(&paint, showGL);

    canvas->translate(40, 50);
    for (int i = 0; i < 10; ++i) {
        paint.setTextSize(12 + i * 3);
        canvas->drawText(text, len, 0, 0, paint);
        if (showGL) {
            SkRect bounds[256];
            SkScalar widths[256];
            int count = paint.getTextWidths(text, len, widths, bounds);
            SkScalar adv = 0;
            for (int j = 0; j < count; ++j) {
                bounds[j].offset(adv, 0);
                show_mesh(canvas, bounds[j]);
                adv += widths[j];
            }
        }
        canvas->translate(0, paint.getTextSize() * 3 / 2);
    }
}

static const struct {
    DrawProc    fProc;
    const char* fName;
} gRec[] = {
    {   draw_line,  "Lines" },
    {   draw_rect,  "Rects" },
    {   draw_oval,  "Ovals" },
    {   draw_image, "Images" },
    {   draw_text,  "Text" },
};

class TalkGM : public skiagm::GM {
    DrawProc fProc;
    SkString fName;
    bool     fShowGL;
    int      fFlags;

public:
    TalkGM(int index, bool showGL, int flags = 0) {
        fProc = gRec[index].fProc;
        fName.set(gRec[index].fName);
        if (showGL) {
            fName.append("-gl");
        }
        fShowGL = showGL;
        fFlags = flags;
    }

protected:
    virtual SkString onShortName() {
        return fName;
    }

    virtual SkISize onISize() {
        return SkISize::Make(640, 480);
    }

    virtual void onDraw(SkCanvas* canvas) {
        SkRect dst = SkRect::MakeWH(canvas->getDevice()->width(), canvas->getDevice()->height());
        SkRect src = SkRect::MakeWH(640, 480);
        SkMatrix matrix;
        matrix.setRectToRect(src, dst, SkMatrix::kCenter_ScaleToFit);

        canvas->concat(matrix);
        fProc(canvas, fShowGL, fFlags);
    }

private:
    typedef skiagm::GM INHERITED;
};

//////////////////////////////////////////////////////////////////////////////

#define GM_CONCAT(X,Y) GM_CONCAT_IMPL(X,Y)
#define GM_CONCAT_IMPL(X,Y) X##Y

#define FACTORY_NAME  GM_CONCAT(Factory, __LINE__)
#define REGISTRY_NAME  GM_CONCAT(gReg, __LINE__)

#define ADD_GM(Class, args)    \
    static skiagm::GM* FACTORY_NAME(void*) { return new Class args; } \
    static skiagm::GMRegistry REGISTRY_NAME(FACTORY_NAME);

ADD_GM(TalkGM, (0, false))
ADD_GM(TalkGM, (0, true))
ADD_GM(TalkGM, (1, false))
ADD_GM(TalkGM, (1, true))
ADD_GM(TalkGM, (2, false))
ADD_GM(TalkGM, (2, true))
ADD_GM(TalkGM, (2, true, 1))
ADD_GM(TalkGM, (2, true, 2))
ADD_GM(TalkGM, (3, false))
ADD_GM(TalkGM, (3, true))
ADD_GM(TalkGM, (4, false))
ADD_GM(TalkGM, (4, true))

//static GM* MyFactory(void*) { return new TalkGM(0, false); }
//static GMRegistry reg(MyFactory);

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: opaqitem.hxx,v $
 *
 *  $Revision: 1.8 $
 *
 *  last change: $Author: kz $ $Date: 2007-05-10 14:20:27 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _SVX_OPAQITEM_HXX
#define _SVX_OPAQITEM_HXX

// include ---------------------------------------------------------------

#ifndef _SFXENUMITEM_HXX //autogen
#include <svtools/eitem.hxx>
#endif

#ifndef INCLUDED_SVXDLLAPI_H
#include "svx/svxdllapi.h"
#endif

class SvXMLUnitConverter;
namespace rtl
{
    class OUString;
}

// class SvxOpaqueItem ---------------------------------------------------

/*
[Beschreibung]
Dieses Item beschreibt eine logische Variable "Undurchsichtig ja oder nein".
*/

class SVX_DLLPUBLIC SvxOpaqueItem : public SfxBoolItem
{
public:
    TYPEINFO();

    SvxOpaqueItem( const USHORT nId , const BOOL bOpa = TRUE );
    inline SvxOpaqueItem &operator=( const SvxOpaqueItem &rCpy );

    // "pure virtual Methoden" vom SfxPoolItem
    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
    virtual SfxPoolItem*    Create(SvStream &, USHORT) const;
    virtual SvStream&       Store(SvStream &, USHORT nItemVersion ) const;

    virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
                                    SfxMapUnit eCoreMetric,
                                    SfxMapUnit ePresMetric,
                                    String &rText, const IntlWrapper * = 0 ) const;
};

inline SvxOpaqueItem::SvxOpaqueItem( const USHORT nId, const BOOL bOpa )
    : SfxBoolItem( nId, bOpa )
{}

inline SvxOpaqueItem &SvxOpaqueItem::operator=( const SvxOpaqueItem &rCpy )
{
    SetValue( rCpy.GetValue() );
    return *this;
}

#endif

<commit_msg>INTEGRATION: CWS changefileheader (1.8.446); FILE MERGED 2008/04/01 15:49:19 thb 1.8.446.3: #i85898# Stripping all external header guards 2008/04/01 12:46:23 thb 1.8.446.2: #i85898# Stripping all external header guards 2008/03/31 14:17:58 rt 1.8.446.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: opaqitem.hxx,v $
 * $Revision: 1.9 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
#ifndef _SVX_OPAQITEM_HXX
#define _SVX_OPAQITEM_HXX

// include ---------------------------------------------------------------

#include <svtools/eitem.hxx>
#include "svx/svxdllapi.h"

class SvXMLUnitConverter;
namespace rtl
{
    class OUString;
}

// class SvxOpaqueItem ---------------------------------------------------

/*
[Beschreibung]
Dieses Item beschreibt eine logische Variable "Undurchsichtig ja oder nein".
*/

class SVX_DLLPUBLIC SvxOpaqueItem : public SfxBoolItem
{
public:
    TYPEINFO();

    SvxOpaqueItem( const USHORT nId , const BOOL bOpa = TRUE );
    inline SvxOpaqueItem &operator=( const SvxOpaqueItem &rCpy );

    // "pure virtual Methoden" vom SfxPoolItem
    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
    virtual SfxPoolItem*    Create(SvStream &, USHORT) const;
    virtual SvStream&       Store(SvStream &, USHORT nItemVersion ) const;

    virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
                                    SfxMapUnit eCoreMetric,
                                    SfxMapUnit ePresMetric,
                                    String &rText, const IntlWrapper * = 0 ) const;
};

inline SvxOpaqueItem::SvxOpaqueItem( const USHORT nId, const BOOL bOpa )
    : SfxBoolItem( nId, bOpa )
{}

inline SvxOpaqueItem &SvxOpaqueItem::operator=( const SvxOpaqueItem &rCpy )
{
    SetValue( rCpy.GetValue() );
    return *this;
}

#endif

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: unoshcol.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: rt $ $Date: 2003-09-19 08:32:11 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _SVX_UNOSHGRP_HXX
#define _SVX_UNOSHGRP_HXX

#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
#include <com/sun/star/lang/XComponent.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_XSHAPES_HPP_
#include <com/sun/star/drawing/XShapes.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
#ifndef _OSL_MUTEX_HXX_
#include <osl/mutex.hxx>
#endif
#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
#include <cppuhelper/interfacecontainer.hxx>
#endif

#include <cppuhelper/implbase3.hxx>

class XShapeList;

class SvxShapeCollectionMutex
{
public:
    ::osl::Mutex maMutex;
};

com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SvxShapeCollection_NewInstance() throw();

/***********************************************************************
*                                                                      *
***********************************************************************/
class SvxShapeCollection :  public ::cppu::WeakAggImplHelper3<
                                            ::com::sun::star::drawing::XShapes,
                                            ::com::sun::star::lang::XServiceInfo,
                                            ::com::sun::star::lang::XComponent
                                            >,
                            public SvxShapeCollectionMutex
{
private:
    cppu::OInterfaceContainerHelper maShapeContainer;

    cppu::OBroadcastHelper mrBHelper;

    virtual void disposing() throw();

public:
    SvxShapeCollection() throw();
    virtual ~SvxShapeCollection() throw();

    // XInterface
    virtual void SAL_CALL release() throw();

    // XComponent
    virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);

    // XIndexAccess
    virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ;
    virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);

    // XElementAccess
    virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);

    // XShapes
    virtual void SAL_CALL add( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw(::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw(::com::sun::star::uno::RuntimeException);

    // XServiceInfo
    virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
    static com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static();
    static ::rtl::OUString getImplementationName_Static();
};

::com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL SvxShapeCollection_createInstance( const com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSMgr );
#endif

<commit_msg>INTEGRATION: CWS visibility01 (1.3.518); FILE MERGED 2004/12/06 08:10:56 mnicel 1.3.518.2: Part of symbol visibility markup - #i35758# 2004/11/19 12:54:35 mmeeks 1.3.518.1: Issue number: #i35758# Submitted by: mnicel Reviewed by:  mmeeks<commit_after>/*************************************************************************
 *
 *  $RCSfile: unoshcol.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: kz $ $Date: 2005-01-21 15:50:43 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _SVX_UNOSHGRP_HXX
#define _SVX_UNOSHGRP_HXX

#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
#include <com/sun/star/lang/XComponent.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_XSHAPES_HPP_
#include <com/sun/star/drawing/XShapes.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
#ifndef _OSL_MUTEX_HXX_
#include <osl/mutex.hxx>
#endif
#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
#include <cppuhelper/interfacecontainer.hxx>
#endif

#include <cppuhelper/implbase3.hxx>

#ifndef INCLUDED_SVXDLLAPI_H
#include "svx/svxdllapi.h"
#endif

class XShapeList;

class SvxShapeCollectionMutex
{
public:
    ::osl::Mutex maMutex;
};

SVX_DLLPUBLIC com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SvxShapeCollection_NewInstance() throw();

/***********************************************************************
*                                                                      *
***********************************************************************/
class SVX_DLLPUBLIC SvxShapeCollection :    public ::cppu::WeakAggImplHelper3<
                                            ::com::sun::star::drawing::XShapes,
                                            ::com::sun::star::lang::XServiceInfo,
                                            ::com::sun::star::lang::XComponent
                                            >,
                            public SvxShapeCollectionMutex
{
private:
    cppu::OInterfaceContainerHelper maShapeContainer;

    cppu::OBroadcastHelper mrBHelper;

    SVX_DLLPRIVATE virtual void disposing() throw();

public:
    SvxShapeCollection() throw();
    virtual ~SvxShapeCollection() throw();

    // XInterface
    virtual void SAL_CALL release() throw();

    // XComponent
    virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);

    // XIndexAccess
    virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ;
    virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);

    // XElementAccess
    virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);

    // XShapes
    virtual void SAL_CALL add( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw(::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw(::com::sun::star::uno::RuntimeException);

    // XServiceInfo
    virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
    virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
    static com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static();
    static ::rtl::OUString getImplementationName_Static();
};

::com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL SvxShapeCollection_createInstance( const com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rSMgr );
#endif

<|endoftext|>