Example #1
0
void C3DList::OnLButtonDown(UINT nFlags, CPoint point) 
{
	SetCapture();

	RECT rect, hs, vs;
	GetClientRect( &rect );

	m_scrollbar.GetClientRect( &vs );
	rect.right -= RW( vs );

	// If horizontal scroll bar
	if ( !GetListCtrl().GetHeader().IsAutosizing() )
	{
		m_hscroll.GetClientRect( &hs );
		rect.bottom -= RH( hs );
	} // end if

	// Let list handle button press
	if ( m_list.OnLButtonDown( nFlags, &point, &rect ) )
	{
		RECT rect;
		GetClientRect( &rect );
		rect.right -= GetSystemMetrics( SM_CXVSCROLL );			
		rect.bottom -= GetSystemMetrics( SM_CYHSCROLL );
		RedrawWindow( &rect );
		UpdateVScrollBar();
	} // end if
	
	CStatic::OnLButtonDown(nFlags, point);
}
Example #2
0
void C3DList::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	UpdateVScrollBar();
	UpdateHScrollBar();

	RECT	rect;
	GetClientRect( &rect );
	rect.right -= GetSystemMetrics( SM_CXVSCROLL );

	// No bottom scroll bar if autosizing header
	if ( !GetListCtrl().GetHeader().IsAutosizing() )
		rect.bottom -= GetSystemMetrics( SM_CYHSCROLL );

	// Get a dc in which to draw
	HDC hDC = dc.GetSafeHdc();
	if ( m_offscreen.Create( hDC, &rect ) )
		hDC = m_offscreen.GetSafeHdc();
		
	// Draw the list
	if ( !m_list.Draw( hDC, &rect, GetSafeHwnd() ) )
		CGrDC::FillSolidRect( hDC, &rect, RGB( 128, 128, 128 ) );

	// Draw to the screen
	m_offscreen.Draw( dc.GetSafeHdc(), &rect );
}
Example #3
0
void ListBox::InsertItem( int32_t index, const std::wstring& text )
{
	mItems.insert(mItems.begin() + index, text);
	UpdateVScrollBar();

	if (mVertScrollBar->IsVisible() && index > mNumVisibleItems)
		mVertScrollBar->SetScrollValue(index - mNumVisibleItems);
}
Example #4
0
void ListBox::AddItem( const std::wstring& text )
{
	mItems.push_back(text);
	UpdateVScrollBar();

	if (mVertScrollBar->IsVisible())
		mVertScrollBar->SetScrollValue(mItems.size() - mNumVisibleItems);
}
Example #5
0
void C3DList::Size()
{
	// Must have window
	if ( !IsWindow( GetSafeHwnd() ) ) return;

	RECT	rect;
	GetClientRect( &rect );

	UpdateVScrollBar();
	UpdateHScrollBar();

	// Set scroll bar position
	rect.left = rect.right - GetSystemMetrics( SM_CXVSCROLL );
	if ( IsWindow( m_scrollbar.GetSafeHwnd() ) )
	{
		m_scrollbar.SetWindowPos(	NULL, rect.left, rect.top,
									rect.right - rect.left,
									rect.bottom - rect.top,
									SWP_NOZORDER | SWP_NOACTIVATE );		

		m_scrollbar.RedrawWindow();

		// Validate vscroll
		ValidateRect( &rect );

	} // end if

	// Set scroll bar position
	GetClientRect( &rect );
	rect.top = rect.bottom - GetSystemMetrics( SM_CYHSCROLL );
	rect.right -= GetSystemMetrics( SM_CXVSCROLL );
	if ( IsWindow( m_hscroll.GetSafeHwnd() ) )
	{
		m_hscroll.SetWindowPos(	NULL, rect.left, rect.top,
								rect.right - rect.left,
								rect.bottom - rect.top,
								SWP_NOZORDER | SWP_NOACTIVATE );		

		m_hscroll.RedrawWindow();

		// Hide or show scroll bar
		if ( !GetListCtrl().GetHeader().IsAutosizing() )
		{
			// Ensure visible
			m_hscroll.ShowWindow( SW_SHOWNORMAL );

			// Validate hscroll
			ValidateRect( &rect );

		} // end if
		else m_hscroll.ShowWindow( SW_HIDE );

		
	} // end if

	RedrawWindow();
}
Example #6
0
void SelectRowSignal( GtkCList *clist, gint row, gint column, GdkEventButton *event, gpointer user_data)
{
	if ( gtk_clist_get_text( GTK_CLIST(SectionsList), row, 0, (gchar **)&pNameSectionSelected ) )
	{
		RowSectionSelected = row;
		SectionSelected( pNameSectionSelected );
		EditorButtonsAccordingSectionType( );
		UpdateVScrollBar( );
	}
}
Example #7
0
void ListBox::RemoveItem( int32_t index )
{
	if (index < 0 || index >= (int32_t)mItems.size())
		return;

	mItems.erase(mItems.begin() + index);

	if( mSelectedIndex >= ( int )mItems.size() )
		mSelectedIndex = mItems.size() - 1;

	UpdateVScrollBar();
}
Example #8
0
void ListBox::UpdateRect()
{
	UIElement::UpdateRect();

	int2 screenPos = GetScreenPosition();

	mSelectionRegion.X = (float)screenPos.X();
	mSelectionRegion.Width = (float)mSize.X();
	mSelectionRegion.Y = (float)screenPos.Y() + mBorder[1];
	mSelectionRegion.Height = (float)mSize.Y() - mBorder[1] - mBorder[3];
	
	float oldHeigt = mSelectionRegion.Height;

	mNumVisibleItems = (int32_t)floor(mSelectionRegion.Height / mTextRowHeight + 0.5f);
	mSelectionRegion.Height = mTextRowHeight * mNumVisibleItems;

	mSize.Y() += int32_t(ceilf(mSelectionRegion.Height) - oldHeigt);
	
	UpdateVScrollBar();

	mTextRegion = mSelectionRegion;
	mTextRegion.SetLeft( mSelectionRegion.X + mBorder[0]);
	mTextRegion.SetRight( mSelectionRegion.Right() - mBorder[2]);
}