void wxTaskBarButtonImpl::SetThumbnailTooltip(const wxString& tooltip)
{
    m_thumbnailTooltip = tooltip;
    m_taskbarList->SetThumbnailTooltip(m_parent->GetHWND(), tooltip.wc_str());
}
Example #2
0
wxBasicString::wxBasicString(const wxString& str)
{
    m_bstrBuf = SysAllocString(str.wc_str(*wxConvCurrent));
}
void wxTaskBarJumpListImpl::LoadKnownCategory(const wxString& title)
{
    wxCOMPtr<IApplicationDocumentLists> docList;
    HRESULT hr = CoCreateInstance
                 (
                    wxCLSID_ApplicationDocumentLists,
                    NULL,
                    CLSCTX_INPROC_SERVER,
                    wxIID_IApplicationDocumentLists,
                    reinterpret_cast<void **>(&docList)
                 );
    if ( FAILED(hr) )
    {
        wxLogApiError("CoCreateInstance(wxCLSID_ApplicationDocumentLists)", hr);
        return;
    }
    if ( !m_appID.empty() )
        docList->SetAppID(m_appID.wc_str());

    wxCOMPtr<IObjectArray> array;
    wxASSERT_MSG( title == "Recent" || title == "Frequent", "Invalid title." );
    hr = docList->GetList
                 (
                     title == "Recent" ? ADLT_RECENT : ADLT_FREQUENT,
                     0,
                     wxIID_IObjectArray,
                     reinterpret_cast<void **>(&array)
                 );
    if ( FAILED(hr) )
    {
        wxLogApiError("IApplicationDocumentLists::GetList", hr);
        return;
    }

    UINT count = 0;
    array->GetCount(&count);
    for (UINT i = 0; i < count; ++i)
    {
        wxCOMPtr<IUnknown> collectionItem;
        hr = array->GetAt(i, wxIID_IUnknown,
                          reinterpret_cast<void **>(&collectionItem));
        if ( FAILED(hr) )
        {
            wxLogApiError("IObjectArray::GetAt", hr);
            continue;
        }

        wxCOMPtr<IShellLink> shellLink;
        wxCOMPtr<IShellItem> shellItem;
        wxTaskBarJumpListItem* item = NULL;

        if ( SUCCEEDED(collectionItem->QueryInterface(
                 wxIID_IShellLink, reinterpret_cast<void**>(&shellLink))) )
        {
            item = GetItemFromIShellLink(shellLink);
        }
        else if ( SUCCEEDED(collectionItem->QueryInterface(
                      wxIID_IShellItem, reinterpret_cast<void**>(&shellItem))) )
        {
            item = GetItemFromIShellItem(shellItem);
        }
        else
        {
            wxLogError("Can not query interfaces: IShellLink or IShellItem.");
        }

        if ( item )
        {
            if ( title == wxT("Frequent") )
                m_frequent->Append(item);
            else
                m_recent->Append(item);
        }
    }
}
Example #4
0
void pxWindowTextWriter::_DoWriteLn( const wxString msg )
{
	_DoWriteLn(msg.wc_str());
}
Example #5
0
void HTMLFileLogger::Append(const wxString& msg, cb_unused Logger::level lv)
{
    fputs(wxSafeConvertWX2MB(msg.wc_str()), f.fp());
    fputs(::newline_string.mb_str(), f.fp());
}
Example #6
0
int nwxFileUtil::CopyFile(
  const wxString &sFileFrom,
  const wxString &sFileTo,
  bool bOverwrite,
  wxString *psError)
{
  wxFile fin;
  wxFile fout;
  wxULongLong nInputSize;
  wxULongLong nOutputSize(0);
  int nRtn = COPY_OK;
  if(!wxFile::Exists(sFileFrom))
  {
    nRtn = INPUT_FILE_MISSING;
  }
  else if( (nInputSize = wxFileName::GetSize(sFileFrom)) == wxInvalidSize)
  {
    nRtn = INPUT_OPEN_ERROR;
  }
  else if(!fin.Open(sFileFrom.wc_str(),wxFile::read))
  {
    nRtn = INPUT_OPEN_ERROR;
  }
  else if((!bOverwrite) && wxFile::Exists(sFileTo.wc_str()))
  {
    nRtn = OUTPUT_FILE_EXISTS;
  }
  else if(!fout.Create(sFileTo.wc_str(),bOverwrite))
  {
    nRtn = OUTPUT_OPEN_ERROR;
  }
  else
  {
    const size_t BUFFER_SIZE = 4096;
    size_t nRead;
    size_t nWrite;
    size_t nToWrite;
    size_t n;
    wxUint8 buffer[BUFFER_SIZE];
    wxUint8 *pBuffer;
    while((nRtn == COPY_OK) && (nInputSize > nOutputSize))
    {
      pBuffer = &buffer[0];
      nRead = fin.Read((void *) pBuffer,BUFFER_SIZE);
      if(nRead == wxInvalidOffset)
      {
        nRtn = READ_ERROR;
      }
      else if(!nRead)
      {
        nRtn = READ_ERROR;
      }
      nToWrite = nRead;
      nWrite = 0;
      while((nRtn == COPY_OK) && (nToWrite > 0))
      {
        // this should be done in one loop
        n = fout.Write((void *)pBuffer,nToWrite);
        if(!n)
        {
          nRtn = WRITE_ERROR;
        }
        else
        {
          nWrite += n;
          nToWrite -= n;
          if(nToWrite)
          {
            pBuffer += n;
          }
        }
      }
      if(nRtn == COPY_OK)
      {
        nOutputSize += nWrite;
      }
    }
    if(nRtn != COPY_OK) {}
    else if(!fout.Close())
    {
      nRtn = WRITE_ERROR;
    }
  }
  if(psError != NULL)
  {
    *psError = CopyErrorMessage(nRtn,sFileFrom,sFileTo);
  }
  return nRtn;
}
Example #7
0
template<> inline
std::wstring
glue_cast<std::wstring, wxString>(const wxString &value)
{
  return std::wstring(value.wc_str());
}
Example #8
0
// Implementation note:  Calls SetColor and Write( text ).  Override those virtuals
// and this one will magically follow suite. :)
bool ConsoleLogFrame::Write( ConsoleColors color, const wxString& text )
{
	pthread_testcancel();

	ScopedLock lock( m_mtx_Queue );

	if( m_QueueColorSection.GetLength() == 0 )
	{
		pxAssertMsg( m_CurQueuePos == 0, "Queue's character position didn't get reset in sync with it's ColorSection table." );
	}

	if( (m_QueueColorSection.GetLength() == 0) || ((color != Color_Current) && (m_QueueColorSection.GetLast().color != color)) )
	{
		++m_CurQueuePos;		// Don't overwrite the NULL;
		m_QueueColorSection.Add( ColorSection(color, m_CurQueuePos) );
	}

	int endpos = m_CurQueuePos + text.Length();
	m_QueueBuffer.MakeRoomFor( endpos + 1 );		// and the null!!
	memcpy( &m_QueueBuffer[m_CurQueuePos], text.wc_str(), sizeof(wxChar) * text.Length() );
	m_CurQueuePos = endpos;

	// this NULL may be overwritten if the next message sent doesn't perform a color change.
	m_QueueBuffer[m_CurQueuePos] = 0;

	// Idle events don't always pass (wx blocks them when moving windows or using menus, for
	// example).  So let's hackfix it so that an alternate message is posted if the queue is
	// "piling up."

	if( !m_pendingFlushMsg )
	{
		m_pendingFlushMsg = true;

		// wxWidgets may have aggressive locks on event processing, so best to release
		// our own mutex lest wx get hung for an extended period of time and cause all
		// of our own stuff to get sluggish.
		lock.Release();

		wxCommandEvent evt( pxEvt_FlushQueue );
		evt.SetInt( 0 );
		if( wxThread::IsMain() )
		{
			OnFlushEvent( evt );
			return false;
		}
		else
			GetEventHandler()->AddPendingEvent( evt );

		lock.Acquire();
	}

	if( !wxThread::IsMain() )
	{
		// Too many color changes causes huge slowdowns when decorating the rich textview, so
		// include a secondary check to avoid having a colorful log spam killing gui responsiveness.

		if( m_CurQueuePos > 0x100000 || m_QueueColorSection.GetLength() > 256 )
		{
			++m_WaitingThreadsForFlush;
			lock.Release();

			// Note: if the queue flushes, we need to return TRUE, so that our thread sleeps
			// until the main thread has had a chance to repaint the console window contents.
			// [TODO] : It'd be a lot better if the console window repaint released the lock
			//  once its task were complete, but thats been problematic, so for now this hack is
			//  what we get.
			if( m_sem_QueueFlushed.Wait( wxTimeSpan( 0,0,0,250 ) ) ) return true;

			// If we're here it means QueueFlush wait timed out, so remove us from the waiting
			// threads count. This way no thread permanently deadlocks against the console
			// logger.  They just run quite slow, but should remain responsive to user input.
			lock.Acquire();
			if( m_WaitingThreadsForFlush != 0 ) --m_WaitingThreadsForFlush;
		}
	}

	return false;
}
Example #9
0
wxArgNormalizerWchar<const wxString&>::wxArgNormalizerWchar(
                            const wxString& s,
                            const wxFormatString *fmt, unsigned index)
    : wxArgNormalizerWithBuffer<wchar_t>(s.wc_str(), fmt, index)
{
}
Example #10
0
	void ActorViewerPostToGame()
	{
		POST_MESSAGE(SetActorViewer, ((std::wstring)m_ActorViewerEntity.wc_str(), (std::wstring)m_ActorViewerAnimation.wc_str(), m_ObjectSettings.GetPlayerID(), m_ActorViewerSpeed, false));
	}
Example #11
0
void wxWebViewIE::DoSetPage(const wxString& html, const wxString& baseUrl)
{
    BSTR bstr = SysAllocString(OLESTR(""));
    SAFEARRAY *psaStrings = SafeArrayCreateVector(VT_VARIANT, 0, 1);
    if (psaStrings != NULL)
    {
        VARIANT *param;
        HRESULT hr = SafeArrayAccessData(psaStrings, (LPVOID*)&param);
        param->vt = VT_BSTR;
        param->bstrVal = bstr;

        hr = SafeArrayUnaccessData(psaStrings);

        wxCOMPtr<IHTMLDocument2> document(GetDocument());

        if(!document)
            return;

        document->write(psaStrings);
        document->close();

        SafeArrayDestroy(psaStrings);

        bstr = SysAllocString(html.wc_str());

        // Creates a new one-dimensional array
        psaStrings = SafeArrayCreateVector(VT_VARIANT, 0, 1);
        if (psaStrings != NULL)
        {
            hr = SafeArrayAccessData(psaStrings, (LPVOID*)&param);
            param->vt = VT_BSTR;
            param->bstrVal = bstr;
            hr = SafeArrayUnaccessData(psaStrings);

            document = GetDocument();

            if(!document)
                return;

            document->write(psaStrings);

            // SafeArrayDestroy calls SysFreeString for each BSTR
            SafeArrayDestroy(psaStrings);

            //We send the events when we are done to mimic webkit
            //Navigated event
            wxWebViewEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
                                 GetId(), baseUrl, "");
            event.SetEventObject(this);
            HandleWindowEvent(event);

            //Document complete event
            event.SetEventType(wxEVT_COMMAND_WEB_VIEW_LOADED);
            event.SetEventObject(this);
            HandleWindowEvent(event);
        }
        else
        {
            wxLogError("wxWebViewIE::SetPage() : psaStrings is NULL");
        }
    }
    else
    {
        wxLogError("wxWebViewIE::SetPage() : psaStrings is NULL during clear");
    }
}
Example #12
0
inline _bstr_t wx2bstr(const wxString& str)
{
    return _bstr_t(str.wc_str());
}
Example #13
0
AvisynthVideoProvider::AvisynthVideoProvider(wxString filename)
: last_fnum(-1)
{
	iframe.flipped = true;
	iframe.invertChannels = true;

	wxMutexLocker lock(avs.GetMutex());

	wxFileName fname(filename);
	if (!fname.FileExists())
		throw agi::FileNotFoundError(from_wx(filename));

	wxString extension = filename.Right(4).Lower();

#ifdef _WIN32
	if (extension == ".avi") {
		// Try to read the keyframes before actually opening the file as trying
		// to open the file while it's already open can cause problems with
		// badly written VFW decoders
		AVIFileInit();

		PAVIFILE pfile;
		long hr = AVIFileOpen(&pfile, filename.wc_str(), OF_SHARE_DENY_WRITE, 0);
		if (hr) {
			warning = "Unable to open AVI file for reading keyframes:\n";
			switch (hr) {
				case AVIERR_BADFORMAT:
					warning += "The file is corrupted, incomplete or has an otherwise bad format.";
					break;
				case AVIERR_MEMORY:
					warning += "The file could not be opened because of insufficient memory.";
					break;
				case AVIERR_FILEREAD:
					warning += "An error occurred reading the file. There might be a problem with the storage media.";
					break;
				case AVIERR_FILEOPEN:
					warning += "The file could not be opened. It might be in use by another application, or you do not have permission to access it.";
					break;
				case REGDB_E_CLASSNOTREG:
					warning += "There is no handler installed for the file extension. This might indicate a fundamental problem in your Video for Windows installation, and can be caused by extremely stripped Windows installations.";
					break;
				default:
					warning += "Unknown error.";
					break;
			}
			goto file_exit;
		}

		PAVISTREAM ppavi;
		if (hr = AVIFileGetStream(pfile, &ppavi, streamtypeVIDEO, 0)) {
			warning = "Unable to open AVI video stream for reading keyframes:\n";
			switch (hr) {
				case AVIERR_NODATA:
					warning += "The file does not contain a usable video stream.";
					break;
				case AVIERR_MEMORY:
					warning += "Not enough memory.";
					break;
				default:
					warning += "Unknown error.";
					break;
			}
			goto file_release;
		}

		AVISTREAMINFO avis;
		if (FAILED(AVIStreamInfo(ppavi,&avis,sizeof(avis)))) {
			warning = "Unable to read keyframes from AVI file:\nCould not get stream information.";
			goto stream_release;
		}

		bool all_keyframes = true;
		for (size_t i = 0; i < avis.dwLength; i++) {
			if (AVIStreamIsKeyFrame(ppavi, i))
				KeyFrames.push_back(i);
			else
				all_keyframes = false;
		}

		// If every frame is a keyframe then just discard the keyframe data as it's useless
		if (all_keyframes) KeyFrames.clear();

		// Clean up
stream_release:
		AVIStreamRelease(ppavi);
file_release:
		AVIFileRelease(pfile);
file_exit:
		AVIFileExit();
	}
#endif

	try {
		AVSValue script = Open(fname, extension);

		// Check if video was loaded properly
		if (!script.IsClip() || !script.AsClip()->GetVideoInfo().HasVideo())
			throw VideoNotSupported("No usable video found");

		vi = script.AsClip()->GetVideoInfo();
		if (!vi.IsRGB()) {
			/// @todo maybe read ColorMatrix hints for d2v files?

			AVSValue args[2] = { script, "Rec601" };
			if (!OPT_GET("Video/Force BT.601")->GetBool() && (vi.width > 1024 || vi.height >= 600)) {
				args[1] = "Rec709";
				colorspace = "TV.709";
			}
			else
				colorspace = "TV.601";
			const char *argnames[2] = { 0, "matrix" };
			script = avs.GetEnv()->Invoke("ConvertToRGB32", AVSValue(args, 2), argnames);
		}
		else
			colorspace = "None";

		RGB32Video = avs.GetEnv()->Invoke("Cache", script).AsClip();
		vi = RGB32Video->GetVideoInfo();
		fps = (double)vi.fps_numerator / vi.fps_denominator;
	}
	catch (AvisynthError const& err) {
		throw VideoOpenError("Avisynth error: " + std::string(err.msg));
	}
}
Example #14
0
wxString Internat::UTF8ToLocal(const wxString &s)
{
   return wxString(s.wc_str(wxConvUTF8), *mConvLocal);
}
Example #15
0
wxString Internat::LocalToUTF8(const wxString &s)
{
   return wxString(s.wc_str(*mConvLocal), wxConvUTF8);
}
void CFileExistsDlg::LoadIcon(int id, const wxString &file)
{
	wxStaticBitmap *pStatBmp = static_cast<wxStaticBitmap *>(FindWindow(id));
	if (!pStatBmp)
		return;

	wxSize size = CThemeProvider::GetIconSize(iconSizeNormal);
	pStatBmp->SetInitialSize(size);
	pStatBmp->InvalidateBestSize();
	pStatBmp->SetBitmap(CThemeProvider::GetBitmap(_T("ART_FILE"), wxART_OTHER, size));

#ifdef __WXMSW__
	SHFILEINFO fileinfo;
	memset(&fileinfo, 0, sizeof(fileinfo));
	if (SHGetFileInfo(file.wc_str(), FILE_ATTRIBUTE_NORMAL, &fileinfo, sizeof(fileinfo), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES)) {
		wxBitmap bmp;
		bmp.Create(size.x, size.y);

		wxMemoryDC *dc = new wxMemoryDC;

		wxPen pen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
		wxBrush brush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));

		dc->SelectObject(bmp);

		dc->SetPen(pen);
		dc->SetBrush(brush);
		dc->DrawRectangle(0, 0, size.x, size.y);

		wxIcon icon;
		icon.SetHandle(fileinfo.hIcon);
		icon.SetSize(size.x, size.y);

		dc->DrawIcon(icon, 0, 0);
		delete dc;

		pStatBmp->SetBitmap(bmp);

		return;
	}

#endif //__WXMSW__

	wxFileName fn(file);
	wxString ext = fn.GetExt();
	if (ext.empty())
		return;

	wxFileType *pType = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
	if (pType) {
		wxIconLocation loc;
		if (pType->GetIcon(&loc) && loc.IsOk()) {
			wxLogNull *tmp = new wxLogNull;
			wxIcon icon(loc);
			delete tmp;
			if (!icon.Ok()) {
				delete pType;
				return;
			}

			int width = icon.GetWidth();
			int height = icon.GetHeight();
			if (width && height) {
				wxBitmap bmp;
				bmp.Create(icon.GetWidth(), icon.GetHeight());

				wxMemoryDC *dc = new wxMemoryDC;

				wxPen pen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
				wxBrush brush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));

				dc->SelectObject(bmp);

				dc->SetPen(pen);
				dc->SetBrush(brush);
				dc->DrawRectangle(0, 0, width, height);

				dc->DrawIcon(icon, 0, 0);
				delete dc;

				pStatBmp->SetBitmap(bmp);

				return;
			}
		}
		delete pType;
	}
}