BOOL XAP_Win32Dialog_HTMLOptions::_onInitDialog(HWND /*hWnd*/, WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	localizeDialogTitle(XAP_STRING_ID_DLG_HTMLOPT_ExpTitle);

	// localize controls
	localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_LBL,			XAP_STRING_ID_DLG_HTMLOPT_ExpLabel);
	localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_HTML4,	XAP_STRING_ID_DLG_HTMLOPT_ExpIs4);
	localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_PHP,		XAP_STRING_ID_DLG_HTMLOPT_ExpAbiWebDoc);
	localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_XML,		XAP_STRING_ID_DLG_HTMLOPT_ExpDeclareXML);
	localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_AWML,	XAP_STRING_ID_DLG_HTMLOPT_ExpAllowAWML);
	localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_EMBEDCSS,XAP_STRING_ID_DLG_HTMLOPT_ExpEmbedCSS);
	localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_URLIMAGE,XAP_STRING_ID_DLG_HTMLOPT_ExpEmbedImages);
	localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_PNGMATHML,XAP_STRING_ID_DLG_HTMLOPT_ExpMathMLRenderPNG);
	localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_CHK_SPLITFILE,XAP_STRING_ID_DLG_HTMLOPT_ExpSplitDocument);
	localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_BTN_SAVE,	XAP_STRING_ID_DLG_HTMLOPT_ExpSave);
	localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_BTN_RESTORE,	XAP_STRING_ID_DLG_HTMLOPT_ExpRestore);
	localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_BTN_OK,		XAP_STRING_ID_DLG_OK);
	localizeControlText(XAP_RID_DIALOG_HTMLOPTIONS_BTN_CANCEL,	XAP_STRING_ID_DLG_Cancel);

	// Set Initial conditions
	refreshStates();
	centerDialog();
	
	return 1;							// 1 == we did not call SetFocus()
}
Exemplo n.º 2
0
void abiSetupModalDialog(GtkDialog * dialog, XAP_Frame *pFrame, XAP_Dialog * pDlg, gint defaultResponse)
{
	GtkWidget *popup = GTK_WIDGET (dialog);
	gtk_dialog_set_default_response (GTK_DIALOG (popup), defaultResponse);
	gtk_window_set_modal (GTK_WINDOW(popup), TRUE);

	// To center the dialog, we need the frame of its parent.
	if (pFrame)
	{
		XAP_UnixFrameImpl * pUnixFrameImpl = static_cast<XAP_UnixFrameImpl *>(pFrame->getFrameImpl());
		GtkWidget * parentWindow = pUnixFrameImpl->getTopLevelWindow();
		if (GTK_IS_WINDOW(parentWindow) != TRUE)
			parentWindow  = gtk_widget_get_parent(parentWindow);
		centerDialog (parentWindow, GTK_WIDGET(popup));
	}
	connectFocus (GTK_WIDGET(popup), pFrame);

	// connect F1 to the help subsystem
	g_signal_connect (G_OBJECT(popup), "key-press-event",
					  G_CALLBACK(modal_keypress_cb), pDlg);
	
	// set the default response
	sAddHelpButton (GTK_DIALOG (popup), pDlg);

	// show the window
	gtk_widget_show (GTK_WIDGET (popup));
}
Exemplo n.º 3
0
BOOL XAP_Win32Dialog_Zoom::_onInitDialog(HWND hWnd, WPARAM /*wParam*/, LPARAM /*lParam*/)
{		
	const XAP_StringSet* pSS = m_pApp->getStringSet();

	// Update the caption
	setDialogTitle(pSS->getValue(XAP_STRING_ID_DLG_Zoom_ZoomTitle));

	// localize controls
	_DSX(ZOOM_BTN_CLOSE,		DLG_Close);
	_DS(ZOOM_TEXT_ZOOMTO,		DLG_Zoom_RadioFrameCaption);
	_DS(ZOOM_RADIO_200,		DLG_Zoom_200);
	_DS(ZOOM_RADIO_100,		DLG_Zoom_100);
	_DS(ZOOM_RADIO_75,		DLG_Zoom_75);
	_DS(ZOOM_RADIO_WIDTH,		DLG_Zoom_PageWidth);
	_DS(ZOOM_RADIO_WHOLE,		DLG_Zoom_WholePage);
	_DS(ZOOM_RADIO_PCT,		DLG_Zoom_Percent);

	// set initial state
	checkButton(XAP_RID_DIALOG_ZOOM_RADIO_200 + m_zoomType);
	setControlInt(XAP_RID_DIALOG_ZOOM_EDIT_PCT, (UINT) m_zoomPercent);
	m_bEditPctEnabled = ((XAP_RID_DIALOG_ZOOM_RADIO_200 + m_zoomType) == XAP_RID_DIALOG_ZOOM_RADIO_PCT);
	enableControl(XAP_RID_DIALOG_ZOOM_EDIT_PCT ,m_bEditPctEnabled);
	
	SendMessageW(GetDlgItem(hWnd,XAP_RID_DIALOG_ZOOM_SPIN_PCT),UDM_SETRANGE,
				(WPARAM)0,(LPARAM)MAKELONG(XAP_DLG_ZOOM_MAXIMUM_ZOOM,XAP_DLG_ZOOM_MINIMUM_ZOOM));
		
	_updatePreviewZoomPercent(getZoomPercent());
	
	centerDialog();	
	
	return 1;							// 1 == we did not call SetFocus()
}
// This handles the WM_INITDIALOG message for the top-level dialog.
BOOL AP_Win32Dialog_SplitCells::_onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
{	
	HDC hdc;
	int x, y;	
	RECT rect;
	DWORD dwColor = GetSysColor(COLOR_BTNFACE);	
	UT_RGBColor Color(GetRValue(dwColor),GetGValue(dwColor),GetBValue(dwColor));
	const XAP_StringSet * pSS = m_pApp->getStringSet();
	
	// Localise caption
	setDialogTitle (pSS->getValue(AP_STRING_ID_DLG_SplitCellsTitle));


	// localise controls 		
	_DS(TEXT_LEFT,		DLG_SplitCells_Left);
	_DS(TEXT_VERTMID,	DLG_SplitCells_VertMid);
	_DS(TEXT_RIGHT,		DLG_SplitCells_Right);		
	_DS(TEXT_ABOVE,		DLG_SplitCells_Above);
	_DS(TEXT_HORIMID,	DLG_SplitCells_HoriMid);
	_DS(TEXT_BELOW,		DLG_SplitCells_Below);		
	_DS(TEXT_FRAME,		DLG_SplitCells_Frame);		
	_DSX(BTN_CANCEL,	DLG_Close);				
				

	// The six items are the same size
	GetClientRect(GetDlgItem(hWnd, AP_RID_DIALOG_SPLITCELLS_BMP_LEFT), &rect);			
		
	hdc = GetDC(hWnd);
	x = rect.right - rect.left,
	y = rect.bottom - rect.top,
	
	// Load the bitmaps into the dialog box								
    m_hBitmapLeft = _loadBitmap(hWnd,AP_RID_DIALOG_SPLITCELLS_BMP_LEFT, "SPLITLEFT",  BITMAP_WITDH, BITMAP_HEIGHT, Color);
	m_hBitmapRight = _loadBitmap(hWnd,AP_RID_DIALOG_SPLITCELLS_BMP_VERTMID, "SPLITVERTMID", BITMAP_WITDH, BITMAP_HEIGHT, Color);
    m_hBitmapRight = _loadBitmap(hWnd,AP_RID_DIALOG_SPLITCELLS_BMP_RIGHT, "SPLITRIGHT", BITMAP_WITDH, BITMAP_HEIGHT, Color);
    m_hBitmapAbove = _loadBitmap(hWnd,AP_RID_DIALOG_SPLITCELLS_BMP_ABOVE, "SPLITABOVE", BITMAP_WITDH, BITMAP_HEIGHT, Color);
	m_hBitmapAbove = _loadBitmap(hWnd,AP_RID_DIALOG_SPLITCELLS_BMP_HORIMID, "SPLITHORIMID", BITMAP_WITDH, BITMAP_HEIGHT, Color);
    m_hBitmapBelow = _loadBitmap(hWnd,AP_RID_DIALOG_SPLITCELLS_BMP_BELOW, "SPLITBELOW", BITMAP_WITDH, BITMAP_HEIGHT, Color);
	
	setAllSensitivities();
	centerDialog();	
	
	SetFocus(GetDlgItem(hWnd,AP_RID_DIALOG_SPLITCELLS_BTN_CANCEL));
	return 0; // 0 because we called SetFocus
}
BOOL AP_Win32Dialog_InsertHyperlink::_onInitDialog(HWND hWnd, WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	const XAP_StringSet* pSS = m_pApp->getStringSet();

	// Update the caption
	setDialogTitle(pSS->getValue(AP_STRING_ID_DLG_InsertHyperlink_Title));

	/* Localise controls*/
	_DSX(INSERTHYPERLINK_BTN_OK,			DLG_OK);
	_DSX(INSERTHYPERLINK_BTN_CANCEL,		DLG_Cancel);
	_DS(INSERTHYPERLINK_LBL_MSG,			DLG_InsertHyperlink_Msg);

	// initial data
	resetContent(AP_RID_DIALOG_INSERTHYPERLINK_LBX_LINK);

	UT_uint32 count = getExistingBookmarksCount();
	for( UT_uint32 i = 0; i < count; i++)
	{
		addItemToList( AP_RID_DIALOG_INSERTHYPERLINK_LBX_LINK,
                       getNthExistingBookmark( i ) );
	}

	SetFocus(GetDlgItem(hWnd,AP_RID_DIALOG_INSERTHYPERLINK_EBX_LINK));

	const gchar * hyperlink = getHyperlink();

	if(hyperlink)
	{
		if(hyperlink[0]=='#')  //ignore the anchor for internal bookmarks
		{
			setControlText(AP_RID_DIALOG_INSERTHYPERLINK_EBX_LINK, hyperlink+1);
		}
		else
		{
			setControlText(AP_RID_DIALOG_INSERTHYPERLINK_EBX_LINK, hyperlink);
		}
		selectControlText(AP_RID_DIALOG_INSERTHYPERLINK_EBX_LINK, 0, -1);
	}

	centerDialog();	
	return 0; // 0 because we called set focus
}
// This handles the WM_INITDIALOG message for the top-level dialog.
BOOL AP_Win32Dialog_MailMerge::_onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
{		
	
	
	const XAP_StringSet * pSS = m_pApp->getStringSet();
	
	// Localise Controls
	_DS(STATIC_AVAIL,	DLG_MailMerge_AvailableFields);		
	_DS(STATIC_FIELD,	DLG_MailMerge_Insert_No_Colon);		
	_DS(BTN_OPEN,		DLG_MailMerge_OpenFile);		
	_DS(BTN_INSERT,		DLG_InsertButton);		
	_DSX(BTN_CLOSE,		DLG_Close);				
	
	setDialogTitle (pSS->getValue(AP_STRING_ID_DLG_MailMerge_MailMergeTitle));	
	
	centerDialog();	
	
	SetFocus(GetDlgItem(hWnd,AP_RID_DIALOG_MAILMERGE_BTN_CLOSE));
	return 0; // 0 because we called SetFocus
}
BOOL AP_Win32Dialog_Annotation::_onInitDialog(HWND /*hWnd*/, WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	const XAP_StringSet * pSS = m_pApp->getStringSet();

	setDialogTitle(pSS->getValue(AP_STRING_ID_DLG_Annotation_Title));
	
	// localize controls
	_DSX(BTN_OK,			DLG_OK);
	_DSX(BTN_CANCEL,		DLG_Cancel);
	_DS(TEXT_TITLE,			DLG_Annotation_Title_LBL);
	_DS(TEXT_AUTHOR,		DLG_Annotation_Author_LBL);
	_DS(TEXT_DESCRIPTION,	DLG_Annotation_Description_LBL);

	_set_text(AP_RID_DIALOG_ANNOTATION_EDIT_TITLE, getTitle ());
	_set_text(AP_RID_DIALOG_ANNOTATION_EDIT_AUTHOR, getAuthor ());
	_set_text(AP_RID_DIALOG_ANNOTATION_EDIT_DESCRIPTION, getDescription ());

	centerDialog();
	return 1;							// 1 == we did not call SetFocus()
}
BOOL XAP_Win32Dialog_DocComparison::_onInitDialog(HWND hWnd, WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	// set the window title
	setDialogTitle (getWindowLabel());	
	
	// localize buttons
	setDlgItemText(XAP_RID_DIALOG_DOCCOMPARISON_BTN_OK,getButtonLabel());

	// set frame titles
	setDlgItemText(XAP_RID_DIALOG_DOCCOMPARISON_FRAME1,getFrame1Label());
	setDlgItemText(XAP_RID_DIALOG_DOCCOMPARISON_FRAME2,getFrame2Label());

	// fill frame 1
	char * p = getPath1();
	if (!p) p = g_strdup("FIXME: Invalid Path1");
    setDlgItemText(XAP_RID_DIALOG_DOCCOMPARISON_PATH1,p);
	FREEP(p);

	p = getPath2();
	if (!p) p = g_strdup("FIXME: Invalid Path2");
	setDlgItemText(XAP_RID_DIALOG_DOCCOMPARISON_PATH2,p);
	FREEP(p);
	
	// fill frame 2
	UT_uint32 i;
	UT_uint32 k1 = XAP_RID_DIALOG_DOCCOMPARISON_LABEL_RELATIONSHIP;
	UT_uint32 k2 = XAP_RID_DIALOG_DOCCOMPARISON_RELATIONSHIP;
								  
	for(i = 0; i < getResultCount(); i++)
	{
		setDlgItemText(k1 + i,getResultLabel(i));
		
		char * t = getResultValue(i);
		setDlgItemText(k2 + i, t);
		FREEP(t);
	}

    centerDialog();
	return 1;							// 1 == we did not call SetFocus()
}
BOOL AP_Win32Dialog_Stylist::_onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	const XAP_StringSet * pSS = m_pApp->getStringSet();
    //localize Caption
  	
	setDialogTitle(pSS->getValue(AP_STRING_ID_DLG_Stylist_Title));	
			
	// localize controls
	_DSX(BTN_OK,		DLG_OK);
	_DSX(BTN_CANCEL,	DLG_Close);

	_DS(TEXT_STYLES,	DLG_Stylist_Styles);

	_populateWindowData();

	HWND hTree = GetDlgItem(m_hDlg, AP_RID_DIALOG_STYLIST_TREE_STYLIST);
	hTreeProc = (WHICHPROC) GetWindowLongPtrW(hTree, GWLP_WNDPROC); // save off our prior callback
	SetWindowLongPtrW(hTree, GWLP_WNDPROC, (LONG_PTR)s_treeProc); // tie the treeview to the new callback
	SetWindowLongPtrW(hTree, GWLP_USERDATA, (LONG_PTR)this);
	centerDialog();

	return 1;							// 1 == we did not call SetFocus()
}
BOOL XAP_Win32Dialog_PluginManager::_onInitDialog(HWND /*hWnd*/, WPARAM /*wParam*/, LPARAM /*lParam*/)
{		
	
	localizeDialogTitle(XAP_STRING_ID_DLG_PLUGIN_MANAGER_TITLE);

	/* Localise controls */	
	localizeControlText(IDOK,			XAP_STRING_ID_DLG_OK);
	localizeControlText(XAP_RID_DIALOG_PLUGIN_MANAGER_BTN_ACTIVE,		XAP_STRING_ID_DLG_PLUGIN_MANAGER_ACTIVE);
	localizeControlText(XAP_RID_DIALOG_PLUGIN_MANAGER_BTN_INSTALL,		XAP_STRING_ID_DLG_PLUGIN_MANAGER_INSTALL);			

	localizeControlText(XAP_RID_DIALOG_PLUGIN_MANAGER_LBL_NAME,			XAP_STRING_ID_DLG_PLUGIN_MANAGER_NAME);
	localizeControlText(XAP_RID_DIALOG_PLUGIN_MANAGER_LBL_DESCRIPTION,	XAP_STRING_ID_DLG_PLUGIN_MANAGER_DESC);
	localizeControlText(XAP_RID_DIALOG_PLUGIN_MANAGER_LBL_AUTHOR,		XAP_STRING_ID_DLG_PLUGIN_MANAGER_AUTHOR);
	localizeControlText(XAP_RID_DIALOG_PLUGIN_MANAGER_LBL_VERSION,		XAP_STRING_ID_DLG_PLUGIN_MANAGER_VERSION);

	refreshPluginList();	

	/* Default */
	selectListItem(XAP_RID_DIALOG_PLUGIN_MANAGER_LBX_LIST, 0);
	centerDialog();

	return 1;							// 1 == we did not call SetFocus()
}
Exemplo n.º 11
0
/*!
 * Sets up the dialog \me as a modeless dialog
 * 1) Connect focus to toplevel frame
 * 2) Centers dialog over toplevel window
 * 3) Makes the App remember this modeless dialog
 * 4) Connects F1 to help system
 * 5) Makes dialog non-modal (modeless)
 * 
6) Sets the default button to defaultResponse, sets ESC to close
 */
void abiSetupModelessDialog(GtkDialog * me, XAP_Frame * pFrame, XAP_Dialog * pDlg,
							gint defaultResponse, bool abi_modeless, AtkRole /*role*/ )
{
	if (abi_modeless)
	{
		// remember the modeless id
		XAP_App::getApp()->rememberModelessId( pDlg->getDialogId(), static_cast<XAP_Dialog_Modeless *>(pDlg));

		// connect focus to our parent frame
		connectFocusModeless(GTK_WIDGET(me), XAP_App::getApp());
	}

	// To center the dialog, we need the frame of its parent.
	if (pFrame)
	{
		XAP_UnixFrameImpl * pUnixFrameImpl = static_cast<XAP_UnixFrameImpl *>(pFrame->getFrameImpl());
		GtkWidget * parentWindow = gtk_widget_get_toplevel (pUnixFrameImpl->getTopLevelWindow());
		centerDialog ( parentWindow, GTK_WIDGET(me), false ) ;
	}
	
	// connect F1 to the help subsystem
	g_signal_connect (G_OBJECT(me), "key-press-event",
					  G_CALLBACK(nonmodal_keypress_cb), pDlg);
	
	// set the default response
	gtk_dialog_set_default_response ( me, defaultResponse ) ;
	sAddHelpButton (me, pDlg);

	// and mark it as modeless
	gtk_window_set_modal ( GTK_WINDOW(me), FALSE ) ;
	// FIXME: shouldn't we pass role here?
	atk_object_set_role (gtk_widget_get_accessible (GTK_WIDGET (me)), ATK_ROLE_ALERT);
	
	// show the window
	gtk_widget_show ( GTK_WIDGET(me) ) ;
}
BOOL AP_Win32Dialog_Field::_onInitDialog(HWND hWnd, WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	const XAP_StringSet * pSS = m_pApp->getStringSet();
	
	setDialogTitle (pSS->getValue(AP_STRING_ID_DLG_Field_FieldTitle));
	
	// localize controls
	_DSX(FIELD_BTN_OK,			DLG_OK);
	_DSX(FIELD_BTN_CANCEL,		DLG_Cancel);
	
	_DS(FIELD_TEXT_TYPES,		DLG_Field_Types);
	_DS(FIELD_TEXT_FORMATS, 	DLG_Field_Fields);
	_DS(FIELD_TEXT_PARAM,		DLG_Field_Parameters);

	// set initial state
	m_hwndTypes = GetDlgItem(hWnd, AP_RID_DIALOG_FIELD_LIST_TYPES);
	m_hwndFormats = GetDlgItem(hWnd, AP_RID_DIALOG_FIELD_LIST_FORMATS);
	m_hwndParam = GetDlgItem(hWnd, AP_RID_DIALOG_FIELD_EDIT_PARAM);
	SetTypesList();
	SetFieldsList();
	centerDialog();		
    
	return 1;				// 1 == we did not call SetFocus()
}
BOOL AP_Win32Dialog_Latex::_onInitDialog(HWND hWnd, WPARAM wParam, LPARAM /*lParam*/)
{
	m_hDlg = hWnd;
	
	// Update the caption
	ConstructWindowName();
	setDialogTitle((LPCSTR)(AP_Win32App::s_fromUTF8ToWinLocale(m_sWindowName.utf8_str())).c_str());

	// localize controls
	localizeControlText(AP_RID_DIALOG_LATEX_TEXT_EXAMPLE,AP_STRING_ID_DLG_Latex_Example);
	localizeControlText(AP_RID_DIALOG_LATEX_TEXT_LATEXEQUATION,AP_STRING_ID_DLG_Latex_LatexEquation);
	localizeControlText(AP_RID_DIALOG_LATEX_BTN_CLOSE,XAP_STRING_ID_DLG_Close);
	localizeControlText(AP_RID_DIALOG_LATEX_BTN_INSERT,XAP_STRING_ID_DLG_Insert);

	setLatexInGUI();
	centerDialog();	

	if (GetDlgCtrlID((HWND) wParam) != AP_RID_DIALOG_LATEX_EDIT_LATEX) 
	{ 
		SetFocus(GetDlgItem(hWnd, AP_RID_DIALOG_LATEX_EDIT_LATEX)); 
		return 0; 
	} 	
	return 1;							// 1 == we did not call SetFocus()
}
BOOL AP_Win32Dialog_Columns::_onInitDialog(HWND hWnd, WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	const XAP_StringSet* pSS = m_pApp->getStringSet();

	// Update the caption
	setDialogTitle(pSS->getValue(AP_STRING_ID_DLG_Column_ColumnTitle));

	/* Localise controls*/
	_DSX(COLUMN_BTN_OK,			DLG_OK);
	_DSX(COLUMN_BTN_CANCEL,			DLG_Cancel);
	_DS(COLUMN_GROUP1,			DLG_Column_Number);
	_DS(COLUMN_GROUP2,			DLG_Column_Preview);
	_DS(COLUMN_TEXT_ONE,			DLG_Column_One);
	_DS(COLUMN_TEXT_TWO,			DLG_Column_Two);
	_DS(COLUMN_TEXT_THREE,			DLG_Column_Three);
	_DS(COLUMN_CHECK_LINE_BETWEEN,		DLG_Column_Line_Between);
	_DS(COLUMN_TEXT_NUMCOLUMNS,		DLG_Column_Number_Cols);
	_DS(COLUMN_TEXT_SPACEAFTER,		DLG_Column_Space_After);
	_DS(COLUMN_TEXT_MAXSIZE,		DLG_Column_Size);
	_DS(COLUMN_CHECK_RTL_ORDER,		DLG_Column_RtlOrder);

	// Do Bitmaps
	RECT rect;
	GetClientRect(GetDlgItem(hWnd, AP_RID_DIALOG_COLUMN_RADIO_ONE), &rect);
	int iWidth = rect.right - rect.left;
	int iHeight = rect.bottom - rect.top;

	HBITMAP hBitmap;
	AP_Win32Toolbar_Icons Icons;
	COLORREF ColorRef = GetSysColor(COLOR_BTNFACE);
	UT_RGBColor Color(GetRValue(ColorRef), GetGValue(ColorRef), GetBValue(ColorRef));

	bool bFoundIcon = Icons.getBitmapForIcon(hWnd, iWidth, iHeight, &Color, "1COLUMN",
																&hBitmap);
	UT_return_val_if_fail (bFoundIcon, false);
	SendDlgItemMessageW(hWnd, AP_RID_DIALOG_COLUMN_RADIO_ONE, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);

	bFoundIcon = Icons.getBitmapForIcon(hWnd, iWidth, iHeight, &Color, "2COLUMN",
																&hBitmap);
	UT_return_val_if_fail (bFoundIcon, false);
	SendDlgItemMessageW(hWnd, AP_RID_DIALOG_COLUMN_RADIO_TWO, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);

	bFoundIcon = Icons.getBitmapForIcon(hWnd, iWidth, iHeight, &Color, "3COLUMN",
																&hBitmap);
	UT_return_val_if_fail (bFoundIcon, false);
	SendDlgItemMessageW(hWnd, AP_RID_DIALOG_COLUMN_RADIO_THREE, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap);

	// set initial state
	wchar_t buf[BUFSIZE];
	checkButton(AP_RID_DIALOG_COLUMN_RADIO_ONE + getColumns() - 1, true);
	enableLineBetweenControl(getColumns() != 1);
	checkButton(AP_RID_DIALOG_COLUMN_CHECK_LINE_BETWEEN, getLineBetween());
	SetDlgItemTextW(m_hDlg, AP_RID_DIALOG_COLUMN_EDIT_NUMCOLUMNS, _itow( getColumns(),buf,10) );    
	setControlText(AP_RID_DIALOG_COLUMN_EDIT_SPACEAFTER, getSpaceAfterString());
	setControlText(AP_RID_DIALOG_COLUMN_EDIT_MAXSIZE, getHeightString());

	showControl( AP_RID_DIALOG_COLUMN_CHECK_RTL_ORDER, SW_NORMAL );
	checkButton(AP_RID_DIALOG_COLUMN_CHECK_RTL_ORDER, getColumnOrder()!=false);

	// Create a preview window.

	HWND hwndChild = GetDlgItem(hWnd, AP_RID_DIALOG_COLUMN_PREVIEW);

	m_pPreviewWidget = new XAP_Win32PreviewWidget(static_cast<XAP_Win32App *>(m_pApp),
													  hwndChild,
													  0);
	UT_uint32 w,h;
	m_pPreviewWidget->getWindowSize(&w,&h);
	//m_pPreviewWidget->init3dColors(m_wpreviewArea->style);
	m_pPreviewWidget->getGraphics()->init3dColors();
	_createPreviewFromGC(m_pPreviewWidget->getGraphics(), w, h);
	m_pPreviewWidget->setPreview(m_pColumnsPreview);
	
	centerDialog();	
	
	return 1;	// 1 == we did not call SetFocus()
}
Exemplo n.º 15
0
void LLUploadDialog::setMessage( const std::string& msg)
{
	const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF );

	const S32 VPAD = 16;
	const S32 HPAD = 25;

	// Make the text boxes a little wider than the text
	const S32 TEXT_PAD = 8;

	// Split message into lines, separated by '\n'
	S32 max_msg_width = 0;
	LLDoubleLinkedList<LLString> msg_lines;

	S32 size = msg.size() + 1;// + strlen("Uploading...\n\n");
	char* temp_msg = new char[size];
	
	//strcpy(temp_msg,"Uploading...\n\n");
	if (temp_msg == NULL)
	{
		llerrs << "Memory Allocation Failed" << llendl;
		return;
	}
	
	strcpy( temp_msg, msg.c_str());		/* Flawfinder: ignore */
	char* token = strtok( temp_msg, "\n" );
	while( token )
	{
		S32 cur_width = S32(font->getWidth(token) + 0.99f) + TEXT_PAD;
		max_msg_width = llmax( max_msg_width, cur_width );
		msg_lines.addDataAtEnd( new LLString( token ) );
		token = strtok( NULL, "\n" );
	}
	delete[] temp_msg;


	S32 line_height = S32( font->getLineHeight() + 0.99f );
	S32 dialog_width = max_msg_width + 2 * HPAD;
	S32 dialog_height = line_height * msg_lines.getLength() + 2 * VPAD;

	reshape( dialog_width, dialog_height, FALSE );

	// Message
	S32 msg_x = (mRect.getWidth() - max_msg_width) / 2;
	S32 msg_y = mRect.getHeight() - VPAD - line_height;
	int line_num;
	for (line_num=0; line_num<16; ++line_num)
	{
		mLabelBox[line_num]->setVisible(FALSE);
	}
	line_num = 0;
	for( LLString* cur_line = msg_lines.getFirstData(); cur_line; cur_line = msg_lines.getNextData() )
	{
		LLRect msg_rect;
		msg_rect.setOriginAndSize( msg_x, msg_y, max_msg_width, line_height );
		mLabelBox[line_num]->setRect(msg_rect);
		mLabelBox[line_num]->setText(*cur_line);
		mLabelBox[line_num]->setColor( gColors.getColor( "LabelTextColor" ) );
		mLabelBox[line_num]->setVisible(TRUE);
		msg_y -= line_height;
		++line_num;
	}
	msg_lines.deleteAllData();

	centerDialog();
}
// This handles the WM_INITDIALOG message for the top-level dialog.
BOOL AP_Win32Dialog_FormatFrame::_onInitDialog(HWND hWnd, WPARAM /*wParam*/, LPARAM /*lParam*/)
{	
	HDC hdc;
	int x, y;	
	UT_uint32 w,h;
	UT_sint32 i = 0;
	RECT rect;	
	const XAP_StringSet * pSS = m_pApp->getStringSet();
	DWORD dwColor = GetSysColor(COLOR_BTNFACE);	
	UT_RGBColor Color(GetRValue(dwColor),GetGValue(dwColor),GetBValue(dwColor));
	
	/* The four items are the same size */
	GetClientRect(GetDlgItem(hWnd, AP_RID_DIALOG_FORMATFRAME_BMP_BOTTOM), &rect);					
	hdc = GetDC(hWnd);
	x = rect.right - rect.left;
	y = rect.bottom - rect.top;
	
	/* Localise controls*/
	_DSX(FORMATFRAME_BTN_CANCEL,		DLG_Close);
	_DSX(FORMATFRAME_BTN_APPLY,			DLG_Apply);
	_DS(FORMATFRAME_TEXT_BACKGROUND,	DLG_FormatFrame_Color);
	_DS(FORMATFRAME_TEXT_PREVIEW,		DLG_FormatFrame_Preview);
	_DS(FORMATFRAME_TEXT_BORDERS,		DLG_FormatFrame_Border_Color);
	_DS(FORMATFRAME_TEXT_BORDER, 		DLG_FormatFrame_Color);
	_DS(FORMATFRAME_TEXT_BACKGROUNDS, 	DLG_FormatFrame_Background);
	_DS(FORMATFRAME_TEXT_TEXTWRAPS,		DLG_FormatFrame_TextWrapping);
	_DS(FORMATFRAME_CHK_TEXTWRAP,		DLG_FormatFrame_SetTextWrapping);
	_DS(FORMATFRAME_TEXT_POSTEXTPOS,	DLG_FormatFrame_PositionTo);
	_DS(FORMATFRAME_RADIO_PARA,		 	DLG_FormatFrame_SetToParagraph);
	_DS(FORMATFRAME_RADIO_COLUMN,		DLG_FormatFrame_SetToColumn);
	_DS(FORMATFRAME_RADIO_PAGE,			DLG_FormatFrame_SetToPage);
	_DS(FORMATFRAME_BUTTON_SELIMAGE,	DLG_FormatFrame_SelectImage);
	_DS(FORMATFRAME_BUTTON_NOIMAGE,		DLG_FormatFrame_NoImageBackground);
	_DS(FORMATFRAME_TEXT_THICKNESS,		DLG_FormatTable_Thickness);
	_DS(FORMATFRAME_TEXT_IMGBACK,		DLG_FormatFrame_SetImageBackground);


	setDialogTitle (pSS->getValue(AP_STRING_ID_DLG_FormatFrameTitle));	
	
	
	/* Load the bitmaps into the dialog box */								
    m_hBitmapBottom = _loadBitmap(hWnd,AP_RID_DIALOG_FORMATFRAME_BMP_BOTTOM, "FT_LINEBOTTOM",  BITMAP_WITDH, BITMAP_HEIGHT, Color);
    m_hBitmapTop = _loadBitmap(hWnd,AP_RID_DIALOG_FORMATFRAME_BMP_TOP, "FT_LINETOP",  BITMAP_WITDH, BITMAP_HEIGHT, Color);
    m_hBitmapRight = _loadBitmap(hWnd,AP_RID_DIALOG_FORMATFRAME_BMP_RIGHT, "FT_LINERIGHT",  BITMAP_WITDH, BITMAP_HEIGHT, Color);
    m_hBitmapLeft = _loadBitmap(hWnd,AP_RID_DIALOG_FORMATFRAME_BMP_LEFT, "FT_LINELEFT",  BITMAP_WITDH, BITMAP_HEIGHT, Color); 
    
	/* Preview*/
	HWND hwndChild = GetDlgItem(hWnd, AP_RID_DIALOG_FORMATFRAME_STATIC_PREVIEW);	
	UT_return_val_if_fail (hwndChild,1);

	m_pPreviewWidget = new XAP_Win32PreviewWidget(static_cast<XAP_Win32App *>(m_pApp),  hwndChild, 0);	
	m_pPreviewWidget->getGraphics()->init3dColors();
	m_pPreviewWidget->getWindowSize(&w,&h);
	_createPreviewFromGC(m_pPreviewWidget->getGraphics(), w, h);	
	m_pPreviewWidget->setPreview(m_pFormatFramePreview); 	
								
	startUpdater();
	setAllSensitivities();

	/* Default status for the dialog controls */
	CheckDlgButton(hWnd, AP_RID_DIALOG_FORMATFRAME_BMP_TOP, getTopToggled() ? BST_CHECKED: BST_UNCHECKED);
	CheckDlgButton(hWnd, AP_RID_DIALOG_FORMATFRAME_BMP_BOTTOM, getBottomToggled() ? BST_CHECKED: BST_UNCHECKED);
	CheckDlgButton(hWnd, AP_RID_DIALOG_FORMATFRAME_BMP_RIGHT, getRightToggled() ? BST_CHECKED: BST_UNCHECKED);
	CheckDlgButton(hWnd, AP_RID_DIALOG_FORMATFRAME_BMP_LEFT, getLeftToggled() ? BST_CHECKED: BST_UNCHECKED);

	/* Position to radio buttons */
	if(positionMode() == FL_FRAME_POSITIONED_TO_BLOCK)
	{
		CheckRadioButton(hWnd, AP_RID_DIALOG_FORMATFRAME_RADIO_PARA, AP_RID_DIALOG_FORMATFRAME_RADIO_PAGE, AP_RID_DIALOG_FORMATFRAME_RADIO_PARA);
	}
	else if(positionMode() == FL_FRAME_POSITIONED_TO_COLUMN)
	{
		CheckRadioButton(hWnd, AP_RID_DIALOG_FORMATFRAME_RADIO_PARA, AP_RID_DIALOG_FORMATFRAME_RADIO_PAGE, AP_RID_DIALOG_FORMATFRAME_RADIO_COLUMN);
	}
	else if(positionMode() == FL_FRAME_POSITIONED_TO_PAGE)
	{
		CheckRadioButton(hWnd, AP_RID_DIALOG_FORMATFRAME_RADIO_PARA, AP_RID_DIALOG_FORMATFRAME_RADIO_PAGE, AP_RID_DIALOG_FORMATFRAME_RADIO_PAGE);
	}

	/* Wrapping checkbox */
	CheckDlgButton(hWnd, AP_RID_DIALOG_FORMATFRAME_CHK_TEXTWRAP, getWrapping() ? BST_CHECKED: BST_UNCHECKED);

	/* Combo Values for Thickness */
	
	for(i=0; i < FORMAT_FRAME_NUMTHICKNESS ;i++)
		addItemToCombo (AP_RID_DIALOG_FORMATFRAME_COMBO_THICKNESS, sThickness[i]);

	selectComboItem (AP_RID_DIALOG_FORMATFRAME_COMBO_THICKNESS, 0);

	centerDialog();
	return 1; 
}
BOOL XAP_Win32Dialog_Insert_Symbol::_onInitDialog(HWND hWnd, WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	m_hDlg = hWnd;

	// localize controls
	localizeControlText(XAP_RID_DIALOG_INSERTSYMBOL_INSERT_BUTTON,XAP_STRING_ID_DLG_Insert);
	localizeControlText(XAP_RID_DIALOG_INSERTSYMBOL_CLOSE_BUTTON,XAP_STRING_ID_DLG_Close);


	// *** this is how we add the gc for symbol table ***
	// attach a new graphics context to the drawing area
	XAP_Win32App * app = static_cast<XAP_Win32App *> (m_pApp);
	UT_ASSERT(app);

	HWND hwndChild = GetDlgItem(hWnd, XAP_RID_DIALOG_INSERTSYMBOL_SYMBOLS);

	m_pSymbolPreviewWidget = new XAP_Win32PreviewWidget(static_cast<XAP_Win32App *>(m_pApp),
													  hwndChild,
													  0);
	UT_uint32 w,h;
	m_pSymbolPreviewWidget->getWindowSize(&w,&h);
	_createSymbolFromGC(m_pSymbolPreviewWidget->getGraphics(), w, h);
	m_pSymbolPreviewWidget->setPreview(m_DrawSymbol);
	m_pSymbolPreviewWidget->setInsertSymbolParent(this);

	hwndChild = GetDlgItem(hWnd, XAP_RID_DIALOG_INSERTSYMBOL_SYMBOL_PREVIEW);

	m_pSamplePreviewWidget = new XAP_Win32PreviewWidget(static_cast<XAP_Win32App *>(m_pApp),
													  hwndChild,
													  0);

	m_pSamplePreviewWidget->getWindowSize(&w,&h);
	_createSymbolareaFromGC(m_pSamplePreviewWidget->getGraphics(), w, h);

	m_DrawSymbolSample = new XAP_Draw_Symbol_sample(m_DrawSymbol, m_pSamplePreviewWidget->getGraphics()); 
		
	// TODO: Colour
	GR_Win32Graphics* gr = (GR_Win32Graphics*) m_DrawSymbolSample->m_pSymbolDraw->getGraphics();
	
	
	gr->setBrush((HBRUSH)GetSysColorBrush(COLOR_3DFACE));
	
	m_pSamplePreviewWidget->setPreview(m_DrawSymbolSample);

	XAP_Draw_Symbol * iDrawSymbol = _getCurrentSymbolMap();
	UT_ASSERT(iDrawSymbol);

	// Fill the list box with symbol fonts.

	HDC hDCScreen = CreateDC("DISPLAY", NULL, NULL, NULL);

#if 1
	EnumFontFamilies(hDCScreen, (const char *)NULL, (FONTENUMPROC)fontEnumProcedure, (LPARAM)this);
#else
	LOGFONT LogFont;
//	LogFont.lfCharSet = SYMBOL_CHARSET; - all fonts enum is more inline with XP nature
	LogFont.lfCharSet = DEFAULT_CHARSET;
	LogFont.lfFaceName[0] = '\0';
	EnumFontFamiliesEx(hDCScreen, &LogFont, (FONTENUMPROC)fontEnumProcedure, (LPARAM)this, 0);
#endif	
	
	DeleteDC(hDCScreen);

	// Select the current font.

	UT_sint32 Index = SendDlgItemMessage(m_hDlg, XAP_RID_DIALOG_INSERTSYMBOL_FONT_LIST, CB_FINDSTRING, -1, (LPARAM)Symbol_font_selected);

	if(Index != -1)
	{
		_setFontFromCombo(Index);
	}
	else
	{
		_setFontFromCombo(0);
	}

	// Update the caption
	ConstructWindowName();
	setDialogTitle((LPCSTR)(AP_Win32App::s_fromUTF8ToWinLocale(m_WindowName)).c_str());
	centerDialog();	

	return 1;							// 1 == we did not call SetFocus()
}
Exemplo n.º 18
0
static void
GDict_dlg_create (const char * search)
{
  GtkWidget * vbox;
  GtkWidget * hbox;
  GtkWidget * button;
  GtkWidget * scrolled;
  GtkWidget * close;
  GtkWidget * gtk_entry;
  
  // create the toplevel dialog
  gdict_dlg = gnome_dialog_new ("AbiWord Dictionary", 
				GNOME_STOCK_BUTTON_CLOSE, NULL);
  gtk_window_set_modal (GTK_WINDOW(gdict_dlg), false);
  gtk_widget_set_usize (gdict_dlg, 450, 300);

  // center the dialog and connect focus
  XAP_App * pApp = XAP_App::getApp ();
  XAP_UnixFrame * pFrame = static_cast<XAP_UnixFrame*>(pApp->getLastFocussedFrame ());
  GtkWidget * parent = pFrame->getTopLevelWindow();
  centerDialog(parent, gdict_dlg);

  close = GTK_WIDGET (g_list_last (GNOME_DIALOG (gdict_dlg)->buttons)->data);  
  vbox = GNOME_DIALOG(gdict_dlg)->vbox;
  
  hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);	
  gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
  
  button = gtk_button_new_with_label ("Look Up");
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
  
  gdict_entry = gnome_entry_new(NULL);
  gtk_entry = gnome_entry_gtk_entry(GNOME_ENTRY(gdict_entry));
  gtk_box_pack_start (GTK_BOX (hbox), gdict_entry, TRUE, TRUE, 0);

  scrolled = gtk_scrolled_window_new (NULL, NULL);
  gtk_container_set_border_width (GTK_CONTAINER (scrolled), GNOME_PAD_SMALL); 
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
				  GTK_POLICY_AUTOMATIC,
				  GTK_POLICY_AUTOMATIC);
  gtk_box_pack_start (GTK_BOX (vbox), scrolled, TRUE, TRUE, 0);
  
  gdict_defbox = gdict_defbox_new ();
  gtk_widget_show (gdict_defbox);
  gtk_container_add (GTK_CONTAINER (scrolled), gdict_defbox);
  
  g_signal_connect (G_OBJECT (button), "clicked",
		      G_CALLBACK (lookup_button_cb), gdict_defbox);

  g_signal_connect (G_OBJECT (gtk_entry), "activate",
		      G_CALLBACK (entry_activate_cb), gdict_defbox);
#if 0
  g_signal_connect (G_OBJECT (gtk_entry), "changed",
		      G_CALLBACK (entry_activate_cb), gdict_defbox);
#endif  

  g_signal_connect (G_OBJECT (gdict_dlg),
		      "close",
		      G_CALLBACK(close_cb),
		      (gpointer)0);
  
  g_signal_connect (G_OBJECT (close),
		      "clicked",
		      G_CALLBACK(close_cb),
		      (gpointer)0);

  g_signal_connect_after(G_OBJECT(gdict_dlg),
			   "destroy",
			   NULL,
			   NULL);

  gtk_widget_show_all (gdict_dlg);
}
void XAP_UnixDialog_FileOpenSaveAs::runModal(XAP_Frame * pFrame)
{
    const XAP_StringSet * pSS = m_pApp->getStringSet();
    std::string szTitle;
    std::string szFileTypeLabel;

    switch (m_id)
    {
    case XAP_DIALOG_ID_INSERT_PICTURE:
    {
        pSS->getValueUTF8(XAP_STRING_ID_DLG_IP_Title, szTitle);
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_FileOpenTypeLabel, szFileTypeLabel);
        m_bSave = false;
        break;
    }
    case XAP_DIALOG_ID_FILE_OPEN:
    {
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_OpenTitle,szTitle);
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_FileOpenTypeLabel,szFileTypeLabel);
        m_bSave = false;
        break;
    }
    case XAP_DIALOG_ID_FILE_IMPORT:
    {
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_ImportTitle,szTitle);
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_FileOpenTypeLabel,szFileTypeLabel);
        m_bSave = false;
        break;
    }
    case XAP_DIALOG_ID_INSERTMATHML:
    {
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_InsertMath,szTitle);
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_FileInsertMath,szFileTypeLabel);
        m_bSave = false;
        break;
    }
    case XAP_DIALOG_ID_INSERTOBJECT:
    {
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_InsertObject,szTitle);
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_FileInsertObject,szFileTypeLabel);
        m_bSave = false;
        break;
    }
    case XAP_DIALOG_ID_INSERT_FILE:
    {
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_InsertTitle,szTitle);
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_FileOpenTypeLabel,szFileTypeLabel);
        m_bSave = false;
        break;
    }
    case XAP_DIALOG_ID_FILE_SAVEAS:
    case XAP_DIALOG_ID_FILE_SAVE_IMAGE:
    {
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_SaveAsTitle,szTitle);
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_FileSaveTypeLabel,szFileTypeLabel);
        m_bSave = true;
        break;
    }
    case XAP_DIALOG_ID_FILE_EXPORT:
    {
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_ExportTitle,szTitle);
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_FileSaveTypeLabel,szFileTypeLabel);
        m_bSave = true;
        break;
    }
    case XAP_DIALOG_ID_PRINTTOFILE:
    {
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_PrintToFileTitle,szTitle);
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_FilePrintTypeLabel,szFileTypeLabel);
        m_bSave = true;
        break;
    }
    case XAP_DIALOG_ID_RECORDTOFILE:
    {
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_RecordToFileTitle,szTitle);
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_RecordToFileLabel,szFileTypeLabel);
        m_bSave = true;
        break;
    }
    case XAP_DIALOG_ID_REPLAYFROMFILE:
    {
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_ReplayFromFileTitle,szTitle);
        pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_ReplayFromFileLabel,szFileTypeLabel);
        m_bSave = false;
        break;
    }
    default:
        UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
        m_bSave = false;
        break;
    }

    // NOTE: we use our string mechanism to localize the dialog's
    // NOTE: title and the error/confirmation message boxes.  we
    // NOTE: let GTK take care of the localization of the actual
    // NOTE: buttons and labels on the FileSelection dialog.

    // Get the GtkWindow of the parent frame
    XAP_UnixFrameImpl * pUnixFrameImpl = static_cast<XAP_UnixFrameImpl *>(pFrame->getFrameImpl());
    GtkWidget * parent = pUnixFrameImpl->getTopLevelWindow();

    if(parent && (GTK_WIDGET_TOPLEVEL(parent) != TRUE))
    {
        parent = gtk_widget_get_toplevel (parent);
    }

#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
    m_FC = GTK_FILE_CHOOSER( hildon_file_chooser_dialog_new(GTK_WINDOW(parent),
                             (!m_bSave ? GTK_FILE_CHOOSER_ACTION_OPEN : GTK_FILE_CHOOSER_ACTION_SAVE))
                           );
#else
    m_FC = GTK_FILE_CHOOSER( gtk_file_chooser_dialog_new (szTitle.c_str(),
                             GTK_WINDOW(parent),
                             (!m_bSave ? GTK_FILE_CHOOSER_ACTION_OPEN : GTK_FILE_CHOOSER_ACTION_SAVE),
                             GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                             (m_bSave ? GTK_STOCK_SAVE : GTK_STOCK_OPEN), GTK_RESPONSE_ACCEPT,
                             (gchar*)NULL)
                           );
#endif

    gtk_file_chooser_set_local_only(m_FC, FALSE);

    abiSetupModalDialog(GTK_DIALOG(m_FC), pFrame, this, GTK_RESPONSE_ACCEPT);
    GtkWidget * filetypes_pulldown = NULL;

    std::string s;

    /*
      Add a drop-down list of known types to facilitate a file-types selection.
      We store an indexer in the user data for each menu item in the popup, so
      we can read the type we need to return.
    */

    if (m_id == XAP_DIALOG_ID_INSERT_PICTURE)
    {
        GtkWidget * preview = createDrawingArea ();
        gtk_widget_show (preview);
        m_preview = preview;
        gtk_widget_set_size_request (preview, PREVIEW_WIDTH, PREVIEW_HEIGHT);

        // place the preview area inside a container to get a nice border
        GtkWidget * preview_hbox = gtk_hbox_new(FALSE, 0);
        gtk_container_set_border_width  (GTK_CONTAINER(preview_hbox), 4);
        gtk_box_pack_start(GTK_BOX(preview_hbox), preview, TRUE, TRUE, 0);

        // attach the preview area to the dialog
        gtk_file_chooser_set_preview_widget (m_FC, preview_hbox);
        gtk_file_chooser_set_preview_widget_active (m_FC, true);

        // connect some signals
        g_signal_connect (m_FC, "update_preview",
                          G_CALLBACK (file_selection_changed), static_cast<gpointer>(this));

        g_signal_connect (preview, "expose_event",
                          G_CALLBACK (s_preview_exposed), static_cast<gpointer>(this));
    }

#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
    filetypes_pulldown = gtk_combo_box_new();
    gtk_widget_show(filetypes_pulldown);
    GtkWidget * pulldown_hbox = filetypes_pulldown;
#else
    // hbox for our pulldown menu (GTK does its pulldown this way */
    GtkWidget * pulldown_hbox = gtk_hbox_new(FALSE, 15);
    gtk_widget_show(pulldown_hbox);

    // pulldown label
    GtkWidget * filetypes_label = gtk_label_new_with_mnemonic(convertMnemonics(szFileTypeLabel).c_str());
    gtk_label_set_justify(GTK_LABEL(filetypes_label), GTK_JUSTIFY_RIGHT);
    gtk_misc_set_alignment(GTK_MISC(filetypes_label), 1.0, 0.5);
    gtk_widget_show(filetypes_label);
    gtk_box_pack_start(GTK_BOX(pulldown_hbox), filetypes_label, TRUE, TRUE, 0);

    // pulldown menu
    filetypes_pulldown = gtk_combo_box_new();
    gtk_widget_show(filetypes_pulldown);
    gtk_box_pack_end(GTK_BOX(pulldown_hbox), filetypes_pulldown, TRUE, TRUE, 0);
    gtk_label_set_mnemonic_widget(GTK_LABEL(filetypes_label), filetypes_pulldown);
#endif
    //
    // add the filters to the dropdown list
    //
    GtkComboBox* combo = GTK_COMBO_BOX(filetypes_pulldown);
    XAP_makeGtkComboBoxText(combo, G_TYPE_INT);

    // Auto-detect is always an option, but a special one, so we use
    // a pre-defined constant for the type, and don't use the user-supplied
    // types yet.
    pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_FileTypeAutoDetect,s);
    XAP_appendComboBoxTextAndInt(combo, s.c_str(), XAP_DIALOG_FILEOPENSAVEAS_FILE_TYPE_AUTO);

    UT_sint32 activeItemIndex = -1;

    // add list items
    {
        UT_ASSERT(g_strv_length((gchar **) m_szSuffixes) == g_strv_length((gchar **) m_szDescriptions));

        // measure one list, they should all be the same length
        UT_uint32 end = g_strv_length((gchar **) m_szDescriptions);

        for (UT_uint32 i = 0; i < end; i++)
        {
            // If this type is default, save its index (i) for later use
            if (m_nTypeList[i] == m_nDefaultFileType)
                activeItemIndex = i;

            XAP_appendComboBoxTextAndInt(combo, m_szDescriptions[i], m_nTypeList[i]);
//
// Attach a callback when it is activated to change the file suffix
//
//			g_signal_connect(G_OBJECT(thismenuitem), "activate",
//							 G_CALLBACK(s_filetypechanged),
//							 reinterpret_cast<gpointer>(this));
        }
    }

    m_wFileTypes_PullDown = filetypes_pulldown;
    // dialog; open dialog always does auto-detect
    // TODO: should this also apply to the open dialog?
    if (m_id == XAP_DIALOG_ID_FILE_SAVEAS || m_id == XAP_DIALOG_ID_FILE_SAVE_IMAGE)
    {
        gtk_combo_box_set_active(combo, activeItemIndex + 1);
    }
    else
    {
        gtk_combo_box_set_active(combo, 0);
    }

#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
    hildon_file_chooser_dialog_add_extra ((HildonFileChooserDialog*)m_FC,
                                          pulldown_hbox);
#else
    gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(m_FC), pulldown_hbox);
#endif

    // connect the signals for OK and CANCEL and the requisite clean-close signals
    g_signal_connect(G_OBJECT(m_FC),
                     "delete-event",
                     G_CALLBACK(s_delete_clicked),
                     this);

    g_signal_connect(G_OBJECT(m_FC),
                     "key_press_event",
                     G_CALLBACK(fsel_key_event), &m_answer);

    g_signal_connect (G_OBJECT (m_FC),
                      "response",
                      G_CALLBACK(dialog_response), &m_answer);

    g_signal_connect (G_OBJECT (m_FC),
                      "file-activated",
                      G_CALLBACK(s_file_activated), &m_answer);

    g_signal_connect(G_OBJECT(filetypes_pulldown), "changed",
                     G_CALLBACK(s_filetypechanged),
                     reinterpret_cast<gpointer>(this));

    // use the persistence info and/or the suggested filename
    // to properly seed the dialog.

    gchar * szPersistDirectory = NULL;	// we must g_free this

    if (!m_szInitialPathname || !*m_szInitialPathname)
    {
        // the caller did not supply initial pathname
        // (or supplied an empty one).  see if we have
        // some persistent info.

        UT_ASSERT(!m_bSuggestName);
        if (m_szPersistPathname)
        {
            // we have a pathname from a previous use,
            // extract the directory portion and start
            // the dialog there (but without a filename).

            szPersistDirectory = UT_go_dirname_from_uri(m_szPersistPathname, FALSE);
            gtk_file_chooser_set_current_folder_uri(m_FC, szPersistDirectory);
        }
        else
        {
            // no initial pathname given and we don't have
            // a pathname from a previous use, so just let
            // it come up in the current working directory.
        }
    }
    else
    {
        // we have an initial pathname (the name of the document
        // in the frame that we were invoked on).  if the caller
        // wanted us to suggest a filename, use the initial
        // pathname as is.  if not, use the directory portion of
        // it.

        if (m_bSuggestName)
        {
            xxx_UT_DEBUGMSG(("Iniitial filename is %s \n",m_szInitialPathname));
#if 0
            if (!g_path_is_absolute (m_szInitialPathname)) { // DAL: todo: is this correct?
                gchar *dir = g_get_current_dir ();
                gchar *file = m_szInitialPathname;
                gchar *filename = g_build_filename (dir, file, (gchar *)NULL);
                m_szInitialPathname = UT_go_filename_to_uri(filename);
                g_free(filename);
                g_free (dir);
                g_free (file);
            }
#endif
            if(m_id == XAP_DIALOG_ID_FILE_SAVEAS)
            {
                std::string szInitialSuffix = UT_pathSuffix(m_szInitialPathname);
                std::string szSaveTypeSuffix = IE_Exp::preferredSuffixForFileType(m_nDefaultFileType).utf8_str();
                if(!szInitialSuffix.empty() && !szSaveTypeSuffix.empty()
                        && (szSaveTypeSuffix != szInitialSuffix))
                {
                    std::string sFileName = m_szInitialPathname;
                    std::string::size_type i = sFileName.find_last_of('.');

                    if(i != std::string::npos)
                    {
                        // erase to the end()
                        sFileName.erase(i);
                        sFileName += szSaveTypeSuffix;
                        FREEP(m_szInitialPathname);
                        m_szInitialPathname = g_strdup(sFileName.c_str());
                    }
                }
            }
            if (UT_go_path_is_uri(m_szInitialPathname) || UT_go_path_is_path(m_szInitialPathname))
            {
                gtk_file_chooser_set_uri(m_FC, m_szInitialPathname);
            }
        }
        else
        {
            if (UT_go_path_is_uri(m_szInitialPathname) || UT_go_path_is_path(m_szInitialPathname))
            {
                szPersistDirectory = UT_go_dirname_from_uri(m_szInitialPathname, FALSE);
                gtk_file_chooser_set_current_folder_uri(m_FC, szPersistDirectory);
            }
            else
            {
                // we are dealing with a plain filename, not an URI or path, so
                // just let it come up in the current working directory.
            }
        }
    }

    // center the dialog
    xxx_UT_DEBUGMSG(("before center IS WIDGET_TOP_LEVL %d \n",(GTK_WIDGET_TOPLEVEL(parent))));
    xxx_UT_DEBUGMSG(("before center IS WIDGET WINDOW %d \n",(GTK_IS_WINDOW(parent))));
    centerDialog(parent, GTK_WIDGET(m_FC));
    xxx_UT_DEBUGMSG(("After center IS WIDGET WINDOW %d \n",(GTK_IS_WINDOW(parent))));

    gtk_widget_show(GTK_WIDGET(m_FC));
    gtk_grab_add(GTK_WIDGET(m_FC));

    bool bResult = _run_gtk_main(pFrame,filetypes_pulldown);

    if (bResult)
    {
        UT_ASSERT(m_szFinalPathnameCandidate);

        // store final path name and file type
        m_szFinalPathname = g_strdup(m_szFinalPathnameCandidate);

        FREEP(m_szFinalPathnameCandidate);

        // what a long ugly line of code
        m_nFileType = XAP_comboBoxGetActiveInt(GTK_COMBO_BOX(filetypes_pulldown));
    }

    if (m_FC != NULL) {
        gtk_grab_remove (GTK_WIDGET(m_FC));
        gtk_widget_destroy (GTK_WIDGET(m_FC));
        m_FC = NULL;
        FREEP(szPersistDirectory);
    }

    return;
}
BOOL AP_Win32Dialog_Paragraph::_onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	const XAP_StringSet * pSS = m_pApp->getStringSet();

	setDialogTitle (pSS->getValue(AP_STRING_ID_DLG_Para_ParaTitle));

	// localize controls
	_DSX(PARA_BTN_OK,			DLG_OK);
	_DSX(PARA_BTN_CANCEL,		DLG_Cancel);

	_DS(PARA_BTN_TABS,			DLG_Para_ButtonTabs);

	// setup the tabs
	{
		TabParam tp;
		TCITEMW tie;

		XAP_Win32App * pWin32App = static_cast<XAP_Win32App *>(m_pApp);
		HINSTANCE hinst = pWin32App->getInstance();
		DLGTEMPLATE * pTemplate = NULL;
		HWND w = NULL;

		tp.pThis = this;

		// remember the windows we're using

		m_hwndDlg = hWnd;
		m_hwndTab = GetDlgItem(hWnd, AP_RID_DIALOG_PARA_TAB);

		// add a tab for each of the child dialog boxes

		UT_Win32LocaleString str;

		tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM;
		tie.iImage = -1;
		str.fromUTF8(_GV(DLG_Para_TabLabelIndentsAndSpacing));
		tie.pszText = (LPWSTR)str.c_str();
		tie.lParam = AP_RID_DIALOG_PARA_TAB1;
		SendMessageW(m_hwndTab, TCM_INSERTITEMW, 0, (LPARAM)&tie);
		str.fromUTF8(_GV(DLG_Para_TabLabelLineAndPageBreaks));
		tie.pszText = (LPWSTR)str.c_str();
		tie.lParam = AP_RID_DIALOG_PARA_TAB2;
		SendMessageW(m_hwndTab, TCM_INSERTITEMW, 1, (LPARAM)&tie);

		// finally, create the (modeless) child dialogs

		tp.which = AP_RID_DIALOG_PARA_TAB1;
		pTemplate = UT_LockDlgRes(hinst, MAKEINTRESOURCEW(tp.which));
		w = CreateDialogIndirectParamW(hinst, pTemplate, m_hwndTab,
										(DLGPROC)s_tabProc, (LPARAM)&tp);
		UT_ASSERT_HARMLESS((w && (w == m_hwndSpacing)));

		tp.which = AP_RID_DIALOG_PARA_TAB2;
		pTemplate = UT_LockDlgRes(hinst, MAKEINTRESOURCEW(tp.which));
		w = CreateDialogIndirectParamW(hinst, pTemplate, m_hwndTab,
										(DLGPROC)s_tabProc, (LPARAM)&tp);
		UT_ASSERT_HARMLESS((w && (w == m_hwndBreaks)));
	}

	// HACK: make sure the first tab is visible
	// TODO: trigger selchange logic instead
	ShowWindow(m_hwndSpacing, SW_SHOW);

	// sync all controls once to get started
	// HACK: the first arg gets ignored
	_syncControls(id_MENU_ALIGNMENT, true);
	centerDialog();
	return 1;							// 1 == we did not call SetFocus()
}
Exemplo n.º 21
0
/*
 * ExceptionProc
 */
BOOL CALLBACK ExceptionProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
    WORD                cmd;
    ExceptDlgInfo       *info;
    ProcNode            *procinfo;
    WORD                tmp;
    address             addr;

    info = FaultGetExceptDlgInfo( hwnd );
    switch( msg ) {
    case WM_INITDIALOG:
        /* make sure this dialog always comes up on top of everything else */
        SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0,
                        SWP_NOSIZE | SWP_NOMOVE );
        SetWindowPos( hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
                        SWP_NOSIZE | SWP_NOMOVE );
        centerDialog( hwnd );
        info = MemAlloc( sizeof( ExceptDlgInfo ) );
        info->dbinfo = (DEBUG_EVENT *)lparam;
        info->rc = 0;
        info->action = 0;
        SetWindowLong( hwnd, DWL_USER, (DWORD)info );
        info->procinfo = FindProcess( info->dbinfo->dwProcessId );
        info->threadinfo = FindThread( info->procinfo,
                                       info->dbinfo->dwThreadId );
        info->module = ModuleFromAddr( info->procinfo,
               info->dbinfo->u.Exception.ExceptionRecord.ExceptionAddress );
        if( info->threadinfo != NULL ) {
            AllocMadRegisters( &(info->regs) );
            LoadMADRegisters( info->regs, info->threadinfo->threadhdl );
            GetCurrAddr( &( info->init_ip ), info->regs );
        }
        if( info->module == NULL ) {
            info->got_dbginfo = FALSE;
        } else {
            if( !LoadDbgInfo( info->module ) ) {
                info->got_dbginfo = FALSE;
            } else {
                info->got_dbginfo = TRUE;
            }
        }
        if( LogData.autolog ) {         //Just create the log and exit
            tmp = ConfigData.exception_action;
            CheckDlgButton( hwnd, INT_TERMINATE, BST_CHECKED );
            SendMessage( hwnd, WM_COMMAND,
                        MAKELONG( INT_ACT_AND_LOG, BN_CLICKED ),
                        (LPARAM)GetDlgItem( hwnd, INT_ACT_AND_LOG ) );
            ConfigData.exception_action = tmp;
        } else {
            fillExceptionDlg( hwnd, info );
        }
        setProcessHdl( info->procinfo->prochdl );
        break;
    case WM_COMMAND:
        cmd = LOWORD( wparam );
        switch( cmd ) {
        case INT_ACT_AND_LOG:
            MakeLog( info );
            /* fall through */
        case INT_ACT:
            if( IsDlgButtonChecked( hwnd, INT_TERMINATE ) ) {
                ConfigData.exception_action = INT_TERMINATE;
//              hp = OpenProcess( PROCESS_TERMINATE, FALSE,
//                                info->dbinfo->dwProcessId );
                procinfo = FindProcess( info->dbinfo->dwProcessId );
                if( procinfo == NULL ) {
                    RCMessageBox( hwnd, STR_CANT_TERMINATE_APP,
                                  AppName, MB_OK | MB_ICONEXCLAMATION );
                } else {
                    TerminateProcess( procinfo->prochdl, -1 );
//                  CloseHandle( hp );
                    info->rc = DBG_CONTINUE;
                    info->action = INT_TERMINATE;
                    SendMessage( hwnd, WM_CLOSE, 0, 0L );
                }
            } else if( IsDlgButtonChecked( hwnd, INT_CHAIN_TO_NEXT ) ) {
                ConfigData.exception_action = INT_CHAIN_TO_NEXT;
                info->rc = DBG_EXCEPTION_NOT_HANDLED;
                info->action = INT_CHAIN_TO_NEXT;
                SendMessage( hwnd, WM_CLOSE, 0, 0L );
            } else if( IsDlgButtonChecked( hwnd, INT_RESTART ) ) {
                ConfigData.exception_action = INT_RESTART;
                info->rc = DBG_CONTINUE;
                info->action = INT_RESTART;
                SendMessage( hwnd, WM_CLOSE, 0, 0L );
            }
            break;
        case INT_REGISTERS:
            SetDisasmInfo( info->procinfo->prochdl, info->module );
            StatShowSymbols = TRUE;
            if ( DoStatDialog( hwnd ) == 1 ){
                StoreMADRegisters( info->regs, info->threadinfo->threadhdl );
                GetCurrAddr(&addr,info->regs);
                SetIp( hwnd, &addr );
            }
            LoadMADRegisters( info->regs, info->threadinfo->threadhdl );
            break;
        case INT_LOG_OPTIONS:
            SetLogOptions( hwnd );
            break;
        }
        break;
    case WM_CLOSE:
        if( info->rc == 0 ) {
            SendMessage( hwnd, WM_COMMAND, INT_ACT, 0L );
        } else {
            if( info->got_dbginfo ) {
                UnloadDbgInfo( info->module );
            }
            EndDialog( hwnd, info->rc );
        }
        break;
    case WM_DESTROY:
        DeAllocMadRegisters( info->regs );
        MemFree( info );
        break;
    default:
        return( FALSE );
        break;
    }
    return( TRUE );
}
BOOL AP_Win32Dialog_ListRevisions::_onInitDialog(HWND hWnd, WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	const XAP_StringSet * pSS = m_pApp->getStringSet();
    
	setDialogTitle (getTitle());

	// localize controls
	_DSX(BTN_OK,			DLG_OK);
	_DSX(BTN_CANCEL,		DLG_Cancel);

	setDlgItemText(AP_RID_DIALOG_LIST_REVISIONS_FRAME,getLabel1());

	// set the column headings
	HWND h = GetDlgItem(hWnd, AP_RID_DIALOG_LIST_REVISIONS_LIST);

    LVCOLUMNW col;
    UT_Win32LocaleString str;
	col.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH;

	int col_hdr[3]={AP_STRING_ID_DLG_ListRevisions_Column1Label,
					AP_STRING_ID_DLG_ListRevisions_Column2Label,
					AP_STRING_ID_DLG_ListRevisions_Column3Label};
	int col_wid[3]={80,160,230};

	for (int i=0; i<3; i++) {
		col.iSubItem = i;
		col.cx = col_wid[i];
		str.fromUTF8(pSS->getValue(col_hdr[i]));
		col.pszText = (LPWSTR) str.c_str();
		SendMessageW(h, LVM_INSERTCOLUMNW, i, (LPARAM)&col);
	}

	ListView_SetItemCount(h, getItemCount());

	LVITEMW item;
	item.state = 0;
	item.stateMask = 0;
	item.iImage = 0;

	WCHAR buf[60];
	const char *tmp;
	item.pszText = buf;

	for(UT_uint32 i = 0; i < getItemCount(); i++)
	{
		wsprintfW(buf,L"%d",getNthItemId(i));
		item.pszText = buf;
		item.iItem = i;
		item.iSubItem = 0;
		item.lParam = getNthItemId(i);
		item.mask = LVIF_TEXT | LVIF_PARAM;
		SendMessageW(h, LVM_INSERTITEMW, 0, (LPARAM)&item);

		item.iSubItem = 1;
		tmp=getNthItemTime(i);
		if (tmp) {
			str.fromASCII(tmp,-1);
			item.pszText = (LPWSTR) str.c_str();
		} else {
			item.pszText = L"";
		}
		item.mask = LVIF_TEXT;
		SendMessageW(h, LVM_SETITEMW, 0, (LPARAM)&item);
		
		item.iSubItem = 2;
		str.fromUTF8(getNthItemText(i));
		item.pszText = (LPWSTR) str.c_str();
		item.mask = LVIF_TEXT;
		SendMessageW(h, LVM_SETITEMW, 0, (LPARAM)&item);
	}
   
	SendMessageW(h, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);  								
    centerDialog();	

	return 1;							// 1 == we did not call SetFocus()
}