示例#1
0
static BOOL cbTypeToSelect(HWND cb, LRESULT *posOut, BOOL restoreAfter)
{
	WCHAR *text;
	LRESULT pos;
	DWORD selStart, selEnd;

	// start by saving the current selection as setting the item will change the selection
	SendMessageW(cb, CB_GETEDITSEL, (WPARAM) (&selStart), (LPARAM) (&selEnd));
	text = windowText(cb);
	pos = SendMessageW(cb, CB_FINDSTRINGEXACT, (WPARAM) (-1), (LPARAM) text);
	if (pos == (LRESULT) CB_ERR) {
		uiFree(text);
		return FALSE;
	}
	cbSetCurSel(cb, (WPARAM) pos);
	if (posOut != NULL)
		*posOut = pos;
	if (restoreAfter)
		if (SendMessageW(cb, WM_SETTEXT, 0, (LPARAM) text) != (LRESULT) TRUE)
			logLastError(L"error restoring old combobox text");
	uiFree(text);
	// and restore the selection like above
	// TODO isn't there a 32-bit version of this
	if (SendMessageW(cb, CB_SETEDITSEL, 0, MAKELPARAM(selStart, selEnd)) != (LRESULT) TRUE)
		logLastError(L"error restoring combobox edit selection");
	return TRUE;
}
示例#2
0
static int editInt(HWND hwnd)
{
	WCHAR *s;
	int i;

	s = windowText(hwnd);
	i = _wtoi(s);
	uiFree(s);
	return i;
}
示例#3
0
static double editDouble(HWND hwnd)
{
	WCHAR *s;
	double d;

	s = windowText(hwnd);
	d = _wtof(s);
	uiFree(s);
	return d;
}
示例#4
0
文件: text.cpp 项目: Alcaro/RetroArch
char *uiWindowsWindowText(HWND hwnd)
{
	WCHAR *wtext;
	char *text;

	wtext = windowText(hwnd);
	text = toUTF8(wtext);
	uiFree(wtext);
	return text;
}
示例#5
0
HRESULT uiprivTableResizeWhileEditing(uiTable *t)
{
	WCHAR *text;
	HRESULT hr;

	if (t->edit == NULL)
		return S_OK;
	text = windowText(t->edit);
	hr = resizeEdit(t, text, t->editedItem, t->editedSubitem);
	uiprivFree(text);
	return hr;
}
示例#6
0
static void hexChanged(struct colorDialog *c)
{
	WCHAR *buf;
	double r, g, b, a;
	BOOL is;

	buf = windowText(c->editHex);
	is = hex2RGBA(buf, &r, &g, &b, &a);
	uiFree(buf);
	if (!is)
		return;
	rgb2HSV(r, g, b, &(c->h), &(c->s), &(c->v));
	c->a = a;
	updateDialog(c, c->editHex);
}
示例#7
0
static void sizeEdited(struct fontDialog *f)
{
	WCHAR *wsize;
	double size;

	// handle type-to-selection
	if (cbTypeToSelect(f->sizeCombobox, NULL, FALSE)) {
		sizeChanged(f);
		return;
	}
	// selection not chosen, try to parse the typing
	wsize = windowText(f->sizeCombobox);
	// this is what the Choose Font dialog does; it swallows errors while the real ChooseFont() is not lenient (and only checks on OK)
	size = wcstod(wsize, NULL);
	if (size <= 0)		// don't change on invalid size
		return;
	f->curSize = size;
	queueRedrawSampleText(f);
}
示例#8
0
static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
{
	uiSpinbox *s = (uiSpinbox *) c;
	WCHAR *wtext;

	if (code != EN_CHANGE)
		return FALSE;
	if (s->inhibitChanged)
		return FALSE;
	// We want to allow typing negative numbers; the natural way to do so is to start with a -.
	// However, if we just have the code below, the up-down will catch the bare - and reject it.
	// Let's fix that.
	// This won't handle leading spaces, but spaces aren't allowed *anyway*.
	wtext = windowText(s->edit);
	if (wcscmp(wtext, L"-") == 0) {
		uiFree(wtext);
		return TRUE;
	}
	uiFree(wtext);
	// value() does the work for us
	value(s);
	(*(s->onChanged))(s, s->onChangedData);
	return TRUE;
}
示例#9
0
/**
* PreTranslateMessage
*
*/
BOOL CHeaderDockPane::PreTranslateMessage(MSG* pMsg)
{
	//CDockablePane::PreTranslateMessage(pMsg);

	//
	// Enter new URL and hit Enter Key
	//
    if (pMsg->message == WM_KEYDOWN &&
        pMsg->wParam == VK_RETURN &&
		url.HasFocus()  )
    {
        // handle return pressed in edit control
		CString windowText(_T(""));
		url.GetWindowTextW(windowText);		// Get window text
		if(url.m_selectedText.GetLength() != 0)
		{
			int i = 0;
			//windowText = url.m_selectedText;
		}
		int idx = url.GetCurSel();			// Get selection text
		if( idx > -1 ) 
		{
		//	url.GetLBText( idx, windowText );
		}
		TRACE1(" windowText %s \n ", windowText);

		CString * urlStr = new CString(windowText);
		AfxGetMainWnd()->PostMessage(ID_LOAD_URL, /*Callback SetUrl*/1, (LPARAM)urlStr);
		
		// If the ID_LOAD_URL is successfull, SetUrl(url) will be called to add this item to the history.

		
		/*
		std::vector<CString> urlHistory; 
		//TRACE0(" \n\n");
		CString str, str2;
		int n;
		int count = url.GetCount();
		for (int i=0;i < count; i++) 
		{
			n = url.GetLBTextLen( i );
			url.GetLBText( i, str.GetBuffer(n) );
			str.ReleaseBuffer();
			urlHistory.push_back(str);
			//url.DeleteString(i);
			//TRACE1(" read: %s \n", str);
		}
		for (int i= count - 1;i >= 0 ; i--) 
		{
			url.DeleteString(i);
		}
		
		// Add url to history. 
		urlHistory.insert(urlHistory.begin(), windowText.AllocSysString());
		for (int i=0; i < urlHistory.size(); i++)
		{
			CString entry(urlHistory[i]);
			//TRACE1(" url entry: %s \n", entry);
			int pos = url.AddString(entry.AllocSysString());
			url.SetItemData(pos, i);
		}
		*/

		//int pos = url.AddString(CString(_T("me")).AllocSysString());
		//url.SetItemData(pos, 0);

		// Load view
		// PostMessage( .... );

        return TRUE; // this doesn't need processing anymore
    }

	if (//pMsg->message == CBN_SELCHANGE &&
        //pMsg->wParam == VK_RETURN &&
		url.HasFocus()  )
    {
		//TRACE1("m %d    %d  \n" , pMsg->message, CBN_SELCHANGE);
	}


	
	//TRACE2(" message: %d   %d \n", pMsg->message, CBN_SELCHANGE);

	

	/*
	if (pMsg->message == WM_KEYDOWN &&
        pMsg->wParam == VK_RETURN &&
		GetFocus() == &search  )
    {
		search.SetWindowText(CString(_T("searching...")));
		
        // handle return pressed in edit control
        return TRUE; // this doesn't need processing anymore
    }
	*/

	//
	// Click on a url history drop down item.
	// url is a CComboBox 
	//
	if(url.HasFocus() && pMsg->message == CBN_SELENDOK && pMsg->message == CBN_SELCHANGE) 
	{
		TRACE0(" url history select  \n");
		int index = url.GetCurSel();
		int size = url.GetCount();
		if(index > -1 && index < size)
		{
			CString str, str2;
			int n;
			n = url.GetLBTextLen( index );
			url.GetLBText( index, str.GetBuffer(n) );
			str.ReleaseBuffer();
			str2.Format(_T("  %s\r\n"), index, str.GetBuffer(0));
			//TRACE1("item: %s \n", str2);
			CString * urlStr = new CString(str);
			//AfxGetMainWnd()->PostMessage(ID_LOAD_URL, 0, (LPARAM)urlStr);
		}
	}
	

	//
	// Search for input string Enter key
	//
	if(pMsg->wParam == VK_RETURN && search.HasFocus()){
		CString str, str2;
		
		m_searchResults.empty(); // remove old results.

		
		int n;
		for (int i = 0; i < search.GetCount(); i++)
		{
			int c = search.GetCount();

			//n = search.GetLBTextLen( i );
			//search.GetLBText( i, str.GetBuffer(n) );
			//str.ReleaseBuffer();
			//str2.Format(_T("item %d: %s\r\n"), i, str.GetBuffer(0));
			//afxDump << str2;
			search.DeleteString(i);
			//search.DeleteItem(
		}
		
		CString searchString(_T(""));
		search.GetWindowTextW(searchString);

		// Start search thread.....
		SEARCH_THREADPARAM * _param = new SEARCH_THREADPARAM;
		_param->_this = this;
		_param->con = m_connection;
		_param->search = searchString;
		_param->path = m_path; 
		m_pSearchThread = AfxBeginThread(CHeaderDockPane::SearchWorker, _param); 
		if (m_pSearchThread != NULL)
		{
			TRACE(_T("AfxBeginThread: 0x%08lX\n"), m_pSearchThread->m_nThreadID);
		}

		//int count = search.GetCount();
		//for (int i=0; i < count; i++) 
		//{
		//	search.DeleteString(i);
		//}

		search.AddString(CString(_T("searching...")));
		search.ShowDropDown(true);

		//return FALSE;
	}


	//
	// Select Search result to view
	//
	if(search.HasFocus() && pMsg->message == 15) // CBN_SELCHANGE=1  
	{
		TRACE0(" CBN_SELCHANGE  \n");
		int index = search.GetCurSel();
		int size = search.GetCount();
		int rsize = m_searchResults.size();
		if(index > -1 && index < size && index < rsize)
		{
			CString str, str2;
			int n;
			n = search.GetLBTextLen( index );
			search.GetLBText( index, str.GetBuffer(n) );
			str.ReleaseBuffer();
			str2.Format(_T("item %d: %s\r\n"), index, str.GetBuffer(0));
			//TRACE1("item: %s \n", str2);

			CFileContainer f;
			f = (CFileContainer)m_searchResults.at(index);
			TRACE1(" Load search result -> file %s \n", f.name);

			CString * dirStr = new CString(f.path);
			//AfxGetMainWnd()->PostMessage(ID_LOAD_DIR, /*Callback SetUrl*/0, (LPARAM)dirStr);

			CFileContainer * argFile = new CFileContainer(f);
			AfxGetMainWnd()->PostMessage(ID_SELECT_FILE, /* */0, (LPARAM)argFile);
		
			//search.SetWindowTextW(_T(""));
			search.SetCurSel(-1); // Deselect item
		}
		//search.Get
	}


	if(pMsg->message == WM_LBUTTONUP){
		//TRACE0(" lbutton ");
	}

	//TRACE1(" m: %d \n", pMsg->message);

    return FALSE; // all other cases still need default processing
}