Pretty redical change concerning the underlying

X's windows' position. Even without having
  scrolled anywhere, the device origin of the
  top left corner is no longer certain to be
  zero,zero.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@401 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-07-30 09:16:21 +00:00
parent 82ab121507
commit d4c99d6fa8
11 changed files with 200 additions and 115 deletions

View File

@@ -330,7 +330,6 @@ private:
int m_lineHeight; int m_lineHeight;
wxPen m_dottedPen; wxPen m_dottedPen;
bool m_isCreated; bool m_isCreated;
wxPaintDC *m_dc;
wxBrush *m_hilightBrush; wxBrush *m_hilightBrush;
wxImageList *m_imageList; wxImageList *m_imageList;
wxImageList *m_smallImageList; wxImageList *m_smallImageList;

View File

@@ -100,7 +100,7 @@ void wxScrolledWindow::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY,
m_yScrollPosition = yPos; m_yScrollPosition = yPos;
m_xScrollLines = noUnitsX; m_xScrollLines = noUnitsX;
m_yScrollLines = noUnitsY; m_yScrollLines = noUnitsY;
AdjustScrollbars(); AdjustScrollbars();
if (do_refresh && !noRefresh) Refresh(); if (do_refresh && !noRefresh) Refresh();

View File

@@ -354,7 +354,6 @@ wxTreeCtrl::wxTreeCtrl()
m_lineHeight = 10; m_lineHeight = 10;
m_indent = 15; m_indent = 15;
m_isCreated = FALSE; m_isCreated = FALSE;
m_dc = NULL;
m_hilightBrush = new wxBrush( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT), wxSOLID ); m_hilightBrush = new wxBrush( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT), wxSOLID );
m_imageList = NULL; m_imageList = NULL;
m_smallImageList = NULL; m_smallImageList = NULL;
@@ -373,7 +372,6 @@ wxTreeCtrl::wxTreeCtrl(wxWindow *parent, wxWindowID id,
m_lineHeight = 10; m_lineHeight = 10;
m_indent = 15; m_indent = 15;
m_isCreated = FALSE; m_isCreated = FALSE;
m_dc = NULL;
m_hilightBrush = new wxBrush( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT), wxSOLID ); m_hilightBrush = new wxBrush( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT), wxSOLID );
m_imageList = NULL; m_imageList = NULL;
m_smallImageList = NULL; m_smallImageList = NULL;
@@ -382,7 +380,6 @@ wxTreeCtrl::wxTreeCtrl(wxWindow *parent, wxWindowID id,
wxTreeCtrl::~wxTreeCtrl() wxTreeCtrl::~wxTreeCtrl()
{ {
if (m_dc) delete m_dc;
}; };
bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id, bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id,
@@ -450,11 +447,14 @@ long wxTreeCtrl::InsertItem( long parent, const wxString& label, int image,
int ch = 0; int ch = 0;
GetClientSize( NULL, &ch ); GetClientSize( NULL, &ch );
wxRectangle rect;
rect.x = 0; rect.y = 0;
rect.width = 10000; rect.height = ch;
PrepareDC( dc ); PrepareDC( dc );
wxRectangle rect;
rect.x = dc.LogicalToDeviceX( 0 );
rect.y = 0;
rect.width = 10000;
rect.height = ch;
if (p->m_children.Number() == 1) if (p->m_children.Number() == 1)
{ {
rect.y = dc.LogicalToDeviceY( p->m_y ); rect.y = dc.LogicalToDeviceY( p->m_y );
@@ -466,11 +466,6 @@ long wxTreeCtrl::InsertItem( long parent, const wxString& label, int image,
rect.y = dc.LogicalToDeviceY( last_child->m_y ); rect.y = dc.LogicalToDeviceY( last_child->m_y );
}; };
long doX = 0;
long doY = 0;
dc.GetDeviceOrigin( &doX, &doY );
rect.height = ch-rect.y-doY;
AdjustMyScrollbars(); AdjustMyScrollbars();
if (rect.height > 0) Refresh( FALSE, &rect); if (rect.height > 0) Refresh( FALSE, &rect);
@@ -531,11 +526,14 @@ long wxTreeCtrl::InsertItem( long parent, wxTreeItem &info, long WXUNUSED(insert
int ch = 0; int ch = 0;
GetClientSize( NULL, &ch ); GetClientSize( NULL, &ch );
wxRectangle rect;
rect.x = 0; rect.y = 0;
rect.width = 10000; rect.height = ch;
PrepareDC( dc ); PrepareDC( dc );
wxRectangle rect;
rect.x = dc.LogicalToDeviceX( 0 );
rect.y = 0;
rect.width = 10000;
rect.height = ch;
if (p->m_children.Number() == 1) if (p->m_children.Number() == 1)
{ {
rect.y = dc.LogicalToDeviceY( p->m_y ); rect.y = dc.LogicalToDeviceY( p->m_y );
@@ -547,11 +545,6 @@ long wxTreeCtrl::InsertItem( long parent, wxTreeItem &info, long WXUNUSED(insert
rect.y = dc.LogicalToDeviceY( last_child->m_y ); rect.y = dc.LogicalToDeviceY( last_child->m_y );
}; };
long doX = 0;
long doY = 0;
dc.GetDeviceOrigin( &doX, &doY );
rect.height = ch-rect.y-doY;
AdjustMyScrollbars(); AdjustMyScrollbars();
if (rect.height > 0) Refresh( FALSE, &rect); if (rect.height > 0) Refresh( FALSE, &rect);
@@ -609,19 +602,18 @@ bool wxTreeCtrl::ExpandItem( long item, int action )
} }
}; };
wxClientDC dc(this);
PrepareDC(dc);
int cw = 0; int cw = 0;
int ch = 0; int ch = 0;
GetClientSize( &cw, &ch ); GetClientSize( &cw, &ch );
wxRect rect; wxRect rect;
rect.x = 0; rect.x = dc.LogicalToDeviceX( 0 );
rect.width = cw; rect.width = cw;
wxClientDC dc(this);
PrepareDC(dc);
rect.y = dc.LogicalToDeviceY( i->m_y ); rect.y = dc.LogicalToDeviceY( i->m_y );
rect.height = ch;
long doY = 0;
dc.GetDeviceOrigin( NULL, &doY );
rect.height = ch-rect.y-doY;
Refresh( TRUE, &rect ); Refresh( TRUE, &rect );
AdjustMyScrollbars(); AdjustMyScrollbars();
@@ -847,12 +839,16 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level,
int oldY = y; int oldY = y;
if (IsExposed( 0, item->m_y-2, 10000, m_lineHeight+4 )) int exposed_x = dc.LogicalToDeviceX( 0 );
int exposed_y = dc.LogicalToDeviceY( item->m_y-2 );
if (IsExposed( exposed_x, exposed_y, 1000, m_lineHeight+4 ))
{ {
int startX = horizX; int startX = horizX;
int endX = horizX + 10; int endX = horizX + 10;
if (!item->HasChildren()) endX += 20; if (!item->HasChildren()) endX += 20;
dc.DrawLine( startX, y, endX, y ); dc.DrawLine( startX, y, endX, y );
if (item->HasChildren()) if (item->HasChildren())
@@ -890,6 +886,7 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level,
} }
else else
{ {
dc.SetBrush( *wxWHITE_BRUSH );
dc.SetPen( *wxTRANSPARENT_PEN ); dc.SetPen( *wxTRANSPARENT_PEN );
long tw, th; long tw, th;
dc.GetTextExtent( item->m_text, &tw, &th ); dc.GetTextExtent( item->m_text, &tw, &th );
@@ -923,19 +920,16 @@ void wxTreeCtrl::OnPaint( const wxPaintEvent &WXUNUSED(event) )
{ {
if (!m_anchor) return; if (!m_anchor) return;
if (!m_dc) wxPaintDC dc(this);
{ PrepareDC( dc );
m_dc = new wxPaintDC(this);
PrepareDC( *m_dc );
};
m_dc->SetFont( wxSystemSettings::GetSystemFont( wxSYS_SYSTEM_FONT ) ); dc.SetFont( wxSystemSettings::GetSystemFont( wxSYS_SYSTEM_FONT ) );
m_dc->SetPen( m_dottedPen ); dc.SetPen( m_dottedPen );
m_lineHeight = (int)(m_dc->GetCharHeight() + 4); m_lineHeight = (int)(dc.GetCharHeight() + 4);
int y = m_lineHeight / 2 + 2; int y = m_lineHeight / 2 + 2;
PaintLevel( m_anchor, *m_dc, 0, y ); PaintLevel( m_anchor, dc, 0, y );
}; };
void wxTreeCtrl::OnSetFocus( const wxFocusEvent &WXUNUSED(event) ) void wxTreeCtrl::OnSetFocus( const wxFocusEvent &WXUNUSED(event) )
@@ -1041,7 +1035,7 @@ void wxTreeCtrl::RefreshLine( wxGenericTreeItem *item )
rect.x = dc.LogicalToDeviceX( item->m_x-2 ); rect.x = dc.LogicalToDeviceX( item->m_x-2 );
rect.y = dc.LogicalToDeviceY( item->m_y-2 ); rect.y = dc.LogicalToDeviceY( item->m_y-2 );
rect.width = 1000; rect.width = 1000;
rect.height = dc.GetCharHeight()+4; rect.height = dc.GetCharHeight()+6;
Refresh( TRUE, &rect ); Refresh( TRUE, &rect );
}; };

View File

@@ -293,8 +293,10 @@ void wxDC::SetDeviceOrigin( long x, long y )
void wxDC::GetDeviceOrigin( long *x, long *y ) void wxDC::GetDeviceOrigin( long *x, long *y )
{ {
if (x) *x = m_externalDeviceOriginX; // if (x) *x = m_externalDeviceOriginX;
if (y) *y = m_externalDeviceOriginY; // if (y) *y = m_externalDeviceOriginY;
if (x) *x = m_deviceOriginX;
if (y) *y = m_deviceOriginY;
}; };
void wxDC::SetInternalDeviceOrigin( long x, long y ) void wxDC::SetInternalDeviceOrigin( long x, long y )

View File

@@ -19,6 +19,7 @@
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/toolbar.h" #include "wx/toolbar.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
#include "wx/mdi.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
const wxMENU_HEIGHT = 28; const wxMENU_HEIGHT = 28;
@@ -253,18 +254,18 @@ void wxFrame::GtkOnSize( int x, int y, int width, int height )
main_y += toolbar_height; main_y += toolbar_height;
main_height -= toolbar_height; main_height -= toolbar_height;
gtk_widget_set_uposition( GTK_WIDGET(m_wxwindow), main_x, main_y ); gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_wxwindow, main_x, main_y );
gtk_widget_set_usize( GTK_WIDGET(m_wxwindow), main_width, main_height ); gtk_widget_set_usize( m_wxwindow, main_width, main_height );
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
gtk_widget_set_uposition( m_frameMenuBar->m_widget, 1, 1 ); gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameMenuBar->m_widget, 1, 1 );
gtk_widget_set_usize( m_frameMenuBar->m_widget, width-2, wxMENU_HEIGHT-2 ); gtk_widget_set_usize( m_frameMenuBar->m_widget, width-2, wxMENU_HEIGHT-2 );
}; };
if (m_frameToolBar) if (m_frameToolBar)
{ {
gtk_widget_set_uposition( m_frameToolBar->m_widget, 1, wxMENU_HEIGHT ); gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, wxMENU_HEIGHT );
gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height ); gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height );
}; };
@@ -320,7 +321,9 @@ void wxFrame::AddChild( wxWindow *child )
{ {
// wxFrame and wxDialog as children aren't placed into the parents // wxFrame and wxDialog as children aren't placed into the parents
if (child->IsKindOf(CLASSINFO(wxFrame)) || child->IsKindOf(CLASSINFO(wxDialog))) if (IS_KIND_OF(child,wxMDIChildFrame)) printf( "wxFrame::AddChild error.\n" );
if ( IS_KIND_OF(child,wxFrame) || IS_KIND_OF(child,wxDialog))
{ {
m_children.Append( child ); m_children.Append( child );

View File

@@ -150,9 +150,9 @@ gtk_myfixed_put (GtkMyFixed *myfixed,
child_info = g_new (GtkMyFixedChild, 1); child_info = g_new (GtkMyFixedChild, 1);
child_info->widget = widget; child_info->widget = widget;
child_info->x = x; child_info->x = x - myfixed->scroll_offset_x;
child_info->y = y; child_info->y = y - myfixed->scroll_offset_y;
gtk_widget_set_parent (widget, GTK_WIDGET (myfixed)); gtk_widget_set_parent (widget, GTK_WIDGET (myfixed));
myfixed->children = g_list_append (myfixed->children, child_info); myfixed->children = g_list_append (myfixed->children, child_info);
@@ -188,8 +188,8 @@ gtk_myfixed_move (GtkMyFixed *myfixed,
if (child->widget == widget) if (child->widget == widget)
{ {
child->x = x; child->x = x - myfixed->scroll_offset_x;
child->y = y; child->y = y - myfixed->scroll_offset_y;
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (myfixed)) if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (myfixed))
gtk_widget_queue_resize (GTK_WIDGET (myfixed)); gtk_widget_queue_resize (GTK_WIDGET (myfixed));
@@ -238,17 +238,20 @@ gtk_myfixed_unmap (GtkWidget *widget)
static void static void
gtk_myfixed_realize (GtkWidget *widget) gtk_myfixed_realize (GtkWidget *widget)
{ {
GtkMyFixed *myfixed;
GdkWindowAttr attributes; GdkWindowAttr attributes;
gint attributes_mask; gint attributes_mask;
g_return_if_fail (widget != NULL); g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_MYFIXED (widget)); g_return_if_fail (GTK_IS_MYFIXED (widget));
myfixed = GTK_MYFIXED (widget);
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
attributes.window_type = GDK_WINDOW_CHILD; attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = widget->allocation.x; attributes.x = widget->allocation.x + myfixed->scroll_offset_x;
attributes.y = widget->allocation.y; attributes.y = widget->allocation.y + myfixed->scroll_offset_x;
attributes.width = 32000; attributes.width = 32000;
attributes.height = 32000; attributes.height = 32000;
attributes.wclass = GDK_INPUT_OUTPUT; attributes.wclass = GDK_INPUT_OUTPUT;

View File

@@ -26,6 +26,8 @@
#include "wx/dnd.h" #include "wx/dnd.h"
#include "wx/mdi.h" #include "wx/mdi.h"
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/statusbr.h"
#include "wx/treectrl.h"
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include <math.h> #include <math.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
@@ -52,7 +54,9 @@ void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gd
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
/* /*
printf( "OnExpose from " ); if (IS_KIND_OF(win,wxTreeCtrl))
{
printf( "OnExpose from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
@@ -61,6 +65,7 @@ void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gd
printf( "y: %d \n", gdk_event->area.y ); printf( "y: %d \n", gdk_event->area.y );
printf( "w: %d \n", gdk_event->area.width ); printf( "w: %d \n", gdk_event->area.width );
printf( "h: %d \n", gdk_event->area.height ); printf( "h: %d \n", gdk_event->area.height );
}
*/ */
win->m_updateRegion.Union( gdk_event->area.x, win->m_updateRegion.Union( gdk_event->area.x,
@@ -1319,14 +1324,11 @@ void wxWindow::ScreenToClient( int *x, int *y )
void wxWindow::Centre( int direction ) void wxWindow::Centre( int direction )
{ {
int x = 0;
int y = 0;
GetPosition( &x, &y );
if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame))) if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame)))
{ {
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2; if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2; if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
gtk_widget_set_uposition( m_widget, x, y ); ImplementSetPosition();
} }
else else
{ {
@@ -1335,9 +1337,9 @@ void wxWindow::Centre( int direction )
int p_w = 0; int p_w = 0;
int p_h = 0; int p_h = 0;
m_parent->GetSize( &p_w, &p_h ); m_parent->GetSize( &p_w, &p_h );
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (p_w - m_width) / 2; if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (p_w - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (p_h - m_height) / 2; if (direction & wxVERTICAL == wxVERTICAL) m_y = (p_h - m_height) / 2;
gtk_widget_set_uposition( m_widget, x, y ); ImplementSetPosition();
}; };
} }
}; };
@@ -1433,7 +1435,8 @@ void wxWindow::AddChild( wxWindow *child )
// wxFrame and wxDialog as children aren't placed into the parents // wxFrame and wxDialog as children aren't placed into the parents
if (child->IsKindOf(CLASSINFO(wxFrame)) || child->IsKindOf(CLASSINFO(wxDialog))) if (( IS_KIND_OF(child,wxFrame) || IS_KIND_OF(child,wxDialog) ) &&
(!IS_KIND_OF(child,wxMDIChildFrame)))
{ {
m_children.Append( child ); m_children.Append( child );
@@ -1446,9 +1449,9 @@ void wxWindow::AddChild( wxWindow *child )
// In the case of an wxMDIChildFrame descendant, we use the // In the case of an wxMDIChildFrame descendant, we use the
// client windows's AddChild() // client windows's AddChild()
if (IsKindOf(CLASSINFO(wxMDIParentFrame))) if (IS_KIND_OF(this,wxMDIParentFrame))
{ {
if (child->IsKindOf(CLASSINFO(wxMDIChildFrame))) if (IS_KIND_OF(child,wxMDIChildFrame))
{ {
wxMDIClientWindow *client = ((wxMDIParentFrame*)this)->GetClientWindow(); wxMDIClientWindow *client = ((wxMDIParentFrame*)this)->GetClientWindow();
if (client) if (client)
@@ -1461,7 +1464,7 @@ void wxWindow::AddChild( wxWindow *child )
// wxNotebook is very special, so it has a private AddChild() // wxNotebook is very special, so it has a private AddChild()
if (IsKindOf(CLASSINFO(wxNotebook))) if (IS_KIND_OF(this,wxNotebook))
{ {
wxNotebook *tab = (wxNotebook*)this; wxNotebook *tab = (wxNotebook*)this;
tab->AddChild( child ); tab->AddChild( child );
@@ -1470,7 +1473,7 @@ void wxWindow::AddChild( wxWindow *child )
// wxFrame has a private AddChild // wxFrame has a private AddChild
if (IsKindOf(CLASSINFO(wxFrame))) if (IS_KIND_OF(this,wxFrame))
{ {
wxFrame *frame = (wxFrame*)this; wxFrame *frame = (wxFrame*)this;
frame->AddChild( child ); frame->AddChild( child );
@@ -1480,7 +1483,8 @@ void wxWindow::AddChild( wxWindow *child )
// All the rest // All the rest
m_children.Append( child ); m_children.Append( child );
if (m_wxwindow) gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget, child->m_x, child->m_y ); if (m_wxwindow) gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget,
child->m_x, child->m_y );
gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height ); gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height );
}; };
@@ -1564,9 +1568,9 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
if (rect) if (rect)
gdk_window_clear_area( m_wxwindow->window, gdk_window_clear_area( m_wxwindow->window,
rect->x, rect->x,
rect->y, rect->y,
rect->width, rect->width,
rect->height ); rect->height );
else else
Clear(); Clear();
}; };
@@ -1599,6 +1603,13 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
gdk_rect.y = rect->y; gdk_rect.y = rect->y;
gdk_rect.width = rect->width; gdk_rect.width = rect->width;
gdk_rect.height = rect->height; gdk_rect.height = rect->height;
if (IS_KIND_OF(this,wxTreeCtrl))
{
printf( "x: %d y: %d w: %d h: %d .\n",
gdk_rect.x, gdk_rect.y, gdk_rect.width, gdk_rect.height );
}
if (m_wxwindow) if (m_wxwindow)
gtk_widget_draw( m_wxwindow, &gdk_rect ); gtk_widget_draw( m_wxwindow, &gdk_rect );
else else
@@ -1885,11 +1896,25 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible,
}; };
if (m_wxwindow->window) if (m_wxwindow->window)
{ {
if (orient == wxHORIZONTAL) if (orient == wxHORIZONTAL)
{
/*
m_drawingOffsetX = -16000;
gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY );
*/
gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
else }
else
{
/*
m_drawingOffsetY = -16000;
gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY );
*/
gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" );
}
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
}; };
@@ -1958,13 +1983,26 @@ void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
{ {
if (!m_wxwindow) return; if (!m_wxwindow) return;
m_drawingOffsetX += dx; bool refresh = FALSE;
m_drawingOffsetY += dy;
if ((m_drawingOffsetX == 0) && (m_drawingOffsetY == 0))
{
m_drawingOffsetX = -16000;
m_drawingOffsetY = -16000;
refresh = TRUE;
}
else
{
m_drawingOffsetX += dx;
m_drawingOffsetY += dy;
}
// printf( "X: %d Y: %d \n", (int)m_drawingOffsetX, (int)m_drawingOffsetY ); // printf( "X: %d Y: %d \n", (int)m_drawingOffsetX, (int)m_drawingOffsetY );
gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY ); gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY );
if (refresh) Refresh();
/* /*
The code here is very nifty, but it doesn't work with The code here is very nifty, but it doesn't work with
overlapping windows... overlapping windows...

View File

@@ -293,8 +293,10 @@ void wxDC::SetDeviceOrigin( long x, long y )
void wxDC::GetDeviceOrigin( long *x, long *y ) void wxDC::GetDeviceOrigin( long *x, long *y )
{ {
if (x) *x = m_externalDeviceOriginX; // if (x) *x = m_externalDeviceOriginX;
if (y) *y = m_externalDeviceOriginY; // if (y) *y = m_externalDeviceOriginY;
if (x) *x = m_deviceOriginX;
if (y) *y = m_deviceOriginY;
}; };
void wxDC::SetInternalDeviceOrigin( long x, long y ) void wxDC::SetInternalDeviceOrigin( long x, long y )

View File

@@ -19,6 +19,7 @@
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/toolbar.h" #include "wx/toolbar.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
#include "wx/mdi.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
const wxMENU_HEIGHT = 28; const wxMENU_HEIGHT = 28;
@@ -253,18 +254,18 @@ void wxFrame::GtkOnSize( int x, int y, int width, int height )
main_y += toolbar_height; main_y += toolbar_height;
main_height -= toolbar_height; main_height -= toolbar_height;
gtk_widget_set_uposition( GTK_WIDGET(m_wxwindow), main_x, main_y ); gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_wxwindow, main_x, main_y );
gtk_widget_set_usize( GTK_WIDGET(m_wxwindow), main_width, main_height ); gtk_widget_set_usize( m_wxwindow, main_width, main_height );
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
gtk_widget_set_uposition( m_frameMenuBar->m_widget, 1, 1 ); gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameMenuBar->m_widget, 1, 1 );
gtk_widget_set_usize( m_frameMenuBar->m_widget, width-2, wxMENU_HEIGHT-2 ); gtk_widget_set_usize( m_frameMenuBar->m_widget, width-2, wxMENU_HEIGHT-2 );
}; };
if (m_frameToolBar) if (m_frameToolBar)
{ {
gtk_widget_set_uposition( m_frameToolBar->m_widget, 1, wxMENU_HEIGHT ); gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, wxMENU_HEIGHT );
gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height ); gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height );
}; };
@@ -320,7 +321,9 @@ void wxFrame::AddChild( wxWindow *child )
{ {
// wxFrame and wxDialog as children aren't placed into the parents // wxFrame and wxDialog as children aren't placed into the parents
if (child->IsKindOf(CLASSINFO(wxFrame)) || child->IsKindOf(CLASSINFO(wxDialog))) if (IS_KIND_OF(child,wxMDIChildFrame)) printf( "wxFrame::AddChild error.\n" );
if ( IS_KIND_OF(child,wxFrame) || IS_KIND_OF(child,wxDialog))
{ {
m_children.Append( child ); m_children.Append( child );

View File

@@ -150,9 +150,9 @@ gtk_myfixed_put (GtkMyFixed *myfixed,
child_info = g_new (GtkMyFixedChild, 1); child_info = g_new (GtkMyFixedChild, 1);
child_info->widget = widget; child_info->widget = widget;
child_info->x = x; child_info->x = x - myfixed->scroll_offset_x;
child_info->y = y; child_info->y = y - myfixed->scroll_offset_y;
gtk_widget_set_parent (widget, GTK_WIDGET (myfixed)); gtk_widget_set_parent (widget, GTK_WIDGET (myfixed));
myfixed->children = g_list_append (myfixed->children, child_info); myfixed->children = g_list_append (myfixed->children, child_info);
@@ -188,8 +188,8 @@ gtk_myfixed_move (GtkMyFixed *myfixed,
if (child->widget == widget) if (child->widget == widget)
{ {
child->x = x; child->x = x - myfixed->scroll_offset_x;
child->y = y; child->y = y - myfixed->scroll_offset_y;
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (myfixed)) if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (myfixed))
gtk_widget_queue_resize (GTK_WIDGET (myfixed)); gtk_widget_queue_resize (GTK_WIDGET (myfixed));
@@ -238,17 +238,20 @@ gtk_myfixed_unmap (GtkWidget *widget)
static void static void
gtk_myfixed_realize (GtkWidget *widget) gtk_myfixed_realize (GtkWidget *widget)
{ {
GtkMyFixed *myfixed;
GdkWindowAttr attributes; GdkWindowAttr attributes;
gint attributes_mask; gint attributes_mask;
g_return_if_fail (widget != NULL); g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_MYFIXED (widget)); g_return_if_fail (GTK_IS_MYFIXED (widget));
myfixed = GTK_MYFIXED (widget);
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
attributes.window_type = GDK_WINDOW_CHILD; attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = widget->allocation.x; attributes.x = widget->allocation.x + myfixed->scroll_offset_x;
attributes.y = widget->allocation.y; attributes.y = widget->allocation.y + myfixed->scroll_offset_x;
attributes.width = 32000; attributes.width = 32000;
attributes.height = 32000; attributes.height = 32000;
attributes.wclass = GDK_INPUT_OUTPUT; attributes.wclass = GDK_INPUT_OUTPUT;

View File

@@ -26,6 +26,8 @@
#include "wx/dnd.h" #include "wx/dnd.h"
#include "wx/mdi.h" #include "wx/mdi.h"
#include "wx/notebook.h" #include "wx/notebook.h"
#include "wx/statusbr.h"
#include "wx/treectrl.h"
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include <math.h> #include <math.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
@@ -52,7 +54,9 @@ void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gd
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
/* /*
printf( "OnExpose from " ); if (IS_KIND_OF(win,wxTreeCtrl))
{
printf( "OnExpose from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
@@ -61,6 +65,7 @@ void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gd
printf( "y: %d \n", gdk_event->area.y ); printf( "y: %d \n", gdk_event->area.y );
printf( "w: %d \n", gdk_event->area.width ); printf( "w: %d \n", gdk_event->area.width );
printf( "h: %d \n", gdk_event->area.height ); printf( "h: %d \n", gdk_event->area.height );
}
*/ */
win->m_updateRegion.Union( gdk_event->area.x, win->m_updateRegion.Union( gdk_event->area.x,
@@ -1319,14 +1324,11 @@ void wxWindow::ScreenToClient( int *x, int *y )
void wxWindow::Centre( int direction ) void wxWindow::Centre( int direction )
{ {
int x = 0;
int y = 0;
GetPosition( &x, &y );
if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame))) if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame)))
{ {
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2; if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2; if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
gtk_widget_set_uposition( m_widget, x, y ); ImplementSetPosition();
} }
else else
{ {
@@ -1335,9 +1337,9 @@ void wxWindow::Centre( int direction )
int p_w = 0; int p_w = 0;
int p_h = 0; int p_h = 0;
m_parent->GetSize( &p_w, &p_h ); m_parent->GetSize( &p_w, &p_h );
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (p_w - m_width) / 2; if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (p_w - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (p_h - m_height) / 2; if (direction & wxVERTICAL == wxVERTICAL) m_y = (p_h - m_height) / 2;
gtk_widget_set_uposition( m_widget, x, y ); ImplementSetPosition();
}; };
} }
}; };
@@ -1433,7 +1435,8 @@ void wxWindow::AddChild( wxWindow *child )
// wxFrame and wxDialog as children aren't placed into the parents // wxFrame and wxDialog as children aren't placed into the parents
if (child->IsKindOf(CLASSINFO(wxFrame)) || child->IsKindOf(CLASSINFO(wxDialog))) if (( IS_KIND_OF(child,wxFrame) || IS_KIND_OF(child,wxDialog) ) &&
(!IS_KIND_OF(child,wxMDIChildFrame)))
{ {
m_children.Append( child ); m_children.Append( child );
@@ -1446,9 +1449,9 @@ void wxWindow::AddChild( wxWindow *child )
// In the case of an wxMDIChildFrame descendant, we use the // In the case of an wxMDIChildFrame descendant, we use the
// client windows's AddChild() // client windows's AddChild()
if (IsKindOf(CLASSINFO(wxMDIParentFrame))) if (IS_KIND_OF(this,wxMDIParentFrame))
{ {
if (child->IsKindOf(CLASSINFO(wxMDIChildFrame))) if (IS_KIND_OF(child,wxMDIChildFrame))
{ {
wxMDIClientWindow *client = ((wxMDIParentFrame*)this)->GetClientWindow(); wxMDIClientWindow *client = ((wxMDIParentFrame*)this)->GetClientWindow();
if (client) if (client)
@@ -1461,7 +1464,7 @@ void wxWindow::AddChild( wxWindow *child )
// wxNotebook is very special, so it has a private AddChild() // wxNotebook is very special, so it has a private AddChild()
if (IsKindOf(CLASSINFO(wxNotebook))) if (IS_KIND_OF(this,wxNotebook))
{ {
wxNotebook *tab = (wxNotebook*)this; wxNotebook *tab = (wxNotebook*)this;
tab->AddChild( child ); tab->AddChild( child );
@@ -1470,7 +1473,7 @@ void wxWindow::AddChild( wxWindow *child )
// wxFrame has a private AddChild // wxFrame has a private AddChild
if (IsKindOf(CLASSINFO(wxFrame))) if (IS_KIND_OF(this,wxFrame))
{ {
wxFrame *frame = (wxFrame*)this; wxFrame *frame = (wxFrame*)this;
frame->AddChild( child ); frame->AddChild( child );
@@ -1480,7 +1483,8 @@ void wxWindow::AddChild( wxWindow *child )
// All the rest // All the rest
m_children.Append( child ); m_children.Append( child );
if (m_wxwindow) gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget, child->m_x, child->m_y ); if (m_wxwindow) gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget,
child->m_x, child->m_y );
gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height ); gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height );
}; };
@@ -1564,9 +1568,9 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
if (rect) if (rect)
gdk_window_clear_area( m_wxwindow->window, gdk_window_clear_area( m_wxwindow->window,
rect->x, rect->x,
rect->y, rect->y,
rect->width, rect->width,
rect->height ); rect->height );
else else
Clear(); Clear();
}; };
@@ -1599,6 +1603,13 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
gdk_rect.y = rect->y; gdk_rect.y = rect->y;
gdk_rect.width = rect->width; gdk_rect.width = rect->width;
gdk_rect.height = rect->height; gdk_rect.height = rect->height;
if (IS_KIND_OF(this,wxTreeCtrl))
{
printf( "x: %d y: %d w: %d h: %d .\n",
gdk_rect.x, gdk_rect.y, gdk_rect.width, gdk_rect.height );
}
if (m_wxwindow) if (m_wxwindow)
gtk_widget_draw( m_wxwindow, &gdk_rect ); gtk_widget_draw( m_wxwindow, &gdk_rect );
else else
@@ -1885,11 +1896,25 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible,
}; };
if (m_wxwindow->window) if (m_wxwindow->window)
{ {
if (orient == wxHORIZONTAL) if (orient == wxHORIZONTAL)
{
/*
m_drawingOffsetX = -16000;
gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY );
*/
gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
else }
else
{
/*
m_drawingOffsetY = -16000;
gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY );
*/
gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" );
}
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
}; };
@@ -1958,13 +1983,26 @@ void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
{ {
if (!m_wxwindow) return; if (!m_wxwindow) return;
m_drawingOffsetX += dx; bool refresh = FALSE;
m_drawingOffsetY += dy;
if ((m_drawingOffsetX == 0) && (m_drawingOffsetY == 0))
{
m_drawingOffsetX = -16000;
m_drawingOffsetY = -16000;
refresh = TRUE;
}
else
{
m_drawingOffsetX += dx;
m_drawingOffsetY += dy;
}
// printf( "X: %d Y: %d \n", (int)m_drawingOffsetX, (int)m_drawingOffsetY ); // printf( "X: %d Y: %d \n", (int)m_drawingOffsetX, (int)m_drawingOffsetY );
gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY ); gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY );
if (refresh) Refresh();
/* /*
The code here is very nifty, but it doesn't work with The code here is very nifty, but it doesn't work with
overlapping windows... overlapping windows...