⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 buttonbox.c

📁 linux下的E_MAIL客户端源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/* *  $Id: ButtonBox.c,v 1.4 2000/05/07 12:26:10 fnevgeny Exp $ *   *  Copyright (c) 1994 HAL Computer Systems International, Ltd. *  *          HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. *                  1315 Dell Avenue *                  Campbell, CA  95008 * * Author: Greg Hilton * Contributors: Tom Lang, Frank Bieser, and others * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * http://www.gnu.org/copyleft/gpl.html * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */#include <config.h>#include <stdio.h>#include "ButtonBoxP.h"/********    Static Function Declarations    ********/static void		ChangeManaged(Widget);static void		ClassInitialize(void);static void		ClassPartInitialize(WidgetClass);static void		ConstraintInitialize(Widget, Widget, ArgList,					     Cardinal*);static Boolean		ConstraintSetValues(Widget, Widget, Widget, ArgList,					    Cardinal*);static void		DeleteChild(Widget);static void		Destroy(Widget);static void		HandleExpose(Widget, XEvent*, Region);static XtGeometryResult GeometryManager(Widget, XtWidgetGeometry*,					XtWidgetGeometry*);static void		GetCellSizes(Widget, int, int, Dimension*, Dimension*);static void		GetChildSize(Widget);static void		GetPreferredSize(Widget,Dimension*,Dimension*);static void		Initialize(Widget, Widget, ArgList, Cardinal*);static void		InsertChild(Widget);static int		ManagedChildCount(Widget);static void		PlaceChildren(Widget, Dimension, Dimension);static XtGeometryResult	QueryGeometry(Widget, XtWidgetGeometry*,				      XtWidgetGeometry*);static void		Refresh(Widget);static void		Resize(Widget);static Boolean		SetValues(Widget, Widget, Widget, ArgList, Cardinal*);static void		SortChildren(Widget);static Boolean		TrySize(Widget, int, int, Dimension*, Dimension*);/********    End Static Function Declarations    ********//*  Resource definitions for ButtonBox */static XmSyntheticResource syn_resources[] ={	{	XmNmarginWidth,		sizeof (Dimension),		XtOffsetOf( struct _ButtonBoxRec, bbox.marginWd),		_XmFromHorizontalPixels,		_XmToHorizontalPixels	},	{	XmNmarginHeight,		sizeof (Dimension),		XtOffsetOf( struct _ButtonBoxRec, bbox.marginHt),		_XmFromVerticalPixels,		_XmToVerticalPixels	},};static XtResource resources[] ={	{	XmNmarginWidth,		XmCMarginWidth, XmRHorizontalDimension, sizeof (Dimension),		XtOffsetOf(ButtonBoxRec, bbox.marginWd),		XmRImmediate, (XtPointer)3	},	{	XmNmarginHeight,		XmCMarginHeight, XmRVerticalDimension, sizeof (Dimension),		XtOffsetOf(ButtonBoxRec, bbox.marginHt),		XmRImmediate, (XtPointer)3	},	{	XmNresizeCallback,		XmCCallback, XmRCallback, sizeof (XtCallbackList),		XtOffsetOf(ButtonBoxRec, bbox.resizeCallback),		XmRImmediate, (XtPointer)NULL	},	{	XmNresizeWidth,		XmCResizeWidth, XmRBoolean, sizeof(Boolean),		XtOffsetOf(ButtonBoxRec, bbox.resizeWidth),		XmRImmediate, (XtPointer)True	},	{	XmNresizeHeight,		XmCResizeHeight, XmRBoolean, sizeof(Boolean),		XtOffsetOf(ButtonBoxRec, bbox.resizeHeight),		XmRImmediate, (XtPointer)True	},	{	BbNrowAlignment,		BbCRowAlignment, XmRAlignment, sizeof(unsigned char),		XtOffsetOf(ButtonBoxRec, bbox.rowAlignment),		XmRImmediate, (XtPointer)XmALIGNMENT_BEGINNING	},	{	BbNcolAlignment,		BbCColAlignment, XmRAlignment, sizeof(unsigned char),		XtOffsetOf(ButtonBoxRec, bbox.colAlignment),		XmRImmediate, (XtPointer)XmALIGNMENT_CENTER	},	{	XmNorientation,		XmCOrientation, XmROrientation, sizeof(unsigned char),		XtOffsetOf(ButtonBoxRec, bbox.orient),		XmRImmediate, (XtPointer)XmHORIZONTAL	},	{	BbNrowSpacing,		BbCRowSpacing, XmRDimension, sizeof(Dimension),		XtOffsetOf(ButtonBoxRec, bbox.rowSpacing),		XmRImmediate, (XtPointer)3	},	{	BbNcolSpacing,		BbCColSpacing, XmRDimension, sizeof(Dimension),		XtOffsetOf(ButtonBoxRec, bbox.colSpacing),		XmRImmediate, (XtPointer)3	},	{	BbNuniformRows,		BbCUniformRows, XmRBoolean, sizeof(Boolean),		XtOffsetOf(ButtonBoxRec, bbox.uniformRows),		XmRImmediate, (XtPointer)False	},	{	BbNuniformCols,		BbCUniformCols, XmRBoolean, sizeof(Boolean),		XtOffsetOf(ButtonBoxRec, bbox.uniformCols),		XmRImmediate, (XtPointer)False	},};static XtResource constraint_resources[] = {    {       XmNpositionIndex,       XmCPositionIndex,       XmRShort,       sizeof(short),       XtOffsetOf(ButtonBoxConstraintRec, bbox.posIndex),       XmRImmediate,       (XtPointer) XmLAST_POSITION    },};/**************************************************************** * * Full class record constant * ****************************************************************/static XmBaseClassExtRec buttonBoxBaseClassExtRec = {    NULL,				/* Next extension	*/    NULLQUARK,				/* record type XmQmotif */    XmBaseClassExtVersion,		/* version		*/    sizeof(XmBaseClassExtRec),		/* size			*/    NULL,				/* InitializePrehook	*/    XmInheritSetValuesPrehook,		/* SetValuesPrehook	*/    NULL,				/* InitializePosthook	*/    XmInheritSetValuesPosthook,		/* SetValuesPosthook	*/    XmInheritClass,			/* secondaryObjectClass	*/    XmInheritSecObjectCreate,		/* secondaryCreate	*/    XmInheritGetSecResData,		/* getSecRes data	*/    { 0 },				/* fastSubclass flags	*/    XmInheritGetValuesPrehook,		/* getValuesPrehook	*/    XmInheritGetValuesPosthook,		/* getValuesPosthook	*/    NULL,                               /* classPartInitPrehook */    NULL,                               /* classPartInitPosthook*/    NULL,                               /* ext_resources        */    NULL,                               /* compiled_ext_resources*/    0,                                  /* num_ext_resources    */    FALSE,                              /* use_sub_resources    */    NULL,				/* widgetNavigable      */    XmInheritFocusChange		/* focusChange          */};externaldef(xmbuttonboxclassrec) ButtonBoxClassRec buttonBoxClassRec ={   {			/* core_class fields      */      (WidgetClass) &xmManagerClassRec,		/* superclass         */      "ButtonBox",				/* class_name         */      sizeof(ButtonBoxRec),			/* widget_size        */      ClassInitialize,	        		/* class_initialize   */      ClassPartInitialize,			/* class_part_init    */      FALSE,					/* class_inited       */      Initialize,       			/* initialize         */      NULL,					/* initialize_hook    */      XtInheritRealize,				/* realize            */      NULL,					/* actions	      */      0,					/* num_actions	      */      resources,				/* resources          */      XtNumber(resources),			/* num_resources      */      NULLQUARK,				/* xrm_class          */      TRUE,					/* compress_motion    */      XtExposeCompressMaximal | XtExposeGraphicsExposeMerged,      						/* compress_exposure  */      FALSE,					/* compress_enterlv   */      FALSE,					/* visible_interest   */      Destroy,			                /* destroy            */      Resize,           			/* resize             */      HandleExpose,	        		/* expose             */      SetValues,                		/* set_values         */      NULL,					/* set_values_hook    */      XtInheritSetValuesAlmost,	        	/* set_values_almost  */      NULL,					/* get_values_hook    */      NULL,					/* accept_focus       */      XtVersion,				/* version            */      NULL,					/* callback_private   */      NULL,					/* tm_table           */      QueryGeometry,                    	/* query_geometry     */      NULL,             	                /* display_accelerator*/      (XtPointer)&buttonBoxBaseClassExtRec,	/* extension          */   },   {		/* composite_class fields */      GeometryManager,    	                /* geometry_manager   */      ChangeManaged,	                	/* change_managed     */      InsertChild,				/* insert_child       */      DeleteChild,		     		/* delete_child       */      NULL,                                     /* extension          */   },   {		/* constraint_class fields */      constraint_resources,			/* resource list        */      XtNumber(constraint_resources),		/* num resources        */      sizeof(ButtonBoxConstraintRec),		/* constraint size      */      ConstraintInitialize,			/* init proc            */      NULL,					/* destroy proc         */      ConstraintSetValues,			/* set values proc      */      NULL,                                     /* extension            */   },   {		/* manager_class fields */      XtInheritTranslations,			/* translations           */      syn_resources,				/* syn_resources      	  */      XtNumber (syn_resources),			/* num_get_resources 	  */      NULL,					/* syn_cont_resources     */      0,					/* num_get_cont_resources */      XmInheritParentProcess,                   /* parent_process         */      NULL,					/* extension           */   },   {		/* ButtonBox class */      (XtPointer) NULL,				/* extension pointer */   }};externaldef(xmbuttonboxwidgetclass) WidgetClass buttonBoxWidgetClass					= (WidgetClass)&buttonBoxClassRec;extern int	debuglev;/*--------------------------------------------------------------- * Initialize class */static voidClassInitialize(	void){  buttonBoxBaseClassExtRec.record_type = XmQmotif;}/*--------------------------------------------------------------- * Initialize class part */static voidClassPartInitialize(        WidgetClass w_class){/*   _XmFastSubclassInit(w_class, XmROW_COLUMN_BIT); */   return;}/*--------------------------------------------------------------- * Initialize widget */static voidInitialize(        Widget		wreq,        Widget		wnew,        ArgList		argv,        Cardinal	*argc){   if ( !XtWidth(wreq)  ) XtWidth(wnew)  = 16;   if ( !XtHeight(wreq) ) XtHeight(wnew) = 16;   if ( BB_rowAlignment(wreq) != XmALIGNMENT_BEGINNING &&	BB_rowAlignment(wreq) != XmALIGNMENT_CENTER &&	BB_rowAlignment(wreq) != XmALIGNMENT_END )      BB_rowAlignment(wreq) = XmALIGNMENT_BEGINNING;   if ( BB_colAlignment(wreq) != XmALIGNMENT_BEGINNING &&	BB_colAlignment(wreq) != XmALIGNMENT_CENTER &&	BB_colAlignment(wreq) != XmALIGNMENT_END )      BB_colAlignment(wreq) = XmALIGNMENT_CENTER;   if ( BB_orient(wreq) != XmVERTICAL &&	BB_orient(wreq) != XmHORIZONTAL )      BB_orient(wreq) = XmHORIZONTAL;   BB_lastWd(wnew)      = 0;   BB_lastHt(wnew)      = 0;   BB_exposed(wnew)     = False;   BB_resizeTimer(wnew) = 0;} /* End Initialize *//*--------------------------------------------------------------- * Destroy widget */static voidDestroy(        Widget	bbw){   if ( BB_resizeTimer(bbw) )      XtRemoveTimeOut(BB_resizeTimer(bbw));   XtRemoveAllCallbacks(bbw, XmNresizeCallback);} /* End Destroy */#if 0/*--------------------------------------------------------------- * Function to realize widget */static voidRealize(	Widget			bbw,	XtValueMask		*mask,	XSetWindowAttributes	*attr){/* * Don't propagate events for row column widgets and set bit gravity to NW */   (*mask) |= CWDontPropagate | CWBitGravity;   attr->bit_gravity = NorthWestGravity;   attr->do_not_propagate_mask = ButtonPressMask	|   				 ButtonReleaseMask	|				 KeyPressMask		|				 KeyReleaseMask		|				 PointerMotionMask;   XtCreateWindow(bbw, InputOutput, CopyFromParent, *mask, attr);} /* End Realize */#endif/*----------------------------------------------------------------------- * Function to add a child widget */static voidInsertChild(        Widget	w){   Widget	bbw = XtParent(w);/* * Use composite class insert proc to do all the dirty work */   (*((XmManagerWidgetClass)xmManagerWidgetClass)->composite_class.insert_child)   									(w);/* * Set the correct posIndex values for everybody if the new child has been *    inserted in the list instead of put at the end. */   if ( BB_posIndex(w) == XmLAST_POSITION || BB_posIndex(w) < 1 )      BB_posIndex(w) = BB_numChildren(bbw);#if 0/* * For every child with a position >= to the new position, bump up the position */   if ( BB_posIndex(w) < BB_numChildren(bbw) ) {      Widget	*p    = BB_children(bbw);      int	count = BB_numChildren(bbw);      int	i;      for (i=0; i<count; i++) {	 if ( *p != w && BB_posIndex(*p) >= BB_posIndex(w) )	    BB_posIndex(*p) = BB_posIndex(*p) + 1;      }      SortChildren(bbw);   }#endif} /* End InsertChild *//*----------------------------------------------------------------------- * Function to delete a child widget */static voidDeleteChild(        Widget	w){   Widget bbw = XtParent(w);/* * Use manager class delete proc to do all the dirty work */   (*((XmManagerWidgetClass)xmManagerWidgetClass)->composite_class.delete_child)   									(w);/* * Set the correct positionIndex values for everybody if the child was not *    deleted from the end of the list.  XmManager delete_child has already *    decremented num_chidren! */   if ( BB_posIndex(w) <= BB_numChildren(bbw) ) {      int	i;      int	count = BB_numChildren(bbw);      Widget	*p    = BB_children(bbw);      for (i=0; i<count; i++) {	 BB_posIndex(*p) = i+1;	 p++;      }   }} /* End DeleteChild *//*--------------------------------------------------------------- * Handle change in children */static void

⌨️ 快捷键说明

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