bool AnnotationRenderer::contains(const Point& point) { const PandaDocument* doc = getParentView()->document(); if(m_annotation->m_type.getValue() != Annotation::ANNOTATION_TEXT && getParentView()->selection().get().size() == 1 && getParentView()->selection().isSelected(m_annotation)) // The annotation is the only selected object { if((point - m_endPos).norm() < 10) return true; } return m_textArea.contains(point); }
KfmView::~KfmView() { // debugT("Deleting KfmView\n"); if ( dropZone != 0L ) delete dropZone; dropZone = 0L; // MRJ: make sure all requests are cancelled before the cache is deleted slotStop(); delete manager; delete htmlCache; if(getParentView() == 0) { delete backStack; delete forwardStack; } // debugT("Deleted\n"); // Save HTTP Cookies if (cookiejar) { QString cookieFile = kapp->localkdedir().copy(); cookieFile += "/share/apps/kfm/cookies"; cookiejar->saveCookies( cookieFile.data() ); } }
void AnnotationRenderer::drawForeground(graphics::DrawList& list, graphics::DrawColors& colors) { // Draw the box behind the text list.addRectFilled(m_textArea, colors.midLightColor); // Draw the text auto textArea = m_textArea.adjusted(5, 5, -5, -5); list.addText(textArea, m_annotation->m_text.getValue(), colors.penColor); // Draw the handle const PandaDocument* doc = getParentView()->document(); if(m_annotation->m_type.getValue() != Annotation::ANNOTATION_TEXT && getParentView()->selection().get().size() == 1 && getParentView()->selection().isSelected(m_annotation)) // The annotation is the only selected object { list.addCircleFilled(m_endPos, 5, colors.midLightColor); list.addCircle(m_endPos, 5, colors.penColor); } }
void AnnotationRenderer::mouseReleaseEvent(const MouseEvent& event) { Point zoomedMouse = getParentView()->viewport().toView(event.pos()); Point deltaStart = m_startMousePos - m_previousMousePos; Point delta = zoomedMouse - m_startMousePos; if (m_movingAction == MOVING_TEXT) { moveText(deltaStart); getParentView()->document()->getUndoStack().push(std::make_shared<MoveObjectCommand>(m_annotation, delta)); } else if (m_movingAction == MOVING_POINT) { moveEnd(deltaStart); getParentView()->document()->getUndoStack().push(std::make_shared<MoveAnnotationEndCommand>(m_annotation, delta)); } m_movingAction = MOVING_NONE; }
//----------------------------------------------------------------------------- CMessageResult CScrollContainer::notify (CBaseObject* sender, IdStringPtr message) { if (message == kMsgViewSizeChanged && !inScrolling) { uint32_t numSubViews = getNbViews (); CView* view = static_cast<CView*> (sender); if (numSubViews == 1 && view && isChild (view)) { CRect r (view->getViewSize ()); CRect newContainerSize (containerSize); newContainerSize.setWidth (r.getWidth ()); newContainerSize.setHeight (r.getHeight ()); if (newContainerSize != containerSize) { CScrollView* scrollView = (CScrollView*)getParentView (); scrollView->setContainerSize (newContainerSize); } } } return getParentView () ? getParentView ()->notify (sender, message) : kMessageUnknown; }
void AnnotationRenderer::mouseMoveEvent(const MouseEvent& event) { Point zoomedMouse = getParentView()->viewport().toView(event.pos()); Point delta = zoomedMouse - m_previousMousePos; m_previousMousePos = zoomedMouse; if(delta.isNull()) return; if (m_movingAction == MOVING_TEXT) moveText(delta); else if (m_movingAction == MOVING_POINT) moveEnd(delta); }
//----------------------------------------------------------------------------- bool CWaveView::onDrop(CDragContainer* drag, const CPoint& where) { C700GUI *guiview = reinterpret_cast<C700GUI*> (getParentView()); if ( !guiview->isTypeOf("C700GUI") ) { return false; } long size, type; void* ptr = drag->first(size, type); if ( ptr ) { if ( type == CDragContainer::kFile ) { return guiview->loadToCurrentProgram((char *)ptr); } } return false; }
//----------------------------------------------------------------------------- void CScrollContainer::onDragMove (IDataPackage* drag, const CPoint& where) { if (autoDragScroll) { float x, y; if (getScrollValue (where, x, y)) { CScrollView* scrollView = static_cast<CScrollView*> (getParentView ()); if (scrollView) { CRect r (getViewSize ()); r.offset (x, y); scrollView->makeRectVisible (r); } } } return CViewContainer::onDragMove (drag, where); }
bool AnnotationRenderer::mousePressEvent(const MouseEvent& event) { Point zoomedMouse = getParentView()->viewport().toView(event.pos()); if(m_textArea.contains(zoomedMouse)) { m_movingAction = MOVING_TEXT; m_startMousePos = m_previousMousePos = zoomedMouse; return true; } if((zoomedMouse - m_endPos).norm() < 10) { m_movingAction = MOVING_POINT; m_startMousePos = m_previousMousePos = zoomedMouse; return true; } return false; }
//----------------------------------------------------------------------------- bool CScrollContainer::attached (CView* parent) { bool result = CViewContainer::attached (parent); if (getNbViews () == 1) { CView* view = getView (0); if (view) { CRect r (view->getViewSize ()); CRect newContainerSize (containerSize); newContainerSize.setWidth (r.getWidth ()); newContainerSize.setHeight (r.getHeight ()); if (newContainerSize != containerSize) { CScrollView* scrollView = (CScrollView*)getParentView (); scrollView->setContainerSize (newContainerSize); } } } return result; }
void AnnotationRenderer::moveEnd(const Point& delta) { m_endPos += delta; update(); getParentView()->update(); }
void AnnotationRenderer::moveText(const Point& delta) { move(delta); getParentView()->update(); }
void cBitmapFontEditable::takeFocus(CDrawContext *pContext) { if(!m_editing) { getText((char*)&m_old_buffer); } m_editing = true; if(m_edit_index) { m_edit_index = 0; memset(m_edit_buffer, 0x0, sizeof(char) * MAX_EDIT_CHARS); } setText(" "); #if WINDOWS || MACX // calculate offset for CViewContainers CRect rect (size); CView* parent = getParentView (); CRect vSize; while (parent) { if (parent->notify (this, kMsgCheckIfViewContainer) == kMessageNotified) { parent->getViewSize (vSize); rect.offset (vSize.left, vSize.top); } parent = parent->getParentView (); } if (pContext) rect.offset (pContext->offset.h, pContext->offset.v); #endif #if WINDOWS // int wstyle = 0; // if (horiTxtAlign == kLeftText) // wstyle |= ES_LEFT; // else if (horiTxtAlign == kRightText) // wstyle |= ES_RIGHT; // else // wstyle |= ES_CENTER; // // wstyle |= WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL; // platformControl = (void*)CreateWindow ( // "EDIT", text, wstyle, // rect.left, rect.top, rect.width ()/* + 1*/, rect.height ()/* + 1*/, // (HWND)getFrame ()->getSystemWindow (), NULL, GetInstance (), 0); // // // get/set the current font // LOGFONT logfont = {0}; // // long fontH = gStandardFontSize [fontID]; // if (fontH > rect.height () - 2) // fontH = rect.height () - 2; // // logfont.lfWeight = FW_NORMAL; // logfont.lfHeight = -fontH; // logfont.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS; // strcpy (logfont.lfFaceName, gStandardFontName[fontID]); // // logfont.lfClipPrecision = CLIP_STROKE_PRECIS; // logfont.lfOutPrecision = OUT_STRING_PRECIS; // logfont.lfQuality = DEFAULT_QUALITY; // logfont.lfCharSet = ANSI_CHARSET; // // platformFont = (HANDLE)CreateFontIndirect (&logfont); // platformFontColor = 0; // SetWindowLongPtr ((HWND)platformControl, GWLP_USERDATA, (LONG_PTR)this); // SendMessage ((HWND)platformControl, WM_SETFONT, (WPARAM)platformFont, true); SendMessage ((HWND)platformControl, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN, MAKELONG (0, 0)); // SendMessage ((HWND)platformControl, EM_SETSEL, 0, -1); SendMessage ((HWND)platformControl, EM_LIMITTEXT, 255, 0); SetFocus ((HWND)platformControl); oldWndProcEdit = (WINDOWSPROC)SetWindowLongPtr ((HWND)platformControl, GWLP_WNDPROC, (LONG_PTR)WindowProcEdit); #elif MAC WindowRef window = (WindowRef)getFrame()->getSystemWindow(); SetUserFocusWindow(window); AdvanceKeyboardFocus(window); EventTypeSpec eventTypes[] = { { kEventClassMouse, kEventMouseDown }, { kEventClassWindow, kEventWindowDeactivated }, { kEventClassKeyboard, kEventRawKeyDown }, { kEventClassKeyboard, kEventRawKeyRepeat } }; InstallWindowEventHandler(window, TextControlProc, GetEventTypeCount(eventTypes), eventTypes, this, &gEventHandler); #endif setDirty(); }