- int red, green, blue;
- if (wxSscanf(str.substr(3), wxT("(%d, %d, %d)"), &red, &green, &blue) != 3)
- return false;
-
- Set((unsigned char)wxClip(red,0,255),
- (unsigned char)wxClip(green,0,255),
- (unsigned char)wxClip(blue,0,255));
+ int red, green, blue,
+ alpha = wxALPHA_OPAQUE;
+ if ( str.length() > 3 && (str[3] == wxT('a') || str[3] == wxT('A')) )
+ {
+ float a;
+ // TODO: use locale-independent function
+ if ( wxSscanf(str.wx_str() + 4, wxT("( %d , %d , %d , %f )"),
+ &red, &green, &blue, &a) != 4 )
+ return false;
+
+ alpha = wxRound(a * 255);
+ }
+ else // no 'a' following "rgb"
+ {
+ if ( wxSscanf(str.wx_str() + 3, wxT("( %d , %d , %d )"),
+ &red, &green, &blue) != 3 )
+ return false;
+ }
+
+ Set((unsigned char)wxClip(red, 0, 255),
+ (unsigned char)wxClip(green, 0, 255),
+ (unsigned char)wxClip(blue, 0, 255),
+ (unsigned char)wxClip(alpha, 0, 255));