* Drawing operations
*
*/
-
+
#define DRAWOP_SET_PEN 1
#define DRAWOP_SET_BRUSH 2
#define DRAWOP_SET_FONT 3
* Base, virtual class
*
*/
-
+
class wxDrawOp: public wxObject
{
public:
* Set font, brush, text colour
*
*/
-
+
class wxOpSetGDI: public wxDrawOp
{
public:
* Set/destroy clipping
*
*/
-
+
class wxOpSetClipping: public wxDrawOp
{
public:
* Draw line, rectangle, rounded rectangle, ellipse, point, arc, text
*
*/
-
+
class wxOpDraw: public wxDrawOp
{
public:
wxOpDraw(int theOp, double theX1, double theY1, double theX2, double theY2,
- double radius = 0.0, char *s = NULL);
+ double radius = 0.0, wxChar *s = NULL);
~wxOpDraw();
void Do(wxDC& dc, double xoffset, double yoffset);
void Scale(double scaleX, double scaleY);
double m_x3;
double m_y3;
double m_radius;
- char* m_textString;
+ wxChar* m_textString;
};
public:
wxRealPoint* m_points;
int m_noPoints;
-
+
};
#endif
long param6;
long param7;
long param8;
- char *stringParam;
+ wxChar *stringParam;
wxRealPoint *points;
-
+
wxMetaRecord(int fun)
{
metaFunction = fun; points = NULL; stringParam = NULL;
// referenced by position in list by SelectObject
wxXMetaFile(char *file = NULL);
~wxXMetaFile(void);
-
+
// After this is called, the metafile cannot be used for anything
// since it is now owned by the clipboard.
bool SetClipboard(int width = 0, int height = 0);
void wxShape::NameRegions(const wxString& parentName)
{
int n = GetNumberOfTextRegions();
- char buf[100];
+ wxString buff;
for (int i = 0; i < n; i++)
{
if (parentName.Length() > 0)
- sprintf(buf, "%s.%d", (const char*) parentName, i);
+ buff << parentName << "." << i;
else
- sprintf(buf, "%d", i);
- SetRegionName(buf, i);
+ buff << i;
+ SetRegionName(buff, i);
}
wxNode *node = m_children.First();
int j = 0;
while (node)
{
+ buff.Empty();
wxShape *child = (wxShape *)node->Data();
if (parentName.Length() > 0)
- sprintf(buf, "%s.%d", (const char*) parentName, j);
+ buff << parentName << "." << i;
else
- sprintf(buf, "%d", j);
- child->NameRegions(buf);
+ buff << i;
+ child->NameRegions(buff);
node = node->Next();
j ++;
}
for (int i = 0; i < n; i++)
{
wxString name(GetRegionName(i));
- list.Add((const char*) name);
+ list.Add(name);
}
wxNode *node = m_children.First();
}
}
wxShapeTextLine *line =
- new wxShapeTextLine(the_x, the_y, (char*) (const char*) the_string);
+ new wxShapeTextLine(the_x, the_y, the_string);
m_text.Append(line);
node = node->next;
if (the_string)
{
wxShapeTextLine *line =
- new wxShapeTextLine(the_x, the_y, (char*) (const char*) the_string);
+ new wxShapeTextLine(the_x, the_y, the_string);
region->m_formattedText.Append(line);
}
node = node->next;
}
default:
{
- wxFAIL_MSG( "Unrecognised attachment point in GetBranchingAttachmentInfo." );
+ wxFAIL_MSG( wxT("Unrecognised attachment point in GetBranchingAttachmentInfo.") );
break;
}
}
}
default:
{
- wxFAIL_MSG( "Unrecognised attachment point in GetBranchingAttachmentPoint." );
+ wxFAIL_MSG( wxT("Unrecognised attachment point in GetBranchingAttachmentPoint.") );
break;
}
}
}
default:
{
- wxFAIL_MSG( "Unrecognised attachment point in GetBranchingAttachmentRoot." );
+ wxFAIL_MSG( wxT("Unrecognised attachment point in GetBranchingAttachmentRoot.") );
break;
}
}
{
wxShape::WriteAttributes(clause);
- clause->AddAttributeValue("x", m_xpos);
- clause->AddAttributeValue("y", m_ypos);
+ clause->AddAttributeValue(wxT("x"), m_xpos);
+ clause->AddAttributeValue(wxT("y"), m_ypos);
// Make a list of lists for the coordinates
wxExpr *list = new wxExpr(wxExprList);
node = node->Next();
}
- clause->AddAttributeValue("points", list);
+ clause->AddAttributeValue(wxT("points"), list);
// Save the original (unscaled) points
list = new wxExpr(wxExprList);
node = node->Next();
}
- clause->AddAttributeValue("m_originalPoints", list);
+ clause->AddAttributeValue(wxT("m_originalPoints"), list);
}
void wxPolygonShape::ReadAttributes(wxExpr *clause)
m_originalPoints = new wxList;
wxExpr *points_list = NULL;
- clause->AssignAttributeValue("points", &points_list);
+ clause->AssignAttributeValue(wxT("points"), &points_list);
// If no points_list, don't crash!! Assume a diamond instead.
double the_height = 100.0;
}
points_list = NULL;
- clause->AssignAttributeValue("m_originalPoints", &points_list);
+ clause->AssignAttributeValue(wxT("m_originalPoints"), &points_list);
// If no points_list, don't crash!! Assume a diamond instead.
if (!points_list)
void wxRectangleShape::WriteAttributes(wxExpr *clause)
{
wxShape::WriteAttributes(clause);
- clause->AddAttributeValue("x", m_xpos);
- clause->AddAttributeValue("y", m_ypos);
+ clause->AddAttributeValue(wxT("x"), m_xpos);
+ clause->AddAttributeValue(wxT("y"), m_ypos);
- clause->AddAttributeValue("width", m_width);
- clause->AddAttributeValue("height", m_height);
+ clause->AddAttributeValue(wxT("width"), m_width);
+ clause->AddAttributeValue(wxT("height"), m_height);
if (m_cornerRadius != 0.0)
- clause->AddAttributeValue("corner", m_cornerRadius);
+ clause->AddAttributeValue(wxT("corner"), m_cornerRadius);
}
void wxRectangleShape::ReadAttributes(wxExpr *clause)
{
wxShape::ReadAttributes(clause);
- clause->AssignAttributeValue("width", &m_width);
- clause->AssignAttributeValue("height", &m_height);
- clause->AssignAttributeValue("corner", &m_cornerRadius);
+ clause->AssignAttributeValue(wxT("width"), &m_width);
+ clause->AssignAttributeValue(wxT("height"), &m_height);
+ clause->AssignAttributeValue(wxT("corner"), &m_cornerRadius);
// In case we're reading an old file, set the region's size
if (m_regions.Number() == 1)
void wxEllipseShape::WriteAttributes(wxExpr *clause)
{
wxShape::WriteAttributes(clause);
- clause->AddAttributeValue("x", m_xpos);
- clause->AddAttributeValue("y", m_ypos);
+ clause->AddAttributeValue(wxT("x"), m_xpos);
+ clause->AddAttributeValue(wxT("y"), m_ypos);
- clause->AddAttributeValue("width", m_width);
- clause->AddAttributeValue("height", m_height);
+ clause->AddAttributeValue(wxT("width"), m_width);
+ clause->AddAttributeValue(wxT("height"), m_height);
}
void wxEllipseShape::ReadAttributes(wxExpr *clause)
{
wxShape::ReadAttributes(clause);
- clause->AssignAttributeValue("width", &m_width);
- clause->AssignAttributeValue("height", &m_height);
+ clause->AssignAttributeValue(wxT("width"), &m_width);
+ clause->AssignAttributeValue(wxT("height"), &m_height);
// In case we're reading an old file, set the region's size
if (m_regions.Number() == 1)
if (objExpr1 && objExpr1->GetClientData())
m_constrainingObject = (wxShape *)objExpr1->GetClientData();
else
- wxLogFatalError("Object graphics error: Couldn't find constraining image of composite.");
+ wxLogFatalError(wxT("Object graphics error: Couldn't find constraining image of composite."));
int i = 0;
wxExpr *currentIdExpr = constrainedExpr->Nth(i);
}
else
{
- wxLogFatalError("Object graphics error: Couldn't find constrained image of composite.");
+ wxLogFatalError(wxT("Object graphics error: Couldn't find constrained image of composite."));
}
i ++;
wxOGLConstraint *newConstraint = AddConstraint(cType, m_constrainingObject, m_constrainedObjects);
newConstraint->SetSpacing(cXSpacing, cYSpacing);
newConstraint->m_constraintId = cId;
- newConstraint->m_constraintName = (const char*) cName;
+ newConstraint->m_constraintName = cName;
constraintNo ++;
}
}
wxShapeRegion *region = (wxShapeRegion *)node->Data();
if (region->GetText())
{
- char *s = copystring(region->GetText());
+ wxChar *s = copystring(region->GetText());
dividedObject->FormatText(dc, s, i);
delete[] s;
}
m_metafiles[m_currentAngle].m_outlinePen = g_oglTransparentPen;
m_metafiles[m_currentAngle].Draw(dc, m_xpos + m_shadowOffsetX, m_ypos + m_shadowOffsetY);
}
-
+
m_metafiles[m_currentAngle].m_outlinePen = m_pen;
m_metafiles[m_currentAngle].m_fillBrush = m_brush;
m_metafiles[m_currentAngle].Draw(dc, m_xpos, m_ypos);
// Rotate metafile
if (!m_metafiles[0].GetRotateable())
return;
-
+
m_metafiles[0].Rotate(x, y, theta);
}
* Individual operations
*
*/
-
+
/*
* Set font, brush, text colour
*
*/
-
+
wxOpSetGDI::wxOpSetGDI(int theOp, wxPseudoMetaFile *theImage, int theGdiIndex, int theMode):
wxDrawOp(theOp)
{
* Set/destroy clipping
*
*/
-
+
wxOpSetClipping::wxOpSetClipping(int theOp, double theX1, double theY1,
double theX2, double theY2):wxDrawOp(theOp)
{
wxOpSetClipping *newOp = new wxOpSetClipping(m_op, m_x1, m_y1, m_x2, m_y2);
return newOp;
}
-
+
void wxOpSetClipping::Do(wxDC& dc, double xoffset, double yoffset)
{
switch (m_op)
* Draw line, rectangle, rounded rectangle, ellipse, point, arc, text
*
*/
-
+
wxOpDraw::wxOpDraw(int theOp, double theX1, double theY1, double theX2, double theY2,
- double theRadius, char *s):wxDrawOp(theOp)
+ double theRadius, wxChar *s) : wxDrawOp(theOp)
{
m_x1 = theX1;
m_y1 = theY1;
m_x1 = expr->Nth(1)->RealValue();
m_y1 = expr->Nth(2)->RealValue();
wxString str(expr->Nth(3)->StringValue());
- m_textString = copystring((const char*) str);
+ m_textString = copystring(str);
break;
}
case DRAWOP_DRAW_ARC:
* E.g. "1B9080CD". 4 hex digits per coordinate pair.
*
*/
-
+
for (int i = 0; i < m_noPoints; i++)
{
long signedX = (long)(m_points[i].x*100.0);
// Scale to 0 -> 64K
long unSignedX = (long)(signedX + 32767.0);
long unSignedY = (long)(signedY + 32767.0);
-
+
// IntToHex((unsigned int)signedX, buf2);
// IntToHex((unsigned int)signedY, buf3);
IntToHex((int)unSignedX, buf2);
buf1[2] = hexString[(size_t)(bufPtr + 2)];
buf1[3] = hexString[(size_t)(bufPtr + 3)];
buf1[4] = 0;
-
+
buf2[0] = hexString[(size_t)(bufPtr + 4)];
buf2[1] = hexString[(size_t)(bufPtr + 5)];
buf2[2] = hexString[(size_t)(bufPtr + 6)];
}
}
}
-
+
double *xpoints = new double[n];
double *ypoints = new double[n];
ypoints[i] = point->y + yOffset;
}
- oglFindEndForPolyline(n, xpoints, ypoints,
+ oglFindEndForPolyline(n, xpoints, ypoints,
x1, y1, x2, y2, x3, y3);
delete[] xpoints;
int digit2 = (int)((dec - (digit1*4096))/256);
int digit3 = (int)((dec - (digit1*4096) - (digit2*256))/16);
int digit4 = dec - (digit1*4096 + digit2*256 + digit3*16);
-
+
buf[0] = hexArray[digit1];
buf[1] = hexArray[digit2];
buf[2] = hexArray[digit3];
void wxPseudoMetaFile::WriteAttributes(wxExpr *clause, int whichAngle)
{
wxString widthStr;
- widthStr.Printf("meta_width%d", whichAngle);
+ widthStr.Printf(wxT("meta_width%d"), whichAngle);
wxString heightStr;
- heightStr.Printf("meta_height%d", whichAngle);
+ heightStr.Printf(wxT("meta_height%d"), whichAngle);
wxString outlineStr;
- outlineStr.Printf("outline_op%d", whichAngle);
+ outlineStr.Printf(wxT("outline_op%d"), whichAngle);
wxString rotateableStr;
- rotateableStr.Printf("meta_rotateable%d", whichAngle);
+ rotateableStr.Printf(wxT("meta_rotateable%d"), whichAngle);
// Write width and height
clause->AddAttributeValue(widthStr, m_width);
node = node->Next();
}
wxString outlineObjectsStr;
- outlineObjectsStr.Printf("outline_objects%d", whichAngle);
+ outlineObjectsStr.Printf(wxT("outline_objects%d"), whichAngle);
clause->AddAttributeValue(outlineObjectsStr, outlineExpr);
}
node = node->Next();
}
wxString fillObjectsStr;
- fillObjectsStr.Printf("fill_objects%d", whichAngle);
+ fillObjectsStr.Printf(wxT("fill_objects%d"), whichAngle);
clause->AddAttributeValue(fillObjectsStr, fillExpr);
}
-
+
}
void wxPseudoMetaFile::ReadAttributes(wxExpr *clause, int whichAngle)
{
wxString widthStr;
- widthStr.Printf("meta_width%d", whichAngle);
+ widthStr.Printf(wxT("meta_width%d"), whichAngle);
wxString heightStr;
- heightStr.Printf("meta_height%d", whichAngle);
+ heightStr.Printf(wxT("meta_height%d"), whichAngle);
wxString outlineStr;
- outlineStr.Printf("outline_op%d", whichAngle);
+ outlineStr.Printf(wxT("outline_op%d"), whichAngle);
wxString rotateableStr;
- rotateableStr.Printf("meta_rotateable%d", whichAngle);
+ rotateableStr.Printf(wxT("meta_rotateable%d"), whichAngle);
clause->GetAttributeValue(widthStr, m_width);
clause->GetAttributeValue(heightStr, m_height);
m_ops.Append(theOp);
break;
}
-
+
case DRAWOP_SET_CLIPPING_RECT:
case DRAWOP_DESTROY_CLIPPING_RECT:
{
}
wxString outlineObjectsStr;
- outlineObjectsStr.Printf("outline_objects%d", whichAngle);
+ outlineObjectsStr.Printf(wxT("outline_objects%d"), whichAngle);
// Now read in the list of outline and fill operations, if any
wxExpr *expr1 = clause->AttributeValue(outlineObjectsStr);
}
wxString fillObjectsStr;
- fillObjectsStr.Printf("fill_objects%d", whichAngle);
+ fillObjectsStr.Printf(wxT("fill_objects%d"), whichAngle);
expr1 = clause->AttributeValue(fillObjectsStr);
if (expr1)
copy.m_gdiObjects.Append(obj);
node = node->Next();
}
-
+
// Copy the operations
node = m_ops.First();
while (node)
* fit width and return new width and height.
*
*/
-
+
bool wxPseudoMetaFile::LoadFromMetaFile(char *filename, double *rwidth, double *rheight)
{
if (!FileExists(filename))
return NULL;
-
+
wxXMetaFile *metaFile = new wxXMetaFile;
-
+
if (!metaFile->ReadFile(filename))
{
delete metaFile;
newPoints[i].x = record->points[i].x;
newPoints[i].y = record->points[i].y;
}
-
+
wxOpPolyDraw *op = new wxOpPolyDraw(DRAWOP_DRAW_POLYGON, n, newPoints);
m_ops.Append(op);
break;
newPoints[i].x = record->points[i].x;
newPoints[i].y = record->points[i].y;
}
-
+
wxOpPolyDraw *op = new wxOpPolyDraw(DRAWOP_DRAW_POLYLINE, n, newPoints);
m_ops.Append(op);
break;
region->GetSize(&w, &h);
// Initialize the size if zero
- if (((w == 0) || (h == 0)) && (strlen(s) > 0))
+ if (((w == 0) || (h == 0)) && (s.Length() > 0))
{
w = 100; h = 50;
region->SetSize(w, h);
else
{
- wxLogFatalError("Unknown arrowhead rotation case in lines.cc");
+ wxLogFatalError(wxT("Unknown arrowhead rotation case in lines.cc"));
}
// Rotate about the centre of the object, then place
wxShape::ReadAttributes(clause);
int iVal = (int) m_isSpline;
- clause->AssignAttributeValue("is_spline", &iVal);
+ clause->AssignAttributeValue(wxT("is_spline"), &iVal);
m_isSpline = (iVal != 0);
iVal = (int) m_maintainStraightLines;
- clause->AssignAttributeValue("keep_lines_straight", &iVal);
+ clause->AssignAttributeValue(wxT("keep_lines_straight"), &iVal);
m_maintainStraightLines = (iVal != 0);
- clause->AssignAttributeValue("align_start", &m_alignmentStart);
- clause->AssignAttributeValue("align_end", &m_alignmentEnd);
+ clause->AssignAttributeValue(wxT("align_start"), &m_alignmentStart);
+ clause->AssignAttributeValue(wxT("align_end"), &m_alignmentEnd);
// Compatibility: check for no regions.
if (m_regions.Number() == 0)
}
newRegion = new wxShapeRegion;
- newRegion->SetName("Start");
+ newRegion->SetName(wxT("Start"));
newRegion->SetSize(150, 50);
m_regions.Append((wxObject *)newRegion);
newRegion = new wxShapeRegion;
- newRegion->SetName("End");
+ newRegion->SetName(wxT("End"));
newRegion->SetSize(150, 50);
m_regions.Append((wxObject *)newRegion);
}
m_attachmentTo = 0;
m_attachmentFrom = 0;
- clause->AssignAttributeValue("attachment_to", &m_attachmentTo);
- clause->AssignAttributeValue("attachment_from", &m_attachmentFrom);
+ clause->AssignAttributeValue(wxT("attachment_to"), &m_attachmentTo);
+ clause->AssignAttributeValue(wxT("attachment_from"), &m_attachmentFrom);
wxExpr *line_list = NULL;
// When image is created, there are default control points. Override
// them if there are some in the file.
- clause->AssignAttributeValue("controls", &line_list);
+ clause->AssignAttributeValue(wxT("controls"), &line_list);
if (line_list)
{
// Read arrow list, for new OGL code
wxExpr *arrow_list = NULL;
- clause->AssignAttributeValue("arrows", &arrow_list);
+ clause->AssignAttributeValue(wxT("arrows"), &arrow_list);
if (arrow_list)
{
wxExpr *node = arrow_list->value.first;
int arrowEnd = 0;
double xOffset = 0.0;
double arrowSize = 0.0;
- wxString arrowName("");
+ wxString arrowName;
long arrowId = -1;
wxExpr *type_expr = node->Nth(0);
else
wxRegisterId(arrowId);
- wxArrowHead *arrowHead = AddArrow(arrowType, arrowEnd, arrowSize, xOffset, (char*) (const char*) arrowName, NULL, arrowId);
+ wxArrowHead *arrowHead = AddArrow(arrowType, arrowEnd, arrowSize, xOffset, arrowName, NULL, arrowId);
if (yOffsetExpr)
arrowHead->SetYOffset(yOffsetExpr->RealValue());
if (spacingExpr)
{
wxMetaRecord *rec = new wxMetaRecord(META_TEXTOUT);
int count = getshort(handle);
- rec->stringParam = new char[count+1];
- fread((void *)rec->stringParam, sizeof(char), count, handle);
+ rec->stringParam = new wxChar[count+1];
+ fread((void *)rec->stringParam, sizeof(wxChar), count, handle);
rec->stringParam[count] = 0;
rec->param2 = getshort(handle); // Y
rec->param1 = getshort(handle); // X
void wxOGLInitialize()
{
g_oglNormalFont = wxTheFontList->FindOrCreateFont(10, wxSWISS, wxNORMAL, wxNORMAL);
- g_oglBlackPen = wxThePenList->FindOrCreatePen("BLACK", 1, wxSOLID);
- g_oglTransparentPen = wxThePenList->FindOrCreatePen("WHITE", 1, wxTRANSPARENT);
- g_oglBlackForegroundPen = wxThePenList->FindOrCreatePen("BLACK", 1, wxSOLID);
- g_oglWhiteBackgroundPen = wxThePenList->FindOrCreatePen("WHITE", 1, wxSOLID);
- g_oglWhiteBackgroundBrush = wxTheBrushList->FindOrCreateBrush("WHITE", wxSOLID);
+ g_oglBlackPen = wxThePenList->FindOrCreatePen(wxT("BLACK"), 1, wxSOLID);
+ g_oglTransparentPen = wxThePenList->FindOrCreatePen(wxT("WHITE"), 1, wxTRANSPARENT);
+ g_oglBlackForegroundPen = wxThePenList->FindOrCreatePen(wxT("BLACK"), 1, wxSOLID);
+ g_oglWhiteBackgroundPen = wxThePenList->FindOrCreatePen(wxT("WHITE"), 1, wxSOLID);
+ g_oglWhiteBackgroundBrush = wxTheBrushList->FindOrCreateBrush(wxT("WHITE"), wxSOLID);
OGLInitializeConstraintTypes();
{
if (old_size <= 0)
old_size = 10;
- char buf[40];
- sprintf(buf, "%d", old_size);
- wxString ans = wxGetTextFromUser("Enter point size", "Font size", buf, parent);
- if (ans == "")
+ wxString buf;
+ buf << old_size;
+ wxString ans = wxGetTextFromUser(wxT("Enter point size"), wxT("Font size"), buf, parent);
+ if (ans.Length() == 0)
return 0;
- int new_size = atoi(ans);
+ long new_size = 0;
+ ans.ToLong(&new_size);
if ((new_size <= 0) || (new_size > 40))
{
- wxMessageBox("Invalid point size!", "Error", wxOK);
+ wxMessageBox(wxT("Invalid point size!"), wxT("Error"), wxOK);
return 0;
}
return new_size;
wxStringList word_list;
// Make new lines into NULL strings at this point
- int i = 0; int j = 0; int len = strlen(text);
- char word[200]; word[0] = 0;
+ int i = 0; int j = 0; int len = text.Length();
+ wxChar word[200]; word[0] = 0;
bool end_word = FALSE; bool new_line = FALSE;
while (i < len)
{
switch (text[i])
{
- case '%':
+ case wxT('%'):
{
i ++;
if (i == len)
- { word[j] = '%'; j ++; }
+ { word[j] = wxT('%'); j ++; }
else
{
- if (text[i] == 'n')
+ if (text[i] == wxT('n'))
{ new_line = TRUE; end_word = TRUE; i++; }
else
- { word[j] = '%'; j ++; word[j] = text[i]; j ++; i ++; }
+ { word[j] = wxT('%'); j ++; word[j] = text[i]; j ++; i ++; }
}
break;
}
{
new_line = TRUE; end_word = TRUE; i++;
}
- case ' ':
+ case wxT(' '):
{
end_word = TRUE;
i ++;
// Now, make a list of strings which can fit in the box
wxStringList *string_list = new wxStringList;
- char buffer[400];
- buffer[0] = 0;
+ wxString buffer;
wxNode *node = word_list.First();
long x, y;
if (!s)
{
// FORCE NEW LINE
- if (strlen(buffer) > 0)
+ if (buffer.Length() > 0)
string_list->Add(buffer);
- buffer[0] = 0;
+ buffer.Empty();
}
else
{
- if (buffer[0] != 0)
- strcat(buffer, " ");
+ if (buffer.Length() != 0)
+ buffer += " ";
- strcat(buffer, s);
+ buffer += s;
dc.GetTextExtent(buffer, &x, &y);
// Don't fit within the bounding box if we're fitting shape to contents
if (oldBuffer.Length() > 0)
string_list->Add(oldBuffer);
- buffer[0] = 0;
- strcat(buffer, s);
+ buffer.Empty();
+ buffer += s;
}
}
node = node->Next();
}
- if (buffer[0] != 0)
+ if (buffer.Length() != 0)
string_list->Add(buffer);
return string_list;
*/
// Array used in DecToHex conversion routine.
-static char sg_HexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
- 'C', 'D', 'E', 'F' };
+static wxChar sg_HexArray[] = { wxT('0'), wxT('1'), wxT('2'), wxT('3'),
+ wxT('4'), wxT('5'), wxT('6'), wxT('7'),
+ wxT('8'), wxT('9'), wxT('A'), wxT('B'),
+ wxT('C'), wxT('D'), wxT('E'), wxT('F')
+};
// Convert 2-digit hex number to decimal
-unsigned int oglHexToDec(char* buf)
+unsigned int oglHexToDec(wxChar* buf)
{
int firstDigit, secondDigit;
- if (buf[0] >= 'A')
- firstDigit = buf[0] - 'A' + 10;
+ if (buf[0] >= wxT('A'))
+ firstDigit = buf[0] - wxT('A') + 10;
else
- firstDigit = buf[0] - '0';
+ firstDigit = buf[0] - wxT('0');
- if (buf[1] >= 'A')
- secondDigit = buf[1] - 'A' + 10;
+ if (buf[1] >= wxT('A'))
+ secondDigit = buf[1] - wxT('A') + 10;
else
- secondDigit = buf[1] - '0';
+ secondDigit = buf[1] - wxT('0');
return firstDigit * 16 + secondDigit;
}
// Convert decimal integer to 2-character hex string
-void oglDecToHex(unsigned int dec, char *buf)
+void oglDecToHex(unsigned int dec, wxChar *buf)
{
int firstDigit = (int)(dec/16.0);
int secondDigit = (int)(dec - (firstDigit*16.0));
wxColour oglHexToColour(const wxString& hex)
{
if (hex.Length() == 6)
- {
- char buf[7];
- strncpy(buf, hex, 7);
- unsigned int r = oglHexToDec((char *)buf);
- unsigned int g = oglHexToDec((char *)(buf+2));
- unsigned int b = oglHexToDec((char *)(buf+4));
+ {
+ long r, g, b;
+ r = g = b = 0;
+ hex.Mid(0,2).ToLong(&r, 16);
+ hex.Mid(2,2).ToLong(&g, 16);
+ hex.Mid(4,2).ToLong(&b, 16);
return wxColour(r, g, b);
- }
- else
- return wxColour(0,0,0);
+ }
+ else
+ return wxColour(0,0,0);
}
// RGB to 3-digit hex
wxString oglColourToHex(const wxColour& colour)
{
- char buf[7];
+ wxChar buf[7];
unsigned int red = colour.Red();
unsigned int green = colour.Green();
unsigned int blue = colour.Blue();
}
OnDatabaseSave(*database);
- char tempFile[400];
- wxGetTempFileName("diag", tempFile);
- FILE* file = fopen(tempFile, "w");
+ wxString tempFile;
+ wxGetTempFileName(wxT("diag"), tempFile);
+ FILE* file = fopen(tempFile.mb_str(wxConvFile), "w");
if (! file)
{
wxEndBusyCursor();
wxExpr *clause = database.FindClauseByFunctor("shape");
while (clause)
{
- char *type = NULL;
+ wxChar *type = NULL;
long parentId = -1;
- clause->AssignAttributeValue("type", &type);
- clause->AssignAttributeValue("parent", &parentId);
+ clause->AssignAttributeValue(wxT("type"), &type);
+ clause->AssignAttributeValue(wxT("parent"), &parentId);
wxClassInfo *classInfo = wxClassInfo::FindClass(type);
if (classInfo)
{
wxExpr *clause = database.FindClauseByFunctor("line");
while (clause)
{
- wxString type("");
+ wxString type;
long parentId = -1;
clause->GetAttributeValue("type", type);
clause->GetAttributeValue("parent", parentId);
- wxClassInfo *classInfo = wxClassInfo::FindClass((char*) (const char*) type);
+ wxClassInfo *classInfo = wxClassInfo::FindClass(type);
if (classInfo)
{
wxLineShape *shape = (wxLineShape *)classInfo->CreateObject();