Ejemplo n.º 1
0
//*****************************************************************************
//
// Function Name: RGridCtrlBase::UpdateMetrics()
//
// Description:   Determines the cell metrics from of first item in
//                the list.  This data is then used to update the
//                internal cell metric information.
//
// Returns:		   None
//
// Exceptions:	   None
//
//*****************************************************************************
void RGridCtrlBase::UpdateMetrics()
{
	if (GetCount() && !m_fResizeCells)
	{
		MEASUREITEMSTRUCT itemMeasure ; 

		itemMeasure.CtlType    = ODT_LISTBOX ;
		itemMeasure.CtlID      = GetDlgCtrlID() ;
		itemMeasure.itemID     = 0 ;
		itemMeasure.itemWidth  = kDefaultWidth ;
		itemMeasure.itemHeight = kDefaultHeight ;

		MeasureItem( &itemMeasure ) ;

		if (m_uiFlags & kPushLike)
		{
			itemMeasure.itemWidth  += 3 ;
			itemMeasure.itemHeight += 3 ;
		}

		if (m_uiFlags & kAddSpacing)
		{
			itemMeasure.itemWidth  += 2 ;
			itemMeasure.itemHeight += 2 ;
		}

		if (itemMeasure.itemWidth != m_cxCellWidth || itemMeasure.itemHeight != m_cxCellHeight)
		{
			SetCellDimensions( itemMeasure.itemWidth, itemMeasure.itemHeight ) ;
		}
	}
}
Ejemplo n.º 2
0
BOOL CListBox::OnChildNotify( UINT message, WPARAM wParam, LPARAM lParam,
                              LRESULT *pResult )
/**********************************************/
{
    switch( message ) {
    case WM_CHARTOITEM:
        *pResult = CharToItem( LOWORD( wParam ), HIWORD( wParam ) );
        return( TRUE );
    case WM_COMPAREITEM:
        *pResult = CompareItem( (LPCOMPAREITEMSTRUCT)lParam );
        return( TRUE );
    case WM_DELETEITEM:
        DeleteItem( (LPDELETEITEMSTRUCT)lParam );
        return( TRUE );
    case WM_DRAWITEM:
        DrawItem( (LPDRAWITEMSTRUCT)lParam );
        return( TRUE );
    case WM_MEASUREITEM:
        MeasureItem( (LPMEASUREITEMSTRUCT)lParam );
        return( TRUE );
    case WM_VKEYTOITEM:
        *pResult = VKeyToItem( LOWORD( wParam ), HIWORD( wParam ) );
        return( TRUE );
    }
    return( FALSE );
}
Ejemplo n.º 3
0
BOOL CComboBox::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam,
	LRESULT* pResult)
{
	switch (message)
	{
	case WM_DRAWITEM:
		ASSERT(pResult == NULL);       // no return value expected
		DrawItem((LPDRAWITEMSTRUCT)lParam);
		break;
	case WM_MEASUREITEM:
		ASSERT(pResult == NULL);       // no return value expected
		MeasureItem((LPMEASUREITEMSTRUCT)lParam);
		break;
	case WM_COMPAREITEM:
		ASSERT(pResult != NULL);       // return value expected
		*pResult = CompareItem((LPCOMPAREITEMSTRUCT)lParam);
		break;
	case WM_DELETEITEM:
		ASSERT(pResult == NULL);       // no return value expected
		DeleteItem((LPDELETEITEMSTRUCT)lParam);
		break;
	default:
		return CWnd::OnChildNotify(message, wParam, lParam, pResult);
	}
	return TRUE;
}
Ejemplo n.º 4
0
void CCheckListBox::PreMeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
	int cyItem = CalcMinimumItemHeight();

	MEASUREITEMSTRUCT measureItem;
	memcpy(&measureItem, lpMeasureItemStruct, sizeof(MEASUREITEMSTRUCT));

	measureItem.itemHeight = cyItem;
	measureItem.itemWidth  = (UINT)-1;

	// WINBUG: Windows95 and Windows NT disagree on what this value
	// should be.  According to the docs, they are both wrong
	if (GetStyle() & LBS_OWNERDRAWVARIABLE)
	{
		LRESULT lResult = DefWindowProc(LB_GETITEMDATA, measureItem.itemID, 0);
		if (lResult != LB_ERR)
			measureItem.itemData = (UINT)lResult;
		else
			measureItem.itemData = 0;

		// WINBUG: This is only done in the LBS_OWNERDRAWVARIABLE case
		// because Windows 95 does not initialize itemData to zero in the
		// case of LBS_OWNERDRAWFIXED list boxes (it is stack garbage).
		if (measureItem.itemData != 0)
		{
			AFX_CHECK_DATA* pState = (AFX_CHECK_DATA*)measureItem.itemData;
			measureItem.itemData = pState->m_dwUserData;
		}
	}

	MeasureItem(&measureItem);

	lpMeasureItemStruct->itemHeight = max(measureItem.itemHeight,(UINT) cyItem);
	lpMeasureItemStruct->itemWidth = measureItem.itemWidth;
}
Ejemplo n.º 5
0
bool wxBitmapComboBox::OnAddBitmap(const wxBitmap& bitmap)
{
    if ( wxBitmapComboBoxBase::OnAddBitmap(bitmap) )
    {
        // Need to recreate control for a new measureitem call?
        int prevItemHeight = ::SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0);

        if ( prevItemHeight != MeasureItem(0) )
            RecreateControl();

        return true;
    }

    return false;
}
Ejemplo n.º 6
0
HRESULT CSIM_ext::HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult)
{
    switch(uMsg)
    {
    case WM_DRAWITEM:
        DrawMenuItem((LPDRAWITEMSTRUCT) lParam);
        break;

    case WM_MEASUREITEM:
        MeasureItem((LPMEASUREITEMSTRUCT) lParam);
        break;
    }

    return S_OK;
}
Ejemplo n.º 7
0
void CSmartFieldListBox::Rebuild(void)
{
	int nMacros = m_pMacros->Macros();

	SetRedraw(FALSE);

	ResetContent();

/* Set the height of the items. */

	MEASUREITEMSTRUCT mi;

	MeasureItem(&mi);
	SetItemHeight(0, mi.itemHeight);

/* Add all the items. */

	for (int nMacro = 0; nMacro < nMacros; nMacro++)
	{
		CMacro* pMacro = m_pMacros->Macro(nMacro);

		ASSERT(pMacro != NULL);

		if (pMacro != NULL && ShowMacro(pMacro))
		{
			CSmartFieldListBoxItem* pItem = new CSmartFieldListBoxItem(pMacro, nMacro, m_pMacroServer);

			ASSERT(pItem != NULL);

			if (pItem != NULL)
			{
				AddString((LPCSTR)pItem);
			}
		}
	}
	SetRedraw(TRUE);

	// No state is saved yet.
	m_fSavedState = FALSE;
}
Ejemplo n.º 8
0
BOOL CComboBox::OnChildNotify( UINT message, WPARAM wParam, LPARAM lParam,
                               LRESULT *pResult )
/***********************************************/
{
    UNUSED_ALWAYS( wParam );
    
    switch( message ) {
    case WM_COMPAREITEM:
        *pResult = CompareItem( (LPCOMPAREITEMSTRUCT)lParam );
        return( TRUE );
    case WM_DELETEITEM:
        DeleteItem( (LPDELETEITEMSTRUCT)lParam );
        return( TRUE );
    case WM_DRAWITEM:
        DrawItem( (LPDRAWITEMSTRUCT)lParam );
        return( TRUE );
    case WM_MEASUREITEM:
        MeasureItem( (LPMEASUREITEMSTRUCT)lParam );
        return( TRUE );
    }
    return( FALSE );
}
Ejemplo n.º 9
0
void wxBitmapComboBox::RecreateControl()
{
    //
    // Recreate control so that WM_MEASUREITEM gets called again.
    // Can't use CBS_OWNERDRAWVARIABLE because it has odd
    // mouse-wheel behaviour.
    //
    wxString value = GetValue();
    wxPoint pos = GetPosition();
    wxSize size = GetSize();
    size.y = GetBestSize().y;
    const wxArrayString strings = GetStrings();
    const unsigned numItems = strings.size();
    unsigned i;

    // Save the client data pointers before clearing the control, if any.
    const wxClientDataType clientDataType = GetClientDataType();
    wxVector<wxClientData*> objectClientData;
    wxVector<void*> voidClientData;
    switch ( clientDataType )
    {
        case wxClientData_None:
            break;

        case wxClientData_Object:
            objectClientData.reserve(numItems);
            for ( i = 0; i < numItems; ++i )
                objectClientData.push_back(GetClientObject(i));
            break;

        case wxClientData_Void:
            voidClientData.reserve(numItems);
            for ( i = 0; i < numItems; ++i )
                voidClientData.push_back(GetClientData(i));
            break;
    }

    wxComboBox::DoClear();

    HWND hwnd = GetHwnd();
    DissociateHandle();
    ::DestroyWindow(hwnd);

    if ( !MSWCreateControl(wxT("COMBOBOX"), wxEmptyString, pos, size) )
        return;

    // initialize the controls contents
    for ( i = 0; i < numItems; i++ )
    {
        wxComboBox::Append(strings[i]);

        if ( !objectClientData.empty() )
            SetClientObject(i, objectClientData[i]);
        else if ( !voidClientData.empty() )
            SetClientData(i, voidClientData[i]);
    }

    // and make sure it has the same attributes as before
    if ( m_hasFont )
    {
        // calling SetFont(m_font) would do nothing as the code would
        // notice that the font didn't change, so force it to believe
        // that it did
        wxFont font = m_font;
        m_font = wxNullFont;
        SetFont(font);
    }

    if ( m_hasFgCol )
    {
        wxColour colFg = m_foregroundColour;
        m_foregroundColour = wxNullColour;
        SetForegroundColour(colFg);
    }

    if ( m_hasBgCol )
    {
        wxColour colBg = m_backgroundColour;
        m_backgroundColour = wxNullColour;
        SetBackgroundColour(colBg);
    }
    else
    {
        SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
    }

    ::SendMessage(GetHwnd(), CB_SETITEMHEIGHT, 0, MeasureItem(0));

    // Revert the old string value
    if ( !HasFlag(wxCB_READONLY) )
        ChangeValue(value);
}
Ejemplo n.º 10
0
static INT_PTR CALLBACK AutoreplaceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) 
{
	switch (msg) {
	case WM_INITDIALOG:
		{
			BOOL ret = SaveOptsDlgProc(autoReplaceControls, SIZEOF(autoReplaceControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);

			int sel = -1;
			for(int i = 0; i < languages.getCount(); i++) {
				Dictionary *p = languages[i];
				SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)p->full_name);
				SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETITEMDATA, i, (LPARAM)new AutoreplaceData(p));

				if ( !lstrcmp(opts.default_language, p->language))
					sel = i;
			}
			SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETCURSEL, sel, 0);

			HWND hList = GetDlgItem(hwndDlg, IDC_REPLACEMENTS);

			ListView_SetExtendedListViewStyle(hList, ListView_GetExtendedListViewStyle(hList) | LVS_EX_FULLROWSELECT);

			LVCOLUMN col = {0};
			col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT ; 
			col.fmt = LVCFMT_LEFT;
			col.cx = 175;
			col.pszText = TranslateT("Wrong word");
			col.cchTextMax = lstrlen(col.pszText);
			ListView_InsertColumn(hList, 0, &col);

			col.pszText = TranslateT("Correction");
			col.cchTextMax = lstrlen(col.pszText);
			ListView_InsertColumn(hList, 1, &col);

			LoadReplacements(hwndDlg);
			return ret;
		}

	case WM_COMMAND:
		if (LOWORD(wParam) == IDC_LANGUAGE && HIWORD(wParam) == CBN_SELCHANGE)
			LoadReplacements(hwndDlg);
		else if (LOWORD(wParam) == IDC_ADD)
			ShowAddReplacement(hwndDlg);
		else if (LOWORD(wParam) == IDC_EDIT) {
			HWND hList = GetDlgItem(hwndDlg, IDC_REPLACEMENTS);
			if (ListView_GetSelectedCount(hList) != 1)
				break;

			int sel = SendMessage(hList, LVM_GETNEXTITEM, -1, LVNI_SELECTED);
			if (sel < 0)
				break;

			ShowAddReplacement(hwndDlg, sel);
		}
		else if (LOWORD(wParam) == IDC_REMOVE) {
			HWND hList = GetDlgItem(hwndDlg, IDC_REPLACEMENTS);

			int sel = SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETCURSEL, 0, 0);
			if (sel < 0)
				break;

			AutoreplaceData *data = (AutoreplaceData *) SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, sel, 0);

			BOOL changed = FALSE;

			sel = SendMessage(hList, LVM_GETNEXTITEM, -1, LVNI_SELECTED);
			while(sel >= 0) {
				TCHAR tmp[256];
				ListView_GetItemText(hList, sel, 0, tmp, SIZEOF(tmp));

				data->RemoveWord(tmp);
				changed = TRUE;

				sel = SendMessage(hList, LVM_GETNEXTITEM, sel, LVNI_SELECTED);
			}

			if (changed) {
				LoadReplacements(hwndDlg);
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			}
		}
		break;

	case WM_NOTIFY:
		{
			LPNMHDR lpnmhdr = (LPNMHDR)lParam;
			if (lpnmhdr->idFrom == 0 && lpnmhdr->code == PSN_APPLY && languages.getCount() > 0) {
				for(int i = 0; i < languages.getCount(); i++) {
					AutoreplaceData *data = (AutoreplaceData *) SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, i, 0);
					if (data->changed) {
						data->dict->autoReplace->setMap(data->autoReplaceMap);
						data->changed = FALSE;
					}
				}
			}
			else if (lpnmhdr->idFrom == IDC_REPLACEMENTS) {
				HWND hList = GetDlgItem(hwndDlg, IDC_REPLACEMENTS);

				switch(lpnmhdr->code) {
				case LVN_ITEMCHANGED:
				case NM_CLICK:
					EnableDisableCtrls(hwndDlg);
					break;

				case NM_DBLCLK:
					LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
					if (lpnmitem->iItem >= 0)
						ShowAddReplacement(hwndDlg, lpnmitem->iItem);
					break;
				}
			}
			else if (lpnmhdr->idFrom == IDC_AUTO_USER)
				EnableDisableCtrls(hwndDlg);
		}
		break;

	case WM_DRAWITEM:
		{
			LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
			if (lpdis->CtlID != IDC_LANGUAGE) 
				break;
			if (lpdis->itemID == -1) 
				break;

			AutoreplaceData *data = (AutoreplaceData *) lpdis->itemData;
			DrawItem(hwndDlg, lpdis, data->dict);
		}
		return TRUE;

	case WM_MEASUREITEM:
		LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
		if (lpmis->CtlID != IDC_LANGUAGE) 
			break;

		MeasureItem(hwndDlg, lpmis);
		return TRUE;
	}

	return SaveOptsDlgProc(autoReplaceControls, SIZEOF(autoReplaceControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
}
Ejemplo n.º 11
0
static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) 
{
	switch (msg) {
	case WM_INITDIALOG:
		{
			int sel = -1;
			for(int i = 0; i < languages.getCount(); i++) {
				SendDlgItemMessage(hwndDlg, IDC_DEF_LANG, CB_ADDSTRING, 0, (LPARAM)languages[i]->full_name);
				SendDlgItemMessage(hwndDlg, IDC_DEF_LANG, CB_SETITEMDATA, i, (LPARAM)languages[i]);

				if ( !lstrcmp(opts.default_language, languages[i]->language))
					sel = i;
			}
			SendDlgItemMessage(hwndDlg, IDC_DEF_LANG, CB_SETCURSEL, sel, 0);

			SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Line"));
			SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Dotted"));
			SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Dash"));
			SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Dash dot"));
			SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Dash dot dot"));
			SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Wave"));
			SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Thick"));
		}
		break;

	case WM_COMMAND:
		if (LOWORD(wParam) == IDC_GETMORE)
			CallService(MS_UTILS_OPENURL, 1, (LPARAM) "http://wiki.services.openoffice.org/wiki/Dictionaries");

		if (LOWORD(wParam) == IDC_DEF_LANG && (HIWORD(wParam) == CBN_SELCHANGE && (HWND)lParam == GetFocus())) {
			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			return 0;
		}

		break;

	case WM_NOTIFY:
		{
			LPNMHDR lpnmhdr = (LPNMHDR)lParam;
			if (lpnmhdr->idFrom == 0 && lpnmhdr->code == PSN_APPLY && languages.getCount() > 0) {
				int sel = SendDlgItemMessage(hwndDlg, IDC_DEF_LANG, CB_GETCURSEL, 0, 0);
				if (sel >= languages.getCount())
					sel = 0;
				db_set_ts(NULL, MODULE_NAME, "DefaultLanguage", 
					(TCHAR *) languages[sel]->language);
				lstrcpy(opts.default_language, languages[sel]->language);
			}
		}
		break;

	case WM_DRAWITEM:
		{
			LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
			if (lpdis->CtlID != IDC_DEF_LANG) 
				break;
			if (lpdis->itemID == -1) 
				break;

			Dictionary *dict = (Dictionary *) lpdis->itemData;
			DrawItem(hwndDlg, lpdis, dict);
		}
		return TRUE;

	case WM_MEASUREITEM:
		LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam;
		if (lpmis->CtlID != IDC_DEF_LANG) 
			break;

		MeasureItem(hwndDlg, lpmis);
		return TRUE;
	}

	return SaveOptsDlgProc(optionsControls, SIZEOF(optionsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
}
Ejemplo n.º 12
0
void wxBitmapComboBox::RecreateControl()
{
    //
    // Recreate control so that WM_MEASUREITEM gets called again.
    // Can't use CBS_OWNERDRAWVARIABLE because it has odd
    // mouse-wheel behaviour.
    //
    wxString value = GetValue();
    wxPoint pos = GetPosition();
    wxSize size = GetSize();
    size.y = GetBestSize().y;
    wxArrayString strings = GetStrings();

    wxComboBox::DoClear();

    HWND hwnd = GetHwnd();
    DissociateHandle();
    ::DestroyWindow(hwnd);

    if ( !MSWCreateControl(wxT("COMBOBOX"), wxEmptyString, pos, size) )
        return;

    // initialize the controls contents
    for ( unsigned int i = 0; i < strings.size(); i++ )
    {
        wxComboBox::Append(strings[i]);
    }

    // and make sure it has the same attributes as before
    if ( m_hasFont )
    {
        // calling SetFont(m_font) would do nothing as the code would
        // notice that the font didn't change, so force it to believe
        // that it did
        wxFont font = m_font;
        m_font = wxNullFont;
        SetFont(font);
    }

    if ( m_hasFgCol )
    {
        wxColour colFg = m_foregroundColour;
        m_foregroundColour = wxNullColour;
        SetForegroundColour(colFg);
    }

    if ( m_hasBgCol )
    {
        wxColour colBg = m_backgroundColour;
        m_backgroundColour = wxNullColour;
        SetBackgroundColour(colBg);
    }
    else
    {
        SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
    }

    ::SendMessage(GetHwnd(), CB_SETITEMHEIGHT, 0, MeasureItem(0));

    // Revert the old string value
    if ( !HasFlag(wxCB_READONLY) )
        ChangeValue(value);
}
Ejemplo n.º 13
0
void CPPPropertyPage::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
	HWND hDlg = GetSafeHwnd();
	MeasureItem( hDlg, lpMeasureItemStruct, NO );
}
Ejemplo n.º 14
0
void Dialog_OnMeasureItem(HWND hDlg, MEASUREITEMSTRUCT FAR * lpMeasureItem)
/************************************************************************/
{
MeasureItem( hDlg, lpMeasureItem, NO );
}