Пример #1
1
LRESULT menu_extension::on_message(HWND wnd,UINT msg,WPARAM wp,LPARAM lp)
{
	switch (msg) 
	{
		case WM_CREATE:
		{
			initialised = true;

			mainmenu_root_group::g_get_root_items(m_buttons);
			t_size button_count = m_buttons.get_count();

			pfc::array_t<TBBUTTON> tbb;
			tbb.set_size(button_count);
			memset(tbb.get_ptr(), 0, tbb.get_size() * sizeof(TBBUTTON));

			wnd_menu = CreateWindowEx(/*TBSTYLE_EX_MIXEDBUTTONS|*/WS_EX_TOOLWINDOW, TOOLBARCLASSNAME, NULL,
				WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_LIST | CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER,
				0, 0, 0, 25, wnd, (HMENU)ID_MENU, core_api::get_my_instance(), NULL);

			if (wnd_menu)
			{
				SetWindowLongPtr(wnd_menu, GWLP_USERDATA, (LPARAM)(this));

				SendMessage(wnd_menu, TB_SETBITMAPSIZE, (WPARAM)0, MAKELONG(0, 0));
				SendMessage(wnd_menu, TB_SETBUTTONSIZE, (WPARAM)0, MAKELONG(0,/*GetSystemMetrics(SM_CYMENUSIZE)*/0));

				SendMessage(wnd_menu, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);

				unsigned n, count = tbb.get_size();
				for (n = 0; n < count; n++)
				{
					tbb[n].iBitmap = I_IMAGECALLBACK;
					tbb[n].idCommand = n + 1;
					tbb[n].fsState = TBSTATE_ENABLED;
					tbb[n].fsStyle = BTNS_DROPDOWN | BTNS_AUTOSIZE;
					tbb[n].dwData = 0;
					tbb[n].iString = (int)m_buttons[n].m_name_with_accelerators.get_ptr();
				}

				SendMessage(wnd_menu, TB_ADDBUTTONS, (WPARAM)tbb.get_size(), (LPARAM)(LPTBBUTTON)tbb.get_ptr());

				//			SendMessage(wnd_menu, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);

				//			SendMessage(wnd_menu, TB_AUTOSIZE, 0, 0); 

							//if (is_win2k_or_newer())
				{
					BOOL a = true;
					SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &a, 0);
					SendMessage(wnd_menu, WM_UPDATEUISTATE, MAKEWPARAM(a ? UIS_CLEAR : UIS_SET, UISF_HIDEACCEL), 0);
				}

				//			SendMessage(wnd_menu, TB_SETPARENT, (WPARAM) (HWND)wnd_host, 0);
				menuproc = (WNDPROC)SetWindowLongPtr(wnd_menu, GWLP_WNDPROC, (LPARAM)main_hook);
			}


			break;
		}
		case WM_WINDOWPOSCHANGED:
		{
			LPWINDOWPOS lpwp = (LPWINDOWPOS)lp;
			if (!(lpwp->flags & SWP_NOSIZE))
			{
				//SIZE sz = {0,0};
				//SendMessage(wnd_menu, TB_GETMAXSIZE, NULL, (LPARAM)&sz);

				RECT rc = { 0,0,0,0 };
				t_size count = m_buttons.get_count();
				int cx = lpwp->cx;
				int cy = lpwp->cy;
				int extra = 0;
				if (count && (BOOL)SendMessage(wnd_menu, TB_GETITEMRECT, count - 1, (LPARAM)(&rc)))
				{
					cx = min(cx, rc.right);
					cy = min(cy, rc.bottom);
					extra = (lpwp->cy - rc.bottom) / 2;
				}
				SetWindowPos(wnd_menu, 0, 0, extra, cx, cy, SWP_NOZORDER);
				RedrawWindow(wnd, 0, 0, RDW_ERASE | RDW_INVALIDATE);
			}
			break;
		}

		case WM_NOTIFY:
		{
			if (((LPNMHDR)lp)->idFrom == ID_MENU) {
				switch (((LPNMHDR)lp)->code)
				{
				case TBN_HOTITEMCHANGE:
				{
					if (!(((LPNMTBHOTITEM)lp)->dwFlags & HICF_LEAVING) && (((LPNMTBHOTITEM)lp)->dwFlags & HICF_MOUSE || ((LPNMTBHOTITEM)lp)->dwFlags & HICF_LMOUSE))
						redrop = true;
					break;
				}
				case TBN_DROPDOWN:
				{
					if (redrop)
						PostMessage(wnd, MSG_CREATE_MENU, ((LPNMTOOLBAR)lp)->iItem, 0);
					else
						redrop = true;

					return TBDDRET_DEFAULT;
				}
				}
			}
			break;
		}
		case MSG_HIDE_MENUACC:
		{
			//if (is_win2k_or_newer())
			{
				BOOL a = true;
				SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &a, 0);
				if ((SendMessage(wnd_menu, WM_QUERYUISTATE, 0, 0) & UISF_HIDEACCEL) != !a)
					SendMessage(wnd_menu, WM_UPDATEUISTATE, MAKEWPARAM(a ? UIS_CLEAR : UIS_SET, UISF_HIDEACCEL), 0);
			}
			break;
		}
		case MSG_SHOW_MENUACC:
		{
			//if (is_win2k_or_newer())
			{
				SendMessage(wnd_menu, WM_UPDATEUISTATE, MAKEWPARAM(UIS_CLEAR, UISF_HIDEACCEL), 0);
			}
			break;
		}
		case MSG_CREATE_MENU:
		{
			if (lp) SetFocus(wnd_menu);
			active_item = wp;

			make_menu(wp);
			break;
		}
		case WM_MENUSELECT:
		{
			if (HIWORD(wp) & MF_POPUP)
			{
				is_submenu = true;
				m_status_override.release();
			}
			else
			{
				is_submenu = false;
				if (p_manager.is_valid())
				{
					unsigned id = LOWORD(wp);

					bool set = false;

					pfc::string8 blah;

					set = p_manager->get_description(id - 1, blah);

					service_ptr_t<ui_status_text_override> p_status_override;

					if (set)
					{
						get_host()->override_status_text_create(p_status_override);

						if (p_status_override.is_valid())
						{
							p_status_override->override_text(blah);
						}
					}
					m_status_override = p_status_override;
				}
			}
			break;
		}
		case WM_INITMENUPOPUP:
		{
			sub_menu_ref_count++;
			break;
		}
		case WM_UNINITMENUPOPUP:
		{
			sub_menu_ref_count--;
			break;
		}
		case WM_GETMINMAXINFO:
		{
			LPMINMAXINFO mmi = LPMINMAXINFO(lp);

			RECT rc = { 0,0,0,0 };
			SendMessage(wnd_menu, TB_GETITEMRECT, m_buttons.get_count() - 1, (LPARAM)(&rc));

			//SIZE sz = {0,0};
			//SendMessage(wnd_menu, TB_GETMAXSIZE, NULL, (LPARAM)&sz);
			//console::formatter() << sz.cx << sz.cy;

			mmi->ptMinTrackSize.x = rc.right;
			mmi->ptMinTrackSize.y = rc.bottom;
			mmi->ptMaxTrackSize.y = rc.bottom;
			return 0;
		}
		case WM_SETTINGCHANGE:
		{
			if (wp == SPI_SETNONCLIENTMETRICS)
			{
				PostMessage(wnd, MSG_SIZE_LIMIT_CHANGE, 0, 0);
			}
			break;
		}
		case SPI_GETKEYBOARDCUES:
		{
			BOOL a = TRUE;
			SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &a, 0);
			SendMessage(wnd_menu, WM_UPDATEUISTATE, MAKEWPARAM((a || GetFocus() == wnd_menu) ? UIS_CLEAR : UIS_SET, UISF_HIDEACCEL), 0);
			break;
		}
		case MSG_SIZE_LIMIT_CHANGE:
		{
			get_host()->on_size_limit_change(wnd, uie::size_limit_minimum_height | uie::size_limit_maximum_height | uie::size_limit_minimum_width);
			break;
		}
		case WM_DESTROY:
		{
			DestroyWindow(wnd_menu);
			wnd_menu = NULL;
			m_buttons.remove_all();
			initialised = false;
			break;
		}
	}
	return DefWindowProc(wnd, msg, wp, lp);
}
Пример #2
0
void seekabilizer::g_seekabilize(service_ptr_t<file> & p_reader,t_size p_buffer_size,abort_callback & p_abort) {
	if (p_reader.is_valid() && p_reader->is_remote() && p_buffer_size > 0) {
		service_ptr_t<seekabilizer> instance = new service_impl_t<seekabilizer>();
		instance->initialize(p_reader,p_buffer_size,p_abort);
		p_reader = instance.get_ptr();
	}
}
Пример #3
0
static void prepare_for_open(service_ptr_t<input_entry> & p_service,service_ptr_t<file> & p_file,const char * p_path,filesystem::t_open_mode p_open_mode,abort_callback & p_abort,bool p_from_redirect)
{
	if (p_file.is_empty())
	{
		service_ptr_t<filesystem> fs;
		if (filesystem::g_get_interface(fs,p_path)) {
			if (fs->supports_content_types()) {
				fs->open(p_file,p_path,p_open_mode,p_abort);
			}
		}
	}

	if (p_file.is_valid())
	{
		pfc::string8 content_type;
		if (p_file->get_content_type(content_type))
		{
			if (input_entry::g_find_service_by_content_type(p_service,content_type))
				return;
		}
	}

	if (input_entry::g_find_service_by_path(p_service,p_path))
	{
		if (p_from_redirect && p_service->is_redirect()) throw exception_io_unsupported_format();
		return;
	}

	throw exception_io_unsupported_format();
}
bool dsp_rate_entry::instantiate(service_ptr_t<dsp>& p_out, const dsp_preset& p_preset)
{
	bool ret = false;
	if (p_preset.get_owner() == get_guid())
	{
		t_dsp_rate_params params;
		params.set_data(p_preset);
		p_out = reinterpret_cast<dsp*>(new service_impl_t<dsp_rate>(params));
		ret = p_out.is_valid();
	}
	return ret;
}
Пример #5
0
static void process_fullbuffer(service_ptr_t<file> & p_file,const char * p_path,t_filesize p_fullbuffer,abort_callback & p_abort) {
	if (p_fullbuffer > 0) {
		if (p_file.is_empty()) {
			service_ptr_t<filesystem> fs;
			if (filesystem::g_get_interface(fs,p_path)) {
				fs->open(p_file,p_path,filesystem::open_mode_read,p_abort);
			}
		}

		if (p_file.is_valid()) {
			t_filesize size = p_file->get_size(p_abort);
			if (size != filesize_invalid && size <= p_fullbuffer) {
				service_ptr_t<file> l_file_buffered;
				if (reader_membuffer_mirror::g_create(l_file_buffered,p_file,p_abort)) {
					p_file = l_file_buffered;
				}
			}
		}
	}
}
Пример #6
0
static void process_path_internal(const char * p_path,const service_ptr_t<file> & p_reader,playlist_loader_callback_v2 & p_callback,playlist_loader_callback::t_entry_type p_type,const t_filestats & p_stats)
{
	//p_path must be canonical

	p_callback.check();

	p_callback.on_progress(p_path);

	
	{
		if (p_reader.is_empty()) {
			directory_callback_impl directory_results(true);
			try {
				filesystem::g_list_directory(p_path,directory_results,p_callback);
				for(t_size n=0;n<directory_results.get_count();n++) {
					process_path_internal(directory_results.get_item(n),0,p_callback,playlist_loader_callback::entry_directory_enumerated,directory_results.get_item_stats(n));
				}
				return;
			} catch(exception_aborted) {throw;}
			catch(...) {
				//do nothing, fall thru
				//fixme - catch only filesystem exceptions?
			}
		}

		bool found = false;


		{
			archive_callback_impl archive_results(p_callback);
			service_enum_t<filesystem> e;
			service_ptr_t<filesystem> f;
			while(e.next(f)) {
				p_callback.check();
				service_ptr_t<archive> arch;
				if (f->service_query_t(arch)) {
					if (p_reader.is_valid()) p_reader->reopen(p_callback);

					try {
						TRACK_CODE("archive::archive_list",arch->archive_list(p_path,p_reader,archive_results,true));
						return;
					} catch(exception_aborted) {throw;} 
					catch(...) {}
				}
			} 
		}
	}

	

	{
		service_ptr_t<link_resolver> ptr;
		if (link_resolver::g_find(ptr,p_path))
		{
			if (p_reader.is_valid()) p_reader->reopen(p_callback);

			pfc::string8 temp;
			try {
				TRACK_CODE("link_resolver::resolve",ptr->resolve(p_reader,p_path,temp,p_callback));

				track_indexer__g_get_tracks_wrap(temp,0,filestats_invalid,playlist_loader_callback::entry_from_playlist,p_callback);
				return;//success
			} catch(exception_aborted) {throw;}
			catch(...) {}
		}
	}

	if (p_callback.is_path_wanted(p_path,p_type)) {
		track_indexer__g_get_tracks_wrap(p_path,p_reader,p_stats,p_type,p_callback);
	}
}
Пример #7
0
void playlist_view::g_get_global_style_titleformat_object(service_ptr_t<titleformat_object> & p_out)
{
	if (!g_to_global_colour.is_valid()) 
		static_api_ptr_t<titleformat_compiler>()->compile_safe(g_to_global_colour, cfg_colour);
	p_out = g_to_global_colour;
}