void View::DrawLyricString ( DeviceContext *dc, int x, int y, std::wstring s, int staffSize) { assert( dc ); dc->StartText( ToDeviceContextX( x ), ToDeviceContextY( y ) ); std::wistringstream iss( s ); std::wstring token; while( std::getline( iss, token, L'_' )) { dc->DrawText( UTF16to8( token.c_str() ), token ); // no _ if (iss.eof()) break; FontInfo vrvTxt; vrvTxt.SetFaceName("VerovioText"); vrvTxt.SetPointSize( m_doc->GetDrawingLyricFont(staffSize)->GetPointSize() ); dc->SetFont( &vrvTxt ); dc->VrvTextFont(); std::wstring str; str.push_back(VRV_TEXT_E551); dc->DrawText( UTF16to8( str.c_str() ), str ); dc->ResetFont(); } //std::wcout << std::endl; dc->EndText( ); }
void View::DrawHarmString(DeviceContext *dc, int x, int y, std::wstring s) { assert(dc); std::size_t prev_pos = 0, pos; while ((pos = s.find_first_of(L"\u266D\u266E\u266F", prev_pos)) != std::wstring::npos) { // If pos is > than the previous, it is the substring to extract if (pos > prev_pos) { std::wstring substr = s.substr(prev_pos, pos - prev_pos); dc->DrawText(UTF16to8(substr), substr); } // if it is the same or we still have space, it is the accidental if (pos == prev_pos || pos < s.length()) { // Then the accidental std::wstring accid = s.substr(pos, 1); std::wstring smufl_accid; if (accid == L"\u266D") { // MUSIC FLAT SIGN smufl_accid.push_back(SMUFL_E260_accidentalFlat); } else if (accid == L"\u266E") { // MUSIC NATURAL SIGN smufl_accid.push_back(SMUFL_E261_accidentalNatural); } else if (accid == L"\u266F") { // MUSIC SHARP SIGN smufl_accid.push_back(SMUFL_E262_accidentalSharp); } else { smufl_accid.push_back(0xE26D); } FontInfo vrvTxt; vrvTxt.SetFaceName("VerovioText"); dc->SetFont(&vrvTxt); dc->DrawText(UTF16to8(smufl_accid), smufl_accid); dc->ResetFont(); } // Skip the accidental and continue prev_pos = pos + 1; } // Print the remainder of the string, or the full string if no accid if (prev_pos < s.length()) { std::wstring substr = s.substr(prev_pos, std::wstring::npos); dc->DrawText(UTF16to8(substr), substr); } }
/** Returns the path of the current working directory */ std::string Path_GetWorkingDirectory() { std::string sPath; #if defined( _WIN32 ) wchar_t buf[MAX_UNICODE_PATH]; sPath = UTF16to8(_wgetcwd(buf, MAX_UNICODE_PATH)); #else char buf[1024]; sPath = getcwd(buf, sizeof(buf)); #endif return sPath; }
/** Gets the path to a temporary directory. */ std::string Path_GetTemporaryDirectory() { #if defined( _WIN32 ) wchar_t buf[MAX_UNICODE_PATH]; if (GetTempPathW(MAX_UNICODE_PATH, buf) == 0) return Path_GetWorkingDirectory(); return UTF16to8(buf); #else const char* pchTmpDir = getenv("TMPDIR"); if (pchTmpDir == NULL) { return ""; } return pchTmpDir; #endif }
void View::DrawText(DeviceContext *dc, Text *text, int x, int y, bool &setX, bool &setY) { assert(dc); assert(text); // special case where we want to replace the '_' with a lyric connector // '_' are produce with the SibMEI plugin if (text->GetFirstParent(SYL)) { DrawLyricString(dc, x, y, text->GetText()); } else if (text->GetFirstParent(HARM)) { DrawHarmString(dc, x, y, text->GetText()); } else { dc->DrawText(UTF16to8(text->GetText()), text->GetText()); } }
const CString GetText() const { return UTF16to8(m_Text); }