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

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

View File

@@ -19,6 +19,7 @@
#include "wx/menu.h"
#include "wx/toolbar.h"
#include "wx/statusbr.h"
#include "wx/mdi.h"
#include "wx/gtk/win_gtk.h"
const wxMENU_HEIGHT = 28;
@@ -253,18 +254,18 @@ void wxFrame::GtkOnSize( int x, int y, int width, int height )
main_y += toolbar_height;
main_height -= toolbar_height;
gtk_widget_set_uposition( GTK_WIDGET(m_wxwindow), main_x, main_y );
gtk_widget_set_usize( GTK_WIDGET(m_wxwindow), main_width, main_height );
gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_wxwindow, main_x, main_y );
gtk_widget_set_usize( m_wxwindow, main_width, main_height );
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 );
};
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 );
};
@@ -320,7 +321,9 @@ void wxFrame::AddChild( wxWindow *child )
{
// 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 );

View File

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

View File

@@ -26,6 +26,8 @@
#include "wx/dnd.h"
#include "wx/mdi.h"
#include "wx/notebook.h"
#include "wx/statusbr.h"
#include "wx/treectrl.h"
#include "gdk/gdkkeysyms.h"
#include <math.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;
/*
printf( "OnExpose from " );
if (IS_KIND_OF(win,wxTreeCtrl))
{
printf( "OnExpose from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() );
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( "w: %d \n", gdk_event->area.width );
printf( "h: %d \n", gdk_event->area.height );
}
*/
win->m_updateRegion.Union( gdk_event->area.x,
@@ -1319,14 +1324,11 @@ void wxWindow::ScreenToClient( int *x, int *y )
void wxWindow::Centre( int direction )
{
int x = 0;
int y = 0;
GetPosition( &x, &y );
if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame)))
{
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
gtk_widget_set_uposition( m_widget, x, y );
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
ImplementSetPosition();
}
else
{
@@ -1335,9 +1337,9 @@ void wxWindow::Centre( int direction )
int p_w = 0;
int p_h = 0;
m_parent->GetSize( &p_w, &p_h );
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (p_w - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (p_h - m_height) / 2;
gtk_widget_set_uposition( m_widget, x, y );
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (p_w - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (p_h - m_height) / 2;
ImplementSetPosition();
};
}
};
@@ -1433,7 +1435,8 @@ void wxWindow::AddChild( wxWindow *child )
// 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 );
@@ -1446,9 +1449,9 @@ void wxWindow::AddChild( wxWindow *child )
// In the case of an wxMDIChildFrame descendant, we use the
// 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();
if (client)
@@ -1461,7 +1464,7 @@ void wxWindow::AddChild( wxWindow *child )
// wxNotebook is very special, so it has a private AddChild()
if (IsKindOf(CLASSINFO(wxNotebook)))
if (IS_KIND_OF(this,wxNotebook))
{
wxNotebook *tab = (wxNotebook*)this;
tab->AddChild( child );
@@ -1470,7 +1473,7 @@ void wxWindow::AddChild( wxWindow *child )
// wxFrame has a private AddChild
if (IsKindOf(CLASSINFO(wxFrame)))
if (IS_KIND_OF(this,wxFrame))
{
wxFrame *frame = (wxFrame*)this;
frame->AddChild( child );
@@ -1480,7 +1483,8 @@ void wxWindow::AddChild( wxWindow *child )
// All the rest
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 );
};
@@ -1564,9 +1568,9 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
if (rect)
gdk_window_clear_area( m_wxwindow->window,
rect->x,
rect->y,
rect->width,
rect->height );
rect->y,
rect->width,
rect->height );
else
Clear();
};
@@ -1599,6 +1603,13 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
gdk_rect.y = rect->y;
gdk_rect.width = rect->width;
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)
gtk_widget_draw( m_wxwindow, &gdk_rect );
else
@@ -1885,11 +1896,25 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible,
};
if (m_wxwindow->window)
{
{
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" );
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_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;
m_drawingOffsetX += dx;
m_drawingOffsetY += dy;
bool refresh = FALSE;
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 );
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
overlapping windows...