void TToolTip::OnGetTooltipText(LPNMTTDISPINFO pTTDispInfo) { TFlagInfo * pFlags = (TFlagInfo *)pTTDispInfo->lParam; LPTSTR szTextBuffEnd = szToolTipText + cchTooltipText; LPTSTR szTextBuff = szToolTipText; TCHAR szWindowText[0x80]; DWORD dwValue32 = 0; HWND hWndChild = (HWND)pTTDispInfo->hdr.idFrom; // Only if the text buffer has been allocated if(pFlags != NULL && szTextBuff != NULL) { // Reset the tooltip info to an empty string szToolTipText[0] = 0; // Retrieve the window text and convert it to 32-bit hexa value GetWindowText(hWndChild, szWindowText, _maxchars(szWindowText)); if(Text2Hex32(szWindowText, &dwValue32) == ERROR_SUCCESS) { // Supply the flags while(dwValue32 != 0 && pFlags->szFlagText != NULL) { // Is that flag set? if(IS_FLAG_SET(pFlags, dwValue32)) { size_t nLength = _tcslen(pFlags->szFlagText); // Is there enough space left? if((size_t)(szTextBuffEnd - szTextBuff) < (nLength + 0x20)) break; // If there is a flag from the previous pass, append newline to it if(szTextBuff > szToolTipText) szTextBuff = AddNewLine(szTextBuff, (szTextBuffEnd - szTextBuff)); // Append the flag text memcpy(szTextBuff, pFlags->szFlagText, (nLength + 1) * sizeof(TCHAR)); szTextBuff += nLength; // Clear the bit from the dwValue32 &= ~pFlags->dwValue; } // Move to the next flag pFlags++; } // If there is no text or there are unknown flags left, put them as hexa value if(szTextBuff == szToolTipText || dwValue32 != 0) { // If there is a flag from the previous pass, append newline to it if(szTextBuff > szToolTipText) szTextBuff = AddNewLine(szTextBuff, (szTextBuffEnd - szTextBuff)); StringCchPrintf(szTextBuff, (szTextBuffEnd - szTextBuff), _T("0x%08X"), dwValue32); } // Supply the text to the tooltip pTTDispInfo->lpszText = szToolTipText; pTTDispInfo->szText[0] = 0; } else { StringCchPrintf(pTTDispInfo->szText, _countof(pTTDispInfo->szText), _T("Error converting \"%s\" to 32-bit integer"), szWindowText); } } }
bool FileXML::Load(const wxString& fileName, unsigned int itemsInLine) { // Make sure file exists if (fileName.IsEmpty() || !wxFileName::FileExists(fileName)) { mmErrorDialogs::InvalidFile(pParentWindow_); return false; } // Open file wxXmlDocument xmlFile; if (!xmlFile.Load(fileName, encoding_)) { mmErrorDialogs::MessageError(pParentWindow_ , _("File is not in Excel XML Spreadsheet 2003 format."), _("Parsing error")); return false; } // Workbook wxXmlNode *workbookElement = xmlFile.GetRoot(); if (workbookElement->GetName().Cmp("Workbook") != 0 || workbookElement->GetAttribute("xmlns").Cmp("urn:schemas-microsoft-com:office:spreadsheet") != 0) { mmErrorDialogs::MessageError(pParentWindow_, _("File is not in Excel XML Spreadsheet 2003 format."), _("Parsing error")); return false; } // Worksheet // TODO: Allow the user to choose the worksheet. This just uses the first. wxXmlNode *worksheetElement = workbookElement->GetChildren(); for (; worksheetElement && worksheetElement->GetName() != "Worksheet"; worksheetElement = worksheetElement->GetNext()) { }; if (!worksheetElement) { mmErrorDialogs::MessageError(pParentWindow_, _("Could not find Worksheet."), _("Parsing error")); return false; } // Table wxXmlNode *tableElement = worksheetElement->GetChildren(); if (tableElement->GetName() != _("Table")) { mmErrorDialogs::MessageError(pParentWindow_, _("Could not find Table."), _("Parsing error")); return false; } // Rows for (wxXmlNode *rowElement = tableElement->GetChildren(); rowElement; rowElement = rowElement->GetNext()) { if (rowElement->GetName() != "Row") continue; AddNewLine(); // Cells in row for (wxXmlNode *cellElement = rowElement->GetChildren(); cellElement; cellElement = cellElement->GetNext()) { if (cellElement->GetName() != "Cell") continue; if (itemsTable_.back().size() >= itemsInLine) break; wxXmlNode *dataElement = cellElement->GetChildren(); wxString content = dataElement? dataElement->GetNodeContent(): ""; AddNewItem(content); } } return true; }
//------------------------------------------------------------------------------ void Sketcher_CommandTrim::TrimCurve() { mySObject = Handle(Sketcher_Object)::DownCast(data->Value(NearestCurveIndex)); newTrimmedObj = mySObject->GetAIS_Object(); switch (TypeofObject) { case PointSketcherObject: break; case LineSketcherObject: if (mySeqOfPntU.Length() <= 2) DelTrimmedObject(); else { FindSegment(); if (FirstU == mySeqOfPntU.First()) EditLine(SecondU,mySeqOfPntU.Last()); else if (SecondU == mySeqOfPntU.Last()) EditLine(mySeqOfPntU.First(),FirstU); else AddNewLine(SecondU,mySeqOfPntU.Last()); } break; case CircleSketcherObject: if (mySeqOfPntU.Length() <= 1) DelTrimmedObject(); else { if ((mySeqOfPntU.First() + 2*M_PI) != mySeqOfPntU.Last()) mySeqOfPntU.Append(mySeqOfPntU.First() + 2*M_PI); if (mySeqOfPntU(1) > NearestPntU) { FirstU = mySeqOfPntU(mySeqOfPntU.Length()-1); SecondU = mySeqOfPntU.Last(); } else FindSegment(); EditCircle(); } break; case ArcSketcherObject: if (mySeqOfPntU.Length() <= 2) DelTrimmedObject(); else { if (NearestPntU < FirstU) NearestPntU += 2*M_PI; FindSegment(); if (FirstU == mySeqOfPntU.First()) EditArc(SecondU,mySeqOfPntU.Last()); else if (SecondU == mySeqOfPntU.Last()) EditArc(mySeqOfPntU.First(),FirstU); else AddNewArc(SecondU,mySeqOfPntU.Last()); } break; default: break; } }