abstractgtkcontrol.cpp

来自「这是VCF框架的代码」· C++ 代码 · 共 1,333 行 · 第 1/3 页

CPP
1,333
字号
	requisition->height = int( bounds.getHeight() );	AbstractGTKControl::Container *container = GTK_VCF_CONTAINER ( widget );	GList* children = container->children;	AbstractGTKControl::ContainerChild* child = NULL;	GtkRequisition child_requisition;	while ( children ) {		child = ( AbstractGTKControl::ContainerChild* ) children->data;		children = children->next;		if ( GTK_WIDGET_VISIBLE ( child->widget ) ) {			//StringUtils::traceWithArgs( "\tcalling gtk_widget_size_request for widget: %p, name:%s, parent: %p\n",			//							child->widget, child->widget->name, widget );			gtk_widget_size_request ( child->widget, &child_requisition );			/*						if ( child->widget->name == String("VCF::CommandButton") ) {							int i = 0;						}						*/		}	}}void AbstractGTKControl::Container::sizeAllocate( GtkWidget *widget, GtkAllocation *allocation ){	g_return_if_fail ( widget != NULL );	//g_return_if_fail (GTK_IS_VCF_CONTAINER (widget));	g_return_if_fail ( allocation != NULL );	StringUtils::traceWithArgs( "Container::sizeAllocate widget: %p, name:%s\n", widget, widget->name );	AbstractGTKControl::Container *container;	//printf( "gtk_absolute_container_size_allocate: %p\n", container );	Rect bounds = AbstractGTKControl::Container::getBounds( widget );	allocation->x = int( bounds.left_ ) ;	allocation->y = int( bounds.top_ );	allocation->width = int( bounds.getWidth() );	allocation->height = int( bounds.getHeight() );	widget->allocation = *allocation;	if ( GTK_WIDGET_REALIZED ( widget ) ) {		gdk_window_move_resize ( widget->window,		                         allocation->x, allocation->y,		                         allocation->width, allocation->height );	}	if ( GTK_IS_VCF_CONTAINER ( widget ) ) {		container = GTK_VCF_CONTAINER ( widget );		GList* children = container->children;		AbstractGTKControl::ContainerChild* child = NULL;		GtkRequisition child_requisition;		GtkAllocation child_allocation;		while ( children ) {			child = ( AbstractGTKControl::ContainerChild* ) children->data;			children = children->next;			if ( GTK_WIDGET_VISIBLE ( widget ) ) {				bounds = AbstractGTKControl::Container::getBounds( child->widget );				//StringUtils::traceWithArgs( "\tcalling gtk_widget_get_child_requisition for widget: %p, name:%s, parent: %p\n",				//						child->widget, child->widget->name, widget );				gtk_widget_get_child_requisition ( child->widget, &child_requisition );				child_allocation.x = int( bounds.left_ ); //child->x;				child_allocation.y = int( bounds.top_ ); //child->y;				if ( GTK_WIDGET_NO_WINDOW ( widget ) ) {					child_allocation.x += widget->allocation.x;					child_allocation.y += widget->allocation.y;				}				child_allocation.width = int( bounds.getWidth() ); //child->width;// child_requisition.width;				child_allocation.height = int( bounds.getHeight() ); // child->height;//child_requisition.height;				StringUtils::traceWithArgs( "\tcalling gtk_widget_size_allocate for widget: %p, name:%s, parent: %p\n\t\tx:%d, y:%d, w:%d, h:%d\n",				                            child->widget, child->widget->name, widget,				                            child->x,				                            child->y,				                            child->width,				                            child->height );				gtk_widget_size_allocate ( child->widget, &child_allocation );				/*								if ( child->widget->name == String("VCF::CommandButton") ) {									int i = 0;								}								*/			}		}	}}gboolean AbstractGTKControl::Container::expose( GtkWidget *widget, GdkEventExpose *event ){	g_return_val_if_fail ( GTK_IS_VCF_CONTAINER ( widget ), FALSE );	g_return_val_if_fail ( event != NULL, FALSE );	if ( GTK_WIDGET_DRAWABLE ( widget ) ) {		//StringUtils::traceWithArgs( "AbstractGTKControl::Container::expose, widget: %p, name: %s\n",		//								widget, widget->name );		AbstractGTKControl::Container * absContainer = GTK_VCF_CONTAINER ( widget );		GList *children = absContainer->children;		AbstractGTKControl::ContainerChild* childObj = NULL;		while ( children ) {			childObj = ( AbstractGTKControl::ContainerChild* ) children->data;			if ( GTK_IS_WIDGET ( childObj->widget ) ) {				g_assert ( childObj->widget->parent == widget );				if ( GTK_WIDGET_DRAWABLE ( childObj->widget ) &&				        GTK_WIDGET_NO_WINDOW ( childObj->widget ) &&				        ( childObj->widget->window == event->window ) ) {					GdkEvent * child_event;					child_event = gdk_event_new ( GDK_EXPOSE );					child_event->expose = *event;					g_object_ref ( child_event->expose.window );					child_event->expose.region =					    gtk_widget_region_intersect ( childObj->widget, event->region );					if ( !gdk_region_empty ( child_event->expose.region ) ) {						gdk_region_get_clipbox ( child_event->expose.region, &child_event->expose.area );						//StringUtils::traceWithArgs( "gtk_widget_send_expose( %p - %s )\n",						//								childObj->widget, childObj->widget->name );						gtk_widget_send_expose ( childObj->widget, child_event );					}					gdk_event_free ( child_event );				}			}			children = children->next;		}	}	return FALSE;}void AbstractGTKControl::Container::adjustmentChanged( GtkAdjustment *adjustment, gpointer data ){}void AbstractGTKControl::Container::adjustmentValueChanged( GtkAdjustment *adjustment, gpointer data ){}void AbstractGTKControl::Container::add	( GtkContainer* container, GtkWidget* widget ){	//printf( "gtk_absolute_container_add\n" );	g_return_if_fail ( container != NULL );	g_return_if_fail ( GTK_IS_VCF_CONTAINER ( container ) );	g_return_if_fail ( widget != NULL );	//StringUtils::traceWithArgs( "Container::add container: %p, widget: %p, name:%s\n",	//							container, widget, widget->name );	AbstractGTKControl::Container *absContainer;	absContainer = GTK_VCF_CONTAINER ( container );	AbstractGTKControl::ContainerChild* newChild = g_new( AbstractGTKControl::ContainerChild, 1 );	newChild->widget = widget;	newChild->height = 1;	newChild->width = 1;	newChild->x = 0;	newChild->y = 0;	GtkRequisition child_requisition;	gtk_widget_size_request ( newChild->widget, &child_requisition );	absContainer->children = g_list_append( absContainer->children, newChild );	gtk_widget_set_parent ( widget, GTK_WIDGET ( container ) );}void AbstractGTKControl::Container::remove	( GtkContainer* container, GtkWidget* widget ){	//printf( "gtk_absolute_container_remove\n" );	g_return_if_fail ( container != NULL );	g_return_if_fail ( GTK_IS_VCF_CONTAINER ( container ) );	g_return_if_fail ( widget != NULL );	AbstractGTKControl::Container *absContainer;	absContainer = GTK_VCF_CONTAINER ( container );	GList *children = absContainer->children;	AbstractGTKControl::ContainerChild* child = NULL;	while ( children ) {		child = ( AbstractGTKControl::ContainerChild* ) children->data;		if ( child->widget == widget ) {			gboolean was_visible = GTK_WIDGET_VISIBLE ( widget );			gtk_widget_unparent ( widget );			absContainer->children = g_list_remove_link ( absContainer->children, children );			g_list_free ( children );			//g_free (child);			if ( was_visible && GTK_WIDGET_VISIBLE ( container ) ) {				gtk_widget_queue_resize ( GTK_WIDGET ( container ) );			}			break;		}		children = children->next;	}}void AbstractGTKControl::Container::forall( GtkContainer* container,                                            gboolean include_internals,                                            GtkCallback callback,                                            gpointer callback_data ){	//printf( "gtk_absolute_container_forall\n" );	g_return_if_fail ( container != NULL );	g_return_if_fail ( GTK_IS_VCF_CONTAINER ( container ) );	g_return_if_fail ( callback != NULL );	AbstractGTKControl::Container *absContainer;	absContainer = GTK_VCF_CONTAINER ( container );	GList *children = absContainer->children;	AbstractGTKControl::ContainerChild* child = NULL;	while ( children ) {		child = ( AbstractGTKControl::ContainerChild* ) children->data;		children = children->next;		( * callback ) ( child->widget, callback_data );	}}GType AbstractGTKControl::Container::getChildType( GtkContainer* container ){	return GTK_TYPE_WIDGET;}void AbstractGTKControl::ContainerClass::init ( ContainerClass *clazz ){	GtkWidgetClass * widget_class;	GtkContainerClass *container_class;	GtkObjectClass *object_class;	object_class = ( GtkObjectClass* ) clazz;	widget_class = ( GtkWidgetClass* ) clazz;	container_class = ( GtkContainerClass* ) clazz;	internalVCFParentClass = ( GtkContainerClass* ) gtk_type_class ( gtk_container_get_type () );	object_class->destroy = AbstractGTKControl::Container::destroy;	widget_class->realize = AbstractGTKControl::Container::realize;	widget_class->expose_event = AbstractGTKControl::Container::expose;	widget_class->size_request = AbstractGTKControl::Container::sizeRequest;	widget_class->size_allocate = AbstractGTKControl::Container::sizeAllocate;	container_class->add	= AbstractGTKControl::Container::add		  ;	container_class->remove	= AbstractGTKControl::Container::remove		  ;	container_class->forall = AbstractGTKControl::Container::forall;	container_class->child_type = AbstractGTKControl::Container::getChildType;}/***CVS Log info*$Log$*Revision 1.3  2005/04/05 23:44:22  jabelardo*a lot of fixes to compile on linux, it does not run but at least it compile**Revision 1.2  2004/08/07 02:49:05  ddiego*merged in the devmain-0-6-5 branch to stable**Revision 1.1.2.3  2004/04/29 03:43:12  marcelloptr*reformatting of source files: macros and csvlog and copyright sections**Revision 1.1.2.2  2004/04/28 18:42:25  ddiego*migrating over changes for unicode strings.*This contains fixes for the linux port and changes to the Makefiles**Revision 1.1.2.1  2004/04/28 00:28:12  ddiego*migration towards new directory structure**Revision 1.8  2004/04/03 15:48:46  ddiego*Merged over code from the 0-6-3 branch.**Revision 1.4.2.3  2004/03/21 00:39:23  ddiego*merged vc7.1 changes into dev branch**Revision 1.4.2.2  2004/02/16 05:34:04  ddiego*updated linux makefiles as a result of new locale support - pushed in stubs for locale peer impl, but no functionality at this point**Revision 1.4.2.1  2004/01/11 19:57:54  ddiego*implemented the following tasks:*79267	Change Class class to NOT inherit from Object*79268	Change Property class to NOT inherit from Object*79269	Change ClassRegistry class to NOT inherit from Object*79270	Change Method class to NOT inherit from Object*91983	Add a Field class for rtti*plus created a new include/rtti and src/rtti directories and moved the*various rtti related code to the appropriate directories**Revision 1.4  2003/12/18 05:16:01  ddiego*merge from devmain-0-6-2 branch into the stable branch**Revision 1.3.2.2  2003/10/02 04:50:52  ddiego*changes to ensure the code compiles on linux. made a bunch of updates to*the makefiles**Revision 1.3.2.1  2003/08/25 03:14:01  ddiego*adjusted the gtk peers to account for the new toolkit method names**Revision 1.3  2003/08/09 02:56:45  ddiego*merge over from the devmain-0-6-1 branch*Changes*Features:*-Added additional implementation to better support the MVC architecture in*the VCF**-Added a Document/View architecure that is similar to MFC's or NextSteps's*Doc/View architectures**-Integrated the Anti Grain Graphics library into the GraphicsKit. There is*now basic support for it in terms of drawing vector shapes*(fills and strokes). Image support will come in the next release**-Added several documented graphics tutorials**Bugfixes:**[ 775744 ] wrong buttons on a dialog*[ 585239 ] Painting weirdness in a modal dialog ?*[ 585238 ] Modal dialog which makes a modal Dialog*[ 509004 ] Opening a modal Dialog causes flicker*[ 524878 ] onDropped not called for MLTcontrol**Plus an issue with some focus and getting the right popup window to activate*has also been fixed**Revision 1.2.2.6  2003/07/14 22:52:53  ddiego*added further GTK support. Fixed some sevent handling issues. Added the*peer for the CommandButton, and basic text widget support (both multiline and*single line) and the file open common dialog peer as well.**Revision 1.2.2.5  2003/07/13 03:45:11  ddiego*Added further fixes for the GTK port. Now have the event handling working*correctly, and fixed an issue with too many repaint messages being sent*which caused 100% CPU utilization.**Revision 1.2.2.4  2003/07/10 04:55:16  ddiego*added more stuff to GTK port - fixed some issues with events, and*added support for posting events, and the stubs for a ButtonPeer**Revision 1.2.2.3  2003/07/09 03:53:18  ddiego*some fixes to gtk port**Revision 1.2.2.2  2003/06/01 16:43:59  ddiego*further GTK support added**Revision 1.2.2.1  2003/05/30 04:13:11  ddiego*added the commandLine class*changed the intialization functions for teh FoundationKit, GraphicsKit, and*ApplicationKit to take command line parameters*FoundationKit now allows you to retreive the commandline (it's stored)*start up has changed from appMain() to main()*added a custom GTK widget class for use in the various GTK peers - this will*allow us to specify absolute positioning and let the VCF handle layout*issues*Miscellaneous clean in various interfaces*removed the Rect, Point, and Size classes from the FoundationKit*and moved them to the GraphicsKit**Revision 1.2  2003/05/17 20:37:26  ddiego*this is the checkin for the 0.6.1 release - represents the merge over from*the devmain-0-6-0 branch plus a few minor bug fixes**Revision 1.1.2.4  2003/05/13 03:57:13  ddiego*cleaned up the GraphicsKit, got rid of some old crap files, cleaned*up the ContextPeer so that tehre are fewer methods to implement, and*moved the repetitive fillPath and strokePath code that was copied into*all the context peers back into the GraphicsContext where it belongs**Revision 1.1.2.3  2003/04/23 03:42:54  ddiego*further gtk dev got basic eventing code in place**Revision 1.1.2.2  2003/04/19 03:31:15  ddiego*basic code in place for gtk port for ApplicationKit - needs to be tested in*linux**Revision 1.1.2.1  2003/04/17 04:29:50  ddiego*updated scintilla, added gtk support for the application kit, with stubs*for the basic peers.**/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?