void AP_Win32Dialog_SplitCells::runModeless(XAP_Frame * pFrame) { // raise the dialog int iResult; XAP_Win32App * pWin32App = static_cast<XAP_Win32App *>(m_pApp); LPCTSTR lpTemplate = NULL; UT_return_if_fail (m_id == AP_DIALOG_ID_SPLIT_CELLS); lpTemplate = MAKEINTRESOURCE(AP_RID_DIALOG_SPLITCELLS); HWND hResult = CreateDialogParam(pWin32App->getInstance(),lpTemplate, static_cast<XAP_Win32FrameImpl*>(pFrame->getFrameImpl())->getTopLevelWindow(), (DLGPROC)s_dlgProc,(LPARAM)this); UT_ASSERT_HARMLESS((hResult != NULL)); m_hwndDlg = hResult; // Save dialog the ID number and pointer to the widget UT_sint32 sid =(UT_sint32) getDialogId(); m_pApp->rememberModelessId( sid, (XAP_Dialog_Modeless *) m_pDialog); iResult = ShowWindow( m_hwndDlg, SW_SHOW ); iResult = BringWindowToTop( m_hwndDlg ); startUpdater(); UT_ASSERT_HARMLESS((iResult != 0)); }
void AP_Win32Dialog_FormatTable::runModeless(XAP_Frame * pFrame) { UT_return_if_fail (pFrame); XAP_Win32App * pWin32App = static_cast<XAP_Win32App *>(m_pApp); LPCTSTR lpTemplate = NULL; UT_return_if_fail (m_id == AP_DIALOG_ID_FORMAT_TABLE); lpTemplate = MAKEINTRESOURCE(AP_RID_DIALOG_FORMATTABLE); HWND hResult = CreateDialogParam(pWin32App->getInstance(),lpTemplate, static_cast<XAP_Win32FrameImpl*>(pFrame->getFrameImpl())->getTopLevelWindow(), (DLGPROC)s_dlgProc,(LPARAM)this); m_hwndDlg = hResult; // Save dialog the ID number and pointer to the widget UT_sint32 sid =(UT_sint32) getDialogId(); m_pApp->rememberModelessId( sid, (XAP_Dialog_Modeless *) m_pDialog); ShowWindow(m_hwndDlg, SW_SHOW); BringWindowToTop(m_hwndDlg); }
void AP_Win32Dialog_MailMerge::runModeless(XAP_Frame * pFrame) { UT_return_if_fail (pFrame); UT_return_if_fail (m_id == AP_DIALOG_ID_MAILMERGE); createModeless(pFrame, MAKEINTRESOURCEW(AP_RID_DIALOG_MAILMERGE)); // Save dialog the ID number and pointer to the widget m_pFrame = pFrame; UT_sint32 sid =(UT_sint32) getDialogId(); m_pApp->rememberModelessId( sid, (XAP_Dialog_Modeless *) m_pDialog); }
void AP_Win32Dialog_MergeCells::runModeless(XAP_Frame * pFrame) { UT_return_if_fail (pFrame); UT_return_if_fail (m_id == AP_DIALOG_ID_MERGE_CELLS); createModeless(pFrame, MAKEINTRESOURCEW(AP_RID_DIALOG_MERGECELLS)); // Save dialog the ID number and pointer to the widget UT_sint32 sid =(UT_sint32) getDialogId(); m_pApp->rememberModelessId( sid, (XAP_Dialog_Modeless *) m_pDialog); startUpdater(); }
void AP_UnixPreview_Annotation::_constructWindow(void) { XAP_App::getApp()->rememberModelessId(getDialogId(), static_cast<XAP_Dialog_Modeless *>(this)); UT_DEBUGMSG(("Contructing Window width %d height %d left %d top %d \n",m_width,m_height,m_left,m_top)); m_pPreviewWindow = gtk_window_new(GTK_WINDOW_POPUP); gtk_widget_set_size_request(m_pPreviewWindow, m_width, m_height); gtk_window_set_position(GTK_WINDOW(m_pPreviewWindow),GTK_WIN_POS_MOUSE); gint root_x,root_y; gtk_window_get_position (GTK_WINDOW(m_pPreviewWindow),&root_x,&root_y); m_pDrawingArea = createDrawingArea(); gtk_widget_show(GTK_WIDGET(m_pDrawingArea)); gtk_container_add(GTK_CONTAINER(m_pPreviewWindow), m_pDrawingArea); root_y -= (m_height/2 + m_Offset); gtk_window_move(GTK_WINDOW(m_pPreviewWindow), root_x, root_y); gtk_widget_show_all(GTK_WIDGET(m_pPreviewWindow)); }
void AP_Win32Dialog_FormatFrame::runModeless(XAP_Frame * pFrame) { UT_return_if_fail (pFrame); UT_return_if_fail (m_id == AP_DIALOG_ID_FORMAT_FRAME); createModeless(pFrame, MAKEINTRESOURCEW(AP_RID_DIALOG_FORMATFRAME)); // Save dialog the ID number and pointer to the widget UT_sint32 sid =(UT_sint32) getDialogId(); m_pApp->rememberModelessId( sid, (XAP_Dialog_Modeless *) m_pDialog); ShowWindow(m_hDlg, SW_SHOW); BringWindowToTop(m_hDlg); }
void AP_Win32Dialog_Stylist::runModeless(XAP_Frame * pFrame) { // raise the dialog int iResult; XAP_Win32App * pWin32App = static_cast<XAP_Win32App *>(m_pApp); m_bIsModal = false; UT_return_if_fail (m_id == AP_DIALOG_ID_STYLIST); createModeless (pFrame, MAKEINTRESOURCEW(AP_RID_DIALOG_STYLIST)); // Save dialog the ID number and pointer to the widget UT_sint32 sid =(UT_sint32) getDialogId(); m_pApp->rememberModelessId( sid, (XAP_Dialog_Modeless *) m_pDialog); iResult = ShowWindow( m_hDlg, SW_SHOW ); iResult = BringWindowToTop( m_hDlg ); UT_ASSERT_HARMLESS((iResult != 0)); }
bool XAP_UnixDialog_FileOpenSaveAs::_run_gtk_main(XAP_Frame * pFrame, GtkWidget * filetypes_pulldown) { /* Run the dialog in a loop to catch bad filenames. The location of this check being in this dialog loop could be considered temporary. Doing this matches the Windows common control behavior (where the dialog checks everything for the programmer), but lacks flexibility for different uses of this dialog (file export, print export, directory (not file) selection). This check might need to be moved into the ap code which calls this dialog, and certain interfaces exposed so that the dialog is displayed throughout the verification. For right now you can signal this check on and off with bCheckWritePermission. */ char * szDialogFilename = NULL; // this is the file name returned from the dialog char * szFinalPathname = NULL; // this is the file name after suffix addition, if any char * szFinalPathnameCopy = NULL; // one to mangle when looking for dirs, etc. char * pLastSlash; // if m_bSave is not set, we're looking to OPEN a file. // otherwise we are looking to SAVE a file. if (!m_bSave) { while (1) { gtk_main(); if (m_answer == a_CANCEL) // The easy way out return false; m_szFinalPathnameCandidate = gtk_file_chooser_get_uri(m_FC); UT_ASSERT(m_szFinalPathnameCandidate); return (m_answer == a_OK); } } else { while(1) { gtk_main(); if (m_answer == a_CANCEL) // The easy way out return false; // Give us a filename we can mangle szDialogFilename = gtk_file_chooser_get_uri(m_FC); if (!szDialogFilename) continue; // We append the suffix of the default type, so the user doesn't // have to. This is adapted from the Windows front-end code // (xap_Win32Dlg_FileOpenSaveAs.cpp), since it should act the same. // If, however, the user doesn't want suffixes, they don't have to have them. { //UT_uint32 end = g_strv_length(m_szSuffixes); UT_sint32 nFileType = XAP_comboBoxGetActiveInt(GTK_COMBO_BOX(filetypes_pulldown)); // set to first item, which should probably be auto detect // TODO : "probably" isn't very good. UT_uint32 nIndex = 0; // the index in the types table will match the index in the suffix // table. nFileType is the data we are searching for. if(m_nTypeList != NULL) { for (UT_uint32 i = 0; m_nTypeList[i]; i++) { if (m_nTypeList[i] == nFileType) { nIndex = i; break; } } } bool wantSuffix = true; XAP_Prefs *pPrefs= XAP_App::getApp()->getPrefs(); pPrefs->getPrefsValueBool(static_cast<const gchar *>(XAP_PREF_KEY_UseSuffix), &wantSuffix); UT_DEBUGMSG(("UseSuffix: %d\n", wantSuffix)); if (nFileType > 0 && getDialogId() != XAP_DIALOG_ID_FILE_SAVE_IMAGE) // 0 means autodetect { if (!UT_pathSuffix(szDialogFilename).empty()) { // warn if we have a suffix that doesn't match the selected file type IE_ExpSniffer* pSniffer = IE_Exp::snifferForFileType(m_nTypeList[nIndex]); if (pSniffer && !pSniffer->recognizeSuffix(UT_pathSuffix(szDialogFilename).c_str())) { UT_UTF8String msg; const XAP_StringSet * pSS = m_pApp->getStringSet(); pSS->getValueUTF8(XAP_STRING_ID_DLG_FOSA_ExtensionDoesNotMatch, msg); if (pFrame->showMessageBox(msg.utf8_str(), XAP_Dialog_MessageBox::b_YN, XAP_Dialog_MessageBox::a_NO) != XAP_Dialog_MessageBox::a_YES) goto ContinueLoop; } szFinalPathname = g_strdup(szDialogFilename); } else if (wantSuffix) { // if the file doesn't have a suffix already, and the file type // is normal (special types are negative, like auto detect), // and the user wants extensions, slap a suffix on it. // add suffix based on selected file type UT_UTF8String suffix (IE_Exp::preferredSuffixForFileType(m_nTypeList[nIndex])); UT_uint32 length = strlen(szDialogFilename) + suffix.size() + 1; szFinalPathname = static_cast<char *>(UT_calloc(length,sizeof(char))); if (szFinalPathname) { char * p = szFinalPathname; strcpy(p,szDialogFilename); strcat(p,suffix.utf8_str()); } } else szFinalPathname = g_strdup(szDialogFilename); } else { // the file type is special (auto detect) // set to plain name, and let the auto detector in the // exporter figure it out szFinalPathname = g_strdup(szDialogFilename); } // g_free szDialogFilename since it's been put into szFinalPathname (with // or without changes) and it's invalid (missing an extension which // might have been appended) FREEP(szDialogFilename); } szFinalPathnameCopy = g_strdup(szFinalPathname); if (UT_go_file_exists(szFinalPathnameCopy)) { // we have an existing file, ask to overwrite if (_askOverwrite_YesNo(pFrame, szFinalPathname)) { m_szFinalPathnameCandidate = g_strdup(szFinalPathname); goto ReturnTrue; } goto ContinueLoop; } // We have a string that may contain a path, and may have a file // at the end. First, strip off a file (if it exists), and test // for a matching directory. We can then proceed with the file // if another stat of that dir passes. if (szFinalPathnameCopy && strlen(szFinalPathnameCopy)) pLastSlash = strrchr(szFinalPathnameCopy,'/'); else pLastSlash = NULL; if (!pLastSlash) { _notifyError_OKOnly(pFrame,XAP_STRING_ID_DLG_InvalidPathname); goto ContinueLoop; } m_szFinalPathnameCandidate = g_strdup(szFinalPathname); goto ReturnTrue; // complain about write permission on the directory. // lop off ugly trailing slash only if we don't have // the root dir ('/') for a path if (pLastSlash > szFinalPathnameCopy) *pLastSlash = 0; _notifyError_OKOnly(pFrame,XAP_STRING_ID_DLG_NoSaveFile_DirNotWriteable, szFinalPathname); ContinueLoop: FREEP(szFinalPathnameCopy); } } /* if m_bSave */ /*NOTREACHED*/ ReturnTrue: FREEP(szFinalPathnameCopy); FREEP(szFinalPathname); return true; }