void CXTPMarkupPanel::OnRender(CXTPMarkupDrawingContext* pDC) { CSize szRender = GetRenderSize(); if (szRender.cx <= 0 || szRender.cy <= 0) return; CXTPMarkupBrush* pBackground = GetBackground(); if (pBackground) { pDC->FillRectangle(CRect(0, 0, szRender.cx, szRender.cy), pBackground); } }
void CTreeCanvas::OnMouse( wxMouseEvent& event ) { if(wxGetApp().m_property_grid_validation)return; if(event.Entering()){ SetFocus(); // so middle wheel works } if(event.LeftDown()) { const CTreeButton* button = HitTest(event.GetPosition()); if(button) { switch(button->type) { case ButtonTypePlus: case ButtonTypeMinus: SetExpanded(button->obj, button->type == 0); SetVirtualSize(GetRenderSize()); this->Refresh(); break; case ButtonTypeLabelBefore: case ButtonTypeLabel: default: OnLabelLeftDown(button->obj, event); clicked_object = button->obj; break; } } else { wxGetApp().m_marked_list->Clear(true); } m_button_down_point = event.GetPosition(); } if(event.LeftUp()) { if(m_dragging) { m_dragging = false; // find the object to drop on to const CTreeButton* button = HitTest(event.GetPosition()); if(button == NULL || !wxGetApp().m_marked_list->ObjectMarked(button->obj)) // can only drop on to an item other than one of the items being dragged { // test drop possible bool drag_possible = true; HeeksObj* add_to = &wxGetApp(); if(button && button->paste_into)add_to = button->paste_into; for(std::list<HeeksObj*>::iterator It = m_dragged_list.begin(); It != m_dragged_list.end(); It++) { HeeksObj* object = *It; if(!add_to->CanAdd(object) || !object->CanAddTo(add_to)) { drag_possible = false; break; } } if(drag_possible) { wxGetApp().CreateUndoPoint(); // cut the objects wxGetApp().Remove(m_dragged_list); // paste the objects for(std::list<HeeksObj*>::iterator It = m_dragged_list.begin(); It != m_dragged_list.end(); It++) { HeeksObj* object = *It; { if(object->OneOfAKind()) { bool one_found = false; for(HeeksObj* child = add_to->GetFirstChild(); child; child = add_to->GetNextChild()) { if(child->GetType() == object->GetType()) { child->CopyFrom(object); one_found = true; break; } } if(!one_found) { add_to->Add(object, button ? button->paste_before : NULL); } } else { add_to->Add(object, button ? button->paste_before : NULL); } } } wxGetApp().Changed(); } else { Refresh(); } } else { Refresh(); } } else { if(m_waiting_until_left_up) { wxGetApp().m_marked_list->Clear(false); wxGetApp().m_marked_list->Add(clicked_object, true); } } m_waiting_until_left_up = false; } if(event.RightDown()) { const CTreeButton* button = HitTest(event.GetPosition()); clicked_object = NULL; if(button && (button->type == ButtonTypeLabelBefore || button->type == ButtonTypeLabel)) { clicked_object = button->obj; OnLabelRightDown(button->obj, event); } } if(event.RightUp()) { // do a context menu MarkedObjectOneOfEach marked_object(0, clicked_object, 1, 0, NULL); if(m_dragging) { m_dragging = false; // find the object to drop on to const CTreeButton* button = HitTest(event.GetPosition()); if(button == NULL || !wxGetApp().m_marked_list->ObjectMarked(button->obj)) // can only drop on to an item other than one of the items being dragged { // make a Move or Copy context menu HeeksObj* paste_into = NULL; HeeksObj* paste_before = NULL; if(button) { paste_into = button->paste_into; paste_before = button->paste_before; } wxGetApp().DoMoveOrCopyDropDownMenu(this, event.GetPosition(), &marked_object, paste_into, paste_before); } else { Refresh(); } } else { // do a standard drop down menu wxGetApp().DoDropDownMenu(this, event.GetPosition(), &marked_object, true, false); } } if(event.Dragging()) { if(event.LeftIsDown() || event.RightIsDown()) { if(!m_dragging && (abs(m_button_down_point.x - event.GetX())>2 || abs(m_button_down_point.y - event.GetY())>2)) { m_dragging = true; m_dragged_list = wxGetApp().m_marked_list->list(); } if(m_dragging) { m_drag_position = CalcUnscrolledPosition(event.GetPosition()); const CTreeButton* button = HitTest(event.GetPosition()); m_drag_paste_rect = wxRect(0, 0, 0, 0); if(button && button->type == ButtonTypeLabelBefore)m_drag_paste_rect = button->rect; Refresh(); } } } if(event.LeftDClick()) { const CTreeButton* button = HitTest(event.GetPosition()); if(button) { if(button->obj) { bool(*callback)(HeeksObj*) = NULL; button->obj->GetOnEdit(&callback); if(callback) { (*callback)(button->obj); } } } } event.Skip(); }
void CTreeCanvas::OnChanged(const std::list<HeeksObj*>* added, const std::list<HeeksObj*>* removed, const std::list<HeeksObj*>* modified) { SetVirtualSize(GetRenderSize()); Refresh(); }
void Image::Render (cairo_t *cr, Region *region, bool path_only) { ImageSource *source = GetSource (); cairo_pattern_t *pattern = NULL; cairo_matrix_t matrix; if (!source) return; source->Lock (); cairo_save (cr); Size specified (GetActualWidth (), GetActualHeight ()); Size stretched = ApplySizeConstraints (specified); bool adjust = specified != GetRenderSize (); if (GetStretch () != StretchUniformToFill) specified = specified.Min (stretched); Rect paint = Rect (0, 0, specified.width, specified.height); if (!path_only) { Rect image = Rect (0, 0, source->GetPixelWidth (), source->GetPixelHeight ()); if (GetStretch () == StretchNone) paint = paint.Union (image); if (image.width == 0.0 && image.height == 0.0) goto cleanup; pattern = cairo_pattern_create_for_surface (source->GetSurface (cr)); image_brush_compute_pattern_matrix (&matrix, paint.width, paint.height, image.width, image.height, GetStretch (), AlignmentXCenter, AlignmentYCenter, NULL, NULL); cairo_pattern_set_matrix (pattern, &matrix); #if MAKE_EVERYTHING_SLOW_AND_BUGGY cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD); #endif if (cairo_pattern_status (pattern) == CAIRO_STATUS_SUCCESS) { cairo_set_source (cr, pattern); } cairo_pattern_destroy (pattern); } if (adjust) { // FIXME: Propagate error properly MoonError error; specified = MeasureOverrideWithError (specified, &error); paint = Rect ((stretched.width - specified.width) * 0.5, (stretched.height - specified.height) * 0.5, specified.width, specified.height); } if (!path_only) RenderLayoutClip (cr); paint = paint.Intersection (Rect (0, 0, stretched.width, stretched.height)); paint.Draw (cr); if (!path_only) cairo_fill (cr); cleanup: cairo_restore (cr); source->Unlock (); }