Пример #1
0
/* ===========                                 */
int EXPORT FAR PASCAL  FontDlgProc (HWND hDlg, UINT wMsg, UINT wParam,
				    LONG lParam)
{
    switch (wMsg) {
        
    case WM_INITDIALOG:
        hNewFont = NULL;
	{   /*-setup the dialog box's caption */
	    char    s[40];

	    strcpy (s, ProgName);
	    strcat (s, " - Font selection");
	    SetWindowText (hDlg, s);
	}
	/*-set the Bold button */
	GetFontMetrics (hEmacsFont, &Metrics, FaceName);
	CheckDlgButton (hDlg, ID_BOLD, (Metrics.tmWeight > 550));
	{   /*-simulate a mouse click on the appropriate charset
	       radiobutton. This will initialize all the other controls
	       */
	    WORD    id;
	    
	    id = (Metrics.tmCharSet == ANSI_CHARSET ? ID_ANSI : ID_OEM);
	    SendMessage (hDlg, WM_COMMAND,
#if WINDOW_MSWIN32
                         MAKELONG(id, BN_CLICKED), (long)GetDlgItem (hDlg, id));
#else
                         id, MAKELONG(GetDlgItem (hDlg, id), BN_CLICKED));
#endif
	}
        return TRUE;

    case WM_COMMAND:
	switch (LOWORD(wParam)) {
	case 1:     /* OK button */
	    if (NOTIFICATION_CODE == BN_CLICKED) {
AcceptFont:
		if (hEmacsFont) DeleteObject (hEmacsFont);
		hEmacsFont = hNewFont;
		EndDialog (hDlg, TRUE);
		/* no need to unhook the SAMPLE's font, it is not
		   destroyed since it will be used by emacs */
	    }
	    else return FALSE;
	    break;
	case 2:     /* Cancel button */
	    if (NOTIFICATION_CODE == BN_CLICKED) goto CancelFont;
	    else return FALSE;
	case ID_SAVEFONT:
	    if (NOTIFICATION_CODE == BN_CLICKED) {
		/*-save the facename, bold status and size into WIN.INI,
		   then perform as the OK button */
		char    NumText[17];
		    
		GetFontMetrics (hNewFont, &Metrics, FaceName);
		WriteProfileString (ProgName, "FontName", FaceName);
		WriteProfileString (ProgName, "CharSet",
		                    itoa (Metrics.tmCharSet, NumText, 10));
		WriteProfileString (ProgName, "FontHeight",
		                    itoa (Metrics.tmHeight, NumText, 10));
		WriteProfileString (ProgName, "FontWidth",
		                    itoa (Metrics.tmAveCharWidth,
                                          NumText, 10));
		WriteProfileString (ProgName, "FontWeight",
		                    itoa (Metrics.tmWeight, NumText, 10));
            }
	    else return FALSE;
	    goto AcceptFont;
	case ID_ANSI:
	case ID_OEM:
	    if (NOTIFICATION_CODE == BN_CLICKED) {
	        CheckRadioButton (hDlg, ID_1ST_CHARSET, ID_LAST_CHARSET,
                                  LOWORD(wParam));
		BuildFaceList (hDlg, FaceName);
	    }
	    else return FALSE;
	    break;
	case ID_BOLD:
	    if (NOTIFICATION_CODE == BN_CLICKED) NewFont (hDlg, TRUE);
	    else return FALSE;
	    break;
	case ID_FONT:
	    switch (NOTIFICATION_CODE) {
	    case LBN_SELCHANGE:
		BuildSizeList (hDlg, &Metrics);
		break;
	    case LBN_DBLCLK:    /* treated as OK */
		goto AcceptFont;
	    default:
		return FALSE;
	    }
	    break;
	case ID_FONTSIZE:
	    switch (NOTIFICATION_CODE) {
	    case CBN_SELCHANGE:
		NewFont (hDlg, FALSE);
		break;
	    case CBN_EDITCHANGE:
	        {
		    BOOL    FontSizeOK;

		    GetDlgItemInt (hDlg, ID_FONTSIZE, &FontSizeOK, FALSE);
		    if (FontSizeOK) NewFont (hDlg, TRUE);
		    else MessageBeep (0);
		}
		break;
	    case CBN_DBLCLK:    /* treated as OK */
		goto AcceptFont;
	    default:
		return FALSE;
	    }
	    break;
	default:
	    return FALSE;
        }
	break;
    case WM_SYSCOMMAND:
	if ((wParam & 0xFFF0) == SC_CLOSE) {
CancelFont:
	    EndDialog (hDlg, FALSE);
	    if (hNewFont) {
		SendDlgItemMessage (hDlg, ID_SAMPLE, WM_SETFONT, 0, FALSE);
		    /* reset to SYSTEM_FONT before deleting the font */
		DeleteObject (hNewFont);
	    }
	    return TRUE;
	}
	return FALSE;
    default:
	return FALSE;
    }
    return FALSE;
} /* FontDlgProc */
Пример #2
0
 /// Return the current list of conforming and nonconforming faces.
 const NCList& GetFaceList()
 {
    if (face_list.Empty()) { BuildFaceList(); }
    return face_list;
 }