X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/92a19c2e7757ba742846f83e56356de0a607bdc2..fd52ec657f141ab94b9aec6f7674d234c4de6adc:/contrib/src/ogl/basic.cpp diff --git a/contrib/src/ogl/basic.cpp b/contrib/src/ogl/basic.cpp index f5bdab84e5..63bbc4dfee 100644 --- a/contrib/src/ogl/basic.cpp +++ b/contrib/src/ogl/basic.cpp @@ -30,12 +30,6 @@ #undef new #endif -#if wxUSE_IOSTREAMH -#include -#else -#include -#endif - #include #include #include @@ -286,9 +280,8 @@ wxShape::wxShape(wxShapeCanvas *can) m_brush = wxWHITE_BRUSH; m_font = g_oglNormalFont; m_textColour = wxBLACK; - m_textColourName = "BLACK"; + m_textColourName = wxT("BLACK"); m_visible = FALSE; - m_clientData = NULL; m_selected = FALSE; m_attachmentMode = ATTACHMENT_MODE_NONE; m_spaceAttachments = TRUE; @@ -306,7 +299,7 @@ wxShape::wxShape(wxShapeCanvas *can) m_shadowBrush = wxBLACK_BRUSH; m_textMarginX = 5; m_textMarginY = 5; - m_regionName = "0"; + m_regionName = wxT("0"); m_centreResize = TRUE; m_maintainAspectRatio = FALSE; m_highlighted = FALSE; @@ -320,10 +313,10 @@ wxShape::wxShape(wxShapeCanvas *can) // the region eventually (the duplication is for compatibility) wxShapeRegion *region = new wxShapeRegion; m_regions.Append(region); - region->SetName("0"); + region->SetName(wxT("0")); region->SetFont(g_oglNormalFont); region->SetFormatMode(FORMAT_CENTRE_HORIZ | FORMAT_CENTRE_VERT); - region->SetColour("BLACK"); + region->SetColour(wxT("BLACK")); } wxShape::~wxShape() @@ -338,11 +331,6 @@ wxShape::~wxShape() if (m_canvas) m_canvas->RemoveShape(this); - if (m_clientData) { - delete m_clientData; - m_clientData = NULL; - } - GetEventHandler()->OnDelete(); } @@ -613,7 +601,8 @@ void wxShape::FormatText(wxDC& dc, const wxString& s, int i) return; wxShapeRegion *region = (wxShapeRegion *)node->Data(); - region->SetText(s); + // region->SetText(s); // don't set the formatted text yet, it will be done below + region->m_regionText = s; dc.SetFont(* region->GetFont()); region->GetSize(&w, &h); @@ -622,7 +611,7 @@ void wxShape::FormatText(wxDC& dc, const wxString& s, int i) node = stringList->First(); while (node) { - char *s = (char *)node->Data(); + wxChar *s = (wxChar *)node->Data(); wxShapeTextLine *line = new wxShapeTextLine(0.0, 0.0, s); region->GetFormattedText().Append((wxObject *)line); node = node->Next(); @@ -782,7 +771,7 @@ wxString wxShape::GetTextColour(int regionId) const { wxNode *node = m_regions.Nth(regionId); if (!node) - return wxString(""); + return wxEmptyString; wxShapeRegion *region = (wxShapeRegion *)node->Data(); return region->GetColour(); } @@ -800,7 +789,7 @@ wxString wxShape::GetRegionName(int regionId) { wxNode *node = m_regions.Nth(regionId); if (!node) - return wxString(""); + return wxEmptyString; wxShapeRegion *region = (wxShapeRegion *)node->Data(); return region->GetName(); } @@ -824,25 +813,26 @@ int wxShape::GetRegionId(const wxString& name) 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 << wxT(".") << 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 << wxT(".") << j; else - sprintf(buf, "%d", j); - child->NameRegions(buf); + buff << j; + child->NameRegions(buff); node = node->Next(); j ++; } @@ -878,7 +868,7 @@ void wxShape::FindRegionNames(wxStringList& list) for (int i = 0; i < n; i++) { wxString name(GetRegionName(i)); - list.Add((const char*) name); + list.Add(name); } wxNode *node = m_children.First(); @@ -997,8 +987,9 @@ void wxShape::OnEraseContents(wxDC& dc) if (m_pen) penWidth = m_pen->GetWidth(); - dc.SetPen(* g_oglWhiteBackgroundPen); - dc.SetBrush(* g_oglWhiteBackgroundBrush); + dc.SetPen(GetBackgroundPen()); + dc.SetBrush(GetBackgroundBrush()); + dc.DrawRectangle(WXROUND(topLeftX - penWidth), WXROUND(topLeftY - penWidth), WXROUND(maxX + penWidth*2.0 + 4.0), WXROUND(maxY + penWidth*2.0 + 4.0)); } @@ -1701,7 +1692,7 @@ void wxShape::RemoveLine(wxLineShape *line) m_lines.DeleteObject(line); } -#ifdef PROLOGIO +#if wxUSE_PROLOGIO void wxShape::WriteAttributes(wxExpr *clause) { clause->AddAttributeValueString("type", GetClassInfo()->GetClassName()); @@ -1936,7 +1927,7 @@ void wxShape::ReadAttributes(wxExpr *clause) } } 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; @@ -2231,7 +2222,7 @@ void wxShape::ReadRegions(wxExpr *clause) 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; @@ -2997,7 +2988,7 @@ bool wxShape::GetBranchingAttachmentInfo(int attachment, wxRealPoint& root, wxRe } default: { - wxFAIL_MSG( "Unrecognised attachment point in GetBranchingAttachmentInfo." ); + wxFAIL_MSG( wxT("Unrecognised attachment point in GetBranchingAttachmentInfo.") ); break; } } @@ -3056,7 +3047,7 @@ bool wxShape::GetBranchingAttachmentPoint(int attachment, int n, wxRealPoint& pt } default: { - wxFAIL_MSG( "Unrecognised attachment point in GetBranchingAttachmentPoint." ); + wxFAIL_MSG( wxT("Unrecognised attachment point in GetBranchingAttachmentPoint.") ); break; } } @@ -3121,7 +3112,7 @@ wxRealPoint wxShape::GetBranchingAttachmentRoot(int attachment) } default: { - wxFAIL_MSG( "Unrecognised attachment point in GetBranchingAttachmentRoot." ); + wxFAIL_MSG( wxT("Unrecognised attachment point in GetBranchingAttachmentRoot.") ); break; } } @@ -3281,3 +3272,25 @@ void wxShape::Rotate(double WXUNUSED(x), double WXUNUSED(y), double theta) } } + +wxPen wxShape::GetBackgroundPen() +{ + if (GetCanvas()) + { + wxColour c = GetCanvas()->GetBackgroundColour(); + return wxPen(c, 1, wxSOLID); + } + return * g_oglWhiteBackgroundPen; +} + + +wxBrush wxShape::GetBackgroundBrush() +{ + if (GetCanvas()) + { + wxColour c = GetCanvas()->GetBackgroundColour(); + return wxBrush(c, wxSOLID); + } + return * g_oglWhiteBackgroundBrush; +} +