void AP_UnixDialog_Stylist::runModal(XAP_Frame * pFrame) { // Build the window's widgets and arrange them m_bIsModal = true; GtkWidget * mainWindow = _constructWindow(); UT_return_if_fail(mainWindow); // Populate the window's data items _populateWindowData(); _connectSignals(); switch (abiRunModalDialog ( GTK_DIALOG(mainWindow), pFrame, this, GTK_RESPONSE_CLOSE,false )) { case GTK_RESPONSE_CLOSE: setStyleValid(false); break; case GTK_RESPONSE_OK: setStyleValid(true); break; default: setStyleValid(false); break; } abiDestroyWidget(mainWindow); }
void AP_UnixDialog_Break::runModal(XAP_Frame * pFrame) { UT_return_if_fail(pFrame); // Build the dialog's window m_windowMain = _constructWindow(); UT_return_if_fail(m_windowMain); _populateWindowData(); switch ( abiRunModalDialog ( GTK_DIALOG(m_windowMain), pFrame, this, CUSTOM_RESPONSE_INSERT, false ) ) { case CUSTOM_RESPONSE_INSERT: m_answer = AP_Dialog_Break::a_OK; break; default: m_answer = AP_Dialog_Break::a_CANCEL; break; } _storeWindowData(); abiDestroyWidget ( m_windowMain ) ; }
void AP_UnixDialog_CollaborationShare::runModal(XAP_Frame * pFrame) { UT_return_if_fail(pFrame); // Build the dialog's window m_wWindowMain = _constructWindow(); UT_return_if_fail(m_wWindowMain); _populateWindowData(); switch ( abiRunModalDialog ( GTK_DIALOG(m_wWindowMain), pFrame, this, GTK_RESPONSE_CANCEL, false ) ) { case GTK_RESPONSE_CANCEL: m_answer = AP_UnixDialog_CollaborationShare::a_CANCEL; break; case GTK_RESPONSE_OK: m_answer = AP_UnixDialog_CollaborationShare::a_OK; break; default: m_answer = AP_UnixDialog_CollaborationShare::a_CANCEL; break; } _freeBuddyList(); abiDestroyWidget(m_wWindowMain); }
GtkWidget * XAP_UnixDialog_History::_constructWindow(void) { const XAP_StringSet * pSS = m_pApp->getStringSet(); // load the dialog from the UI file GtkBuilder* builder = newDialogBuilder("xap_UnixDlg_History.ui"); // Update our member variables with the important widgets that // might need to be queried or altered later m_windowMain = GTK_WIDGET(gtk_builder_get_object(builder, "xap_UnixDlg_History")); UT_ASSERT(m_windowMain); std::string s; pSS->getValueUTF8(XAP_STRING_ID_DLG_History_WindowLabel,s); gtk_window_set_title (GTK_WINDOW(m_windowMain), s.c_str()); m_wListWindow = GTK_WIDGET(gtk_builder_get_object(builder, "wListWindow")); _fillHistoryTree(); // set the single selection mode for the TreeView gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (m_wTreeView)), GTK_SELECTION_SINGLE); gtk_container_add (GTK_CONTAINER (m_wListWindow), m_wTreeView); #if 1 g_signal_connect_after(G_OBJECT(m_wTreeView), "cursor-changed", G_CALLBACK(s_history_selected), static_cast<gpointer>(this)); #endif gtk_widget_show_all(m_wTreeView); _populateWindowData(builder); g_object_unref(G_OBJECT(builder)); return m_windowMain; }
void AP_Dialog_Options::_event_SetDefaults(void) { XAP_Prefs *pPrefs; const gchar *old_name; int currentPage; pPrefs = m_pApp->getPrefs(); UT_return_if_fail (pPrefs); // SetDefaults // To set the defaults, save the scheme name and notebook page number, // re-populate the window with the _builtin_ scheme, then reset the // scheme name and page number. // If the user hits cancel, then nothing is saved in user_prefs old_name = pPrefs->getCurrentScheme()->getSchemeName(); currentPage = _gatherNotebookPageNum(); pPrefs->setCurrentScheme("_builtin_"); _populateWindowData(); // TODO i'm not sure you want to do the following at this // TODO time. setting to "defaults" should probably just // TODO set us to "_builtin_" and that's it. if the user // TODO then changes something, we should create a new // TODO scheme and fill in the new value. --jeff _setNotebookPageNum( currentPage ); pPrefs->setCurrentScheme(old_name); }
void AP_UnixDialog_FormatFrame::runModeless(XAP_Frame * pFrame) { // Build the window's widgets and arrange them m_windowMain = _constructWindow(); UT_return_if_fail(m_windowMain); // Populate the window's data items _populateWindowData(); _connectSignals(); abiSetupModelessDialog(GTK_DIALOG(m_windowMain), pFrame, this, BUTTON_CLOSE); // *** this is how we add the gc for Column Preview *** // attach a new graphics context to the drawing area UT_return_if_fail(m_wPreviewArea && m_wPreviewArea->window); // make a new Unix GC DELETEP (m_pPreviewWidget); GR_UnixCairoAllocInfo ai(m_wPreviewArea); m_pPreviewWidget = (GR_UnixCairoGraphics*) XAP_App::getApp()->newGraphics(ai); // Todo: we need a good widget to query with a probable // Todo: non-white (i.e. gray, or a similar bgcolor as our parent widget) // Todo: background. This should be fine m_pPreviewWidget->init3dColors(m_wPreviewArea->style); // let the widget materialize _createPreviewFromGC(m_pPreviewWidget, static_cast<UT_uint32>(m_wPreviewArea->allocation.width), static_cast<UT_uint32>(m_wPreviewArea->allocation.height)); m_pFormatFramePreview->draw(); startUpdater(); }
/*! * Run dialog. */ void AP_UnixDialog_Spell::runModal (XAP_Frame * pFrame) { // class the base class method to initialize some basic xp stuff AP_Dialog_Spell::runModal(pFrame); bool bRes = nextMisspelledWord(); if (bRes) { // we need to prepare the dialog GtkWidget * mainWindow = _constructWindow(); UT_ASSERT(mainWindow); // Populate the window's data items _populateWindowData(); abiSetupModalDialog(GTK_DIALOG(mainWindow), pFrame, this, GTK_RESPONSE_CLOSE); // now loop while there are still misspelled words while (bRes) { // show word in main window makeWordVisible(); gpointer inst = gtk_tree_view_get_selection (GTK_TREE_VIEW (m_lvSuggestions)); g_signal_handler_block (inst, m_listHandlerID); // update dialog with new misspelled word info/suggestions _updateWindow(); g_signal_handler_unblock (inst, m_listHandlerID); // run into the GTK event loop for this window gint response = abiRunModalDialog (GTK_DIALOG(mainWindow), false); UT_DEBUGMSG (("ROB: response='%d'\n", response)); switch(response) { case SPELL_RESPONSE_CHANGE: onChangeClicked (); break; case SPELL_RESPONSE_CHANGE_ALL: onChangeAllClicked (); break; case SPELL_RESPONSE_IGNORE: onIgnoreClicked (); break; case SPELL_RESPONSE_IGNORE_ALL: onIgnoreAllClicked (); break; case SPELL_RESPONSE_ADD: onAddClicked (); break; default: m_bCancelled = TRUE; _purgeSuggestions(); gtk_widget_destroy (m_wDialog); return; } _purgeSuggestions(); // get the next unknown word bRes = nextMisspelledWord(); } abiDestroyWidget(mainWindow); } }
void AP_UnixDialog_SplitCells::runModeless(XAP_Frame * pFrame) { // Build the window's widgets and arrange them GtkWidget * mainWindow = _constructWindow(); UT_return_if_fail(mainWindow); // Populate the window's data items _populateWindowData(); _connectSignals(); abiSetupModelessDialog(GTK_DIALOG(mainWindow),pFrame,this,BUTTON_CLOSE); startUpdater(); }
BOOL AP_Win32Dialog_CollaborationAccounts::_onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam) { // Set up common controls INITCOMMONCONTROLSEX icc; icc.dwSize=sizeof(INITCOMMONCONTROLSEX); icc.dwICC=ICC_LISTVIEW_CLASSES; m_hAccountList = GetDlgItem(hWnd, AP_RID_DIALOG_COLLABORATIONACCOUNTS_ACCOUNT_LIST); // setup our listview columns // column 0 LVCOLUMNW lvc; lvc.mask = LVCF_WIDTH | LVCF_TEXT; lvc.pszText = L"Online"; lvc.cx = 50; ListView_InsertColumn(m_hAccountList, 0, &lvc); // column 1 lvc.mask = LVCF_WIDTH | LVCF_TEXT; lvc.pszText = L"Account"; lvc.cx = 180; ListView_InsertColumn(m_hAccountList, 1, &lvc); // column 2 lvc.mask = LVCF_WIDTH | LVCF_TEXT; lvc.pszText = L"Type"; lvc.cx = 200; ListView_InsertColumn(m_hAccountList, 2, &lvc); // enable checkboxes and row select on items in the list view ListView_SetExtendedListViewStyle(m_hAccountList, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT); // Get ourselves a custom DialogHelper DELETEP(m_pWin32Dialog); m_pWin32Dialog = new XAP_Win32DialogHelper(hWnd); // Set up dialog initial state _populateWindowData(); // we have no selection yet //_updateSelection(); // Center Window m_pWin32Dialog->centerDialog(); return true; }
void AP_Win32Dialog_CollaborationAccounts::signal(const Event& event, BuddyPtr pSource) { UT_DEBUGMSG(("AP_Win32Dialog_CollaborationAccounts::signal()\n")); switch (event.getClassType()) { case PCT_AccountNewEvent: case PCT_AccountOnlineEvent: case PCT_AccountOfflineEvent: // FIXME: VERY VERY BAD, CHECK WHICH ACCOUNT HAS CHANGED, AND UPDATE THAT _populateWindowData(); break; default: // we will ignore the rest break; } }
void XAP_UnixDialog_Encoding::runModal(XAP_Frame * pFrame) { // Build the window's widgets and arrange them GtkWidget * mainWindow = _constructWindow(); UT_return_if_fail(mainWindow); // Populate the window's data items _populateWindowData(); switch ( abiRunModalDialog ( GTK_DIALOG(mainWindow), pFrame, this, GTK_RESPONSE_CANCEL, false ) ) { case GTK_RESPONSE_OK: event_Ok (); break; default: event_Cancel (); break; } abiDestroyWidget ( mainWindow ) ; }
void XAP_UnixDialog_Language::runModal(XAP_Frame * pFrame) { // build the dialog GtkWidget * cf = constructWindow(); UT_return_if_fail(cf); _populateWindowData(); // connect a dbl-clicked signal to the column g_signal_connect_after(G_OBJECT(m_pLanguageList), "row-activated", G_CALLBACK(s_lang_dblclicked), static_cast<gpointer>(this)); abiRunModalDialog ( GTK_DIALOG(cf), pFrame, this, GTK_RESPONSE_CLOSE, false ); event_setLang(); abiDestroyWidget(cf); }
void AP_UnixDialog_Styles::event_ListClicked(const char * which) { const XAP_StringSet * pSS = m_pApp->getStringSet(); UT_UTF8String s; pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_LBL_InUse,s); if (!strcmp(which, s.utf8_str())) m_whichType = USED_STYLES; else { pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_LBL_UserDefined,s); if (!strcmp(which, s.utf8_str())) m_whichType = USER_STYLES; else m_whichType = ALL_STYLES; } // force a refresh of everything _populateWindowData(); }
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() }
void XAP_UnixDialog_WindowMore::runModal(XAP_Frame * pFrame) { // Initialize member so we know where we are now m_ndxSelFrame = m_pApp->findFrame(pFrame); UT_ASSERT_HARMLESS(m_ndxSelFrame >= 0); // Build the window's widgets and arrange them GtkWidget * mainWindow = _constructWindow(); UT_return_if_fail(mainWindow); // Populate the window's data items _populateWindowData(); switch ( abiRunModalDialog ( GTK_DIALOG(mainWindow), pFrame, this, CUSTOM_RESPONSE_VIEW, false ) ) { case CUSTOM_RESPONSE_VIEW: event_View () ; break ; default: event_Cancel (); break ; } abiDestroyWidget ( mainWindow ) ; }
void AP_UnixDialog_CollaborationAccounts::runModal(XAP_Frame * pFrame) { UT_return_if_fail(pFrame); // Build the dialog's window m_wWindowMain = _constructWindow(); UT_return_if_fail(m_wWindowMain); _populateWindowData(); switch ( abiRunModalDialog ( GTK_DIALOG(m_wWindowMain), pFrame, this, GTK_RESPONSE_CLOSE, false ) ) { case GTK_RESPONSE_CLOSE: m_answer = AP_Dialog_CollaborationAccounts::a_CLOSE; break; default: m_answer = AP_Dialog_CollaborationAccounts::a_CLOSE; break; } abiDestroyWidget(m_wWindowMain); }
void AP_UnixDialog_Styles::event_DeleteClicked(void) { if (m_selectedStyle) { m_sNewStyleName = ""; gchar * style = NULL; GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(m_tvStyles)); GtkTreeIter iter; gtk_tree_model_get_iter(model, &iter, m_selectedStyle); gtk_tree_model_get(model, &iter, 0, &style, -1); if (!style) return; // ok, nothing's selected. that's fine UT_DEBUGMSG(("DOM: attempting to delete style %s\n", style)); if (!getDoc()->removeStyle(style)) // actually remove the style { const XAP_StringSet * pSS = m_pApp->getStringSet(); UT_UTF8String s; pSS->getValueUTF8 (AP_STRING_ID_DLG_Styles_ErrStyleCantDelete,s); const gchar * msg = s.utf8_str(); getFrame()->showMessageBox (static_cast<const char *>(msg), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK); return; } g_free(style); getFrame()->repopulateCombos(); _populateWindowData(); // force a refresh getDoc()->signalListeners(PD_SIGNAL_UPDATE_LAYOUT); } }
void AP_UnixDialog_GenericInput::runModal(XAP_Frame * pFrame) { // Build the dialog's window m_wWindowMain = _constructWindow(); UT_return_if_fail(m_wWindowMain); _populateWindowData(); switch ( abiRunModalDialog ( GTK_DIALOG(m_wWindowMain), pFrame, this, GTK_RESPONSE_OK, false ) ) { case GTK_RESPONSE_CANCEL: m_answer = AP_UnixDialog_GenericInput::a_CANCEL; break; case GTK_RESPONSE_OK: m_answer = AP_UnixDialog_GenericInput::a_OK; break; default: m_answer = AP_UnixDialog_GenericInput::a_CANCEL; break; } abiDestroyWidget(m_wWindowMain); }
// return true if we process the command, false otherwise BOOL AP_Win32Dialog_CollaborationAccounts::_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { WORD wNotifyCode = HIWORD(wParam); WORD wId = LOWORD(wParam); switch (wId) { case AP_RID_DIALOG_COLLABORATIONACCOUNTS_CLOSE_BUTTON: m_answer=AP_Dialog_CollaborationAccounts::a_CLOSE; EndDialog(hWnd,0); return true; case AP_RID_DIALOG_COLLABORATIONACCOUNTS_ADD_BUTTON: // open the Add dialog createNewAccount(); // TODO: only refresh if it actually changed. _populateWindowData(); return true; case AP_RID_DIALOG_COLLABORATIONACCOUNTS_DELETE_BUTTON: { AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager(); UT_return_val_if_fail(pManager, false); bool hasSelection = ListView_GetSelectedCount(m_hAccountList); if (!hasSelection) return true; UT_sint32 iIndex = ListView_GetSelectionMark(m_hAccountList); UT_return_val_if_fail(iIndex >= 0, false); LVITEM lviAccount; lviAccount.mask = LVIF_PARAM; lviAccount.iItem = iIndex; lviAccount.iSubItem = 0; UT_return_val_if_fail(ListView_GetItem(m_hAccountList, &lviAccount), false); UT_return_val_if_fail(lviAccount.lParam, false); AccountHandler* pAccount = reinterpret_cast<AccountHandler*>(lviAccount.lParam); // TODO: we should ask for confirmation, as this account handler // could be in use by serveral AbiCollab Sessions UT_DEBUGMSG(("Delete account: %s of type %s\n", pAccount->getDescription().utf8_str(), pAccount->getDisplayType().utf8_str() )); pManager->destroyAccount(pAccount); // for now, recreate the whole model; but we should really just delete // the iter we got above _populateWindowData(); } return true; case AP_RID_DIALOG_COLLABORATIONACCOUNTS_PROPERTIES_BUTTON: // open the Properties dialog. This does not exist yet, but when it does, we'll be ready. UT_DEBUGMSG(("AP_Win32Dialog_CollaborationAccounts::eventProperties()\n")); // TODO: implement me return true; default: // WM_COMMAND message NOT processed return false; } }
void AP_UnixDialog_Paragraph::runModal(XAP_Frame * pFrame) { m_pFrame = pFrame; // Build the window's widgets and arrange them GtkWidget * mainWindow = _constructWindow(); UT_ASSERT(mainWindow); // Populate the window's data items _populateWindowData(); // Attach signals (after data settings, so we don't trigger // updates yet) _connectCallbackSignals(); // Show the top level dialog, gtk_widget_show(mainWindow); #if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON #else // *** this is how we add the gc *** { // attach a new graphics context to the drawing area UT_ASSERT(m_drawingareaPreview && gtk_widget_get_window(m_drawingareaPreview)); // make a new Unix GC GR_UnixCairoAllocInfo ai(m_drawingareaPreview); m_unixGraphics = (GR_CairoGraphics*) XAP_App::getApp()->newGraphics(ai); // let the widget materialize GtkAllocation allocation; gtk_widget_get_allocation(m_drawingareaPreview, &allocation); _createPreviewFromGC(m_unixGraphics, (UT_uint32) allocation.width, (UT_uint32) allocation.height); } // sync all controls once to get started // HACK: the first arg gets ignored _syncControls(id_MENU_ALIGNMENT, true); #endif bool tabs; do { switch(abiRunModalDialog(GTK_DIALOG(mainWindow), pFrame, this, BUTTON_CANCEL, false)) { case BUTTON_OK: event_OK(); tabs = false; break; case BUTTON_TABS: event_Tabs (); tabs = true; break; default: event_Cancel(); tabs = false; break; } } while (tabs); abiDestroyWidget(mainWindow); }
BOOL AP_Win32Dialog_Styles::_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { WORD wNotifyCode = HIWORD(wParam); WORD wId = LOWORD(wParam); HWND hWndCtrl = (HWND)lParam; switch (wId) { case AP_RID_DIALOG_STYLES_TOP_BUTTON_APPLY: { const gchar * szStyle = getCurrentStyle(); if(szStyle && *szStyle) { getView()->setStyle(szStyle); } } m_answer = a_OK; return 1; case AP_RID_DIALOG_STYLES_TOP_BUTTON_CLOSE: case IDCANCEL: m_answer = a_CANCEL; EndDialog(hWnd,0); return 1; case IDOK: { const XAP_StringSet * pSS = m_pApp->getStringSet (); WCHAR stylename[MAX_EBX_LENGTH+1]; // Verfiy a name value for the style // TODO - Verify unique name value GetDlgItemTextW(hWnd,AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_NAME,stylename,MAX_EBX_LENGTH); /*_win32DialogNewModify.getControlText( AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_NAME, m_newStyleName, MAX_EBX_LENGTH );*/ UT_UTF8String str; str.appendUCS2((const UT_UCS2Char*)stylename,0); strcpy(m_newStyleName,str.utf8_str()); if( !m_newStyleName || !strlen(m_newStyleName) ) { getFrame()->showMessageBox( pSS->getValue (AP_STRING_ID_DLG_Styles_ErrBlankName), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK); return 1; } //strcpy (m_newStyleName, (AP_Win32App::s_fromWinLocaleToUTF8(m_newStyleName)).utf8_str()); } m_answer = a_OK; EndDialog(hWnd,0); return 1; case AP_RID_DIALOG_STYLES_TOP_COMBO_LIST: if( wNotifyCode == CBN_SELCHANGE ) { switch(_win32Dialog.getComboSelectedIndex(AP_RID_DIALOG_STYLES_TOP_COMBO_LIST)) { case 0: m_whichType = USED_STYLES; break; case 1: m_whichType = ALL_STYLES; break; case 2: m_whichType = USER_STYLES; break; } _populateWindowData(); } return 1; case AP_RID_DIALOG_STYLES_TOP_LIST_STYLES: if (wNotifyCode == LBN_SELCHANGE) { UT_uint32 nData = -1; const char* name; const PD_Style * pcStyle = NULL; int row = _win32Dialog.getListSelectedIndex(AP_RID_DIALOG_STYLES_TOP_LIST_STYLES); nData = _win32Dialog.getListDataItem( AP_RID_DIALOG_STYLES_TOP_LIST_STYLES, row); if (row!=LB_ERR) { getDoc()->enumStyles(nData, &name, &pcStyle); m_selectedStyle = name; m_nSelectedStyleIdx = nData; // refresh the previews _populatePreviews(false); } break; } return 1; case AP_RID_DIALOG_STYLES_TOP_BUTTON_DELETE: { if( m_selectedStyle != "" ) { if ( !getDoc()->removeStyle(m_selectedStyle.c_str()) ) // actually remove the style { const XAP_StringSet * pSS = m_pApp->getStringSet(); getFrame()->showMessageBox( pSS->getValue (AP_STRING_ID_DLG_Styles_ErrStyleCantDelete), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK ); return 1; } getFrame()->repopulateCombos(); _populateWindowData(); // force a refresh getDoc()->signalListeners(PD_SIGNAL_UPDATE_LAYOUT); m_selectedStyle = ""; } } return 1; case AP_RID_DIALOG_STYLES_TOP_BUTTON_NEW: { m_bisNewStyle = true; //_win32Dialog.showWindow(SW_HIDE); XAP_Frame* pFrame = getFrame(); //_win32DialogNewModify.runModal(pFrame, AP_DIALOG_ID_STYLES, AP_RID_DIALOG_STYLES_NEWMODIFY, this); createModal(pFrame, MAKEINTRESOURCEW(AP_RID_DIALOG_STYLES_NEWMODIFY)); if(m_answer == AP_Dialog_Styles::a_OK) { createNewStyle((gchar *) m_newStyleName); _populateCList(); } destroyAbiPreview(); DELETEP(m_pAbiPreviewWidget); //_win32Dialog.showWindow(SW_SHOW); } return 1; case AP_RID_DIALOG_STYLES_TOP_BUTTON_MODIFY: { // Verify that a style is selected if( m_selectedStyle == "" ) { XAP_Frame * pFrame = getFrame(); const XAP_StringSet * pSS = m_pApp->getStringSet(); pFrame->showMessageBox( pSS->getValue(AP_STRING_ID_DLG_Styles_ErrNoStyle), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK); m_answer = AP_Dialog_Styles::a_CANCEL; return 1; } else { PD_Style * pStyle = NULL; getDoc()->getStyle(m_selectedStyle.c_str(), &pStyle); m_bisNewStyle = false; XAP_Frame* pFrame = getFrame(); XAP_Win32App * pWin32App = static_cast<XAP_Win32App *>(getApp()); createModal (pFrame, MAKEINTRESOURCEW(AP_RID_DIALOG_STYLES_NEWMODIFY)); /*LPCWSTR lpTemplate = MAKEINTRESOURCEW(AP_RID_DIALOG_STYLES_NEWMODIFY); int result = DialogBoxParamW(pWin32App->getInstance(), lpTemplate, static_cast<XAP_Win32FrameImpl*>(pFrame->getFrameImpl())->getTopLevelWindow(), (DLGPROC)s_dlgProc, (LPARAM)this);*/ if(m_answer == AP_Dialog_Styles::a_OK) { applyModifiedStyleToDoc(); getDoc()->updateDocForStyleChange(getCurrentStyle(),true); getDoc()->signalListeners(PD_SIGNAL_UPDATE_LAYOUT); } destroyAbiPreview(); DELETEP(m_pAbiPreviewWidget); } } return 1; case AP_RID_DIALOG_STYLES_NEWMODIFY_BTN_REMOVE: { char szTemp[128]; _win32DialogNewModify.getControlText( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_REMOVE, szTemp, sizeof(szTemp) ); removeVecProp(szTemp); rebuildDeleteProps(); updateCurrentStyle(); } return 1; case AP_RID_DIALOG_STYLES_NEWMODIFY_BTN_TOGGLEITEMS: { RECT rect; HMENU hMenu; int x,y; HWND hWndButton; static int menu_items[]={AP_STRING_ID_DLG_Styles_ModifyParagraph, AP_STRING_ID_DLG_Styles_ModifyFont, AP_STRING_ID_DLG_Styles_ModifyTabs, AP_STRING_ID_DLG_Styles_ModifyNumbering, AP_STRING_ID_DLG_Styles_ModifyLanguage }; UT_Win32LocaleString str; hWndButton = GetDlgItem(hWnd, AP_RID_DIALOG_STYLES_NEWMODIFY_BTN_TOGGLEITEMS); XAP_Win32App * app = static_cast<XAP_Win32App *> (m_pApp); const XAP_StringSet * pSS = m_pApp->getStringSet(); // Get button position GetWindowRect(hWndButton, &rect); x = rect.left; y = rect.bottom; // Menu creation hMenu = CreatePopupMenu(); str; for (int i=0; i<5; i++) { str.fromUTF8(pSS->getValue(menu_items[i])); AppendMenuW(hMenu, MF_ENABLED|MF_STRING, i+1, (LPCWSTR)str.c_str()); } // show and track the menu m_selectToggle = TrackPopupMenu(hMenu, TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD, x,y,0, hWndButton, NULL); switch(m_selectToggle) { case 0: // user has cancelled break; case 1: ModifyParagraph(); break; case 2: ModifyFont(); break; case 3: ModifyTabs(); break; case 4: ModifyLists(); break; case 5: ModifyLang(); break; default: break; } rebuildDeleteProps(); updateCurrentStyle(); DestroyMenu(hMenu); return 1; } case AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_BASEDON: if( wNotifyCode == CBN_SELCHANGE ) { eventBasedOn(); rebuildDeleteProps(); } return 1; case AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_FOLLOWPARA: if( wNotifyCode == CBN_SELCHANGE ) { eventFollowedBy(); } return 1; case AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_TYPE: if( wNotifyCode == CBN_SELCHANGE ) { eventStyleType(); } 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. } return 0; // return zero to let windows take care of it. }
BOOL AP_Win32Dialog_Styles::_onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam) { XAP_Win32App * app = static_cast<XAP_Win32App *> (m_pApp); UT_return_val_if_fail (app,0); const XAP_StringSet * pSS = m_pApp->getStringSet(); WCHAR szTemp[20]; GetWindowTextW(hWnd, szTemp, 20 ); m_hDlg=hWnd; // Regular dialog box if( lstrcmpW(szTemp, L"Styles") == 0 ) { setDialogTitle (pSS->getValue(AP_STRING_ID_DLG_Styles_StylesTitle)); // localize controls _DS(STYLES_TOP_TEXT_LIST, DLG_Styles_List); _DS(STYLES_TOP_TEXT_PARAGRAPH_PREVIEW, DLG_Styles_ParaPrev); _DS(STYLES_TOP_TEXT_CHARACTER_PREVIEW, DLG_Styles_CharPrev); _DS(STYLES_TOP_TEXT_DESCRIPTION, DLG_Styles_Description); _DS(STYLES_TOP_BUTTON_DELETE, DLG_Styles_Delete); _DS(STYLES_TOP_BUTTON_MODIFY, DLG_Styles_Modify); _DS(STYLES_TOP_BUTTON_NEW, DLG_Styles_New); _DS(STYLES_TOP_TEXT_AVAILABLE, DLG_Styles_Available); // "Available Styles" GROUPBOX _DSX(STYLES_TOP_BUTTON_APPLY, DLG_Apply); _DSX(STYLES_TOP_BUTTON_CLOSE, DLG_Close); // Set the list combo. _win32Dialog.addItemToCombo(AP_RID_DIALOG_STYLES_TOP_COMBO_LIST, pSS->getValue (AP_STRING_ID_DLG_Styles_LBL_InUse)); _win32Dialog.addItemToCombo(AP_RID_DIALOG_STYLES_TOP_COMBO_LIST, pSS->getValue(AP_STRING_ID_DLG_Styles_LBL_All)); _win32Dialog.addItemToCombo(AP_RID_DIALOG_STYLES_TOP_COMBO_LIST, pSS->getValue(AP_STRING_ID_DLG_Styles_LBL_UserDefined)); _win32Dialog.selectComboItem(AP_RID_DIALOG_STYLES_TOP_COMBO_LIST, (int)m_whichType); // Create a preview windows. HWND hwndChild = GetDlgItem(hWnd, AP_RID_DIALOG_STYLES_TOP_TEXT_PARAGRAPH_PREVIEW); m_pParaPreviewWidget = new XAP_Win32PreviewWidget(static_cast<XAP_Win32App *>(m_pApp), hwndChild, 0); UT_uint32 w,h; m_pParaPreviewWidget->getWindowSize(&w,&h); _createParaPreviewFromGC(m_pParaPreviewWidget->getGraphics(), w, h); m_pParaPreviewWidget->setPreview(m_pParaPreview); hwndChild = GetDlgItem(hWnd, AP_RID_DIALOG_STYLES_TOP_TEXT_CHARACTER_PREVIEW); m_pCharPreviewWidget = new XAP_Win32PreviewWidget(static_cast<XAP_Win32App *>(m_pApp), hwndChild, 0); m_pCharPreviewWidget->getWindowSize(&w,&h); _createCharPreviewFromGC(m_pCharPreviewWidget->getGraphics(), w, h); m_pCharPreviewWidget->setPreview(m_pCharPreview); _populateWindowData(); } // This is either the new or Modify sub dialog of styles else { _win32DialogNewModify.setHandle(hWnd); // Localize the controls Labels etc... setWindowText(hWnd, pSS->getValue( (m_bisNewStyle) ? AP_STRING_ID_DLG_Styles_NewTitle : AP_STRING_ID_DLG_Styles_ModifyTitle )); #define _DS(c,s) setDlgItemText(hWnd, AP_RID_DIALOG_##c,pSS->getValue(AP_STRING_ID_##s)) #define _DSX(c,s) setDlgItemText(hWnd, AP_RID_DIALOG_##c,pSS->getValue(XAP_STRING_ID_##s)) _DS(STYLES_NEWMODIFY_LBL_NAME, DLG_Styles_ModifyName); _DS(STYLES_NEWMODIFY_LBL_BASEDON, DLG_Styles_ModifyBasedOn); _DS(STYLES_NEWMODIFY_LBL_TYPE, DLG_Styles_ModifyType); _DS(STYLES_NEWMODIFY_LBL_FOLLOWPARA, DLG_Styles_ModifyFollowing); _DS(STYLES_NEWMODIFY_LBL_REMOVE, DLG_Styles_RemoveLab); _DS(STYLES_NEWMODIFY_GBX_PREVIEW, DLG_Styles_ModifyPreview); _DS(STYLES_NEWMODIFY_GBX_DESC, DLG_Styles_ModifyDescription); _DS(STYLES_NEWMODIFY_BTN_REMOVE, DLG_Styles_RemoveButton); _DS(STYLES_NEWMODIFY_BTN_SHORTCUT, DLG_Styles_ModifyShortCut); _DSX(STYLES_NEWMODIFY_BTN_OK, DLG_OK); _DSX(STYLES_NEWMODIFY_BTN_CANCEL, DLG_Cancel); #undef _DSX #undef _DS // Changes basic controls based upon either New or Modify Dialog _win32DialogNewModify.showControl( AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_TYPE , (m_bisNewStyle) ? SW_HIDE : SW_SHOW ); _win32DialogNewModify.showControl( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_TYPE , (m_bisNewStyle) ? SW_SHOW : SW_HIDE ); // Initialize the controls with appropriate data size_t nStyles = getDoc()->getStyleCount(); const char * name = NULL; const char * pLocalised = NULL; const PD_Style * pcStyle = NULL; int nIndex; UT_Win32LocaleString str; UT_UTF8String utf8; UT_GenericVector<PD_Style*> * pStyles = NULL; getDoc()->enumStyles(pStyles); UT_return_val_if_fail( pStyles, FALSE ); for (UT_uint32 i = 0; i < nStyles; i++) { pcStyle = pStyles->getNthItem(i); UT_return_val_if_fail( pcStyle, FALSE ); name = pcStyle->getName(); pt_PieceTable::s_getLocalisedStyleName(name, utf8); pLocalised = utf8.utf8_str(); nIndex = _win32DialogNewModify.addItemToCombo(AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_BASEDON, pLocalised); _win32DialogNewModify.setComboDataItem(AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_BASEDON, nIndex, i); nIndex = _win32DialogNewModify.addItemToCombo(AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_FOLLOWPARA, pLocalised); _win32DialogNewModify.setComboDataItem(AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_FOLLOWPARA, nIndex, i); } delete pStyles; // Strings (not styles names) const char* pDefCurrent = pSS->getValue(AP_STRING_ID_DLG_Styles_DefCurrent); const char* pDefNone = pSS->getValue(AP_STRING_ID_DLG_Styles_DefNone); nIndex = _win32DialogNewModify.addItemToCombo( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_FOLLOWPARA, pDefCurrent ); _win32DialogNewModify.setComboDataItem(AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_FOLLOWPARA, nIndex, (DWORD)-1); nIndex = _win32DialogNewModify.addItemToCombo( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_BASEDON, pDefNone); _win32DialogNewModify.setComboDataItem(AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_BASEDON, nIndex, (DWORD)-1); if( m_bisNewStyle ) { const char* p = pSS->getValue(AP_STRING_ID_DLG_Styles_ModifyParagraph); _win32DialogNewModify.addItemToCombo( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_TYPE, p ); p = pSS->getValue(AP_STRING_ID_DLG_Styles_ModifyCharacter); _win32DialogNewModify.addItemToCombo( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_TYPE, p); // Set the Default syltes: none, default current UT_sint32 result; str.fromUTF8(pSS->getValue(AP_STRING_ID_DLG_Styles_DefNone)); result = SendDlgItemMessageW(hWnd, AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_BASEDON, CB_FINDSTRING, -1, (LPARAM) str.c_str()); _win32DialogNewModify.selectComboItem( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_BASEDON, result ); str.fromUTF8(pSS->getValue(AP_STRING_ID_DLG_Styles_DefCurrent)); result = SendDlgItemMessageW(hWnd, AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_FOLLOWPARA, CB_FINDSTRING, -1, (LPARAM) str.c_str()); _win32DialogNewModify.selectComboItem( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_FOLLOWPARA, result ); str.fromUTF8(pSS->getValue(AP_STRING_ID_DLG_Styles_ModifyParagraph)); result = SendDlgItemMessageW(hWnd, AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_TYPE, CB_FINDSTRING, -1, (LPARAM) str.c_str()); _win32DialogNewModify.selectComboItem( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_TYPE, result ); eventBasedOn(); eventFollowedBy(); eventStyleType(); fillVecFromCurrentPoint(); } else { const char * szCurrentStyle = NULL; const char * szBasedOn = NULL; const char * szFollowedBy = NULL; const char * pLocalised = NULL; PD_Style * pStyle = NULL; PD_Style * pBasedOnStyle = NULL; PD_Style * pFollowedByStyle = NULL; szCurrentStyle = m_selectedStyle.c_str(); pt_PieceTable::s_getLocalisedStyleName(szCurrentStyle, utf8); pLocalised = utf8.utf8_str(); _win32DialogNewModify.setControlText( AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_NAME, pLocalised); if(szCurrentStyle) getDoc()->getStyle(szCurrentStyle,&pStyle); if(!pStyle) { XAP_Frame * pFrame = getFrame(); pFrame->showMessageBox( pSS->getValue(AP_STRING_ID_DLG_Styles_ErrNoStyle), XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK); m_answer = AP_Dialog_Styles::a_CANCEL; return false; } // // Valid style get the Based On and followed by values // pBasedOnStyle = pStyle->getBasedOn(); pFollowedByStyle = pStyle->getFollowedBy(); size_t nStyles = getDoc()->getStyleCount(); const char * name = NULL; const PD_Style * pcStyle = NULL; UT_GenericVector<PD_Style*> * pStyles = NULL; getDoc()->enumStyles(pStyles); UT_return_val_if_fail( pStyles, FALSE ); for (UT_uint32 i = 0; i < nStyles; i++) { pcStyle = pStyles->getNthItem(i); UT_return_val_if_fail( pcStyle, FALSE ); name = pcStyle->getName(); if(pBasedOnStyle && pcStyle == pBasedOnStyle) { szBasedOn = name; } if(pFollowedByStyle && pcStyle == pFollowedByStyle) { szFollowedBy = name; } } delete pStyles; if(pBasedOnStyle != NULL) { pt_PieceTable::s_getLocalisedStyleName(szBasedOn, utf8); pLocalised = utf8.utf8_str(); str = AP_Win32App::s_fromUTF8ToWinLocale(pLocalised); UT_uint32 result = SendDlgItemMessageW(hWnd, AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_BASEDON, CB_FINDSTRING, -1, (LPARAM)str.c_str()); _win32DialogNewModify.selectComboItem( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_BASEDON, result ); } else { // Not a style name str.fromUTF8(pSS->getValue(AP_STRING_ID_DLG_Styles_DefNone)); UT_uint32 result = SendDlgItemMessageW(hWnd, AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_BASEDON, CB_FINDSTRING, -1, (LPARAM) str.c_str()); _win32DialogNewModify.selectComboItem( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_BASEDON, result ); } if(pFollowedByStyle != NULL) { pt_PieceTable::s_getLocalisedStyleName(szFollowedBy, utf8); pLocalised = utf8.utf8_str(); str = AP_Win32App::s_fromUTF8ToWinLocale(pLocalised); UT_uint32 result = SendDlgItemMessageW(hWnd, AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_FOLLOWPARA, CB_FINDSTRING, -1, (LPARAM)str.c_str()); _win32DialogNewModify.selectComboItem( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_FOLLOWPARA, result ); } else { pt_PieceTable::s_getLocalisedStyleName(pSS->getValue(AP_STRING_ID_DLG_Styles_DefCurrent), utf8); pLocalised = utf8.utf8_str(); str = AP_Win32App::s_fromUTF8ToWinLocale(pLocalised); UT_uint32 result = SendDlgItemMessageW(hWnd, AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_FOLLOWPARA, CB_FINDSTRING, -1, (LPARAM) str.c_str()); _win32DialogNewModify.selectComboItem( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_FOLLOWPARA, result ); } if(strstr(getAttsVal("type"),"P") != 0) { _win32DialogNewModify.setControlText( AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_TYPE, pSS->getValue(AP_STRING_ID_DLG_Styles_ModifyParagraph) ); } else { _win32DialogNewModify.setControlText( AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_TYPE, pSS->getValue(AP_STRING_ID_DLG_Styles_ModifyCharacter) ); } // Disable for editing top controls in Modify Dialog _win32DialogNewModify.enableControl( AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_NAME, false ); _win32DialogNewModify.enableControl( AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_TYPE, false ); fillVecWithProps(szCurrentStyle,true); } // Generate the Preview class HWND hwndChild = GetDlgItem( hWnd, AP_RID_DIALOG_STYLES_NEWMODIFY_CTL_PREVIEW ); m_pAbiPreviewWidget = new XAP_Win32PreviewWidget(static_cast<XAP_Win32App *>(m_pApp), hwndChild, 0); UT_uint32 w,h; m_pAbiPreviewWidget->getWindowSize(&w,&h); _createAbiPreviewFromGC(m_pAbiPreviewWidget->getGraphics(), w, h); _populateAbiPreview(m_bisNewStyle); m_pAbiPreviewWidget->setPreview(m_pAbiPreview); rebuildDeleteProps(); _populatePreviews(true); } XAP_Win32DialogHelper::s_centerDialog(hWnd); return 1; // 1 == we did not call SetFocus() }
void AP_UnixDialog_Styles::runModal(XAP_Frame * pFrame) { // // Get View and Document pointers. Place them in member variables // setFrame(pFrame); setView(static_cast<FV_View *>(pFrame->getCurrentView())); UT_ASSERT(getView()); setDoc(getView()->getLayout()->getDocument()); UT_ASSERT(getDoc()); // Build the window's widgets and arrange them m_windowMain = _constructWindow(); UT_ASSERT(m_windowMain); abiSetupModalDialog(GTK_DIALOG(m_windowMain), pFrame, this, GTK_RESPONSE_CLOSE); // *** this is how we add the gc for the para and char Preview's *** // attach a new graphics context to the drawing area UT_ASSERT(m_wParaPreviewArea && gtk_widget_get_window(m_wParaPreviewArea)); // make a new Unix GC DELETEP (m_pParaPreviewWidget); { GR_UnixCairoAllocInfo ai(m_wParaPreviewArea); m_pParaPreviewWidget = (GR_CairoGraphics*) XAP_App::getApp()->newGraphics(ai); } // let the widget materialize GtkAllocation allocation; gtk_widget_get_allocation(m_wParaPreviewArea, &allocation); _createParaPreviewFromGC(m_pParaPreviewWidget, static_cast<UT_uint32>(allocation.width), static_cast<UT_uint32>(allocation.height)); UT_ASSERT(m_wCharPreviewArea && gtk_widget_get_window(m_wCharPreviewArea)); // make a new Unix GC DELETEP (m_pCharPreviewWidget); { GR_UnixCairoAllocInfo ai(m_wCharPreviewArea); m_pCharPreviewWidget = (GR_CairoGraphics*) XAP_App::getApp()->newGraphics(ai); } // let the widget materialize gtk_widget_get_allocation(m_wCharPreviewArea, &allocation); _createCharPreviewFromGC(m_pCharPreviewWidget, static_cast<UT_uint32>(allocation.width), static_cast<UT_uint32>(allocation.height)); // Populate the window's data items _populateWindowData(); // the expose event of the preview g_signal_connect(G_OBJECT(m_wParaPreviewArea), #if GTK_CHECK_VERSION(3,0,0) "draw", #else "expose_event", #endif G_CALLBACK(s_paraPreview_draw), reinterpret_cast<gpointer>(this)); g_signal_connect(G_OBJECT(m_wCharPreviewArea), #if GTK_CHECK_VERSION(3,0,0) "draw", #else "expose_event", #endif G_CALLBACK(s_charPreview_draw), reinterpret_cast<gpointer>(this)); // connect the select_row signal to the clist g_signal_connect (G_OBJECT (gtk_tree_view_get_selection(GTK_TREE_VIEW(m_tvStyles))), "changed", G_CALLBACK (s_tvStyles_selection_changed), reinterpret_cast<gpointer>(this)); // main loop for the dialog gint response; while(true) { response = abiRunModalDialog(GTK_DIALOG(m_windowMain), false); if (response == GTK_RESPONSE_APPLY) event_Apply(); else { event_Close(); break; // exit the loop } } DELETEP (m_pParaPreviewWidget); DELETEP (m_pCharPreviewWidget); abiDestroyWidget(m_windowMain); }