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

📄 vboxc.c

📁 linux下的E_MAIL客户端源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * $Id: VBoxC.C,v 1.7 2000/08/07 12:36:18 evgeny Exp $ * * Copyright (c) 1992 HaL Computer Systems, Inc.  All rights reserved. *  *          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 "HalAppC.h"#include "VBoxC.h"#include "LgIconViewC.h"#include "SmIconViewC.h"#include "WArgList.h"#include "WXmString.h"#include "rsrc.h"#include "StringC.h"#include "SortDialogC.h"#include "FiltDialogC.h"#include "FindDialogC.h"#include "JoyStickC.h"#include <Xm/Form.h>#include <Xm/Frame.h>#include <Xm/DrawingA.h>#include <Xm/ScrollBar.h>#include <Xm/RowColumn.h>#include <Xm/Separator.h>#include <Xm/PushB.h>#include <Xm/Label.h>/*----------------------------------------------------------------------- *  Constructor for VBoxC */VBoxC::VBoxC(Widget parent, const char *name, ArgList argv, Cardinal argc){   WArgList	args;   Widget	wlist[7];   viewGC         = NULL;   viewPm	  = (Pixmap)NULL;   dropAtoms      = NULL;   dropAtomCount  =   dropAtomAlloc  = 0;   realized       = False;   filtFunc       = (FilterFn)NULL;   findFunc       = (FindFn)NULL;   compFunc       = (CompareFn)NULL;   visItems.SetSorted(TRUE);   selectChangeCalls.AllowDuplicates(TRUE);   dragCalls.AllowDuplicates(TRUE);#if 1   viewForm = XmCreateForm(parent, (char *)name, argv, argc);#else   args.Reset();   for (int i=0; i<argc; i++) args[i] = argv[i];   args.Orientation(XmVERTICAL);   args.Packing(XmPACK_TIGHT);   viewForm = XmCreateRowColumn(parent, (char *)name, ARGS);#endif//// Create the viewForm widget hierarchy//// viewForm//    Form	scrollForm//    Form	statusForm//   args.Reset();#if 1   args.LeftAttachment(XmATTACH_FORM);   args.RightAttachment(XmATTACH_NONE);   args.TopAttachment(XmATTACH_NONE);   args.BottomAttachment(XmATTACH_FORM);#endif   statusForm = XmCreateForm(viewForm, "statusForm", ARGS);   args.Reset();#if 1   args.LeftAttachment(XmATTACH_FORM);   args.RightAttachment(XmATTACH_FORM);   args.TopAttachment(XmATTACH_FORM);   args.BottomAttachment(XmATTACH_WIDGET, statusForm);#endif   scrollForm = XmCreateForm(viewForm, "scrollForm", ARGS);//// Create a parent for the joy stick and then the stick itself.//   args.Reset();   args.LeftAttachment(XmATTACH_NONE);   args.RightAttachment(XmATTACH_FORM);   args.TopAttachment(XmATTACH_NONE);   args.BottomAttachment(XmATTACH_FORM);   args.ShadowType(XmSHADOW_IN);   args.MappedWhenManaged(FALSE);   args.MarginWidth(0);   args.MarginHeight(0);   joyStickFrame = XmCreateFrame(scrollForm, "joyStickFrame", ARGS);   joyStick = new JoyStickC(joyStickFrame, "joyStick", 0,0);   XtManageChild(*joyStick);   joyStickOn = FALSE;    joyStick->AddMoveCallback((CallbackFn*)DoMoveJoyStick, this);//// Create the scrollForm widget hierarchy//// scrollForm//    Frame		viewFrame//	 DrawingArea	viewDA//    ScrollBar		hScrollBar//    ScrollBar		vScrollBar//   args.Reset();   args.LeftAttachment(XmATTACH_FORM);   args.RightAttachment(XmATTACH_FORM);   args.TopAttachment(XmATTACH_FORM);   args.BottomAttachment(XmATTACH_FORM);   viewFrame = XmCreateFrame(scrollForm, "viewFrame", ARGS);   args.Reset();   args.LeftAttachment(XmATTACH_OPPOSITE_WIDGET, viewFrame);   args.RightAttachment(XmATTACH_OPPOSITE_WIDGET, viewFrame);   args.TopAttachment(XmATTACH_NONE);   args.BottomAttachment(XmATTACH_FORM);   args.Orientation(XmHORIZONTAL);   args.ProcessingDirection(XmMAX_ON_RIGHT);   args.ShowArrows(True);   args.MappedWhenManaged(False);   hScrollBar = XmCreateScrollBar(scrollForm, "hScrollBar", ARGS);   args.Reset();   args.LeftAttachment(XmATTACH_NONE);   args.RightAttachment(XmATTACH_FORM);   args.TopAttachment(XmATTACH_OPPOSITE_WIDGET, viewFrame);   args.BottomAttachment(XmATTACH_OPPOSITE_WIDGET, viewFrame);   args.Orientation(XmVERTICAL);   args.ProcessingDirection(XmMAX_ON_BOTTOM);   args.ShowArrows(True);   args.MappedWhenManaged(False);   vScrollBar = XmCreateScrollBar(scrollForm, "vScrollBar", ARGS);   hScrollOn       = vScrollOn       = False;   hScrollValue    = vScrollValue    = 0;   hScrollMaxValue = vScrollMaxValue = 0;   args.Reset();   args.ResizePolicy(XmRESIZE_NONE);   args.UserData(this);   viewDA = XmCreateDrawingArea(viewFrame, "viewDA", ARGS);   XtManageChild(viewDA);   XtAddCallback(hScrollBar, XmNdecrementCallback,		 (XtCallbackProc)HandleHScroll, (XtPointer)this);   XtAddCallback(hScrollBar, XmNdragCallback,		 (XtCallbackProc)HandleHScroll, (XtPointer)this);   XtAddCallback(hScrollBar, XmNincrementCallback,		 (XtCallbackProc)HandleHScroll, (XtPointer)this);   XtAddCallback(hScrollBar, XmNpageDecrementCallback,		 (XtCallbackProc)HandleHScroll, (XtPointer)this);   XtAddCallback(hScrollBar, XmNpageIncrementCallback,		 (XtCallbackProc)HandleHScroll, (XtPointer)this);   XtAddCallback(hScrollBar, XmNtoBottomCallback,		 (XtCallbackProc)HandleHScroll, (XtPointer)this);   XtAddCallback(hScrollBar, XmNtoTopCallback,		 (XtCallbackProc)HandleHScroll, (XtPointer)this);   XtAddCallback(hScrollBar, XmNvalueChangedCallback,		 (XtCallbackProc)HandleHScroll, (XtPointer)this);   XtAddCallback(vScrollBar, XmNdecrementCallback,		 (XtCallbackProc)HandleVScroll, (XtPointer)this);   XtAddCallback(vScrollBar, XmNdragCallback,		 (XtCallbackProc)HandleVScroll, (XtPointer)this);   XtAddCallback(vScrollBar, XmNincrementCallback,		 (XtCallbackProc)HandleVScroll, (XtPointer)this);   XtAddCallback(vScrollBar, XmNpageDecrementCallback,		 (XtCallbackProc)HandleVScroll, (XtPointer)this);   XtAddCallback(vScrollBar, XmNpageIncrementCallback,		 (XtCallbackProc)HandleVScroll, (XtPointer)this);   XtAddCallback(vScrollBar, XmNtoBottomCallback,		 (XtCallbackProc)HandleVScroll, (XtPointer)this);   XtAddCallback(vScrollBar, XmNtoTopCallback,		 (XtCallbackProc)HandleVScroll, (XtPointer)this);   XtAddCallback(vScrollBar, XmNvalueChangedCallback,		 (XtCallbackProc)HandleVScroll, (XtPointer)this);   wlist[0] = viewFrame;   wlist[1] = hScrollBar;   wlist[2] = vScrollBar;   XtManageChildren(wlist, 3);	// scrollForm children//// Create the status form widget hierarchy////      statusForm//         Label	totalLabel//         Label	totalVal//         Label	dispLabel//         Label	dispVal//         Label	selLabel//         Label	selVal//   Widget	totalLabel = XmCreateLabel(statusForm, "totalLabel", 0,0);   args.Reset();   args.LeftAttachment(XmATTACH_WIDGET, totalLabel);   totalVal = XmCreateLabel(statusForm, "totalVal", ARGS);   args.LeftWidget(totalVal);   Widget	dispLabel = XmCreateLabel(statusForm, "dispLabel", ARGS);   args.LeftWidget(dispLabel);   dispVal = XmCreateLabel(statusForm, "dispVal", ARGS);   args.LeftWidget(dispVal);   Widget	selLabel = XmCreateLabel(statusForm, "selLabel", ARGS);   args.LeftWidget(selLabel);   selVal = XmCreateLabel(statusForm, "selVal", ARGS);   wlist[0] = totalLabel;   wlist[1] = dispLabel;   wlist[2] = selLabel;   wlist[3] = totalVal;   wlist[4] = dispVal;   wlist[5] = selVal;   XtManageChildren(wlist, 6);	// statusForm children   SetLabel(totalVal, 0);   SetLabel(dispVal, 0);   SetLabel(selVal, 0);   wlist[0] = statusForm;   wlist[1] = scrollForm;   XtManageChildren(wlist, 2);	// viewForm   XtManageChild(joyStickFrame);   XtManageChild(viewForm);   statusShown = True;//// Create the drawing area widget hierarchy////	viewDA//         PopupMenu		viewPopup//   popupEnabled = get_boolean("VBoxC", viewForm, "popupEnabled", True);   vScrollInc   = get_int("VBoxC", viewForm, "vJoyStickInc", 5);   hScrollInc   = get_int("VBoxC", viewForm, "hJoyStickInc", 5);   viewPopup      = (Widget)NULL;   selectButton   = (Widget)NULL;   deselectButton = (Widget)NULL;   sortButton     = (Widget)NULL;   filterButton   = (Widget)NULL;   findButton     = (Widget)NULL;   if ( popupEnabled ) {      args.Reset();      args.RadioBehavior(True);      viewPopup = XmCreatePopupMenu(viewDA, "viewPopup", ARGS);//// Create the popup menu widget hierarchy////	viewPopup//         PushButton	selectButton//         PushButton	deselectButton//	   Separator	sep;//         PushButton	filterButton//         PushButton	sortButton//         PushButton	findButton//	   Separator	sep;//      selectButton   = XmCreatePushButton(viewPopup, "selectButton",   0,0);      deselectButton = XmCreatePushButton(viewPopup, "deselectButton", 0,0);      Widget	sep1 = XmCreateSeparator(viewPopup, "sep1", 0,0);	 sortButton   = XmCreatePushButton(viewPopup, "sortButton", 0,0);	 filterButton = XmCreatePushButton(viewPopup, "filterButton", 0,0);	 findButton   = XmCreatePushButton(viewPopup, "findButton", 0,0);      wlist[0] = selectButton;      wlist[1] = deselectButton;      wlist[2] = sep1;      wlist[3] = sortButton;      wlist[4] = filterButton;      wlist[5] = findButton;      XtManageChildren(wlist, 6);	// viewPopup      XtAddCallback(selectButton, XmNactivateCallback,      		    (XtCallbackProc)DoSelectAll, (XtPointer)this);      XtAddCallback(deselectButton, XmNactivateCallback,		    (XtCallbackProc)DoDeselectAll, (XtPointer)this);      XtAddCallback(sortButton, XmNactivateCallback, (XtCallbackProc)DoSort,		    (XtPointer)this);      XtAddCallback(filterButton, XmNactivateCallback, (XtCallbackProc)DoFilt,		    (XtPointer)this);      XtAddCallback(findButton, XmNactivateCallback, (XtCallbackProc)DoFind,		    (XtPointer)this);      XtSetSensitive(selectButton,   False);      XtSetSensitive(deselectButton, False);   } // End if the popup menu is enabled//// Build default sort, filter and find dialogs//   Boolean builtIns = get_boolean("VBoxC", viewForm, "builtInDialogs", True);   if ( builtIns ) {      sortDialog = defSortDialog = (HalDialogC *)new SortDialogC(this);      filtDialog = defFiltDialog = (HalDialogC *)new FiltDialogC(this);      findDialog = defFindDialog = (HalDialogC *)new FindDialogC(this);   }   else {      sortDialog = defSortDialog = NULL;      filtDialog = defFiltDialog = NULL;      findDialog = defFindDialog = NULL;   }//// Initialize variables//   changed = False;   partialSelect = 0;   filterOutput = DISPLAY_FILTER_OUTPUT;   findPos = 0;   findBlinkCount    = get_int("VBoxC", viewForm, "findBlinkCount",    0);   findBlinkInterval = get_int("VBoxC", viewForm, "findBlinkInterval", 0);   dragEnabled       = get_boolean("VBoxC", viewForm, "enableDragOut", True);   dropEnabled       = get_boolean("VBoxC", viewForm, "enableDropIn",  False);//// NEW FOR I18N - Check for a fontList resource first.  If it is found, use it//		  instead of the font resource//      StringC	fontListName = get_string("VBoxC", viewDA, "fontList");   Boolean goodFontList = False;   freeFontList = False;   if ( fontListName.size() > 0 && fontListName != "none" ) {      XrmValue fromVal, toVal;      fromVal.addr = (XPointer)((char*)fontListName);      fromVal.size = fontListName.size() + 1;      toVal.addr = (XPointer)&fontList;      toVal.size = sizeof(XmFontList);      goodFontList = XtConvertAndStore(viewDA, XmRString, &fromVal, 				       XmRFontList, &toVal);      if (goodFontList) {        freeFontList = True;      } else {	fontList = NULL;      }   } else {     fontList = NULL;   }   StringC	fontName = get_string("VBoxC", viewDA, "font", "fixed");   freeFont = True;   goodFont = True;     font = XLoadQueryFont(halApp->display, fontName);   if ( !font ) {      font = halApp->font;      freeFont = False;      goodFont = False;   }   view = NULL;//// Add default view types//   VTypeT	ltype, stype;   Boolean	doit = get_boolean("VBoxC", viewForm, "hasLargeIconView", True);   if ( doit ) {      lgIconView = new LgIconViewC(this);      ltype = AddView(*lgIconView);   } else {      lgIconView = NULL;   }   doit = get_boolean("VBoxC", viewForm, "hasSmallIconView", True);   if ( doit ) {      smIconView = new SmIconViewC(this);      stype = AddView(*smIconView);   } else {      smIconView = NULL;   }   if ( lgIconView ) viewType = ltype;   else if ( smIconView ) viewType = stype;   XtAddEventHandler(viewForm, StructureNotifyMask, False,		     (XtEventHandler)HandleMapChange, (XtPointer)this);} // End Constructor/*----------------------------------------------------------------------- *  Destructor for VBoxC */VBoxC::~VBoxC(){//// Release GC//   if ( halApp->xRunning ) {      if ( viewGC ) XtReleaseGC(halApp->appShell, viewGC);      if ( freeFont ) XFreeFont(halApp->display, font);#if 0      // FIXME: problems with Linux Motif 2.0      if ( freeFontList ) XmFontListFree(fontList);#endif      if (viewPm) XFreePixmap(halApp->display, viewPm);   }//// Delete dialogs//   delete defSortDialog;   delete defFiltDialog;   delete defFindDialog;//// Delete views//   delete lgIconView;   delete smIconView;   delete dropAtoms;//// Delete callback structures//   DeleteCallbacks(selectChangeCalls);   DeleteCallbacks(dragCalls);   DeleteCallbacks(dropCalls);} // End Destructor/*----------------------------------------------------------------------- *  Called on initial display */voidVBoxC::HandleMapChange(Widget, VBoxC *This, XEvent *ev, Boolean*){   if ( ev->type != MapNotify ) return;   XtRemoveEventHandler(This->viewForm, StructureNotifyMask, False,		        (XtEventHandler)HandleMapChange, (XtPointer)This);//// Create graphics contexts for drawing//   XtGCMask	modMask = GCClipMask | GCFillStyle | GCFont | GCFunction			| GCGraphicsExposures | GCLineStyle | GCLineWidth			| GCPlaneMask | GCForeground | GCArcMode | GCBackground			| GCCapStyle | GCClipXOrigin | GCClipYOrigin			| GCDashList | GCDashOffset | GCFillRule | GCJoinStyle			| GCStipple | GCSubwindowMode | GCTile			| GCTileStipXOrigin | GCTileStipYOrigin;   XGCValues fixVals;   This->viewGC  = XtAllocateGC(This->viewDA, 0, 0, &fixVals, modMask, 0);   This->viewWin = XtWindow(This->viewDA);#if 0// If you use backing store, the window manager "Refresh" function doesn't//    work//// Turn on backing store//   unsigned long	winMask = CWBackingStore;   XSetWindowAttributes	winVals;   winVals.backing_store = WhenMapped;   XChangeWindowAttributes(halApp->display, This->viewWin, winMask, &winVals);#endif//// Create a drop site//   WArgList	args;   args.DragProc((XtCallbackProc)HandleDragOver);   args.DropProc((XtCallbackProc)HandleDropIn);   args.AnimationStyle(XmDRAG_UNDER_NONE);   args.DropSiteType(XmDROP_SITE_SIMPLE);   if ( This->dropEnabled ) {      args.DropSiteActivity(XmDROP_SITE_ACTIVE);      args.ImportTargets(This->dropAtoms);      args.NumImportTargets(This->dropAtomCount);   } else {      args.DropSiteActivity(XmDROP_SITE_INACTIVE);   }   XmDropSiteRegister(This->viewDA, ARGS);//// Finalize layout//   Dimension	dawd, daht;   XtVaGetValues(This->viewDA, XmNwidth, &dawd, XmNheight, &daht, NULL);   This->visRect.Set(0, 0, dawd, daht);//// Get offsets to use if scrollbars are not displayed//   XtVaGetValues(This->viewFrame, XmNrightOffset,  &This->noScrollRoff,				  XmNbottomOffset, &This->noScrollBoff, NULL);//// Get size and offset for scrollbars//

⌨️ 快捷键说明

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