Ejemplo n.º 1
0
// MW-2005-05-15: Updated for new answer command restructuring
bool MCA_color(MCStringRef p_title, MCColor p_initial_color, bool p_as_sheet, bool& r_chosen, MCColor& r_chosen_color)
{
	CHOOSECOLORW chooseclr ;

	memset(&chooseclr, 0, sizeof(CHOOSECOLORW));
	chooseclr.lStructSize = sizeof (CHOOSECOLORW);
	chooseclr.lpCustColors = (LPDWORD)s_colordialogcolors;

	Window t_parent_window;
	t_parent_window = MCModeGetParentWindow();
	chooseclr.hwndOwner = t_parent_window != NULL ? (HWND)t_parent_window -> handle . window : NULL;

	chooseclr.Flags = CC_RGBINIT;
	chooseclr.rgbResult = RGB(p_initial_color.red >> 8, p_initial_color.green >> 8,
	                          p_initial_color.blue >> 8);

	bool t_success = true;
	if (!ChooseColorW(&chooseclr))
	{
		DWORD err = CommDlgExtendedError();
		r_chosen = false;
	}
	else
	{
		r_chosen = true;
		r_chosen_color.red = GetRValue(chooseclr.rgbResult);
		r_chosen_color.red |= r_chosen_color.red << 8;
		r_chosen_color.green = GetGValue(chooseclr.rgbResult);
		r_chosen_color.green |= r_chosen_color.green << 8;
		r_chosen_color.blue = GetBValue(chooseclr.rgbResult);
		r_chosen_color.blue |= r_chosen_color.blue << 8;
	}

	//  SMR 1880 clear shift and button state
	waitonbutton();

	return t_success;
}
INT_PTR CALLBACK DlgProcDisplayAttr(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam, int no)
{
    HWND hwnd;
    int x, y;
    RECT rect;
    POINT pt;
    CHOOSECOLORW cc;
    PAINTSTRUCT ps;
    HDC hdc;
    static COLORREF colCust[16];

    switch(message)
    {
    case WM_INITDIALOG:
        for(int i = 0; i < _countof(cbAttrID); i++)
        {
            for(int j = 0; j < _countof(cbAttrText); j++)
            {
                SendMessageW(GetDlgItem(hDlg, cbAttrID[i]), CB_ADDSTRING, 0, (LPARAM)cbAttrText[j]);
            }
        }
        for(int i = 0; i < _countof(cbULAttrID); i++)
        {
            for(int j = 0; j < _countof(cbULAttrText); j++)
            {
                SendMessageW(GetDlgItem(hDlg, cbULAttrID[i]), CB_ADDSTRING, 0, (LPARAM)cbULAttrText[j]);
            }
        }
        for(int i = 0; i < _countof(colCust); i++)
        {
            colCust[i] = RGB(0xFF, 0xFF, 0xFF);
        }

        LoadConfigDisplayAttr(no);

        for(int i = 0; i < _countof(displayAttr[no]); i++)
        {
            if(displayAttr[no][i].se)
            {
                CheckDlgButton(hDlg, displayAttrID[i][0], BST_CHECKED);
                DisplayAttrSeriesChecked(hDlg, displayAttrID[i][0]);
            }
            switch(displayAttr[no][i].da.crText.type)
            {
            case TF_CT_NONE:
                CheckDlgButton(hDlg, displayAttrID[i][1], BST_CHECKED);
                break;
            default:
                CheckDlgButton(hDlg, displayAttrID[i][2], BST_CHECKED);
                break;
            }
            switch(displayAttr[no][i].da.crBk.type)
            {
            case TF_CT_NONE:
                CheckDlgButton(hDlg, displayAttrID[i][4], BST_CHECKED);
                break;
            default:
                CheckDlgButton(hDlg, displayAttrID[i][5], BST_CHECKED);
                break;
            }
            SendMessageW(GetDlgItem(hDlg, displayAttrID[i][7]), CB_SETCURSEL, displayAttr[no][i].da.lsStyle, 0);
            CheckDlgButton(hDlg, displayAttrID[i][8], (displayAttr[no][i].da.fBoldLine ? BST_CHECKED : BST_UNCHECKED));
            switch(displayAttr[no][i].da.crLine.type)
            {
            case TF_CT_NONE:
                CheckDlgButton(hDlg, displayAttrID[i][9], BST_CHECKED);
                break;
            default:
                CheckDlgButton(hDlg, displayAttrID[i][10], BST_CHECKED);
                break;
            }
            SendMessageW(GetDlgItem(hDlg, displayAttrID[i][12]), CB_SETCURSEL, displayAttr[no][i].da.bAttr, 0);
        }

        return TRUE;

    case WM_COMMAND:
        switch(LOWORD(wParam))
        {
        case IDC_CHECKBOX_SERIES_MARK:
        case IDC_CHECKBOX_SERIES_TEXT:
        case IDC_CHECKBOX_SERIES_OKURI:
        case IDC_CHECKBOX_SERIES_ANNOT:
            DisplayAttrSeriesChecked(hDlg, LOWORD(wParam));
        //no break;
        case IDC_RADIO_FG_STD_MARK:
        case IDC_RADIO_FG_STD_TEXT:
        case IDC_RADIO_FG_STD_OKURI:
        case IDC_RADIO_FG_STD_ANNOT:
        case IDC_RADIO_FG_SEL_MARK:
        case IDC_RADIO_FG_SEL_TEXT:
        case IDC_RADIO_FG_SEL_OKURI:
        case IDC_RADIO_FG_SEL_ANNOT:
        case IDC_RADIO_BG_STD_MARK:
        case IDC_RADIO_BG_STD_TEXT:
        case IDC_RADIO_BG_STD_OKURI:
        case IDC_RADIO_BG_STD_ANNOT:
        case IDC_RADIO_BG_SEL_MARK:
        case IDC_RADIO_BG_SEL_TEXT:
        case IDC_RADIO_BG_SEL_OKURI:
        case IDC_RADIO_BG_SEL_ANNOT:
        case IDC_CHECKBOX_UL_BOLD_MARK:
        case IDC_CHECKBOX_UL_BOLD_TEXT:
        case IDC_CHECKBOX_UL_BOLD_OKURI:
        case IDC_CHECKBOX_UL_BOLD_ANNOT:
        case IDC_RADIO_UL_STD_MARK:
        case IDC_RADIO_UL_STD_TEXT:
        case IDC_RADIO_UL_STD_OKURI:
        case IDC_RADIO_UL_STD_ANNOT:
        case IDC_RADIO_UL_SEL_MARK:
        case IDC_RADIO_UL_SEL_TEXT:
        case IDC_RADIO_UL_SEL_OKURI:
        case IDC_RADIO_UL_SEL_ANNOT:
            PropSheet_Changed(GetParent(hDlg), hDlg);
            return TRUE;

        case IDC_COMBO_UL_ATTR_MARK:
        case IDC_COMBO_UL_ATTR_TEXT:
        case IDC_COMBO_UL_ATTR_OKURI:
        case IDC_COMBO_UL_ATTR_ANNOT:
        case IDC_COMBO_ATTR_MARK:
        case IDC_COMBO_ATTR_TEXT:
        case IDC_COMBO_ATTR_OKURI:
        case IDC_COMBO_ATTR_ANNOT:
            switch(HIWORD(wParam))
            {
            case CBN_SELCHANGE:
                PropSheet_Changed(GetParent(hDlg), hDlg);
                return TRUE;
            default:
                break;
            }
            break;

        default:
            break;
        }
        break;

    case WM_LBUTTONDOWN:
        for(int i = 0; i < _countof(displayAttrColor[no]); i++)
        {
            for(int j = 0; j < _countof(displayAttrColor[no][i]); j++)
            {
                hwnd = GetDlgItem(hDlg, displayAttrColor[no][i][j].id);
                if(!IsWindowEnabled(hwnd))
                {
                    continue;
                }
                GetWindowRect(hwnd, &rect);
                pt.x = x = GET_X_LPARAM(lParam);
                pt.y = y = GET_Y_LPARAM(lParam);
                ClientToScreen(hDlg, &pt);

                if(rect.left <= pt.x && pt.x <= rect.right &&
                        rect.top <= pt.y && pt.y <= rect.bottom)
                {
                    cc.lStructSize = sizeof(cc);
                    cc.hwndOwner = hDlg;
                    cc.hInstance = nullptr;
                    cc.rgbResult = *displayAttrColor[no][i][j].color;
                    cc.lpCustColors = colCust;
                    cc.Flags = CC_FULLOPEN | CC_RGBINIT;
                    cc.lCustData = 0;
                    cc.lpfnHook = nullptr;
                    cc.lpTemplateName = nullptr;
                    if(ChooseColorW(&cc))
                    {
                        DrawSelectColor(hDlg, displayAttrColor[no][i][j].id, cc.rgbResult);
                        *displayAttrColor[no][i][j].color = cc.rgbResult;
                        PropSheet_Changed(GetParent(hDlg), hDlg);
                        return TRUE;
                    }
                    break;
                }
            }
        }
        break;

    case WM_PAINT:
        hdc = BeginPaint(hDlg, &ps);
        for(int i = 0; i < _countof(displayAttrColor[no]); i++)
        {
            for(int j = 0; j < _countof(displayAttrColor[no][i]) && displayAttr[no][i].key != nullptr; j++)
            {
                DrawSelectColor(hDlg, displayAttrColor[no][i][j].id, *displayAttrColor[no][i][j].color);
            }
        }
        EndPaint(hDlg, &ps);

        return TRUE;

    case WM_NOTIFY:
        switch(((LPNMHDR)lParam)->code)
        {
        case PSN_APPLY:
            for(int i = 0; i < _countof(displayAttr[no]); i++)
            {
                displayAttr[no][i].se =
                    (IsDlgButtonChecked(hDlg, displayAttrID[i][0]) == BST_CHECKED ? TRUE : FALSE);
                displayAttr[no][i].da.crText.type =
                    (IsDlgButtonChecked(hDlg, displayAttrID[i][2]) == BST_CHECKED ? TF_CT_COLORREF : TF_CT_NONE);
                displayAttr[no][i].da.crBk.type =
                    (IsDlgButtonChecked(hDlg, displayAttrID[i][5]) == BST_CHECKED ? TF_CT_COLORREF : TF_CT_NONE);
                displayAttr[no][i].da.lsStyle =
                    (TF_DA_LINESTYLE)SendMessageW(GetDlgItem(hDlg, displayAttrID[i][7]), CB_GETCURSEL, 0, 0);
                displayAttr[no][i].da.fBoldLine =
                    (IsDlgButtonChecked(hDlg, displayAttrID[i][8]) == BST_CHECKED ? TRUE : FALSE);
                displayAttr[no][i].da.crLine.type =
                    (IsDlgButtonChecked(hDlg, displayAttrID[i][10]) == BST_CHECKED ? TF_CT_COLORREF : TF_CT_NONE);
                displayAttr[no][i].da.bAttr =
                    (TF_DA_ATTR_INFO)SendMessageW(GetDlgItem(hDlg, displayAttrID[i][12]), CB_GETCURSEL, 0, 0);
            }
            SaveConfigDisplayAttr(no);
            return TRUE;
        default:
            break;
        }
        break;

    default:
        break;
    }

    return FALSE;
}
Ejemplo n.º 3
0
INT_PTR CALLBACK
ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
        case WM_INITDIALOG:
            read_shell_folder_link_targets();
            init_shell_folder_listview_headers(hDlg);
            update_shell_folder_listview(hDlg);
            read_sysparams(hDlg);
            break;
        
        case WM_DESTROY:
            free_theme_files();
            break;

        case WM_SHOWWINDOW:
            set_window_title(hDlg);
            break;
            
        case WM_COMMAND:
            switch(HIWORD(wParam)) {
                case CBN_SELCHANGE: {
                    if (updating_ui) break;
                    switch (LOWORD(wParam))
                    {
                        case IDC_THEME_THEMECOMBO: on_theme_changed(hDlg); break;
                        case IDC_THEME_COLORCOMBO: /* fall through */
                        case IDC_THEME_SIZECOMBO: theme_dirty = TRUE; break;
                        case IDC_SYSPARAM_COMBO: on_sysparam_change(hDlg); return FALSE;
                    }
                    SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
                    break;
                }
                case EN_CHANGE: {
                    if (updating_ui) break;
                    switch (LOWORD(wParam))
                    {
                        case IDC_EDIT_SFPATH: on_shell_folder_edit_changed(hDlg); break;
                        case IDC_SYSPARAM_SIZE:
                        {
                            char *text = get_text(hDlg, IDC_SYSPARAM_SIZE);
                            int index = SendDlgItemMessageW(hDlg, IDC_SYSPARAM_COMBO, CB_GETCURSEL, 0, 0);

                            index = SendDlgItemMessageW(hDlg, IDC_SYSPARAM_COMBO, CB_GETITEMDATA, index, 0);

                            if (text)
                            {
                                metrics[index].size = atoi(text);
                                HeapFree(GetProcessHeap(), 0, text);
                            }
                            else
                            {
                                /* for empty string set to minimum value */
                                SendDlgItemMessageW(hDlg, IDC_SYSPARAM_SIZE_UD, UDM_GETRANGE32, (WPARAM)&metrics[index].size, 0);
                            }

                            SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
                            break;
                        }
                    }
                    break;
                }
                case BN_CLICKED:
                    switch (LOWORD(wParam))
                    {
                        case IDC_THEME_INSTALL:
                            on_theme_install (hDlg);
                            break;

                        case IDC_SYSPARAM_FONT:
                            on_select_font(hDlg);
                            break;

                        case IDC_BROWSE_SFPATH:
                        {
                            WCHAR link[FILENAME_MAX];
                            if (browse_for_unix_folder(hDlg, link)) {
                                WideCharToMultiByte(CP_UNIXCP, 0, link, -1,
                                                    psfiSelected->szLinkTarget, FILENAME_MAX,
                                                    NULL, NULL);
                                update_shell_folder_listview(hDlg);
                                SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
                            }
                            break;
                        }

                        case IDC_LINK_SFPATH:
                            if (IsDlgButtonChecked(hDlg, IDC_LINK_SFPATH)) {
                                WCHAR link[FILENAME_MAX];
                                if (browse_for_unix_folder(hDlg, link)) {
                                    WideCharToMultiByte(CP_UNIXCP, 0, link, -1,
                                                        psfiSelected->szLinkTarget, FILENAME_MAX,
                                                        NULL, NULL);
                                    update_shell_folder_listview(hDlg);
                                    SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
                                } else {
                                    CheckDlgButton(hDlg, IDC_LINK_SFPATH, BST_UNCHECKED);
                                }
                            } else {
                                psfiSelected->szLinkTarget[0] = '\0';
                                update_shell_folder_listview(hDlg);
                                SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
                            }
                            break;    

                        case IDC_SYSPARAM_COLOR:
                        {
                            static COLORREF user_colors[16];
                            CHOOSECOLORW c_color;
                            int index = SendDlgItemMessageW(hDlg, IDC_SYSPARAM_COMBO, CB_GETCURSEL, 0, 0);

                            index = SendDlgItemMessageW(hDlg, IDC_SYSPARAM_COMBO, CB_GETITEMDATA, index, 0);

                            memset(&c_color, 0, sizeof(c_color));
                            c_color.lStructSize = sizeof(c_color);
                            c_color.lpCustColors = user_colors;
                            c_color.rgbResult = metrics[index].color;
                            c_color.Flags = CC_ANYCOLOR | CC_RGBINIT;
                            c_color.hwndOwner = hDlg;
                            if (ChooseColorW(&c_color))
                            {
                                metrics[index].color = c_color.rgbResult;
                                save_sys_color(index, metrics[index].color);
                                InvalidateRect(GetDlgItem(hDlg, IDC_SYSPARAM_COLOR), NULL, TRUE);
                                SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
                            }
                            break;
                        }
                    }
                    break;
            }
            break;
        
        case WM_NOTIFY:
            switch (((LPNMHDR)lParam)->code) {
                case PSN_KILLACTIVE: {
                    SetWindowLongPtrW(hDlg, DWLP_MSGRESULT, FALSE);
                    break;
                }
                case PSN_APPLY: {
                    apply();
                    apply_theme(hDlg);
                    apply_shell_folder_changes();
                    apply_sysparams();
                    read_shell_folder_link_targets();
                    update_shell_folder_listview(hDlg);
                    SetWindowLongPtrW(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
                    break;
                }
                case LVN_ITEMCHANGED: { 
                    if (wParam == IDC_LIST_SFPATHS)  
                        on_shell_folder_selection_changed(hDlg, (LPNMLISTVIEW)lParam);
                    break;
                }
                case PSN_SETACTIVE: {
                    init_dialog (hDlg);
                    break;
                }
            }
            break;

        case WM_DRAWITEM:
            on_draw_item(hDlg, wParam, lParam);
            break;

        default:
            break;
    }
    return FALSE;
}
BOOL AP_Win32Dialog_FormatFrame::_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	WORD wNotifyCode = HIWORD(wParam);
	WORD wId = LOWORD(wParam);

	switch (wId)
	{			
		case AP_RID_DIALOG_FORMATFRAME_BMP_BOTTOM:		
		{
			bool bChecked;			
			bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_BMP_BOTTOM)==BST_CHECKED);							
			toggleLineType(AP_Dialog_FormatFrame::toggle_bottom, bChecked);				
			event_previewExposed();			
			return 1;
		}			
		
		case AP_RID_DIALOG_FORMATFRAME_BMP_TOP:		
		{
			bool bChecked;			
			bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_BMP_TOP)==BST_CHECKED);							
			toggleLineType(AP_Dialog_FormatFrame::toggle_top, bChecked);				
			event_previewExposed();			
			return 1;
		}	
		
		case AP_RID_DIALOG_FORMATFRAME_BMP_RIGHT:		
		{
			bool bChecked;			
			bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_BMP_RIGHT)==BST_CHECKED);							
			toggleLineType(AP_Dialog_FormatFrame::toggle_right, bChecked);				
			event_previewExposed();			
			return 1;
		}			
		
		case AP_RID_DIALOG_FORMATFRAME_BMP_LEFT:		
		{
			bool bChecked;			
			bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_BMP_LEFT)==BST_CHECKED);							
			toggleLineType(AP_Dialog_FormatFrame::toggle_left, bChecked);				
			event_previewExposed();			
			return 1;
		}	
		 
		 
		case AP_RID_DIALOG_FORMATFRAME_BTN_BORDERCOLOR:		
		{	
			CHOOSECOLORW cc;                
			static COLORREF acrCustClr[16];
			
			/* Initialize CHOOSECOLOR */
			ZeroMemory(&cc, sizeof(CHOOSECOLORW));
			cc.lStructSize = sizeof(CHOOSECOLORW);
			cc.hwndOwner = m_hDlg;
			cc.lpCustColors = (LPDWORD) acrCustClr;
			cc.rgbResult = 0;
			cc.Flags = CC_FULLOPEN | CC_RGBINIT;
		 
			if(ChooseColorW(&cc))			
			{
				setBorderColor(UT_RGBColor(GetRValue( cc.rgbResult), GetGValue(cc.rgbResult), GetBValue(cc.rgbResult)));		
				m_borderButton.setColour(cc.rgbResult);

				/*Force redraw*/
				InvalidateRect(GetDlgItem(hWnd, AP_RID_DIALOG_FORMATFRAME_BTN_BORDERCOLOR), NULL, FALSE);
				event_previewExposed();	
			}

			return 1;
		}	
		
		
		case AP_RID_DIALOG_FORMATFRAME_BTN_BACKCOLOR:		
		{	
			CHOOSECOLORW cc;               
			static COLORREF acrCustClr2[16];
			
			/* Initialize CHOOSECOLOR */
			ZeroMemory(&cc, sizeof(CHOOSECOLORW));
			cc.lStructSize = sizeof(CHOOSECOLORW);
			cc.hwndOwner = m_hDlg;
			cc.lpCustColors = (LPDWORD) acrCustClr2;
			cc.rgbResult = 0;
			cc.Flags = CC_FULLOPEN | CC_RGBINIT;
		 
			if(ChooseColorW(&cc))			
			{
				setBGColor(UT_RGBColor(GetRValue( cc.rgbResult), GetGValue(cc.rgbResult), GetBValue(cc.rgbResult)));						
				m_backgButton.setColour(cc.rgbResult);

				/*Force redraw*/
				InvalidateRect(GetDlgItem(hWnd, AP_RID_DIALOG_FORMATFRAME_BTN_BACKCOLOR), NULL, FALSE);
				event_previewExposed();	
			}

			return 1;
		}			

		case AP_RID_DIALOG_FORMATFRAME_CHK_TEXTWRAP:
		{
			bool bChecked;
			bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_CHK_TEXTWRAP)==BST_CHECKED);

			setWrapping(bChecked);

			// Not necessary now, but we may some day show
			// text wrapping in the preview.
			event_previewExposed();
			return 1;
		}

			
		case AP_RID_DIALOG_FORMATFRAME_BTN_CANCEL:			
			m_answer = AP_Dialog_FormatFrame::a_CLOSE;
			destroy();
			event_Close();
			EndDialog(hWnd,0);
			return 1;

		case AP_RID_DIALOG_FORMATFRAME_COMBO_THICKNESS:
		{
			if (wNotifyCode == CBN_SELCHANGE)                       
			{
				int nSelected = getComboSelectedIndex (AP_RID_DIALOG_FORMATFRAME_COMBO_THICKNESS);

				if (nSelected != CB_ERR)
				{
					UT_LocaleTransactor t(LC_NUMERIC, "C");					
					UT_Win32LocaleString thickness;
					UT_UTF8String thickness_utf8 = thickness.utf8_str ();
					getComboTextItem(AP_RID_DIALOG_FORMATFRAME_COMBO_THICKNESS, nSelected, thickness);
					setBorderThicknessAll(thickness_utf8);					
					event_previewExposed();
				}
			}
			return 1;
		}

		case AP_RID_DIALOG_FORMATFRAME_BUTTON_SELIMAGE:
				askForGraphicPathName();
				return 1;

		case AP_RID_DIALOG_FORMATFRAME_BUTTON_NOIMAGE:
				clearImage();
				return 1;

		case AP_RID_DIALOG_FORMATFRAME_RADIO_PARA:
				setPositionMode(FL_FRAME_POSITIONED_TO_BLOCK);
				return 1;

		case AP_RID_DIALOG_FORMATFRAME_RADIO_COLUMN:
				setPositionMode(FL_FRAME_POSITIONED_TO_COLUMN);
				return 1;

		case AP_RID_DIALOG_FORMATFRAME_RADIO_PAGE:
				setPositionMode(FL_FRAME_POSITIONED_TO_PAGE);
				return 1;

		case AP_RID_DIALOG_FORMATFRAME_BTN_APPLY:
				applyChanges();
				return 1;

		
			
		default:							// we did not handle this notification 
			UT_DEBUGMSG(("WM_Command for id %ld\n",wId));
			return 0;						// return zero to let windows take care of it.
	}
}