]> git.saurik.com Git - wxWidgets.git/commitdiff
image to bitmap rewrite,
authorRobert Roebling <robert@roebling.de>
Fri, 14 Jan 2000 20:29:01 +0000 (20:29 +0000)
committerRobert Roebling <robert@roebling.de>
Fri, 14 Jan 2000 20:29:01 +0000 (20:29 +0000)
  ViewStart() renamed GetViewStart()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5392 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/outptstr.tex
docs/latex/wx/scrolwin.tex
docs/latex/wx/window.tex
include/wx/generic/scrolwin.h
samples/image/image.cpp
src/common/image.cpp
src/generic/listctrl.cpp
src/generic/scrolwin.cpp

index 6fec17cdfe863909d1cd96c1432c29479e5786cc..02da47fd2dd3d6d29769df398f31b7681e23ae8d 100644 (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
index ef24da24c9acbaea350e5ee32ef639448bf24637..1bdf47ea152654bd585646186411d32d6a0a2a1e 100644 (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.
 
index 98d2acabf5850d14c25e9128bb27a69358d723a3..d4774806bbf95f2a235cb74a0d8cd6f7dd1ec695 100644 (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
index 13c5a2d9f5186def86c20b0951e2cfd38c9fbc55..ce7a477fec0bc6cd1abaa2c393076c57d56ee075 100644 (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;
index 335f548f8389642922209bce63d3d4eaac00a40a..1e683274ad51d2cc9a50e78cd290dfdb78e9e7f4 100644 (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 );
index 627e7ab6ad221ee7e275187482310d66cd5b9ed0..dc5fdf6c481616e29df7624588e6390e555b9888 100644 (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,54 +1671,38 @@ wxImage::wxImage( const wxBitmap &bitmap )
     {
         for (int i = 0; i < bitmap.GetWidth(); i++)
         {
-            wxInt32 pixel = gdk_image_get_pixel( gdk_image, i, j );
-           if (bpp == 1)
-           {
-               if (pixel == 0)
-               {
-                    data[pos] = 0;
+            wxUint32 pixel = gdk_image_get_pixel( gdk_image, i, j );
+               if (bpp == 1)
+               {
+                   if (pixel == 0)
+                       {
+                    data[pos]   = 0;
                     data[pos+1] = 0;
                     data[pos+2] = 0;
-               }
-               else
-               {
-                    data[pos] = 255;
+                       }
+                       else
+                       {
+                    data[pos]   = 255;
                     data[pos+1] = 255;
                     data[pos+2] = 255;
-               }
-           } else if (bpp <= 8)
+                       }
+            }
+            else if (use_shift)
             {
-                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)
+                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)
             {
-#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
+                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 (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)
             {
index 98060e7927f09c674755b70a50727870b93f2771..43b025202c9a2d51241798f12b797db1b5fef977 100644 (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 w_p = 0;
-    int h_p = 0;
-    GetClientSize( &w_p, &h_p );
+    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 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;
         }
index 3ae5a628894eeae33e2eeec94d7a647154ea3afe..4e3db4bf49f8998235e64a934d0b608c19047c67 100644 (file)
@@ -351,14 +351,14 @@ void wxScrolledWindow::AdjustScrollbars()
 
     if (m_xScrollLines > 0)
     {
-       // Calculate page size i.e. number of scroll units you get on the
-       // current client window
+           // Calculate page size i.e. number of scroll units you get on the
+           // current client window
         int noPagePositions = (int) ( (w/(double)m_xScrollPixelsPerLine) + 0.5 );
         if (noPagePositions < 1) noPagePositions = 1;
 
         // Correct position if greater than extent of canvas minus
-       // the visible portion of it or if below zero
-       m_xScrollPosition = wxMin( m_xScrollLines-noPagePositions, m_xScrollPosition);
+           // the visible portion of it or if below zero
+           m_xScrollPosition = wxMin( m_xScrollLines-noPagePositions, m_xScrollPosition);
         m_xScrollPosition = wxMax( 0, m_xScrollPosition );
 
         SetScrollbar(wxHORIZONTAL, m_xScrollPosition, noPagePositions, m_xScrollLines);
@@ -373,13 +373,13 @@ void wxScrolledWindow::AdjustScrollbars()
     
     if (m_yScrollLines > 0)
     {
-       // Calculate page size i.e. number of scroll units you get on the
-       // current client window
+           // Calculate page size i.e. number of scroll units you get on the
+           // current client window
         int noPagePositions = (int) ( (h/(double)m_yScrollPixelsPerLine) + 0.5 );
         if (noPagePositions < 1) noPagePositions = 1;
 
         // Correct position if greater than extent of canvas minus
-       // the visible portion of it or if below zero
+           // the visible portion of it or if below zero
         m_yScrollPosition = wxMin( m_yScrollLines-noPagePositions, m_yScrollPosition );
         m_yScrollPosition = wxMax( 0, m_yScrollPosition );
 
@@ -495,46 +495,41 @@ void wxScrolledWindow::Scroll( int x_pos, int y_pos )
         int old_x = m_xScrollPosition;
         m_xScrollPosition = x_pos;
     
-       // Calculate page size i.e. number of scroll units you get on the
-       // current client window
+           // Calculate page size i.e. number of scroll units you get on the
+           // current client window
         int noPagePositions = (int) ( (w/(double)m_xScrollPixelsPerLine) + 0.5 );
         if (noPagePositions < 1) noPagePositions = 1;
 
         // Correct position if greater than extent of canvas minus
-       // the visible portion of it or if below zero
+           // the visible portion of it or if below zero
         m_xScrollPosition = wxMin( m_xScrollLines-noPagePositions, m_xScrollPosition );
         m_xScrollPosition = wxMax( 0, m_xScrollPosition );
       
         m_targetWindow->SetScrollPos( wxHORIZONTAL, m_xScrollPosition, TRUE );
        
-       m_targetWindow->ScrollWindow( (old_x-m_xScrollPosition)*m_xScrollPixelsPerLine, 0 );
+           m_targetWindow->ScrollWindow( (old_x-m_xScrollPosition)*m_xScrollPixelsPerLine, 0 );
     }
     if (y_pos != -1)
     {
         int old_y = m_yScrollPosition;
         m_yScrollPosition = y_pos;
        
-       // Calculate page size i.e. number of scroll units you get on the
-       // current client window
+           // Calculate page size i.e. number of scroll units you get on the
+           // current client window
         int noPagePositions = (int) ( (h/(double)m_yScrollPixelsPerLine) + 0.5 );
         if (noPagePositions < 1) noPagePositions = 1;
 
         // Correct position if greater than extent of canvas minus
-       // the visible portion of it or if below zero
+           // the visible portion of it or if below zero
         m_yScrollPosition = wxMin( m_yScrollLines-noPagePositions, m_yScrollPosition );
         m_yScrollPosition = wxMax( 0, m_yScrollPosition );
        
         m_targetWindow->SetScrollPos( wxVERTICAL, m_yScrollPosition, TRUE );
        
-       m_targetWindow->ScrollWindow( 0, (old_y-m_yScrollPosition)*m_yScrollPixelsPerLine );
+           m_targetWindow->ScrollWindow( 0, (old_y-m_yScrollPosition)*m_yScrollPixelsPerLine );
     }
     
     
-#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;