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

📄 rowcolc.c

📁 linux下的E_MAIL客户端源码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* * $Id: RowColC.C,v 1.2 2000/05/07 12:26:11 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 "RowColC.h"#include "HalAppC.h"#include "rsrc.h"#include "RowColP.h"#include <X11/IntrinsicP.h>#include <X11/CoreP.h>#include <Xm/PrimitiveP.h>extern int	debug1, debug2;//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//----------------------------------------------------------------------------// RowC constructor//RowC::RowC(RowColC *parent) : RowOrColC(parent){   RowColPart	*rc = GetRowColPart(par->rcw);   alignment = rc->rowAlignment;   adjust    = rc->rowAdjust;   resizeOk  = rc->rowResizeOk;}//----------------------------------------------------------------------------// Method to determine the preferred height of this row//voidRowC::CalcPrefSize(){   unsigned	count = childList.size();   prefSize = 0;   for (int i=0; i<count; i++) {      RowColChildC	*child = childList[i];      if ( !child->w || !child->col->visible ) continue;      int	size = child->PrefHeight();      if ( size > prefSize ) prefSize = size;   }//// Add the title column member of this row if present//   if ( par->titleCol && par->titleCol->visible ) {      int		index = par->rowList.indexOf(this);      if ( index < par->titleCol->childList.size() ) {	 RowColChildC	*child = par->titleCol->childList[index];	 if ( child->w ) {	    int	size = child->PrefHeight();	    if ( size > prefSize ) prefSize = size;	 }      }   } // End if the title column is visible} // End RowC CalcPrefSize//----------------------------------------------------------------------------// Method to set heights of children//voidRowC::SizeChildren(){   unsigned	count = childList.size();   for (int i=0; i<count; i++) {      RowColChildC	*child = childList[i];      if      ( adjust == RcADJUST_NONE  ) child->curHt = child->PrefHeight();      else if ( adjust == RcADJUST_EQUAL ) child->curHt = prefSize;      else				   child->curHt = realSize;   }//// Size the title column member of this row if present//   if ( par->titleCol ) {      int		index = par->rowList.indexOf(this);      if ( index < par->titleCol->childList.size() ) {	 RowColChildC	*child = par->titleCol->childList[index];	 if      ( adjust == RcADJUST_NONE ) child->curHt = child->PrefHeight();	 else if ( adjust == RcADJUST_EQUAL) child->curHt = prefSize;	 else				     child->curHt = realSize;      }   }} // End RowC SizeChildren//----------------------------------------------------------------------------// Method to set y positions of children//voidRowC::PlaceChildren(){   unsigned	count = childList.size();   for (int i=0; i<count; i++) {      RowColChildC	*child = childList[i];      child->curY = pos;      if ( alignment == XmALIGNMENT_CENTER )	 child->curY += (Position)((int)(realSize - child->curHt) / (int)2);      else if ( alignment == XmALIGNMENT_END )	 child->curY += (Position)(realSize - child->curHt);   }//// Place the title column member of this row if present//   if ( par->titleCol ) {      int		index = par->rowList.indexOf(this);      if ( index < par->titleCol->childList.size() ) {	 RowColChildC	*child = par->titleCol->childList[index];	 child->curY = pos;	 if ( alignment == XmALIGNMENT_CENTER )	    child->curY += (Position)((int)(realSize - child->curHt)/(int)2);	 else if ( alignment == XmALIGNMENT_END )	    child->curY += (Position)(realSize - child->curHt);      }   }} // End RowC PlaceChildren//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//----------------------------------------------------------------------------// ColC constructor//ColC::ColC(RowColC *par) : RowOrColC(par){   RowColPart	*rc = GetRowColPart(par->rcw);   alignment = rc->colAlignment;   adjust    = rc->colAdjust;   resizeOk  = rc->colResizeOk;}//----------------------------------------------------------------------------// Method to determine the preferred width of this column//voidColC::CalcPrefSize(){   unsigned	count = childList.size();   prefSize = 0;   for (int i=0; i<count; i++) {      RowColChildC	*child = childList[i];      if ( !child->w || !child->row->visible ) continue;      int	size = child->PrefWidth();      if ( size > prefSize ) prefSize = size;   }//// Add the title row member of this column if present//   if ( par->titleRow && par->titleRow->visible ) {      int		index = par->colList.indexOf(this);      if ( index < par->titleRow->childList.size() ) {	 RowColChildC	*child = par->titleRow->childList[index];	 if ( child->w ) {	    int	size = child->PrefWidth();	    if ( size > prefSize ) prefSize = size;	 }      }   } // End if the title row is visible} // End ColC CalcPrefSize//----------------------------------------------------------------------------// Method to set widths of children//voidColC::SizeChildren(){   unsigned	count = childList.size();   for (int i=0; i<count; i++) {      RowColChildC	*child = childList[i];      if      ( adjust == RcADJUST_NONE  ) child->curWd = child->PrefWidth();      else if ( adjust == RcADJUST_EQUAL ) child->curWd = prefSize;      else				   child->curWd = realSize;   }//// Size the title row member of this column if present//   if ( par->titleRow ) {      int		index = par->colList.indexOf(this);      if ( index < par->titleRow->childList.size() ) {	 RowColChildC	*child = par->titleRow->childList[index];	 if      ( adjust == RcADJUST_NONE  ) child->curWd = child->PrefWidth();	 else if ( adjust == RcADJUST_EQUAL ) child->curWd = prefSize;	 else				      child->curWd = realSize;      }   }} // End ColC SizeChildren//----------------------------------------------------------------------------// Method to set x positions of children//voidColC::PlaceChildren(){   unsigned	count = childList.size();   for (int i=0; i<count; i++) {      RowColChildC	*child = childList[i];      child->curX = pos;      if ( alignment == XmALIGNMENT_CENTER )	 child->curX += (Position)((int)(realSize - child->curWd) / (int)2);      else if ( alignment == XmALIGNMENT_END )	 child->curX += (Position)(realSize - child->curWd);   }//// Place the title row member of this column if present//   if ( par->titleRow ) {      int		index = par->colList.indexOf(this);      if ( index < par->titleRow->childList.size() ) {	 RowColChildC	*child = par->titleRow->childList[index];	 child->curX = pos;	 if ( alignment == XmALIGNMENT_CENTER )	    child->curX += (Position)((int)(realSize - child->curWd) / (int)2);	 else if ( alignment == XmALIGNMENT_END )	    child->curX += (Position)(realSize - child->curWd);      }   }} // End ColC PlaceChildren//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%//----------------------------------------------------------------------------// RowColC constructor//RowColC::RowColC(Widget parent, const char *name, ArgList argv, Cardinal argc){//// Create drawing area//   rcw = CreateRowCol(parent, (char *)name, argv, argc);   RowColPart	*rc = GetRowColPart(rcw);//// Add callbacks//   XtAddCallback(rcw, XmNexposeCallback, (XtCallbackProc)HandleExpose,		 (XtPointer)this);   XtAddCallback(rcw, XmNresizeCallback, (XtCallbackProc)HandleResize,		 (XtPointer)this);   XtAddCallback(rcw, RcNgeometryCallback,   		 (XtCallbackProc)HandleGeometryRequest, (XtPointer)this);   XtAddCallback(rcw, RcNchildGeometryCallback,   		 (XtCallbackProc)HandleChildResize, (XtPointer)this);   XtAddEventHandler(rcw, StructureNotifyMask, False,		     (XtEventHandler)HandleMapChange, (XtPointer)this);   childList.AllowDuplicates(FALSE);   rowList.AllowDuplicates(FALSE);   colList.AllowDuplicates(FALSE);   titleColWidget = NULL;   titleRowWidget = NULL;   titleCol       = NULL;   titleRow       = NULL;   newWd        = 0;   newHt        = 0;   exposed      = False;   deferred     = False;   changed      = False;   deferCount   = 0;   selfResize   = False;   inResize     = False;   refreshTimer = (XtIntervalId)NULL;//// Create initial rows or columns//   if ( rc->orient == RcROW_MAJOR ) {      for (int i=0; i<rc->colCount; i++) {	 ColC	*col = new ColC(this);	 colList.add(col);      }   } else {      for (int i=0; i<rc->rowCount; i++) {	 RowC	*row = new RowC(this);	 rowList.add(row);      }   }} // End RowColC constructor//----------------------------------------------------------------------------// RowColC destructor//RowColC::~RowColC(){   Defer(True);	// Do this so it won't try to refresh   Reset();}//----------------------------------------------------------------------------// Method to add a single child to the list.  If "child" is NULL, it means//    the user wants an empty cell.//voidRowColC::AddChild(Widget wp){   if ( wp && childList.includes(wp) ) return;   Defer(True);//// Add child//   RowColChildC	*child = new RowColChildC(wp);   childList.add(child);   RowColPart	*rc = GetRowColPart(rcw);   if ( rc->orient == RcROW_MAJOR ) {//// See if this child can be added to the last row//      RowC	*row = NULL;      if ( rowList.size() > 0 ) row = (RowC*)rowList[rowList.size()-1];      if ( !row || row->childList.size() == rc->colCount ) {	 row = new RowC(this);	 rowList.add(row);	 rc->rowCount++;      }      row->AddChild(child);      child->row = row;//// Also add this one to the appropriate column//      ColC	*col = NULL;      int	colNum = row->childList.size() - 1;      if ( colNum < colList.size() ) {	 col = (ColC*)colList[colNum];	 col->AddChild(child);	 child->col = col;      }   } // End if ROW_MAJOR   else {//// See if this child can be added to the last column//      ColC	*col = NULL;      if ( colList.size() > 0 ) col = (ColC*)colList[colList.size()-1];      if ( !col || col->childList.size() == rc->rowCount ) {	 col = new ColC(this);	 colList.add(col);	 rc->colCount++;      }      col->AddChild(child);      child->col = col;//// Also add this one to the appropriate row//      RowC	*row = NULL;      int	rowNum = col->childList.size() - 1;      if ( rowNum < rowList.size() ) {	 row = (RowC*)rowList[rowNum];	 row->AddChild(child);	 child->row = row;      }   } // End if COL_MAJOR   Defer(False);} // End RowColC AddChild//----------------------------------------------------------------------------// Methods to add several children to the list//voidRowColC::AddChildren(WidgetListC& list){   AddChildren(list.start(), list.size());}voidRowColC::AddChildren(Widget *list, int count){   Defer(True);   for (int i=0; i<count; i++) AddChild(list[i]);   Defer(False);}//----------------------------------------------------------------------------// Methods to set the child list//voidRowColC::SetChildren(WidgetListC& list){   SetChildren(list.start(), list.size());}voidRowColC::SetChildren(Widget *list, int count){   Defer(True);   Reset();   for (int i=0; i<count; i++) AddChild(list[i]);   Defer(False);}//----------------------------------------------------------------------------// Method to remove all children//voidRowColC::Reset(){   unsigned	count;   int		i;   RowColPart	*rc = GetRowColPart(rcw);   if ( rc->orient == RcROW_MAJOR ) {      count = rowList.size();      for (i=0; i<count; i++) delete (RowC*)rowList[i];      rowList.removeAll();      count = colList.size();      for (i=0; i<count; i++) colList[i]->Reset();   } else {      count = colList.size();      for (i=0; i<count; i++) delete (ColC*)colList[i];      colList.removeAll();      count = rowList.size();      for (i=0; i<count; i++) rowList[i]->Reset();   }   count = childList.size();   for (i=0; i<count; i++) {      RowColChildC	*child = childList[i];      delete child;   }   childList.removeAll();   if ( !deferred ) Refresh();   else		    changed = True;} // End RowColC Reset/*----------------------------------------------------------------------- *  Method to set deferral mode */voidRowColC::Defer(Boolean on){   if	   ( on )	deferCount++;   else if ( deferred ) deferCount--;   deferred = (deferCount > 0);   if ( !deferred && changed ) Refresh();} // End RowColC Defer#if 0/*----------------------------------------------------------------------- *  Method to realize widgets */static voidRealizeWidget(Widget w){   XtRealizeWidget(w);//// If this is a composite, realize the children//   if ( XtIsComposite(w) ) {      WidgetList	wlist;      Cardinal		wcount;      XtVaGetValues(w, XmNnumChildren, &wcount, XmNchildren, &wlist, 0);      for (int i=0; i<wcount; i++)	 RealizeWidget(wlist[i]);   }}#endif/*----------------------------------------------------------------------- *  Method to update geometry */voidRowColC::Refresh(){#if 0   if ( !XtIsRealized(rcw) ) {      changed = True;      return;   }#endif   if ( debug2 )      cout <<"RowColC(" <<rcw->core.name <<")::Refresh entered" <<endl;   Boolean	saveDeferred = deferred;   deferred = True;   selfResize = True;//// Calculate preferred sizes//   Dimension	prefWd = PrefWidth();   Dimension	prefHt = PrefHeight();   if ( debug2 )      cout <<"   we'd like to be: " <<prefWd <<" by " <<prefHt <<endl;   if ( !inResize ) {      if ( newWd > 0 ) {	 prefWd = newWd;	 newWd = 0;	 if ( debug2 )	    cout <<"   but the programmed width is: " <<prefWd <<endl;

⌨️ 快捷键说明

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