void Text::expose(unsigned line, unsigned column) { if (! canvas_) return; String string; if (line < text_->Height()) { string = text_->getNth(line); } FontBoundingBox fbb; font_->font_bbox(fbb); Coord x = columnCoord(string, column) - allocation_->left() + curLowerX_; bool invisibleX = (x < curLowerX_) || ((x + width(' ')) > curUpperX_); Coord y = line * (fbb.ascent() + fbb.descent()); bool invisibleY = (y < curLowerY_) || ((y + fbb.ascent() + fbb.descent()) > curUpperY_); if (invisibleX) { scroll_to(Dimension_X, x - (curUpperX_ - curLowerX_) / 2); } if (invisibleY) { scroll_to(Dimension_Y, height() - y - (curUpperY_ - curLowerY_) / 2); } }
void Text::scroll_backward(DimensionName dimension) { FontBoundingBox fbb; font_->font_bbox(fbb); if (dimension == Dimension_X) { scroll_to(dimension, cur_lower(Dimension_X) - width(' ')); } else { scroll_to(dimension, cur_lower(Dimension_Y) - (fbb.ascent() + fbb.descent())); } }
bool NoteEditor::key_pressed (GdkEventKey * ev) { bool ret_value = false; if(!get_editable()) { return ret_value; } switch (ev->keyval) { case GDK_KEY_KP_Enter: case GDK_KEY_Return: // Allow opening notes with Ctrl + Enter if (ev->state != Gdk::CONTROL_MASK) { if (ev->state & Gdk::SHIFT_MASK) { ret_value = NoteBuffer::Ptr::cast_static(get_buffer())->add_new_line (true); } else { ret_value = NoteBuffer::Ptr::cast_static(get_buffer())->add_new_line (false); } scroll_to (get_buffer()->get_insert()); } break; case GDK_KEY_Tab: ret_value = NoteBuffer::Ptr::cast_static(get_buffer())->add_tab (); scroll_to (get_buffer()->get_insert()); break; case GDK_KEY_ISO_Left_Tab: ret_value = NoteBuffer::Ptr::cast_static(get_buffer())->remove_tab (); scroll_to (get_buffer()->get_insert()); break; case GDK_KEY_Delete: if (Gdk::SHIFT_MASK != (ev->state & Gdk::SHIFT_MASK)) { ret_value = NoteBuffer::Ptr::cast_static(get_buffer())->delete_key_handler(); scroll_to (get_buffer()->get_insert()); } break; case GDK_KEY_BackSpace: ret_value = NoteBuffer::Ptr::cast_static(get_buffer())->backspace_key_handler(); break; case GDK_KEY_Left: case GDK_KEY_Right: case GDK_KEY_Up: case GDK_KEY_Down: case GDK_KEY_End: ret_value = false; break; default: NoteBuffer::Ptr::cast_static(get_buffer())->check_selection(); break; } return ret_value; }
void scrollable_widget_rep::handle_set_coord2 (set_coord2_event ev) { if (ev->which == "scroll position") scroll_to (ev->c1, ev->c2); else if (ev->which == "extra width"); else attribute_widget_rep::handle_set_coord2 (ev); }
void Fl_ImageViewer::image(Fl_Image* aimg) { if( aimg == NULL ) return; #ifdef DEBUG if ( dispbox->label() != NULL ) { dispbox->label( NULL ); } #endif unloadimage(); imgsrc = aimg->copy( aimg->w(), aimg->h() ); if ( imgsrc != NULL ) { dispbox->resize( x(), y(), x()+1, y()+1 ); dispbox->image( imgsrc ); dispbox->resize( x(), y(), x() + imgsrc->w(), y() + imgsrc->h() ); dispbox->show(); scroll_to(0, 0); redraw(); } }
static void retain_position(struct selector *sel) { size_t n; struct listing *l; if (sel->target == NULL) return; l = sel->view_listing; switch (sel->sort) { case SORT_ARTIST: case SORT_BPM: n = listing_find(l, sel->target, sel->sort); break; case SORT_PLAYLIST: /* Linear search */ for (n = 0; n < l->entries; n++) { if (l->record[n] == sel->target) break; } break; default: abort(); } if (n < l->entries) scroll_to(&sel->records, n); }
/* Scrolls the image view by the specified offsets. Notifies the adjustments * about their new values. */ static void scroll_by (ImageView *view, int xofs, int yofs) { ImageViewPrivate *priv; priv = view->priv; scroll_to (view, priv->xofs + xofs, priv->yofs + yofs, TRUE); }
/* Callback used when an adjustment is changed */ static void adjustment_changed_cb (GtkAdjustment *adj, gpointer data) { ImageView *view; ImageViewPrivate *priv; view = IMAGE_VIEW (data); priv = view->priv; scroll_to (view, priv->hadj->value, priv->vadj->value, FALSE); }
void selector_toggle(struct selector_t *sel) { if (!sel->toggled) { sel->toggle_back = scroll_current(&sel->crates); scroll_first(&sel->crates); sel->toggled = true; } else { scroll_to(&sel->crates, sel->toggle_back); sel->toggled = false; } crate_has_changed(sel); }
void EinDaten::OnBnClickedLoeschen() { UpdateData(TRUE); if (DemoData.get_wert(auswahl, nummer - 1) != 0) { DemoData.set_wert(auswahl, nummer - 1, 0); GetParentFrame()->GetActiveDocument()->SetModifiedFlag(); update_all(0, 0, 1); } scroll_to(nummer + 1); GotoDlgCtrl(GetDlgItem(IDC_WERT)); }
/* Drags the image to the specified position */ static void drag_to (ImageView *view, int x, int y) { ImageViewPrivate *priv; int dx, dy; priv = view->priv; dx = priv->drag_anchor_x - x; dy = priv->drag_anchor_y - y; x = priv->drag_ofs_x + dx; y = priv->drag_ofs_y + dy; scroll_to (view, x, y, TRUE); }
BOOL EinDaten::OnInitDialog() { CDialog::OnInitDialog(); for (int i = 0; i < DemoData.get_anz_z(); i++) combobox.InsertString(i, DemoData.get_rname(i)); auswahl = 0; scrollbar.SetScrollRange(1, DemoData.get_anz_s()); scroll_to(1); UpdateData(FALSE); //Wir aktualisieren aus der Bildschirmdarstellung unsere Membervariablen GotoDlgCtrl(GetDlgItem(IDC_WERT)); //Input-Fokus wird auf das Eingabefeld (selektiertes Editierfeld) return TRUE; // return TRUE unless you set the focus to a control // AUSNAHME: OCX-Eigenschaftenseite muss FALSE zurückgeben. }
/** * image_view_set_pixbuf: * @view: An image view. * @pixbuf: A pixbuf. * * Sets the pixbuf that an image view will display. **/ void image_view_set_pixbuf (ImageView *view, GdkPixbuf *pixbuf) { ImageViewPrivate *priv; g_return_if_fail (view != NULL); g_return_if_fail (IS_IMAGE_VIEW (view)); priv = view->priv; if (pixbuf) { g_object_ref (pixbuf); if (view->priv->pixbuf) g_object_unref (view->priv->pixbuf); } view->priv->pixbuf = pixbuf; remove_dirty_region (view); scroll_to (view, 0, 0, TRUE); gtk_widget_queue_draw (GTK_WIDGET (view)); }
//nSBCode = gedrückte 'Buttons' der Scrollbar (Dreieck rechts/links, etc.), pScrollBar = Zeiger auf den Scrollbar void EinDaten::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { UpdateData(TRUE); if (pScrollBar == &scrollbar) { switch (nSBCode) { case SB_LEFT: //Ganz links scroll_to(1); break; case SB_RIGHT: //Ganz rechts scroll_to(DemoData.get_anz_s()); break; case SB_LINELEFT: //Dreieck links scroll_to(nummer - 1); break; case SB_LINERIGHT: //Dreieck rechts scroll_to(nummer + 1); break; case SB_PAGELEFT: //Zwischenfeld links scroll_to(nummer - 5); break; case SB_PAGERIGHT: //Zwischenfeld rechts scroll_to(nummer + 5); break; case SB_THUMBPOSITION: case SB_THUMBTRACK: //Positionsänderung scroll_to(nPos); break; case SB_ENDSCROLL: break; } GotoDlgCtrl(GetDlgItem(IDC_WERT)); } CDialog::OnHScroll(nSBCode, nPos, pScrollBar); }
void popup_menu::init() { iLayout.set_margins(neogfx::margins{}); closed([this]() { if (iMenu.is_open()) iMenu.close(); }); for (i_menu::item_index i = 0; i < iMenu.item_count(); ++i) iLayout.add_item(std::make_shared<menu_item_widget>(*this, iMenu, iMenu.item(i))); layout_items(); iMenu.open(); iSink += iMenu.item_added([this](i_menu::item_index aIndex) { iLayout.add_item(aIndex, std::make_shared<menu_item_widget>(*this, iMenu, iMenu.item(aIndex))); layout_items(); }); iSink += iMenu.item_removed([this](i_menu::item_index aIndex) { iLayout.remove_item(aIndex); layout_items(); }); iSink += iMenu.item_changed([this](i_menu::item_index) { layout_items(); }); iSink += iMenu.item_selected([this](i_menu_item& aMenuItem) { if (!app::instance().keyboard().is_keyboard_grabbed_by(*this)) app::instance().keyboard().grab_keyboard(*this); if (iOpenSubMenu != nullptr) { if (aMenuItem.type() == i_menu_item::Action || (aMenuItem.type() == i_menu_item::SubMenu && &iOpenSubMenu->menu() != &aMenuItem.sub_menu())) { iOpenSubMenu->menu().close(); } } scroll_to(layout().get_widget<menu_item_widget>(iMenu.find_item(aMenuItem))); update(); }); iSink += iMenu.open_sub_menu([this](i_menu& aSubMenu) { if (!iOpeningSubMenu && aSubMenu.item_count() > 0) { neolib::scoped_flag sf(iOpeningSubMenu); auto& itemWidget = layout().get_widget<menu_item_widget>(iMenu.find_item(aSubMenu)); close_sub_menu(); iOpenSubMenu = std::make_unique<popup_menu>(*this, itemWidget.sub_menu_position(), aSubMenu); iSink2 += iOpenSubMenu->menu().closed([this]() { if (iOpenSubMenu != nullptr) iOpenSubMenu->close(); }); iSink2 += iOpenSubMenu->closed([this]() { close_sub_menu(); }); } }); show(); }
void Adjustable::scroll_backward(DimensionName d) { scroll_to(d, cur_lower(d) - small_scroll(d)); }
void Adjustable::page_backward(DimensionName d) { scroll_to(d, cur_lower(d) - large_scroll(d)); }
void Text::page_backward(DimensionName dimension) { scroll_to(dimension, cur_lower(dimension) - cur_length(dimension)); }