Example #1
0
/*
	ディレクトリダイアログ用汎用ルーチン
*/
void BrowseDirDlg(TWin *parentWin, UINT editCtl, char *title)
{ 
	IMalloc			*iMalloc = NULL;
	BROWSEINFOW		brInfo;
	LPITEMIDLIST	pidlBrowse;
	char			buf[MAX_PATH_U8];
	WCHAR			wbuf[MAX_PATH];
	Wstr			wtitle(title);

	parentWin->GetDlgItemTextU8(editCtl, buf, sizeof(buf));
	U8toW(buf, wbuf, MAX_PATH);
	if (!SUCCEEDED(SHGetMalloc(&iMalloc)))
		return;

	TBrowseDirDlg	dirDlg(buf);
	brInfo.hwndOwner = parentWin->hWnd;
	brInfo.pidlRoot = 0;
	brInfo.pszDisplayName = wbuf;
	brInfo.lpszTitle = wtitle.Buf();
	brInfo.ulFlags = BIF_RETURNONLYFSDIRS;
	brInfo.lpfn = BrowseDirDlg_Proc;
	brInfo.lParam = (LPARAM)&dirDlg;
	brInfo.iImage = 0;

	do {
		if ((pidlBrowse = ::SHBrowseForFolderW(&brInfo))) {
			if (::SHGetPathFromIDListW(pidlBrowse, wbuf))
				::SetDlgItemTextW(parentWin->hWnd, editCtl, wbuf);
			iMalloc->Free(pidlBrowse);
			break;
		}
	} while (dirDlg.IsDirty());

	iMalloc->Release();
}
Example #2
0
int TWin::MessageBoxU8(LPCSTR msg, LPCSTR title, UINT style)
{
	Wstr	wmsg(msg);
	Wstr	wtitle(title);

	
	return	MessageBoxW(wmsg.s(), wtitle.s(), style);
}
Example #3
0
void wow3d_t::set_title(const std::string& title)
{
	title_m=title;

	if(good())
	{
		std::wstring wtitle(title_m.begin(),title_m.end());
		device->setWindowCaption(wtitle.c_str());
	}
}
Example #4
0
static string BrowserWindow_fileDialog(bool save, BrowserWindow::State& state) {
  string path = string{state.path}.replace("/", "\\");

  string filters;
  for(auto& filter : state.filters) {
    lstring part = filter.split("(");
    if(part.size() != 2) continue;
    part[1].rtrim<1>(")");
    part[1].replace(" ", "");
    part[1].transform(",", ";");
    filters.append(filter, "\t", part[1], "\t");
  }

  utf16_t wfilters(filters);
  wchar_t wname[PATH_MAX + 1] = L"";
  utf16_t wpath(path);
  utf16_t wtitle(state.title);

  wchar_t* p = wfilters;
  while(*p != L'\0') {
    if(*p == L'\t') *p = L'\0';
    p++;
  }

  if(path.empty() == false) {
    //clear COMDLG32 MRU (most recently used) file list
    //this is required in order for lpstrInitialDir to be honored in Windows 7 and above
    registry::remove("HKCU/Software/Microsoft/Windows/CurrentVersion/Explorer/ComDlg32/LastVisitedPidlMRU/");
    registry::remove("HKCU/Software/Microsoft/Windows/CurrentVersion/Explorer/ComDlg32/OpenSavePidlMRU/");
  }

  OPENFILENAME ofn;
  memset(&ofn, 0, sizeof(OPENFILENAME));
  ofn.lStructSize = sizeof(OPENFILENAME);
  ofn.hwndOwner = state.parent ? state.parent->p.hwnd : 0;
  ofn.lpstrFilter = wfilters;
  ofn.lpstrInitialDir = wpath;
  ofn.lpstrFile = wname;
  ofn.lpstrTitle = wtitle;
  ofn.nMaxFile = PATH_MAX;
  ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
  ofn.lpstrDefExt = L"";

  bool result = (save == false ? GetOpenFileName(&ofn) : GetSaveFileName(&ofn));
  if(result == false) return "";
  string name = (const char*)utf8_t(wname);
  name.transform("\\", "/");
  return name;
}
Example #5
0
status_t Win::ReceiveBroadcast(BMessage *message) 
{
//	printf( "Win::ReceiveBroadcast()\n" );
//	message->PrintToStream();
	uint32 command=0;
	message->FindInt32("command",(int32*)&command);

	int16 win_uid = -1;
	if( message->HasInt16( "window_uid" ) )
	{
		message->FindInt16( "window_uid", &win_uid );
	}
					
	switch(command)
	{
		case COMMAND_INFO :
		{
			switch( message->what )
			{
				case RENDERVIEW_POINTER :
				{
//					printf( "  RENDERVIEW_POINTER\n" );
					
					message->PrintToStream();
					
					int32 site_id = 0;
					message->FindInt32( "site_id", &site_id );
					if( site_id == 0 )
						break;
					
					int32 tabindex;
					ThemisTab* tab = FindTabFor( site_id, &tabindex );
					if( tab == NULL )
						break;
					
					TRenderView* renderview = NULL;
					message->FindPointer( "renderview_pointer", ( void** )&renderview );
					if( renderview == NULL )
						break;
					
					/* Attach the renderview to the correct tab. */

					Lock();
					
					//int32 tabindex = tabview->IndexForTab( tab );
					
					/*
					 * We don't need to resize the renderview here, as this is done in
					 * ThemisTabView::Select().
					 */
					
					tabview->TabAt( tabindex )->SetView( renderview );
					
					if( tabview->Selection() == tabindex )
					{
						tabview->Select( tabindex );
						
						if( CurrentFocus() != NULL )
							CurrentFocus()->MakeFocus( false );
						tabview->TabAt( tabindex )->View()->MakeFocus( true );
					}
					
					Unlock();
					
					break;
				}
				case SH_WIN_LOADING_PROGRESS :
				{
//					printf( "WIN: UH_WIN_LOADING_PROGRESS\n" );
					
					int32 id = 0;
					message->FindInt32( "site_id", &id );
					
					int32 tabindex;
					ThemisTab* tab = FindTabFor( id, &tabindex );
					if( !tab )
						break;
					
					SiteHandler* sh = ( ( App* )be_app )->GetSiteHandler();
					if( !sh )
						break;
					
					if( sh->EntryValid( id ) )
					{
						Lock();					

						/* Update the tabs label and icon */
						tab->SetLabel( sh->GetTitleFor( id ) );
						tab->SetFavIcon( sh->GetFavIconFor( id ) );
						tabview->DrawTabs();
						
						if( tabindex == tabview->Selection() )
						{
							/*
							 * I could introduce some checking here, if things have changed at all.
							 * But imo this is ok for now.
							 */
							
							/* Update the window title */
							BString wtitle( "Themis - " );
							wtitle.Append( sh->GetTitleFor( id ) );
							SetTitle( wtitle.String() );
							
							/* Update the FavIcon and Text in the NavView */
							navview->urlview->SetText( sh->GetUrlFor( id ) );
							navview->urlview->SetFavIcon( sh->GetFavIconFor( id ) );
							
							/* Update the StatusView */
							statusview->SetLoadingInfo(
								sh->GetLoadingProgressFor( id ),
								sh->GetStatusTextFor( id ) );
						}

						Unlock();
					}
					break;
				}
			} // switch( message->what )
			break;
		} // case COMMAND_INFO :
	} // switch( command )
	return B_OK;
}