Fixed some stuff.

Originally committed to SVN as r2464.
This commit is contained in:
Rodrigo Braz Monteiro 2008-11-17 03:09:27 +00:00
parent dae123d225
commit e255222316
5 changed files with 29 additions and 45 deletions

View file

@ -186,6 +186,10 @@
RelativePath=".\include\athenasub\athenawin.h"
>
</File>
<File
RelativePath=".\include\athenasub\colour.h"
>
</File>
<File
RelativePath=".\include\athenasub\exception.h"
>
@ -194,6 +198,10 @@
RelativePath=".\include\athenasub\interfaces.h"
>
</File>
<File
RelativePath=".\include\athenasub\range.h"
>
</File>
<File
RelativePath=".\include\athenasub\tr1.h"
>
@ -242,10 +250,6 @@
RelativePath=".\src\colour.cpp"
>
</File>
<File
RelativePath=".\include\aegilib\colour.h"
>
</File>
<File
RelativePath=".\src\exception.cpp"
>

View file

@ -34,19 +34,20 @@
//
#pragma once
#include "athenasub.h"
namespace Athenasub {
class String;
// Colour class
class CColour : public IColour {
class Colour {
private:
unsigned char r, g, b, a;
public:
CColour ();
CColour (unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha=0);
CColour (int red,int green,int blue,int alpha=0);
Colour ();
Colour (unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha=0);
Colour (int red,int green,int blue,int alpha=0);
void SetRed(unsigned char red) { r = red; }
void SetGreen(unsigned char green) { g = green; }

View file

@ -38,6 +38,7 @@
#include "tr1.h"
#include "athenatime.h"
#include "athenastring.h"
#include "colour.h"
#include <vector>
#include <list>
@ -52,7 +53,6 @@ namespace Athenasub {
class IController;
class IView;
class IFormatHandler;
class IColour;
class IEntry;
class IDialogue;
class IStyle;
@ -72,7 +72,6 @@ namespace Athenasub {
typedef shared_ptr<IController> Controller;
typedef shared_ptr<IView> View;
typedef shared_ptr<IFormatHandler> FormatHandler;
typedef shared_ptr<IColour> Colour;
typedef shared_ptr<IEntry> Entry;
typedef shared_ptr<IDialogue> Dialogue;
typedef shared_ptr<IStyle> Style;
@ -145,6 +144,8 @@ namespace Athenasub {
class IView {
public:
virtual ~IView() {}
virtual void OnNotify(Notification notification) = 0;
};
@ -201,26 +202,6 @@ namespace Athenasub {
};
// Color
class IColour {
public:
virtual ~IColour() {}
virtual void SetRed(int red) = 0;
virtual void SetGreen(int green) = 0;
virtual void SetBlue(int blue) = 0;
virtual void SetAlpha(int alpha) = 0;
virtual int GetRed() const = 0;
virtual int GetGreen() const = 0;
virtual int GetBlue() const = 0;
virtual int GetAlpha() const = 0;
virtual void Parse(String str,bool reverse) = 0;
virtual String GetVBHex(bool withAlpha=false,bool withHeader=true,bool withFooter=true) const = 0;
};
// Types
enum SectionEntryType {
SECTION_ENTRY_PLAIN,
@ -304,7 +285,7 @@ namespace Athenasub {
virtual String GetName() const = 0;
virtual String GetFontName() const = 0;
virtual float GetFontSize() const = 0;
virtual const IColour& GetColour(int n) const = 0;
virtual const Colour& GetColour(int n) const = 0;
virtual int GetMargin(int n) const = 0;
};
@ -356,8 +337,6 @@ namespace Athenasub {
virtual ~IAction() {}
virtual Action GetAntiAction() const = 0;
virtual void Execute() = 0;
//virtual Section GetSection(const String &name) const = 0;
};

View file

@ -42,18 +42,18 @@ using namespace Athenasub;
////////////////
// Constructors
CColour::CColour ()
Colour::Colour ()
{
r = g = b = a = 0;
}
CColour::CColour (unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha)
Colour::Colour (unsigned char red,unsigned char green,unsigned char blue,unsigned char alpha)
{
r = red;
g = green;
b = blue;
a = alpha;
}
CColour::CColour (int red,int green,int blue,int alpha)
Colour::Colour (int red,int green,int blue,int alpha)
{
SetRed(red);
SetGreen(green);
@ -64,15 +64,15 @@ CColour::CColour (int red,int green,int blue,int alpha)
////////////////////////
// Set colour component
void CColour::SetRed(int red) { r = (unsigned char) Mid(0,red,255); }
void CColour::SetGreen(int green) { g = (unsigned char) Mid(0,green,255); }
void CColour::SetBlue(int blue) { b = (unsigned char) Mid(0,blue,255); }
void CColour::SetAlpha(int alpha) { a = (unsigned char) Mid(0,alpha,255); }
void Colour::SetRed(int red) { r = (unsigned char) Mid(0,red,255); }
void Colour::SetGreen(int green) { g = (unsigned char) Mid(0,green,255); }
void Colour::SetBlue(int blue) { b = (unsigned char) Mid(0,blue,255); }
void Colour::SetAlpha(int alpha) { a = (unsigned char) Mid(0,alpha,255); }
//////////////
// Parse text
void CColour::Parse(String value,bool reverse)
void Colour::Parse(String value,bool reverse)
{
// Prepare
unsigned char c;
@ -112,7 +112,7 @@ void CColour::Parse(String value,bool reverse)
/////////////////////////////
// Generate Visual Basic hex
String CColour::GetVBHex(bool withAlpha,bool withHeader,bool withFooter) const
String Colour::GetVBHex(bool withAlpha,bool withHeader,bool withFooter) const
{
String work;
if (withHeader) work += "&H";

View file

@ -48,7 +48,7 @@ namespace Athenasub {
float fontSize;
int formatVersion;
array<CColour,5> colour; // 0 = Primary, 1 = Secondary, 2 = Tertiary, 3 = Outline, 4 = Shadow
array<Colour,5> colour; // 0 = Primary, 1 = Secondary, 2 = Tertiary, 3 = Outline, 4 = Shadow
array<int,4> margin;
bool bold;
@ -90,7 +90,7 @@ namespace Athenasub {
String GetName() const { return name; }
String GetFontName() const { return font; }
float GetFontSize() const { return fontSize; }
const IColour& GetColour(int n) const { return colour.at(n); }
const Colour& GetColour(int n) const { return colour.at(n); }
int GetMargin(int n) const { return margin.at(n); }
};