static gboolean focus_out_event_Modeless(GtkWidget *widget,GdkEvent */*event*/,gpointer /*user_data*/) { XAP_App *pApp = static_cast<XAP_App *>(g_object_get_data(G_OBJECT(widget), "pApp")); XAP_Frame *pFrame = pApp->getLastFocussedFrame(); if(pFrame ==static_cast<XAP_Frame *>(NULL)) { UT_uint32 nframes = pApp->getFrameCount(); if(nframes > 0 && nframes < 10) { pFrame = pApp->getFrame(0); } else { return FALSE; } } if(pFrame == static_cast<XAP_Frame *>(NULL)) return FALSE; AV_View * pView = pFrame->getCurrentView(); UT_ASSERT_HARMLESS(pView); if(pView!= NULL) { pView->focusChange(AV_FOCUS_NONE); } return FALSE; }
static gboolean focus_in_event_ModelessOther(GtkWidget *widget,GdkEvent */*event*/, std::pointer_to_unary_function<int, gboolean> *other_function) { XAP_App *pApp=static_cast<XAP_App *>(g_object_get_data(G_OBJECT(widget), "pApp")); XAP_Frame *pFrame= pApp->getLastFocussedFrame(); if(pFrame == static_cast<XAP_Frame *>(NULL)) { UT_uint32 nframes = pApp->getFrameCount(); if(nframes > 0 && nframes < 10) { pFrame = pApp->getFrame(0); } else { return FALSE; } } if(pFrame == static_cast<XAP_Frame *>(NULL)) return FALSE; AV_View * pView = pFrame->getCurrentView(); if(pView!= NULL) { pView->focusChange(AV_FOCUS_MODELESS); (*other_function)(0); } return FALSE; }
UT_Error IE_Exp_EPUB::doOptions() { XAP_Frame * pFrame = XAP_App::getApp()->getLastFocussedFrame(); if (!pFrame || isCopying()) return UT_OK; if (pFrame) { AV_View * pView = pFrame->getCurrentView(); if (pView) { GR_Graphics * pG = pView->getGraphics(); if (pG && pG->queryProperties(GR_Graphics::DGP_PAPER)) { return UT_OK; } } } //FIXME:FIDENCIO: Remove this clause when Cocoa's dialog is implemented #ifdef TOOLKIT_COCOA return UT_OK; #else /* run the dialog */ XAP_Dialog_Id id = m_iDialogExport; XAP_DialogFactory * pDialogFactory = static_cast<XAP_DialogFactory *> (XAP_App::getApp()->getDialogFactory()); AP_Dialog_EpubExportOptions* pDialog = static_cast<AP_Dialog_EpubExportOptions*> (pDialogFactory->requestDialog(id)); if (pDialog == NULL) { return UT_OK; } pDialog->setEpubExportOptions(&m_exp_opt, XAP_App::getApp()); pDialog->runModal(pFrame); /* extract what they did */ bool bSave = pDialog->shouldSave(); pDialogFactory->releaseDialog(pDialog); if (!bSave) { return UT_SAVE_CANCELLED; } return UT_OK; #endif }
static gboolean focus_out_event(GtkWidget *widget,GdkEvent */*event*/,gpointer /*user_data*/) { XAP_Frame *pFrame=static_cast<XAP_Frame *>(g_object_get_data(G_OBJECT(widget), "frame")); if(pFrame == NULL) return FALSE; AV_View * pView = pFrame->getCurrentView(); if(pView!= NULL) { pView->focusChange(AV_FOCUS_NONE); } return FALSE; }
/*! * Implements the signal() method of the Document listener class. */ bool AbiCollabService_Export::signal(UT_uint32 iSignal) { if((iSignal == PD_SIGNAL_SAVEDOC) && m_pDoc->isDirty()) { bool bSavedRemotely = ServiceAccountHandler::m_saveInterceptor.save(m_pDoc); if(bSavedRemotely) { UT_GenericVector<AV_View *> vecViews; m_pDoc->getAllViews(&vecViews); AV_View * pView = vecViews.getNthItem(0); XAP_Frame * pFrame = static_cast<XAP_Frame *> (pView->getParentData()); if (pFrame->getViewNumber() > 0) XAP_App::getApp()->updateClones(pFrame); } return bSavedRemotely; } return true; }
bool XAP_App::retrieveState() { XAP_StateData sd; bool bRet = true; if(!_retrieveState(sd)) return false; UT_return_val_if_fail(sd.iFileCount <= XAP_SD_MAX_FILES, false); // now do our thing with it: // * open the files stored in the data // * move carets and scrollbars to the saved positions // * make the first saved frame to be the current frame // we should only be restoring state with no docs already // opened UT_return_val_if_fail(m_vecFrames.getItemCount() <= 1, false); XAP_Frame * pFrame = NULL; if(m_vecFrames.getItemCount()) pFrame = m_vecFrames.getNthItem(0); // if there is a frame, it should be one with unmodified untitled document UT_return_val_if_fail( !pFrame || (!pFrame->getFilename() && !pFrame->isDirty()), false ); UT_Error errorCode = UT_IE_IMPORTERROR; for(UT_uint32 i = 0; i < sd.iFileCount; ++i) { if(!pFrame) pFrame = newFrame(); if (!pFrame) return false; // Open a complete but blank frame, then load the document into it errorCode = pFrame->loadDocument((const char *)NULL, 0 /*IEFT_Unknown*/); bRet &= (errorCode == UT_OK); if (errorCode == UT_OK) pFrame->show(); else continue; errorCode = pFrame->loadDocument(sd.filenames[i], 0 /*IEFT_Unknown*/); bRet &= (errorCode == UT_OK); if (errorCode != UT_OK) continue; pFrame->show(); AV_View* pView = pFrame->getCurrentView(); if(!pView) { UT_ASSERT_HARMLESS( UT_SHOULD_NOT_HAPPEN ); bRet = false; continue; } pView->setPoint(sd.iDocPos[i]); pView->setXScrollOffset(sd.iXScroll[i]); pView->setYScrollOffset(sd.iYScroll[i]); // now we check if this doc was autosaved Untitled* doc at hibernation char * p = strstr(sd.filenames[i], HIBERNATED_EXT); if(p) { // remove extension p = 0; AD_Document * pDoc = pFrame->getCurrentDoc(); if(pDoc) { pDoc->clearFilename(); pDoc->forceDirty(); pFrame->updateTitle(); } } // frame used -- next doc needs a new one pFrame = NULL; } // set focus to the first frame pFrame = m_vecFrames.getNthItem(0); UT_return_val_if_fail( pFrame, false ); AV_View* pView = pFrame->getCurrentView(); UT_return_val_if_fail( pView, false ); pView->focusChange(AV_FOCUS_HERE); return bRet; }
bool XAP_App::saveState(bool bQuit) { // gather the state data for platform code to deal with XAP_StateData sd; bool bRet = true; // We will store data for up to XAP_SD_MAX_FILES, making sure we save it for the last // focussed frame in the first slot XAP_Frame * pLastFrame = getLastFocussedFrame(); UT_sint32 i; UT_sint32 j; for(i = 0, j = 0; i < m_vecFrames.getItemCount(); ++i, ++j) { XAP_Frame * pFrame = NULL; if(i == 0) pFrame = pLastFrame; else pFrame = m_vecFrames[i]; if(pLastFrame == pFrame && j != 0) { // we have done this frame, but need to do the one at pos 0 in its place pFrame = m_vecFrames[0]; } if(!pFrame) { --j; continue; } AD_Document * pDoc = pFrame->getCurrentDoc(); if(!pDoc) { --j; continue; } UT_Error e = UT_OK; if(pDoc->isDirty()) { // need to decide what to do about dirty documents; perhaps we should keep a // copy of the unsaved state under a different name? // for now just save (otherwise the user will loose the changes when app // hibernates) e = pDoc->save(); if(e == UT_SAVE_NAMEERROR) { // this is an Untitled document UT_UTF8String s = pFrame->getNonDecoratedTitle(); s += HIBERNATED_EXT; e = pDoc->saveAs(s.utf8_str(), 0); } bRet &= (UT_OK == e); } if(j >= XAP_SD_MAX_FILES || e != UT_OK) { // no storage space left -- nothing more we can do with this document, so move // to the next one (do not break, we need to deal with anything that is not // saved) --j; // we want to preserve the j value continue; } const char * file = pDoc->getFilename(); if(file && strlen(file) < XAP_SD_FILENAME_LENGTH) { strncpy(sd.filenames[j], file, XAP_SD_FILENAME_LENGTH); AV_View * pView = pFrame->getCurrentView(); if(pView) { sd.iDocPos[j] = pView->getPoint(); sd.iXScroll[j] = pView->getXScrollOffset(); sd.iYScroll[j] = pView->getYScrollOffset(); } } else { --j; continue; } } sd.iFileCount = j; if(!_saveState(sd)) return false; if(bQuit) { // we have dealt with unsaved docs above, so just clean up any modeless dlgs and quit closeModelessDlgs(); reallyExit(); } return bRet; }
void ev_BeOSMouse::mouseMotion(BMessage *msg) { AV_View* pView = m_pBeOSFrame->getFrame()->getCurrentView(); EV_EditMethod * pEM; EV_EditModifierState ems = 0; EV_EditEventMapperResult result; EV_EditMouseButton emb = 0; EV_EditMouseOp mop; EV_EditMouseContext emc = 0; BPoint pt; int32 clicks, mod, buttons; msg->FindInt32("clicks", &clicks); msg->FindInt32("buttons", &buttons); msg->FindInt32("modifiers", &mod); msg->FindPoint("be:view_where", &pt); // UT_DEBUGMSG(("mouseMotion: [x=%f y=%f]\n",pt.x, pt.y)); if (buttons & B_PRIMARY_MOUSE_BUTTON) emb = EV_EMB_BUTTON1; else if (buttons & B_PRIMARY_MOUSE_BUTTON) emb = EV_EMB_BUTTON2; else if (buttons & B_PRIMARY_MOUSE_BUTTON) emb = EV_EMB_BUTTON3; else { //Bail because I don't think the code expect non button events return; } if (mod & B_SHIFT_KEY) ems |= EV_EMS_SHIFT; if (mod & B_CONTROL_KEY) ems |= EV_EMS_CONTROL; if (mod & B_OPTION_KEY) ems |= EV_EMS_ALT; // report movements under the mouse button that we did the capture on if (m_clickState == 0) { mop = EV_EMO_DRAG; emc = pView->getMouseContext((UT_sint32)pt.x,(UT_sint32)pt.y); } else if (m_clickState == EV_EMO_SINGLECLICK) { mop = EV_EMO_DRAG; emc = m_contextState; } else if (m_clickState == EV_EMO_DOUBLECLICK) { mop = EV_EMO_DOUBLEDRAG; emc = m_contextState; } else { UT_ASSERT(UT_SHOULD_NOT_HAPPEN); return; } // UT_DEBUGMSG(("onButtonMove: %p [b=%d m=%d]\n",EV_EMO_DRAG|ems, emb, ems)); result = m_pEEM->Mouse(emc|mop|emb|ems, &pEM); switch (result) { case EV_EEMR_COMPLETE: UT_ASSERT(pEM); invokeMouseMethod(pView,pEM,(UT_sint32)pt.x,(UT_sint32)pt.y); return; case EV_EEMR_INCOMPLETE: // I'm not sure this makes any sense, but we allow it. return; case EV_EEMR_BOGUS_START: case EV_EEMR_BOGUS_CONT: // TODO What to do ?? Should we beep at them or just be quiet ?? return; default: UT_ASSERT(UT_SHOULD_NOT_HAPPEN); return; } }
void ev_BeOSMouse::mouseClick(BMessage *msg) { AV_View* pView = m_pBeOSFrame->getFrame()->getCurrentView(); EV_EditMethod * pEM; EV_EditModifierState state = 0; EV_EditEventMapperResult result; EV_EditMouseButton emb = 0; EV_EditMouseOp mop = 0; EV_EditMouseContext emc = 0; BPoint pt; int32 clicks, mod, buttons; msg->FindInt32("clicks", &clicks); msg->FindInt32("buttons", &buttons); msg->FindInt32("modifiers", &mod); msg->FindPoint("where", &pt); UT_DEBUGMSG(("mouseClick: [x=%f y=%f]\n",pt.x, pt.y)); printf("mouseClick: [x=%f y=%f]\n",pt.x, pt.y); if (buttons & B_PRIMARY_MOUSE_BUTTON) emb = EV_EMB_BUTTON1; else if (buttons & B_SECONDARY_MOUSE_BUTTON) emb = EV_EMB_BUTTON3; else if (buttons & B_TERTIARY_MOUSE_BUTTON) emb = EV_EMB_BUTTON2; if (mod & B_SHIFT_KEY) state |= EV_EMS_SHIFT; if (mod & B_CONTROL_KEY) state |= EV_EMS_CONTROL; if (mod & B_OPTION_KEY) state |= EV_EMS_ALT; mop = 0; if (clicks == 1) mop = EV_EMO_SINGLECLICK; else if (clicks == 2) mop = EV_EMO_DOUBLECLICK; if (msg->what==B_MOUSE_UP) { if (m_clickState==EV_EMO_SINGLECLICK) { mop=EV_EMO_RELEASE; } else if (m_clickState==EV_EMO_DOUBLECLICK) { mop=EV_EMO_DOUBLERELEASE; } } emc = pView->getMouseContext((UT_sint32)pt.x,(UT_sint32)pt.y); m_clickState = mop; //Remember the click type m_contextState = emc; result = m_pEEM->Mouse(emc|mop|emb|state, &pEM); switch (result) { case EV_EEMR_COMPLETE: UT_ASSERT(pEM); invokeMouseMethod(pView,pEM,(UT_sint32)pt.x,(UT_sint32)pt.y); return; case EV_EEMR_INCOMPLETE: // I'm not sure this makes any sense, but we allow it. return; case EV_EEMR_BOGUS_START: case EV_EEMR_BOGUS_CONT: // TODO What to do ?? Should we beep at them or just be quiet ?? return; default: UT_ASSERT(0); return; } }