X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;ds=sidebyside;f=source%2Fcommon%2Fcolour.h;h=b950973edc2ee2e9cfd2dc2833493f753fc63b32;hb=172322316537049f6ced59877a3b5bd3d2f64f2c;hp=8eebe416e085c09f185bfb0a439cae7d12c928e9;hpb=79fd61b6cd5e5ba6a44e7fc97a5b53d7e0d70793;p=xestiacalendar%2F.git
diff --git a/source/common/colour.h b/source/common/colour.h
index 8eebe41..b950973 100644
--- a/source/common/colour.h
+++ b/source/common/colour.h
@@ -17,6 +17,7 @@
// with Xestia Calendar. If not, see
#include
+#include
#include "text.h"
#ifndef __COMMON_COLOUR_H__
@@ -26,11 +27,75 @@ using namespace std;
struct Colour{
- int red;
- int blue;
- int green;
- int alpha;
+ int red = 0;
+ int blue = 0;
+ int green = 0;
+ int alpha = 255;
+ Colour& operator= (string const &arg){
+
+ // Check if the size of the string is 9.
+ // Return if not.
+
+ if (arg.size() != 9){
+
+ return *this;
+
+ }
+
+ // Check if the first character has a hash in.
+ // Return if not.
+
+ if (arg.substr(0,1) != "#"){
+
+ return *this;
+
+ }
+
+ // Check each character (1-8) and make sure
+ // it is a number or a letter between A and F.
+
+ for (int characterSeek = 1; characterSeek < 9; characterSeek++){
+
+ int characterASCII = 0;
+
+ characterASCII = arg[characterSeek];
+
+ if ((characterASCII < 48 && characterASCII > 57) || (characterASCII < 65 && characterASCII > 70)){
+ return *this;
+ }
+
+ }
+
+ istringstream hexNumber;
+
+ // Set the red value.
+
+ hexNumber.str(arg.substr(1,2));
+ hexNumber >> hex >> this->red;
+
+ // Set the green value.
+
+ hexNumber.clear();
+ hexNumber.str(arg.substr(3,2));
+ hexNumber >> hex >> this->green;
+
+ // Set the blue value.
+
+ hexNumber.clear();
+ hexNumber.str(arg.substr(5,2));
+ hexNumber >> hex >> this->blue;
+
+ // Set the alpha value.
+
+ hexNumber.clear();
+ hexNumber.str(arg.substr(7,2));
+ hexNumber >> hex >> this->alpha;
+
+ return *this;
+
+ }
+
operator string() {
string ColourOut;