void QConsolePrivate::updateConsoleSize (bool sync)
{
  QFontMetrics fm (m_consoleView->font());
  QSize winSize = m_consoleView->size ();

  m_charSize.rwidth () = fm.averageCharWidth();
  m_charSize.rheight () = fm.lineSpacing ();

  m_consoleRect.setWidth (int(double(winSize.width ()) / double(fm.averageCharWidth())));
  m_consoleRect.setHeight (int(double(winSize.height ()) / double(fm.lineSpacing ())));

  m_bufferSize.rwidth () = m_consoleRect.width ();
  m_bufferSize.rheight () = qMax (m_bufferSize.height (),
                                  m_consoleRect.height ());

  m_consoleRect.moveLeft (0);
  if (m_consoleRect.bottom () >= m_bufferSize.height ())
    m_consoleRect.moveTop (m_bufferSize.height () - m_consoleRect.height ());

  log ("Console resized:\n");
  log ("  widget size: %d x %d\n", winSize.width (), winSize.height ());
  log ("  buffer size: %d x %d\n", m_bufferSize.width (),
       m_bufferSize.height ());
  log ("  window: (%d, %d) -> (%d, %d) [%d x %d]\n",
       m_consoleRect.left (), m_consoleRect.top (),
       m_consoleRect.right (), m_consoleRect.bottom (),
       m_consoleRect.width (), m_consoleRect.height ());

  if (sync)
    syncConsoleParameters ();

  updateScrollBar ();
}
Example #2
0
//---------------------------------------------------------------------------
void MainWindow::on_actionZoomOne_triggered()
{
    PlotsArea->zoomXAxis( Plots::ZoomOneToOne );
    configureZoom();

    updateScrollBar();
}
Example #3
0
//---------------------------------------------------------------------------
void MainWindow::configureZoom()
{
    updateScrollBar();

    if (Files.empty() || PlotsArea==NULL || !PlotsArea->isZoomed() )
    {
        ui->actionZoomOut->setEnabled(false);
        if (Files_CurrentPos<Files.size() && isPlotZoomable())
            ui->actionZoomIn->setEnabled(true);
        else
            ui->actionZoomIn->setEnabled(false);

        ui->actionGoTo->setEnabled(!Files.empty());
        ui->actionExport_XmlGz_Prompt->setEnabled(!Files.empty());
        ui->actionExport_XmlGz_Sidecar->setEnabled(!Files.empty());
        ui->actionExport_XmlGz_Custom->setEnabled(!Files.empty());
        ui->actionCSV->setEnabled(!Files.empty());
        //ui->actionPrint->setEnabled(!Files.empty());
        return;
    }

    ui->actionZoomOut->setEnabled(true);
    ui->actionZoomIn->setEnabled( isPlotZoomable() );
    ui->actionGoTo->setEnabled(true);
    ui->actionExport_XmlGz_Prompt->setEnabled(true);
    ui->actionExport_XmlGz_Sidecar->setEnabled(true);
    ui->actionExport_XmlGz_Custom->setEnabled(true);
    ui->actionCSV->setEnabled(true);
    //ui->actionPrint->setEnabled(true);
}
static LRESULT CALLBACK WND_PROC_FLIF_PREVIEW_HANDLER(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED)
        {
            flifPreviewHandler* handler = reinterpret_cast<flifPreviewHandler*>(GetWindowLongPtrW(hWnd, GWLP_USERDATA));
            handler->togglePlayState();
        }
        break;
    case WM_TIMER:
        if(wParam == 1)
        {
            flifPreviewHandler* handler = reinterpret_cast<flifPreviewHandler*>(GetWindowLongPtrW(hWnd, GWLP_USERDATA));
            handler->showNextFrame();
        }
        break;
    case WM_HSCROLL:
        {
            int scroll_pos = updateScrollBar(hWnd, message, wParam, lParam);

            flifPreviewHandler* handler = reinterpret_cast<flifPreviewHandler*>(GetWindowLongPtrW(hWnd, GWLP_USERDATA));
            handler->showFrameFromScrollBar(scroll_pos);
        }
        break;
    case WM_CTLCOLORSTATIC:
        // no background color to avoid flickering during animation
        return reinterpret_cast<LRESULT>(GetStockObject(NULL_BRUSH));
    }

    return DefWindowProcW(hWnd, message, wParam, lParam);
}
Example #5
0
void GUITable::setOpenedTrees(const std::set<s32> &opened_trees)
{
	s32 old_selected = -1;
	if (m_selected >= 0)
		old_selected = m_visible_rows[m_selected];

	std::vector<s32> parents;
	std::vector<s32> closed_parents;

	m_visible_rows.clear();

	for (size_t i = 0; i < m_rows.size(); ++i) {
		Row *row = &m_rows[i];

		// Update list of ancestors
		while (!parents.empty() && m_rows[parents.back()].indent >= row->indent)
			parents.pop_back();
		while (!closed_parents.empty() &&
				m_rows[closed_parents.back()].indent >= row->indent)
			closed_parents.pop_back();

		assert(closed_parents.size() <= parents.size());

		if (closed_parents.empty()) {
			// Visible row
			row->visible_index = m_visible_rows.size();
			m_visible_rows.push_back(i);
		}
		else if (parents.back() == closed_parents.back()) {
			// Invisible row, direct parent is closed
			row->visible_index = -2;
		}
		else {
			// Invisible row, direct parent is open, some ancestor is closed
			row->visible_index = -1;
		}

		// If not a leaf, add to parents list
		if (i < m_rows.size()-1 && row->indent < m_rows[i+1].indent) {
			parents.push_back(i);

			s32 content_index = 0; // "-", open
			if (opened_trees.count(i) == 0) {
				closed_parents.push_back(i);
				content_index = 1; // "+", closed
			}

			// Update all cells of type "tree"
			for (s32 j = 0; j < row->cellcount; ++j)
				if (row->cells[j].content_type == COLUMN_TYPE_TREE)
					row->cells[j].content_index = content_index;
		}
	}

	updateScrollBar();

	// m_selected must be updated since it is a visible row index
	if (old_selected >= 0)
		m_selected = m_rows[old_selected].visible_index;
}
Example #6
0
/* BrowserCanvas::onSize
 * Called when the canvas is resized
 *******************************************************************/
void BrowserCanvas::onSize(wxSizeEvent& e) {
	updateScrollBar();
	updateLayout();

	// Do default stuff
	e.Skip();
}
Example #7
0
void ScrollView::moveChildrenToPosition(const Vec2& position)
{
    setInnerContainerPosition(position);
    
    Vec2 outOfBoundary = getHowMuchOutOfBoundary(Vec2::ZERO);
    updateScrollBar(outOfBoundary);
}
Example #8
0
/* BrowserCanvas::filterItems
 * Filters the visible items by [filter], by name
 *******************************************************************/
void BrowserCanvas::filterItems(string filter)
{
	// Clear current filter list
	items_filter.clear();

	// If the filter is empty, just add all items to the filter
	if (filter.IsEmpty())
	{
		for (unsigned a = 0; a < items.size(); a++)
			items_filter.push_back(a);
	}
	else
	{
		// Setup filter string
		filter.MakeLower();
		filter += "*";

		// Go through items
		for (unsigned a = 0; a < items.size(); a++)
		{
			// Add to filter list if name matches
			if (items[a]->getName().Lower().Matches(filter))
				items_filter.push_back(a);
		}
	}

	// Update scrollbar and refresh
	updateScrollBar();
	Refresh();
}
//------------------------------------------------------------------
void scrollBar::setup(){
    /*
     The "panel" is a frame. This frame contains the displayed images, and the scroll bar.
     The scroll bar contains a "grip". The user can drag the grip with the mouse.
     */
    
    margin = SCROLL_BAR_WIDTH; // Distance between the edge of the screen and the panel frame
    scrollBarWidth = SCROLL_BAR_WIDTH;
    
    BEGIN_X = RIGHT_MENU_WIDTH;
    BEGIN_Y = MENU_HEIGHT + MENU_TOP_PADDING;
    
    // Now two rectangles, for the scroll bar and his grip placements
    // Coordinates are relative to the panel coordinates, not to the screen coordinates
    // This is a first initialisation, but we don't know many things about these placements at this state
    scrollBarRectangle = ofRectangle(ofGetWidth() - scrollBarWidth, BEGIN_Y, scrollBarWidth, 0);
    gripRectangle = ofRectangle(ofGetWidth() - scrollBarWidth, BEGIN_Y, scrollBarWidth, 0);
    
    
    windowHeight = ofGetHeight()*windowRatio;
    hScrollBarRectangle = ofRectangle(BEGIN_X, windowHeight - scrollBarWidth, 0, scrollBarWidth);
    hGripRectangle = ofRectangle(BEGIN_X, windowHeight - scrollBarWidth, 0, scrollBarWidth);
    
    composer->setDraggingGrip(false); // true when the user is moving the grip
    mouseOverGrip = false; // true when the mouse is over the grip
    
    mouseOverHGrip = false;
    composer->setDraggingHGrip(false);
    
    updateScrollBar(ofVec3f(0,0,0));
    updateHScrollBar(ofVec3f(0,0,0));
}
void scrollBar::mouseDragged(ofMouseEventArgs &e){
    mousePositionX = e.x;
    mousePositionY = e.y;
    
    ofVec3f mouse = ofVec3f(e.x, e.y,0);
    ofVec3f mouseLast = ofVec3f(ofGetPreviousMouseX(),ofGetPreviousMouseY(),0);
    
    ofVec3f diffVec = ofVec3f(0,0,0);
    
    if (isScrollBarVisible && composer->isDraggingGrip()) {
        diffVec.y = mouseLast.y - mouse.y;
        
        // Move the grip according to the mouse displacement
        int dy = e.y - mousePreviousY;
        mousePreviousY = e.y;
        gripRectangle.y += dy;
        
    }
    if(isHScrollBarVisible && composer->isDraggingHGrip()){
        diffVec.x = mouseLast.x - mouse.x;
        
        // Move the grip according to the mouse displacement
        int dx = e.x - mousePreviousX;
        mousePreviousX = e.x;
        hGripRectangle.x += dx;
    }

    updateScrollBar(diffVec);
    updateHScrollBar(diffVec);

}
Example #11
0
void GUITable::setTextList(const std::vector<std::string> &content,
		bool transparent)
{
	clear();

	if (transparent) {
		m_background.setAlpha(0);
		m_border = false;
	}

	m_is_textlist = true;

	s32 empty_string_index = allocString("");

	m_rows.resize(content.size());
	for (s32 i = 0; i < (s32) content.size(); ++i) {
		Row *row = &m_rows[i];
		row->cells = new Cell[1];
		row->cellcount = 1;
		row->indent = 0;
		row->visible_index = i;
		m_visible_rows.push_back(i);

		Cell *cell = row->cells;
		cell->xmin = 0;
		cell->xmax = 0x7fff;  // something large enough
		cell->xpos = 6;
		cell->content_type = COLUMN_TYPE_TEXT;
		cell->content_index = empty_string_index;
		cell->tooltip_index = empty_string_index;
		cell->color.set(255, 255, 255, 255);
		cell->color_defined = false;
		cell->reported_column = 1;

		// parse row content (color)
		const std::string &s = content[i];
		if (s[0] == '#' && s[1] == '#') {
			// double # to escape
			cell->content_index = allocString(s.substr(2));
		}
		else if (s[0] == '#' && s.size() >= 7 &&
				parseColorString(
					s.substr(0,7), cell->color, false)) {
			// single # for color
			cell->color_defined = true;
			cell->content_index = allocString(s.substr(7));
		}
		else {
			// no #, just text
			cell->content_index = allocString(s);
		}

	}

	allocationComplete();

	// Clamp scroll bar position
	updateScrollBar();
}
void FragmentGalleryWidget::clear() // delete all fragment widgets
{
    while ( ! contents.isEmpty() ) {
        GalleryButton * w = contents.takeLast();
        delete w;
    }
    updateScrollBar();
}
Example #13
0
bool PBListBox::Create(PBWindow* pParent, int left, int top, int width, int height)
{
	char defaultFont[32];
	PBWindow::Create(pParent, left, top, width, height, PBWS_VSCROLL);
	snprintf(defaultFont, sizeof(defaultFont), "#LiberationSans,%u,0", (m_itemHeight << 2) / 5);
	m_font = GetThemeFont("dictionary.font.normal", defaultFont);
	updateScrollBar();
	return true;
}
Example #14
0
/* BrowserCanvas::updateLayout
 * Updates variables concerning the object layout
 *******************************************************************/
void BrowserCanvas::updateLayout() {
	// Determine number of columns
	num_cols = GetSize().x / fullItemSizeX();

	// Update the scrollbar
	updateScrollBar();

	Refresh();
}
Example #15
0
int PBListBox::OnDraw(bool force)
{
    int elem_iter;
    int elem_render_count, elem_count;

	if ( IsVisible() && (IsChanged() || force) && m_font)
    {
		PBGraphics *graphics = GetGraphics();

		if (m_properties & DRAW_BORDER)
			graphics->DrawRect(GetLeft(), GetTop(), GetWidth(), GetHeight(), BLACK);

		graphics->FillArea(GetClientLeft() + PBLIST_BORDER, GetClientTop() + PBLIST_BORDER, GetClientWidth() - (PBLIST_BORDER << 1), GetClientHeight() - (PBLIST_BORDER << 1), WHITE);

		elem_count = count();
		elem_render_count = calcListCapacity();

		// corect elements for render
		if (elem_render_count > elem_count)
			elem_render_count = elem_count;

		if (elem_render_count)
		{
			if (m_AutoScroll)
			{
				if (elem_render_count < elem_count)
				{
					if (m_listOffset > m_selected) m_listOffset = m_selected;
					if (m_selected > (m_listOffset + elem_render_count)) m_listOffset = m_selected - elem_render_count;
				}
			}
			else m_AutoScroll = 1;

			updateScrollBar();

			if (m_selected != -1)
				DrawSelect(m_selected, BLACK);

			SetFont(m_font, BLACK);
			elem_iter = 0;
			while( elem_iter <  elem_render_count)
			{
				graphics->DrawTextRect(GetClientLeft() + (PBLIST_BORDER << 2),
									   GetClientTop() + PBLIST_BORDER + elem_iter * m_itemHeight,
									   GetClientWidth() - (PBLIST_BORDER << 3),
									   m_itemHeight,
									   text(elem_iter + m_listOffset), // m_stringList[elem_iter + m_listOffset].c_str(),
									   ALIGN_LEFT | VALIGN_MIDDLE | DOTS);
				elem_iter++;
			}
		}
    }
	return 0;//PBWindow::Draw();
}
void FragmentGalleryWidget::updateButtonsGeometry()
{
    if (contents.isEmpty()) return;
    GalleryButton* firstButton = contents[0];
    buttonWidth = firstButton->layout()->sizeHint().width();
    buttonHeight = firstButton->layout()->sizeHint().height();
    for (int i = 0; i < contents.size(); ++i)
        contents[i]->resize(buttonWidth, buttonHeight);
    updateThumbnailPositions();
    updateScrollBar();
}
void Textbox::addNewLine() {
	currentLineNumber++;
	currHorizontalOffset = 0.0f;
	tokens.push_back( StringToken( "", currHorizontalOffset, currentLineNumber, textColor ) );
	// any time a new line is added, go to bottom of textbox
	firstLineInView = 0;
	if ( currentLineNumber >= getNumLinesThatFit() ) {
		firstLineInView = currentLineNumber + 1 - getNumLinesThatFit();
	}

	updateScrollBar();
}
Textbox::Textbox( glm::vec2 pos, glm::vec2 size, GLuint borderSize, const font& fontType, GLfloat fontScale ) :
	pos( pos ), size( size ), borderSize( borderSize ), fontType( fontType ), fontScale( fontScale ), borderColor( glm::vec3( 0.0f ) ),
	backgroundColor( glm::vec3( 1.0f ) ), textColor( glm::vec3( 0.0f ) ), paddingHorizontal( 8.0f ), paddingVertical( 8.0f ), currHorizontalOffset( 0.0f ),
	currentLineNumber( 0 ), lineSpacing( 1.5f ), firstLineInView( 0 ), btnSize( 32.0f ), currentMousePos( glm::vec2( -1 ) ), mouseClickOffset( 0.0f ) {
	// set scroll button textures
	Texture pressed = ResourceManager::loadTexture( "scroll_btn_pressed.png", GL_TRUE, "scroll_btn_pressed_default" );
	Texture released = ResourceManager::loadTexture( "scroll_btn_released.png", GL_TRUE, "scroll_btn_released_default" );
	Texture hover = ResourceManager::loadTexture( "scroll_btn_hover.png", GL_TRUE, "scroll_btn_hover_default" );
	bScrollUp.setTextures( pressed, released, hover );
	bScrollUp.setSize( btnSize );
	bScrollUp.setPos( glm::vec2( pos.x + size.x - borderSize - btnSize.x, pos.y + borderSize ) );
	bScrollUp.setOnClickFunction( [&]() {
		if ( firstLineInView > 0 ) {
			firstLineInView--;
			updateScrollBar();
		}
	} );

	bScrollDown.setTextures( pressed, released, hover );
	bScrollDown.setSize( btnSize );
	bScrollDown.setPos( glm::vec2( pos.x + size.x - borderSize - btnSize.x, pos.y + size.y - borderSize - btnSize.y ) );
	bScrollDown.setRotation( 180 );
	bScrollDown.setOnClickFunction( [&]() {
		if ( firstLineInView < currentLineNumber + 1 - getNumLinesThatFit() ) {
			firstLineInView++;
			updateScrollBar();
		}
	} );

	// create scroll bar
	Texture scrollbarPressed = ResourceManager::loadTexture( "scroll_bar_pressed.png", GL_TRUE, "scroll_bar_pressed_default" );
	Texture scrollbarReleased = ResourceManager::loadTexture( "scroll_bar_released.png", GL_TRUE, "scroll_bar_released_default" );
	Texture scrollbarHover = ResourceManager::loadTexture( "scroll_bar_hover.png", GL_TRUE, "scroll_bar_hover_default" );
	bScrollBar.setTextures( scrollbarPressed, scrollbarReleased, scrollbarHover );
	bScrollBar.setDraggable( GL_TRUE );
	updateScrollBar();
	bScrollBar.setOnMouseMovementFunction( [&]() {
		dragScrollBar();
	} );
}
void FragmentGalleryWidget::appendFragment(GalleryButton * button)
{
    // Assume all buttons are the same size
    if (contents.isEmpty()) {
        buttonWidth = button->layout()->sizeHint().width();
        buttonHeight = button->layout()->sizeHint().height();
    }
    button->setGeometry(0, 0, buttonWidth, buttonHeight);
    button->setParent(viewport());
    contents.append(button);
    updateThumbnailPositions();
    updateScrollBar();
}
Example #20
0
void ScrollView::moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack)
{
    Vec2 adjustedMove = flattenVectorByDirection(deltaMove);

    setInnerContainerPosition(getInnerContainerPosition() + adjustedMove);

    Vec2 outOfBoundary = getHowMuchOutOfBoundary();
    updateScrollBar(outOfBoundary);

    if(_bounceEnabled && canStartBounceBack)
    {
        startBounceBackIfNeeded();
    }
}
void Textbox::dragScrollBar() {
	if ( currentLineNumber + 1 > getNumLinesThatFit() ) {
		GLfloat yOffset = currentMousePos.y - ( mouseClickOffset + bScrollBar.getPos().y );
		GLfloat totalYSize = size.y - ( borderSize + btnSize.y ) * 2.0f;
		GLfloat lineRatio = yOffset / totalYSize;
		firstLineInView = lineRatio * currentLineNumber + firstLineInView;
		if ( firstLineInView < 0 ) {
			firstLineInView = 0;
		} else if ( firstLineInView > currentLineNumber + 1 - getNumLinesThatFit() ) {
			firstLineInView = currentLineNumber + 1 - getNumLinesThatFit();
		}
		updateScrollBar();
	}
}
void Textbox::onVerticalScroll( GLfloat offset, glm::vec2 pos ) {
	if ( isOverView( pos ) ) {
		if ( offset < 0 ) {
			if ( firstLineInView < currentLineNumber + 1 - getNumLinesThatFit() ) {
				firstLineInView++;
			}
		} else {
			if ( firstLineInView > 0 ) {
				firstLineInView--;
			}
		}
		updateScrollBar();
	}
}
void cMaterialItemView::resizeEvent(QResizeEvent *event)
{
	QAbstractItemView::resizeEvent(event);
	if (model())
	{
		updateScrollBar();
	}

	updateNameHeight();
	if (horizontalScrollBar()->isVisible())
		viewHeight = cMaterialWidget::previewHeight + horizontalScrollBar()->height() + iconMargin * 2
								 + maxNameHeight;
	else
		viewHeight = cMaterialWidget::previewHeight + iconMargin * 2 + maxNameHeight;
	setMinimumHeight(viewHeight);
}
Example #24
0
void MainWindow::updateScaleFactors(float value)
{
	static int lock = 0;

	/* TODO: There must be a better way to do this. */
	if (lock == 1)
		return;

	lock = 1;
	for (int i = 0; i < getNumChannels(); ++i) {
		// qDebug("updating scaleFactor %d", i);
		channelForms[i]->setScaleFactor(value);
		// qDebug("updating scaleFactor %d (DONE)", i);
	}
	updateScrollBar();
	lock = 0;
}
void ScrollView::setInnerContainerSize(const Size &size)
{
    float innerSizeWidth = _contentSize.width;
    float innerSizeHeight = _contentSize.height;
    Size originalInnerSize = _innerContainer->getContentSize();
    if (size.width < _contentSize.width)
    {
        CCLOG("Inner width <= scrollview width, it will be force sized!");
    }
    else
    {
        innerSizeWidth = size.width;
    }
    if (size.height < _contentSize.height)
    {
        CCLOG("Inner height <= scrollview height, it will be force sized!");
    }
    else
    {
        innerSizeHeight = size.height;
    }
    _innerContainer->setContentSize(Size(innerSizeWidth, innerSizeHeight));

    // Calculate and set the position of the inner container.
    Vec2 pos = _innerContainer->getPosition();
    if (_innerContainer->getLeftBoundary() > 0.0f)
    {
        pos.x = _innerContainer->getAnchorPoint().x * _innerContainer->getContentSize().width;
    }
    if (_innerContainer->getRightBoundary() < _contentSize.width)
    {
        pos.x = _contentSize.width - ((1.0f - _innerContainer->getAnchorPoint().x) * _innerContainer->getContentSize().width);
    }
    if (_innerContainer->getPosition().y > 0.0f)
    {
        pos.y = _innerContainer->getAnchorPoint().y * _innerContainer->getContentSize().height;
    }
    if (_innerContainer->getTopBoundary() < _contentSize.height)
    {
        pos.y = _contentSize.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getContentSize().height;
    }
    setInnerContainerPosition(pos);

    updateScrollBar(Vec2::ZERO);
}
void cMaterialItemView::rowsInserted(const QModelIndex &parent, int start, int end)
{
	for (int r = start; r <= end; r++)
	{
		cMaterialWidget *widget = new cMaterialWidget(this);
		widget->setAutoFillBackground(true);
		setIndexWidget(model()->index(r, 0, parent), widget);
	}
	QAbstractItemView::rowsInserted(parent, start, end);
	// updateGeometries();

	updateScrollBar();
	updateGeometries();

	setCurrentIndex(model()->index(start, 0));
	scrollTo(model()->index(start, 0));

	model()->fetchMore(QModelIndex());
	viewport()->update();
}
//------------------------------------------------------------------
void scrollBar::keyPressed(ofKeyEventArgs &e){
    ofVec3f diffVec = ofVec3f(0, 0, 0);
    if (isScrollBarVisible) {
        if (e.key == OF_KEY_UP ){
            diffVec.y = KEY_SCROLL_SENSITIVITY;
            gripRectangle.y -= KEY_SCROLL_SENSITIVITY;
        } else if (e.key == OF_KEY_DOWN){
            diffVec.y = -KEY_SCROLL_SENSITIVITY;
            gripRectangle.y += KEY_SCROLL_SENSITIVITY;
        }
    }
    if(isHScrollBarVisible){
        if (e.key == OF_KEY_LEFT ){
            diffVec.x = KEY_SCROLL_SENSITIVITY;
            hGripRectangle.x -= KEY_SCROLL_SENSITIVITY;
        } else if (e.key == OF_KEY_RIGHT ){
            diffVec.x = -KEY_SCROLL_SENSITIVITY;
            hGripRectangle.x += KEY_SCROLL_SENSITIVITY;
        }
    }
    updateScrollBar(diffVec);
    updateHScrollBar(diffVec);
}
Example #28
0
void eListbox::moveSelection(long dir)
{
		/* refuse to do anything without a valid list. */
	if (!m_content)
		return;
		/* if our list does not have one entry, don't do anything. */
	if (!m_items_per_page)
		return;
		/* we need the old top/sel to see what we have to redraw */
	int oldtop = m_top;
	int oldsel = m_selected;
		/* first, move cursor */
	switch (dir)
	{
	case moveUp:
	{
		m_content->cursorMove(-1);
		if (m_enabled_wrap_around && oldsel == m_content->cursorGet())  // must wrap around ?
			moveToEnd();
		break;
	}
	case moveDown:
		m_content->cursorMove(1);
			/* ok - we could have reached the end. So we do wrap around. */
		if (!m_content->cursorValid())
		{
			if (m_enabled_wrap_around)
			{
				m_top = 0;
				m_content->cursorHome();
			}
			else
				m_content->cursorMove(-1);
		}
		break;
	case pageUp:
		if (m_content->cursorGet() >= m_items_per_page)
		{
			m_content->cursorMove(-m_items_per_page);
			m_top -= m_items_per_page;
			if (m_top < 0)
				m_top = 0;
		} else
		{
			m_top = 0;
			m_content->cursorHome();
		}
		break;
	case moveTop:
		m_content->cursorHome();
		m_top = 0; /* align with top, speeds up process */
		break;
	case pageDown:
		m_content->cursorMove(m_items_per_page);
		if (m_content->cursorValid())
			break;
				/* fall through */
	case moveEnd:
		moveToEnd();
		break;
	case justCheck:
		break;
	}
	
	if (m_content->cursorValid() && !m_content->currentCursorSelectable())
	{
			/* ok, our cursor position is valid (i.e. in list), but not selectable. */
			
			/* when moving up, continue until we found a valid position. */
		if ((dir == moveUp) || (dir == pageDown))
		{
			while (m_content->cursorGet())
			{
				m_content->cursorMove(-1);
				if (m_content->currentCursorSelectable())
				{
					break;
				}
			}
		} else
		{
				/* else move down */
			while (m_content->cursorValid())
			{
				m_content->cursorMove(+1);
				if (m_content->currentCursorSelectable())
				{
					break;
				}
			}
			
			if (!m_content->cursorValid())
				m_content->cursorMove(-1);
		}
		
		if (!m_content->currentCursorSelectable())
			m_content->cursorSet(oldsel);
	}
	
		/* note that we could be on an invalid cursor position, but we don't
		   care. this only happens on empty lists, and should have almost no
		   side effects. */
	
		/* now, look wether the current selection is out of screen */
	m_selected = m_content->cursorGet();
	while (m_selected < m_top)
	{
		m_top -= m_items_per_page;
		if (m_top < 0)
			m_top = 0;
	}
	while (m_selected >= m_top + m_items_per_page)
		/* m_top should be always valid here as it's selected */
		m_top += m_items_per_page;

	if (oldsel != m_selected)
		/* emit */ selectionChanged();

	updateScrollBar();

	if (m_top != oldtop)
		invalidate();
	else if (m_selected != oldsel)
	{
   /* redraw the old and newly selected */
		gRegion inv = eRect(0, m_itemheight * (m_selected-m_top), size().width(), m_itemheight);
		inv |= eRect(0, m_itemheight * (oldsel-m_top), size().width(), m_itemheight);
		invalidate(inv);
	}
}
Example #29
0
void eListbox::moveSelection(long dir)
{
	/* refuse to do anything without a valid list. */
	if (!m_content)
		return;
	/* if our list does not have one entry, don't do anything. */
	if (!m_items_per_page)
		return;
	/* we need the old top/sel to see what we have to redraw */
	int oldtop = m_top;
	int oldsel = m_selected;
	int prevsel = oldsel;
	int newsel;

	switch (dir)
	{
	case moveEnd:
		m_content->cursorEnd();
		// falltrough
	case moveUp:
		do
		{
			m_content->cursorMove(-1);
			newsel = m_content->cursorGet();
			if (newsel == prevsel) {  // cursorMove reached top and left cursor position the same. Must wrap around ?
				if (m_enabled_wrap_around)
				{
					m_content->cursorEnd();
					m_content->cursorMove(-1);
					newsel = m_content->cursorGet();
				}
				else
				{
					m_content->cursorSet(oldsel);
					break;
				}
			}
			prevsel = newsel;
		}
		while (newsel != oldsel && !m_content->currentCursorSelectable());
		break;
	case moveTop:
		m_content->cursorHome();
		// falltrough
	case justCheck:
		if (m_content->cursorValid() && m_content->currentCursorSelectable())
			break;
		// falltrough
	case moveDown:
		do
		{
			m_content->cursorMove(1);
			if (!m_content->cursorValid()) { //cursorMove reached end and left cursor position past the list. Must wrap around ?
				if (m_enabled_wrap_around)
					m_content->cursorHome();
				else
					m_content->cursorSet(oldsel);
			}
			newsel = m_content->cursorGet();
		}
		while (newsel != oldsel && !m_content->currentCursorSelectable());
		break;
	case pageUp:
	{
		int pageind;
		do
		{
			m_content->cursorMove(-m_items_per_page);
			newsel = m_content->cursorGet();
			pageind = newsel % m_items_per_page; // rememer were we land in thsi page (could be different on topmost page)
			prevsel = newsel - pageind; // get top of page index
			// find first selectable entry in new page. First check bottom part, than upper part
			while (newsel != prevsel + m_items_per_page && m_content->cursorValid() && !m_content->currentCursorSelectable())
			{
				m_content->cursorMove(1);
				newsel = m_content->cursorGet();
			}
			if (!m_content->currentCursorSelectable()) // no selectable found in bottom part of page
			{
				m_content->cursorSet(prevsel + pageind);
				while (newsel != prevsel && !m_content->currentCursorSelectable())
				{
					m_content->cursorMove(-1);
					newsel = m_content->cursorGet();
				}
			}
			if (m_content->currentCursorSelectable())
				break;
			if (newsel == 0) // at top and nothing found . Go down till someing selectable or old location
			{
				while (newsel != oldsel && !m_content->currentCursorSelectable());
				{
					m_content->cursorMove(1);
					newsel = m_content->cursorGet();
				}
				break;
			}
			m_content->cursorSet(prevsel + pageind);
		}
		while (newsel == prevsel);
		break;
	}
	case pageDown:
	{
		int pageind;
		do
		{
			m_content->cursorMove(m_items_per_page);
			if (!m_content->cursorValid())
				m_content->cursorMove(-1);
			newsel = m_content->cursorGet();
			pageind = newsel % m_items_per_page;
			prevsel = newsel - pageind; // get top of page index
			// find a selectable entry in the new page. first look up then down from current screenlocation on the page
			while (newsel != prevsel && !m_content->currentCursorSelectable())
			{
				m_content->cursorMove(-1);
				newsel = m_content->cursorGet();
			}
			if (!m_content->currentCursorSelectable()) // no selectable found in top part of page
			{
				m_content->cursorSet(prevsel + pageind);
				do {
					m_content->cursorMove(1);
					newsel = m_content->cursorGet();
				}
			        while (newsel != prevsel + m_items_per_page && m_content->cursorValid() && !m_content->currentCursorSelectable());
			}
			if (!m_content->cursorValid())
			{
				// we reached the end of the list
				// Back up till something selectable or we reach oldsel again
				// E.g this should bring us back to the last selectable item on the original page
				do
				{
					m_content->cursorMove(-1);
					newsel = m_content->cursorGet();
				}
				while (newsel != oldsel && !m_content->currentCursorSelectable());
				break;
			}
			if (newsel != prevsel + m_items_per_page)
				break;
			m_content->cursorSet(prevsel + pageind); // prepare for next page down
		}
		while (newsel == prevsel + m_items_per_page);
		break;
	}
	}

	/* now, look wether the current selection is out of screen */
	m_selected = m_content->cursorGet();
	m_top = m_selected - (m_selected % m_items_per_page);

	if (oldsel != m_selected)
		/* emit */ selectionChanged();

	updateScrollBar();

	if (m_top != oldtop)
		invalidate();
	else if (m_selected != oldsel)
	{
		/* redraw the old and newly selected */
		gRegion inv = eRect(0, m_itemheight * (m_selected-m_top), size().width(), m_itemheight);
		inv |= eRect(0, m_itemheight * (oldsel-m_top), size().width(), m_itemheight);
		invalidate(inv);
	}
}
Example #30
0
void GUITable::updateAbsolutePosition()
{
	IGUIElement::updateAbsolutePosition();
	updateScrollBar();
}