void SetStatusUrl(void) { /* display the current url being processed */ if(gbUrlChanged) { char szUrlPathBuf[MAX_BUF]; char szToPathBuf[MAX_BUF]; HWND hStatusUrl = NULL; HWND hStatusTo = NULL; hStatusUrl = GetDlgItem(dlgInfo.hWndDlg, IDC_STATUS_URL); if(hStatusUrl) TruncateString(hStatusUrl, gszUrl, szUrlPathBuf, sizeof(szUrlPathBuf)); else lstrcpy(szUrlPathBuf, gszUrl); hStatusTo = GetDlgItem(dlgInfo.hWndDlg, IDC_STATUS_TO); if(hStatusTo) TruncateString(hStatusTo, gszTo, szToPathBuf, sizeof(szToPathBuf)); else lstrcpy(szToPathBuf, gszTo); SetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS_URL, szUrlPathBuf); SetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS_TO, szToPathBuf); SetStatusFile(); gbUrlChanged = FALSE; } }
void CLabelListCtrl::OnUpdateLabelSyncClient(CCmdUI* pCmdUI) { CString sel = TruncateString(GetSelectedItemText(), 50); CString txt; txt.FormatMessage(IDS_SYNC_CLIENT_s_TO_LABEL_s, TruncateString(GET_P4REGPTR()->GetP4Client(), 50), sel); pCmdUI->SetText ( txt ); pCmdUI->Enable(!SERVER_BUSY() && !sel.IsEmpty() && !MainFrame()->IsModlessUp()); }
void CClientListCtrl::OnUpdateClientTemplate(CCmdUI* pCmdUI) { m_Active = GetSelectedItemText(); CString sCurrentClient = GET_P4REGPTR()->GetP4Client(); CString prompt; prompt.FormatMessage(IDS_CREATE_UPDATE_CLIENT_USING_s_AS_TEMPLATE, m_Active.IsEmpty( ) ? TruncateString(sCurrentClient, 50) : TruncateString(m_Active, 50)); pCmdUI->SetText ( prompt ); pCmdUI->Enable( !SERVER_BUSY() && !m_EditInProgress && !m_Active.IsEmpty() && !MainFrame()->IsModlessUp() ); }
/*! \param name[] 子网格的名称 * \param numAnimFrames 动画帧数 */ void CSMSubMesh::GenHeaderInfo( char name[], int numAnimFrames ) { memset( &subMeshHeader, 0, sizeof( subMeshHeader ) ); strcpy( subMeshHeader.name, TruncateString( name ) ); subMeshHeader.numAnimFrames = numAnimFrames; subMeshHeader.numVertices = static_cast< int >( vVertexData.size() ); int numSkinData; if ( numAnimFrames > 1 ) { numSkinData = static_cast< int >( vVertexData.size() ); } else { numSkinData = 0; } subMeshHeader.numFaces = static_cast< int >( vTriangleData.size() ); subMeshHeader.nHeaderSize = sizeof( CSMSubMeshHeader ); subMeshHeader.nOffVertices = subMeshHeader.nHeaderSize + MAX_STRING_LENGTH; subMeshHeader.nOffSkin = subMeshHeader.nOffVertices + sizeof( CSMVertexData ) * subMeshHeader.numVertices; subMeshHeader.nOffFaces = subMeshHeader.nOffSkin + sizeof( CSMSkinData ) * numSkinData; subMeshHeader.nOffEnd = subMeshHeader.nOffFaces + sizeof( CSMTriangleData ) * subMeshHeader.numFaces; }
void XmlReaderSaturationElt::end() { Trim(m_contentData); std::vector<double> data; try { data = GetNumbers<double>(m_contentData.c_str(), m_contentData.size()); } catch (Exception& /* ce */) { const std::string s = TruncateString(m_contentData.c_str(), m_contentData.size()); std::ostringstream oss; oss << "Illegal values '" << s << "' in " << getTypeName(); throwMessage(oss.str()); } if (data.size() != 1) { throwMessage("SatNode: non-single value. "); } XmlReaderSatNodeBaseElt* pSatNodeElt = dynamic_cast<XmlReaderSatNodeBaseElt*>(getParent().get()); CDLOpDataRcPtr pCDL = pSatNodeElt->getCDL(); if (0 == strcmp(getName().c_str(), TAG_SATURATION)) { pCDL->setSaturation(data[0]); } }
void Draw(BRect updateRect) { const float kSpacing = 20.0; const float kTopOffset = kSpacing + 5; const uint32 kTruncateModes[] = { B_TRUNCATE_BEGINNING, B_TRUNCATE_MIDDLE, B_TRUNCATE_END }; const uint32 kTruncateModeCount = sizeof(kTruncateModes) / sizeof(kTruncateModes[0]); BString theString("ö&ä|ü-é#"); BPoint point(10, kTopOffset); BString truncated; for (float length = 5; length < 65; length += 3) { SetHighColor(255, 0, 0); StrokeRect(BRect(point.x, point.y - kSpacing, point.x + length, point.y + kSpacing * kTruncateModeCount)); SetHighColor(0, 0, 0); for (uint32 i = 0; i < kTruncateModeCount; i++) { truncated = theString; TruncateString(&truncated, kTruncateModes[i], length); DrawString(truncated.String(), point); point.y += kSpacing; } point.x += length + kSpacing; point.y = kTopOffset; } }
void CLabelListCtrl::OnUpdateLabelListfiles(CCmdUI* pCmdUI) { CString selUser = TruncateString(GetSelectedItemText(), 50); CString txt; txt.FormatMessage(IDS_LIST_FILES_AT_s, selUser); pCmdUI->SetText ( txt ); pCmdUI->Enable(!SERVER_BUSY() && !selUser.IsEmpty()); }
void CUserListCtrl::OnUpdateUserPassword(CCmdUI* pCmdUI, LPCTSTR userName) { CString txt; txt.FormatMessage(IDS_SET_PASSWORD_FOR_s, TruncateString(userName, 50)); pCmdUI->SetText ( txt ); pCmdUI->Enable( !SERVER_BUSY() && GET_SERVERLEVEL() >= 6 && lstrlen(userName) && !MainFrame()->IsModlessUp()); }
void CLabelListCtrl::OnUpdateLabelDeletefiles(CCmdUI* pCmdUI) { CString selUser = TruncateString(GetSelectedItemText(), 50); CString txt; txt.FormatMessage(IDS_DELETE_FILES_AT_s, selUser); pCmdUI->SetText ( txt ); pCmdUI->Enable(!SERVER_BUSY() && !selUser.IsEmpty() && !SelectedItemIsLocked(LABEL_OPTIONS) && !MainFrame()->IsModlessUp()); }
void CLabelListCtrl::OnUpdateLabelSync(CCmdUI* pCmdUI) { CString sel = TruncateString(GetSelectedItemText(), 50); CString txt; txt.FormatMessage(IDS_ADD_REPLACE_FILES_IN_LABEL_s, sel); pCmdUI->SetText ( txt ); pCmdUI->Enable(!SERVER_BUSY() && !sel.IsEmpty() && !SelectedItemIsLocked(LABEL_OPTIONS) && !MainFrame()->IsModlessUp()); }
void CUserListCtrl::OnUpdateSetDefUser(CCmdUI* pCmdUI) { CString selUser = GetSelectedItemText(); pCmdUI->SetText ( LoadStringResource(IDS_SET_DEFAULT_USER_TO) + TruncateString(selUser, 50) ); pCmdUI->Enable( !SERVER_BUSY() && !selUser.IsEmpty() && selUser == GET_P4REGPTR()->GetP4User( FALSE ) && selUser != GET_P4REGPTR()->GetP4User( TRUE ) && !MainFrame()->IsModlessUp() ); }
void CLabelListCtrl::OnUpdateAddToLabelView(CCmdUI* pCmdUI) { CString sel = TruncateString(GetSelectedItemText(), 50); CString txt; txt.FormatMessage(IDS_ADDTOLABELVIEW_s, sel); pCmdUI->SetText ( txt ); pCmdUI->Enable(!SERVER_BUSY() && !sel.IsEmpty() && !m_EditInProgress && !SelectedItemIsLocked(LABEL_OPTIONS)); }
void CUserListCtrl::OnUpdateUserSwitchtouser(CCmdUI* pCmdUI) { CString selUser = GetSelectedItemText(); CString prompt; prompt.FormatMessage(IDS_SWITCH_TO_s, TruncateString(selUser, 50)); pCmdUI->SetText ( prompt ); pCmdUI->Enable( !SERVER_BUSY() && !selUser.IsEmpty() && selUser != GET_P4REGPTR()->GetP4User( ) && !MainFrame()->IsModlessUp() ); }
void CClientListCtrl::OnUpdateClientspecSwitch(CCmdUI* pCmdUI) { CString selClient = GetSelectedItemText(); CString prompt; prompt.FormatMessage(IDS_SWITCH_TO_s, TruncateString(selClient, 50)); pCmdUI->SetText ( prompt ); pCmdUI->Enable( !SERVER_BUSY() && !selClient.IsEmpty() && selClient != GET_P4REGPTR()->GetP4Client( ) && !MainFrame()->IsModlessUp()); }
void CLabelListCtrl::OnUpdateLabelTemplate(CCmdUI* pCmdUI) { m_Active = GetSelectedItemText(); CString prompt; prompt.FormatMessage(IDS_CREATE_UPDATE_LABEL_USING_s_AS_TEMPLATE, TruncateString(m_Active, 50)); pCmdUI->SetText ( prompt ); pCmdUI->Enable( GET_SERVERLEVEL() >= 6 && !SERVER_BUSY() && !m_Active.IsEmpty() && !m_EditInProgress ); }
void cbXPIProgress(const char* msg, PRInt32 val, PRInt32 max) { char szBuf[MAX_BUF]; if(sgProduct.ulMode != SILENT) { TruncateString(WinWindowFromID(dlgInfo.hWndDlg, IDC_STATUS3), msg, szBuf, sizeof(szBuf)); WinSetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS3, szBuf); } ProcessWindowsMessages(); }
void CClientListCtrl::OnUpdateSetDefClient(CCmdUI* pCmdUI) { CString selClient = GetSelectedItemText(); CString prompt; prompt.FormatMessage(IDS_SETDEFCLIENT_s, TruncateString(selClient, 50)); pCmdUI->SetText ( prompt ); pCmdUI->Enable( !SERVER_BUSY() && !selClient.IsEmpty() && selClient == GET_P4REGPTR()->GetP4Client( FALSE ) && selClient != GET_P4REGPTR()->GetP4Client( TRUE ) && !MainFrame()->IsModlessUp() ); }
void ClipView::FrameResized(float width, float height) { BListView::FrameResized(width, height); static const float spacing = be_control_look->DefaultLabelSpacing(); for (int32 i = 0; i < CountItems(); i++) { ClipItem *sItem = dynamic_cast<ClipItem *> (ItemAt(i)); BString string(sItem->GetClip()); TruncateString(&string, B_TRUNCATE_END, width - kIconSize - spacing * 4); sItem->SetTitle(string); } }
void XmlReaderSOPValueElt::end() { Trim(m_contentData); std::vector<double> data; try { data = GetNumbers<double>(m_contentData.c_str(), m_contentData.size()); } catch (Exception&) { const std::string s = TruncateString(m_contentData.c_str(), m_contentData.size()); std::ostringstream oss; oss << "Illegal values '" << s << "' in " << getTypeName(); throwMessage(oss.str()); } if (data.size() != 3) { throwMessage("SOPNode: 3 values required."); } XmlReaderSOPNodeBaseElt* pSOPNodeElt = dynamic_cast<XmlReaderSOPNodeBaseElt*>(getParent().get()); CDLOpDataRcPtr pCDL = pSOPNodeElt->getCDL(); if (0 == strcmp(getName().c_str(), TAG_SLOPE)) { pCDL->setSlopeParams(CDLOpData::ChannelParams(data[0], data[1], data[2])); pSOPNodeElt->setIsSlopeInit(true); } else if (0 == strcmp(getName().c_str(), TAG_OFFSET)) { pCDL->setOffsetParams(CDLOpData::ChannelParams(data[0], data[1], data[2])); pSOPNodeElt->setIsOffsetInit(true); } else if (0 == strcmp(getName().c_str(), TAG_POWER)) { pCDL->setPowerParams(CDLOpData::ChannelParams(data[0], data[1], data[2])); pSOPNodeElt->setIsPowerInit(true); } }
void BStringView::Draw(BRect updateRect) { if (!fText) return; SetLowColor(ViewColor()); font_height fontHeight; GetFontHeight(&fontHeight); BRect bounds = Bounds(); const char* text = fText; float width = fPreferredSize.width; BString truncated; if (fTruncation != B_NO_TRUNCATION && width > bounds.Width()) { // The string needs to be truncated // TODO: we should cache this truncated = fText; TruncateString(&truncated, fTruncation, bounds.Width()); text = truncated.String(); width = StringWidth(text); } float y = (bounds.top + bounds.bottom - ceilf(fontHeight.ascent) - ceilf(fontHeight.descent)) / 2.0 + ceilf(fontHeight.ascent); float x; switch (fAlign) { case B_ALIGN_RIGHT: x = bounds.Width() - width; break; case B_ALIGN_CENTER: x = (bounds.Width() - width) / 2.0; break; default: x = 0.0; break; } DrawString(text, BPoint(x, y)); }
/*! \param n[] 子网格名称 * \param nAF 动画帧数 * \param nV 顶点数 * \param nF 面数 */ CSMSubMeshHeader::CSMSubMeshHeader( char n[], int nAF, int nV, int nF ) : numAnimFrames( nAF ), numVertices( nV ), numFaces( nF ) { strcpy( name, TruncateString( n ) ); int numSkinData; if ( nAF > 1 ) { numSkinData = numVertices; } else { numSkinData = 0; } nHeaderSize = sizeof( CSMSubMeshHeader ); nOffVertices = nHeaderSize + MAX_STRING_LENGTH; nOffSkin = nOffVertices + sizeof( CSMVertexData ) * numVertices; nOffFaces = nOffSkin + sizeof( CSMSkinData ) * numSkinData; nOffEnd = nOffFaces + sizeof( CSMTriangleData ) * numFaces; }
void NotificationView::Draw(BRect updateRect) { BRect progRect; SetDrawingMode(B_OP_ALPHA); SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); // Icon size float iconSize = (float)fParent->IconSize(); BRect stripeRect = Bounds(); stripeRect.right = kIconStripeWidth; SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); FillRect(stripeRect); SetHighColor(fStripeColor); stripeRect.right = 2; FillRect(stripeRect); SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); // Rectangle for icon and overlay icon BRect iconRect(0, 0, 0, 0); // Draw icon if (fBitmap) { float ix = 18; float iy = (Bounds().Height() - iconSize) / 4.0; // Icon is vertically centered in view if (fNotification->Type() == B_PROGRESS_NOTIFICATION) { // Move icon up by half progress bar height if it's present iy -= (progRect.Height() + kEdgePadding); } iconRect.Set(ix, iy, ix + iconSize - 1.0, iy + iconSize - 1.0); DrawBitmapAsync(fBitmap, fBitmap->Bounds(), iconRect); } // Draw content LineInfoList::iterator lIt; for (lIt = fLines.begin(); lIt != fLines.end(); lIt++) { LineInfo *l = (*lIt); SetFont(&l->font); // Truncate the string. We have already line-wrapped the text but if // there is a very long 'word' we can only truncate it. TruncateString(&(l->text), B_TRUNCATE_END, Bounds().Width() - l->location.x); DrawString(l->text.String(), l->text.Length(), l->location); } rgb_color detailCol = ui_color(B_CONTROL_BORDER_COLOR); detailCol = tint_color(detailCol, B_LIGHTEN_2_TINT); AppGroupView* groupView = dynamic_cast<AppGroupView*>(Parent()); if (groupView != NULL && groupView->ChildrenCount() > 1) _DrawCloseButton(updateRect); SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT)); BPoint left(Bounds().left, Bounds().top); BPoint right(Bounds().right, Bounds().top); StrokeLine(left, right); Sync(); }
void ActivityView::Draw(BRect updateRect) { bool drawBackground = true; if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) drawBackground = false; _DrawHistory(drawBackground); if (!fShowLegend) return; // draw legend BRect legendFrame = _LegendFrame(); if (LowUIColor() == B_NO_COLOR) SetLowColor(fLegendBackgroundColor); if (drawBackground) { BRect backgroundFrame(legendFrame); backgroundFrame.bottom += kDraggerSize; FillRect(backgroundFrame, B_SOLID_LOW); } BAutolock _(fSourcesLock); font_height fontHeight; GetFontHeight(&fontHeight); for (int32 i = 0; i < fSources.CountItems(); i++) { DataSource* source = fSources.ItemAt(i); DataHistory* values = fValues.ItemAt(i); BRect frame = _LegendFrameAt(legendFrame, i); // draw color box BRect colorBox = _LegendColorFrameAt(legendFrame, i); BRect rect = colorBox; uint32 flags = BControlLook::B_BLEND_FRAME; be_control_look->DrawTextControlBorder(this, rect, rect, fLegendBackgroundColor, flags); SetHighColor(source->Color()); FillRect(rect); // show current value and label float y = frame.top + ceilf(fontHeight.ascent); int64 value = values->ValueAt(values->End()); BString text; source->Print(text, value); float width = StringWidth(text.String()); BString label = source->Label(); float possibleLabelWidth = frame.right - colorBox.right - 12 - width; // TODO: TruncateString() is broken... remove + 5 when fixed! if (ceilf(StringWidth(label.String()) + 5) > possibleLabelWidth) label = source->ShortLabel(); TruncateString(&label, B_TRUNCATE_MIDDLE, possibleLabelWidth); if (drawBackground) SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); if (be_control_look == NULL) { DrawString(label.String(), BPoint(6 + colorBox.right, y)); DrawString(text.String(), BPoint(frame.right - width, y)); } else { be_control_look->DrawLabel(this, label.String(), Parent()->ViewColor(), 0, BPoint(6 + colorBox.right, y)); be_control_look->DrawLabel(this, text.String(), Parent()->ViewColor(), 0, BPoint(frame.right - width, y)); } } }
void BStatusView::Draw(BRect updateRect) { if (fBitmap) { BPoint location; location.x = (fStatusBar->Frame().left - fBitmap->Bounds().Width()) / 2; location.y = (Bounds().Height()- fBitmap->Bounds().Height()) / 2; DrawBitmap(fBitmap, location); } BRect bounds(Bounds()); be_control_look->DrawRaisedBorder(this, bounds, updateRect, ViewColor()); SetHighColor(0, 0, 0); BPoint tp = fStatusBar->Frame().LeftBottom(); font_height fh; GetFontHeight(&fh); tp.y += ceilf(fh.leading) + ceilf(fh.ascent); if (IsPaused()) { DrawString(B_TRANSLATE("Paused: click to resume or stop"), tp); return; } BFont font; GetFont(&font); float normalFontSize = font.Size(); float smallFontSize = max_c(normalFontSize * 0.8f, 8.0f); float availableSpace = fStatusBar->Frame().Width(); availableSpace -= be_control_look->DefaultLabelSpacing(); // subtract to provide some room between our two strings float destinationStringWidth = 0.f; BString destinationString(_DestinationString(&destinationStringWidth)); availableSpace -= destinationStringWidth; float statusStringWidth = 0.f; BString statusString(_StatusString(availableSpace, smallFontSize, &statusStringWidth)); if (statusStringWidth > availableSpace) { TruncateString(&destinationString, B_TRUNCATE_MIDDLE, availableSpace + destinationStringWidth - statusStringWidth); } BPoint textPoint = fStatusBar->Frame().LeftBottom(); textPoint.y += ceilf(fh.leading) + ceilf(fh.ascent); if (destinationStringWidth > 0) { DrawString(destinationString.String(), textPoint); } SetHighColor(tint_color(LowColor(), B_DARKEN_4_TINT)); font.SetSize(smallFontSize); SetFont(&font, B_FONT_SIZE); textPoint.x = fStatusBar->Frame().right - statusStringWidth; DrawString(statusString.String(), textPoint); font.SetSize(normalFontSize); SetFont(&font, B_FONT_SIZE); }
void ActivityView::Draw(BRect updateRect) { bool drawBackground = true; if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) drawBackground = false; _DrawHistory(drawBackground); if (!fShowLegend) return; // draw legend BRect legendFrame = _LegendFrame(); SetLowColor(fLegendBackgroundColor); if (drawBackground) { BRect backgroundFrame(legendFrame); backgroundFrame.bottom += kDraggerSize; FillRect(backgroundFrame, B_SOLID_LOW); } BAutolock _(fSourcesLock); font_height fontHeight; GetFontHeight(&fontHeight); for (int32 i = 0; i < fSources.CountItems(); i++) { DataSource* source = fSources.ItemAt(i); DataHistory* values = fValues.ItemAt(i); BRect frame = _LegendFrameAt(legendFrame, i); // draw color box BRect colorBox = _LegendColorFrameAt(legendFrame, i); BRect rect = colorBox; uint32 flags = BControlLook::B_BLEND_FRAME; be_control_look->DrawTextControlBorder(this, rect, rect, fLegendBackgroundColor, flags); SetHighColor(source->Color()); FillRect(rect); // show current value and label float y = frame.top + ceilf(fontHeight.ascent); int64 value = values->ValueAt(values->End()); BString text; source->Print(text, value); float width = StringWidth(text.String()); BString label = source->Label(); float possibleLabelWidth = frame.right - colorBox.right - 12 - width; // TODO: TruncateString() is broken... remove + 5 when fixed! if (ceilf(StringWidth(label.String()) + 5) > possibleLabelWidth) label = source->ShortLabel(); TruncateString(&label, B_TRUNCATE_MIDDLE, possibleLabelWidth); if (drawBackground) SetHighColor(ui_color(B_CONTROL_TEXT_COLOR)); else { rgb_color c = Parent()->ViewColor(); rgb_color textColor = c.red + c.green * 1.5f + c.blue * 0.50f >= 300 ? kBlack : kWhite; int32 mask; bool tmpOutline = false; bool outline = fCachedOutline; int8 indice = 0; if (fCachedWorkspace != current_workspace()) { while (fBackgroundInfo.FindInt32("be:bgndimginfoworkspaces", indice, &mask) == B_OK && fBackgroundInfo.FindBool("be:bgndimginfoerasetext", indice, &tmpOutline) == B_OK) { if (((1 << current_workspace()) & mask) != 0) { outline = tmpOutline; fCachedWorkspace = current_workspace(); fCachedOutline = outline; break; } indice++; } } if (outline) { SetDrawingMode(B_OP_ALPHA); SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); BFont font; GetFont(&font); if (textColor == kBlack) { // Black text with white halo/glow rgb_color glowColor = kWhite; font.SetFalseBoldWidth(2.0); SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); glowColor.alpha = 30; SetHighColor(glowColor); DrawString(label.String(), BPoint(6 + colorBox.right, y)); DrawString(text.String(), BPoint(frame.right - width, y)); font.SetFalseBoldWidth(1.0); SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); glowColor.alpha = 65; SetHighColor(glowColor); DrawString(label.String(), BPoint(6 + colorBox.right, y)); DrawString(text.String(), BPoint(frame.right - width, y)); font.SetFalseBoldWidth(0.0); SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); } else { // white text with black outline rgb_color outlineColor = kBlack; font.SetFalseBoldWidth(1.0); SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); outlineColor.alpha = 30; SetHighColor(outlineColor); DrawString(label.String(), BPoint(6 + colorBox.right, y)); DrawString(text.String(), BPoint(frame.right - width, y)); font.SetFalseBoldWidth(0.0); SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); outlineColor.alpha = 200; SetHighColor(outlineColor); DrawString(label.String(), BPoint(6 + colorBox.right + 1, y + 1)); DrawString(text.String(), BPoint(frame.right - width + 1, y + 1)); } } SetDrawingMode(B_OP_OVER); SetHighColor(textColor); } DrawString(label.String(), BPoint(6 + colorBox.right, y)); DrawString(text.String(), BPoint(frame.right - width, y)); } }
void SYLT_Parse(struct ID3Tag *tag) { unsigned char frameheader[10]={0}; //This is the ID3 frame header unsigned char syltheader[6]={0}; //This is the SYLT frame header, excluding the terminated descriptor string that follows char *contentdescriptor=NULL; //The null terminated string located after the SYLT frame header char timestampformat=0; //Will be set based on the SYLT header (1= MPEG Frames, 2=Milliseconds) char *string=NULL; //Used to store SYLT strings that are read char *string2=NULL; //Used to build a display version of the string for debug output (minus newline) unsigned char timestamparray[4]={0};//Used to store the timestamp for a lyric string unsigned long timestamp=0; //The timestamp converted to milliseconds unsigned long breakpos; //Will be set to the first byte beyond the SYLT frame unsigned long framesize=0; char groupswithnext=0; //Used for grouping logic char linebreaks=0; //Tracks whether the imported lyrics defined linebreaks (if not, each ID3 lyric should be treated as one line) struct Lyric_Piece *ptr=NULL,*ptr2=NULL; //Used to insert line breaks as necessary struct Lyric_Line *lineptr=NULL; //Used to insert line breaks as necessary unsigned long length=0; //Used to store the length of each string that is read from file unsigned long filepos=0; //Used to track the current file position during SYLT lyric parsing //Validate input assert_wrapper((tag != NULL) && (tag->fp != NULL)); breakpos=ftell_err(tag->fp); //Load and validate ID3 frame header and SYLT frame header fread_err(frameheader,10,1,tag->fp); //Load ID3 frame header fread_err(syltheader,6,1,tag->fp); //Load SYLT frame header if((frameheader[9] & 192) != 0) { (void) puts("ID3 Compression and Encryption are not supported\nAborting"); exit_wrapper(3); } if(syltheader[0] != 0) { (void) puts("Unicode ID3 lyrics are not supported\nAborting"); exit_wrapper(4); } //Load and validate content descriptor string contentdescriptor=ReadString(tag->fp,NULL,0); //Load content descriptor string if(contentdescriptor == NULL) //If the content descriptor string couldn't be read { (void) puts("Damaged Content Descriptor String\nAborting"); exit_wrapper(1); } //Validate timestamp format timestampformat=syltheader[4]; if((timestampformat != 1) && (timestampformat != 2)) { printf("Warning: Invalid timestamp format (%d) specified, ms timing assumed\n",timestampformat); timestampformat=2; //Assume millisecond timing } //Process framesize as a 4 byte Big Endian integer framesize=((unsigned long)frameheader[4]<<24) | ((unsigned long)frameheader[5]<<16) | ((unsigned long)frameheader[6]<<8) | ((unsigned long)frameheader[7]); //Convert to 4 byte integer if(framesize & 0x80808080) //According to the ID3v2 specification, the MSB of each of the 4 bytes defining the tag size must be zero exit_wrapper(5); //If this isn't the case, the size is invalid assert(framesize < 0x80000000); //Redundant assert() to resolve a false positive with Coverity (this assertion will never be triggered because the above exit_wrapper() call would be triggered first) breakpos=breakpos + framesize + 10; //Find the position that is one byte past the end of the SYLT frame if(Lyrics.verbose>=2) printf("SYLT frame info:\n\tFrame size is %lu bytes\n\tEnds after byte 0x%lX\n\tTimestamp format: %s\n\tLanguage: %c%c%c\n\tContent Type %d\n\tContent Descriptor: \"%s\"\n\n",framesize,breakpos-1,timestampformat == 1 ? "MPEG frames" : "Milliseconds",syltheader[1],syltheader[2],syltheader[3],syltheader[5],contentdescriptor != NULL ? contentdescriptor : "(none)"); if(Lyrics.verbose) (void) puts("Parsing SYLT frame:"); free(contentdescriptor); //Release this, it's not going to be used contentdescriptor=NULL; //Load SYLT lyrics filepos=ftell_err(tag->fp); while(filepos < breakpos) //While we haven't reached the end of the SYLT frame { //Load the lyric text string=ReadString(tag->fp,&length,0); //Load SYLT lyric string, save the string length if(string == NULL) { (void) puts("Invalid SYLT lyric string\nAborting"); exit_wrapper(6); } //Load the timestamp if(fread(timestamparray,4,1,tag->fp) != 1) //Read timestamp { (void) puts("Error reading SYLT timestamp\nAborting"); exit_wrapper(7); } filepos+=length+4; //The number of bytes read from the input file during this iteration is the string length and the timestamp length //Process the timestamp as a 4 byte Big Endian integer timestamp=(unsigned long)((timestamparray[0]<<24) | (timestamparray[1]<<16) | (timestamparray[2]<<8) | timestamparray[3]); if(timestampformat == 1) //If this timestamp is in MPEG frames instead of milliseconds timestamp=((double)timestamp * tag->frameduration + 0.5); //Convert to milliseconds, rounding up //Perform line break logic assert(string != NULL); //(check string for NULL again to satisfy cppcheck) if((string[0] == '\r') || (string[0] == '\n')) //If this lyric begins with a newline or carriage return { EndLyricLine(); //End the lyric line before the lyric is added linebreaks=1; //Track that line break character(s) were found in the lyrics } if(Lyrics.verbose >= 2) { string2=DuplicateString(string); //Make a copy of the string for display purposes string2=TruncateString(string2,1); //Remove leading/trailing whitespace, newline chars, etc. printf("Timestamp: 0x%X%X%X%X\t%lu %s\t\"%s\"\t%s",timestamparray[0],timestamparray[1],timestamparray[2],timestamparray[3],timestamp,(timestampformat == 1) ? "MPEG frames" : "Milliseconds",string2,(string[0]=='\n') ? "(newline)\n" : "\n"); free(string2); string2=NULL; } //Perform grouping logic //Handle whitespace at the beginning of the parsed lyric piece as a signal that the piece will not group with previous piece if(isspace(string[0])) if(Lyrics.curline->pieces != NULL) //If there was a previous lyric piece on this line Lyrics.lastpiece->groupswithnext=0; //Ensure it is set to not group with this lyric piece if(isspace(string[strlen(string)-1])) //If the lyric ends in a space groupswithnext=0; else groupswithnext=1; if(Lyrics.line_on == 0) //Ensure that a line phrase is started CreateLyricLine(); //Add lyric piece, during testing, I'll just write it with a duration of 1ms AddLyricPiece(string,timestamp,timestamp+1,PITCHLESS,groupswithnext); //Write lyric with no defined pitch free(string); //Free string if((Lyrics.lastpiece != NULL) && (Lyrics.lastpiece->prev != NULL) && (Lyrics.lastpiece->prev->groupswithnext)) //If this piece groups with the previous piece Lyrics.lastpiece->prev->duration=Lyrics.lastpiece->start-Lyrics.realoffset-Lyrics.lastpiece->prev->start; //Extend previous piece's length to reach this piece, take the current offset into account }//While we haven't reached the end of the SYLT frame //If the imported lyrics did not contain line breaks, they must be inserted manually if(!linebreaks && Lyrics.piececount) { if(Lyrics.verbose) (void) puts("\nImported ID3 lyrics did not contain line breaks, adding..."); ptr=Lyrics.lines->pieces; lineptr=Lyrics.lines; //Point to first line of lyrics (should be the only line) assert_wrapper((lineptr != NULL) && (ptr != NULL)); //This shouldn't be possible if Lyrics.piececount is nonzero if(lineptr->next != NULL) //If there is another line of lyrics defined return; //abort the insertion of automatic line breaks while((ptr != NULL) && (ptr->next != NULL)) //For each lyric { ptr2=ptr->next; //Store pointer to next lyric lineptr=InsertLyricLineBreak(lineptr,ptr2); //Insert a line break between this lyric and the next, line conductor points to new line ptr=ptr2; //lyric conductor points to the next lyric, which is at the beginning of the new line } } }
void CClientListCtrl::OnContextMenu(CWnd* pWnd, CPoint point) { // make sure window is active // GetParentFrame()->ActivateFrame(); /////////////////////////////// // See ContextMenuRules.txt for order of menu commands! // create an empty context menu // CP4Menu popMenu; popMenu.CreatePopupMenu(); int index; SetIndexAndPoint( index, point ); // Can always create a new client popMenu.AppendMenu( stringsON, ID_CLIENTSPEC_NEW ); // Only offer edit if no other client is selected if ( index == -1 || GetSelectedItemText() == GET_P4REGPTR()->GetP4Client() ) popMenu.AppendMenu( stringsON, ID_CLIENT_EDITMY ); if( index != -1 ) { // Make sure item gets selected SetItemState( index, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED ); popMenu.AppendMenu( stringsON, ID_CLIENT_DESCRIBE ); //or client edit if user is the owner popMenu.AppendMenu( stringsON, ID_CLIENT_DELETE ); popMenu.AppendMenu( MF_SEPARATOR ); // Can only switch to a client if its not my current client if ( GetSelectedItemText() != GET_P4REGPTR()->GetP4Client() ) popMenu.AppendMenu( stringsON, ID_CLIENTSPEC_SWITCH ); else // can only set as default if it is my current client popMenu.AppendMenu( stringsON, ID_SETDEFCLIENT ); popMenu.AppendMenu( stringsON, ID_CLIENT_TEMPLATE ); if (GET_P4REGPTR()->LocalCliTemplateSw()) { popMenu.AppendMenu( MF_SEPARATOR ); popMenu.AppendMenu( stringsON, ID_CLIENT_USEASLOCALTEMPLATE, LoadStringResource(IDS_CLIENT_USEASLOCALTEMPLATE) ); popMenu.AppendMenu( stringsON, ID_CLIENT_CLEARLOCALTEMPLATE, LoadStringResource(IDS_CLIENT_CLEARLOCALTEMPLATE) ); } } popMenu.AppendMenu( MF_SEPARATOR ); popMenu.AppendMenu( stringsON, ID_FILTERCLIENTS, LoadStringResource(IDS_FILTERCLIENTS) ); popMenu.AppendMenu( stringsON, ID_CLEARCLIENTFILTER, LoadStringResource(IDS_CLEARCLIENTFILTER) ); popMenu.AppendMenu( MF_SEPARATOR ); CString txt = GetSelectedItemText(); if (txt.IsEmpty()) txt = GET_P4REGPTR()->GetP4Client( ); txt = LoadStringResource(IDS_CHGS_BY_CLIENT) + txt; txt = TruncateString(txt, 50); popMenu.AppendMenu( stringsON, ID_CHGS_BY_CLIENT, txt ); popMenu.AppendMenu( stringsON, ID_VIEW_UPDATE, LoadStringResource(IDS_REFRESH) ); MainFrame()->AddToolsToContextMenu(&popMenu); // put up the menu // popMenu.TrackPopupMenu( TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, AfxGetMainWnd( ) ); }
void CUserListCtrl::OnUpdateUserPassword(CCmdUI* pCmdUI) { OnUpdateUserPassword( pCmdUI, TruncateString(GET_P4REGPTR()->GetP4User(), 50) ); }