image to bitmap rewrite,

ViewStart() renamed GetViewStart()


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5392 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2000-01-14 20:29:01 +00:00
parent 27259273e4
commit cf3da716f6
8 changed files with 96 additions and 90 deletions

View File

@@ -72,7 +72,7 @@ by one of the two streams.
% -----------------------------------------------------------------------------
% wxCountingOutputStream
% -----------------------------------------------------------------------------
\section{\class{wxCountOutputStream}}\label{wxcountingoutputstream}
\section{\class{wxCountingOutputStream}}\label{wxcountingoutputstream}
wxCountingOutputStream is specialized output stream which does not write any data anyway,
instead it counts how many bytes would get written if this were a normal stream. This

View File

@@ -351,9 +351,9 @@ adjusting the scrollbars appropriately.
Call this function to tell wxScrolledWindow to perform the actually scrolling on
a different window (not on itself).
\membersection{wxScrolledWindow::ViewStart}\label{wxscrolledwindowviewstart}
\membersection{wxScrolledWindow::GetViewStart}\label{wxscrolledwindowgetviewstart}
\constfunc{void}{ViewStart}{\param{int* }{x}, \param{int* }{ y}}
\constfunc{void}{GetViewStart}{\param{int* }{x}, \param{int* }{ y}}
Get the position at which the visible portion of the window starts.

View File

@@ -1405,7 +1405,7 @@ void MyWindow::OnPaint(wxPaintEvent\& event)
// Find Out where the window is scrolled to
int vbX,vbY; // Top left corner of client
ViewStart(&vbX,&vbY);
GetViewStart(&vbX,&vbY);
int vX,vY,vW,vH; // Dimensions of client area in pixels
wxRegionIterator upd(GetUpdateRegion()); // get the update rect list

View File

@@ -80,7 +80,10 @@ public:
virtual void EnableScrolling(bool x_scrolling, bool y_scrolling);
// Get the view start
virtual void ViewStart(int *x, int *y) const;
virtual void GetViewStart(int *x, int *y) const;
// Compatibility
void ViewStart(int *x, int *y) const
{ GetViewStart( x, y ); }
// Actual size in pixels when scrolling is taken into account
virtual void GetVirtualSize(int *x, int *y) const;

View File

@@ -115,8 +115,10 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
wxMemoryDC dc;
dc.SelectObject( bitmap );
dc.SetBrush( wxBrush( "orange", wxSOLID ) );
dc.SetPen( *wxWHITE_PEN );
dc.SetPen( *wxBLACK_PEN );
dc.DrawRectangle( 0, 0, 100, 100 );
dc.SetBrush( *wxWHITE_BRUSH );
dc.DrawRectangle( 20, 20, 60, 60 );
dc.SelectObject( wxNullBitmap );
// try to find the directory with our images
@@ -209,8 +211,10 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
dc.DrawText( "Drawn directly", 150, 10 );
dc.SetBrush( wxBrush( "orange", wxSOLID ) );
dc.SetPen( *wxWHITE_PEN );
dc.SetPen( *wxBLACK_PEN );
dc.DrawRectangle( 150, 30, 100, 100 );
dc.SetBrush( *wxWHITE_BRUSH );
dc.DrawRectangle( 170, 50, 60, 60 );
if (my_anti && my_anti->Ok())
dc.DrawBitmap( *my_anti, 280, 30 );

View File

@@ -1634,19 +1634,36 @@ wxImage::wxImage( const wxBitmap &bitmap )
}
int bpp = -1;
int red_shift_right = 0;
int green_shift_right = 0;
int blue_shift_right = 0;
int red_shift_left = 0;
int green_shift_left = 0;
int blue_shift_left = 0;
bool use_shift = FALSE;
if (bitmap.GetPixmap())
{
GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() );
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
bpp = visual->depth;
if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
if (bpp == 16) bpp = visual->red_prec + visual->green_prec + visual->blue_prec;
red_shift_right = visual->red_shift;
red_shift_left = 8-visual->red_prec;
green_shift_right = visual->green_shift;
green_shift_left = 8-visual->green_prec;
blue_shift_right = visual->blue_shift;
blue_shift_left = 8-visual->blue_prec;
use_shift = (visual->type == GDK_VISUAL_TRUE_COLOR) || (visual->type == GDK_VISUAL_DIRECT_COLOR);
}
if (bitmap.GetBitmap())
{
bpp = 1;
}
GdkColormap *cmap = gtk_widget_get_default_colormap();
long pos = 0;
@@ -1654,7 +1671,7 @@ wxImage::wxImage( const wxBitmap &bitmap )
{
for (int i = 0; i < bitmap.GetWidth(); i++)
{
wxInt32 pixel = gdk_image_get_pixel( gdk_image, i, j );
wxUint32 pixel = gdk_image_get_pixel( gdk_image, i, j );
if (bpp == 1)
{
if (pixel == 0)
@@ -1669,38 +1686,22 @@ wxImage::wxImage( const wxBitmap &bitmap )
data[pos+1] = 255;
data[pos+2] = 255;
}
} else if (bpp <= 8)
}
else if (use_shift)
{
data[pos] = (pixel >> red_shift_right) << red_shift_left;
data[pos+1] = (pixel >> green_shift_right) << green_shift_left;
data[pos+2] = (pixel >> blue_shift_right) << blue_shift_left;
}
else if (cmap->colors)
{
data[pos] = cmap->colors[pixel].red >> 8;
data[pos+1] = cmap->colors[pixel].green >> 8;
data[pos+2] = cmap->colors[pixel].blue >> 8;
} else if (bpp == 15)
}
else
{
#if (wxBYTE_ORDER == wxBIG_ENDIAN)
// ?
#endif
data[pos] = (pixel >> 7) & 0xf8;
data[pos+1] = (pixel >> 2) & 0xf8;
data[pos+2] = (pixel << 3) & 0xf8;
} else if (bpp == 16)
{
#if (wxBYTE_ORDER == wxBIG_ENDIAN)
// ?
#endif
data[pos] = (pixel >> 8) & 0xf8;
data[pos+1] = (pixel >> 3) & 0xfc;
data[pos+2] = (pixel << 3) & 0xf8;
} else
{
#if (wxBYTE_ORDER == wxBIG_ENDIAN)
data[pos] = (pixel) & 0xff; // Red
data[pos+1] = (pixel >> 8) & 0xff; // Green
data[pos+2] = (pixel >> 16) & 0xff; // Blue
#else
data[pos] = (pixel >> 16) & 0xff;
data[pos+1] = (pixel >> 8) & 0xff;
data[pos+2] = pixel & 0xff;
#endif
wxFAIL_MSG( wxT("Image conversion failed. Unknown visual type.") );
}
if (gdk_image_mask)

View File

@@ -1530,29 +1530,32 @@ void wxListMainWindow::MoveToFocus()
{
if (!m_current) return;
int x = 0;
int y = 0;
int w = 0;
int h = 0;
m_current->GetExtent( x, y, w, h );
int item_x = 0;
int item_y = 0;
int item_w = 0;
int item_h = 0;
m_current->GetExtent( item_x, item_y, item_w, item_h );
int w_p = 0;
int h_p = 0;
GetClientSize( &w_p, &h_p );
int client_w = 0;
int client_h = 0;
GetClientSize( &client_w, &client_h );
int view_x = m_xScroll*GetScrollPos( wxHORIZONTAL );
int view_y = m_yScroll*GetScrollPos( wxVERTICAL );
if (m_mode & wxLC_REPORT)
{
int y_s = m_yScroll*GetScrollPos( wxVERTICAL );
if ((y > y_s) && (y+h < y_s+h_p)) return;
if (y-y_s < 5) { Scroll( -1, (y-5-h_p/2)/m_yScroll ); }
if (y+h+5 > y_s+h_p) { Scroll( -1, (y+h-h_p/2+h+15)/m_yScroll); }
if (item_y-5 < view_y )
Scroll( -1, (item_y-5)/m_yScroll );
if (item_y+item_h+5 > view_y+client_h)
Scroll( -1, (item_y+item_h-client_h+15)/m_yScroll );
}
else
{
int x_s = m_xScroll*GetScrollPos( wxHORIZONTAL );
if ((x > x_s) && (x+w < x_s+w_p)) return;
if (x-x_s < 5) { Scroll( (x-5)/m_xScroll, -1 ); }
if (x+w-5 > x_s+w_p) { Scroll( (x+w-w_p+15)/m_xScroll, -1 ); }
if (item_x-view_x < 5)
Scroll( (item_x-5)/m_xScroll, -1 );
if (item_x+item_w-5 > view_x+client_w)
Scroll( (item_x+item_w-client_w+15)/m_xScroll, -1 );
}
}
@@ -1561,12 +1564,12 @@ void wxListMainWindow::OnArrowChar( wxListLineData *newCurrent, bool shiftDown )
if ((m_mode & wxLC_SINGLE_SEL) || (m_usedKeys == FALSE)) m_current->Hilight( FALSE );
wxListLineData *oldCurrent = m_current;
m_current = newCurrent;
MoveToFocus();
if (shiftDown || (m_mode & wxLC_SINGLE_SEL)) m_current->Hilight( TRUE );
RefreshLine( m_current );
RefreshLine( oldCurrent );
FocusLine( m_current );
UnfocusLine( oldCurrent );
MoveToFocus();
}
void wxListMainWindow::OnKeyDown( wxKeyEvent &event )
@@ -1722,11 +1725,11 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
m_current->ReverseHilight();
wxNode *node = m_lines.Member( m_current )->Next();
if (node) m_current = (wxListLineData*)node->Data();
MoveToFocus();
RefreshLine( oldCurrent );
RefreshLine( m_current );
UnfocusLine( oldCurrent );
FocusLine( m_current );
MoveToFocus();
}
break;
}

View File

@@ -530,11 +530,6 @@ void wxScrolledWindow::Scroll( int x_pos, int y_pos )
}
#ifdef __WXMSW__
// ::UpdateWindow ((HWND) GetHWND());
#else
// Refresh();
#endif
#ifdef __WXMAC__
m_targetWindow->MacUpdateImmediately() ;
#endif
@@ -555,7 +550,7 @@ void wxScrolledWindow::GetVirtualSize (int *x, int *y) const
}
// Where the current view starts from
void wxScrolledWindow::ViewStart (int *x, int *y) const
void wxScrolledWindow::GetViewStart (int *x, int *y) const
{
if ( x )
*x = m_xScrollPosition;