Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
14
cde/programs/dtmail/Imakefile
Normal file
14
cde/programs/dtmail/Imakefile
Normal file
@@ -0,0 +1,14 @@
|
||||
XCOMM $TOG: Imakefile /main/6 1998/08/10 15:47:38 mgreess $
|
||||
XCOMM @(#)Imakefile 1.35 07 Oct 1994
|
||||
|
||||
#define IHaveSubdirs
|
||||
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' 'CXXDEBUGFLAGS=$(CXXDEBUGFLAGS)'
|
||||
|
||||
#ifdef SunArchitecture
|
||||
.NO_PARALLEL:
|
||||
#endif
|
||||
|
||||
SUBDIRS = libDtMail MotifApp dtmail dtmailpr
|
||||
|
||||
MakeSubdirs($(SUBDIRS))
|
||||
DependSubdirs($(SUBDIRS))
|
||||
378
cde/programs/dtmail/MotifApp/Application.C
Normal file
378
cde/programs/dtmail/MotifApp/Application.C
Normal file
@@ -0,0 +1,378 @@
|
||||
/* $TOG: Application.C /main/15 1998/10/01 12:10:26 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Application.C:
|
||||
////////////////////////////////////////////////////////////
|
||||
#include "Application.h"
|
||||
#include "MainWindow.h"
|
||||
#include <X11/StringDefs.h>
|
||||
#include <X11/Shell.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <nl_types.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "EUSDebug.hh"
|
||||
|
||||
|
||||
XtResource
|
||||
Application::_appResources[] = {
|
||||
{
|
||||
"workspaceList", "WorkspaceList", XtRString, sizeof(XtRString),
|
||||
XtOffset(Application *, _appWorkspaceList), XtRString, (XtPointer) NULL
|
||||
}
|
||||
};
|
||||
|
||||
// XPG3 compatible. NL_CAT_LOCALE is set to 1 (non-zero) in XPG4. Use NL_CAT_LOCALE
|
||||
// for all catopen() calls. This is also defined in include/DtMail/Common.h for dtmail
|
||||
// and libDtMail catopen calls, if later on we have a common include file for
|
||||
// dtmail, libDtMail and MotifApp, we can move this define over there.
|
||||
|
||||
#if defined(sun) && (_XOPEN_VERSION == 3)
|
||||
#undef NL_CAT_LOCALE
|
||||
#define NL_CAT_LOCALE 0
|
||||
|
||||
// If NL_CAT_LOCALE is not defined in other platforms, set it to 0
|
||||
#elif !defined(NL_CAT_LOCALE)
|
||||
#define NL_CAT_LOCALE 0
|
||||
#endif
|
||||
|
||||
#ifdef hpV4
|
||||
/*
|
||||
* Wrapper around catgets -- this makes sure the message string is saved
|
||||
* in a safe location; so repeated calls to catgets() do not overwrite
|
||||
* the catgets() internal buffer. This has been a problem on HP systems.
|
||||
*/
|
||||
char *catgets_cache2(nl_catd catd, int set, int num, char *dflt)
|
||||
{
|
||||
|
||||
#define MSGS_PER_SET_MAX 12
|
||||
#define NUM_SETS_MAX 2
|
||||
|
||||
/* array to hold messages from catalog */
|
||||
static char *MsgCat[NUM_SETS_MAX][MSGS_PER_SET_MAX];
|
||||
|
||||
/* convert to a zero based index */
|
||||
int setIdx = set - 1;
|
||||
int numIdx = num - 1;
|
||||
|
||||
if ( ! MsgCat[setIdx][numIdx] ) {
|
||||
MsgCat[setIdx][numIdx] = strdup( catgets(catd, set, num, dflt));
|
||||
}
|
||||
|
||||
return MsgCat[setIdx][numIdx];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Application *theApplication = NULL;
|
||||
|
||||
nl_catd catd = (nl_catd) -1; // catgets file descriptor
|
||||
|
||||
extern String ApplicationFallbacks[];
|
||||
|
||||
Application::Application ( char *appClassName ) :
|
||||
UIComponent ( appClassName )
|
||||
{
|
||||
// Set the global Application pointer
|
||||
DebugPrintf(2, "Application::Application(%p \"%s\")\n", appClassName, appClassName);
|
||||
|
||||
theApplication = this;
|
||||
|
||||
// Initialize data members
|
||||
|
||||
_display = NULL;
|
||||
_appContext = NULL;
|
||||
_bMenuButton = 0;
|
||||
_windows = NULL;
|
||||
_numWindows = 0;
|
||||
_shutdownEnabled = 1;
|
||||
_applicationClass = strdup ( appClassName );
|
||||
}
|
||||
|
||||
void Application::initialize ( int *argcp, char **argv )
|
||||
{
|
||||
DebugPrintf(2, "Application::initialize(%p %d, %p)\n", argcp, *argcp, argv);
|
||||
|
||||
DebugPrintf(3, "Application::initialize - Initializing privileges.\n");
|
||||
|
||||
// The Solaris sendmail operates differently than the HP/IBM sendmail.
|
||||
// sendmail on Solaris runs as 'root' and so has access permissions
|
||||
// to any file on the system. sendmail on HP/IBM runs as set-group-id
|
||||
// 'mail' and so requires that all mailboxes that it may deliver e-mail
|
||||
// to be writable either by being group mail group writable, or by being
|
||||
// writable by the world. On those platforms, then, dtmail is required
|
||||
// to always run with set-group-id mail otherwise, when mailboxes are
|
||||
// saved, they will loose their group ownership and sendmail will no
|
||||
// onger be able to deliver to those mailboxes.
|
||||
|
||||
// we have to be set-gid to group "mail" when opening and storing
|
||||
// folders. But we don't want to do everything as group mail.
|
||||
// here we record our original gid, and set the effective gid
|
||||
// back the the real gid. We'll set it back when we're dealing
|
||||
// with folders...
|
||||
//
|
||||
_originalEgid = getegid(); // remember effective group ID
|
||||
_originalRgid = getgid(); // remember real group ID
|
||||
disableGroupPrivileges(); // disable group privileges from here on
|
||||
|
||||
DebugPrintf(3, "Application::initialize - Initializing Xt.\n");
|
||||
|
||||
_w = XtOpenApplication (
|
||||
&_appContext,
|
||||
_applicationClass,
|
||||
(XrmOptionDescList) NULL, 0,
|
||||
argcp, argv, ApplicationFallbacks,
|
||||
sessionShellWidgetClass, (ArgList) NULL, 0 );
|
||||
|
||||
// Extract and save a pointer to the X display structure
|
||||
DebugPrintf(3, "Application::initialize - Extracting display.\n");
|
||||
_display = XtDisplay ( _w );
|
||||
|
||||
// Set virtual BMenu mouse binding
|
||||
int numButtons = XGetPointerMapping(_display, (unsigned char *)NULL, 0);
|
||||
_bMenuButton = (numButtons < 3) ? Button2 : Button3;
|
||||
|
||||
// The Application class is less likely to need to handle
|
||||
// "surprise" widget destruction than other classes, but
|
||||
// we might as well install a callback to be safe and consistent
|
||||
DebugPrintf(3, "Application::initialize - Installing destroy handler.\n");
|
||||
installDestroyHandler();
|
||||
|
||||
// Center the shell, and make sure it isn't visible
|
||||
DebugPrintf(3, "Application::initialize - Setting window size.\n");
|
||||
XtVaSetValues ( _w,
|
||||
XmNmappedWhenManaged, FALSE,
|
||||
XmNx, DisplayWidth ( _display, 0 ) / 2,
|
||||
XmNy, DisplayHeight ( _display, 0 ) / 2,
|
||||
XmNwidth, 1,
|
||||
XmNheight, 1,
|
||||
NULL );
|
||||
|
||||
// The instance name of this object was set in the UIComponent
|
||||
// constructor, before the name of the program was available
|
||||
// Free the old name and reset it to argv[0]
|
||||
DebugPrintf(3, "Application::initialize - Deleting name %p\n", _name);
|
||||
free(_name);
|
||||
_name = strdup ( argv[0] );
|
||||
|
||||
// Force the shell window to exist so dialogs popped up from
|
||||
// this shell behave correctly
|
||||
DebugPrintf(3, "Application::initialize - Realizing shell window.\n");
|
||||
XtRealizeWidget ( _w );
|
||||
|
||||
getResources(_appResources, XtNumber(_appResources));
|
||||
|
||||
// Initialize and manage any windows registered
|
||||
// with this application.
|
||||
|
||||
for ( int i = 0; i < _numWindows; i++ )
|
||||
{
|
||||
DebugPrintf(3, "Application::initialize - Initializing windows[%d]\n", i);
|
||||
_windows[i]->initialize();
|
||||
DebugPrintf(3, "Application::initialize - Managing windows[%d]\n", i);
|
||||
_windows[i]->manage();
|
||||
}
|
||||
}
|
||||
|
||||
// Calling _exit() now to work around a problem with threads
|
||||
// deadlocking if exit() is called.
|
||||
// Need to fix the threads deadlocking bug and then replace
|
||||
// _exit() with exit().
|
||||
|
||||
Application::~Application()
|
||||
{
|
||||
//
|
||||
// Allocated using strdup, so free using free.
|
||||
//
|
||||
free((void*) _applicationClass);
|
||||
delete []_windows;
|
||||
|
||||
#ifdef CDExc21492
|
||||
#if defined(__hpux) || defined(USL) || defined(__uxp__)
|
||||
this->BasicComponent::~BasicComponent();
|
||||
#elif __osf__
|
||||
BasicComponent * The_End = this;
|
||||
The_End->BasicComponent::~BasicComponent();
|
||||
#else
|
||||
BasicComponent::~BasicComponent();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
catclose(catd);
|
||||
|
||||
// In an MT environment, calling exit() causes threads to
|
||||
// hang and a deadlock results.
|
||||
// Call _exit() instead
|
||||
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
// ApplicationExtractEventTime - extract the time the
|
||||
// current event happened if it is one we are interested
|
||||
// in - this is used to delay actions that can lock the application
|
||||
// while the user is being interactive with the application
|
||||
//
|
||||
|
||||
inline void Application::extractAndRememberEventTime(XEvent *event)
|
||||
{
|
||||
switch (((XAnyEvent *)event)->type)
|
||||
{
|
||||
case KeyPress: // press any key on the keyboard
|
||||
case ButtonPress: // press any botton on the screen
|
||||
case MotionNotify: // motion events
|
||||
_lastInteractiveEventTime = time((time_t *)0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Application::handleEvents()
|
||||
{
|
||||
// Just loop forever
|
||||
#if 0
|
||||
XtAppMainLoop ( _appContext );
|
||||
#else
|
||||
XEvent event;
|
||||
|
||||
_lastInteractiveEventTime = time((time_t *)0);
|
||||
|
||||
for (;;) {
|
||||
XtAppNextEvent( _appContext, &event );
|
||||
extractAndRememberEventTime( &event );
|
||||
XtDispatchEvent( &event );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Application::registerWindow ( MainWindow *window )
|
||||
{
|
||||
int i;
|
||||
MainWindow **newList;
|
||||
|
||||
// Allocate a new list large enough to hold the new
|
||||
// object, and copy the contents of the current list
|
||||
// to the new list
|
||||
|
||||
newList = new MainWindow*[_numWindows + 1];
|
||||
|
||||
for ( i = 0; i < _numWindows; i++ )
|
||||
newList[i] = _windows[i];
|
||||
|
||||
// Install the new list and add the window to the list
|
||||
|
||||
if (_numWindows > 0) delete []_windows;
|
||||
_windows = newList;
|
||||
_windows[_numWindows] = window;
|
||||
|
||||
_numWindows++;
|
||||
}
|
||||
|
||||
void Application::unregisterWindow ( MainWindow *window )
|
||||
{
|
||||
int i, index;
|
||||
|
||||
// If this is the last window bye bye.
|
||||
|
||||
if (isEnabledShutdown() && _numWindows == 1)
|
||||
{
|
||||
_numWindows--;
|
||||
|
||||
// Call derived class's shutdown method.
|
||||
shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy all objects, except the one to be removed, to a new list
|
||||
|
||||
MainWindow **newList = new MainWindow*[_numWindows - 1];
|
||||
|
||||
for (i=0, index=0; i<_numWindows; i++)
|
||||
if (_windows[i] != window)
|
||||
newList[index++] = _windows[i];
|
||||
|
||||
delete []_windows;
|
||||
_windows = newList;
|
||||
_numWindows--;
|
||||
}
|
||||
|
||||
void Application::manage()
|
||||
{
|
||||
// Manage all application windows. This will pop up
|
||||
// iconified windows as well.
|
||||
|
||||
for ( int i = 0; i < _numWindows; i++ )
|
||||
_windows[i]->manage();
|
||||
}
|
||||
|
||||
void Application::unmanage()
|
||||
{
|
||||
// Unmanage all application windows
|
||||
|
||||
for ( int i = 0; i < _numWindows; i++ )
|
||||
_windows[i]->unmanage();
|
||||
}
|
||||
|
||||
void Application::iconify()
|
||||
{
|
||||
// Iconify all top-level windows.
|
||||
|
||||
for ( int i = 0; i < _numWindows; i++ )
|
||||
_windows[i]->iconify();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Application::open_catalog()
|
||||
{
|
||||
// open message catalog file
|
||||
catd = catopen("MotifApp", NL_CAT_LOCALE);
|
||||
}
|
||||
|
||||
void
|
||||
Application::setAppWorkspaceList(char *workspaceList)
|
||||
{
|
||||
// open message catalog file
|
||||
if (NULL != _appWorkspaceList)
|
||||
free(_appWorkspaceList);
|
||||
|
||||
_appWorkspaceList = strdup(workspaceList);
|
||||
}
|
||||
121
cde/programs/dtmail/MotifApp/AskFirstCmd.C
Normal file
121
cde/programs/dtmail/MotifApp/AskFirstCmd.C
Normal file
@@ -0,0 +1,121 @@
|
||||
/* $TOG: AskFirstCmd.C /main/5 1997/03/31 15:59:09 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// AskFirstCmd.C
|
||||
//////////////////////////////////////////////////////////
|
||||
#include "AskFirstCmd.h"
|
||||
#include "QuestionDialogManager.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <nl_types.h>
|
||||
extern nl_catd catd;
|
||||
|
||||
#include "NLS.hh"
|
||||
|
||||
AskFirstCmd::AskFirstCmd ( char *name,
|
||||
char *label,
|
||||
int active ) : Cmd ( name, label, active )
|
||||
{
|
||||
_dialog = NULL;
|
||||
_question = NULL;
|
||||
_dialogParentWidget = NULL;
|
||||
setQuestion ( GETMSG(catd, 1, 1,
|
||||
"Do you really want to execute this command?"));
|
||||
}
|
||||
|
||||
void AskFirstCmd::setQuestion ( char *str )
|
||||
{
|
||||
if (_question)
|
||||
free(_question);
|
||||
_question = strdup ( str );
|
||||
}
|
||||
|
||||
void AskFirstCmd::execute()
|
||||
{
|
||||
char *name_str;
|
||||
char *label_str;
|
||||
|
||||
name_str = (char *) name();
|
||||
label_str = (char *) getLabel();
|
||||
|
||||
|
||||
if (!_dialogParentWidget) return;
|
||||
|
||||
if (!_dialog) {
|
||||
_dialog = new QuestionDialogManager(name_str);
|
||||
}
|
||||
|
||||
_dialog->post(
|
||||
label_str,
|
||||
_question,
|
||||
_dialogParentWidget,
|
||||
(void *) this,
|
||||
&AskFirstCmd::yesCallback,
|
||||
&AskFirstCmd::cancelCallback);
|
||||
}
|
||||
|
||||
void AskFirstCmd::yesCallback ( void *clientData )
|
||||
{
|
||||
AskFirstCmd *obj = (AskFirstCmd *) clientData;
|
||||
|
||||
obj->doYesCallback();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
AskFirstCmd::cancelCallback ( void *)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
AskFirstCmd::doYesCallback()
|
||||
{
|
||||
|
||||
// unmanage the dialog right away
|
||||
_dialog->unmanage();
|
||||
|
||||
|
||||
// Call the base class execute()
|
||||
// member function to do all the
|
||||
// usual processing of the command
|
||||
|
||||
this->Cmd::execute();
|
||||
|
||||
}
|
||||
73
cde/programs/dtmail/MotifApp/BasicComponent.C
Normal file
73
cde/programs/dtmail/MotifApp/BasicComponent.C
Normal file
@@ -0,0 +1,73 @@
|
||||
/* $XConsortium: BasicComponent.C /main/4 1996/04/05 16:48:29 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// BasicComponent.C: Initial version of a class to define
|
||||
// a protocol for all components
|
||||
///////////////////////////////////////////////////////////
|
||||
#include "BasicComponent.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
BasicComponent::BasicComponent ( const char *name )
|
||||
{
|
||||
_w = NULL;
|
||||
assert ( name != NULL ); // Make sure programmers provide name
|
||||
_name = strdup ( name );
|
||||
}
|
||||
|
||||
BasicComponent::~BasicComponent()
|
||||
{
|
||||
if( _w )
|
||||
XtDestroyWidget ( _w );
|
||||
_w = NULL;
|
||||
free (_name);
|
||||
}
|
||||
|
||||
void BasicComponent::manage()
|
||||
{
|
||||
assert ( _w != NULL );
|
||||
XtManageChild ( _w );
|
||||
}
|
||||
|
||||
void BasicComponent::unmanage()
|
||||
{
|
||||
assert ( _w != NULL );
|
||||
XtUnmanageChild ( _w );
|
||||
}
|
||||
145
cde/programs/dtmail/MotifApp/BusyPixmap.C
Normal file
145
cde/programs/dtmail/MotifApp/BusyPixmap.C
Normal file
@@ -0,0 +1,145 @@
|
||||
/* $XConsortium: BusyPixmap.C /main/3 1996/04/21 19:32:02 drk $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
// BusyPixmap.C
|
||||
///////////////////////////////////////////////////
|
||||
#include "BusyPixmap.h"
|
||||
#include <Xm/Xm.h>
|
||||
|
||||
#define NUMPIXMAPS 8
|
||||
#define PIXMAPSIZE 50
|
||||
|
||||
BusyPixmap::BusyPixmap ( Widget w ) :
|
||||
PixmapCycler ( NUMPIXMAPS, PIXMAPSIZE, PIXMAPSIZE )
|
||||
{
|
||||
_w = w;
|
||||
}
|
||||
|
||||
void BusyPixmap::createPixmaps()
|
||||
{
|
||||
int angle, delta, i;
|
||||
XGCValues gcv;
|
||||
|
||||
// Create a graphics context used to draw each pixmap,
|
||||
// based on the colors of the given widget
|
||||
|
||||
XtVaGetValues ( _w,
|
||||
XmNforeground, &gcv.foreground,
|
||||
XmNbackground, &gcv.background,
|
||||
NULL );
|
||||
|
||||
_gc = XtGetGC ( _w, GCForeground | GCBackground, &gcv );
|
||||
|
||||
// Create a second GC used to fill the pixmap with
|
||||
// the background color of the widget
|
||||
|
||||
XtVaGetValues ( _w,
|
||||
XmNforeground, &gcv.background,
|
||||
XmNbackground, &gcv.foreground,
|
||||
NULL );
|
||||
|
||||
_inverseGC = XtGetGC ( _w, GCForeground | GCBackground, &gcv );
|
||||
|
||||
// Define the starting increment, and a slice of the pie.
|
||||
// The size of the pie slice depends on the number of pixmaps
|
||||
// to be created.
|
||||
|
||||
angle = 360;
|
||||
delta = 360 / NUMPIXMAPS;
|
||||
|
||||
for ( i = 0; i < NUMPIXMAPS; i++)
|
||||
{
|
||||
// Create a pixmap for each slice of the pie. X measures
|
||||
// counterclockwise, so subtract the size of each slice
|
||||
// so the sequence moves clockwise.
|
||||
|
||||
_pixmapList[i] = createBusyPixmap ( angle, delta );
|
||||
angle -= delta;
|
||||
}
|
||||
|
||||
// Release the GCs after all pixmaps have been created
|
||||
|
||||
XtReleaseGC ( _w, _gc );
|
||||
XtReleaseGC ( _w, _inverseGC );
|
||||
}
|
||||
|
||||
Pixmap BusyPixmap::createBusyPixmap ( int start,
|
||||
int end )
|
||||
{
|
||||
Pixmap pm;
|
||||
const int margin = 1;
|
||||
|
||||
// Create a pixmap. Use the root window used by the widget,
|
||||
// because the widget may not be realized, or may be a gadget
|
||||
|
||||
pm = XCreatePixmap ( XtDisplay ( _w ),
|
||||
RootWindowOfScreen ( XtScreen ( _w ) ),
|
||||
_width, _height,
|
||||
DefaultDepthOfScreen ( XtScreen ( _w ) ) );
|
||||
|
||||
// Pixmaps have to be cleared by filling them with a background color
|
||||
|
||||
XFillRectangle ( XtDisplay ( _w ),
|
||||
pm,
|
||||
_inverseGC,
|
||||
0, 0, _width, _height );
|
||||
|
||||
// Draw a complete circle just inside the bounds of the pxmap
|
||||
|
||||
XDrawArc ( XtDisplay ( _w ),
|
||||
pm,
|
||||
_gc,
|
||||
margin, margin,
|
||||
_width - 2 * margin,
|
||||
_height - 2 * margin,
|
||||
0, 360 * 64 );
|
||||
|
||||
// Draw the pie slice as a solid color
|
||||
|
||||
XFillArc ( XtDisplay ( _w ),
|
||||
pm,
|
||||
_gc,
|
||||
margin, margin,
|
||||
_width - 2 * margin,
|
||||
_height - 2 * margin,
|
||||
start * 64, end * 64 );
|
||||
|
||||
return pm;
|
||||
}
|
||||
120
cde/programs/dtmail/MotifApp/ButtonInterface.C
Normal file
120
cde/programs/dtmail/MotifApp/ButtonInterface.C
Normal file
@@ -0,0 +1,120 @@
|
||||
/* $XConsortium: ButtonInterface.C /main/4 1996/04/05 16:48:43 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// ButtonInterface.C: A push button interface to a Cmd object
|
||||
///////////////////////////////////////////////////////////////
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "ButtonInterface.h"
|
||||
#include <Xm/PushB.h>
|
||||
#include "Help.hh"
|
||||
#include "Cmd.h"
|
||||
|
||||
ButtonInterface::ButtonInterface ( Widget parent,
|
||||
Cmd *cmd ) : CmdInterface ( cmd )
|
||||
{
|
||||
|
||||
// We need to generate a button name that doesn't have illegal characters.
|
||||
//
|
||||
char w_name[200];
|
||||
mapName(_name, w_name);
|
||||
|
||||
XmString label = XmStringCreateLocalized(_cmd->getLabel());
|
||||
_w = XtVaCreateWidget (w_name,
|
||||
xmPushButtonWidgetClass,
|
||||
parent,
|
||||
XmNlabelString, label, NULL);
|
||||
XmStringFree(label);
|
||||
|
||||
printHelpId("_w", _w);
|
||||
// XtAddCallback(_w, XmNhelpCallback, HelpCB, helpId);
|
||||
// free(helpId);
|
||||
|
||||
installDestroyHandler();
|
||||
|
||||
// The _active member is set when each instance is registered
|
||||
// with an associated Cmd object. Now that a widget exists,
|
||||
// set the widget's sensitivity according to its active state.
|
||||
|
||||
if ( _active )
|
||||
activate();
|
||||
else
|
||||
deactivate();
|
||||
|
||||
#ifdef GNU_CC // No idea what the right ifdef is for automatically recognizing g++
|
||||
|
||||
// G++ reportedly doesn't like the form expected by cfront. I'm
|
||||
// told this will work, but I haven't tested it myself.
|
||||
|
||||
XtAddCallback ( _w,
|
||||
XmNactivateCallback,
|
||||
executeCmdCallback,
|
||||
(XtPointer) this );
|
||||
#else
|
||||
|
||||
XtAddCallback ( _w,
|
||||
XmNactivateCallback,
|
||||
&CmdInterface::executeCmdCallback,
|
||||
(XtPointer) this );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifndef CAN_INLINE_VIRTUALS
|
||||
ButtonInterface::~ButtonInterface(void)
|
||||
{
|
||||
}
|
||||
#endif /* ! CAN_INLINE_VIRTUALS */
|
||||
|
||||
void
|
||||
ButtonInterface::mapName(const char * input, char * output)
|
||||
{
|
||||
strcpy(output, input);
|
||||
for (char * cur = output; *cur; cur++) {
|
||||
if (isspace(*cur) || *cur == ',') {
|
||||
*cur = '_';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*cur == '.' || *cur == ':') {
|
||||
*cur = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
242
cde/programs/dtmail/MotifApp/Cmd.C
Normal file
242
cde/programs/dtmail/MotifApp/Cmd.C
Normal file
@@ -0,0 +1,242 @@
|
||||
/* $TOG: Cmd.C /main/4 1998/07/24 16:04:37 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// Cmd.C
|
||||
///////////////////////////////////////////////////////
|
||||
#include <stdlib.h>
|
||||
#include "Cmd.h"
|
||||
#include "CmdList.h"
|
||||
#include "CmdInterface.h"
|
||||
|
||||
extern Cmd *theUndoCmd; // External object that reverses the
|
||||
// most recent Cmd when executed
|
||||
|
||||
Cmd *Cmd::_lastCmd = NULL; // Pointer to most recent Cmd
|
||||
|
||||
Cmd::Cmd ( char *name, char *label, int active )
|
||||
{
|
||||
// Initialize all data members
|
||||
|
||||
_name = name;
|
||||
_active = active;
|
||||
_numInterfaces = 0;
|
||||
_ci = NULL;
|
||||
_activationList = NULL;
|
||||
_deactivationList = NULL;
|
||||
_hasUndo = TRUE;
|
||||
|
||||
if (label) {
|
||||
_label = strdup(label);
|
||||
} else {
|
||||
_label = strdup(name);
|
||||
}
|
||||
}
|
||||
|
||||
Cmd::~Cmd()
|
||||
{
|
||||
delete _activationList;
|
||||
delete _deactivationList;
|
||||
free (_label);
|
||||
if (_ci)
|
||||
delete [] _ci;
|
||||
}
|
||||
|
||||
void Cmd::registerInterface ( CmdInterface *ci )
|
||||
{
|
||||
// Make a new list, large enough for the new object
|
||||
|
||||
CmdInterface **newList = new CmdInterface*[_numInterfaces + 1];
|
||||
|
||||
// Copy the contents of the previous list to
|
||||
// the new list
|
||||
|
||||
for( int i = 0; i < _numInterfaces; i++)
|
||||
newList[i] = _ci[i];
|
||||
|
||||
// Free the old list
|
||||
|
||||
if (_ci)
|
||||
delete []_ci;
|
||||
|
||||
// Install the new list
|
||||
|
||||
_ci = newList;
|
||||
|
||||
// Add the object to the list and update the list size.
|
||||
|
||||
_ci[_numInterfaces] = ci;
|
||||
|
||||
_numInterfaces++;
|
||||
|
||||
if ( ci )
|
||||
if ( _active )
|
||||
ci->activate();
|
||||
else
|
||||
ci->deactivate();
|
||||
}
|
||||
|
||||
void Cmd::activate()
|
||||
{
|
||||
// Activate the associated interfaces
|
||||
|
||||
for ( int i = 0; i < _numInterfaces; i++ )
|
||||
_ci[i]->activate ();
|
||||
|
||||
// Save the current value of active before setting the new state
|
||||
|
||||
_previouslyActive = _active;
|
||||
_active = TRUE;
|
||||
}
|
||||
|
||||
void Cmd::deactivate()
|
||||
{
|
||||
// Deactivate the associated interfaces
|
||||
|
||||
for ( int i = 0; i < _numInterfaces; i++ )
|
||||
_ci[i]->deactivate ();
|
||||
|
||||
// Save the current value of active before setting the new state
|
||||
|
||||
_previouslyActive = _active;
|
||||
_active = FALSE;
|
||||
}
|
||||
|
||||
void Cmd::revert()
|
||||
{
|
||||
// Activate or deactivate, as necessary,
|
||||
// to return to the previous state
|
||||
|
||||
if ( _previouslyActive )
|
||||
activate();
|
||||
else
|
||||
deactivate();
|
||||
}
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
void Cmd::addToActivationList ( Cmd *cmd )
|
||||
{
|
||||
if ( !_activationList )
|
||||
_activationList = new CmdList();
|
||||
|
||||
_activationList->add ( cmd );
|
||||
}
|
||||
|
||||
void Cmd::addToDeactivationList ( Cmd *cmd )
|
||||
{
|
||||
if ( !_deactivationList )
|
||||
_deactivationList = new CmdList();
|
||||
|
||||
_deactivationList->add ( cmd );
|
||||
}
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
void Cmd::execute()
|
||||
{
|
||||
int i;
|
||||
|
||||
// If a command is inactive, it cannot be executed
|
||||
|
||||
if ( !_active )
|
||||
return;
|
||||
|
||||
|
||||
// Activate or deactivate the global theUndoCmd,
|
||||
// and remember the last command, as needed
|
||||
|
||||
if ( _hasUndo )
|
||||
{
|
||||
Cmd::_lastCmd = this;
|
||||
theUndoCmd->activate();
|
||||
}
|
||||
else
|
||||
{
|
||||
Cmd::_lastCmd = NULL;
|
||||
theUndoCmd->deactivate();
|
||||
}
|
||||
|
||||
// Process the commands that depend on this one
|
||||
|
||||
if ( _activationList )
|
||||
for ( i = 0; i < _activationList->size(); i++ )
|
||||
(*_activationList)[i]->activate();
|
||||
|
||||
if ( _deactivationList )
|
||||
for ( i = 0; i < _deactivationList->size(); i++ )
|
||||
(*_deactivationList)[i]->deactivate();
|
||||
|
||||
|
||||
// Call the derived class's doit member function to
|
||||
// perform the action represented by this object
|
||||
|
||||
doit();
|
||||
|
||||
}
|
||||
|
||||
void Cmd::undo()
|
||||
{
|
||||
int i;
|
||||
|
||||
// Call the derived class's undoit() member function.
|
||||
|
||||
undoit();
|
||||
|
||||
// The system only supports one level of undo, and this is it,
|
||||
// so deactivate the undo facility.
|
||||
|
||||
theUndoCmd->deactivate();
|
||||
|
||||
// Reverse the effects of the execute() member function by
|
||||
// reverting all dependent objects to their previous state
|
||||
|
||||
if ( _activationList )
|
||||
for ( i = 0; i < _activationList->size(); i++ )
|
||||
(*_activationList)[i]->revert();
|
||||
|
||||
if ( _deactivationList )
|
||||
for ( i = 0; i < _deactivationList->size(); i++ )
|
||||
(*_deactivationList)[i]->revert();
|
||||
}
|
||||
|
||||
#ifndef CAN_INLINE_VIRTUALS
|
||||
const char *const
|
||||
Cmd::className(void)
|
||||
{
|
||||
return "Cmd";
|
||||
}
|
||||
#endif /* ! CAN_INLINE_VIRTUALS */
|
||||
73
cde/programs/dtmail/MotifApp/CmdInterface.C
Normal file
73
cde/programs/dtmail/MotifApp/CmdInterface.C
Normal file
@@ -0,0 +1,73 @@
|
||||
/* $XConsortium: CmdInterface.C /main/4 1996/04/05 16:48:53 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// CmdInterface.C
|
||||
/////////////////////////////////////////////////////////
|
||||
#include "CmdInterface.h"
|
||||
#include "Cmd.h"
|
||||
|
||||
CmdInterface::CmdInterface ( Cmd *cmd ) : UIComponent( cmd->name() )
|
||||
{
|
||||
_active = TRUE;
|
||||
_cmd = cmd;
|
||||
cmd->registerInterface ( this );
|
||||
}
|
||||
|
||||
void CmdInterface::executeCmdCallback ( Widget,
|
||||
XtPointer clientData,
|
||||
XtPointer )
|
||||
{
|
||||
CmdInterface *obj = (CmdInterface *) clientData;
|
||||
|
||||
obj->_cmd->execute();
|
||||
}
|
||||
|
||||
void CmdInterface::activate()
|
||||
{
|
||||
if ( _w )
|
||||
XtSetSensitive ( _w, TRUE );
|
||||
_active = TRUE;
|
||||
}
|
||||
|
||||
void CmdInterface::deactivate()
|
||||
{
|
||||
if ( _w )
|
||||
XtSetSensitive ( _w, FALSE );
|
||||
_active = FALSE;
|
||||
}
|
||||
127
cde/programs/dtmail/MotifApp/CmdList.C
Normal file
127
cde/programs/dtmail/MotifApp/CmdList.C
Normal file
@@ -0,0 +1,127 @@
|
||||
/* $XConsortium: CmdList.C /main/3 1995/11/06 15:59:50 rswiston $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// CmdList.C: Maintain a list of Cmd objects
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// MODIFIED TO INHERIT FROM CMD - not described in Book
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "CmdList.h"
|
||||
|
||||
CmdList::CmdList() : Cmd("CmdList", "CmdList", 1)
|
||||
{
|
||||
_contents = 0;
|
||||
_numElements = 0;
|
||||
_pane = NULL;
|
||||
}
|
||||
|
||||
CmdList::CmdList(char *name, char *label ) : Cmd(name, label, 1)
|
||||
{
|
||||
// The list is initially empty
|
||||
|
||||
_contents = 0;
|
||||
_numElements = 0;
|
||||
}
|
||||
|
||||
CmdList::~CmdList()
|
||||
{
|
||||
// free the list
|
||||
|
||||
delete []_contents;
|
||||
}
|
||||
|
||||
void CmdList::add ( Cmd *cmd )
|
||||
{
|
||||
int i;
|
||||
Cmd **newList;
|
||||
|
||||
// CmdList can only be undone if all Cmds it contains can be undone
|
||||
|
||||
if(!cmd->hasUndo())
|
||||
_hasUndo = 0;
|
||||
|
||||
// Allocate a list large enough for one more element
|
||||
|
||||
newList = new Cmd*[_numElements + 1];
|
||||
|
||||
// Copy the contents of the previous list to
|
||||
// the new list
|
||||
|
||||
for( i = 0; i < _numElements; i++)
|
||||
newList[i] = _contents[i];
|
||||
|
||||
// Free the old list
|
||||
|
||||
if (_contents)
|
||||
delete []_contents;
|
||||
|
||||
// Make the new list the current list
|
||||
|
||||
_contents = newList;
|
||||
|
||||
// Add the command to the list and update the list size.
|
||||
|
||||
_contents[_numElements] = cmd;
|
||||
|
||||
_numElements++;
|
||||
}
|
||||
|
||||
Cmd *CmdList::operator[] ( int index )
|
||||
{
|
||||
// Return the indexed element
|
||||
|
||||
return _contents[index];
|
||||
}
|
||||
|
||||
|
||||
void CmdList::doit()
|
||||
{
|
||||
for( int i = 0; i < _numElements; i++)
|
||||
_contents[i]->execute();
|
||||
}
|
||||
|
||||
void CmdList::undoit()
|
||||
{
|
||||
if(_hasUndo)
|
||||
for( int i = _numElements - 1; i >=0; i--)
|
||||
_contents[i]->undo();
|
||||
}
|
||||
571
cde/programs/dtmail/MotifApp/DialogManager.C
Normal file
571
cde/programs/dtmail/MotifApp/DialogManager.C
Normal file
@@ -0,0 +1,571 @@
|
||||
/* $XConsortium: DialogManager.C /main/5 1996/04/21 19:32:05 drk $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: DialogManager.C /main/5 1996/04/21 19:32:05 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// DialogManager.C: Support cached dialog widgets
|
||||
//////////////////////////////////////////////////////////
|
||||
#include "DialogManager.h"
|
||||
#include "Application.h"
|
||||
#include <Xm/MessageB.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nl_types.h>
|
||||
extern nl_catd catd;
|
||||
|
||||
#include "NLS.hh"
|
||||
|
||||
DialogManager::DialogManager ( char *name ): UIComponent ( name )
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
Widget DialogManager::getDialog()
|
||||
{
|
||||
Widget newDialog = NULL;
|
||||
|
||||
// If the permanent widget exists and is not in use,
|
||||
// just return it
|
||||
|
||||
if ( _w && !XtIsManaged ( _w ) )
|
||||
return _w;
|
||||
|
||||
// Get a widget from the derived class
|
||||
|
||||
newDialog = createDialog ( theApplication->baseWidget() ) ;
|
||||
|
||||
// If this is a temporary dialog, install callbacks to
|
||||
// destroy it when the user pops it down.
|
||||
|
||||
if ( _w )
|
||||
{
|
||||
XtAddCallback ( newDialog,
|
||||
XmNokCallback,
|
||||
&DialogManager::destroyTmpDialogCallback,
|
||||
(XtPointer) this );
|
||||
|
||||
XtAddCallback ( newDialog,
|
||||
XmNcancelCallback,
|
||||
&DialogManager::destroyTmpDialogCallback,
|
||||
(XtPointer) this );
|
||||
}
|
||||
else // If this is the first dialog to be
|
||||
_w = newDialog; // created, save it to be used again.
|
||||
|
||||
return newDialog;
|
||||
}
|
||||
|
||||
Widget DialogManager::getDialog(
|
||||
Widget w
|
||||
)
|
||||
{
|
||||
Widget newDialog = NULL;
|
||||
|
||||
// If the permanent widget exists and is not in use,
|
||||
// just return it
|
||||
|
||||
if ( _w && !XtIsManaged ( _w ) )
|
||||
return _w;
|
||||
|
||||
// Get a widget from the derived class
|
||||
// Parent the dialog to the widget passed in
|
||||
|
||||
newDialog = createDialog (w);
|
||||
|
||||
// If this is a temporary dialog, install callbacks to
|
||||
// destroy it when the user pops it down.
|
||||
|
||||
if ( _w )
|
||||
{
|
||||
XtAddCallback ( newDialog,
|
||||
XmNokCallback,
|
||||
&DialogManager::destroyTmpDialogCallback,
|
||||
(XtPointer) this );
|
||||
|
||||
XtAddCallback ( newDialog,
|
||||
XmNcancelCallback,
|
||||
&DialogManager::destroyTmpDialogCallback,
|
||||
(XtPointer) this );
|
||||
}
|
||||
else // If this is the first dialog to be
|
||||
_w = newDialog; // created, save it to be used again.
|
||||
|
||||
return newDialog;
|
||||
}
|
||||
|
||||
void DialogManager::destroyTmpDialogCallback ( Widget w,
|
||||
XtPointer,
|
||||
XtPointer clientData)
|
||||
{
|
||||
XtDestroyWidget ( w );
|
||||
|
||||
// We must set the wiget handle to NULL to prevent multiple
|
||||
// destroys.
|
||||
((DialogManager *)clientData)->_w = NULL;
|
||||
}
|
||||
|
||||
Widget DialogManager::post (char *title,
|
||||
char *text,
|
||||
Widget wid,
|
||||
void *clientData,
|
||||
DialogCallback ok,
|
||||
DialogCallback cancel,
|
||||
DialogCallback help)
|
||||
{
|
||||
// Get a dialog widget from the cache
|
||||
|
||||
Widget dialog = getDialog(wid);
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( dialog != NULL );
|
||||
// assert ( XtIsSubclass ( dialog, xmMessageBoxWidgetClass ) );
|
||||
|
||||
// Convert the text string to a compound string and
|
||||
// specify this to be the message displayed in the dialog.
|
||||
|
||||
XmString titleStr = XmStringCreateLocalized (title);
|
||||
XmString xmstr = XmStringCreateLocalized ( text );
|
||||
XtVaSetValues ( dialog,
|
||||
XmNmessageString, xmstr,
|
||||
XmNdialogTitle, titleStr,
|
||||
NULL );
|
||||
XmStringFree ( xmstr );
|
||||
XmStringFree ( titleStr );
|
||||
|
||||
// Create an object to carry the additional data needed
|
||||
// to cache the dialogs.
|
||||
|
||||
DialogCallbackData *dcb = new DialogCallbackData( this,
|
||||
clientData,
|
||||
ok, cancel,
|
||||
help );
|
||||
// Install callback function for each button
|
||||
// support by Motif dialogs. If there is no help callback
|
||||
// unmanage the corresponding button instead, if possible.
|
||||
|
||||
if ( ok )
|
||||
XtAddCallback ( dialog,
|
||||
XmNokCallback,
|
||||
&DialogManager::okCallback,
|
||||
(XtPointer) dcb );
|
||||
else
|
||||
{
|
||||
Widget w = XmMessageBoxGetChild ( dialog,
|
||||
XmDIALOG_OK_BUTTON );
|
||||
XtUnmanageChild ( w );
|
||||
}
|
||||
|
||||
|
||||
if ( cancel )
|
||||
XtAddCallback ( dialog,
|
||||
XmNcancelCallback,
|
||||
&DialogManager::cancelCallback,
|
||||
(XtPointer) dcb );
|
||||
else
|
||||
{
|
||||
Widget w = XmMessageBoxGetChild ( dialog,
|
||||
XmDIALOG_CANCEL_BUTTON );
|
||||
XtUnmanageChild ( w );
|
||||
}
|
||||
|
||||
|
||||
if ( help )
|
||||
XtAddCallback ( dialog,
|
||||
XmNhelpCallback,
|
||||
&DialogManager::helpCallback,
|
||||
(XtPointer) dcb );
|
||||
else
|
||||
{
|
||||
Widget w = XmMessageBoxGetChild ( dialog,
|
||||
XmDIALOG_HELP_BUTTON );
|
||||
XtUnmanageChild ( w );
|
||||
}
|
||||
|
||||
// Post the dialog.
|
||||
|
||||
XtManageChild ( dialog );
|
||||
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
Widget DialogManager::post (char *title,
|
||||
char *text,
|
||||
void *clientData,
|
||||
DialogCallback ok,
|
||||
DialogCallback cancel,
|
||||
DialogCallback help)
|
||||
{
|
||||
// Get a dialog widget from the cache
|
||||
|
||||
Widget dialog = getDialog();
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( dialog != NULL );
|
||||
// assert ( XtIsSubclass ( dialog, xmMessageBoxWidgetClass ) );
|
||||
|
||||
// Convert the text string to a compound string and
|
||||
// specify this to be the message displayed in the dialog.
|
||||
|
||||
XmString titleStr = XmStringCreateLocalized (title);
|
||||
XmString xmstr = XmStringCreateLocalized ( text );
|
||||
XtVaSetValues ( dialog,
|
||||
XmNmessageString, xmstr,
|
||||
XmNdialogTitle, titleStr,
|
||||
NULL );
|
||||
XmStringFree ( xmstr );
|
||||
XmStringFree ( titleStr );
|
||||
|
||||
// Create an object to carry the additional data needed
|
||||
// to cache the dialogs.
|
||||
|
||||
DialogCallbackData *dcb = new DialogCallbackData( this,
|
||||
clientData,
|
||||
ok, cancel,
|
||||
help );
|
||||
// Install callback function for each button
|
||||
// support by Motif dialogs. If there is no help callback
|
||||
// unmanage the corresponding button instead, if possible.
|
||||
|
||||
if ( ok )
|
||||
XtAddCallback ( dialog,
|
||||
XmNokCallback,
|
||||
&DialogManager::okCallback,
|
||||
(XtPointer) dcb );
|
||||
else
|
||||
{
|
||||
Widget w = XmMessageBoxGetChild ( dialog,
|
||||
XmDIALOG_OK_BUTTON );
|
||||
XtUnmanageChild ( w );
|
||||
}
|
||||
|
||||
|
||||
if ( cancel )
|
||||
XtAddCallback ( dialog,
|
||||
XmNcancelCallback,
|
||||
&DialogManager::cancelCallback,
|
||||
(XtPointer) dcb );
|
||||
else
|
||||
{
|
||||
Widget w = XmMessageBoxGetChild ( dialog,
|
||||
XmDIALOG_CANCEL_BUTTON );
|
||||
XtUnmanageChild ( w );
|
||||
}
|
||||
|
||||
|
||||
if ( help )
|
||||
XtAddCallback ( dialog,
|
||||
XmNhelpCallback,
|
||||
&DialogManager::helpCallback,
|
||||
(XtPointer) dcb );
|
||||
else
|
||||
{
|
||||
Widget w = XmMessageBoxGetChild ( dialog,
|
||||
XmDIALOG_HELP_BUTTON );
|
||||
XtUnmanageChild ( w );
|
||||
}
|
||||
|
||||
// Post the dialog.
|
||||
|
||||
XtManageChild ( dialog );
|
||||
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
void DialogManager::okCallback ( Widget w,
|
||||
XtPointer clientData,
|
||||
XtPointer )
|
||||
{
|
||||
DialogCallbackData *dcd = (DialogCallbackData *) clientData;
|
||||
DialogManager *obj = (DialogManager *) dcd->dialogManager();
|
||||
DialogCallback callback;
|
||||
|
||||
// If caller specified an ok callback, call the function
|
||||
|
||||
if ( ( callback = dcd->ok() ) != NULL )
|
||||
( *callback )( dcd->clientData() );
|
||||
|
||||
// Reset for the next time
|
||||
|
||||
obj->cleanup ( w, dcd );
|
||||
}
|
||||
|
||||
void DialogManager::cancelCallback ( Widget w,
|
||||
XtPointer clientData,
|
||||
XtPointer )
|
||||
{
|
||||
DialogCallbackData *dcd = (DialogCallbackData *) clientData;
|
||||
DialogManager *obj = (DialogManager *) dcd->dialogManager();
|
||||
DialogCallback callback;
|
||||
|
||||
if ( ( callback = dcd->cancel() ) != NULL )
|
||||
( *callback )( dcd->clientData() );
|
||||
|
||||
obj->cleanup ( w, dcd );
|
||||
}
|
||||
|
||||
void DialogManager::helpCallback ( Widget w,
|
||||
XtPointer clientData,
|
||||
XtPointer )
|
||||
{
|
||||
DialogCallbackData *dcd = (DialogCallbackData *) clientData;
|
||||
DialogManager *obj = (DialogManager *) dcd->dialogManager();
|
||||
DialogCallback callback;
|
||||
|
||||
if ( ( callback = dcd->help() ) != NULL )
|
||||
( *callback )( dcd->clientData() );
|
||||
|
||||
obj->cleanup ( w, dcd );
|
||||
}
|
||||
|
||||
void DialogManager::cleanup ( Widget w, DialogCallbackData *dcd )
|
||||
{
|
||||
// Remove all callbacks to avoid having duplicate
|
||||
// callback functions installed.
|
||||
|
||||
XtRemoveCallback ( w,
|
||||
XmNokCallback,
|
||||
&DialogManager::okCallback,
|
||||
(XtPointer) dcd );
|
||||
|
||||
XtRemoveCallback ( w,
|
||||
XmNcancelCallback,
|
||||
&DialogManager::cancelCallback,
|
||||
(XtPointer) dcd );
|
||||
|
||||
XtRemoveCallback ( w,
|
||||
XmNhelpCallback,
|
||||
&DialogManager::helpCallback,
|
||||
(XtPointer) dcd );
|
||||
|
||||
// Delete the DialogCallbackData instance for this posting
|
||||
|
||||
delete dcd;
|
||||
}
|
||||
|
||||
void
|
||||
DialogManager::forceUpdate( Widget w )
|
||||
{
|
||||
Widget diashell, topshell;
|
||||
Window diawindow, topwindow;
|
||||
|
||||
Display *dpy;
|
||||
XWindowAttributes xwa;
|
||||
XEvent event;
|
||||
if ( !w )
|
||||
return;
|
||||
XtAppContext cxt=XtWidgetToApplicationContext( w );
|
||||
for (diashell=w;!XtIsShell(diashell);diashell=XtParent(diashell));
|
||||
for ( topshell=diashell;XtIsTopLevelShell( topshell );
|
||||
topshell = XtParent( topshell ) );
|
||||
|
||||
// if (XtIsRealized(diashell) && XtIsRealized(topshell)){
|
||||
dpy=XtDisplay(diashell);
|
||||
diawindow=XtWindow(diashell);
|
||||
topwindow=XtWindow(topshell);
|
||||
while ( XGetWindowAttributes(dpy,diawindow,&xwa) &&
|
||||
xwa.map_state != IsViewable && XEventsQueued(dpy,QueuedAlready)){
|
||||
// if ( XGetWindowAttributes( dpy, topwindow, &xwa ) &&
|
||||
// xwa.map_state != IsViewable )
|
||||
// break;
|
||||
XtAppNextEvent( cxt, &event );
|
||||
XtDispatchEvent( &event );
|
||||
}
|
||||
// }
|
||||
XmUpdateDisplay(topshell);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Added this extra functionality
|
||||
|
||||
void
|
||||
my_okCallback( int *data )
|
||||
{
|
||||
*data=1;
|
||||
}
|
||||
|
||||
void
|
||||
my_cancelCallback( int *data )
|
||||
{
|
||||
*data=2;
|
||||
}
|
||||
|
||||
int
|
||||
DialogManager::post_and_return(
|
||||
char *title_str,
|
||||
char *text_str,
|
||||
Widget wid
|
||||
)
|
||||
{
|
||||
int answer = 0;
|
||||
XmString okLabel, cancelLabel;
|
||||
|
||||
// They may have been set via the overloaded post_and_return()
|
||||
// method before. Reset them to their default values...
|
||||
|
||||
okLabel = XmStringCreateLocalized(GETMSG(catd, 1, 2, "OK"));
|
||||
cancelLabel = XmStringCreateLocalized(GETMSG(catd, 1, 3, "Cancel"));
|
||||
|
||||
Widget dlg = this->getDialog(wid);
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( dlg != NULL );
|
||||
|
||||
XtVaSetValues(dlg,
|
||||
XmNokLabelString, okLabel,
|
||||
XmNcancelLabelString, cancelLabel,
|
||||
NULL);
|
||||
|
||||
Widget dialog =
|
||||
this->post(title_str,
|
||||
text_str,
|
||||
wid,
|
||||
(void *) &answer,
|
||||
( DialogCallback ) &my_okCallback,
|
||||
( DialogCallback ) &my_cancelCallback);
|
||||
|
||||
forceUpdate( dialog );
|
||||
while ( answer==0 )
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
|
||||
// Process just one more event to pop down dialog.
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
|
||||
return(answer);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
DialogManager::post_and_return(
|
||||
char *title_str,
|
||||
char *text_str,
|
||||
char *okLabelString,
|
||||
Widget wid
|
||||
)
|
||||
{
|
||||
int answer = 0;
|
||||
XmString okLabel;
|
||||
|
||||
okLabel = XmStringCreateLocalized(okLabelString);
|
||||
|
||||
Widget dlg = this->getDialog(wid);
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( dlg != NULL );
|
||||
|
||||
XtVaSetValues(dlg,
|
||||
XmNokLabelString, okLabel,
|
||||
NULL);
|
||||
|
||||
Widget dialog = this->post(title_str,
|
||||
text_str,
|
||||
wid,
|
||||
(void *) &answer,
|
||||
( DialogCallback ) &my_okCallback);
|
||||
|
||||
forceUpdate( dialog );
|
||||
while ( answer==0 )
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
|
||||
// Process just one more event to pop down dialog.
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
|
||||
return(answer);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
DialogManager::post_and_return(
|
||||
char *title_str,
|
||||
char *text_str,
|
||||
char *okLabelString,
|
||||
char *cancelLabelString,
|
||||
Widget wid
|
||||
|
||||
)
|
||||
{
|
||||
int answer = 0;
|
||||
XmString okLabel, cancelLabel;
|
||||
|
||||
okLabel = XmStringCreateLocalized(okLabelString);
|
||||
cancelLabel = XmStringCreateLocalized(cancelLabelString);
|
||||
|
||||
Widget dlg = this->getDialog(wid);
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( dlg != NULL );
|
||||
|
||||
XtVaSetValues(dlg,
|
||||
XmNokLabelString, okLabel,
|
||||
XmNcancelLabelString, cancelLabel,
|
||||
NULL);
|
||||
|
||||
Widget dialog = this->post(title_str,
|
||||
text_str,
|
||||
wid,
|
||||
(void *) &answer,
|
||||
( DialogCallback ) &my_okCallback,
|
||||
( DialogCallback ) &my_cancelCallback);
|
||||
|
||||
forceUpdate( dialog );
|
||||
while ( answer==0 )
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
|
||||
// Process just one more event to pop down dialog.
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
|
||||
return(answer);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
478
cde/programs/dtmail/MotifApp/Help.C
Normal file
478
cde/programs/dtmail/MotifApp/Help.C
Normal file
@@ -0,0 +1,478 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: Help.C /main/7 1996/10/11 20:04:16 cde-hp $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <Xm/Xm.h>
|
||||
#include <Dt/HelpDialog.h>
|
||||
#include <Dt/HelpQuickD.h>
|
||||
#include <Dt/Help.h>
|
||||
#include <Dt/Editor.h>
|
||||
#include "Help.hh"
|
||||
|
||||
#include <nl_types.h>
|
||||
extern nl_catd catd;
|
||||
|
||||
#include "NLS.hh"
|
||||
|
||||
void DisplayMain( Widget, char *, char *);
|
||||
static Widget helpMain = NULL;
|
||||
static Widget helpError = NULL;
|
||||
static Widget versionMain = NULL;
|
||||
|
||||
Widget
|
||||
getErrorHelpWidget(void)
|
||||
{
|
||||
return (helpError);
|
||||
}
|
||||
|
||||
void
|
||||
clearErrorHelpWidget(void)
|
||||
{
|
||||
helpError = NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
getHelpId (Widget w)
|
||||
{
|
||||
char *helpId;
|
||||
char *buf;
|
||||
char *index;
|
||||
int i = 0, j = 0;
|
||||
|
||||
if (XtParent(w) == NULL) {
|
||||
helpId = (char *) malloc(1000);
|
||||
index = helpId;
|
||||
buf = XtName(w);
|
||||
while(*buf) {
|
||||
if (isalnum(*buf)) {
|
||||
*index++ = toupper(*buf);
|
||||
} else if ('_' == *buf) {
|
||||
*index++ = '-';
|
||||
}
|
||||
buf++;
|
||||
}
|
||||
*index++ = '\0';
|
||||
return (helpId);
|
||||
} else {
|
||||
helpId = getHelpId (XtParent(w));
|
||||
i = strlen(helpId);
|
||||
buf = XtName(w);
|
||||
while(*buf) {
|
||||
if (isalnum(*buf)) {
|
||||
helpId[i++] = toupper(*buf);
|
||||
} else if ('_' == *buf) {
|
||||
helpId[i++] = '-';
|
||||
}
|
||||
buf++;
|
||||
}
|
||||
helpId[i++] = '\0';
|
||||
return (helpId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DisplayVersion (
|
||||
Widget parent,
|
||||
char *helpVolume,
|
||||
char *locationId )
|
||||
{
|
||||
Arg args[10];
|
||||
int n;
|
||||
Widget printWidget;
|
||||
Widget helpWidget;
|
||||
|
||||
if (versionMain != NULL) {
|
||||
n = 0;
|
||||
XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 4,
|
||||
"DtMail Version Dialog")); n++;
|
||||
if (helpVolume != NULL) {
|
||||
XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
|
||||
}
|
||||
XtSetArg (args[n], DtNlocationId, locationId); n++;
|
||||
XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
|
||||
XtSetValues(versionMain, args, n);
|
||||
XtManageChild(versionMain);
|
||||
} else {
|
||||
while (!XtIsSubclass(parent, applicationShellWidgetClass))
|
||||
parent = XtParent(parent);
|
||||
|
||||
// Build a new one in our cached list
|
||||
n = 0;
|
||||
XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 5,
|
||||
"DtMail Version Dialog")); n++;
|
||||
if (helpVolume != NULL) {
|
||||
XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
|
||||
}
|
||||
XtSetArg (args[n], DtNlocationId, locationId); n++;
|
||||
XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
|
||||
versionMain = DtCreateQuickHelpDialog(parent, "versionWidget", args, n);
|
||||
XtAddCallback(versionMain, XmNokCallback,
|
||||
CloseMainCB, (XtPointer) versionMain);
|
||||
|
||||
// We do not want a print button for now so we unmap it
|
||||
printWidget = DtHelpQuickDialogGetChild (versionMain,
|
||||
DtHELP_QUICK_PRINT_BUTTON);
|
||||
XtUnmanageChild (printWidget);
|
||||
|
||||
// We do not want a help button for now so we unmap it
|
||||
|
||||
helpWidget = DtHelpQuickDialogGetChild (versionMain,
|
||||
DtHELP_QUICK_PRINT_BUTTON);
|
||||
XtUnmanageChild (helpWidget);
|
||||
XtManageChild(versionMain);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
// The callback for the Help Menu in the combo window.
|
||||
|
||||
void
|
||||
HelpMenuCB (
|
||||
Widget widget,
|
||||
XtPointer clientdata,
|
||||
XtPointer)
|
||||
{
|
||||
Widget selWidget = NULL;
|
||||
int status = DtHELP_SELECT_ERROR;
|
||||
|
||||
// Determine which help button was activated and display the
|
||||
// appropriate help information.
|
||||
|
||||
switch ((long) clientdata) {
|
||||
case HELP_ON_ITEM:
|
||||
while (!XtIsSubclass(widget, applicationShellWidgetClass))
|
||||
widget = XtParent(widget);
|
||||
status = DtHelpReturnSelectedWidgetId(widget, NULL, &selWidget);
|
||||
|
||||
switch ((int) status) {
|
||||
case DtHELP_SELECT_ERROR:
|
||||
printf(GETMSG(catd, 2, 1, "Selection Error, cannot continue\n"));
|
||||
break;
|
||||
case DtHELP_SELECT_VALID:
|
||||
while (selWidget != NULL) {
|
||||
if ((XtHasCallbacks(selWidget, XmNhelpCallback)
|
||||
== XtCallbackHasSome)) {
|
||||
XtCallCallbacks((Widget)selWidget,
|
||||
XmNhelpCallback, NULL);
|
||||
break;
|
||||
} else {
|
||||
selWidget = XtParent(selWidget);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DtHELP_SELECT_ABORT:
|
||||
printf(GETMSG(catd, 2, 2, "Selection aborted by user.\n"));
|
||||
break;
|
||||
case DtHELP_SELECT_INVALID:
|
||||
printf(GETMSG(catd, 1, 6,
|
||||
"You must select a component withing your app.\n"));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HELP_ON_TOPIC:
|
||||
DisplayMain(widget, NULL, APP_MENU_ID);
|
||||
break;
|
||||
case HELP_ON_VERSION:
|
||||
DisplayVersion(widget, NULL, VER_MENU_ID);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
|
||||
// Callback to process JUMP-NEW and APP-LINK hypertext requests in a
|
||||
// given Help Dialog Window.
|
||||
//
|
||||
// This is the callback used for the DtNhyperLinkCallback
|
||||
// on each of the help dialog widgets created.
|
||||
|
||||
static void
|
||||
ProcessLinkCB (
|
||||
Widget,
|
||||
XtPointer,
|
||||
XtPointer callData)
|
||||
{
|
||||
// Arg args[20];
|
||||
// Position xPos, yPos;
|
||||
int appLinkNum = 0;
|
||||
|
||||
DtHelpDialogCallbackStruct * hyperData =
|
||||
(DtHelpDialogCallbackStruct *) callData;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DisplayMain(
|
||||
Widget parent,
|
||||
char *helpVolume,
|
||||
char *locationId)
|
||||
{
|
||||
Arg args[10];
|
||||
int n;
|
||||
|
||||
if (helpMain != NULL) {
|
||||
n = 0;
|
||||
#ifdef undef
|
||||
XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 7, "DtMail Help")); n++;
|
||||
#endif
|
||||
XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 12, "Mailer : Help")); n++;
|
||||
if (helpVolume != NULL) {
|
||||
XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
|
||||
}
|
||||
XtSetArg (args[n], DtNlocationId, locationId); n++;
|
||||
XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
|
||||
XtSetValues (helpMain, args, n);
|
||||
XtUnmanageChild(helpMain);
|
||||
XtManageChild(helpMain);
|
||||
} else {
|
||||
while (!XtIsSubclass(parent, applicationShellWidgetClass))
|
||||
parent = XtParent(parent);
|
||||
|
||||
// Build a new one in our cached list
|
||||
n = 0;
|
||||
XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 12, "Mailer : Help")); n++;
|
||||
if (helpVolume != NULL) {
|
||||
XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
|
||||
}
|
||||
XtSetArg (args[n], DtNlocationId, locationId); n++;
|
||||
XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
|
||||
helpMain = DtCreateHelpDialog(parent, "Mailer", args, n);
|
||||
|
||||
XtAddCallback(helpMain, DtNhyperLinkCallback, ProcessLinkCB, NULL);
|
||||
XtAddCallback(
|
||||
helpMain,
|
||||
DtNcloseCallback, CloseMainCB, (XtPointer) helpMain);
|
||||
|
||||
XtManageChild(helpMain);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DisplayErrorHelp(
|
||||
Widget parent,
|
||||
char *helpVolume,
|
||||
char *locationId)
|
||||
{
|
||||
Arg args[10];
|
||||
int n;
|
||||
|
||||
if (helpError) {
|
||||
n = 0;
|
||||
#ifdef undef
|
||||
XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 7, "DtMail Help")); n++;
|
||||
#endif
|
||||
XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 12, "Mailer : Help")); n++;
|
||||
if (helpVolume != NULL) {
|
||||
XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
|
||||
}
|
||||
XtSetArg (args[n], DtNlocationId, locationId); n++;
|
||||
XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
|
||||
//XtSetArg (args[n], DtNlocationId, "DTMAILVIEWMAINWINDOWWORK-AREA"); n++;
|
||||
XtSetValues (helpError, args, n);
|
||||
XtManageChild(helpError);
|
||||
} else {
|
||||
|
||||
// Create a new help on the error dialogs each time, destroy it
|
||||
// when done.
|
||||
n = 0;
|
||||
#ifdef undef
|
||||
XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 8, "DtMail Help")); n++;
|
||||
#endif
|
||||
XtSetArg (args[n], XmNtitle, GETMSG(catd, 1, 12, "Mailer : Help")); n++;
|
||||
if (helpVolume != NULL) {
|
||||
XtSetArg (args[n], DtNhelpVolume, helpVolume); n++;
|
||||
}
|
||||
//XtSetArg (args[n], DtNlocationId, "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWCOLUMNPREVIOUS"); n++;
|
||||
XtSetArg (args[n], DtNlocationId, locationId); n++;
|
||||
XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
|
||||
helpError = DtCreateHelpDialog(parent, "Mailer", args, n);
|
||||
|
||||
XtAddCallback(helpError, DtNhyperLinkCallback, ProcessLinkCB, NULL);
|
||||
|
||||
XtAddCallback(helpError, DtNcloseCallback,
|
||||
CloseMainCB, (XtPointer) helpError);
|
||||
|
||||
XtUnmanageChild(helpError);
|
||||
XtManageChild(helpError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// The Help Callback for when the F1 key is pressed or when On Item
|
||||
// Help is selected from the Help menu.
|
||||
|
||||
void
|
||||
HelpCB (
|
||||
Widget w,
|
||||
XtPointer clientData,
|
||||
XtPointer)
|
||||
{
|
||||
char *locationId = (char *) clientData;
|
||||
|
||||
// printf("locationId = %s\n", locationId);
|
||||
// Just display the proper help based on the id string passed in.
|
||||
|
||||
// We pass in a NULL for our helpVolume and let the value defined
|
||||
// in the app-defaults file be used.
|
||||
|
||||
DisplayMain (w, "Mailer", locationId);
|
||||
}
|
||||
|
||||
void
|
||||
HelpErrorCB (
|
||||
Widget w,
|
||||
XtPointer clientData,
|
||||
XtPointer)
|
||||
{
|
||||
char *locationId = (char *) clientData;
|
||||
|
||||
// printf("locationId = %s\n", locationId);
|
||||
// Just display the proper help based on the id string passed in.
|
||||
|
||||
// We pass in a NULL for our helpVolume and let the value defined
|
||||
// in the app-defaults file be used.
|
||||
|
||||
DisplayErrorHelp (w, "Mailer", locationId);
|
||||
}
|
||||
|
||||
void
|
||||
HelpTexteditCB (
|
||||
Widget w,
|
||||
XtPointer clientData,
|
||||
XtPointer callData )
|
||||
{
|
||||
|
||||
char *locationId = NULL;
|
||||
Widget wEditor = (Widget) clientData;
|
||||
DtEditorHelpCallbackStruct *editorHelp =
|
||||
(DtEditorHelpCallbackStruct *) callData;
|
||||
|
||||
switch (editorHelp->reason) {
|
||||
|
||||
/* -----> edit area */
|
||||
case DtEDITOR_HELP_EDIT_WINDOW:
|
||||
locationId = EDIT_AREA_HELP;
|
||||
break;
|
||||
|
||||
/* -----> status line area and fields */
|
||||
case DtEDITOR_HELP_STATUS_LINE:
|
||||
locationId = STATUS_LINE_HELP;
|
||||
break;
|
||||
case DtEDITOR_HELP_STATUS_CURRENT_LINE:
|
||||
locationId = STATUS_CURRENT_LINE_HELP;
|
||||
break;
|
||||
case DtEDITOR_HELP_STATUS_TOTAL_LINES:
|
||||
locationId = STATUS_TOTAL_LINES_HELP;
|
||||
break;
|
||||
case DtEDITOR_HELP_STATUS_MESSAGE:
|
||||
locationId = STATUS_MESSAGE_HELP;
|
||||
break;
|
||||
case DtEDITOR_HELP_STATUS_OVERSTRIKE:
|
||||
locationId = STATUS_OVERSTRIKE_HELP;
|
||||
|
||||
/* -----> Format Settings dialog and dialog fields */
|
||||
case DtEDITOR_HELP_FORMAT_DIALOG:
|
||||
locationId = FORMAT_SETTINGS_HELP;
|
||||
break;
|
||||
case DtEDITOR_HELP_FORMAT_LEFT_MARGIN:
|
||||
locationId = FORMAT_LEFT_MARGIN_HELP;
|
||||
break;
|
||||
case DtEDITOR_HELP_FORMAT_RIGHT_MARGIN:
|
||||
locationId = FORMAT_RIGHT_MARGIN_HELP;
|
||||
break;
|
||||
case DtEDITOR_HELP_FORMAT_ALIGNMENT:
|
||||
locationId = FORMAT_ALIGNMENT_HELP;
|
||||
break;
|
||||
|
||||
/* -----> Find/Change dialog and dialog fields */
|
||||
case DtEDITOR_HELP_CHANGE_DIALOG:
|
||||
locationId = FINDCHANGE_HELP;
|
||||
break;
|
||||
case DtEDITOR_HELP_CHANGE_FIND:
|
||||
locationId = FINDCHANGE_FIND_HELP;
|
||||
break;
|
||||
case DtEDITOR_HELP_CHANGE_CHANGE:
|
||||
locationId = FINDCHANGE_CHANGETO_HELP;
|
||||
break;
|
||||
|
||||
/* -----> Check Spelling dialog and dialog fields */
|
||||
case DtEDITOR_HELP_SPELL_DIALOG:
|
||||
locationId = SPELL_HELP;
|
||||
break;
|
||||
case DtEDITOR_HELP_SPELL_MISSPELLED_WORDS:
|
||||
locationId = SPELL_MISSPELLED_WORDS_HELP;
|
||||
break;
|
||||
case DtEDITOR_HELP_SPELL_CHANGE:
|
||||
locationId = SPELL_CHANGETO_HELP;
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
|
||||
} /* switch (editorHelp->reason) */
|
||||
|
||||
DisplayMain (w, "Textedit", locationId);
|
||||
}
|
||||
|
||||
|
||||
// Callback to process close requests on our main help dialog.
|
||||
|
||||
static void
|
||||
CloseMainCB (
|
||||
Widget,
|
||||
XtPointer clientData,
|
||||
XtPointer)
|
||||
{
|
||||
Widget currentDialog = (Widget) clientData;
|
||||
|
||||
// Unmap and clean up help widget
|
||||
|
||||
XtUnmanageChild(currentDialog);
|
||||
}
|
||||
|
||||
#if defined(PRINT_HELPIDS)
|
||||
|
||||
void
|
||||
printHelpId (char *w_name, Widget w)
|
||||
{
|
||||
char *helpId;
|
||||
|
||||
helpId = getHelpId (w);
|
||||
printf("%s = %s\n", w_name, helpId);
|
||||
free(helpId);
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
printHelpId (char *, Widget)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
55
cde/programs/dtmail/MotifApp/IconifyCmd.C
Normal file
55
cde/programs/dtmail/MotifApp/IconifyCmd.C
Normal file
@@ -0,0 +1,55 @@
|
||||
/* $XConsortium: IconifyCmd.C /main/3 1995/11/06 16:00:15 rswiston $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// IconifyCmd.C: Iconify all windows in a MotifApp application.
|
||||
////////////////////////////////////////////////////////////////
|
||||
#include "IconifyCmd.h"
|
||||
#include "Application.h"
|
||||
|
||||
IconifyCmd::IconifyCmd ( char *name, char *label, int active ) :
|
||||
NoUndoCmd ( name, label, active )
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
|
||||
void IconifyCmd::doit()
|
||||
{
|
||||
theApplication->iconify(); // Close all top-level windows
|
||||
}
|
||||
83
cde/programs/dtmail/MotifApp/Imakefile
Normal file
83
cde/programs/dtmail/MotifApp/Imakefile
Normal file
@@ -0,0 +1,83 @@
|
||||
XCOMM $TOG: Imakefile /main/8 1998/08/05 13:24:05 mgreess $
|
||||
#define DoNormalLib YES
|
||||
#define DoSharedLib NO
|
||||
#define DoDebugLib NO
|
||||
#define DoProfileLib NO
|
||||
#define LibName MotifApp
|
||||
#define LibHeaders NO
|
||||
|
||||
#define CplusplusSource YES
|
||||
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
|
||||
|
||||
#include <Threads.tmpl>
|
||||
|
||||
INCLUDES = -I../include/MotifApp -I../include -I../include/utils
|
||||
|
||||
#ifndef DtMailDefines
|
||||
# define DtMailDefines
|
||||
#endif
|
||||
DEFINES = DtMailDefines
|
||||
|
||||
#ifdef HPArchitecture
|
||||
EXTRA_C++OPTIONS = +p
|
||||
#endif
|
||||
|
||||
#ifdef SunArchitecture
|
||||
# ifdef USE_SPRO_V3
|
||||
SPRO_V3_OPTIONS = -noex -xO0 -USPRO_V2
|
||||
# ifdef DEBUGTREE
|
||||
SPRO_V3_OPTIONS += -xsb
|
||||
# endif
|
||||
# endif
|
||||
|
||||
EXTRA_C++OPTIONS = -xF +p +w $(SPRO_V3_OPTIONS)
|
||||
|
||||
#endif /* SunArchitecture */
|
||||
|
||||
HEADERS =
|
||||
|
||||
SRCS = \
|
||||
Application.C AskFirstCmd.C \
|
||||
BasicComponent.C BusyPixmap.C \
|
||||
ButtonInterface.C Cmd.C \
|
||||
CmdInterface.C CmdList.C \
|
||||
DialogManager.C Help.C \
|
||||
IconifyCmd.C InfoDialogManager.C \
|
||||
InterruptibleCmd.C Main.C \
|
||||
MainWindow.C ManageCmd.C \
|
||||
MenuBar.C MenuWindow.C \
|
||||
MotifCmds.C NoUndoCmd.C \
|
||||
PixmapCycler.C PromptDialogManager.C \
|
||||
QuestionDialogManager.C QuitCmd.C \
|
||||
ScrollingList.C SelectFileCmd.C \
|
||||
ToggleButtonInterface.C UIComponent.C \
|
||||
UndoCmd.C WarnNoUndoCmd.C \
|
||||
WorkingDialogManager.C
|
||||
|
||||
OBJS = \
|
||||
Application.o AskFirstCmd.o \
|
||||
BasicComponent.o BusyPixmap.o \
|
||||
ButtonInterface.o Cmd.o \
|
||||
CmdInterface.o CmdList.o \
|
||||
DialogManager.o Help.o \
|
||||
IconifyCmd.o InfoDialogManager.o \
|
||||
InterruptibleCmd.o Main.o \
|
||||
MainWindow.o ManageCmd.o \
|
||||
MenuBar.o MenuWindow.o \
|
||||
MotifCmds.o NoUndoCmd.o \
|
||||
PixmapCycler.o PromptDialogManager.o \
|
||||
QuestionDialogManager.o QuitCmd.o \
|
||||
ScrollingList.o SelectFileCmd.o \
|
||||
ToggleButtonInterface.o UIComponent.o \
|
||||
UndoCmd.o WarnNoUndoCmd.o \
|
||||
WorkingDialogManager.o
|
||||
|
||||
#include <Library.tmpl>
|
||||
|
||||
DependTarget()
|
||||
|
||||
#ifdef SunArchitecture
|
||||
clean::
|
||||
$(RM) -r .sb
|
||||
$(RM) .make.state*
|
||||
#endif
|
||||
61
cde/programs/dtmail/MotifApp/InfoDialogManager.C
Normal file
61
cde/programs/dtmail/MotifApp/InfoDialogManager.C
Normal file
@@ -0,0 +1,61 @@
|
||||
/* $XConsortium: InfoDialogManager.C /main/3 1996/04/21 19:32:17 drk $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// InfoDialogManager.C:
|
||||
//////////////////////////////////////////////////////////
|
||||
#include "InfoDialogManager.h"
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/MessageB.h>
|
||||
|
||||
DialogManager *theInfoDialogManager =
|
||||
new InfoDialogManager ( "InformationDialog" );
|
||||
|
||||
InfoDialogManager::InfoDialogManager ( char *name ) :
|
||||
DialogManager ( name )
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
Widget InfoDialogManager::createDialog ( Widget parent )
|
||||
{
|
||||
Widget dialog = XmCreateInformationDialog ( parent, _name, NULL, 0 );
|
||||
|
||||
return dialog;
|
||||
}
|
||||
186
cde/programs/dtmail/MotifApp/InterruptibleCmd.C
Normal file
186
cde/programs/dtmail/MotifApp/InterruptibleCmd.C
Normal file
@@ -0,0 +1,186 @@
|
||||
/* $XConsortium: InterruptibleCmd.C /main/3 1995/11/06 16:00:32 rswiston $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// InterruptibleCmd.C: Abstract class that supports lengthy,
|
||||
// user-interruptible activities
|
||||
//////////////////////////////////////////////////////////////
|
||||
#include "InterruptibleCmd.h"
|
||||
#include "WorkingDialogManager.h"
|
||||
#include "Application.h"
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/MessageB.h>
|
||||
#include <assert.h>
|
||||
extern forceUpdate( Widget );
|
||||
InterruptibleCmd::InterruptibleCmd ( char *name, char *label, int active ) :
|
||||
NoUndoCmd ( name, label, active )
|
||||
{
|
||||
_wpId = NULL; // There is no work procedure yet
|
||||
_callback = NULL; // Callbacks are specified in execute()
|
||||
_clientData = NULL;
|
||||
_done = FALSE;
|
||||
}
|
||||
|
||||
InterruptibleCmd::~InterruptibleCmd()
|
||||
{
|
||||
// Clean up by removing all callbacks
|
||||
|
||||
if ( _wpId)
|
||||
XtRemoveWorkProc ( _wpId );
|
||||
}
|
||||
|
||||
void InterruptibleCmd::execute ( TaskDoneCallback callback, void *clientData )
|
||||
{
|
||||
_callback = callback;
|
||||
_clientData = clientData;
|
||||
execute();
|
||||
}
|
||||
|
||||
void InterruptibleCmd::execute()
|
||||
{
|
||||
char *name_str;
|
||||
char *label_str;
|
||||
|
||||
name_str = (char *) name();
|
||||
label_str = (char *) getLabel();
|
||||
|
||||
_done = FALSE; // Initialize flag
|
||||
|
||||
// Call the Cmd execute function to handle the Undo, and other
|
||||
// general mechanisms supported by Cmd. Execute calls doit()
|
||||
|
||||
Cmd::execute();
|
||||
|
||||
// If the task was completed in a single call,
|
||||
// don't bother to set up a work procedure. Just
|
||||
// give derived classes a chance to cleanup and
|
||||
// call the application's callback function
|
||||
|
||||
if ( _done )
|
||||
{
|
||||
cleanup();
|
||||
|
||||
if ( _callback )
|
||||
( *_callback )( this, FALSE, _clientData );
|
||||
}
|
||||
|
||||
// If the task is not done, post a WorkingDialog and
|
||||
// install a work procedure to continue the task
|
||||
// as soon as possible.
|
||||
|
||||
if ( !_done )
|
||||
{
|
||||
theWorkingDialogManager->post (label_str,
|
||||
"Fetching" ,
|
||||
(void *) this,
|
||||
NULL,
|
||||
&InterruptibleCmd::interruptCallback );
|
||||
|
||||
_wpId = XtAppAddWorkProc ( theApplication->appContext(),
|
||||
&InterruptibleCmd::workProcCallback,
|
||||
(XtPointer) this );
|
||||
}
|
||||
}
|
||||
|
||||
Boolean InterruptibleCmd::workProcCallback ( XtPointer clientData )
|
||||
{
|
||||
InterruptibleCmd *obj = (InterruptibleCmd *) clientData;
|
||||
|
||||
// The work procedure just returns the value returned by the
|
||||
// workProc member function.
|
||||
|
||||
return ( obj->workProc() );
|
||||
}
|
||||
|
||||
Boolean InterruptibleCmd::workProc()
|
||||
{
|
||||
doit();
|
||||
|
||||
// If the task has been completed, hide the dialog,
|
||||
// give the derived class a chance to clean up, and notify
|
||||
// the application that instantiated this object.
|
||||
|
||||
if ( _done )
|
||||
{
|
||||
theWorkingDialogManager->unpost();
|
||||
cleanup();
|
||||
|
||||
if ( _callback )
|
||||
( *_callback )( this, FALSE, _clientData );
|
||||
}
|
||||
|
||||
return _done;
|
||||
}
|
||||
|
||||
void InterruptibleCmd::cleanup()
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
void InterruptibleCmd::interruptCallback ( void * clientData )
|
||||
{
|
||||
InterruptibleCmd *obj = ( InterruptibleCmd * ) clientData;
|
||||
|
||||
// Just set the _interrupt flag to TRUE. The workProc()
|
||||
// function will notice the next time it is called
|
||||
|
||||
obj->interrupt();
|
||||
}
|
||||
|
||||
void InterruptibleCmd::interrupt()
|
||||
{
|
||||
// Remove the work procedure
|
||||
|
||||
XtRemoveWorkProc ( _wpId );
|
||||
|
||||
// Remove the working dialog and give derived
|
||||
// classes a chance to clean up
|
||||
|
||||
theWorkingDialogManager->unpost();
|
||||
cleanup();
|
||||
|
||||
// Notify the application that the task was interrupted
|
||||
|
||||
if ( _callback )
|
||||
( *_callback )( this, TRUE, _clientData);
|
||||
}
|
||||
|
||||
void InterruptibleCmd::updateMessage ( char * msg )
|
||||
{
|
||||
theWorkingDialogManager->updateMessage ( msg );
|
||||
}
|
||||
103
cde/programs/dtmail/MotifApp/Main.C
Normal file
103
cde/programs/dtmail/MotifApp/Main.C
Normal file
@@ -0,0 +1,103 @@
|
||||
/* $XConsortium: Main.C /main/5 1996/10/17 17:00:51 drk $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: Main.C /main/5 1996/10/17 17:00:51 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// Main.C: Generic main program used by all applications
|
||||
//////////////////////////////////////////////////////////
|
||||
#include "Application.h"
|
||||
#include <assert.h>
|
||||
|
||||
// We can implement main() in the library because the
|
||||
// framework completely encapsulates all Xt boilerplate
|
||||
// and all central flow of control.
|
||||
|
||||
|
||||
#ifdef _AIX
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
static struct sigaction action;
|
||||
|
||||
void _signal( int Sig )
|
||||
{
|
||||
if ( getenv( "_ILS_DEBUG_" ) ) {
|
||||
printf( "Got signal[%d]. Generate full core...\n", Sig );
|
||||
sigaction( SIGIOT, NULL, &action );
|
||||
action.sa_flags |= SA_FULLDUMP;
|
||||
action.sa_flags &= ~SA_PARTDUMP;
|
||||
sigaction( SIGIOT, &action, NULL );
|
||||
abort();
|
||||
}
|
||||
}
|
||||
#endif /* _AIX */
|
||||
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
|
||||
#ifdef _AIX
|
||||
//
|
||||
// With Defect 174851, a lot of codes are changed to make dtmail i18n'ze.
|
||||
// Especially, dtmail allocates the memory dynamically to convert the mail
|
||||
// body. Therefore, I believe no defects there, but it will cause the
|
||||
// potential coredump. If coredump will happen, to get the FULLCORE image,
|
||||
// please set // _ILS_DEBUG_ environment variable on, like
|
||||
// export _ILS_DEBUG_=:
|
||||
// dtmail
|
||||
// and do the same operation as that of when coredump will have occured.
|
||||
// If the signal will be received, dtmail generates full core dump image.
|
||||
// Note: This core file size will be big. So be aware of "ulimit" of sh.
|
||||
//
|
||||
if ( getenv( "_ILS_DEBUG_" ) )
|
||||
(void)signal( SIGILL|SIGIOT|SIGKILL|SIGBUS|SIGSEGV, _signal );
|
||||
#endif /* _AIX */
|
||||
|
||||
// Make sure the programmer has remembered to
|
||||
// instantiate an Application object
|
||||
|
||||
assert ( theApplication != NULL );
|
||||
|
||||
// Init Intrinsics, build all windows, and enter event loop
|
||||
|
||||
theApplication->initialize ( &argc, argv );
|
||||
|
||||
theApplication->handleEvents();
|
||||
return(0);
|
||||
}
|
||||
659
cde/programs/dtmail/MotifApp/MainWindow.C
Normal file
659
cde/programs/dtmail/MotifApp/MainWindow.C
Normal file
@@ -0,0 +1,659 @@
|
||||
/* $TOG: MainWindow.C /main/13 1998/04/06 13:22:40 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: MainWindow.C /main/13 1998/04/06 13:22:40 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993, 1994, 1995 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// MainWindow.C: Support a toplevel window
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <Xm/Protocols.h>
|
||||
#include <Xm/AtomMgr.h>
|
||||
#include <Xm/MainW.h>
|
||||
#include <Dt/Wsm.h>
|
||||
#include <Dt/Session.h>
|
||||
#include <DtMail/IO.hh>
|
||||
#include <X11/Shell.h>
|
||||
#include <X11/Xmu/Editres.h>
|
||||
#include "Application.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Help.hh"
|
||||
|
||||
// The following headers are private to CDE and should NOT be required
|
||||
// but unfortunately are.
|
||||
//
|
||||
extern "C" {
|
||||
#include <Dt/HourGlass.h>
|
||||
}
|
||||
#include <Dt/Icon.h>
|
||||
#include <Dt/IconP.h>
|
||||
#include <Dt/IconFile.h>
|
||||
|
||||
// This is a private CDE function that should be public, but is not,
|
||||
// and does not even have a prototype in a header. Yes, it is required.
|
||||
//
|
||||
extern "C" Pixmap _DtGetMask(Screen * screen, char * image_name);
|
||||
|
||||
#if 0
|
||||
static const char * DefaultIcon = "Dtablnk";
|
||||
#endif
|
||||
static const unsigned long FLASH_INTERVAL = 250; // milliseconds
|
||||
|
||||
MainWindow::MainWindow( char *name, Boolean allowResize ) : UIComponent ( name )
|
||||
{
|
||||
_workArea = NULL;
|
||||
_flashing = 0;
|
||||
_icon_invert = NULL;
|
||||
_window_invert = NULL;
|
||||
_icon = 0;
|
||||
_allow_resize = allowResize;
|
||||
|
||||
assert ( theApplication != NULL ); // Application object must exist
|
||||
// before any MainWindow object
|
||||
theApplication->registerWindow ( this );
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::initialize( )
|
||||
{
|
||||
char *appWorkspaces;
|
||||
|
||||
// All toplevel windows in the MotifApp framework are
|
||||
// implemented as a popup shell off the Application's
|
||||
// base widget.
|
||||
//
|
||||
// XmNdeleteResponse is being set to DO_NOTHING so
|
||||
// that the user can Cancel their close request.
|
||||
|
||||
_w = XtVaCreatePopupShell ( _name,
|
||||
topLevelShellWidgetClass,
|
||||
theApplication->baseWidget(),
|
||||
XmNdeleteResponse, XmDO_NOTHING,
|
||||
XmNallowShellResize, _allow_resize,
|
||||
NULL, 0 );
|
||||
|
||||
#ifdef USE_EDITRES
|
||||
XtAddEventHandler(
|
||||
_w, (EventMask) 0, True,
|
||||
(XtEventHandler) _XEditResCheckMessages, NULL);
|
||||
#endif
|
||||
|
||||
installDestroyHandler();
|
||||
|
||||
// Use a Motif XmMainWindow widget to handle window layout
|
||||
|
||||
_main = XtCreateManagedWidget ( "mainWindow",
|
||||
xmMainWindowWidgetClass,
|
||||
_w,
|
||||
NULL, 0 );
|
||||
printHelpId("_main", _main);
|
||||
/* install callback */
|
||||
// XtAddCallback(_main, XmNhelpCallback, HelpCB, helpId);
|
||||
XtAddCallback(_main, XmNhelpCallback,
|
||||
HelpCB, "_HOMETOPIC");
|
||||
|
||||
// Called derived class to create the work area
|
||||
|
||||
_workArea = createWorkArea ( _main );
|
||||
assert ( _workArea != NULL );
|
||||
|
||||
// Designate the _workArea widget as the XmMainWindow
|
||||
// widget's XmNworkWindow widget
|
||||
|
||||
XtVaSetValues ( _main,
|
||||
XmNworkWindow, _workArea,
|
||||
NULL );
|
||||
|
||||
Atom WM_DELETE_WINDOW=XmInternAtom( XtDisplay( _w ),
|
||||
"WM_DELETE_WINDOW",
|
||||
False );
|
||||
|
||||
XmAddWMProtocolCallback( _w,
|
||||
WM_DELETE_WINDOW,
|
||||
( XtCallbackProc ) quitCallback,
|
||||
this );
|
||||
|
||||
#if 0
|
||||
// Why are we setting the icon to Dtablnk. This is simply going to
|
||||
// be overriden by some other function setting it to the appropriate
|
||||
// icon.
|
||||
setIconName(DefaultIcon);
|
||||
#endif
|
||||
|
||||
_window_invert = NULL;
|
||||
_last_state = 0;
|
||||
_flash_owin = (Window) NULL;
|
||||
_flash_iwin = (Window) NULL;
|
||||
memset((char*) &(this->_window_attributes), 0, sizeof(XWindowAttributes));
|
||||
|
||||
// Manage the work area if the derived class hasn't already.
|
||||
|
||||
if ( !XtIsManaged ( _workArea ) )
|
||||
XtManageChild ( _workArea );
|
||||
|
||||
XtRealizeWidget(_w);
|
||||
appWorkspaces = theApplication->getAppWorkspaceList();
|
||||
setWorkspacesOccupied(appWorkspaces);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow( )
|
||||
{
|
||||
// Unregister this window with the Application object
|
||||
|
||||
if (_w) {
|
||||
Atom WM_DELETE_WINDOW=XmInternAtom( XtDisplay( _w ),
|
||||
"WM_DELETE_WINDOW",
|
||||
False );
|
||||
XmRemoveWMProtocolCallback( _w,
|
||||
WM_DELETE_WINDOW,
|
||||
( XtCallbackProc ) quitCallback,
|
||||
NULL );
|
||||
|
||||
if (_icon_invert) XFreeGC(XtDisplay(_w), _icon_invert);
|
||||
if (_window_invert) XFreeGC(XtDisplay(_w), _window_invert);
|
||||
if (_flash_iwin != (Window) NULL)
|
||||
XDestroyWindow( XtDisplay(_w), _flash_iwin );
|
||||
if (_flash_owin != (Window) NULL)
|
||||
XDestroyWindow( XtDisplay(_w), _flash_owin );
|
||||
}
|
||||
|
||||
theApplication->unregisterWindow ( this );
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::enableWorkAreaResize()
|
||||
{
|
||||
XtVaSetValues(_workArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::disableWorkAreaResize()
|
||||
{
|
||||
XtVaSetValues(_workArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::manage()
|
||||
{
|
||||
assert ( _w != NULL );
|
||||
XtPopup ( _w, XtGrabNone );
|
||||
|
||||
// Map the window, in case the window is iconified
|
||||
|
||||
if ( XtIsRealized ( _w ) )
|
||||
XMapRaised ( XtDisplay ( _w ), XtWindow ( _w ) );
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::unmanage()
|
||||
{
|
||||
assert ( _w != NULL );
|
||||
XtPopdown ( _w );
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::iconify()
|
||||
{
|
||||
assert ( _w != NULL );
|
||||
|
||||
// Set the widget to have an initial iconic state
|
||||
// in case the base widget has not yet been realized
|
||||
|
||||
XtVaSetValues ( _w, XmNiconic, TRUE, NULL );
|
||||
|
||||
// If the widget has already been realized,
|
||||
// iconify the window
|
||||
|
||||
if ( XtIsRealized ( _w ) )
|
||||
XIconifyWindow ( XtDisplay ( _w ), XtWindow ( _w ), 0 );
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::setIconTitle(const char * title)
|
||||
{
|
||||
XtVaSetValues(_w, XmNiconName, title, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::setIconName(const char * path)
|
||||
{
|
||||
char * icon_filename = XmGetIconFileName(XtScreen(_w),
|
||||
NULL,
|
||||
(char *)path, // Bug!
|
||||
NULL,
|
||||
DtLARGE);
|
||||
|
||||
if (icon_filename == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Pixel fg = 0, bg = 0;
|
||||
|
||||
getIconColors(fg, bg);
|
||||
|
||||
_icon = XmGetPixmap(XtScreen(_w),
|
||||
icon_filename,
|
||||
fg, bg);
|
||||
|
||||
Pixmap icon_mask_map = _DtGetMask(XtScreen(_w), icon_filename);
|
||||
|
||||
if (!_icon || !icon_mask_map) {
|
||||
return;
|
||||
}
|
||||
|
||||
XtVaSetValues(_w,
|
||||
XmNiconPixmap, _icon,
|
||||
XmNiconMask, icon_mask_map,
|
||||
NULL);
|
||||
|
||||
// Build the inverted icon mask for flashing.
|
||||
//
|
||||
if (_icon_invert) {
|
||||
XFreeGC(XtDisplay(_w), _icon_invert);
|
||||
}
|
||||
|
||||
XGCValues gc_vals;
|
||||
|
||||
gc_vals.foreground = bg;
|
||||
gc_vals.function = GXxor;
|
||||
_icon_invert = XCreateGC(XtDisplay(_w), _icon, GCForeground | GCFunction,
|
||||
&gc_vals);
|
||||
|
||||
XtFree(icon_filename);
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::busyCursor()
|
||||
{
|
||||
// Do nothing if the widget has not been realized
|
||||
|
||||
if (XtIsRealized(_w)) {
|
||||
_DtTurnOnHourGlass(_w);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::normalCursor()
|
||||
{
|
||||
// Do nothing if the widget has not been realized
|
||||
|
||||
if (XtIsRealized ( _w ))
|
||||
{
|
||||
_DtTurnOffHourGlass(_w);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::setStatus(const char *)
|
||||
{
|
||||
// Noop in our case.
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::clearStatus(void)
|
||||
{
|
||||
// Noop in our case.
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::title(const char *text )
|
||||
{
|
||||
XtVaSetValues ( _w, XmNtitle, (char *)text, NULL );
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::quitCallback( Widget,
|
||||
XtPointer clientData,
|
||||
XmAnyCallbackStruct *)
|
||||
{
|
||||
MainWindow *window=( MainWindow *) clientData;
|
||||
window->quit();
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::getIconColors(Pixel & fore, Pixel & back)
|
||||
{
|
||||
XtVaGetValues (_w,
|
||||
XmNforeground, &fore,
|
||||
XmNbackground, &back,
|
||||
NULL);
|
||||
}
|
||||
|
||||
struct WM_STATE {
|
||||
int state;
|
||||
Window icon;
|
||||
};
|
||||
|
||||
static int
|
||||
getWindowState(Widget w)
|
||||
{
|
||||
Atom wmStateAtom, actualType;
|
||||
int actualFormat;
|
||||
int retval;
|
||||
unsigned long nitems, leftover;
|
||||
WM_STATE *wmState;
|
||||
|
||||
/* Getting the WM_STATE property to see if iconified or not */
|
||||
wmStateAtom = XInternAtom(XtDisplay(w), "WM_STATE", False);
|
||||
|
||||
XGetWindowProperty (XtDisplay(w), XtWindow(w),
|
||||
wmStateAtom, 0L,
|
||||
(long)BUFSIZ, False, wmStateAtom, &actualType,
|
||||
&actualFormat, &nitems, &leftover,
|
||||
(unsigned char **) &wmState);
|
||||
|
||||
if (wmState)
|
||||
retval = wmState->state;
|
||||
else
|
||||
retval = 0;
|
||||
|
||||
free((void*) wmState);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::flash(const int count)
|
||||
{
|
||||
XWindowAttributes window_attributes;
|
||||
|
||||
if (count == 0) return;
|
||||
if (_flashing > 0) return;
|
||||
|
||||
if (_window_invert == NULL) {
|
||||
// Create a GC to flash the window.
|
||||
//
|
||||
XGCValues gc_vals;
|
||||
Pixel fg, bg;
|
||||
getIconColors(fg, bg);
|
||||
|
||||
gc_vals.foreground = bg;
|
||||
gc_vals.function = GXxor;
|
||||
_window_invert = XCreateGC(XtDisplay(_w), XtWindow(_w),
|
||||
GCForeground | GCFunction, &gc_vals);
|
||||
XSetSubwindowMode(XtDisplay(_w), _window_invert, IncludeInferiors);
|
||||
}
|
||||
|
||||
_last_state = getWindowState(_w);
|
||||
|
||||
//
|
||||
// The original method here, to invert the window and timeout
|
||||
// before inverting back to the original (pixels), breaks when
|
||||
// the window is left with pixels XOR'd in the flash ON state.
|
||||
//
|
||||
// One quick fix, uses a transparent window (or windows) on top
|
||||
// of the window to be flashed. The temp window(s) are used to
|
||||
// prevent updates while flash is ON and/or cause a full update
|
||||
// (expose) after each flash.
|
||||
//
|
||||
// First, (this part optional) put an "InputOnly" window on top of
|
||||
// the window to be flashed and ignore all events to this window.
|
||||
// This has the effect of preventing user input (events) from
|
||||
// causing application updates to the window. This temp window
|
||||
// can be left up (with the wait cursor) until flashing is done.
|
||||
//
|
||||
// Next, handle expose events by using a transparent "InputOutput"
|
||||
// window on top of everything only when flash is ON. This has
|
||||
// the effect of preventing expose events from causing application
|
||||
// updates to the real window when flash is ON. It especially,
|
||||
// ensures other problems (e.g. updates to the window caused by
|
||||
// other application timeout events and overlapping window pixels
|
||||
// from an expose event) are cleaned up by an expose event when
|
||||
// this temp window is unmapped or destroyed (between each flash).
|
||||
//
|
||||
|
||||
XGetWindowAttributes(XtDisplay(_w), XtWindow(_w), &window_attributes);
|
||||
|
||||
if ((Window) NULL != _flash_owin &&
|
||||
(window_attributes.width != _window_attributes.width ||
|
||||
window_attributes.height != _window_attributes.height ||
|
||||
window_attributes.border_width != _window_attributes.border_width))
|
||||
{
|
||||
XDestroyWindow( XtDisplay(_w), _flash_iwin );
|
||||
XDestroyWindow( XtDisplay(_w), _flash_owin );
|
||||
_flash_iwin = (Window) NULL;
|
||||
_flash_owin = (Window) NULL;
|
||||
}
|
||||
|
||||
if ((Window) NULL == _flash_owin)
|
||||
{
|
||||
XSetWindowAttributes sw_attr;
|
||||
|
||||
memcpy((char*) &(this->_window_attributes),
|
||||
(char*) &window_attributes,
|
||||
sizeof(window_attributes));
|
||||
|
||||
sw_attr.event_mask = 0;
|
||||
_flash_iwin = XCreateWindow(
|
||||
XtDisplay(_w), XtWindow(_w), 0, 0,
|
||||
_window_attributes.width, _window_attributes.height,
|
||||
_window_attributes.border_width, (int) CopyFromParent,
|
||||
InputOnly, CopyFromParent,
|
||||
CWEventMask, &sw_attr );
|
||||
XMapWindow( XtDisplay(_w), _flash_iwin );
|
||||
_flash_owin = XCreateWindow(
|
||||
XtDisplay(_w), XtWindow(_w), 0, 0,
|
||||
_window_attributes.width, _window_attributes.height,
|
||||
_window_attributes.border_width, (int) CopyFromParent,
|
||||
InputOutput, CopyFromParent,
|
||||
CWEventMask, &sw_attr );
|
||||
}
|
||||
|
||||
_flashing = count * 2;
|
||||
XtAppAddTimeOut(
|
||||
XtWidgetToApplicationContext(_w),
|
||||
FLASH_INTERVAL, flashCallback, this);
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::flashCallback(XtPointer client_data, XtIntervalId * interval_id)
|
||||
{
|
||||
MainWindow * mw = (MainWindow *)client_data;
|
||||
|
||||
mw->doFlash(interval_id);
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::doFlash(XtIntervalId *)
|
||||
{
|
||||
static int busy_cursor = 0;
|
||||
int state = getWindowState(_w);
|
||||
|
||||
// We are going to make things flash an even number of times.
|
||||
// to do this, we will lie about the state, and leave it at the
|
||||
// old state for one iteration.
|
||||
if (state != _last_state && (_flashing % 2) != 0)
|
||||
state = _last_state;
|
||||
|
||||
if (! busy_cursor) {
|
||||
busyCursor();
|
||||
busy_cursor = 1;
|
||||
}
|
||||
|
||||
if (state == IconicState) {
|
||||
Pixmap image = _icon;
|
||||
|
||||
XFillRectangle(XtDisplay(_w), image, _icon_invert, 0, 0, 48, 48);
|
||||
XtVaSetValues(_w, XmNiconPixmap, NULL, NULL);
|
||||
XtVaSetValues(_w, XmNiconPixmap, image, NULL);
|
||||
}
|
||||
else if (state != 0) {
|
||||
|
||||
// Map temp window to prevent expose updates and other
|
||||
// application event updates ... when flash is on.
|
||||
if ( (_flashing % 2) == 0 )
|
||||
XMapWindow( XtDisplay(_w), _flash_owin );
|
||||
|
||||
XFillRectangle(
|
||||
XtDisplay(_w), XtWindow(_w),
|
||||
_window_invert, 0, 0,
|
||||
_window_attributes.width, _window_attributes.height);
|
||||
|
||||
// Remove temp window to update display when flash is off.
|
||||
if ( (_flashing % 2) != 0 )
|
||||
XUnmapWindow( XtDisplay(_w), _flash_owin );
|
||||
}
|
||||
|
||||
_flashing -= 1;
|
||||
|
||||
if (_flashing > 0) {
|
||||
XtAppAddTimeOut(
|
||||
XtWidgetToApplicationContext(_w),
|
||||
FLASH_INTERVAL, flashCallback, this);
|
||||
_last_state = state;
|
||||
}
|
||||
else {
|
||||
XUnmapWindow( XtDisplay(_w), _flash_iwin );
|
||||
XUnmapWindow( XtDisplay(_w), _flash_owin );
|
||||
normalCursor();
|
||||
busy_cursor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Boolean
|
||||
MainWindow::isIconified()
|
||||
{
|
||||
|
||||
Atom wmStateAtom, actualType;
|
||||
int actualFormat;
|
||||
unsigned long nitems, leftover;
|
||||
WM_STATE *wmState;
|
||||
Boolean retval = FALSE;
|
||||
|
||||
assert ( _w != NULL );
|
||||
|
||||
/* Getting the WM_STATE property to see if iconified or not */
|
||||
wmStateAtom = XInternAtom(XtDisplay(_w), "WM_STATE", False);
|
||||
|
||||
XGetWindowProperty (XtDisplay(_w), XtWindow(_w),
|
||||
wmStateAtom, 0L,
|
||||
(long)BUFSIZ, False, wmStateAtom, &actualType,
|
||||
&actualFormat, &nitems, &leftover,
|
||||
(unsigned char **) &wmState);
|
||||
|
||||
|
||||
if (wmState && wmState->state == IconicState)
|
||||
retval = TRUE;
|
||||
|
||||
free((void*) wmState);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* MbStrchr -
|
||||
************************************************************************/
|
||||
char *
|
||||
MainWindow::MbStrchr(char *str, int ch)
|
||||
{
|
||||
size_t mbCurMax = MB_CUR_MAX;
|
||||
wchar_t targetChar, curChar;
|
||||
char tmpChar;
|
||||
int i, numBytes, byteLen;
|
||||
|
||||
if(mbCurMax <= 1) return strchr(str, ch);
|
||||
|
||||
tmpChar = (char)ch;
|
||||
mbtowc(&targetChar, &tmpChar, mbCurMax);
|
||||
for(i = 0, numBytes = 0, byteLen = strlen(str); i < byteLen; i += numBytes)
|
||||
{
|
||||
numBytes = mbtowc(&curChar, &str[i], mbCurMax);
|
||||
if(curChar == targetChar) return &str[i];
|
||||
}
|
||||
return (char *)NULL;
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::setWorkspacesOccupied(char *workspaces)
|
||||
{
|
||||
char *ptr;
|
||||
Atom *workspace_atoms = NULL;
|
||||
int nworkspaces=0;
|
||||
|
||||
if (workspaces)
|
||||
{
|
||||
do
|
||||
{
|
||||
ptr = MbStrchr (workspaces, ' ');
|
||||
|
||||
if (ptr != NULL) *ptr = '\0';
|
||||
|
||||
workspace_atoms = (Atom*) XtRealloc(
|
||||
(char *) workspace_atoms,
|
||||
sizeof(Atom)*(nworkspaces+1));
|
||||
workspace_atoms[nworkspaces] = XmInternAtom(
|
||||
XtDisplay(_w),
|
||||
workspaces, True);
|
||||
nworkspaces++;
|
||||
|
||||
if (ptr != NULL)
|
||||
{
|
||||
*ptr = ' ';
|
||||
workspaces = ptr + 1;
|
||||
}
|
||||
} while (ptr != NULL);
|
||||
|
||||
DtWsmSetWorkspacesOccupied(
|
||||
XtDisplay(_w), XtWindow (_w),
|
||||
workspace_atoms, nworkspaces);
|
||||
|
||||
XtFree ((char *) workspace_atoms);
|
||||
workspace_atoms = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
Window rootWindow;
|
||||
Atom pCurrent;
|
||||
Screen *currentScreen;
|
||||
int screen;
|
||||
|
||||
screen = XDefaultScreen(XtDisplay(_w));
|
||||
currentScreen = XScreenOfDisplay(XtDisplay(_w), screen);
|
||||
rootWindow = RootWindowOfScreen(currentScreen);
|
||||
|
||||
if (DtWsmGetCurrentWorkspace(
|
||||
XtDisplay(_w),
|
||||
rootWindow,
|
||||
&pCurrent) == Success)
|
||||
DtWsmSetWorkspacesOccupied(
|
||||
XtDisplay(_w),
|
||||
XtWindow(_w),
|
||||
&pCurrent, 1);
|
||||
}
|
||||
}
|
||||
54
cde/programs/dtmail/MotifApp/ManageCmd.C
Normal file
54
cde/programs/dtmail/MotifApp/ManageCmd.C
Normal file
@@ -0,0 +1,54 @@
|
||||
/* $XConsortium: ManageCmd.C /main/3 1995/11/06 16:00:58 rswiston $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// ManageCmd.C: Manage all windows in a MotifApp application.
|
||||
//////////////////////////////////////////////////////////
|
||||
#include "ManageCmd.h"
|
||||
#include "Application.h"
|
||||
|
||||
ManageCmd::ManageCmd ( char *name, char *label, int active ) :
|
||||
NoUndoCmd ( name, label, active )
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
void ManageCmd::doit()
|
||||
{
|
||||
theApplication->manage(); // Opens all top-level windows
|
||||
}
|
||||
808
cde/programs/dtmail/MotifApp/MenuBar.C
Normal file
808
cde/programs/dtmail/MotifApp/MenuBar.C
Normal file
@@ -0,0 +1,808 @@
|
||||
/* $TOG: MenuBar.C /main/6 1997/06/03 16:12:28 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993, 1994, 1995 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// MenuBar.C: A menu bar whose panes support items
|
||||
// that execute Cmd's
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// MODIFIED TO SUPPORT SUBMENUS - not described in Book
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "Application.h"
|
||||
#include "MenuBar.h"
|
||||
#include "Cmd.h"
|
||||
#include "CmdList.h"
|
||||
#include "ToggleButtonInterface.h"
|
||||
#include "ButtonInterface.h"
|
||||
#include "Help.hh"
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/CascadeB.h>
|
||||
#include <Xm/Separator.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/Label.h>
|
||||
|
||||
|
||||
extern "C" {
|
||||
extern XtPointer _XmStringUngenerate (
|
||||
XmString string,
|
||||
XmStringTag tag,
|
||||
XmTextType tag_type,
|
||||
XmTextType output_type);
|
||||
}
|
||||
|
||||
MenuBar::MenuBar ( Widget parent, char *name, unsigned char type )
|
||||
: UIComponent ( name )
|
||||
{
|
||||
// Base widget is a Motif menu bar widget
|
||||
|
||||
if(parent == NULL)
|
||||
return;
|
||||
|
||||
if( type == XmMENU_POPUP) {
|
||||
Arg args[1];
|
||||
int i = 0;
|
||||
|
||||
XtSetArg(args[i], XmNwhichButton, theApplication->bMenuButton()); i++;
|
||||
_w = XmCreatePopupMenu( parent, _name, args, i );
|
||||
// XtVaSetValues(_w, XmNwhichButton, theApplication->bMenuButton(), NULL);
|
||||
} else {
|
||||
type = XmMENU_BAR; // Force it to menu bar
|
||||
_w = XmCreateMenuBar ( parent, _name, NULL, 0 );
|
||||
}
|
||||
|
||||
printHelpId("_w", _w);
|
||||
/* install callback */
|
||||
// XtAddCallback(_w, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
installDestroyHandler();
|
||||
}
|
||||
Widget MenuBar::addCommands ( Widget *menuBarCascade, CmdList *list, Boolean help, unsigned char type )
|
||||
{
|
||||
return( createPulldown ( _w, list, menuBarCascade, help, type ) );
|
||||
}
|
||||
|
||||
Widget MenuBar::addCommands ( CmdList *list, Boolean help, unsigned char type )
|
||||
{
|
||||
return( createPulldown ( _w, list, help, type ) );
|
||||
}
|
||||
|
||||
Widget
|
||||
MenuBar::createPulldown (
|
||||
Widget parent,
|
||||
CmdList *list,
|
||||
Widget *cascade,
|
||||
Boolean help ,
|
||||
unsigned char type)
|
||||
{
|
||||
int i;
|
||||
Widget pulldown;
|
||||
Arg args2[2];
|
||||
char * helpId;
|
||||
XmString label_str;
|
||||
|
||||
if(type != XmMENU_POPUP)
|
||||
type = XmMENU_BAR;
|
||||
|
||||
// Create a pulldown menu pane for this list of commands
|
||||
|
||||
if( type == XmMENU_BAR) {
|
||||
pulldown = XmCreatePulldownMenu( parent,
|
||||
(char *) list->name(), NULL, 0 );
|
||||
label_str = XmStringCreateLocalized(list->getLabel());
|
||||
XtVaSetValues(pulldown,
|
||||
XmNlabelString, label_str,
|
||||
NULL);
|
||||
printHelpId("pulldown", pulldown);
|
||||
/* install callback */
|
||||
// XtAddCallback(pulldown, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
|
||||
// Each entry in the menu bar must have a cascade button
|
||||
// from which the user can pull down the pane
|
||||
|
||||
if (cascade != NULL && *cascade != NULL)
|
||||
XtVaSetValues (*cascade, XmNsubMenuId, pulldown,
|
||||
XmNlabelString, label_str,
|
||||
NULL);
|
||||
else {
|
||||
|
||||
XtSetArg(args2[0], XmNsubMenuId, pulldown);
|
||||
*cascade = XtCreateWidget ( list->name(),
|
||||
xmCascadeButtonWidgetClass,
|
||||
parent,
|
||||
args2, 1);
|
||||
XtVaSetValues(*cascade,
|
||||
XmNlabelString, label_str,
|
||||
NULL);
|
||||
if (help) {
|
||||
XtSetArg (args2[0], XmNmenuHelpWidget, *cascade);
|
||||
XtSetValues (parent, args2, 1);
|
||||
}
|
||||
|
||||
XtManageChild ( *cascade );
|
||||
printHelpId("cascade", *cascade);
|
||||
/* install callback */
|
||||
|
||||
|
||||
// Install callbacks for each of the
|
||||
// pulldown menus so we can get
|
||||
// On Item help for them.
|
||||
|
||||
helpId = XtName(*cascade);
|
||||
if (helpId == "Mailbox") {
|
||||
XtAddCallback(*cascade, XmNhelpCallback,
|
||||
HelpCB, DTMAILCONTAINERMENUID);
|
||||
} else if (helpId == "Edit") {
|
||||
XtAddCallback(*cascade, XmNhelpCallback,
|
||||
HelpCB, DTMAILEDITMENUID);
|
||||
} else if (helpId == "Message") {
|
||||
XtAddCallback(*cascade, XmNhelpCallback,
|
||||
HelpCB, DTMAILMESSAGEMENUID);
|
||||
} else if (helpId == "Attachments") {
|
||||
XtAddCallback(*cascade, XmNhelpCallback,
|
||||
HelpCB, DTMAILATTACHMENUID);
|
||||
} else if (helpId == "View") {
|
||||
XtAddCallback(*cascade, XmNhelpCallback,
|
||||
HelpCB, DTMAILVIEWMENUID);
|
||||
} else if (helpId == "Compose") {
|
||||
XtAddCallback(*cascade, XmNhelpCallback,
|
||||
HelpCB, DTMAILCOMPOSEMENUID);
|
||||
}
|
||||
}
|
||||
} else
|
||||
pulldown = _w;
|
||||
|
||||
|
||||
|
||||
// Loop through the cmdList, creating a menu
|
||||
// entry for each command.
|
||||
Widget *head_wl, *wl;
|
||||
Cardinal num_wl = 0;
|
||||
head_wl = wl = new Widget[ list->size() ];
|
||||
|
||||
for ( i = 0; i < list->size(); i++)
|
||||
{
|
||||
|
||||
if(!strcmp((*list)[i]->className(), "CmdList")) {
|
||||
Widget pane = createPulldown(pulldown,
|
||||
(CmdList*) (*list)[i], FALSE, XmMENU_BAR);
|
||||
((CmdList *)(*list)[i])->setPaneWidget(pane);
|
||||
label_str = XmStringCreateLocalized(((CmdList *)(*list)[i])->getLabel());
|
||||
XtVaSetValues(pane,
|
||||
XmNlabelString, label_str,
|
||||
NULL);
|
||||
} else {
|
||||
if ( !strcmp((*list)[i]->className(),"SeparatorCmd")) {
|
||||
*(wl++) = XtCreateWidget ( (*list)[i]->name(),
|
||||
xmSeparatorWidgetClass,
|
||||
pulldown,
|
||||
NULL, 0);
|
||||
} else if (!strcmp((*list)[i]->className(),"ToggleButtonCmd")) {
|
||||
CmdInterface *ci;
|
||||
ci = new ToggleButtonInterface(pulldown, (*list)[i] );
|
||||
*(wl++) = ci->baseWidget();
|
||||
} else if(!strcmp((*list)[i]->className(),"LabelCmd")) {
|
||||
label_str = XmStringCreateLocalized((*list)[i]->getLabel());
|
||||
|
||||
*(wl++) = XtVaCreateWidget ( (*list)[i]->name(),
|
||||
xmLabelWidgetClass,
|
||||
pulldown,
|
||||
XmNlabelString, label_str,
|
||||
NULL);
|
||||
} else {
|
||||
CmdInterface *ci;
|
||||
ci = new ButtonInterface ( pulldown, (*list)[i] );
|
||||
*(wl++) = ci->baseWidget();
|
||||
}
|
||||
|
||||
num_wl++;
|
||||
}
|
||||
}
|
||||
|
||||
XtManageChildren ( head_wl, num_wl );
|
||||
delete head_wl;
|
||||
|
||||
return(pulldown);
|
||||
}
|
||||
|
||||
Widget
|
||||
MenuBar::createPulldown (
|
||||
Widget parent,
|
||||
CmdList *list,
|
||||
Boolean help ,
|
||||
unsigned char type)
|
||||
{
|
||||
int i;
|
||||
Widget pulldown, cascade;
|
||||
Arg args2[2];
|
||||
char * helpId;
|
||||
XmString label_str;
|
||||
|
||||
if(type != XmMENU_POPUP)
|
||||
type = XmMENU_BAR;
|
||||
|
||||
// Create a pulldown menu pane for this list of commands
|
||||
|
||||
if( type == XmMENU_BAR) {
|
||||
pulldown = XmCreatePulldownMenu( parent,
|
||||
(char *) list->name(), NULL, 0 );
|
||||
label_str = XmStringCreateLocalized(list->getLabel());
|
||||
XtVaSetValues(pulldown,
|
||||
XmNlabelString, label_str,
|
||||
NULL);
|
||||
printHelpId("pulldown", pulldown);
|
||||
/* install callback */
|
||||
// XtAddCallback(pulldown, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
|
||||
// Each entry in the menu bar must have a cascade button
|
||||
// from which the user can pull down the pane
|
||||
|
||||
XtSetArg(args2[0], XmNsubMenuId, pulldown);
|
||||
cascade = XtCreateWidget ( list->name(),
|
||||
xmCascadeButtonWidgetClass,
|
||||
parent,
|
||||
args2, 1);
|
||||
XtVaSetValues(cascade,
|
||||
XmNlabelString, label_str,
|
||||
NULL);
|
||||
if (help) {
|
||||
XtSetArg (args2[0], XmNmenuHelpWidget, cascade);
|
||||
XtSetValues (parent, args2, 1);
|
||||
}
|
||||
|
||||
XtManageChild ( cascade );
|
||||
printHelpId("cascade", cascade);
|
||||
/* install callback */
|
||||
|
||||
|
||||
// Install callbacks for each of the
|
||||
// pulldown menus so we can get
|
||||
// On Item help for them.
|
||||
|
||||
helpId = XtName(cascade);
|
||||
if (helpId == "Mailbox") {
|
||||
XtAddCallback(cascade, XmNhelpCallback,
|
||||
HelpCB, DTMAILCONTAINERMENUID);
|
||||
} else if (helpId == "Edit") {
|
||||
XtAddCallback(cascade, XmNhelpCallback,
|
||||
HelpCB, DTMAILEDITMENUID);
|
||||
} else if (helpId == "Message") {
|
||||
XtAddCallback(cascade, XmNhelpCallback,
|
||||
HelpCB, DTMAILMESSAGEMENUID);
|
||||
} else if (helpId == "Attachments") {
|
||||
XtAddCallback(cascade, XmNhelpCallback,
|
||||
HelpCB, DTMAILATTACHMENUID);
|
||||
} else if (helpId == "View") {
|
||||
XtAddCallback(cascade, XmNhelpCallback,
|
||||
HelpCB, DTMAILVIEWMENUID);
|
||||
} else if (helpId == "Compose") {
|
||||
XtAddCallback(cascade, XmNhelpCallback,
|
||||
HelpCB, DTMAILCOMPOSEMENUID);
|
||||
}
|
||||
} else
|
||||
pulldown = _w;
|
||||
|
||||
|
||||
|
||||
// Loop through the cmdList, creating a menu
|
||||
// entry for each command.
|
||||
|
||||
for ( i = 0; i < list->size(); i++)
|
||||
{
|
||||
|
||||
if(!strcmp((*list)[i]->className(), "CmdList")) {
|
||||
Widget pane = createPulldown(pulldown,
|
||||
(CmdList*) (*list)[i], FALSE, XmMENU_BAR);
|
||||
((CmdList *)(*list)[i])->setPaneWidget(pane);
|
||||
label_str = XmStringCreateLocalized((*list)[i]->getLabel());
|
||||
XtVaSetValues(pane,
|
||||
XmNlabelString, label_str,
|
||||
NULL);
|
||||
} else {
|
||||
if ( !strcmp((*list)[i]->className(),"SeparatorCmd")) {
|
||||
XtCreateManagedWidget ( (*list)[i]->name(),
|
||||
xmSeparatorWidgetClass,
|
||||
pulldown,
|
||||
NULL, 0);
|
||||
} else if (!strcmp((*list)[i]->className(),"ToggleButtonCmd")) {
|
||||
CmdInterface *ci;
|
||||
ci = new ToggleButtonInterface(pulldown, (*list)[i]);
|
||||
ci->manage();
|
||||
} else if(!strcmp((*list)[i]->className(),"LabelCmd")) {
|
||||
Widget _i18n;
|
||||
Arg _args[1];
|
||||
XmString xms;
|
||||
|
||||
_i18n = XtCreateManagedWidget(
|
||||
(*list)[i]->name(),
|
||||
xmLabelWidgetClass,
|
||||
pulldown,
|
||||
NULL, 0
|
||||
);
|
||||
|
||||
xms = XmStringCreateLocalized((char*) (*list)[i]->getLabel());
|
||||
XtSetArg( _args[0], XmNlabelString, xms );
|
||||
XtSetValues( _i18n, _args, 1 );
|
||||
XmStringFree(xms);
|
||||
} else {
|
||||
CmdInterface *ci;
|
||||
ci = new ButtonInterface ( pulldown, (*list)[i] );
|
||||
ci->manage();
|
||||
}
|
||||
}
|
||||
}
|
||||
return(pulldown);
|
||||
}
|
||||
|
||||
// SR - Added to handle dynamic menus
|
||||
|
||||
Widget
|
||||
MenuBar::addCommands(
|
||||
Widget pulldown,
|
||||
CmdList *new_list
|
||||
)
|
||||
{
|
||||
// if(isValidMenuPane(pulldown) == FALSE)
|
||||
// return NULL;
|
||||
|
||||
int i, num_children;
|
||||
WidgetList children;
|
||||
Boolean haveNoSeparator;
|
||||
int newItemIndex, numPBUnmanaged, tmpPBUnmanaged;
|
||||
|
||||
XtVaGetValues(pulldown,
|
||||
XmNnumChildren, &num_children,
|
||||
NULL);
|
||||
|
||||
children = (WidgetList)XtMalloc(sizeof(Widget) * num_children);
|
||||
|
||||
XtVaGetValues(pulldown,
|
||||
XmNchildren, &children,
|
||||
NULL);
|
||||
|
||||
// Handle the creation or management of the Separator.
|
||||
|
||||
haveNoSeparator = TRUE;
|
||||
numPBUnmanaged = 0;
|
||||
|
||||
for (i=0; (i < num_children); i++) {
|
||||
Widget wid = (Widget) children[i];
|
||||
if (XtIsSubclass(wid, xmSeparatorWidgetClass)) {
|
||||
XtManageChild(wid);
|
||||
haveNoSeparator = FALSE;
|
||||
}
|
||||
else if (XtIsSubclass(wid, xmPushButtonWidgetClass)) {
|
||||
if (!XtIsManaged(wid)) { // If widget is unmanaged
|
||||
numPBUnmanaged++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (haveNoSeparator) {
|
||||
XtCreateManagedWidget ("Separator",
|
||||
xmSeparatorWidgetClass,
|
||||
pulldown,
|
||||
NULL, 0);
|
||||
haveNoSeparator = FALSE;
|
||||
}
|
||||
|
||||
// Now handle the pushButton case
|
||||
|
||||
newItemIndex = 0;
|
||||
tmpPBUnmanaged = 0;
|
||||
|
||||
// Loop through the cmdList, creating a menu
|
||||
// entry for each command.
|
||||
|
||||
for (newItemIndex = 0; newItemIndex < new_list->size(); newItemIndex++) {
|
||||
|
||||
tmpPBUnmanaged = numPBUnmanaged;
|
||||
|
||||
if (numPBUnmanaged > 0) { // If there exists unmanaged PBs
|
||||
for (i = 0;
|
||||
(i < num_children) &&
|
||||
(tmpPBUnmanaged == numPBUnmanaged);
|
||||
i++) {
|
||||
|
||||
Widget wid = (Widget) children[i];
|
||||
|
||||
if (XtIsSubclass(wid, xmPushButtonWidgetClass)) {
|
||||
if (!XtIsManaged(wid)) {
|
||||
// If widget is unmanaged
|
||||
// Set its label to be the newItemIndex widget's.
|
||||
// Manage it.
|
||||
// Bump up newItemIndex
|
||||
XtVaSetValues(wid,
|
||||
XmNlabelString, XmStringCreateLocalized(
|
||||
(char *) (*new_list)[newItemIndex]->getLabel()),
|
||||
NULL);
|
||||
XtManageChild(wid);
|
||||
numPBUnmanaged--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // No unmanaged push buttons available
|
||||
CmdInterface *ci;
|
||||
ci = new ButtonInterface (
|
||||
pulldown, (*new_list)[newItemIndex]
|
||||
);
|
||||
ci->manage();
|
||||
}
|
||||
}
|
||||
|
||||
return(pulldown);
|
||||
}
|
||||
|
||||
void
|
||||
MenuBar::removeOnlyCommands(
|
||||
Widget pulldown,
|
||||
CmdList *redundant_list
|
||||
)
|
||||
{
|
||||
// if(isValidMenuPane(pulldown) == FALSE)
|
||||
// return;
|
||||
|
||||
int i, j, num_children;
|
||||
WidgetList children;
|
||||
|
||||
XtVaGetValues(pulldown,
|
||||
XmNnumChildren, &num_children,
|
||||
NULL);
|
||||
|
||||
children = (WidgetList)XtMalloc(sizeof(Widget) * num_children);
|
||||
|
||||
XtVaGetValues(pulldown,
|
||||
XmNchildren, &children,
|
||||
NULL);
|
||||
|
||||
// Loop through widget list. Destroy those widgets that map to those
|
||||
// in the redundant list.
|
||||
|
||||
for (i=0; i<num_children; i++) {
|
||||
|
||||
Widget wid = (Widget) children[i];
|
||||
|
||||
if (XtIsSubclass(wid, xmPushButtonWidgetClass)) {
|
||||
|
||||
for (j=0; j<redundant_list->size(); j++) {
|
||||
char name[200];
|
||||
ButtonInterface::mapName((*redundant_list)[j]->name(), name);
|
||||
if (strcmp(XtName(wid), name) == 0) {
|
||||
// The redundant item has been found.
|
||||
XtUnmanageChild(wid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void
|
||||
MenuBar::removeCommands(
|
||||
Widget pulldown,
|
||||
CmdList *redundant_list
|
||||
)
|
||||
{
|
||||
// if(isValidMenuPane(pulldown) == FALSE)
|
||||
// return;
|
||||
|
||||
int i, j, num_children;
|
||||
WidgetList children;
|
||||
|
||||
XtVaGetValues(pulldown,
|
||||
XmNnumChildren, &num_children,
|
||||
NULL);
|
||||
|
||||
children = (WidgetList)XtMalloc(sizeof(Widget) * num_children);
|
||||
|
||||
XtVaGetValues(pulldown,
|
||||
XmNchildren, &children,
|
||||
NULL);
|
||||
|
||||
// Loop through widget list. Destroy those widgets that map to those
|
||||
// in the redundant list.
|
||||
|
||||
for (i=0; i<num_children; i++) {
|
||||
|
||||
Widget wid = (Widget) children[i];
|
||||
|
||||
if (XtIsSubclass(wid, xmSeparatorWidgetClass)) {
|
||||
XtUnmanageChild(wid);
|
||||
}
|
||||
else if (XtIsSubclass(wid, xmPushButtonWidgetClass)) {
|
||||
|
||||
for (j=0; j<redundant_list->size(); j++) {
|
||||
XmString str=NULL;
|
||||
String label=NULL;
|
||||
XtVaGetValues(wid, XmNlabelString, &str, NULL);
|
||||
if (str == NULL) continue;
|
||||
label = NULL;
|
||||
label = (char *) _XmStringUngenerate(
|
||||
str, NULL,
|
||||
XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
|
||||
XmStringFree(str);
|
||||
if (label == NULL) continue;
|
||||
if (strcmp(label, (*redundant_list)[j]->getLabel()) == 0) {
|
||||
// The redundant item has been found.
|
||||
XtUnmanageChild(wid);
|
||||
}
|
||||
XtFree(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MenuBar::addCommand(
|
||||
Widget pulldown,
|
||||
Cmd *cmd
|
||||
)
|
||||
{
|
||||
// if(isValidMenuPane(pulldown) == FALSE)
|
||||
// return;
|
||||
|
||||
CmdInterface *ci;
|
||||
ci = new ButtonInterface ( pulldown, cmd);
|
||||
ci->manage();
|
||||
}
|
||||
|
||||
void
|
||||
MenuBar::changeLabel(
|
||||
Widget pulldown,
|
||||
int index,
|
||||
char * name
|
||||
)
|
||||
{
|
||||
// if(isValidMenuPane(pulldown) == FALSE)
|
||||
// return;
|
||||
|
||||
int managed_widgets, i, num_children;
|
||||
WidgetList children;
|
||||
XmString label;
|
||||
Widget wid;
|
||||
|
||||
XtVaGetValues(pulldown,
|
||||
XmNnumChildren, &num_children,
|
||||
NULL);
|
||||
|
||||
children = (WidgetList)XtMalloc(sizeof(Widget) * num_children);
|
||||
|
||||
XtVaGetValues(pulldown,
|
||||
XmNchildren, &children,
|
||||
NULL);
|
||||
|
||||
// Some widgets may be unmanaged, so find the real index
|
||||
for (managed_widgets=0, i=0;
|
||||
managed_widgets <= index && i < num_children; i++) {
|
||||
wid = (Widget) children[i];
|
||||
if (XtIsManaged(wid)) managed_widgets++;
|
||||
}
|
||||
if (--i >= num_children) return;
|
||||
|
||||
wid = (Widget) children[i];
|
||||
|
||||
label = XmStringCreateLocalized(name);
|
||||
|
||||
XtVaSetValues(wid,
|
||||
XmNlabelString, label,
|
||||
NULL);
|
||||
XmStringFree(label);
|
||||
}
|
||||
|
||||
void
|
||||
MenuBar::changeLabel(Widget pulldown,
|
||||
const char * button_name,
|
||||
const char * label)
|
||||
{
|
||||
// if(isValidMenuPane(pulldown) == FALSE)
|
||||
// return;
|
||||
|
||||
// Locate the appropriate widget in the list.
|
||||
//
|
||||
int num_children;
|
||||
char wid_name[200];
|
||||
XmString label_string = XmStringCreateLocalized((char *)label);
|
||||
|
||||
ButtonInterface::mapName(button_name, wid_name);
|
||||
|
||||
XtVaGetValues(pulldown,
|
||||
XmNnumChildren, &num_children,
|
||||
NULL);
|
||||
|
||||
Widget * children = new Widget[num_children];
|
||||
XtVaGetValues(pulldown,
|
||||
XmNchildren, &children,
|
||||
NULL);
|
||||
|
||||
for (int wid = 0; wid < num_children; wid++) {
|
||||
if (strcmp(XtName(children[wid]), wid_name) == 0) {
|
||||
if (XtIsManaged(children[wid]))
|
||||
XtVaSetValues(children[wid],
|
||||
XmNlabelString, label_string,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
XmStringFree(label_string);
|
||||
}
|
||||
|
||||
void
|
||||
MenuBar::rotateLabels(
|
||||
Widget pulldown,
|
||||
int startindex,
|
||||
int endindex
|
||||
)
|
||||
{
|
||||
// if(isValidMenuPane(pulldown) == FALSE)
|
||||
// return;
|
||||
|
||||
int num_managed_wids=0, i, j, num_children, num_to_change;
|
||||
WidgetList children;
|
||||
XmString label, endlabel;
|
||||
Widget prevwid, wid;
|
||||
|
||||
if (startindex < 0 || endindex < 0)
|
||||
return;
|
||||
|
||||
XtVaGetValues(pulldown,
|
||||
XmNnumChildren, &num_children,
|
||||
NULL);
|
||||
|
||||
if (startindex >= num_children || endindex >= num_children)
|
||||
return;
|
||||
|
||||
num_to_change = endindex - startindex;
|
||||
if (num_children < num_to_change || num_to_change == 0)
|
||||
return;
|
||||
|
||||
children = (WidgetList)XtMalloc(sizeof(Widget) * num_children);
|
||||
|
||||
XtVaGetValues(pulldown,
|
||||
XmNchildren, &children,
|
||||
NULL);
|
||||
|
||||
// Some of the widgets may be unmanaged: find the first managed widget
|
||||
for (i = startindex; i < num_children; i++) {
|
||||
if (XtIsManaged(children[i]))
|
||||
break;
|
||||
startindex++;
|
||||
}
|
||||
|
||||
if (startindex == num_children)
|
||||
return;
|
||||
|
||||
// Find the real endindex
|
||||
endindex = startindex+1;
|
||||
while (endindex < num_children) {
|
||||
if (XtIsManaged(children[endindex]))
|
||||
num_managed_wids++;
|
||||
if (num_managed_wids == num_to_change)
|
||||
// We have found the endindex at this point
|
||||
break;
|
||||
endindex++;
|
||||
}
|
||||
|
||||
if (endindex == num_children)
|
||||
return;
|
||||
|
||||
wid = (Widget) children[endindex];
|
||||
XtVaGetValues(wid,
|
||||
XmNlabelString, &label,
|
||||
NULL);
|
||||
endlabel = XmStringCopy(label);
|
||||
|
||||
j = i = endindex;
|
||||
while (i > startindex) {
|
||||
|
||||
do {
|
||||
if (--j < startindex) break;
|
||||
prevwid = (Widget) children[j];
|
||||
} while (!XtIsManaged(prevwid));
|
||||
|
||||
XtVaGetValues(prevwid,
|
||||
XmNlabelString, &label,
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(wid,
|
||||
XmNlabelString, label,
|
||||
NULL);
|
||||
|
||||
i = j;
|
||||
|
||||
wid = (Widget) children[i];
|
||||
}
|
||||
|
||||
wid = (Widget) children[startindex];
|
||||
XtVaSetValues(wid,
|
||||
XmNlabelString, endlabel,
|
||||
NULL);
|
||||
|
||||
XmStringFree(endlabel);
|
||||
}
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
Boolean
|
||||
MenuBar::isValidMenuPane(Widget w)
|
||||
{
|
||||
Boolean retval = FALSE;
|
||||
Widget parent = w;
|
||||
|
||||
while(parent && parent != _w)
|
||||
parent = XtParent(parent);
|
||||
|
||||
if(parent == _w)
|
||||
retval = TRUE;
|
||||
|
||||
return retval;
|
||||
}
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
void
|
||||
MenuBar::removeCommand(
|
||||
Widget pulldown,
|
||||
int index
|
||||
)
|
||||
{
|
||||
//if(isValidMenuPane(pulldown) == FALSE)
|
||||
// return;
|
||||
|
||||
int managed_widgets, i, num_children;
|
||||
WidgetList children;
|
||||
|
||||
XtVaGetValues(pulldown,
|
||||
XmNnumChildren, &num_children,
|
||||
NULL);
|
||||
|
||||
children = (WidgetList)XtMalloc(sizeof(Widget) * num_children);
|
||||
|
||||
XtVaGetValues(pulldown,
|
||||
XmNchildren, &children,
|
||||
NULL);
|
||||
|
||||
// Some widgets may be unmanaged, so find the real index
|
||||
for (managed_widgets=0, i=0;
|
||||
managed_widgets <= index && i < num_children; i++) {
|
||||
Widget wid = (Widget) children[i];
|
||||
if (XtIsManaged(wid)) managed_widgets++;
|
||||
}
|
||||
|
||||
if (--i < num_children)
|
||||
XtUnmanageChild(children[i]);
|
||||
}
|
||||
100
cde/programs/dtmail/MotifApp/MenuWindow.C
Normal file
100
cde/programs/dtmail/MotifApp/MenuWindow.C
Normal file
@@ -0,0 +1,100 @@
|
||||
/* $TOG: MenuWindow.C /main/5 1997/06/04 18:42:40 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// MenuWindow.C
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
#include "MenuWindow.h"
|
||||
#include "MenuBar.h"
|
||||
|
||||
|
||||
MenuWindow::MenuWindow( char *name, Boolean allowResize ) :
|
||||
MainWindow ( name, allowResize )
|
||||
{
|
||||
_menuBar = NULL;
|
||||
}
|
||||
|
||||
void MenuWindow::initialize()
|
||||
{
|
||||
|
||||
// Call base class to create XmMainWindow widget
|
||||
// and set up the work area.
|
||||
|
||||
MainWindow::initialize();
|
||||
|
||||
// Specify the base widget of a MenuBar object
|
||||
// the XmMainWindow widget's menu bar.
|
||||
|
||||
_menuBar = new MenuBar ( _main, "menubar" );
|
||||
|
||||
XtVaSetValues ( _main,
|
||||
XmNmenuBar, _menuBar->baseWidget(),
|
||||
NULL);
|
||||
|
||||
// Call derived class hook to add panes to the menu
|
||||
|
||||
createMenuPanes();
|
||||
|
||||
_menuBar->manage();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
MenuWindow::~MenuWindow()
|
||||
{
|
||||
|
||||
|
||||
delete _menuBar;
|
||||
}
|
||||
|
||||
void
|
||||
MenuWindow::getIconColors(Pixel & fore, Pixel & back)
|
||||
{
|
||||
if (_menuBar) {
|
||||
XtVaGetValues (_menuBar->baseWidget(),
|
||||
XmNforeground, &fore,
|
||||
XmNbackground, &back,
|
||||
NULL);
|
||||
}
|
||||
else {
|
||||
MainWindow::getIconColors(fore, back);
|
||||
}
|
||||
}
|
||||
61
cde/programs/dtmail/MotifApp/MotifApp.msg
Normal file
61
cde/programs/dtmail/MotifApp/MotifApp.msg
Normal file
@@ -0,0 +1,61 @@
|
||||
$
|
||||
$ COMPONENT_NAME: desktop
|
||||
$
|
||||
$ FUNCTIONS: none
|
||||
$
|
||||
$ ORIGINS: 27,118,119,120,121
|
||||
$
|
||||
$ This module contains IBM CONFIDENTIAL code. -- (IBM
|
||||
$ Confidential Restricted when combined with the aggregated
|
||||
$ modules for this product)
|
||||
$ OBJECT CODE ONLY SOURCE MATERIALS
|
||||
$
|
||||
$ (C) COPYRIGHT International Business Machines Corp. 1995
|
||||
$ All Rights Reserved
|
||||
$ US Government Users Restricted Rights - Use, duplication or
|
||||
$ disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
|
||||
$
|
||||
$
|
||||
$ +SNOTICE
|
||||
$
|
||||
$ $XConsortium: MotifApp.msg /main/4 1996/07/18 14:35:42 mgreess $
|
||||
$
|
||||
$ RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
$
|
||||
$ The information in this document is subject to special
|
||||
$ restrictions in a confidential disclosure agreement between
|
||||
$ HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
$ document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
$ Sun's specific written approval. This document and all copies
|
||||
$ and derivative works thereof must be returned or destroyed at
|
||||
$ Sun's request.
|
||||
$
|
||||
$ Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
$
|
||||
$ +ENOTICE
|
||||
$
|
||||
|
||||
$quote "
|
||||
|
||||
$set 1
|
||||
1 "Do you really want to execute this command?"
|
||||
2 "OK"
|
||||
3 "Cancel"
|
||||
4 "DtMail Version Dialog"
|
||||
5 "DtMail Version Dialog"
|
||||
6 "You must select a component withing your app.\n"
|
||||
$ Messages 7 and 8 are no longer used. They are both
|
||||
$ replaced by message 9.
|
||||
7 "DtMail Help"
|
||||
8 "DtMail Help"
|
||||
9 "Close this folder?"
|
||||
10 "This command cannot be undone. Proceed anyway?"
|
||||
11 "Show hidden folders and files"
|
||||
$ /* NL_COMMENT
|
||||
$ * This message replaces messages 7 and 8.
|
||||
$ */
|
||||
12 "Mailer : Help"
|
||||
|
||||
$set 2
|
||||
1 "Selection Error, cannot continue\n"
|
||||
2 "Selection aborted by user.\n"
|
||||
126
cde/programs/dtmail/MotifApp/MotifCmds.C
Normal file
126
cde/programs/dtmail/MotifApp/MotifCmds.C
Normal file
@@ -0,0 +1,126 @@
|
||||
/* $TOG: MotifCmds.C /main/5 1998/09/21 18:49:41 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
#include "MotifCmds.h"
|
||||
|
||||
SeparatorCmd::SeparatorCmd (
|
||||
char *name,
|
||||
char *,
|
||||
int active
|
||||
) : Cmd ( name, NULL, active )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SeparatorCmd::doit()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SeparatorCmd::undoit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
ToggleButtonCmd::ToggleButtonCmd (
|
||||
char *name,
|
||||
char *label,
|
||||
int active,
|
||||
Boolean visible_when_off,
|
||||
unsigned char indicator_type
|
||||
) : Cmd ( name, label, active )
|
||||
{
|
||||
_indicator_type = indicator_type;
|
||||
_visible_when_off = visible_when_off;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ToggleButtonCmd::doit()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ToggleButtonCmd::undoit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Returns TRUE if button is ON, FALSE if OFF.
|
||||
|
||||
Boolean
|
||||
ToggleButtonCmd::getButtonState()
|
||||
{
|
||||
CmdInterface *ci;
|
||||
Widget toggleButton;
|
||||
|
||||
if (!_ci) return(NULL);
|
||||
|
||||
ci = _ci[0];
|
||||
|
||||
toggleButton = ci->baseWidget();
|
||||
|
||||
return (XmToggleButtonGetState(toggleButton));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
ToggleButtonCmd::setButtonState(
|
||||
Boolean state,
|
||||
Boolean notify
|
||||
)
|
||||
{
|
||||
|
||||
CmdInterface *ci;
|
||||
Widget toggleButton;
|
||||
|
||||
if (!_ci) return;
|
||||
|
||||
ci = _ci[0];
|
||||
|
||||
if (ci) {
|
||||
toggleButton = ci->baseWidget();
|
||||
|
||||
XmToggleButtonSetState(toggleButton, state, notify);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef CAN_INLINE_VIRTUALS
|
||||
const char *const
|
||||
ToggleButtonCmd::className( void )
|
||||
{
|
||||
return "ToggleButtonCmd";
|
||||
}
|
||||
#endif /* ! CAN_INLINE_VIRTUALS */
|
||||
|
||||
unsigned char
|
||||
ToggleButtonCmd::indicatorType( void )
|
||||
{
|
||||
return _indicator_type;
|
||||
}
|
||||
|
||||
Boolean
|
||||
ToggleButtonCmd::visibleWhenOff( void )
|
||||
{
|
||||
return _visible_when_off;
|
||||
}
|
||||
56
cde/programs/dtmail/MotifApp/NoUndoCmd.C
Normal file
56
cde/programs/dtmail/MotifApp/NoUndoCmd.C
Normal file
@@ -0,0 +1,56 @@
|
||||
/* $XConsortium: NoUndoCmd.C /main/3 1995/11/06 16:01:40 rswiston $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// NoUndoCmd.C: Base class for all commands without undo
|
||||
//////////////////////////////////////////////////////////
|
||||
#include "NoUndoCmd.h"
|
||||
|
||||
#define FALSE 0
|
||||
|
||||
NoUndoCmd::NoUndoCmd ( char *name,
|
||||
char *label,
|
||||
int active ) : Cmd ( name, label, active )
|
||||
{
|
||||
_hasUndo = FALSE; // This class has no undo
|
||||
}
|
||||
|
||||
void NoUndoCmd::undoit()
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
82
cde/programs/dtmail/MotifApp/PixmapCycler.C
Normal file
82
cde/programs/dtmail/MotifApp/PixmapCycler.C
Normal file
@@ -0,0 +1,82 @@
|
||||
/* $XConsortium: PixmapCycler.C /main/3 1996/04/21 19:40:27 drk $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// PixmapCycler.C: Abstract class that supports a continuous cycle
|
||||
// of pixmaps for short animation sequences.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#include "PixmapCycler.h"
|
||||
|
||||
#define INVALID -1
|
||||
|
||||
PixmapCycler::PixmapCycler ( int numPixmaps, Dimension w, Dimension h )
|
||||
{
|
||||
_numPixmaps = numPixmaps;
|
||||
_current = INVALID;
|
||||
_pixmapList = new Pixmap[_numPixmaps];
|
||||
_width = w;
|
||||
_height = h;
|
||||
}
|
||||
|
||||
PixmapCycler::~PixmapCycler()
|
||||
{
|
||||
delete []_pixmapList;
|
||||
}
|
||||
|
||||
Pixmap PixmapCycler::next()
|
||||
{
|
||||
// The first time, call the createPixmaps() function
|
||||
// implemented by the derived class to create the pixmaps
|
||||
|
||||
if ( _current == INVALID )
|
||||
{
|
||||
createPixmaps();
|
||||
_current = 0; // Initialize to the first pixmap
|
||||
}
|
||||
|
||||
// If the counter is larger than the index of the
|
||||
// last pixmap, roll it over and restart with zero
|
||||
|
||||
if ( _current >= _numPixmaps )
|
||||
_current = 0;
|
||||
|
||||
// Return the current pixmap and increment the counter
|
||||
|
||||
return _pixmapList[_current++];
|
||||
}
|
||||
247
cde/programs/dtmail/MotifApp/PromptDialogManager.C
Normal file
247
cde/programs/dtmail/MotifApp/PromptDialogManager.C
Normal file
@@ -0,0 +1,247 @@
|
||||
/* $XConsortium: PromptDialogManager.C /main/4 1996/04/21 19:40:30 drk $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: PromptDialogManager.C /main/4 1996/04/21 19:40:30 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// PromptDialogManager.C:
|
||||
//////////////////////////////////////////////////////////
|
||||
#include "PromptDialogManager.h"
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/SelectioB.h>
|
||||
#include <assert.h>
|
||||
// Define an instance to be available throughout the framework.
|
||||
|
||||
PromptDialogManager *thePromptDialogManager =
|
||||
new PromptDialogManager ( "PromptDialog" );
|
||||
|
||||
PromptDialogManager::PromptDialogManager ( char *name ) :
|
||||
DialogManager ( name )
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
Widget PromptDialogManager::createDialog ( Widget parent )
|
||||
{
|
||||
Widget dialog = XmCreatePromptDialog ( parent, _name, NULL, 0);
|
||||
|
||||
XtVaSetValues ( dialog,
|
||||
XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
|
||||
NULL );
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
Widget
|
||||
PromptDialogManager::post( char *title,
|
||||
char *text,
|
||||
void *clientData,
|
||||
DialogCallback ok,
|
||||
DialogCallback cancel,
|
||||
DialogCallback help )
|
||||
{
|
||||
|
||||
// Get a dialog widget from the cache
|
||||
|
||||
Widget dialog = getDialog();
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( dialog != NULL );
|
||||
assert ( XtIsSubclass ( dialog, xmSelectionBoxWidgetClass ) );
|
||||
|
||||
// Convert the text string to a compound string and
|
||||
// specify this to be the message displayed in the dialog.
|
||||
|
||||
XmString titleStr = XmStringCreateLocalized (title);
|
||||
XmString xmstr = XmStringCreateLocalized ( text );
|
||||
XtVaSetValues ( dialog,
|
||||
XmNmessageString, xmstr,
|
||||
XmNdialogTitle, titleStr,
|
||||
NULL );
|
||||
XmStringFree ( xmstr );
|
||||
XmStringFree ( titleStr );
|
||||
|
||||
// Create an object to carry the additional data needed
|
||||
// to cache the dialogs.
|
||||
|
||||
DialogCallbackData *dcb = new DialogCallbackData( this,
|
||||
clientData,
|
||||
ok, cancel,
|
||||
help );
|
||||
// Install callback function for each button
|
||||
// support by Motif dialogs. If there is no help callback
|
||||
// unmanage the corresponding button instead, if possible.
|
||||
|
||||
if ( ok )
|
||||
XtAddCallback ( dialog,
|
||||
XmNokCallback,
|
||||
&DialogManager::okCallback,
|
||||
(XtPointer) dcb );
|
||||
else
|
||||
{
|
||||
Widget w = XmSelectionBoxGetChild ( dialog,
|
||||
XmDIALOG_OK_BUTTON );
|
||||
XtUnmanageChild ( w );
|
||||
}
|
||||
|
||||
|
||||
if ( cancel )
|
||||
XtAddCallback ( dialog,
|
||||
XmNcancelCallback,
|
||||
&DialogManager::cancelCallback,
|
||||
(XtPointer) dcb );
|
||||
else
|
||||
{
|
||||
Widget w = XmSelectionBoxGetChild ( dialog,
|
||||
XmDIALOG_CANCEL_BUTTON );
|
||||
XtUnmanageChild ( w );
|
||||
}
|
||||
|
||||
|
||||
if ( help )
|
||||
XtAddCallback ( dialog,
|
||||
XmNhelpCallback,
|
||||
&DialogManager::helpCallback,
|
||||
(XtPointer) dcb );
|
||||
else
|
||||
{
|
||||
Widget w = XmSelectionBoxGetChild ( dialog,
|
||||
XmDIALOG_HELP_BUTTON );
|
||||
XtUnmanageChild ( w );
|
||||
}
|
||||
|
||||
// Post the dialog.
|
||||
|
||||
XtManageChild ( dialog );
|
||||
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
Widget
|
||||
PromptDialogManager::post( char *title,
|
||||
char *text,
|
||||
Widget wid,
|
||||
void *clientData,
|
||||
DialogCallback ok,
|
||||
DialogCallback cancel,
|
||||
DialogCallback help )
|
||||
{
|
||||
|
||||
// Get a dialog widget from the cache
|
||||
|
||||
Widget dialog = getDialog(wid);
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( dialog != NULL );
|
||||
assert ( XtIsSubclass ( dialog, xmSelectionBoxWidgetClass ) );
|
||||
|
||||
// Convert the text string to a compound string and
|
||||
// specify this to be the message displayed in the dialog.
|
||||
|
||||
XmString titleStr = XmStringCreateLocalized (title);
|
||||
XmString xmstr = XmStringCreateLocalized ( text );
|
||||
XtVaSetValues ( dialog,
|
||||
XmNmessageString, xmstr,
|
||||
XmNdialogTitle, titleStr,
|
||||
NULL );
|
||||
XmStringFree ( xmstr );
|
||||
XmStringFree ( titleStr );
|
||||
|
||||
// Create an object to carry the additional data needed
|
||||
// to cache the dialogs.
|
||||
|
||||
DialogCallbackData *dcb = new DialogCallbackData( this,
|
||||
clientData,
|
||||
ok, cancel,
|
||||
help );
|
||||
// Install callback function for each button
|
||||
// support by Motif dialogs. If there is no help callback
|
||||
// unmanage the corresponding button instead, if possible.
|
||||
|
||||
if ( ok )
|
||||
XtAddCallback ( dialog,
|
||||
XmNokCallback,
|
||||
&DialogManager::okCallback,
|
||||
(XtPointer) dcb );
|
||||
else
|
||||
{
|
||||
Widget w = XmSelectionBoxGetChild ( dialog,
|
||||
XmDIALOG_OK_BUTTON );
|
||||
XtUnmanageChild ( w );
|
||||
}
|
||||
|
||||
|
||||
if ( cancel )
|
||||
XtAddCallback ( dialog,
|
||||
XmNcancelCallback,
|
||||
&DialogManager::cancelCallback,
|
||||
(XtPointer) dcb );
|
||||
else
|
||||
{
|
||||
Widget w = XmSelectionBoxGetChild ( dialog,
|
||||
XmDIALOG_CANCEL_BUTTON );
|
||||
XtUnmanageChild ( w );
|
||||
}
|
||||
|
||||
|
||||
if ( help )
|
||||
XtAddCallback ( dialog,
|
||||
XmNhelpCallback,
|
||||
&DialogManager::helpCallback,
|
||||
(XtPointer) dcb );
|
||||
else
|
||||
{
|
||||
Widget w = XmSelectionBoxGetChild ( dialog,
|
||||
XmDIALOG_HELP_BUTTON );
|
||||
XtUnmanageChild ( w );
|
||||
}
|
||||
|
||||
// Post the dialog.
|
||||
|
||||
XtManageChild ( dialog );
|
||||
|
||||
|
||||
return dialog;
|
||||
}
|
||||
69
cde/programs/dtmail/MotifApp/QuestionDialogManager.C
Normal file
69
cde/programs/dtmail/MotifApp/QuestionDialogManager.C
Normal file
@@ -0,0 +1,69 @@
|
||||
/* $XConsortium: QuestionDialogManager.C /main/4 1996/04/21 19:40:33 drk $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// QuestionDialogManager.C:
|
||||
//////////////////////////////////////////////////////////
|
||||
#include "QuestionDialogManager.h"
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/MessageB.h>
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
// Define an instance to be available throughout the framework.
|
||||
|
||||
QuestionDialogManager *theQuestionDialogManager =
|
||||
new QuestionDialogManager ( "QuestionDialog", "QuestionDialog" );
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
QuestionDialogManager::QuestionDialogManager ( char *name ) :
|
||||
DialogManager ( name )
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
Widget QuestionDialogManager::createDialog ( Widget parent )
|
||||
{
|
||||
Widget dialog = XmCreateQuestionDialog ( parent, _name, NULL, 0);
|
||||
|
||||
XtVaSetValues ( dialog,
|
||||
XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
|
||||
NULL );
|
||||
|
||||
return dialog;
|
||||
}
|
||||
99
cde/programs/dtmail/MotifApp/QuitCmd.C
Normal file
99
cde/programs/dtmail/MotifApp/QuitCmd.C
Normal file
@@ -0,0 +1,99 @@
|
||||
/* $XConsortium: QuitCmd.C /main/4 1995/12/07 15:27:45 rswiston $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// QuitCmd.C: Exit an application after checking with user.
|
||||
//////////////////////////////////////////////////////////
|
||||
#include "QuitCmd.h"
|
||||
#include <stdlib.h>
|
||||
#include "MainWindow.h"
|
||||
#include "Application.h"
|
||||
|
||||
#include <nl_types.h>
|
||||
extern nl_catd catd;
|
||||
|
||||
#include "NLS.hh"
|
||||
|
||||
QuitCmd::QuitCmd ( char *name, char *label, int active, MainWindow *mywindow) :
|
||||
WarnNoUndoCmd ( name, label, active )
|
||||
{
|
||||
_mywindow = mywindow;
|
||||
_dialogParentWidget = _mywindow->baseWidget();
|
||||
setQuestion ( GETMSG(catd, 1, 9, "Close this folder?") );
|
||||
}
|
||||
|
||||
void QuitCmd::doit()
|
||||
{
|
||||
_mywindow->quit();
|
||||
|
||||
// exit(status);
|
||||
}
|
||||
|
||||
|
||||
// If there are no windows in the application (say, none have been created!)
|
||||
// or if its the last window and the user wants to close it, enquire whether
|
||||
// the user intends to quit the session since that is what closing the last
|
||||
// window means!
|
||||
//
|
||||
|
||||
|
||||
// HI wants the Quit to "just happen" -- they don't want any dialog
|
||||
// to come up when user chooses to Close a container.
|
||||
// Just call doit().
|
||||
// Retain code in case they change their mind and later decide to
|
||||
// have a confirm dialog...
|
||||
// void
|
||||
// QuitCmd::execute()
|
||||
// {
|
||||
// if (theApplication->num_windows() <= 1) {
|
||||
// char *qq = "Exit this session?";
|
||||
// setQuestion(qq);
|
||||
// this->AskFirstCmd::execute();
|
||||
// }
|
||||
// else {
|
||||
// this->AskFirstCmd::execute();
|
||||
// }
|
||||
// }
|
||||
|
||||
void
|
||||
QuitCmd::execute()
|
||||
{
|
||||
this->doit();
|
||||
}
|
||||
|
||||
|
||||
86
cde/programs/dtmail/MotifApp/ScrollingList.C
Normal file
86
cde/programs/dtmail/MotifApp/ScrollingList.C
Normal file
@@ -0,0 +1,86 @@
|
||||
/* $XConsortium: ScrollingList.C /main/3 1995/11/06 16:02:12 rswiston $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// ScrollingList.C:
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ScrollingList.h"
|
||||
#include "Help.hh"
|
||||
|
||||
|
||||
ScrollingList::ScrollingList( Widget parent, char *name ) : UIComponent( name )
|
||||
{
|
||||
|
||||
#if defined(aix_bidi)
|
||||
//This is a temporary solution for defect 179364 and 179532
|
||||
// the resource "textMode should be dropped off after 179364 gets fixed
|
||||
Arg args[1];
|
||||
XtSetArg(args[0],"textMode",XmTEXT_MODE_EXPLICIT);
|
||||
_w = XmCreateScrolledList( parent, name, args, 1 );
|
||||
#else
|
||||
_w = XmCreateScrolledList( parent, name, NULL, 0 );
|
||||
#endif
|
||||
|
||||
printHelpId("_w", _w);
|
||||
/* add help callback */
|
||||
// XtAddCallback(_w, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
XtAddCallback( _w,
|
||||
XmNdefaultActionCallback,
|
||||
(XtCallbackProc) &ScrollingList::defaultActionCallback,
|
||||
this );
|
||||
installDestroyHandler();
|
||||
}
|
||||
|
||||
ScrollingList::~ScrollingList ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ScrollingList::defaultActionCallback( Widget w,
|
||||
XtPointer clientData,
|
||||
XmListCallbackStruct *cbs )
|
||||
{
|
||||
ScrollingList *obj = ( ScrollingList *) clientData;
|
||||
obj->defaultAction( w, clientData, cbs );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
382
cde/programs/dtmail/MotifApp/SelectFileCmd.C
Normal file
382
cde/programs/dtmail/MotifApp/SelectFileCmd.C
Normal file
@@ -0,0 +1,382 @@
|
||||
/* $TOG: SelectFileCmd.C /main/9 1998/10/26 17:57:37 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993, 1994, 1995 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// SelectFileCmd.C:
|
||||
//////////////////////////////////////////////////////////
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "SelectFileCmd.h"
|
||||
#include "Application.h"
|
||||
#include <Xm/FileSB.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include "Help.hh"
|
||||
|
||||
#include <nl_types.h>
|
||||
extern nl_catd catd;
|
||||
|
||||
#include "NLS.hh"
|
||||
|
||||
extern "C" {
|
||||
#include <Dt/HourGlass.h>
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
extern XtPointer _XmStringUngenerate (
|
||||
XmString string,
|
||||
XmStringTag tag,
|
||||
XmTextType tag_type,
|
||||
XmTextType output_type);
|
||||
}
|
||||
|
||||
|
||||
extern forceUpdate( Widget );
|
||||
|
||||
SelectFileCmd::SelectFileCmd (const char * name,
|
||||
const char * label,
|
||||
const char * title,
|
||||
const char * ok_label,
|
||||
int active,
|
||||
FileCallback ok_callback,
|
||||
void *ok_clientData,
|
||||
Widget parent) :
|
||||
NoUndoCmd ((char *)name, (char *)label, active )
|
||||
{
|
||||
_ok_label = (ok_label ? strdup(ok_label) : strdup("OK"));
|
||||
_title = (title ? strdup(title) : strdup(name));
|
||||
_ok_callback = ok_callback;
|
||||
_ok_clientData = ok_clientData;
|
||||
_cancel_callback = NULL;
|
||||
_cancel_clientData = NULL;
|
||||
_fileBrowser = NULL;
|
||||
_parentWidget = parent;
|
||||
}
|
||||
|
||||
SelectFileCmd::SelectFileCmd (const char * name,
|
||||
const char * label,
|
||||
const char * title,
|
||||
const char * ok_label,
|
||||
int active,
|
||||
FileCallback ok_callback,
|
||||
void *ok_clientData,
|
||||
FileCallback cancel_callback,
|
||||
void *cancel_clientData,
|
||||
Widget parent) :
|
||||
NoUndoCmd ((char *)name, (char *)label, active )
|
||||
{
|
||||
_ok_label = (ok_label ? strdup(ok_label) : strdup("OK"));
|
||||
_title = (title ? strdup(title) : strdup(name));
|
||||
_ok_callback = ok_callback;
|
||||
_ok_clientData = ok_clientData;
|
||||
_cancel_callback = cancel_callback;
|
||||
_cancel_clientData = cancel_clientData;
|
||||
_fileBrowser = NULL;
|
||||
_parentWidget = parent;
|
||||
}
|
||||
|
||||
SelectFileCmd::~SelectFileCmd()
|
||||
{
|
||||
free(_ok_label);
|
||||
free(_title);
|
||||
}
|
||||
|
||||
|
||||
void SelectFileCmd::doit()
|
||||
{
|
||||
// Create a FileSelectionBox widget
|
||||
|
||||
Arg args[1];
|
||||
Cardinal n = 0;
|
||||
XmString title;
|
||||
|
||||
// If the FSB already exists and is managed, raise it.
|
||||
|
||||
if (_fileBrowser) {
|
||||
XtManageChild ( _fileBrowser );
|
||||
XtPopup (XtParent(_fileBrowser), XtGrabNone );
|
||||
XRaiseWindow(XtDisplay(_fileBrowser), XtWindow(XtParent(_fileBrowser)));
|
||||
forceUpdate(_fileBrowser);
|
||||
return;
|
||||
}
|
||||
|
||||
// If there is no FSB, create it and manage it.
|
||||
// If there is one, just manage it.
|
||||
|
||||
// Creating one is different from the book. cast required.
|
||||
// Also, its the "new CDE" FSB!
|
||||
|
||||
if (!_fileBrowser) {
|
||||
_DtTurnOnHourGlass(_parentWidget);
|
||||
|
||||
_fileBrowser =
|
||||
XmCreateFileSelectionDialog (_parentWidget,
|
||||
(char *) name(),
|
||||
args, n );
|
||||
// Set the title right...
|
||||
title = XmStringCreateLocalized(_title);
|
||||
XmString ok_str = XmStringCreateLocalized(_ok_label);
|
||||
XtVaSetValues(_fileBrowser,
|
||||
XmNdialogTitle, title,
|
||||
XmNokLabelString, ok_str,
|
||||
NULL);
|
||||
XmStringFree(title);
|
||||
XmStringFree(ok_str);
|
||||
XmString hidden_str = XmStringCreateLocalized(
|
||||
GETMSG(catd, 1, 11, "Show hidden folders and files"));
|
||||
_hidden_button = XtVaCreateManagedWidget(
|
||||
"hidden", xmToggleButtonWidgetClass,
|
||||
_fileBrowser,
|
||||
XmNlabelString, hidden_str,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
XmNnavigationType, XmSTICKY_TAB_GROUP,
|
||||
XmNsensitive, TRUE,
|
||||
NULL);
|
||||
XmStringFree(hidden_str);
|
||||
|
||||
printHelpId("_fileBrowser", _fileBrowser);
|
||||
/* add help callback */
|
||||
// XtAddCallback(_fileBrowser, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
// Set up the callback to be called when the user chooses a file
|
||||
|
||||
XtAddCallback ( _fileBrowser,
|
||||
XmNokCallback,
|
||||
&SelectFileCmd::fileSelectedCB,
|
||||
(XtPointer) this );
|
||||
XtAddCallback ( _fileBrowser,
|
||||
XmNcancelCallback,
|
||||
&SelectFileCmd::fileCanceledCB,
|
||||
(XtPointer) this );
|
||||
XtAddCallback(_hidden_button,
|
||||
XmNvalueChangedCallback,
|
||||
&SelectFileCmd::hiddenCB,
|
||||
this);
|
||||
|
||||
XtSetSensitive(
|
||||
XmFileSelectionBoxGetChild(_fileBrowser, XmDIALOG_HELP_BUTTON),
|
||||
False);
|
||||
|
||||
_DtTurnOffHourGlass(_parentWidget);
|
||||
}
|
||||
|
||||
// Display the dialog
|
||||
|
||||
XtManageChild ( _fileBrowser );
|
||||
|
||||
// Raise it, because it might be buried.
|
||||
//
|
||||
XRaiseWindow(XtDisplay(_fileBrowser), XtWindow(XtParent(_fileBrowser)));
|
||||
}
|
||||
|
||||
void SelectFileCmd::fileSelectedCB(
|
||||
Widget w,
|
||||
XtPointer clientData,
|
||||
XtPointer callData)
|
||||
{
|
||||
SelectFileCmd * obj = (SelectFileCmd *) clientData;
|
||||
XmFileSelectionBoxCallbackStruct *cb =
|
||||
(XmFileSelectionBoxCallbackStruct *) callData;
|
||||
char *name = NULL;
|
||||
|
||||
// XtUnmanageChild ( w ); // Bring the file selection dialog down.
|
||||
|
||||
if (cb->value)
|
||||
{
|
||||
// Extract the first character string matching the default
|
||||
// character set from the compound string
|
||||
name = (char *) _XmStringUngenerate(
|
||||
cb->value, NULL,
|
||||
XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
|
||||
// if the name is a null string ( no file is selected)
|
||||
// we should pop up an error dialog to let user know
|
||||
// that he/she did not specify file name. But because
|
||||
// the message cat file is frozen, we can not add any
|
||||
// new msg. Just free the name and return.
|
||||
// see aix defect 176761.
|
||||
if(NULL == name) return;
|
||||
if (strlen(name)<1)
|
||||
{
|
||||
free(name);
|
||||
return;
|
||||
}
|
||||
|
||||
// If a string was succesfully extracted, call
|
||||
// fileSelected to handle the file.
|
||||
|
||||
XtUnmanageChild ( w ); // Bring the file selection dialog down.
|
||||
obj->fileSelected ( name );
|
||||
}
|
||||
}
|
||||
|
||||
void SelectFileCmd::fileCanceledCB ( Widget w,
|
||||
XtPointer clientData,
|
||||
XtPointer )
|
||||
{
|
||||
SelectFileCmd * obj = (SelectFileCmd *) clientData;
|
||||
|
||||
XtUnmanageChild(w); // Bring the file selection dialog down.
|
||||
obj->fileCanceled();
|
||||
}
|
||||
|
||||
void SelectFileCmd::fileSelected ( char *filename )
|
||||
{
|
||||
if ( _ok_callback )
|
||||
_ok_callback ( _ok_clientData, filename );
|
||||
}
|
||||
|
||||
void SelectFileCmd::fileCanceled ()
|
||||
{
|
||||
if ( _cancel_callback )
|
||||
_cancel_callback ( _cancel_clientData, NULL );
|
||||
}
|
||||
|
||||
void
|
||||
SelectFileCmd::hiddenCB(Widget,
|
||||
XtPointer client_data,
|
||||
XtPointer cb_data)
|
||||
{
|
||||
SelectFileCmd * self = (SelectFileCmd *)client_data;
|
||||
XmToggleButtonCallbackStruct *cbs = (XmToggleButtonCallbackStruct*) cb_data;
|
||||
|
||||
self->doHidden(cbs->set);
|
||||
}
|
||||
|
||||
void
|
||||
SelectFileCmd::doHidden(int on)
|
||||
{
|
||||
XtEnum style;
|
||||
style = (on) ? XmFILTER_NONE : XmFILTER_HIDDEN_FILES;
|
||||
XtVaSetValues(_fileBrowser, XmNfileFilterStyle, style, NULL);
|
||||
XmFileSelectionDoSearch(_fileBrowser, NULL);
|
||||
}
|
||||
|
||||
char *
|
||||
SelectFileCmd::getDirectory()
|
||||
{
|
||||
XmString directory;
|
||||
char *path;
|
||||
|
||||
if (NULL == _fileBrowser)
|
||||
return NULL;
|
||||
|
||||
// Get the default selection.
|
||||
XtVaGetValues(_fileBrowser, XmNdirectory, &directory, NULL);
|
||||
path = (char *)
|
||||
_XmStringUngenerate(directory, NULL, XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
|
||||
XmStringFree(directory);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
char *
|
||||
SelectFileCmd::getSelected()
|
||||
{
|
||||
Widget text;
|
||||
char *path = NULL;
|
||||
|
||||
if (NULL == _fileBrowser)
|
||||
return NULL;
|
||||
|
||||
// Set the default selection.
|
||||
text = XtNameToWidget(_fileBrowser, "Text");
|
||||
if (NULL != text)
|
||||
XtVaGetValues(text, XmNvalue, &path, NULL);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
int
|
||||
SelectFileCmd::getHidden()
|
||||
{
|
||||
int val;
|
||||
unsigned char current_state;
|
||||
|
||||
if (NULL == _fileBrowser || NULL == _hidden_button)
|
||||
return 0;
|
||||
|
||||
XtVaGetValues(_hidden_button, XmNset, ¤t_state, NULL);
|
||||
val = (current_state == XmSET) ? 1 : 0;
|
||||
return val;
|
||||
}
|
||||
|
||||
void
|
||||
SelectFileCmd::setDirectory(char *path)
|
||||
{
|
||||
XmString directory;
|
||||
|
||||
if (NULL == _fileBrowser)
|
||||
return;
|
||||
|
||||
// Set the default directory where the file selection box points.
|
||||
directory = XmStringCreateLocalized(path);
|
||||
XtVaSetValues(_fileBrowser, XmNdirectory, directory, NULL);
|
||||
XmStringFree(directory);
|
||||
}
|
||||
|
||||
void
|
||||
SelectFileCmd::setSelected(char *path)
|
||||
{
|
||||
Widget text;
|
||||
|
||||
if (NULL == _fileBrowser)
|
||||
return;
|
||||
|
||||
// Set the default selection.
|
||||
text = XtNameToWidget(_fileBrowser, "Text");
|
||||
if (NULL != text)
|
||||
XtVaSetValues(text, XmNvalue, path, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
SelectFileCmd::setHidden(int on)
|
||||
{
|
||||
unsigned char current_state;
|
||||
unsigned char desired_state;
|
||||
|
||||
if (NULL == _fileBrowser || NULL == _hidden_button)
|
||||
return;
|
||||
|
||||
desired_state = (on) ? XmSET : XmUNSET;
|
||||
XtVaGetValues(_hidden_button, XmNset, ¤t_state, NULL);
|
||||
if (current_state == desired_state)
|
||||
return;
|
||||
|
||||
XtVaSetValues(_hidden_button, XmNset, desired_state, NULL);
|
||||
doHidden(on);
|
||||
}
|
||||
117
cde/programs/dtmail/MotifApp/ToggleButtonInterface.C
Normal file
117
cde/programs/dtmail/MotifApp/ToggleButtonInterface.C
Normal file
@@ -0,0 +1,117 @@
|
||||
/* $TOG: ToggleButtonInterface.C /main/6 1998/09/21 18:50:08 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////
|
||||
// ToggleButtonInterface.C: A toggle button interface to a Cmd object
|
||||
///////////////////////////////////////////////////////////////
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "Cmd.h"
|
||||
#include "MotifCmds.h"
|
||||
#include "ToggleButtonInterface.h"
|
||||
#include <Xm/ToggleB.h>
|
||||
#include "Help.hh"
|
||||
|
||||
ToggleButtonInterface::ToggleButtonInterface (
|
||||
Widget parent,
|
||||
Cmd *cmd
|
||||
) : CmdInterface ( cmd )
|
||||
{
|
||||
|
||||
// We need to generate a button name that doesn't have illegal characters.
|
||||
//
|
||||
char *w_name = new char[200];
|
||||
strcpy(w_name, _name);
|
||||
for (char * cur = w_name; *cur; cur++) {
|
||||
if (isspace(*cur) || *cur == ',') {
|
||||
*cur = '_';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*cur == '.') {
|
||||
*cur = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XmString label = XmStringCreateLocalized(cmd->getLabel());
|
||||
|
||||
if (0 == strcmp(cmd->className(),"ToggleButtonCmd"))
|
||||
{
|
||||
ToggleButtonCmd *tbc = (ToggleButtonCmd*) cmd;
|
||||
Boolean visible_when_off = tbc->visibleWhenOff();
|
||||
unsigned char indicator_type = tbc->indicatorType();
|
||||
|
||||
_w = XtVaCreateWidget (w_name,
|
||||
xmToggleButtonWidgetClass,
|
||||
parent,
|
||||
XmNlabelString, label,
|
||||
XmNvisibleWhenOff, visible_when_off,
|
||||
XmNindicatorType, indicator_type,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
_w = XtVaCreateWidget (w_name,
|
||||
xmToggleButtonWidgetClass,
|
||||
parent,
|
||||
XmNlabelString, label,
|
||||
XmNvisibleWhenOff, TRUE,
|
||||
NULL);
|
||||
|
||||
XmStringFree(label);
|
||||
|
||||
printHelpId("_w", _w);
|
||||
|
||||
// XtAddCallback(_w, XmNhelpCallback, HelpCB, helpId);
|
||||
// free(helpId);
|
||||
|
||||
installDestroyHandler();
|
||||
|
||||
// The _active member is set when each instance is registered
|
||||
// with an associated Cmd object. Now that a widget exists,
|
||||
// set the widget's sensitivity according to its active state.
|
||||
|
||||
if ( _active )
|
||||
activate();
|
||||
else
|
||||
deactivate();
|
||||
|
||||
#ifdef GNU_CC // No idea what the right ifdef is for automatically recognizing g++
|
||||
|
||||
// G++ reportedly doesn't like the form expected by cfront. I'm
|
||||
// told this will work, but I haven't tested it myself.
|
||||
|
||||
XtAddCallback ( _w,
|
||||
XmNvalueChangedCallback,
|
||||
executeCmdCallback,
|
||||
(XtPointer) this );
|
||||
#else
|
||||
|
||||
XtAddCallback ( _w,
|
||||
XmNvalueChangedCallback,
|
||||
&CmdInterface::executeCmdCallback,
|
||||
(XtPointer) this );
|
||||
#endif
|
||||
delete [] w_name;
|
||||
}
|
||||
|
||||
#ifndef CAN_INLINE_VIRTUALS
|
||||
ToggleButtonInterface::~ToggleButtonInterface (void)
|
||||
{
|
||||
}
|
||||
#endif /* ! CAN_INLINE_VIRTUALS */
|
||||
237
cde/programs/dtmail/MotifApp/UIComponent.C
Normal file
237
cde/programs/dtmail/MotifApp/UIComponent.C
Normal file
@@ -0,0 +1,237 @@
|
||||
/* $TOG: UIComponent.C /main/9 1998/07/23 17:57:36 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// UIComponent.C: Base class for all C++/Motif UI components
|
||||
///////////////////////////////////////////////////////////////
|
||||
#include <Dt/Wsm.h>
|
||||
#include "UIComponent.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
UIComponent::UIComponent ( const char *name ) : BasicComponent ( name )
|
||||
{
|
||||
// Empty
|
||||
_numPendingTasks = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
UIComponent::widgetDestroyedCallback( Widget,
|
||||
XtPointer clientData,
|
||||
XtPointer )
|
||||
{
|
||||
UIComponent * obj = (UIComponent *) clientData;
|
||||
|
||||
obj->widgetDestroyed();
|
||||
}
|
||||
|
||||
void
|
||||
UIComponent::widgetDestroyed()
|
||||
{
|
||||
_w = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
UIComponent::installDestroyHandler()
|
||||
{
|
||||
assert ( _w != NULL );
|
||||
XtAddCallback ( _w,
|
||||
XmNdestroyCallback,
|
||||
&UIComponent::widgetDestroyedCallback,
|
||||
(XtPointer) this );
|
||||
}
|
||||
|
||||
void
|
||||
UIComponent::manage()
|
||||
{
|
||||
assert ( _w != NULL );
|
||||
assert ( XtHasCallbacks ( _w, XmNdestroyCallback ) ==
|
||||
XtCallbackHasSome );
|
||||
XtManageChild ( _w );
|
||||
}
|
||||
|
||||
void
|
||||
UIComponent::displayInCurrentWorkspace()
|
||||
{
|
||||
Widget w = baseWidget();
|
||||
while (w && !XtIsShell(w)) w = XtParent(w);
|
||||
if (w && XtIsShell(w)) displayInCurrentWorkspace(w);
|
||||
manage();
|
||||
}
|
||||
|
||||
void
|
||||
UIComponent::displayInCurrentWorkspace(Widget shell)
|
||||
{
|
||||
while (shell && !XtIsShell(shell)) shell = XtParent(shell);
|
||||
|
||||
// Make sure the shell is popped up and occupying the current workspace.
|
||||
if (NULL != shell && XtIsShell(shell))
|
||||
{
|
||||
Atom pCurrent;
|
||||
Display *display = XtDisplay(shell);
|
||||
Window window = XtWindow(shell);
|
||||
|
||||
XtVaSetValues(shell, XmNiconic, False, NULL);
|
||||
XRaiseWindow(display, window);
|
||||
|
||||
/* Get the current Workspace */
|
||||
if (Success == DtWsmGetCurrentWorkspace(
|
||||
display,
|
||||
XRootWindowOfScreen(XtScreen(shell)),
|
||||
&pCurrent))
|
||||
{
|
||||
Atom *ws = NULL;
|
||||
unsigned long num = 0;
|
||||
int k;
|
||||
|
||||
if (Success==DtWsmGetWorkspacesOccupied(display, window, &ws, &num))
|
||||
{
|
||||
/* Already in this workspace? */
|
||||
for (k = 0; k < num; k++)
|
||||
if (ws[k] == pCurrent) break;
|
||||
|
||||
/* Add to the workspace */
|
||||
if (k >= num)
|
||||
{
|
||||
size_t nbytes = sizeof(Atom) * (num+1);
|
||||
ws = (Atom*) XtRealloc((char*) ws, nbytes);
|
||||
ws[num] = pCurrent;
|
||||
DtWsmSetWorkspacesOccupied(display, window, ws, num + 1);
|
||||
}
|
||||
|
||||
XFree((char *)ws);
|
||||
}
|
||||
else
|
||||
/* Change the hints to reflect the current workspace */
|
||||
DtWsmSetWorkspacesOccupied(display, window, &pCurrent, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UIComponent::~UIComponent()
|
||||
{
|
||||
// Make sure the widget hasn't already been destroyed
|
||||
|
||||
if ( _w )
|
||||
{
|
||||
// Remove destroy callback so Xt can't call the callback
|
||||
// with a pointer to an object that has already been freed
|
||||
|
||||
XtRemoveCallback ( _w,
|
||||
XmNdestroyCallback,
|
||||
&UIComponent::widgetDestroyedCallback,
|
||||
(XtPointer) this );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UIComponent::getResources( const XtResourceList resources,
|
||||
const int numResources )
|
||||
{
|
||||
// Check for errors
|
||||
|
||||
assert ( _w != NULL );
|
||||
assert ( resources != NULL );
|
||||
|
||||
// Retrieve the requested resources relative to the
|
||||
// parent of this object's base widget
|
||||
// Added support for doing getResources on the Application
|
||||
|
||||
if ( XtParent( _w ) )
|
||||
XtGetSubresources ( XtParent( _w ),
|
||||
(XtPointer) this,
|
||||
_name,
|
||||
className(),
|
||||
resources,
|
||||
numResources,
|
||||
NULL,
|
||||
0 );
|
||||
else
|
||||
XtGetSubresources ( _w ,
|
||||
(XtPointer) this,
|
||||
_name,
|
||||
className(),
|
||||
resources,
|
||||
numResources,
|
||||
NULL,
|
||||
0 );
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
void
|
||||
UIComponent::setDefaultResources( const Widget w,
|
||||
const String *resourceSpec )
|
||||
{
|
||||
int i;
|
||||
Display *dpy = XtDisplay ( w ); // Retrieve the display pointer
|
||||
XrmDatabase rdb = NULL; // A resource data base
|
||||
|
||||
// Create an empty resource database
|
||||
|
||||
rdb = XrmGetStringDatabase ( "" );
|
||||
|
||||
// Add the Component resources, prepending the name of the component
|
||||
|
||||
i = 0;
|
||||
while ( resourceSpec[i] != NULL )
|
||||
{
|
||||
char *buf = new char[1000];
|
||||
sprintf(buf, "*%s%s", _name, resourceSpec[i++]);
|
||||
XrmPutLineResource( &rdb, buf );
|
||||
delete [] buf;
|
||||
}
|
||||
|
||||
// Merge them into the Xt database, with lowest precendence
|
||||
|
||||
if ( rdb )
|
||||
{
|
||||
XrmDatabase db = XtDatabase(dpy);
|
||||
XrmCombineDatabase(rdb, &db, FALSE);
|
||||
}
|
||||
}
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
#ifndef CAN_INLINE_VIRTUALS
|
||||
const char *const
|
||||
UIComponent::className(void)
|
||||
{
|
||||
return "UIComponent";
|
||||
}
|
||||
#endif /* ! CAN_INLINE_VIRTUALS */
|
||||
67
cde/programs/dtmail/MotifApp/UndoCmd.C
Normal file
67
cde/programs/dtmail/MotifApp/UndoCmd.C
Normal file
@@ -0,0 +1,67 @@
|
||||
/* $XConsortium: UndoCmd.C /main/3 1995/11/06 16:02:46 rswiston $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// UndoCmd.C: An interface to undoing the last command
|
||||
//////////////////////////////////////////////////////////
|
||||
#include "UndoCmd.h"
|
||||
|
||||
#define NULL 0
|
||||
|
||||
// Declare a global object: theUndoCmd
|
||||
|
||||
UndoCmd *theUndoCmd = new UndoCmd ( "Undo", "Undo" );
|
||||
|
||||
UndoCmd::UndoCmd ( char *name, char *label ) : NoUndoCmd ( name, label, 0 )
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
void UndoCmd::doit()
|
||||
{
|
||||
// If there is a current command, undo it
|
||||
|
||||
if ( _lastCmd != NULL )
|
||||
{
|
||||
// Undo the previous command
|
||||
|
||||
_lastCmd->undo();
|
||||
|
||||
_lastCmd = NULL; // Make sure we can't undo twice
|
||||
}
|
||||
}
|
||||
61
cde/programs/dtmail/MotifApp/WarnNoUndoCmd.C
Normal file
61
cde/programs/dtmail/MotifApp/WarnNoUndoCmd.C
Normal file
@@ -0,0 +1,61 @@
|
||||
/* $XConsortium: WarnNoUndoCmd.C /main/4 1995/12/07 15:28:22 rswiston $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// WarnNoUndoCmd.C: Warns user before executing a command
|
||||
//////////////////////////////////////////////////////////
|
||||
#include "WarnNoUndoCmd.h"
|
||||
|
||||
#include <nl_types.h>
|
||||
extern nl_catd catd;
|
||||
|
||||
#include "NLS.hh"
|
||||
|
||||
WarnNoUndoCmd::WarnNoUndoCmd ( char *name, char *label, int active) :
|
||||
AskFirstCmd ( name, label, active )
|
||||
{
|
||||
_hasUndo = 0; // Specify that there is no undo
|
||||
|
||||
setQuestion ( GETMSG(catd, 1, 10,
|
||||
"This command cannot be undone. Proceed anyway?") );
|
||||
}
|
||||
|
||||
void WarnNoUndoCmd::undoit()
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
211
cde/programs/dtmail/MotifApp/WorkingDialogManager.C
Normal file
211
cde/programs/dtmail/MotifApp/WorkingDialogManager.C
Normal file
@@ -0,0 +1,211 @@
|
||||
/* $XConsortium: WorkingDialogManager.C /main/4 1996/04/21 19:40:36 drk $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: WorkingDialogManager.C /main/4 1996/04/21 19:40:36 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// WorkingDialogManager.C:
|
||||
//////////////////////////////////////////////////////////
|
||||
#include "WorkingDialogManager.h"
|
||||
#include "Application.h"
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/MessageB.h>
|
||||
#include <Xm/Scale.h>
|
||||
#include "BusyPixmap.h"
|
||||
#include <assert.h>
|
||||
|
||||
WorkingDialogManager *theWorkingDialogManager =
|
||||
new WorkingDialogManager ( "WorkingDialog" );
|
||||
|
||||
WorkingDialogManager::WorkingDialogManager ( char *name ) :
|
||||
DialogManager ( name )
|
||||
{
|
||||
_intervalId = NULL;
|
||||
_busyPixmaps = NULL;
|
||||
}
|
||||
|
||||
Widget WorkingDialogManager::createDialog ( Widget parent )
|
||||
{
|
||||
Widget dialog = XmCreateWorkingDialog ( parent, _name, NULL, 0 );
|
||||
|
||||
XtVaSetValues ( dialog,
|
||||
XmNdialogStyle, XmDIALOG_PRIMARY_APPLICATION_MODAL,
|
||||
NULL );
|
||||
|
||||
XtAddCallback ( dialog,
|
||||
XmNokCallback,
|
||||
&WorkingDialogManager::unpostCallback,
|
||||
(XtPointer) this );
|
||||
|
||||
XtAddCallback ( dialog,
|
||||
XmNcancelCallback,
|
||||
&WorkingDialogManager::unpostCallback,
|
||||
(XtPointer) this );
|
||||
|
||||
// if ( !_busyPixmaps )
|
||||
// _busyPixmaps = new BusyPixmap ( dialog );
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
Widget WorkingDialogManager::post (char *title,
|
||||
char *text,
|
||||
void *clientData,
|
||||
DialogCallback ok,
|
||||
DialogCallback cancel,
|
||||
DialogCallback help )
|
||||
{
|
||||
// The the dialog already exists, and is currently in use,
|
||||
// just return this dialog. The WorkingDialogManager
|
||||
// only supports one dialog.
|
||||
|
||||
if ( _w && XtIsManaged ( _w ) )
|
||||
return _w;
|
||||
|
||||
// Pass the message on to the base class
|
||||
|
||||
DialogManager::post (title, text, clientData, ok, cancel, help );
|
||||
|
||||
// Call timer to start an animation sequence for this dialog
|
||||
|
||||
timer();
|
||||
forceUpdate( _w );
|
||||
return _w;
|
||||
}
|
||||
|
||||
Widget
|
||||
WorkingDialogManager::post (char *title,
|
||||
char *text,
|
||||
Widget wid,
|
||||
void *clientData,
|
||||
DialogCallback ok,
|
||||
DialogCallback cancel,
|
||||
DialogCallback help )
|
||||
{
|
||||
// The the dialog already exists, and is currently in use,
|
||||
// just return this dialog. The WorkingDialogManager
|
||||
// only supports one dialog.
|
||||
|
||||
if ( _w && XtIsManaged ( _w ) )
|
||||
return _w;
|
||||
|
||||
// Pass the message on to the base class
|
||||
|
||||
DialogManager::post (title, text, wid, clientData, ok, cancel, help );
|
||||
|
||||
// Call timer to start an animation sequence for this dialog
|
||||
|
||||
timer();
|
||||
forceUpdate( _w );
|
||||
return _w;
|
||||
}
|
||||
|
||||
void WorkingDialogManager::timerCallback ( XtPointer clientData,
|
||||
XtIntervalId * )
|
||||
{
|
||||
WorkingDialogManager *obj = ( WorkingDialogManager * ) clientData;
|
||||
|
||||
obj->timer();
|
||||
}
|
||||
|
||||
void WorkingDialogManager::timer ()
|
||||
{
|
||||
if ( !_w )
|
||||
return;
|
||||
|
||||
|
||||
// Reinstall the time-out callback to be called again
|
||||
|
||||
_intervalId =
|
||||
XtAppAddTimeOut ( XtWidgetToApplicationContext ( _w ),
|
||||
250,
|
||||
&WorkingDialogManager::timerCallback,
|
||||
( XtPointer ) this );
|
||||
|
||||
// Get the next pixmap in the animation sequence and display
|
||||
// it in the dialog's symbol area.
|
||||
|
||||
// XtVaSetValues ( _w,
|
||||
// XmNsymbolPixmap, _busyPixmaps->next(),
|
||||
// NULL );
|
||||
forceUpdate( _w );
|
||||
|
||||
}
|
||||
|
||||
void WorkingDialogManager::unpostCallback ( Widget ,
|
||||
XtPointer clientData,
|
||||
XtPointer )
|
||||
{
|
||||
WorkingDialogManager *obj = ( WorkingDialogManager* ) clientData;
|
||||
|
||||
obj->unpost();
|
||||
}
|
||||
|
||||
void WorkingDialogManager::unpost ()
|
||||
{
|
||||
assert ( _w != NULL );
|
||||
|
||||
// Remove the dialog from the screen
|
||||
|
||||
XtUnmanageChild ( _w );
|
||||
|
||||
// Stop the animation
|
||||
|
||||
if ( _intervalId )
|
||||
XtRemoveTimeOut ( _intervalId );
|
||||
}
|
||||
|
||||
void WorkingDialogManager::updateMessage ( char *text )
|
||||
{
|
||||
if ( _w )
|
||||
{
|
||||
|
||||
// Just change the string displayed in the dialog
|
||||
|
||||
XmString xmstr = XmStringCreateLocalized ( text );
|
||||
XtVaSetValues ( _w, XmNmessageString, xmstr, NULL );
|
||||
XmStringFree ( xmstr );
|
||||
}
|
||||
forceUpdate( _w );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
5
cde/programs/dtmail/MotifApp/motifapp.nlset
Normal file
5
cde/programs/dtmail/MotifApp/motifapp.nlset
Normal file
@@ -0,0 +1,5 @@
|
||||
$ MotifApp set file
|
||||
$ Used in conjunction with "genmsg"
|
||||
$
|
||||
1 12
|
||||
2 2
|
||||
405
cde/programs/dtmail/dtmail/AliasListUiItem.C
Normal file
405
cde/programs/dtmail/dtmail/AliasListUiItem.C
Normal file
@@ -0,0 +1,405 @@
|
||||
/* $TOG: AliasListUiItem.C /main/6 1997/09/03 17:33:31 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: AliasListUiItem.C /main/6 1997/09/03 17:33:31 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include "RoamApp.h"
|
||||
#include <Xm/List.h>
|
||||
#include <DtMail/options_util.h>
|
||||
#include "options_ui.h"
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/ListUiItem.hh>
|
||||
#include <DtMail/AliasListUiItem.hh>
|
||||
|
||||
extern Boolean props_changed;
|
||||
void alias_stuffing_func(char * key, void * data, void * client_data);
|
||||
void handleAliasSelection(Widget w, XtPointer clientdata, XtPointer calldata);
|
||||
|
||||
// AliasListUiItem::AliasListUiItem
|
||||
// AliasListUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
AliasListUiItem::AliasListUiItem(Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
Widget key_entry_widget,
|
||||
Widget value_entry_widget):ListUiItem(w, source, search_key, NULL)
|
||||
{
|
||||
source = source; search_key = search_key;
|
||||
|
||||
key_widget = key_entry_widget;
|
||||
value_widget = value_entry_widget;
|
||||
|
||||
list_items = NULL;
|
||||
deleted_items = NULL;
|
||||
|
||||
XtVaSetValues(w,
|
||||
XmNuserData, this,
|
||||
XmNautomaticSelection, True,
|
||||
XmNselectionPolicy, XmBROWSE_SELECT,
|
||||
NULL);
|
||||
|
||||
XtAddCallback(w,
|
||||
XmNbrowseSelectionCallback,
|
||||
(XtCallbackProc)handleAliasSelection,
|
||||
(XtPointer)this);
|
||||
|
||||
}
|
||||
|
||||
//-----------------======================-----------------
|
||||
void handleAliasSelection(Widget w, XtPointer, XtPointer calldata)
|
||||
{
|
||||
AliasListUiItem *item;
|
||||
XmListCallbackStruct *list_info = (XmListCallbackStruct *)calldata;
|
||||
char *selection_string = NULL;
|
||||
DtVirtArray<PropStringPair *> *list_items;
|
||||
|
||||
XtVaGetValues(w,
|
||||
XmNuserData, &item,
|
||||
NULL);
|
||||
|
||||
list_items = item->getItemList();
|
||||
|
||||
if(list_items != NULL)
|
||||
{ // motif index is 1 based
|
||||
//virtarry is 0 based
|
||||
PropStringPair *pair = (*list_items)[list_info->item_position - 1];
|
||||
|
||||
if(pair != NULL)
|
||||
{
|
||||
XtVaSetValues(item->getKeyWidget(),
|
||||
XmNvalue,pair->label,
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(item->getValueWidget(),
|
||||
XmNvalue,pair->value,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AliasListUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void AliasListUiItem::writeFromUiToSource()
|
||||
{
|
||||
Widget w = this->getWidget();
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
int i, num_items;
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
num_items = deleted_items->length();
|
||||
|
||||
for(i = 0; i < num_items; i++)
|
||||
{
|
||||
mail_rc->removeAlias(error,(*deleted_items)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
num_items = list_items->length();
|
||||
for(i = 0; i < num_items; i++)
|
||||
{
|
||||
|
||||
mail_rc->setAlias(error,(*list_items)[i]->label,
|
||||
(*list_items)[i]->value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
delete deleted_items;
|
||||
deleted_items = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// AliasListUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
static int cmp_prop_string_pair(const void *v1, const void *v2)
|
||||
{
|
||||
PropStringPair *p1 = *((PropStringPair **) v1);
|
||||
PropStringPair *p2 = *((PropStringPair **) v2);
|
||||
int ret;
|
||||
|
||||
ret = strcmp((const char *) p1->label, (const char *) p2->label);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void AliasListUiItem::writeFromSourceToUi()
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
Widget w = this->getWidget();
|
||||
const char *list_str = NULL;
|
||||
DtVirtArray<char *> list_str_list(10);
|
||||
char *buf = NULL;
|
||||
int list_len, i;
|
||||
const char *value = NULL;
|
||||
PropStringPair **prop_pairs = NULL;
|
||||
|
||||
XmListDeleteAllItems(w);
|
||||
|
||||
if (deleted_items != NULL)
|
||||
{
|
||||
delete deleted_items;
|
||||
deleted_items = NULL;
|
||||
}
|
||||
|
||||
if (list_items != NULL)
|
||||
delete list_items;
|
||||
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
mail_rc->getAliasList(alias_stuffing_func, list_items);
|
||||
|
||||
list_len = list_items->length();
|
||||
if (list_len)
|
||||
{
|
||||
prop_pairs =
|
||||
(PropStringPair**) XtMalloc(list_len * sizeof(PropStringPair*));
|
||||
|
||||
for (i = 0; i < list_len; i++)
|
||||
{
|
||||
prop_pairs[i] = (*list_items)[0];
|
||||
list_items->remove(0);
|
||||
}
|
||||
|
||||
qsort(
|
||||
prop_pairs,
|
||||
list_len,
|
||||
sizeof(PropStringPair*),
|
||||
cmp_prop_string_pair);
|
||||
|
||||
for (i = 0; i < list_len; i++)
|
||||
list_items->append(prop_pairs[i]);
|
||||
|
||||
if (NULL != prop_pairs)
|
||||
XtFree((char*) prop_pairs);
|
||||
}
|
||||
|
||||
for (i = 0; i < list_len; i++)
|
||||
list_str_list.append(
|
||||
formatPropPair( (*list_items)[i]->label, (*list_items)[i]->value ));
|
||||
|
||||
options_list_init(w, &list_str_list);
|
||||
}
|
||||
//
|
||||
// callback for creating alias list...
|
||||
void alias_stuffing_func(char * key, void * data, void * client_data)
|
||||
{
|
||||
DtVirtArray<PropStringPair *> *alias_list = (DtVirtArray<PropStringPair *> *)client_data;
|
||||
PropStringPair *new_pair;
|
||||
|
||||
new_pair = new PropStringPair;
|
||||
|
||||
new_pair->label = strdup(key);
|
||||
new_pair->value = strdup((char *)data);
|
||||
|
||||
alias_list->append(new_pair);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
void AliasListUiItem::handleAddButtonPress()
|
||||
{
|
||||
char *key_str = NULL;
|
||||
char *value_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
|
||||
XtVaGetValues(key_widget,
|
||||
XmNvalue, &key_str,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues(value_widget,
|
||||
XmNvalue, &value_str,
|
||||
NULL);
|
||||
|
||||
if(key_str != NULL)
|
||||
if(strlen(key_str) > 0)
|
||||
{
|
||||
new_pair = new PropStringPair;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
new_pair->label = strdup(key_str);
|
||||
|
||||
if(value_str != NULL)
|
||||
new_pair->value = strdup(value_str);
|
||||
else
|
||||
new_pair->value = NULL;
|
||||
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,pos_list[0] - 1);
|
||||
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(
|
||||
formatPropPair(
|
||||
new_pair->label,
|
||||
new_pair->value)),
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
pos_list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,0);
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(
|
||||
formatPropPair(
|
||||
new_pair->label,
|
||||
new_pair->value)),
|
||||
1);
|
||||
XmListSelectPos(this->getWidget(),
|
||||
1,
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
1);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void AliasListUiItem::handleChangeButtonPress()
|
||||
{
|
||||
char *key_str = NULL;
|
||||
char *value_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
XmString replace_string;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
// if nothing selected nothing to change...
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
XtVaGetValues(key_widget,
|
||||
XmNvalue, &key_str,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues(value_widget,
|
||||
XmNvalue, &value_str,
|
||||
NULL);
|
||||
|
||||
if(key_str != NULL)
|
||||
if(strlen(key_str) > 0)
|
||||
{
|
||||
|
||||
new_pair = (*list_items)[pos_list[0] - 1];
|
||||
|
||||
if(deleted_items == NULL)
|
||||
{
|
||||
deleted_items = new DtVirtArray<char *>(10);
|
||||
}
|
||||
|
||||
deleted_items->append(strdup((*list_items)[pos_list[0] -1]->label));
|
||||
|
||||
free(new_pair->label);
|
||||
new_pair->label = strdup(key_str);
|
||||
|
||||
if(new_pair->value != NULL)
|
||||
{
|
||||
free(new_pair->value);
|
||||
if(value_str != NULL)
|
||||
new_pair->value = strdup(value_str);
|
||||
else
|
||||
new_pair->value = NULL;
|
||||
}
|
||||
|
||||
replace_string = XmStringCreateLocalized(
|
||||
formatPropPair(new_pair->label,
|
||||
new_pair->value));
|
||||
|
||||
XmListReplaceItemsPos(this->getWidget(),
|
||||
&replace_string,
|
||||
1,
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void AliasListUiItem::handleDeleteButtonPress()
|
||||
{
|
||||
Widget list_widget = this->getWidget();
|
||||
int *p_list, p_count;
|
||||
|
||||
// get the selected position
|
||||
if(XmListGetSelectedPos(list_widget,
|
||||
&p_list,
|
||||
&p_count))
|
||||
{
|
||||
|
||||
if(deleted_items == NULL)
|
||||
{
|
||||
deleted_items = new DtVirtArray<char *>(10);
|
||||
}
|
||||
|
||||
deleted_items->append(strdup((*list_items)[p_list[0] -1]->label));
|
||||
|
||||
// delete the item from our list
|
||||
this->list_items->remove(p_list[0] - 1); // remove only first
|
||||
|
||||
// delete the item from the widget
|
||||
XmListDeletePos(list_widget, p_list[0]);
|
||||
|
||||
XtVaSetValues(this->getKeyWidget(),
|
||||
XmNvalue,"",
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(this->getValueWidget(),
|
||||
XmNvalue,"",
|
||||
NULL);
|
||||
|
||||
XmListSelectPos(list_widget,
|
||||
p_list[0],
|
||||
TRUE);
|
||||
|
||||
props_changed = TRUE;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
346
cde/programs/dtmail/dtmail/AlternatesListUiItem.C
Normal file
346
cde/programs/dtmail/dtmail/AlternatesListUiItem.C
Normal file
@@ -0,0 +1,346 @@
|
||||
/* $XConsortium: AlternatesListUiItem.C /main/3 1995/11/06 16:03:45 rswiston $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
#include "RoamApp.h"
|
||||
#include <Xm/List.h>
|
||||
#include <DtMail/options_util.h>
|
||||
#include "options_ui.h"
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/ListUiItem.hh>
|
||||
#include <DtMail/AlternatesListUiItem.hh>
|
||||
|
||||
extern Boolean props_changed;
|
||||
void handleAlternateSelection(Widget w, XtPointer clientdata, XtPointer calldata);
|
||||
|
||||
// AlternatesListUiItem::AlternatesListUiItem
|
||||
// AlternatesListUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
AlternatesListUiItem::AlternatesListUiItem(Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
Widget text_entry_widget):ListUiItem(w, source, search_key, NULL)
|
||||
{
|
||||
source = source; search_key = search_key;
|
||||
|
||||
entry_field_widget = text_entry_widget;
|
||||
|
||||
list_items = NULL;
|
||||
deleted_items = NULL;
|
||||
|
||||
XtVaSetValues(w,
|
||||
XmNuserData, this,
|
||||
XmNautomaticSelection, True,
|
||||
XmNselectionPolicy, XmBROWSE_SELECT,
|
||||
NULL);
|
||||
|
||||
XtAddCallback(w,
|
||||
XmNbrowseSelectionCallback,
|
||||
(XtCallbackProc)handleAlternateSelection,
|
||||
(XtPointer)this);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
void handleAlternateSelection(Widget w, XtPointer clientdata, XtPointer calldata)
|
||||
{
|
||||
AlternatesListUiItem *item;
|
||||
XmListCallbackStruct *list_info = (XmListCallbackStruct *)calldata;
|
||||
char *selection_string = NULL;
|
||||
DtVirtArray<PropStringPair *> *list_items;
|
||||
clientdata = clientdata;
|
||||
|
||||
XtVaGetValues(w,
|
||||
XmNuserData, &item,
|
||||
NULL);
|
||||
|
||||
list_items = item->getItemList();
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
// motif index is 1 based
|
||||
//virtarry is 0 based
|
||||
PropStringPair *pair = (*list_items)[list_info->item_position - 1];
|
||||
|
||||
if(pair != NULL)
|
||||
{
|
||||
XtVaSetValues(item->getEntryFieldWidget(),
|
||||
XmNvalue,pair->label,
|
||||
NULL);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// AlternatesListUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void AlternatesListUiItem::writeFromUiToSource()
|
||||
{
|
||||
Widget w = this->getWidget();
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
int i, num_items;
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
num_items = deleted_items->length();
|
||||
|
||||
for(i = 0; i < num_items; i++)
|
||||
{
|
||||
mail_rc->removeAlternate(error,(*deleted_items)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
num_items = list_items->length();
|
||||
for(i = 0; i < num_items; i++)
|
||||
{
|
||||
mail_rc->setAlternate(error,(*list_items)[i]->label);
|
||||
}
|
||||
}
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
delete deleted_items;
|
||||
deleted_items = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// AlternatesListUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void AlternatesListUiItem::writeFromSourceToUi()
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
Widget w = this->getWidget();
|
||||
const char *list_str = NULL;
|
||||
DtVirtArray<char *> *char_list = NULL;
|
||||
PropStringPair *new_pair;
|
||||
char *token, *buf = NULL;
|
||||
|
||||
XmListDeleteAllItems(w);
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
delete deleted_items;
|
||||
deleted_items = NULL;
|
||||
}
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
delete list_items;
|
||||
list_items = NULL;
|
||||
}
|
||||
|
||||
if ((list_str = mail_rc->getAlternates(error)) == NULL) {
|
||||
list_str = strdup("");
|
||||
}
|
||||
|
||||
if ((buf = (char *) malloc(strlen(list_str) + 1)) == NULL)
|
||||
return;
|
||||
strcpy(buf, (char *)list_str);
|
||||
|
||||
if((token = (char *) strtok(buf, " ")))
|
||||
{
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
char_list = new DtVirtArray<char *>(10);
|
||||
|
||||
new_pair = new PropStringPair;
|
||||
new_pair->label = strdup(token);
|
||||
new_pair->value = NULL;
|
||||
list_items->append(new_pair);
|
||||
|
||||
char_list->append(strdup(token));
|
||||
|
||||
while(token = (char *)strtok(NULL, " "))
|
||||
{
|
||||
new_pair = new PropStringPair;
|
||||
new_pair->label = strdup(token);
|
||||
new_pair->value = NULL;
|
||||
list_items->append(new_pair);
|
||||
|
||||
char_list->append(strdup(token));
|
||||
}
|
||||
}
|
||||
|
||||
options_list_init(w, char_list);
|
||||
|
||||
delete char_list;
|
||||
|
||||
if(list_str != NULL)
|
||||
free((void *)list_str);
|
||||
|
||||
if(buf != NULL)
|
||||
free((void *)buf);
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
void AlternatesListUiItem::handleAddButtonPress()
|
||||
{
|
||||
Widget entry_field = this->getEntryFieldWidget();
|
||||
char *test_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
|
||||
XtVaGetValues(entry_field,
|
||||
XmNvalue, &test_str,
|
||||
NULL);
|
||||
|
||||
if(test_str != NULL)
|
||||
if(strlen(test_str) > 1)
|
||||
{
|
||||
new_pair = new PropStringPair;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
new_pair->label = strdup(test_str);
|
||||
new_pair->value = NULL;
|
||||
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,pos_list[0] - 1);
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(new_pair->label),
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
pos_list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,0);
|
||||
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(new_pair->label),
|
||||
1);
|
||||
XmListSelectPos(this->getWidget(),
|
||||
1,
|
||||
TRUE);
|
||||
XmListSetPos(this->getWidget(),
|
||||
1);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void AlternatesListUiItem::handleChangeButtonPress()
|
||||
{
|
||||
Widget entry_field = this->getEntryFieldWidget();
|
||||
char *test_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
XmString replace_string;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
// if nothing selected nothing to change...
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
XtVaGetValues(entry_field,
|
||||
XmNvalue, &test_str,
|
||||
NULL);
|
||||
|
||||
if(test_str != NULL)
|
||||
if(strlen(test_str) > 1)
|
||||
{
|
||||
|
||||
new_pair = (*list_items)[pos_list[0] - 1];
|
||||
|
||||
if(deleted_items == NULL)
|
||||
{
|
||||
deleted_items = new DtVirtArray<char *>(10);
|
||||
}
|
||||
|
||||
deleted_items->append(strdup((*list_items)[pos_list[0] -1]->label));
|
||||
|
||||
free(new_pair->label);
|
||||
new_pair->label = strdup(test_str);
|
||||
|
||||
replace_string = XmStringCreateLocalized(new_pair->label);
|
||||
|
||||
XmListReplaceItemsPos(this->getWidget(),
|
||||
&replace_string,
|
||||
1,
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void AlternatesListUiItem::handleDeleteButtonPress()
|
||||
{
|
||||
Widget list_widget = this->getWidget();
|
||||
int *p_list, p_count;
|
||||
|
||||
// get the selected position
|
||||
if(XmListGetSelectedPos(list_widget,
|
||||
&p_list,
|
||||
&p_count))
|
||||
{
|
||||
|
||||
if(deleted_items == NULL)
|
||||
{
|
||||
deleted_items = new DtVirtArray<char *>(10);
|
||||
}
|
||||
|
||||
deleted_items->append(strdup((*list_items)[p_list[0] -1]->label));
|
||||
|
||||
// delete the item from our list
|
||||
this->list_items->remove(p_list[0] - 1); // remove only first
|
||||
|
||||
// delete the item from the widget
|
||||
XmListDeletePos(list_widget, p_list[0]);
|
||||
|
||||
XtVaSetValues(this->getEntryFieldWidget(),
|
||||
XmNvalue,"",
|
||||
NULL);
|
||||
XmListSelectPos(list_widget,
|
||||
p_list[0],
|
||||
TRUE);
|
||||
|
||||
props_changed = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
85
cde/programs/dtmail/dtmail/AntiCheckBoxUiItem.C
Normal file
85
cde/programs/dtmail/dtmail/AntiCheckBoxUiItem.C
Normal file
@@ -0,0 +1,85 @@
|
||||
/* $TOG: AntiCheckBoxUiItem.C /main/4 1997/04/29 15:57:39 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <DtMail/options_util.h>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/AntiCheckBoxUiItem.hh>
|
||||
|
||||
// AntiCheckBoxUiItem::AntiCheckBoxUiItem
|
||||
// AntiCheckBoxUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
AntiCheckBoxUiItem::AntiCheckBoxUiItem(
|
||||
Widget w,
|
||||
int source,
|
||||
char *search_key
|
||||
):CheckBoxUiItem(w, source, search_key)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
// AntiCheckBoxUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void AntiCheckBoxUiItem::writeFromUiToSource()
|
||||
{
|
||||
Boolean checkbox_value;
|
||||
Widget w = this->getWidget();
|
||||
PropSource *p_s = this->getPropSource();
|
||||
|
||||
checkbox_value = options_checkbox_get_value(w);
|
||||
|
||||
if(checkbox_value == TRUE) // make sure the value is in the table
|
||||
{
|
||||
p_s->setValue("f");
|
||||
}
|
||||
else
|
||||
{
|
||||
p_s->setValue("");
|
||||
}
|
||||
}
|
||||
|
||||
// AntiCheckBoxUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void AntiCheckBoxUiItem::writeFromSourceToUi()
|
||||
{
|
||||
char *value = NULL;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
PropSource *p_s = this->getPropSource();
|
||||
|
||||
value = (char *)p_s->getValue();
|
||||
|
||||
//
|
||||
// this will have to be made more robust...
|
||||
//
|
||||
// This assumes that a non-null value means that the
|
||||
// value is set and that a non-null means turn on the CB
|
||||
if (strcmp(value, "f") == 0)
|
||||
options_checkbox_set_value(w, TRUE, this->dirty_bit);
|
||||
else if (value == NULL || strcmp(value, "") == 0)
|
||||
options_checkbox_set_value(w, FALSE, this->dirty_bit);
|
||||
|
||||
if (NULL != NULL)
|
||||
free((void*) value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
1717
cde/programs/dtmail/dtmail/AttachArea.C
Normal file
1717
cde/programs/dtmail/dtmail/AttachArea.C
Normal file
File diff suppressed because it is too large
Load Diff
307
cde/programs/dtmail/dtmail/AttachArea.h
Normal file
307
cde/programs/dtmail/dtmail/AttachArea.h
Normal file
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: AttachArea.h /main/3 1995/11/06 16:04:04 rswiston $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef ATTACHAREA_H
|
||||
#define ATTACHAREA_H
|
||||
|
||||
#ifndef I_HAVE_NO_IDENT
|
||||
#endif
|
||||
|
||||
#define TYPETEXT 0 /* unformatted text */
|
||||
#define TYPEMULTIPART 1 /* multiple part */
|
||||
#define TYPEMESSAGE 2 /* encapsulated message */
|
||||
#define TYPEAPPLICATION 3 /* application data */
|
||||
#define TYPEAUDIO 4 /* audio */
|
||||
#define TYPEIMAGE 5 /* static image */
|
||||
#define TYPEVIDEO 6 /* video */
|
||||
#define TYPEOTHER 7 /* unknown */
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include "UIComponent.h"
|
||||
#include "UndoCmd.h"
|
||||
#include "CmdList.h"
|
||||
#include "MenuBar.h"
|
||||
#include "DtMailHelp.hh"
|
||||
|
||||
#include <DtMail/DtMailError.hh>
|
||||
#include <DtMail/DtMail.hh>
|
||||
|
||||
typedef enum { NOTSET, ADD, SAVEAS } FSState;
|
||||
|
||||
class Attachment;
|
||||
class DtMailEditor;
|
||||
|
||||
class RoamMenuWindow;
|
||||
class SendMsgDialog;
|
||||
class ViewMsgDialog;
|
||||
|
||||
class AttachArea : public UIComponent {
|
||||
|
||||
private:
|
||||
|
||||
enum AAreaSState {AA_SEL_NONE=0, AA_SEL_SINGLE=1, AA_SEL_ALL=2};
|
||||
static void inputCallback( Widget, XtPointer, XtPointer );
|
||||
static void MenuButtonHandler(Widget, XtPointer, XEvent *, Boolean *);
|
||||
static void resizeCallback( Widget, XtPointer, XtPointer );
|
||||
|
||||
void popupAttachmentMenu(XEvent *event);
|
||||
|
||||
void resize(Dimension); // Called when the user click a button
|
||||
unsigned int _iconCount;
|
||||
unsigned int _iconSelectedCount;
|
||||
unsigned int _deleteCount;
|
||||
Attachment **_attachmentList;// The list of attachments
|
||||
|
||||
FSState _fsState; // State of the File Selection Box
|
||||
Widget _fsDialog;
|
||||
Widget _renameDialog;
|
||||
Widget _descriptionDialog;
|
||||
Widget _no_attachments_label;
|
||||
Widget _attachments_label;
|
||||
Widget _size_attachments_label;
|
||||
Widget _no_selected_label;
|
||||
Widget _selected_label;
|
||||
DtMailEditor *_myOwner; // The class that owns it
|
||||
Widget _parent; // The parent widget
|
||||
Widget rowOfAttachmentsStatus;
|
||||
Widget _attachments_status;
|
||||
Widget _attachments_summary;
|
||||
RoamMenuWindow *_myRMW;
|
||||
ViewMsgDialog *_myVMD;
|
||||
SendMsgDialog *_mySMD;
|
||||
Boolean _pendingAction;
|
||||
int _numPendingActions;
|
||||
|
||||
// Selection State of Attach Area
|
||||
AAreaSState _attach_area_selection_state;
|
||||
Attachment *_cache_single_attachment; // single selected attachment
|
||||
DtMail::MailBox *_mailbox;
|
||||
Dimension _attachAreaWidth; // The width of the AA
|
||||
Dimension _attachAreaHeight; // The height of the AA
|
||||
void valueChanged( XtPointer );
|
||||
static void valueChangedCallback( Widget, XtPointer, XtPointer );
|
||||
void dragSlider( XtPointer );
|
||||
static void dragCallback( Widget, XtPointer, XtPointer );
|
||||
unsigned int _lastRow; // The current last row
|
||||
unsigned int _currentRow; // The current row
|
||||
unsigned int _attachmentsSize; // Size of all attachments
|
||||
unsigned int _selectedAttachmentsSize; // Size of all
|
||||
XtPointer _clientData;
|
||||
// selected attachments
|
||||
char * calcKbytes(unsigned int);
|
||||
|
||||
protected:
|
||||
|
||||
Widget _rc; // The RowColumn widget that manages
|
||||
// the attachments
|
||||
Widget _sw; // The ScrolledWindow widget
|
||||
Widget _vsb; // The vertical scrollbar of the ScrolledWindow
|
||||
Widget _message;
|
||||
Widget _clipWindow;
|
||||
Cmd *_open;
|
||||
Cmd *_saveas;
|
||||
Cmd *_selectall;
|
||||
Cmd *_unselectall;
|
||||
MenuBar *_menuBar;
|
||||
Pixel _background;
|
||||
Pixel _foreground;
|
||||
Pixel _appBackground;
|
||||
Pixel _appForeground;
|
||||
CmdList* _fileCmdList;
|
||||
CmdList* _editCmdList;
|
||||
Widget _size_selected_label;
|
||||
Widget _format_button;
|
||||
|
||||
public:
|
||||
AttachArea (Widget, DtMailEditor*, char *);
|
||||
virtual ~AttachArea();
|
||||
|
||||
void initialize();
|
||||
void addToRowOfAttachmentsStatus();
|
||||
void attachment_summary(int, int);
|
||||
// Inline functions
|
||||
Cmd* openCmd() { return ( _open ); }
|
||||
Widget getVerticalSB() { return ( _vsb ); }
|
||||
unsigned int getIconCount() { return ( _iconCount ); }
|
||||
unsigned int getUndeletedIconCount()
|
||||
{ return (_iconCount - _deleteCount); }
|
||||
unsigned int getIconSelectedCount()
|
||||
{ return ( _iconSelectedCount ); }
|
||||
|
||||
unsigned int getDeleteCount(){ return ( _deleteCount ); }
|
||||
void incIconCount() { _iconCount++; }
|
||||
void decIconCount() { _iconCount--; }
|
||||
void incIconSelectedCount()
|
||||
{ _iconSelectedCount++; }
|
||||
void decIconSelectedCount()
|
||||
{ _iconSelectedCount--; }
|
||||
void incDeleteCount(){ _deleteCount++; }
|
||||
void decDeleteCount(){ _deleteCount--; }
|
||||
Attachment** getList() { return ( _attachmentList ); }
|
||||
|
||||
FSState getFsState() { return (_fsState ); }
|
||||
void setFsState( FSState state )
|
||||
{ ( _fsState = state ); }
|
||||
void setFsDialog( Widget w )
|
||||
{ _fsDialog = w; }
|
||||
void setRenameDialog( Widget w )
|
||||
{ _renameDialog = w; }
|
||||
void setDescriptionDialog( Widget w )
|
||||
{ _descriptionDialog = w; }
|
||||
Widget getFsDialog() { return (_fsDialog ); }
|
||||
Widget getRenameDialog() { return (_renameDialog ); }
|
||||
|
||||
Widget getDescriptionDialog()
|
||||
{ return (_descriptionDialog );}
|
||||
virtual const char *const className() { return ( "AttachArea" ); }
|
||||
|
||||
|
||||
void addToList( Attachment * );
|
||||
void addToDeletedList( Attachment *);
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
void undeleteAllDeletedAttachments(DtMailEnv &);
|
||||
#endif /* DEAD_WOOD */
|
||||
void undeleteLastDeletedAttachment(DtMailEnv &);
|
||||
|
||||
void removeLastDeletedAttachment();
|
||||
|
||||
virtual void attachmentFeedback(Boolean);
|
||||
|
||||
virtual void activateDeactivate();
|
||||
Widget getRc() { return (_rc ); }
|
||||
Widget getClipWindow() { return (_clipWindow ); }
|
||||
Widget getSWWindow() { return (_sw ); }
|
||||
Pixel getBackground() { return (_background ); }
|
||||
Pixel getForeground() { return (_foreground ); }
|
||||
Pixel getAppBackground(){ return (_appBackground ); }
|
||||
Pixel getAppForeground(){ return (_appForeground ); }
|
||||
Dimension getAAWidth() { return (_attachAreaWidth); }
|
||||
Dimension getAAHeight() { return (_attachAreaHeight); }
|
||||
DtMailEditor* owner() { return ( _myOwner ); }
|
||||
|
||||
Attachment* addAttachment(
|
||||
DtMail::Message *,
|
||||
DtMail::BodyPart *,
|
||||
char *filename,
|
||||
char *
|
||||
);
|
||||
|
||||
Attachment* addAttachment(DtMail::Message *,
|
||||
DtMail::BodyPart *,
|
||||
String,
|
||||
DtMailBuffer);
|
||||
|
||||
Attachment* addAttachment(String name, DtMail::BodyPart *);
|
||||
|
||||
void addAttachmentActions(
|
||||
char **,
|
||||
int
|
||||
);
|
||||
DtMail::MailBox* get_mailbox() { return ( _mailbox ); }
|
||||
String getRenameMessageString()
|
||||
{ return ("RenameMessageString"); }
|
||||
String getDescriptionMessageString()
|
||||
{ return ("DescriptionMessageString"); }
|
||||
unsigned int getAttachmentsSize()
|
||||
{ return ( _attachmentsSize ); }
|
||||
unsigned int getSelectedAttachmentsSize()
|
||||
{ return ( _selectedAttachmentsSize ); }
|
||||
void setAttachmentsSize( unsigned int size )
|
||||
{ ( _attachmentsSize = size ); }
|
||||
void setSelectedAttachmentsSize( unsigned int size )
|
||||
{ ( _selectedAttachmentsSize = size ); }
|
||||
|
||||
void selectAllAttachments();
|
||||
|
||||
Attachment* getSelectedAttachment();
|
||||
void unselectOtherSelectedAttachments(Attachment *);
|
||||
#ifdef DEAD_WOOD
|
||||
void deleteAttachments();
|
||||
#endif /* DEAD_WOOD */
|
||||
void manageList();
|
||||
void CalcSizeOfAttachPane( );
|
||||
#ifdef DEAD_WOOD
|
||||
void CalcAttachmentPosition(Attachment *);
|
||||
#endif /* DEAD_WOOD */
|
||||
void CalcAllAttachmentPositions();
|
||||
void DisplayAttachmentsInRow(unsigned int);
|
||||
void calculate_attachment_position(
|
||||
Attachment *,
|
||||
Attachment *);
|
||||
void CalcLastRow();
|
||||
unsigned int getLastRow() { return ( _lastRow); }
|
||||
unsigned int getCurrentRow() { return ( _currentRow); }
|
||||
void SetScrollBarSize(unsigned int );
|
||||
void AdjustCurrentRow();
|
||||
void initialize(Widget);
|
||||
void initialize_send(Widget);
|
||||
void initialize_view(Widget);
|
||||
#ifdef DEAD_WOOD
|
||||
void setAttachmentsLabel( );
|
||||
#endif /* DEAD_WOOD */
|
||||
int getSelectedIconCount();
|
||||
#ifdef DEAD_WOOD
|
||||
void CalcAttachmentsSize( );
|
||||
void add_attachment( Attachment * );
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
// Methods for parsing the attachments in a DtMail::Message
|
||||
|
||||
void parseAttachments(
|
||||
DtMailEnv &,
|
||||
DtMail::Message *,
|
||||
Boolean,
|
||||
int);
|
||||
|
||||
// SR -- Added methods below
|
||||
|
||||
void attachmentSelected(Attachment *);
|
||||
void manage();
|
||||
void unmanage();
|
||||
void removeCurrentAttachments();
|
||||
void clearAttachArea();
|
||||
#ifdef DEAD_WOOD
|
||||
void saveAttachmentToFile(DtMailEnv &, char *);
|
||||
#endif /* DEAD_WOOD */
|
||||
void deleteSelectedAttachments(DtMailEnv &);
|
||||
Widget ownerShellWidget();
|
||||
void setOwnerShell(RoamMenuWindow *);
|
||||
void setOwnerShell(ViewMsgDialog *);
|
||||
void setOwnerShell(SendMsgDialog *);
|
||||
Boolean isOwnerShellEditable();
|
||||
|
||||
void setPendingAction(Boolean);
|
||||
void resetPendingAction();
|
||||
int getNumPendingActions();
|
||||
|
||||
XmString getSelectedAttachName();
|
||||
void setSelectedAttachName(XmString );
|
||||
|
||||
int handleQuestionDialog(char *title,
|
||||
char *buf,
|
||||
char *helpId = DTMAILHELPERROR);
|
||||
|
||||
int handleErrorDialog(char *title,
|
||||
char *buf,
|
||||
char *helpId = DTMAILHELPERROR);
|
||||
};
|
||||
#endif
|
||||
|
||||
1042
cde/programs/dtmail/dtmail/AttachCmds.C
Normal file
1042
cde/programs/dtmail/dtmail/AttachCmds.C
Normal file
File diff suppressed because it is too large
Load Diff
290
cde/programs/dtmail/dtmail/AttachCmds.h
Normal file
290
cde/programs/dtmail/dtmail/AttachCmds.h
Normal file
@@ -0,0 +1,290 @@
|
||||
/* $XConsortium: AttachCmds.h /main/3 1995/11/06 16:04:23 rswiston $ */
|
||||
#include <Xm/Xm.h>
|
||||
#include "UIComponent.h"
|
||||
#include "Cmd.h"
|
||||
#include "AttachArea.h"
|
||||
#include "DialogManager.h"
|
||||
|
||||
#ifndef ATTACHADDCMD_H
|
||||
#define ATTACHADDCMD_H
|
||||
|
||||
typedef enum { OK, ERR, CONFIRM } SaveFileState;
|
||||
|
||||
class AttachAddCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
Widget _clipWindow;
|
||||
Widget _parent;
|
||||
void cancel( XtPointer ); // Called when the Cancel button is pressed
|
||||
void ok( Widget, XtPointer );// Called when the OK button is pressed
|
||||
void add_file(char *);
|
||||
AttachArea *_attachArea;
|
||||
|
||||
static void okCallback( Widget, XtPointer, XtPointer );
|
||||
static void cancelCallback( Widget, XtPointer, XtPointer );
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachAddCmd ( AttachArea *, Widget, Widget, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachAddCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef ATTACHFETCHCMD_H
|
||||
#define ATTACHFETCHCMD_H
|
||||
|
||||
class AttachFetchCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
Widget _clipWindow;
|
||||
AttachArea *_attachArea;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachFetchCmd ( AttachArea *, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachFetchCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTACHDELETECMD_H
|
||||
#define ATTACHDELETECMD_H
|
||||
|
||||
class AttachDeleteCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
AttachArea *_attachArea;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachDeleteCmd ( AttachArea *, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachDeleteCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTACHOPENCMD_H
|
||||
#define ATTACHOPENCMD_H
|
||||
|
||||
class AttachOpenCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
Widget _clipWindow;
|
||||
void cancel( XtPointer ); // Called when the Cancel button is pressed
|
||||
void ok( XtPointer ); // Called when the OK button is pressed
|
||||
|
||||
static void okCallback( Widget, XtPointer, XtPointer );
|
||||
static void cancelCallback( Widget, XtPointer, XtPointer );
|
||||
AttachArea *_attachArea;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachOpenCmd ( AttachArea *, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachOpenCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTACHRENAMECMD_H
|
||||
#define ATTACHRENAMECMD_H
|
||||
|
||||
class AttachRenameCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
AttachArea *_attachArea;
|
||||
void cancel( XtPointer ); // Called when the Cancel button is pressed
|
||||
static void cancelCallback( Widget, XtPointer, XtPointer );
|
||||
void ok( XtPointer ); // Called when the OK button is pressed
|
||||
static void okCallback( Widget, XtPointer, XtPointer );
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachRenameCmd ( AttachArea *, Widget, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachRenameCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef ATTACHDESCRIPTIONCMD_H
|
||||
#define ATTACHDESCRIPTIONCMD_H
|
||||
|
||||
class AttachDescriptionCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
AttachArea *_attachArea;
|
||||
void cancel( XtPointer ); // Called when the Cancel button is pressed
|
||||
static void cancelCallback( Widget, XtPointer, XtPointer );
|
||||
void ok( XtPointer ); // Called when the OK button is pressed
|
||||
static void okCallback( Widget, XtPointer, XtPointer );
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachDescriptionCmd ( AttachArea *, Widget, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachDescriptionCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTACHSAVEASCMD_H
|
||||
#define ATTACHSAVEASCMD_H
|
||||
|
||||
class AttachSaveAsCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
Widget _parent;
|
||||
Widget _clipWindow;
|
||||
void cancel( XtPointer ); // Called when the Cancel button is pressed
|
||||
void ok( XtPointer ); // Called when the OK button is pressed
|
||||
AttachArea *_attachArea;
|
||||
|
||||
static void okCallback( Widget, XtPointer, XtPointer );
|
||||
static void cancelCallback( Widget, XtPointer, XtPointer );
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachSaveAsCmd ( AttachArea *, Widget, Widget, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachSaveAsCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTACHSELECTALLCMD_H
|
||||
#define ATTACHSELECTALLCMD_H
|
||||
|
||||
class AttachSelectAllCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
AttachArea *_attachArea;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachSelectAllCmd ( AttachArea *, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachSelectAllCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTACHUNDELETECMD_H
|
||||
#define ATTACHUNDELETECMD_H
|
||||
|
||||
class AttachUndeleteCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
AttachArea *_attachArea;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachUndeleteCmd ( AttachArea *, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachUndeleteCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTACHUNSELECTALLCMD_H
|
||||
#define ATTACHUNSELECTALLCMD_H
|
||||
|
||||
class AttachUnselectAllCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
AttachArea *_attachArea;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachUnselectAllCmd ( AttachArea *, char *, int );
|
||||
|
||||
virtual const char *const className () { return "AttachUnselectAllCmd"; }
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef ATTACHINFOCMD_H
|
||||
#define ATTACHINFOCMD_H
|
||||
|
||||
class AttachInfoCmd : public Cmd {
|
||||
|
||||
private:
|
||||
|
||||
AttachArea *_attachArea;
|
||||
Widget _info_dialog;
|
||||
DialogManager *_attachInfoDialogManager;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void doit();
|
||||
virtual void undoit();
|
||||
|
||||
public:
|
||||
|
||||
AttachInfoCmd ( AttachArea *, char *, int );
|
||||
~AttachInfoCmd();
|
||||
|
||||
virtual const char *const className () { return "AttachInfoCmd"; }
|
||||
};
|
||||
#endif
|
||||
1279
cde/programs/dtmail/dtmail/Attachment.C
Normal file
1279
cde/programs/dtmail/dtmail/Attachment.C
Normal file
File diff suppressed because it is too large
Load Diff
201
cde/programs/dtmail/dtmail/Attachment.h
Normal file
201
cde/programs/dtmail/dtmail/Attachment.h
Normal file
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: Attachment.h /main/8 1998/05/06 15:54:12 rafi $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef ATTACHMENT_H
|
||||
#define ATTACHMENT_H
|
||||
|
||||
#include <Dt/Dts.h>
|
||||
#include <Dt/Action.h>
|
||||
#include <DtMail/DtMail.hh>
|
||||
#include <DtMail/DtVirtArray.hh>
|
||||
|
||||
#include "UIComponent.h"
|
||||
#include "AttachArea.h"
|
||||
|
||||
#define MARGIN 2
|
||||
|
||||
typedef enum { ROAM_CACHED, ROAM_LOCAL, ROAM_AVAILABLE, ROAM_UNAVAILABLE } ACState;
|
||||
|
||||
typedef enum { DONTKNOW, EXECUTABLE, NOTEXECUTABLE } ExecState;
|
||||
|
||||
class Icon;
|
||||
class Attachment;
|
||||
|
||||
class ActionCallback {
|
||||
friend class Attachment;
|
||||
public:
|
||||
ActionCallback(DtMailObjectKey, Attachment *);
|
||||
~ActionCallback();
|
||||
|
||||
private:
|
||||
DtMailObjectKey _myKey;
|
||||
Attachment *_myAttachment;
|
||||
};
|
||||
|
||||
class Attachment : public UIComponent {
|
||||
|
||||
public:
|
||||
|
||||
// This version takes a filename as a parameter
|
||||
|
||||
Attachment ( AttachArea *, String, DtMail::BodyPart *, int);
|
||||
|
||||
virtual ~Attachment(); // Destructor
|
||||
virtual void initialize();
|
||||
void action(
|
||||
DtActionInvocationID,
|
||||
DtActionArg *,
|
||||
int,
|
||||
int );
|
||||
void invokeAction(int);
|
||||
|
||||
int operator==(const Attachment&);
|
||||
|
||||
// Accessors
|
||||
//
|
||||
// Note: functions calling getLabel are responsible for freeing
|
||||
// the XmString it returns
|
||||
//
|
||||
XmString getLabel() { return ( XmStringCopy ( _label ) ); }
|
||||
void rename(XmString);
|
||||
void *getContents();
|
||||
|
||||
|
||||
unsigned long getContentsSize()
|
||||
{ return ( _myContentsSize ); }
|
||||
|
||||
Dimension getWidth() { return ( _attachmentWidth ); }
|
||||
Dimension getHeight() { return ( _attachmentHeight );}
|
||||
Position getX() { return ( _positionX ); }
|
||||
Position getY() { return ( _positionY );}
|
||||
int getRow() { return ( _row ); }
|
||||
|
||||
Boolean isManaged() { return ( XtIsManaged(_w) ); }
|
||||
Boolean isDeleted() { return ( _deleted ); }
|
||||
AttachArea* parent() { return ( _parent ); }
|
||||
Widget getIconWidget() { return ( _w); }
|
||||
void manageIconWidget(void);
|
||||
void unmanageIconWidget(void);
|
||||
|
||||
String getSaveAsFilename()
|
||||
{ return ( _saveAsFilename ); }
|
||||
char* getCeName() { return ( _ce_name ); }
|
||||
unsigned short getType() { return ( _type ); }
|
||||
String getSubType() { return ( _subtype ); }
|
||||
DtMail::BodyPart *getBodyPart() { return ( _body_part ); }
|
||||
Boolean isBinary() { return ( _binary ); }
|
||||
Boolean isSelected() { return ( _selected ); }
|
||||
|
||||
|
||||
void saveToFile(DtMailEnv & error,char *filename);
|
||||
virtual const char *const className() { return ( "Attachment" ); }
|
||||
|
||||
// Mutators
|
||||
void setLabel( XmString str );
|
||||
|
||||
void setX(Position);
|
||||
#ifdef DEAD_WOOD
|
||||
void setY(Position);
|
||||
void setRow(int);
|
||||
#else /* ! DEAD_WOOD */
|
||||
void setY(Position);
|
||||
void setRow(int row) { _row = row; }
|
||||
#endif /* ! DEAD_WOOD */
|
||||
|
||||
void deleteIt();
|
||||
void undeleteIt();
|
||||
void setSaveAsFilename(String str)
|
||||
{ ( _saveAsFilename = str); }
|
||||
|
||||
void set_binary(Boolean binary)
|
||||
{ ( _binary = binary); }
|
||||
|
||||
void handleDoubleClick();
|
||||
|
||||
void name_to_type();
|
||||
void setAttachArea(AttachArea *);
|
||||
#ifdef DEAD_WOOD
|
||||
Boolean check_if_binary(String, unsigned long);
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
// SR -- Added methods below
|
||||
|
||||
void primitive_select();
|
||||
void set_selected();
|
||||
Boolean is_selected();
|
||||
|
||||
void setContents();
|
||||
|
||||
void unselect();
|
||||
|
||||
void quit();
|
||||
|
||||
void registerAction(DtActionInvocationID);
|
||||
void unregisterAction(DtActionInvocationID);
|
||||
protected:
|
||||
static void actionCallback(
|
||||
DtActionInvocationID id,
|
||||
XtPointer client_data,
|
||||
DtActionArg *actionArgPtr,
|
||||
int actionArgCount,
|
||||
DtActionStatus status
|
||||
);
|
||||
|
||||
private:
|
||||
|
||||
Icon* myIcon; // my Icon instance
|
||||
|
||||
Pixel _background; // The background color
|
||||
Pixel _foreground; // The foreground color
|
||||
AttachArea *_parent; // The Parent class
|
||||
XmString _label; // The name (no absolute path)
|
||||
DtMail::BodyPart *_body_part; // Pointer to back end body part.
|
||||
|
||||
Dimension _attachmentWidth; // The width of the attachment
|
||||
Dimension _attachmentHeight; // The height of the attachment
|
||||
Position _positionX; // The X Position
|
||||
Position _positionY; // The Y Position
|
||||
|
||||
Boolean _deleted; // True is it has been deleted
|
||||
Boolean _selected; // True if selected.
|
||||
int _row; // Which row this is displayed in
|
||||
String _saveAsFilename; // Name for Save As
|
||||
int _index; // Index in attachArea
|
||||
char *_ce_name;
|
||||
char *_ce_type;
|
||||
unsigned short _type;
|
||||
String _subtype;
|
||||
Boolean _binary;
|
||||
|
||||
Boolean _executable;
|
||||
Boolean _haveContents;
|
||||
char *_myAllocContents;
|
||||
const void *_myContents;
|
||||
unsigned long _myContentsSize;
|
||||
char * _myType;
|
||||
Boolean _canKillSelf;
|
||||
|
||||
char ** _myActionsList;
|
||||
DtVirtArray<DtActionInvocationID> _myActionIds;
|
||||
DtMailObjectKey _key;
|
||||
void _setMyContents(const void * data, int size);
|
||||
};
|
||||
|
||||
#endif
|
||||
83
cde/programs/dtmail/dtmail/CheckBoxUiItem.C
Normal file
83
cde/programs/dtmail/dtmail/CheckBoxUiItem.C
Normal file
@@ -0,0 +1,83 @@
|
||||
/* $TOG: CheckBoxUiItem.C /main/5 1997/04/29 15:58:33 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <DtMail/options_util.h>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/CheckBoxUiItem.hh>
|
||||
|
||||
// CheckBoxUiItem::CheckBoxUiItem
|
||||
// CheckBoxUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
CheckBoxUiItem::CheckBoxUiItem(Widget w, int source, char *search_key):PropUiItem(w, source, search_key)
|
||||
{
|
||||
#ifdef DEAD_WOOD
|
||||
data_source = source;
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
options_checkbox_init(w, &(this->dirty_bit));
|
||||
|
||||
}
|
||||
|
||||
// CheckBoxUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void CheckBoxUiItem::writeFromUiToSource()
|
||||
{
|
||||
Boolean checkbox_value;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
checkbox_value = options_checkbox_get_value(w);
|
||||
|
||||
if(checkbox_value == TRUE) // make sure the value is in the table
|
||||
{
|
||||
prop_source->setValue("");
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_source->setValue("f");
|
||||
}
|
||||
}
|
||||
|
||||
// CheckBoxUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void CheckBoxUiItem::writeFromSourceToUi()
|
||||
{
|
||||
char *value = NULL;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
value = (char *)prop_source->getValue();
|
||||
|
||||
//
|
||||
// this will have to be made more robust...
|
||||
//
|
||||
// This assumes that a non-null value means that the
|
||||
// value is set and that a non-null means turn on the CB
|
||||
if (strcmp(value, "") == 0)
|
||||
options_checkbox_set_value(w, TRUE, this->dirty_bit);
|
||||
else if (NULL == value || strcmp(value, "f") == 0)
|
||||
options_checkbox_set_value(w, FALSE, this->dirty_bit);
|
||||
|
||||
if (NULL != NULL)
|
||||
free((void*) value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
97
cde/programs/dtmail/dtmail/CheckForMailUiItem.C
Normal file
97
cde/programs/dtmail/dtmail/CheckForMailUiItem.C
Normal file
@@ -0,0 +1,97 @@
|
||||
/* $TOG: CheckForMailUiItem.C /main/1 1998/02/17 15:19:56 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <Xm/XmAll.h>
|
||||
#include <DtMail/options_util.h>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/CheckForMailUiItem.hh>
|
||||
#include <DtMail/SpinBoxUiItem.hh>
|
||||
|
||||
int CheckForMailUiItem::_initialized = 0;
|
||||
DtVirtArray<CheckForMailUiItem*> *CheckForMailUiItem::_checkformail_ui = NULL;
|
||||
|
||||
CheckForMailUiItem::CheckForMailUiItem(Widget w, int source, char *search_key):
|
||||
SpinBoxUiItem(w, source, search_key)
|
||||
{
|
||||
Widget textfield;
|
||||
|
||||
if (! _initialized)
|
||||
{
|
||||
_initialized = 1;
|
||||
_checkformail_ui = new DtVirtArray<CheckForMailUiItem*> (3);
|
||||
}
|
||||
|
||||
options_spinbox_init(w, &(this->dirty_bit));
|
||||
XtVaGetValues(w, XmNtextField, &textfield, NULL);
|
||||
XtAddCallback(
|
||||
textfield,
|
||||
XmNvalueChangedCallback,
|
||||
CheckForMailUiItem::valueChangedCB,
|
||||
this);
|
||||
|
||||
_checkformail_ui->append(this);
|
||||
}
|
||||
|
||||
//
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void CheckForMailUiItem::valueChangedCB(Widget w, XtPointer client, XtPointer)
|
||||
{
|
||||
CheckForMailUiItem *cui = (CheckForMailUiItem*) client;
|
||||
cui->_valueChanged = TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void CheckForMailUiItem::writeFromUiToSource()
|
||||
{
|
||||
int spinbox_value;
|
||||
Widget w = this->getWidget();
|
||||
char val_str[64];
|
||||
|
||||
if (!_valueChanged) return;
|
||||
|
||||
spinbox_value = options_spinbox_get_value(w);
|
||||
sprintf(val_str, "%d", spinbox_value);
|
||||
prop_source->setValue(val_str);
|
||||
|
||||
for (int i = 0; i < _checkformail_ui->length(); i++)
|
||||
{
|
||||
CheckForMailUiItem *cui = (*_checkformail_ui)[i];
|
||||
if (cui != this) cui->writeFromSourceToUi();
|
||||
}
|
||||
_valueChanged = FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void CheckForMailUiItem::writeFromSourceToUi()
|
||||
{
|
||||
const char *value;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
value = prop_source->getValue();
|
||||
options_spinbox_set_value(w, atoi(value), this->dirty_bit);
|
||||
_valueChanged = FALSE;
|
||||
|
||||
if (NULL != value) free((void*) value);
|
||||
}
|
||||
870
cde/programs/dtmail/dtmail/ComposeCmds.C
Normal file
870
cde/programs/dtmail/dtmail/ComposeCmds.C
Normal file
@@ -0,0 +1,870 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: ComposeCmds.C /main/11 1998/10/21 17:23:13 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <EUSCompat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(NEED_MMAP_WRAPPER)
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <sys/mman.h>
|
||||
#if defined(NEED_MMAP_WRAPPER)
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <pwd.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <Xm/FileSBP.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/ToggleB.h>
|
||||
#include <Xm/PushBG.h>
|
||||
#include <Xm/PanedW.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Dt/Dts.h>
|
||||
#include <Dt/Action.h>
|
||||
#include <DtMail/IO.hh>
|
||||
#include "RoamMenuWindow.h"
|
||||
#include "SendMsgDialog.h"
|
||||
#include "Undelete.hh"
|
||||
#include "RoamCmds.h"
|
||||
#include "ComposeCmds.hh"
|
||||
#include "Application.h"
|
||||
#include "RoamApp.h"
|
||||
#include "DtMailWDM.hh"
|
||||
#include "FindDialog.h"
|
||||
#include "MsgScrollingList.hh"
|
||||
#include "MsgHndArray.hh"
|
||||
#include "MemUtils.hh"
|
||||
#include "MailMsg.h"
|
||||
#include "EUSDebug.hh"
|
||||
#include "DtMailGenDialog.hh"
|
||||
#include "DtMailHelp.hh"
|
||||
#include <DtMail/DtMailError.hh>
|
||||
#include "Help.hh"
|
||||
#include <Dt/Help.h>
|
||||
#include "Attachment.h"
|
||||
#include "str_utils.h"
|
||||
|
||||
ComposeFamily::ComposeFamily(char *name,
|
||||
char *label,
|
||||
int active,
|
||||
RoamMenuWindow *window)
|
||||
: RoamCmd(name, label, active, window)
|
||||
{
|
||||
_parent = window;
|
||||
}
|
||||
|
||||
#ifndef CAN_INLINE_VIRTUALS
|
||||
ComposeFamily::~ComposeFamily( void )
|
||||
{
|
||||
}
|
||||
#endif /* ! CAN_INLINE_VIRTUALS */
|
||||
|
||||
// Append a formatted message to Compose's Text area.
|
||||
// This routine is essentially the same as MsgScollingList::display_message()
|
||||
// except for two major differences:
|
||||
// 1. No RoamMenuWindow reference (so that Compose can be standalone).
|
||||
// 2. Indent string can be used for "include" and "forward".
|
||||
void
|
||||
ComposeFamily::Display_entire_msg(DtMailMessageHandle msgno,
|
||||
SendMsgDialog *compose,
|
||||
char *format
|
||||
)
|
||||
{
|
||||
DtMailEnv error;
|
||||
|
||||
int num_bodyParts;
|
||||
DtMail::MailBox *mbox = _menuwindow->mailbox();
|
||||
DtMail::Message *msg = mbox->getMessage(error, msgno);
|
||||
DtMail::Envelope *env = msg->getEnvelope(error);
|
||||
DtMail::BodyPart *tmpBP = NULL;
|
||||
DtMailBuffer tmpBuffer;
|
||||
void *buffer = NULL;
|
||||
unsigned long size = 0;
|
||||
|
||||
Editor::InsertFormat ins_format = Editor::IF_NONE;
|
||||
Editor::BracketFormat brackets = Editor::BF_NONE;
|
||||
|
||||
// Do not need to wrap "include", "forward", and "indent" with
|
||||
// catgets().
|
||||
if ( strcmp(format, "include") == 0 ) {
|
||||
ins_format = Editor::IF_BRACKETED;
|
||||
brackets = Editor::BF_INCLUDE;
|
||||
} else if ( strcmp(format, "forward") == 0 ) {
|
||||
ins_format = Editor::IF_BRACKETED;
|
||||
brackets = Editor::BF_FORWARD;
|
||||
} else if ( strcmp(format, "indent") == 0 ) {
|
||||
ins_format = Editor::IF_INDENTED;
|
||||
}
|
||||
|
||||
// Get the editor to display the body of message with the appropriate
|
||||
// insert/bracket formatting.
|
||||
// We only include the first body part of the message. Attachments,
|
||||
// etc. are "FORWARD"-ed but not "INCLUDE"-ed
|
||||
|
||||
char * status_string;
|
||||
DtMailBoolean firstBPHandled =
|
||||
compose->get_editor()->textEditor()->set_message(
|
||||
msg,
|
||||
&status_string,
|
||||
Editor::HF_ABBREV,
|
||||
ins_format,
|
||||
brackets);
|
||||
|
||||
// Now need to handle the unhandled body parts of the message.
|
||||
|
||||
num_bodyParts = msg->getBodyCount(error);
|
||||
if (error.isSet()) {
|
||||
// do something
|
||||
}
|
||||
|
||||
if (strcmp(format, "forward") == 0) {
|
||||
// If the message has attachments, then let the attach pane
|
||||
// handle attachments but not the first bodyPart (which has
|
||||
// already been handled here).
|
||||
|
||||
if ((num_bodyParts > 1) || (!firstBPHandled)) {
|
||||
|
||||
tmpBP = msg->getFirstBodyPart(error);
|
||||
if (firstBPHandled) {
|
||||
// The first bodyPart has already been handled.
|
||||
// The others, beginning from the second, need to be parsed
|
||||
// and put into the attachPane.
|
||||
|
||||
compose->setInclMsgHnd(msg, TRUE);
|
||||
tmpBP = msg->getNextBodyPart(error, tmpBP);
|
||||
|
||||
} else {
|
||||
// The first bodyPart was not handled.
|
||||
// It may not have been of type text.
|
||||
// The attachment pane needs to handle all the bodyParts
|
||||
// beginning with the first.
|
||||
|
||||
compose->setInclMsgHnd(msg, FALSE);
|
||||
}
|
||||
|
||||
char *name;
|
||||
while (tmpBP != NULL) {
|
||||
tmpBP->getContents(
|
||||
error, (const void **) &tmpBuffer.buffer,
|
||||
&tmpBuffer.size,
|
||||
NULL,
|
||||
&name,
|
||||
NULL,
|
||||
NULL);
|
||||
if (error.isSet()) {
|
||||
// Do something
|
||||
}
|
||||
// It's possible for an attachment to not have a name.
|
||||
if (!name) {
|
||||
name = "NoName";
|
||||
}
|
||||
|
||||
compose->add_att(name, tmpBuffer);
|
||||
tmpBP = msg->getNextBodyPart(error, tmpBP);
|
||||
if (error.isSet()) {
|
||||
// do something
|
||||
}
|
||||
|
||||
if (strcmp(name, "NoName") != 0) {
|
||||
free(name);
|
||||
}
|
||||
}
|
||||
if (error.isSet()) {
|
||||
|
||||
// do something
|
||||
}
|
||||
|
||||
// Need to call this after calling parseAttachments().
|
||||
|
||||
compose->get_editor()->manageAttachArea();
|
||||
|
||||
// This message has attachment and is being included/forwarded,
|
||||
// so need to fill the Compose Message Handle with attachment
|
||||
// BodyParts.
|
||||
// See function for further details.
|
||||
|
||||
// compose->updateMsgHndAtt();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the message has attachments, then let the attach pane
|
||||
// handle attachments but not the first bodyPart (which has
|
||||
// already been handled here).
|
||||
|
||||
if ((num_bodyParts > 1) || (!firstBPHandled))
|
||||
{
|
||||
char *att;
|
||||
Editor *editor = compose->get_editor()->textEditor();
|
||||
|
||||
att = GETMSG(
|
||||
DT_catd, 1, 255,
|
||||
"------------------ Attachments ------------------\n");
|
||||
|
||||
tmpBP = msg->getFirstBodyPart(error);
|
||||
if (firstBPHandled)
|
||||
tmpBP = msg->getNextBodyPart(error, tmpBP);
|
||||
|
||||
editor->append_to_contents(att, strlen(att));
|
||||
while (tmpBP != NULL)
|
||||
{
|
||||
editor->set_attachment(tmpBP, ins_format, brackets);
|
||||
tmpBP = msg->getNextBodyPart(error, tmpBP);
|
||||
if (error.isSet()) {
|
||||
// do something
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Leave it up to check point routine for update or do it now???
|
||||
compose->updateMsgHnd();
|
||||
}
|
||||
|
||||
void
|
||||
ComposeFamily::appendSignature(SendMsgDialog * compose)
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
|
||||
const char * value = NULL;
|
||||
mail_rc->getValue(error, "signature", &value);
|
||||
if (error.isSet()) {
|
||||
return;
|
||||
}
|
||||
|
||||
char * fullpath = d_session->expandPath(error, value);
|
||||
compose->get_editor()->textEditor()->append_to_contents(fullpath);
|
||||
if (NULL != fullpath)
|
||||
free((void*) fullpath);
|
||||
if (NULL != NULL)
|
||||
free((void*) value);
|
||||
|
||||
compose->get_editor()->textEditor()->set_to_top();
|
||||
}
|
||||
|
||||
char *
|
||||
ComposeFamily::valueToAddrString(DtMailValueSeq & value)
|
||||
{
|
||||
int max_len = 0;
|
||||
|
||||
for (int count = 0; count < value.length(); count++) {
|
||||
max_len += strlen(*(value[count]));
|
||||
}
|
||||
|
||||
char * str = new char[max_len + count + 1];
|
||||
str[0] = 0;
|
||||
|
||||
DtMailBoolean need_comma = DTM_FALSE;
|
||||
|
||||
for (int cat = 0; cat < value.length(); cat++)
|
||||
{
|
||||
DtMailValue * val = value[cat];
|
||||
DtMailAddressSeq *addr_seq = val->toAddress();
|
||||
|
||||
for (int ad = 0; ad < addr_seq->length(); ad++)
|
||||
{
|
||||
DtMailValueAddress * addr = (*addr_seq)[ad];
|
||||
|
||||
// Deal with mail address parser shortcomings
|
||||
if ( strcmp(addr->dtm_address, ",") == 0 )
|
||||
continue ;
|
||||
|
||||
if (need_comma) {
|
||||
strcat(str, ", ");
|
||||
}
|
||||
|
||||
need_comma = DTM_TRUE;
|
||||
|
||||
strcat(str, addr->dtm_address);
|
||||
}
|
||||
|
||||
delete addr_seq;
|
||||
}
|
||||
|
||||
return(str);
|
||||
}
|
||||
|
||||
|
||||
// Container menu "Compose==>New Message"
|
||||
ComposeCmd::ComposeCmd(
|
||||
char *name,
|
||||
char *label,
|
||||
int active,
|
||||
RoamMenuWindow *window
|
||||
) : ComposeFamily( name, label, active, window )
|
||||
{
|
||||
}
|
||||
|
||||
// Put up a blank compose window.
|
||||
void
|
||||
ComposeCmd::doit()
|
||||
{
|
||||
SendMsgDialog * newsend = theCompose.getWin();
|
||||
if (newsend == NULL) {
|
||||
DtMailGenDialog * dialog = _parent->genDialog();
|
||||
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 203, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 204, "Unable to create a compose window."));
|
||||
char * helpId = DTMAILHELPNOCOMPOSE;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
}
|
||||
|
||||
appendSignature(newsend);
|
||||
}
|
||||
|
||||
// Container menu "Compose==>New, Include All" and "Compose==>Forward Message"
|
||||
// The last parameter is a switch for "include" or "forward" format.
|
||||
ForwardCmd::ForwardCmd(
|
||||
char *name,
|
||||
char *label,
|
||||
int active,
|
||||
RoamMenuWindow *window,
|
||||
int forward
|
||||
) : ComposeFamily(name, label, active, window)
|
||||
{
|
||||
_forward = forward;
|
||||
}
|
||||
|
||||
// Forward or Include selected messages.
|
||||
// For Include message(s), all Compose window header fields are left blank.
|
||||
// For Forward message(s), the Compose window "Subject" header field is filled
|
||||
// with the subject of the last selected message.
|
||||
void
|
||||
ForwardCmd::doit()
|
||||
{
|
||||
FORCE_SEGV_DECL(MsgHndArray, msgList);
|
||||
FORCE_SEGV_DECL(MsgStruct, tmpMS);
|
||||
DtMailMessageHandle msgno;
|
||||
|
||||
// Get a Compose window.
|
||||
SendMsgDialog *newsend = theCompose.getWin();
|
||||
if ( newsend == NULL ) {
|
||||
DtMailGenDialog * dialog = _parent->genDialog();
|
||||
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 205, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 206, "Unable to create a compose window."));
|
||||
char * helpId = DTMAILHELPNOCOMPOSE;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
}
|
||||
|
||||
// Put the signature above the message.
|
||||
//
|
||||
appendSignature(newsend);
|
||||
|
||||
// For Forwarding subject
|
||||
DtMail::MailBox * mbox = _menuwindow->mailbox();
|
||||
DtMail::Message * msg;
|
||||
DtMail::Envelope * env;
|
||||
DtMailValueSeq value;
|
||||
DtMailEnv error;
|
||||
|
||||
// For each selected message, put it in the Compose window.
|
||||
if ( msgList = _menuwindow->list()->selected() ) {
|
||||
for ( int k = 0; k < msgList->length(); k++ ) {
|
||||
tmpMS = msgList->at(k);
|
||||
msgno = tmpMS->message_handle;
|
||||
if ( _forward ) {
|
||||
msg = mbox->getMessage(error, msgno);
|
||||
env = msg->getEnvelope(error);
|
||||
value.clear();
|
||||
env->getHeader(error, DtMailMessageSubject, DTM_TRUE, value);
|
||||
if (!error.isSet()) {
|
||||
const char *subject = *(value[0]);
|
||||
newsend->setHeader("Subject", subject);
|
||||
newsend->setTitle((char*) subject);
|
||||
newsend->setIconTitle((char*) subject);
|
||||
}
|
||||
Display_entire_msg(msgno, newsend, "forward");
|
||||
} else {
|
||||
Display_entire_msg(msgno, newsend, "indent");
|
||||
}
|
||||
}
|
||||
}
|
||||
newsend->get_editor()->textEditor()->set_to_top();
|
||||
}
|
||||
|
||||
// Container menu "Compose==>Reply to Semder" and
|
||||
// "Compose==>Reply to Sender, Include"
|
||||
// The last parameter is a switch for including the selected message or not.
|
||||
ReplyCmd::ReplyCmd (
|
||||
char *name,
|
||||
char *label,
|
||||
int active,
|
||||
RoamMenuWindow *window,
|
||||
int include
|
||||
) : ComposeFamily ( name, label, active, window )
|
||||
{
|
||||
_include = include;
|
||||
}
|
||||
|
||||
// For each message selected, reply to sender.
|
||||
void
|
||||
ReplyCmd::doit()
|
||||
{
|
||||
FORCE_SEGV_DECL(MsgHndArray, msgList);
|
||||
FORCE_SEGV_DECL(MsgStruct, tmpMS);
|
||||
DtMailMessageHandle msgno;
|
||||
FORCE_SEGV_DECL(char, from);
|
||||
FORCE_SEGV_DECL(char, subject);
|
||||
FORCE_SEGV_DECL(char, cc);
|
||||
DtMailEnv error;
|
||||
DtMail::MailBox * mbox = _menuwindow->mailbox();
|
||||
|
||||
// Initialize the error.
|
||||
error.clear();
|
||||
|
||||
if (msgList = _menuwindow->list()->selected())
|
||||
{
|
||||
for ( int i=0; i < msgList->length(); i++ ) {
|
||||
tmpMS = msgList->at(i);
|
||||
msgno = tmpMS->message_handle;
|
||||
SendMsgDialog *newsend = theCompose.getWin();
|
||||
if ( newsend == NULL ) {
|
||||
DtMailGenDialog * dialog = _parent->genDialog();
|
||||
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 207, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 208, "Unable to create a compose window."));
|
||||
char * helpId = DTMAILHELPNOCOMPOSE;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
}
|
||||
XmUpdateDisplay( newsend->baseWidget() );
|
||||
|
||||
DtMail::Message * msg = mbox->getMessage(error, msgno);
|
||||
DtMail::Envelope * env = msg->getEnvelope(error);
|
||||
|
||||
DtMailValueSeq value;
|
||||
|
||||
env->getHeader(error, DtMailMessageSender, DTM_TRUE, value);
|
||||
if (error.isSet()) {
|
||||
newsend->setHeader("To", "nobody@nowhere");
|
||||
}
|
||||
else {
|
||||
char * addr_str = valueToAddrString(value);
|
||||
newsend->setHeader("To", addr_str);
|
||||
delete [] addr_str;
|
||||
}
|
||||
|
||||
value.clear();
|
||||
env->getHeader(error, DtMailMessageSubject, DTM_TRUE, value);
|
||||
if (error.isSet()) {
|
||||
subject = new char[200];
|
||||
strcpy(subject, "Re: ");
|
||||
DtMailValueSeq sent;
|
||||
env->getHeader(error,
|
||||
DtMailMessageSentTime,
|
||||
DTM_TRUE,
|
||||
sent);
|
||||
if (error.isSet()) {
|
||||
strcat(subject, "Your Message");
|
||||
}
|
||||
else {
|
||||
strcat(subject, "Your Message Sent on ");
|
||||
strcat(subject, *(sent[0]));
|
||||
}
|
||||
newsend->setHeader("Subject", subject);
|
||||
}
|
||||
else {
|
||||
// Get the BE store of header. It may contain newlines or
|
||||
// tab chars which can munge the scrolling list's display!
|
||||
|
||||
const char * orig = *(value[0]);
|
||||
|
||||
int fc;
|
||||
int orig_length;
|
||||
char *tmp_subj;
|
||||
|
||||
// Check if BE store contains the funky chars.
|
||||
|
||||
for (fc = 0, orig_length = strlen(orig),
|
||||
tmp_subj = (char *) orig;
|
||||
fc < orig_length;
|
||||
fc++, tmp_subj++) {
|
||||
|
||||
char c = *tmp_subj;
|
||||
if ((c == '\n')
|
||||
|| (c == '\t')
|
||||
|| (c == '\r')) {
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
subject = new char[fc+6];
|
||||
|
||||
if (strncasecmp(orig, "Re:", 3)) {
|
||||
strcpy(subject, "Re: ");
|
||||
}
|
||||
else {
|
||||
*subject = 0;
|
||||
}
|
||||
|
||||
strncat((char *)subject, orig, fc);
|
||||
|
||||
newsend->setHeader("Subject", subject);
|
||||
}
|
||||
|
||||
newsend->setTitle(subject);
|
||||
newsend->setIconTitle(subject);
|
||||
delete [] subject;
|
||||
|
||||
if ( _include ) {
|
||||
Display_entire_msg(msgno, newsend, "indent");
|
||||
newsend->get_editor()->textEditor()->set_to_top();
|
||||
}
|
||||
appendSignature(newsend);
|
||||
newsend->setInputFocus(1);
|
||||
}
|
||||
|
||||
delete msgList;
|
||||
}
|
||||
}
|
||||
|
||||
// Container menu "Compose==>Reply to All" and "Compose==>Reply to All, Include"
|
||||
// The last parameter is a switch for including the selected message or not.
|
||||
ReplyAllCmd::ReplyAllCmd(
|
||||
char *name,
|
||||
char *label,
|
||||
int active,
|
||||
RoamMenuWindow *window,
|
||||
int include
|
||||
) : ComposeFamily( name, label, active, window )
|
||||
{
|
||||
_include = include;
|
||||
}
|
||||
|
||||
// For each message selected, reply to everybody.
|
||||
void
|
||||
ReplyAllCmd::doit()
|
||||
{
|
||||
FORCE_SEGV_DECL(MsgHndArray, msgList);
|
||||
FORCE_SEGV_DECL(MsgStruct, tmpMS);
|
||||
FORCE_SEGV_DECL(char, subject);
|
||||
FORCE_SEGV_DECL(char, to);
|
||||
FORCE_SEGV_DECL(char, buffer);
|
||||
DtMailMessageHandle msgno;
|
||||
DtMail::MailBox *mbox = _menuwindow->mailbox();
|
||||
DtMailEnv error;
|
||||
char *currentCcValue;
|
||||
SendMsgDialog *newsend;
|
||||
DtMailGenDialog * dialog;
|
||||
DtMail::Message *msg;
|
||||
DtMail::Envelope *env;
|
||||
|
||||
|
||||
// Initialize the mail_error.
|
||||
error.clear();
|
||||
|
||||
|
||||
if ( msgList = _menuwindow->list()->selected() )
|
||||
for ( int k = 0; k < msgList->length(); k++ ) {
|
||||
DtMailValueSeq value ;
|
||||
|
||||
tmpMS = msgList->at(k);
|
||||
msgno = tmpMS->message_handle;
|
||||
newsend = theCompose.getWin();
|
||||
if ( newsend == NULL ) {
|
||||
dialog = _parent->genDialog();
|
||||
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 209, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 210, "Unable to create a compose window."));
|
||||
char * helpId = DTMAILHELPNOCOMPOSE;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
}
|
||||
msg = mbox->getMessage(error, msgno);
|
||||
env = msg->getEnvelope(error);
|
||||
|
||||
env->getHeader(
|
||||
error,
|
||||
DtMailMessageToReply,
|
||||
DTM_TRUE,
|
||||
value);
|
||||
|
||||
env->getHeader(
|
||||
error,
|
||||
DtMailMessageSender,
|
||||
DTM_TRUE,
|
||||
value);
|
||||
|
||||
char * addr_str = valueToAddrString(value);
|
||||
newsend->setHeader("To", addr_str);
|
||||
delete [] addr_str;
|
||||
value.clear();
|
||||
env->getHeader(
|
||||
error,
|
||||
DtMailMessageSubject,
|
||||
DTM_TRUE,
|
||||
value);
|
||||
if ( error.isSet() ) {
|
||||
subject = new char[200];
|
||||
strcpy(subject, "Re: ");
|
||||
DtMailValueSeq sent;
|
||||
env->getHeader(error,
|
||||
DtMailMessageSentTime,
|
||||
DTM_TRUE,
|
||||
sent);
|
||||
if (error.isSet()) {
|
||||
strcat(subject, "Your Message");
|
||||
}
|
||||
else {
|
||||
strcat(subject, "Your Message Sent on ");
|
||||
strcat(subject, *(sent[0]));
|
||||
}
|
||||
newsend->setHeader("Subject", subject);
|
||||
} else {
|
||||
// Get the BE store of header. It may contain newlines or
|
||||
// tab chars which can munge the scrolling list's display!
|
||||
|
||||
const char * orig = *(value[0]);
|
||||
|
||||
|
||||
int fc = 0;
|
||||
int orig_length;
|
||||
char *tmp_subj;
|
||||
|
||||
// Check if BE store contains the funky chars.
|
||||
|
||||
for (fc = 0, orig_length = strlen(orig),
|
||||
tmp_subj = (char *)orig;
|
||||
fc < orig_length;
|
||||
fc++, tmp_subj++) {
|
||||
|
||||
char c = *tmp_subj;
|
||||
if ((c == '\n')
|
||||
|| (c == '\t')
|
||||
|| (c == '\r')) {
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
subject = new char[fc+6];
|
||||
|
||||
if (strncasecmp(orig, "Re:", 3)) {
|
||||
strcpy(subject, "Re: ");
|
||||
}
|
||||
else {
|
||||
*subject = 0;
|
||||
}
|
||||
|
||||
strncat((char *)subject, orig, fc);
|
||||
|
||||
newsend->setHeader("Subject", subject);
|
||||
}
|
||||
value.clear();
|
||||
env->getHeader(
|
||||
error,
|
||||
DtMailMessageCcReply,
|
||||
DTM_TRUE,
|
||||
value);
|
||||
if (!error.isSet()) {
|
||||
// Strip out newlines from the cc line. They *may* be
|
||||
// present.
|
||||
currentCcValue = valueToAddrString(value);
|
||||
|
||||
newsend->setHeader("Cc", currentCcValue);
|
||||
delete [] currentCcValue ;
|
||||
}
|
||||
|
||||
newsend->setTitle(subject);
|
||||
newsend->setIconTitle(subject);
|
||||
delete [] subject;
|
||||
|
||||
if ( _include ) {
|
||||
Display_entire_msg(msgno, newsend, "indent");
|
||||
newsend->get_editor()->textEditor()->set_to_top();
|
||||
}
|
||||
appendSignature(newsend);
|
||||
newsend->setInputFocus(1);
|
||||
}
|
||||
}
|
||||
|
||||
TemplateCmd::TemplateCmd(char *name,
|
||||
char *label,
|
||||
int active,
|
||||
SendMsgDialog * compose,
|
||||
const char * file)
|
||||
: NoUndoCmd(name, label, active)
|
||||
{
|
||||
_compose = compose;
|
||||
|
||||
if (*file != '/' && *file != '~') {
|
||||
// Relative path. Should be relative to home directory
|
||||
_file = (char *)malloc(strlen(file) + 4);
|
||||
if (_file != NULL) {
|
||||
strcpy(_file, "~/");
|
||||
strcat(_file, file);
|
||||
}
|
||||
} else {
|
||||
_file = strdup(file);
|
||||
}
|
||||
}
|
||||
|
||||
TemplateCmd::~TemplateCmd(void)
|
||||
{
|
||||
free(_file);
|
||||
}
|
||||
|
||||
void
|
||||
TemplateCmd::doit()
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMailGenDialog * dialog = _compose->genDialog();
|
||||
DtMailBuffer mbuf;
|
||||
|
||||
char * fullpath = d_session->expandPath(error, _file);
|
||||
|
||||
// Map the file and try to parse it as a message. If it is a message,
|
||||
// then load it with headers. Otherwise, throw everything into the
|
||||
// editor.
|
||||
//
|
||||
int fd = SafeOpen(fullpath, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 211, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 212, "The template does not exist."));
|
||||
char * helpId = DTMAILHELPNOTEMPLATE;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
free(fullpath);
|
||||
return;
|
||||
}
|
||||
|
||||
struct stat buf;
|
||||
if (SafeFStat(fd, &buf) < 0) {
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 213, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 214, "The template appears to be corrupt."));
|
||||
char * helpId = DTMAILHELPCORRUPTTEMPLATE;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
SafeClose(fd);
|
||||
free(fullpath);
|
||||
return;
|
||||
}
|
||||
|
||||
int page_size = (int)sysconf(_SC_PAGESIZE);
|
||||
size_t map_size = (size_t) (buf.st_size +
|
||||
(page_size - (buf.st_size % page_size)));
|
||||
|
||||
int free_buf = 0;
|
||||
mbuf.size = buf.st_size;
|
||||
#ifdef __osf__
|
||||
// This version of mmap does NOT allow requested length to be
|
||||
// greater than the file size ... in contradiction to the
|
||||
// documentation (don't round up).
|
||||
mbuf.buffer = mmap(0, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
#else
|
||||
mbuf.buffer = mmap(0, map_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
#endif
|
||||
if (mbuf.buffer == (char *)-1) {
|
||||
free_buf = 1;
|
||||
mbuf.buffer = new char[mbuf.size];
|
||||
if (mbuf.buffer == NULL) {
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 215, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 216, "There is not enough memory to load the template."));
|
||||
char * helpId = DTMAILHELPNOMEMTEMPLATE;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
SafeClose(fd);
|
||||
free(fullpath);
|
||||
return;
|
||||
}
|
||||
|
||||
if (SafeRead(fd, mbuf.buffer, (unsigned int)mbuf.size) < mbuf.size) {
|
||||
dialog->setToErrorDialog(GETMSG(DT_catd, 1, 217, "Mailer"),
|
||||
GETMSG(DT_catd, 1, 218, "The template appears to be corrupt."));
|
||||
char * helpId = DTMAILHELPERROR;
|
||||
int answer = dialog->post_and_return(helpId);
|
||||
SafeClose(fd);
|
||||
delete [] mbuf.buffer;
|
||||
free(fullpath);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Now we ask the library to parse it. If this fails for any reason, this
|
||||
// is not a message, so we give up.
|
||||
//
|
||||
DtMail::Message * msg = d_session->messageConstruct(error,
|
||||
DtMailBufferObject,
|
||||
&mbuf,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
if (error.isSet()) {
|
||||
_compose->get_editor()->textEditor()->append_to_contents((char *)mbuf.buffer,
|
||||
mbuf.size);
|
||||
}
|
||||
else {
|
||||
_compose->loadHeaders(msg, DTM_TRUE);
|
||||
|
||||
DtMail::BodyPart * bp = msg->getFirstBodyPart(error);
|
||||
if (error.isNotSet()) {
|
||||
const void * contents;
|
||||
unsigned long length;
|
||||
|
||||
bp->getContents(error,
|
||||
&contents,
|
||||
&length,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
_compose->get_editor()->textEditor()->append_to_contents(
|
||||
(char *)contents, length);
|
||||
}
|
||||
}
|
||||
|
||||
free(fullpath);
|
||||
|
||||
if (free_buf) {
|
||||
free(mbuf.buffer);
|
||||
}
|
||||
else {
|
||||
munmap((char *)mbuf.buffer, map_size);
|
||||
}
|
||||
|
||||
SafeClose(fd);
|
||||
}
|
||||
|
||||
HideShowCmd::HideShowCmd(char *name,
|
||||
char *widgetlabel,
|
||||
int active,
|
||||
SendMsgDialog * compose,
|
||||
const char * label)
|
||||
: NoUndoCmd(name, (char *)widgetlabel, active)
|
||||
{
|
||||
_compose = compose;
|
||||
_header = strdup(label);
|
||||
}
|
||||
|
||||
HideShowCmd::~HideShowCmd(void)
|
||||
{
|
||||
if (_header) {
|
||||
free(_header);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HideShowCmd::doit(void)
|
||||
{
|
||||
_compose->changeHeaderState(_header);
|
||||
}
|
||||
110
cde/programs/dtmail/dtmail/ComposeCmds.hh
Normal file
110
cde/programs/dtmail/dtmail/ComposeCmds.hh
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: ComposeCmds.hh /main/3 1995/11/06 16:05:11 rswiston $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef COMPOSECMDS_HH
|
||||
#define COMPOSECMDS_HH
|
||||
|
||||
class ComposeFamily : public RoamCmd {
|
||||
private:
|
||||
RoamMenuWindow * _parent;
|
||||
|
||||
public:
|
||||
ComposeFamily(char * name, char *label, int active, RoamMenuWindow *);
|
||||
#ifndef CAN_INLINE_VIRTUALS
|
||||
~ComposeFamily( void );
|
||||
#endif /* ! CAN_INLINE_VIRTUALS */
|
||||
void Display_entire_msg(DtMailMessageHandle, SendMsgDialog *, char *);
|
||||
void appendSignature(SendMsgDialog *);
|
||||
char * valueToAddrString(DtMailValueSeq & value);
|
||||
};
|
||||
|
||||
class ComposeCmd : public ComposeFamily {
|
||||
private:
|
||||
RoamMenuWindow * _parent;
|
||||
|
||||
public:
|
||||
virtual void doit();
|
||||
ComposeCmd( char *, char *, int, RoamMenuWindow * );
|
||||
virtual const char *const className () { return "ComposeCmd"; }
|
||||
};
|
||||
|
||||
class ForwardCmd : public ComposeFamily {
|
||||
private:
|
||||
RoamMenuWindow *_parent;
|
||||
int _forward;
|
||||
public:
|
||||
virtual void doit();
|
||||
ForwardCmd( char *, char *, int, RoamMenuWindow *, int );
|
||||
virtual const char *const className () { return "ForwardCmd"; }
|
||||
};
|
||||
|
||||
class ReplyAllCmd : public ComposeFamily {
|
||||
private:
|
||||
RoamMenuWindow *_parent;
|
||||
int _include;
|
||||
public:
|
||||
virtual void doit();
|
||||
ReplyAllCmd( char *, char *, int, RoamMenuWindow *, int );
|
||||
virtual const char *const className () { return "ReplyAllCmd"; }
|
||||
};
|
||||
|
||||
class ReplyCmd : public ComposeFamily {
|
||||
private:
|
||||
RoamMenuWindow *_parent;
|
||||
int _include;
|
||||
public:
|
||||
virtual void doit();
|
||||
ReplyCmd( char *, char *, int, RoamMenuWindow *, int );
|
||||
virtual const char *const className () { return "ReplyCmd"; }
|
||||
};
|
||||
|
||||
class TemplateCmd : public NoUndoCmd {
|
||||
private:
|
||||
SendMsgDialog *_compose;
|
||||
char *_file;
|
||||
|
||||
public:
|
||||
virtual void doit();
|
||||
TemplateCmd(char * name,
|
||||
char *label,
|
||||
int active,
|
||||
SendMsgDialog *,
|
||||
const char * file);
|
||||
virtual ~TemplateCmd();
|
||||
virtual const char *const className() { return "TemplateCmd"; }
|
||||
};
|
||||
|
||||
class HideShowCmd : public NoUndoCmd {
|
||||
private:
|
||||
SendMsgDialog *_compose;
|
||||
char *_header;
|
||||
|
||||
public:
|
||||
virtual void doit(void);
|
||||
HideShowCmd(char * name,
|
||||
char *widgetlabel,
|
||||
int active,
|
||||
SendMsgDialog *,
|
||||
const char * label);
|
||||
virtual ~HideShowCmd(void);
|
||||
virtual const char *const className() { return "HideShowCmd"; }
|
||||
};
|
||||
|
||||
#endif
|
||||
404
cde/programs/dtmail/dtmail/CustomListUiItem.C
Normal file
404
cde/programs/dtmail/dtmail/CustomListUiItem.C
Normal file
@@ -0,0 +1,404 @@
|
||||
/* $TOG: CustomListUiItem.C /main/6 1997/09/03 17:34:40 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: CustomListUiItem.C /main/6 1997/09/03 17:34:40 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include "RoamApp.h"
|
||||
#include <Xm/List.h>
|
||||
#include <DtMail/options_util.h>
|
||||
#include "options_ui.h"
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/ListUiItem.hh>
|
||||
#include <DtMail/CustomListUiItem.hh>
|
||||
|
||||
extern void handleCustSelection(Widget, XtPointer, XtPointer );
|
||||
extern Boolean props_changed;
|
||||
|
||||
// CustomListUiItem::CustomListUiItem
|
||||
// CustomListUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
CustomListUiItem::CustomListUiItem(Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
Widget key_entry_widget,
|
||||
Widget value_entry_widget):ListUiItem(w, source, search_key, NULL)
|
||||
{
|
||||
source = source; search_key = search_key;
|
||||
|
||||
key_widget = key_entry_widget;
|
||||
value_widget = value_entry_widget;
|
||||
|
||||
list_items = NULL;
|
||||
deleted_items = NULL;
|
||||
|
||||
XtVaSetValues(w,
|
||||
XmNuserData, this,
|
||||
XmNautomaticSelection, True,
|
||||
XmNselectionPolicy, XmBROWSE_SELECT,
|
||||
NULL);
|
||||
|
||||
XtAddCallback(w,
|
||||
XmNbrowseSelectionCallback,
|
||||
(XtCallbackProc)handleCustSelection,
|
||||
(XtPointer)this);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
//-----------------======================-----------------
|
||||
void handleDoubleSelection(Widget w, XtPointer clientdata, XtPointer calldata)
|
||||
{
|
||||
CustomListUiItem *item;
|
||||
XmListCallbackStruct *list_info = (XmListCallbackStruct *)calldata;
|
||||
char *selection_string = NULL;
|
||||
DtVirtArray<PropStringPair *> *list_items;
|
||||
|
||||
|
||||
XtVaGetValues(w,
|
||||
XmNuserData, &item,
|
||||
NULL);
|
||||
|
||||
list_items = item->getItemList();
|
||||
|
||||
if(list_items != NULL)
|
||||
{ // motif index is 1 based
|
||||
//virtarry is 0 based
|
||||
PropStringPair *pair = (*list_items)[list_info->item_position - 1];
|
||||
|
||||
if(pair != NULL)
|
||||
{
|
||||
XtVaSetValues(item->getKeyWidget(),
|
||||
XmNvalue,pair->label,
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(item->getValueWidget(),
|
||||
XmNvalue,pair->value,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
//-----------------======================-----------------
|
||||
void handleCustSelection(Widget w, XtPointer, XtPointer calldata)
|
||||
{
|
||||
CustomListUiItem *item;
|
||||
XmListCallbackStruct *list_info = (XmListCallbackStruct *)calldata;
|
||||
char *selection_string = NULL;
|
||||
DtVirtArray<PropStringPair *> *list_items;
|
||||
|
||||
|
||||
XtVaGetValues(w,
|
||||
XmNuserData, &item,
|
||||
NULL);
|
||||
|
||||
list_items = item->getItemList();
|
||||
|
||||
if(list_items != NULL)
|
||||
{ // motif index is 1 based
|
||||
//virtarry is 0 based
|
||||
PropStringPair *pair = (*list_items)[list_info->item_position - 1];
|
||||
|
||||
if(pair != NULL)
|
||||
{
|
||||
XtVaSetValues(item->getKeyWidget(),
|
||||
XmNvalue,pair->label,
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(item->getValueWidget(),
|
||||
XmNvalue,pair->value,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
// CustomListUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void CustomListUiItem::writeFromUiToSource()
|
||||
{
|
||||
Widget w = this->getWidget();
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
int i, num_items;
|
||||
char *cf_str = NULL;
|
||||
|
||||
if(list_items != NULL) {
|
||||
if(list_items->length() > 0)
|
||||
{
|
||||
num_items = list_items->length();
|
||||
// calc mailrc strlen...
|
||||
int total_len = 1; // add space for the terminator...
|
||||
for(i = 0; i < num_items; i++) {
|
||||
int num_blanks=0;
|
||||
for (char *ptr = (*list_items)[i]->value;
|
||||
ptr && *ptr; ptr++)
|
||||
if (*ptr == ' ') num_blanks++;
|
||||
// strlen(label) strlen(value) + space + colon +
|
||||
// potential \'s that precede the blank character
|
||||
if((*list_items)[i]->label != NULL)
|
||||
total_len = total_len + strlen(":") +
|
||||
(strlen("\\") * num_blanks) +
|
||||
strlen((*list_items)[i]->label) + 2;
|
||||
|
||||
if((*list_items)[i]->value != NULL)
|
||||
total_len = total_len + strlen((*list_items)[i]->value);
|
||||
}
|
||||
cf_str = (char *)malloc(total_len);
|
||||
cf_str[0] = '\0';
|
||||
|
||||
for(i = 0; i < num_items; i++) {
|
||||
if((*list_items)[i]->label != NULL)
|
||||
strcat(cf_str, (*list_items)[i]->label);
|
||||
strcat(cf_str, ":");
|
||||
if((*list_items)[i]->value != NULL) {
|
||||
if (strchr((char*)(*list_items)[i]->value, ' ')) {
|
||||
char *token, *tmpbuf;
|
||||
tmpbuf = strdup((*list_items)[i]->value);
|
||||
if (token = (char *)strtok(tmpbuf, " ")) {
|
||||
strcat(cf_str, token);
|
||||
while(token = (char *)strtok(NULL, " ")) {
|
||||
strcat(cf_str, "\\ ");
|
||||
strcat(cf_str, token);
|
||||
}
|
||||
}
|
||||
free(tmpbuf);
|
||||
}
|
||||
else
|
||||
strcat(cf_str, (*list_items)[i]->value);
|
||||
}
|
||||
strcat(cf_str, " ");
|
||||
}
|
||||
mail_rc->setValue(error, "additionalfields", cf_str);
|
||||
}
|
||||
else
|
||||
mail_rc->removeValue(error, "additionalfields");
|
||||
}
|
||||
else
|
||||
mail_rc->removeValue(error, "additionalfields");
|
||||
|
||||
}
|
||||
|
||||
// CustomListUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void CustomListUiItem::writeFromSourceToUi()
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
Widget w = this->getWidget();
|
||||
const char *list_str = NULL;
|
||||
DtVirtArray<char *> list_str_list(10);
|
||||
char *buf = NULL;
|
||||
int list_len, i;
|
||||
const char *value = NULL;
|
||||
|
||||
XmListDeleteAllItems(w);
|
||||
|
||||
mail_rc->getValue(error, "additionalfields", &value);
|
||||
|
||||
if(list_items != NULL)
|
||||
delete list_items;
|
||||
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
parsePropString(value, *list_items);
|
||||
|
||||
list_len = list_items->length();
|
||||
for(i = 0; i < list_len; i++)
|
||||
list_str_list.append(formatPropPair((*list_items)[i]->label,
|
||||
(*list_items)[i]->value));
|
||||
|
||||
options_list_init(w, &list_str_list);
|
||||
|
||||
if (value != NULL)
|
||||
free((void *)value);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
void CustomListUiItem::handleAddButtonPress()
|
||||
{
|
||||
char *key_str = NULL;
|
||||
char *value_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
|
||||
XtVaGetValues(key_widget,
|
||||
XmNvalue, &key_str,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues(value_widget,
|
||||
XmNvalue, &value_str,
|
||||
NULL);
|
||||
|
||||
if(key_str != NULL)
|
||||
if(strlen(key_str) > 0)
|
||||
{
|
||||
new_pair = new PropStringPair;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
new_pair->label = strdup(key_str);
|
||||
|
||||
if(value_str != NULL)
|
||||
new_pair->value = strdup(value_str);
|
||||
else
|
||||
new_pair->value = NULL;
|
||||
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,pos_list[0] - 1);
|
||||
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(
|
||||
formatPropPair(
|
||||
new_pair->label,
|
||||
new_pair->value)),
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
pos_list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,0);
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(
|
||||
formatPropPair(
|
||||
new_pair->label,
|
||||
new_pair->value)),
|
||||
1);
|
||||
XmListSelectPos(this->getWidget(),
|
||||
1,
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
1);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void CustomListUiItem::handleChangeButtonPress()
|
||||
{
|
||||
char *key_str = NULL;
|
||||
char *value_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
XmString replace_string;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
// if nothing selected nothing to change...
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
XtVaGetValues(key_widget,
|
||||
XmNvalue, &key_str,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues(value_widget,
|
||||
XmNvalue, &value_str,
|
||||
NULL);
|
||||
|
||||
if(key_str != NULL)
|
||||
if(strlen(key_str) > 0)
|
||||
{
|
||||
|
||||
new_pair = (*list_items)[pos_list[0] - 1];
|
||||
|
||||
free(new_pair->label);
|
||||
new_pair->label = strdup(key_str);
|
||||
|
||||
if(new_pair->value != NULL)
|
||||
{
|
||||
free(new_pair->value);
|
||||
if(value_str != NULL)
|
||||
new_pair->value = strdup(value_str);
|
||||
else
|
||||
new_pair->value = NULL;
|
||||
}
|
||||
|
||||
replace_string = XmStringCreateLocalized(
|
||||
formatPropPair(new_pair->label,
|
||||
new_pair->value));
|
||||
|
||||
XmListReplaceItemsPos(this->getWidget(),
|
||||
&replace_string,
|
||||
1,
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void CustomListUiItem::handleDeleteButtonPress()
|
||||
{
|
||||
Widget list_widget = this->getWidget();
|
||||
int *p_list, p_count;
|
||||
|
||||
// get the selected position
|
||||
if(XmListGetSelectedPos(list_widget,
|
||||
&p_list,
|
||||
&p_count))
|
||||
{
|
||||
|
||||
// delete the item from our list
|
||||
this->list_items->remove(p_list[0] - 1); // remove only first
|
||||
|
||||
// delete the item from the widget
|
||||
XmListDeletePos(list_widget, p_list[0]);
|
||||
|
||||
XtVaSetValues(this->getKeyWidget(),
|
||||
XmNvalue,"",
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(this->getValueWidget(),
|
||||
XmNvalue,"",
|
||||
NULL);
|
||||
|
||||
XmListSelectPos(list_widget,
|
||||
p_list[0],
|
||||
TRUE);
|
||||
|
||||
props_changed = TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
18
cde/programs/dtmail/dtmail/DebugBento
Normal file
18
cde/programs/dtmail/dtmail/DebugBento
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/csh
|
||||
#
|
||||
# A script that aids in debugging and testing dtmail
|
||||
#
|
||||
if ( `uname -s` != SunOS ) then
|
||||
echo "Only support SunOS"
|
||||
exit 1
|
||||
endif
|
||||
set echo
|
||||
setenv DT_MAIL /home/dougr/INBOX
|
||||
setenv DEFAULT_BACKEND Bento
|
||||
setenv LD_LIBRARY_PATH ../libDtMail:../../../lib/Bento:../../../binstall/lib:$LD_LIBRARY_PATH
|
||||
ldd -r dtmail
|
||||
if ( -f core ) then
|
||||
exec debugger dtmail core &
|
||||
else
|
||||
exec debugger dtmail &
|
||||
endif
|
||||
20
cde/programs/dtmail/dtmail/DebugMime
Normal file
20
cde/programs/dtmail/dtmail/DebugMime
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/csh
|
||||
#
|
||||
# A script that aids in debugging and testing dtmail
|
||||
#
|
||||
if ( `uname -s` != SunOS ) then
|
||||
echo "Only support SunOS"
|
||||
exit 1
|
||||
endif
|
||||
|
||||
set echo
|
||||
setenv LD_LIBRARY_PATH ../libDtMail:../../../binstall/lib:$LD_LIBRARY_PATH
|
||||
ldd -r dtmail
|
||||
|
||||
setenv ARGS "$*"
|
||||
if ( -f core ) then
|
||||
exec debugger dtmail core &
|
||||
else
|
||||
exec debugger dtmail &
|
||||
endif
|
||||
exit 1
|
||||
151
cde/programs/dtmail/dtmail/Dialog.C
Normal file
151
cde/programs/dtmail/dtmail/Dialog.C
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: Dialog.C /main/4 1996/04/21 19:41:15 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include "Dialog.h"
|
||||
#include "Application.h"
|
||||
#include "RoamMenuWindow.h"
|
||||
#include <Xm/DialogS.h>
|
||||
#include <assert.h>
|
||||
#include "Help.hh"
|
||||
|
||||
// The following header is private to CDE and should NOT be required
|
||||
// but unfortunately is.
|
||||
//
|
||||
extern "C" {
|
||||
#include <Dt/HourGlass.h>
|
||||
}
|
||||
|
||||
|
||||
Dialog::Dialog(char *name, RoamMenuWindow *parent) : UIComponent(name)
|
||||
{
|
||||
_parent = parent;
|
||||
_workArea = NULL;
|
||||
|
||||
_w = XtCreatePopupShell(_name,
|
||||
xmDialogShellWidgetClass,
|
||||
parent->baseWidget(),
|
||||
NULL, 0 );
|
||||
|
||||
XtVaSetValues(_w, XmNdefaultPosition, False, NULL);
|
||||
|
||||
assert( theApplication != NULL );
|
||||
}
|
||||
|
||||
Dialog::Dialog(RoamMenuWindow *parent) : UIComponent("")
|
||||
{
|
||||
_parent = parent;
|
||||
_workArea=NULL;
|
||||
}
|
||||
|
||||
Dialog::~Dialog()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Dialog::initialize()
|
||||
{
|
||||
|
||||
|
||||
|
||||
XtVaSetValues( _w,
|
||||
XmNdefaultPosition, False, NULL );
|
||||
|
||||
XtAddCallback( _w,
|
||||
XmNpopupCallback,
|
||||
( XtCallbackProc ) &Dialog::popupCallback,
|
||||
XtPointer( this ) );
|
||||
|
||||
XtAddCallback( _w,
|
||||
XmNpopdownCallback,
|
||||
( XtCallbackProc ) &Dialog::popdownCallback,
|
||||
XtPointer( this ) );
|
||||
|
||||
_workArea = createWorkArea ( _w );
|
||||
assert ( _workArea != NULL );
|
||||
printHelpId("_workArea", _workArea);
|
||||
/* add help callback */
|
||||
// XtAddCallback(_workArea, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
if ( !XtIsManaged ( _workArea ) )
|
||||
XtManageChild ( _workArea );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Dialog::title(
|
||||
char *text
|
||||
)
|
||||
{
|
||||
XtVaSetValues ( _w, XmNtitle, text, NULL );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Dialog::popupCallback( Widget ,
|
||||
XtPointer clientData,
|
||||
XmAnyCallbackStruct *
|
||||
)
|
||||
{
|
||||
Dialog *window=( Dialog * ) clientData;
|
||||
|
||||
window->popped_up();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Dialog::popdownCallback( Widget , // w
|
||||
XtPointer clientData,
|
||||
XmAnyCallbackStruct *
|
||||
)
|
||||
{
|
||||
Dialog *window=( Dialog * ) clientData;
|
||||
|
||||
window->popped_down();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Dialog::manage()
|
||||
{
|
||||
if ( !XtIsManaged ( _workArea ) )
|
||||
XtManageChild ( _workArea );
|
||||
UIComponent::manage();
|
||||
}
|
||||
|
||||
void
|
||||
Dialog::busyCursor()
|
||||
{
|
||||
// Do nothing if the widget has not been realized.
|
||||
|
||||
if (XtIsRealized(_w)) {
|
||||
_DtTurnOnHourGlass(_w);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Dialog::normalCursor()
|
||||
{
|
||||
// Do nothing if the widget has not been realized
|
||||
|
||||
if (XtIsRealized(_w)) {
|
||||
_DtTurnOffHourGlass(_w);
|
||||
}
|
||||
}
|
||||
68
cde/programs/dtmail/dtmail/Dialog.h
Normal file
68
cde/programs/dtmail/dtmail/Dialog.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: Dialog.h /main/4 1996/04/21 19:41:19 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef DIALOG_H
|
||||
#define DIALOG_H
|
||||
|
||||
#include <UIComponent.h>
|
||||
|
||||
class RoamMenuWindow;
|
||||
|
||||
class Dialog : public UIComponent {
|
||||
|
||||
public:
|
||||
Dialog(char *, RoamMenuWindow *);
|
||||
Dialog(RoamMenuWindow *); // For custom dialogs.
|
||||
|
||||
virtual ~Dialog();
|
||||
virtual void initialize();
|
||||
|
||||
// Accessors
|
||||
|
||||
RoamMenuWindow *parent() { return _parent; };
|
||||
Widget work_area(){ return _workArea; }
|
||||
|
||||
// Mutators
|
||||
|
||||
virtual void title( char * );
|
||||
virtual void popped_up()=0;
|
||||
virtual void popped_down()=0;
|
||||
virtual void popup()=0;
|
||||
virtual void popdown()=0;
|
||||
virtual void manage();
|
||||
virtual void busyCursor();
|
||||
virtual void normalCursor();
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual Widget createWorkArea( Widget ) = 0;
|
||||
static void popdownCallback ( Widget, XtPointer, XmAnyCallbackStruct * );
|
||||
static void popupCallback( Widget, XtPointer, XmAnyCallbackStruct * );
|
||||
|
||||
private:
|
||||
|
||||
Widget _workArea;
|
||||
RoamMenuWindow *_parent;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
177
cde/programs/dtmail/dtmail/DialogShell.C
Normal file
177
cde/programs/dtmail/dtmail/DialogShell.C
Normal file
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DialogShell.C /main/10 1998/02/03 12:10:06 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/Xmu/Editres.h>
|
||||
#include <Xm/Protocols.h>
|
||||
#include <Xm/AtomMgr.h>
|
||||
|
||||
#include <Dt/Wsm.h>
|
||||
#include <Dt/Session.h>
|
||||
#include <DtMail/IO.hh>
|
||||
|
||||
// The following headers are private to CDE and should NOT be required
|
||||
// but unfortunately are.
|
||||
//
|
||||
extern "C" {
|
||||
#include <Dt/HourGlass.h>
|
||||
}
|
||||
#include <Dt/Icon.h>
|
||||
#include <Dt/IconP.h>
|
||||
#include <Dt/IconFile.h>
|
||||
|
||||
#include "DialogShell.h"
|
||||
#include "Application.h"
|
||||
#include "RoamMenuWindow.h"
|
||||
|
||||
|
||||
DialogShell::DialogShell(char *name, RoamMenuWindow *parent, WidgetClass wc)
|
||||
: UIComponent(name)
|
||||
{
|
||||
_parent=parent;
|
||||
_workArea=NULL;
|
||||
_widgetClass=wc;
|
||||
|
||||
assert( theApplication != NULL );
|
||||
}
|
||||
|
||||
DialogShell::~DialogShell()
|
||||
{
|
||||
Atom WM_DELETE_WINDOW=XmInternAtom( XtDisplay( _w ),
|
||||
"WM_DELETE_WINDOW",
|
||||
False );
|
||||
XmRemoveWMProtocolCallback( _w,
|
||||
WM_DELETE_WINDOW,
|
||||
( XtCallbackProc ) quitCallback,
|
||||
NULL );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DialogShell::initialize()
|
||||
{
|
||||
_w = XtVaCreatePopupShell(
|
||||
_name, _widgetClass, _parent->baseWidget(),
|
||||
XmNdefaultPosition, False,
|
||||
NULL, 0 );
|
||||
#ifdef USE_EDITRES
|
||||
XtAddEventHandler(
|
||||
_w, (EventMask) 0, True,
|
||||
(XtEventHandler) _XEditResCheckMessages, NULL);
|
||||
#endif
|
||||
|
||||
installDestroyHandler();
|
||||
_workArea = createWorkArea ( _w );
|
||||
assert ( _workArea != NULL );
|
||||
|
||||
XtVaSetValues( _w, XmNdefaultPosition, False, NULL );
|
||||
XtAddCallback( _w,
|
||||
XmNpopupCallback,
|
||||
( XtCallbackProc ) &DialogShell::popupCallback,
|
||||
XtPointer( this ) );
|
||||
XtAddCallback( _w,
|
||||
XmNpopdownCallback,
|
||||
( XtCallbackProc ) &DialogShell::popdownCallback,
|
||||
XtPointer( this ) );
|
||||
|
||||
Atom WM_DELETE_WINDOW=XmInternAtom( XtDisplay( _w ),
|
||||
"WM_DELETE_WINDOW",
|
||||
False );
|
||||
|
||||
XmAddWMProtocolCallback( _w,
|
||||
WM_DELETE_WINDOW,
|
||||
( XtCallbackProc ) quitCallback,
|
||||
this );
|
||||
|
||||
// if (!XtIsManaged(_workArea)) XtManageChild(_workArea);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DialogShell::title(
|
||||
char *text
|
||||
)
|
||||
{
|
||||
XtVaSetValues ( _w, XmNtitle, text, NULL );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DialogShell::popupCallback( Widget ,
|
||||
XtPointer clientData,
|
||||
XmAnyCallbackStruct *
|
||||
)
|
||||
{
|
||||
DialogShell *obj=( DialogShell * ) clientData;
|
||||
obj->popped_up();
|
||||
obj->displayInCurrentWorkspace();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DialogShell::popdownCallback( Widget ,
|
||||
XtPointer clientData,
|
||||
XmAnyCallbackStruct *
|
||||
)
|
||||
{
|
||||
DialogShell *obj=( DialogShell * ) clientData;
|
||||
obj->popped_down();
|
||||
}
|
||||
|
||||
void
|
||||
DialogShell::manage()
|
||||
{
|
||||
if (NULL == _workArea) return;
|
||||
if (!XtIsManaged(_workArea )) XtManageChild(_workArea);
|
||||
UIComponent::manage();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DialogShell::quitCallback( Widget,
|
||||
XtPointer clientData,
|
||||
XmAnyCallbackStruct *)
|
||||
{
|
||||
DialogShell *dlg = ( DialogShell *) clientData;
|
||||
dlg->quit();
|
||||
}
|
||||
|
||||
void
|
||||
DialogShell::busyCursor()
|
||||
{
|
||||
// Do nothing if the widget has not been realized
|
||||
|
||||
if (XtIsRealized(_w)) {
|
||||
_DtTurnOnHourGlass(_w);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DialogShell::normalCursor()
|
||||
{
|
||||
// Do nothing if the widget has not been realized
|
||||
|
||||
if (XtIsRealized ( _w ))
|
||||
{
|
||||
_DtTurnOffHourGlass(_w);
|
||||
}
|
||||
}
|
||||
71
cde/programs/dtmail/dtmail/DialogShell.h
Normal file
71
cde/programs/dtmail/dtmail/DialogShell.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DialogShell.h /main/5 1998/01/28 18:35:07 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef DIALOGSHELL_H
|
||||
#define DIALOGSHELL_H
|
||||
|
||||
#include <Xm/DialogS.h>
|
||||
#include "UIComponent.h"
|
||||
|
||||
class RoamMenuWindow;
|
||||
|
||||
class DialogShell : public UIComponent {
|
||||
|
||||
public:
|
||||
DialogShell(
|
||||
char *name,
|
||||
RoamMenuWindow *parent,
|
||||
WidgetClass wc = xmDialogShellWidgetClass);
|
||||
virtual ~DialogShell();
|
||||
virtual void initialize();
|
||||
|
||||
// Accessors
|
||||
|
||||
RoamMenuWindow *parent() { return _parent; };
|
||||
Widget work_area(){ return _workArea; }
|
||||
|
||||
// Mutators
|
||||
|
||||
virtual void title( char * );
|
||||
virtual void popped_up()=0;
|
||||
virtual void popped_down()=0;
|
||||
virtual void manage();
|
||||
virtual void busyCursor();
|
||||
virtual void normalCursor();
|
||||
|
||||
virtual void quit()=0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual Widget createWorkArea( Widget ) = 0;
|
||||
static void popdownCallback ( Widget, XtPointer, XmAnyCallbackStruct * );
|
||||
static void popupCallback( Widget, XtPointer, XmAnyCallbackStruct * );
|
||||
Widget _workArea;
|
||||
|
||||
private:
|
||||
|
||||
static void quitCallback( Widget, XtPointer, XmAnyCallbackStruct * );
|
||||
|
||||
RoamMenuWindow *_parent;
|
||||
WidgetClass _widgetClass;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
55
cde/programs/dtmail/dtmail/DialogWindow.h
Normal file
55
cde/programs/dtmail/dtmail/DialogWindow.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: DialogWindow.h /main/4 1996/04/21 19:41:28 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef DIALOGWINDOW_H
|
||||
#define DIALOGWINDOW_H
|
||||
|
||||
#include "UIComponent.h"
|
||||
|
||||
class RoamMenuWindow;
|
||||
|
||||
class DialogWindow : public UIComponent {
|
||||
|
||||
static void popdownCallback ( Widget, XtPointer, XmAnyCallbackStruct * );
|
||||
static void popupCallback( Widget, XtPointer, XmAnyCallbackStruct * );
|
||||
|
||||
protected:
|
||||
|
||||
Widget _workArea;
|
||||
RoamMenuWindow *_parent;
|
||||
virtual Widget createWorkArea( Widget ) = 0;
|
||||
|
||||
public:
|
||||
DialogWindow( char *, RoamMenuWindow * );
|
||||
virtual ~DialogWindow();
|
||||
virtual void initialize();
|
||||
|
||||
// Accessors
|
||||
|
||||
RoamMenuWindow *parent() { return _parent; };
|
||||
|
||||
// Mutators
|
||||
|
||||
virtual void title( char * );
|
||||
virtual void popup()=0;
|
||||
virtual void popdown()=0;
|
||||
};
|
||||
|
||||
#endif
|
||||
198
cde/programs/dtmail/dtmail/Dmx.h
Normal file
198
cde/programs/dtmail/dtmail/Dmx.h
Normal file
@@ -0,0 +1,198 @@
|
||||
/* $XConsortium: Dmx.h /main/4 1996/04/21 19:55:42 drk $ */
|
||||
|
||||
#ifndef _DMX_HH
|
||||
#define _DMX_HH
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <DtMail/DtMail.hh>
|
||||
#include <DtMail/DtMailError.hh>
|
||||
#include <DtMail/DtMailValues.hh>
|
||||
#include <Dt/Dts.h>
|
||||
|
||||
extern const char *const dmxversion;
|
||||
|
||||
typedef enum {
|
||||
DMX_NONE_STRING,
|
||||
DMX_CC_HEADER_STRING,
|
||||
DMX_DATE_HEADER_STRING,
|
||||
DMX_FROM_HEADER_STRING,
|
||||
DMX_SUBJECT_HEADER_STRING,
|
||||
DMX_TO_HEADER_STRING,
|
||||
DMX_PAGE_NUMBER_STRING,
|
||||
DMX_USER_NAME_STRING,
|
||||
/*
|
||||
* KEEP THIS LAST
|
||||
*/
|
||||
DMX_NUM_STRING_TYPE_ENUM
|
||||
} DmxStringTypeEnum;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DMX_SEPARATOR_NEW_LINE,
|
||||
DMX_SEPARATOR_BLANK_LINE,
|
||||
DMX_SEPARATOR_CHARACTER_LINE,
|
||||
DMX_SEPARATOR_PAGE_BREAK,
|
||||
DMX_SEPARATOR_NEW_JOB,
|
||||
/*
|
||||
* KEEP THIS LAST
|
||||
*/
|
||||
DMX_NUM_MSG_SEPARATOR_ENUM
|
||||
} DmxMsgSeparatorEnum;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DMX_PRINT_HEADERS_NONE,
|
||||
DMX_PRINT_HEADERS_STANDARD,
|
||||
DMX_PRINT_HEADERS_ABBREV,
|
||||
DMX_PRINT_HEADERS_ALL,
|
||||
/*
|
||||
* KEEP THIS LAST
|
||||
*/
|
||||
DMX_NUM_PRINT_HEADERS_ENUM
|
||||
} DmxPrintHeadersEnum;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DMXCC,
|
||||
DMXFROM,
|
||||
DMXSUBJ,
|
||||
DMXCLENGTH,
|
||||
DMXSTATUS,
|
||||
DMXDATE,
|
||||
DMXTO,
|
||||
DMXV3CHARSET,
|
||||
DMXCONTENTTYPE,
|
||||
DMXNUMHDRS
|
||||
} DmxHeaders;
|
||||
|
||||
// utils
|
||||
char *convertValueToString (DtMailValueSeq *, int);
|
||||
DtMailBoolean handleError (DtMailEnv &, char *);
|
||||
char *getStandardHeaders (DtMailHeaderLine &);
|
||||
char *errorString (DmxHeaders);
|
||||
|
||||
class DmxMsg
|
||||
{
|
||||
public:
|
||||
|
||||
typedef void (*DmxPrintOutputProc)(XtPointer, char*);
|
||||
|
||||
DmxMsg (void);
|
||||
|
||||
void display (DmxPrintHeadersEnum, DmxPrintOutputProc, XtPointer);
|
||||
void setHandle (DtMailMessageHandle &);
|
||||
void setHeader (DtMailHeaderLine &);
|
||||
void setMessage (DtMail::Message *);
|
||||
void setInfo (char *);
|
||||
void parse (void);
|
||||
char *getPrintedHeaders (DmxPrintHeadersEnum);
|
||||
char *getHeaders (DtMailBoolean);
|
||||
char *getMessageHeader (DmxHeaders);
|
||||
|
||||
|
||||
DtMailMessageHandle msgHandle;
|
||||
DtMailHeaderLine msgHeader;
|
||||
DtMail::Message *message;
|
||||
|
||||
DtMail::BodyPart **bodyParts;
|
||||
int numBPs;
|
||||
|
||||
char *addlInfo;
|
||||
DtMailBoolean cachedValues;
|
||||
DtMailBoolean isNew;
|
||||
// other flags for status (read, unopened, etc.)
|
||||
};
|
||||
|
||||
|
||||
class DmxMailbox
|
||||
{
|
||||
private:
|
||||
void createHeaderRequest (DtMailHeaderRequest &);
|
||||
void printMailboxInfo (void);
|
||||
|
||||
static const int _firstIndex;
|
||||
char *_fileName;
|
||||
DtMail::MailBox *_mbox;
|
||||
DmxMsg _messages[2048];
|
||||
DmxMsg *_message;
|
||||
int _messageCount;
|
||||
public:
|
||||
DmxMailbox (char*);
|
||||
~DmxMailbox (void);
|
||||
|
||||
void loadMessages (void);
|
||||
inline DmxMsg *firstMessage (void)
|
||||
{
|
||||
return (_message = &_messages[_firstIndex]);
|
||||
}
|
||||
inline DmxMsg *nextMessage (void)
|
||||
{
|
||||
_message++;
|
||||
return ((_message <= &_messages[_messageCount]) ?
|
||||
_message :
|
||||
(DmxMsg*)NULL);
|
||||
}
|
||||
inline int numMessages (void) { return _messageCount; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // _DMX_HH
|
||||
212
cde/programs/dtmail/dtmail/DmxMailbox.C
Normal file
212
cde/programs/dtmail/dtmail/DmxMailbox.C
Normal file
@@ -0,0 +1,212 @@
|
||||
/* $XConsortium: DmxMailbox.C /main/3 1996/04/21 19:55:45 drk $ */
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "Dmx.h"
|
||||
#include "MemUtils.hh"
|
||||
#include "RoamApp.h"
|
||||
|
||||
const int DmxMailbox::_firstIndex = 1;
|
||||
|
||||
DmxMailbox::DmxMailbox (char *filename)
|
||||
{
|
||||
_mbox = NULL;
|
||||
_messageCount = 0;
|
||||
_fileName = strdup_n(filename);
|
||||
}
|
||||
|
||||
DmxMailbox::~DmxMailbox (void)
|
||||
{
|
||||
delete(_fileName);
|
||||
if (_mbox)
|
||||
delete (_mbox);
|
||||
}
|
||||
|
||||
void
|
||||
DmxMailbox::loadMessages (void)
|
||||
{
|
||||
DtMailEnv env;
|
||||
DtMailBoolean moreMessages = DTM_TRUE;
|
||||
DtMail::Session *session = theRoamApp.session()->session();
|
||||
|
||||
// try to construct _mbox
|
||||
_mbox = session->mailBoxConstruct (
|
||||
env,
|
||||
DtMailFileObject,
|
||||
_fileName,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
if (handleError (env, "new DtMail::MailBox") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
// open the mailbox
|
||||
// (O_RDONLY for now)
|
||||
_mbox->open (env, /* DtMailEnv */
|
||||
DTM_FALSE, /* auto_create */
|
||||
O_RDONLY, /* open(2) flag */
|
||||
(mode_t) 0, /* create(2) mode */
|
||||
DTM_FALSE, /* lock_flag */
|
||||
DTM_TRUE /* auto_parse */
|
||||
);
|
||||
|
||||
if (handleError (env, "open mailbox") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
// get the first message handle
|
||||
DtMailMessageHandle first = NULL, next = NULL, prev = NULL;
|
||||
DtMailHeaderRequest request;
|
||||
DtMailHeaderLine hdrline;
|
||||
int i = _firstIndex;
|
||||
DtMail::Message *m = NULL; // temporary
|
||||
|
||||
createHeaderRequest (request);
|
||||
|
||||
first = _mbox->getFirstMessageSummary (env, request, hdrline);
|
||||
|
||||
if (handleError (env, "get first msg summary") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
if (first == NULL)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"loadMessages: error w/1st message...exiting.\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
// this makes hash of the caching strategy, but oh well....
|
||||
m = _mbox->getMessage (env, first);
|
||||
if (handleError (env, "get first msg") == DTM_TRUE)
|
||||
exit (1);
|
||||
_messages [i].setMessage (m);
|
||||
|
||||
prev = first;
|
||||
|
||||
_messages [i].setHandle (first);
|
||||
_messages [i].setHeader (hdrline);
|
||||
|
||||
while (moreMessages == DTM_TRUE)
|
||||
{
|
||||
next = _mbox->getNextMessageSummary (env, prev,
|
||||
request, hdrline);
|
||||
|
||||
if (next == NULL)
|
||||
{
|
||||
moreMessages = DTM_FALSE;
|
||||
if (handleError (env, "msgLoop") == DTM_TRUE)
|
||||
exit (1);
|
||||
break; // break out if error
|
||||
} else {
|
||||
i++;
|
||||
_messages [i].setHandle (next);
|
||||
_messages [i].setHeader (hdrline);
|
||||
}
|
||||
|
||||
prev = next;
|
||||
}
|
||||
|
||||
_messageCount = i;
|
||||
|
||||
|
||||
// fill in the remaining message structures .. temporary, honest!
|
||||
for (int j = _firstIndex; j <= _messageCount; j++)
|
||||
{
|
||||
m = _mbox->getMessage (env, _messages [j].msgHandle);
|
||||
if (handleError (env, "getMessage loop") == DTM_TRUE)
|
||||
{
|
||||
printf ("fatal error...bailing...\n");
|
||||
exit (1);
|
||||
}
|
||||
_messages [j].setMessage (m);
|
||||
|
||||
char tmp [100];
|
||||
sprintf (tmp, "%d", j); // ick
|
||||
_messages [j].setInfo (tmp);
|
||||
}
|
||||
|
||||
// free header request structure
|
||||
int k;
|
||||
// this assumes that you have allocated all of the possible headers
|
||||
// in the DmxHeaders -- a bad assumption, but currently true
|
||||
for (k = 0; k < DMXNUMHDRS; k++)
|
||||
{
|
||||
free (request.header_name [k]);
|
||||
}
|
||||
delete request.header_name;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DmxMailbox::createHeaderRequest (DtMailHeaderRequest &request)
|
||||
{
|
||||
// set up default headers
|
||||
request.number_of_names = DMXNUMHDRS;
|
||||
request.header_name = new (char* [DMXNUMHDRS]);
|
||||
request.header_name[DMXCC] = strdup(DtMailMessageCc);
|
||||
request.header_name[DMXFROM] = strdup(DtMailMessageSender);
|
||||
request.header_name[DMXSUBJ] = strdup(DtMailMessageSubject);
|
||||
request.header_name[DMXDATE] = strdup(DtMailMessageReceivedTime);
|
||||
request.header_name[DMXCLENGTH] = strdup(DtMailMessageContentLength);
|
||||
request.header_name[DMXSTATUS] = strdup(DtMailMessageStatus);
|
||||
request.header_name[DMXTO] = strdup(DtMailMessageTo);
|
||||
request.header_name[DMXV3CHARSET] = strdup(DtMailMessageV3charset);
|
||||
request.header_name[DMXCONTENTTYPE] = strdup(DtMailMessageContentType);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DmxMailbox::printMailboxInfo (void)
|
||||
{
|
||||
printf ("\"%s\": %d messages\n", _fileName, _messageCount);
|
||||
return;
|
||||
}
|
||||
593
cde/programs/dtmail/dtmail/DmxMessage.C
Normal file
593
cde/programs/dtmail/dtmail/DmxMessage.C
Normal file
@@ -0,0 +1,593 @@
|
||||
/* $TOG: DmxMessage.C /main/6 1998/07/24 16:18:17 mgreess $ */
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
#include "Dmx.h"
|
||||
// For CHARSET
|
||||
#include <LocaleXlate.h>
|
||||
#include <locale.h>
|
||||
#if !defined(USL) && !defined(__uxp__)
|
||||
#include <strings.h>
|
||||
#else
|
||||
#include <EUSCompat.h>
|
||||
#endif
|
||||
|
||||
#include "Application.h"
|
||||
#include "DtMail/DtMail.hh"
|
||||
#include "DtMailTypes.h"
|
||||
#include "MailSession.hh"
|
||||
#include "RoamApp.h"
|
||||
#include "str_utils.h"
|
||||
|
||||
|
||||
DmxMsg::DmxMsg (void)
|
||||
{
|
||||
// initialize everything
|
||||
message = NULL;
|
||||
addlInfo = NULL;
|
||||
numBPs = 0;
|
||||
cachedValues = DTM_FALSE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DmxMsg::setHandle (DtMailMessageHandle &h)
|
||||
{
|
||||
msgHandle = h;
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DmxMsg::setHeader (DtMailHeaderLine &h)
|
||||
{
|
||||
msgHeader = h;
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DmxMsg::setMessage (DtMail::Message *m)
|
||||
{
|
||||
message = m;
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DmxMsg::setInfo (char *info)
|
||||
{
|
||||
addlInfo = strdup (info);
|
||||
return;
|
||||
}
|
||||
|
||||
char *
|
||||
DmxMsg::getMessageHeader (DmxHeaders which)
|
||||
{
|
||||
int i = 0, length = 0;
|
||||
int buflength = 0;
|
||||
char *rtn;
|
||||
const char *str;
|
||||
|
||||
if (which >= DMXNUMHDRS)
|
||||
return (char *) NULL;
|
||||
|
||||
length = msgHeader.header_values[which].length ();
|
||||
if (length == 0)
|
||||
str = errorString(which);
|
||||
else
|
||||
str = *((msgHeader.header_values[which])[0]);
|
||||
|
||||
//need to free this after using it
|
||||
rtn = strdup(str);
|
||||
return (rtn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
char *
|
||||
DmxMsg::getHeaders (DtMailBoolean abbreviated_only)
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session *m_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc *mail_rc = m_session->mailRc(error);
|
||||
DtMail::Envelope *env = message->getEnvelope(error);
|
||||
|
||||
DtMailHeaderHandle hdr_hnd;
|
||||
char *name;
|
||||
DtMailValueSeq value;
|
||||
|
||||
// Code from MsgScrollingList - display_message().
|
||||
// We're trying to reduce heap size by not allocating and
|
||||
// deleting space in every loop iteration. So just have a
|
||||
// fixed size buffer initially.
|
||||
//
|
||||
|
||||
// Initial line size. When not enough, allocate more.
|
||||
int buffer_size = 2048;
|
||||
char *buffer = new char [buffer_size];
|
||||
int count = 0;
|
||||
int hdr_num = 0;
|
||||
char *newline = "\n";
|
||||
char *separator = ": ";
|
||||
int val = 0;
|
||||
|
||||
//
|
||||
// Iterate through each header in the message and add it
|
||||
// to the buffer.
|
||||
//
|
||||
for (hdr_hnd = env->getFirstHeader(error, &name, value), *buffer = '\0';
|
||||
hdr_hnd && !error.isSet();
|
||||
hdr_hnd = env->getNextHeader(error, hdr_hnd, &name, value), hdr_num++)
|
||||
{
|
||||
if (abbreviated_only == DTM_TRUE &&
|
||||
(hdr_num != 0 || strcmp(name, "From") != 0))
|
||||
{
|
||||
DtMailEnv ierror;
|
||||
if (mail_rc->ignore(ierror, name))
|
||||
{
|
||||
free(name);
|
||||
value.clear();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (val=0; val<value.length(); val++)
|
||||
count += strlen(name) +
|
||||
strlen(*(value[val])) +
|
||||
strlen(separator) +
|
||||
strlen(newline) + 1;
|
||||
|
||||
if (count > buffer_size)
|
||||
{
|
||||
// Need to increase buffer size.
|
||||
char *new_buffer;
|
||||
|
||||
buffer_size *= 2;
|
||||
new_buffer = new char [buffer_size];
|
||||
memset(new_buffer, 0, buffer_size);
|
||||
|
||||
strcpy(new_buffer, buffer);
|
||||
delete [] buffer;
|
||||
buffer = new_buffer;
|
||||
}
|
||||
|
||||
for (val=0; val<value.length(); val++)
|
||||
{
|
||||
strcat(buffer, name);
|
||||
|
||||
if (hdr_num != 0 || strcmp(name, "From") != 0)
|
||||
strcat(buffer, separator);
|
||||
else
|
||||
strcat(buffer, " ");
|
||||
|
||||
strcat(buffer, *(value[val]));
|
||||
strcat(buffer, newline);
|
||||
}
|
||||
value.clear();
|
||||
free(name);
|
||||
}
|
||||
|
||||
//
|
||||
// Need to free this after using;
|
||||
//
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
char *
|
||||
DmxMsg::getPrintedHeaders (DmxPrintHeadersEnum header_format)
|
||||
{
|
||||
char *newline = "\n";
|
||||
char *buffer = NULL;
|
||||
|
||||
switch (header_format)
|
||||
{
|
||||
case DMX_PRINT_HEADERS_NONE:
|
||||
buffer = new char [strlen(newline) + 1];
|
||||
strcpy(buffer, (const char *) newline);
|
||||
break;
|
||||
case DMX_PRINT_HEADERS_STANDARD:
|
||||
buffer = getStandardHeaders(msgHeader);
|
||||
break;
|
||||
case DMX_PRINT_HEADERS_ABBREV:
|
||||
buffer = getHeaders(DTM_TRUE);
|
||||
break;
|
||||
case DMX_PRINT_HEADERS_ALL:
|
||||
buffer = getHeaders(DTM_FALSE);
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr, "error in DmxMsg::display\n");
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Need to free this after using;
|
||||
//
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxMsg::display (
|
||||
DmxPrintHeadersEnum header_format,
|
||||
DmxPrintOutputProc print_proc,
|
||||
XtPointer stream)
|
||||
{
|
||||
DtMailEnv env;
|
||||
DtMailBoolean FirstIsText = DTM_FALSE;
|
||||
DtMail::BodyPart *firstPart = NULL, *nextpart = NULL;
|
||||
char *buf = NULL,
|
||||
*description = NULL,
|
||||
*name = NULL,
|
||||
*newline = NULL,
|
||||
*sunDataDescription = NULL,
|
||||
*type = NULL;
|
||||
|
||||
void *contents = NULL;
|
||||
unsigned long length = 0;
|
||||
int mode = 0;
|
||||
|
||||
// For CHARSET
|
||||
char v3_cs[64],
|
||||
*mime_cs = NULL,
|
||||
*from_cs = NULL,
|
||||
*to_cs = NULL;
|
||||
|
||||
|
||||
// read in body part info
|
||||
if (cachedValues != DTM_TRUE)
|
||||
parse ();
|
||||
|
||||
firstPart = bodyParts [0];
|
||||
|
||||
firstPart->getContents(env,
|
||||
(const void **) &contents,
|
||||
&length,
|
||||
NULL, //type
|
||||
NULL, //name
|
||||
NULL, //mode
|
||||
NULL); //description
|
||||
|
||||
if (handleError(env, "getContents") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
// For CHARSET
|
||||
DtMailValueSeq value;
|
||||
DtMailBoolean err = DTM_FALSE;
|
||||
|
||||
// Get the bodypart's charset - Try MIME first then V3
|
||||
firstPart->getHeader(env, DtMailMessageContentType, DTM_TRUE, value);
|
||||
if (env.isNotSet()) {
|
||||
mime_cs = firstPart->csFromContentType(value);
|
||||
} else {
|
||||
env.clear();
|
||||
value.clear();
|
||||
firstPart->getHeader(env, DtMailMessageV3charset, DTM_TRUE, value);
|
||||
if (env.isNotSet()) {
|
||||
strcpy(v3_cs, *(value[0]));
|
||||
} else {
|
||||
err = DTM_TRUE;
|
||||
env.clear();
|
||||
value.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// If cannot obtain bodypart's charset header, then maybe this message
|
||||
// has only one bodypart, then in this case the charset header maybe
|
||||
// among the message's envelope (main message headers).
|
||||
// Get the envelope of the message (in order to access the headers)
|
||||
DtMail::Envelope *envelope = NULL;
|
||||
if (err == DTM_TRUE) {
|
||||
envelope = message->getEnvelope(env);
|
||||
err = DTM_FALSE;
|
||||
#ifdef DEBUG
|
||||
env.logError(
|
||||
DTM_FALSE,
|
||||
"DEBUG dtmailpr: Looking at main message header\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
// Check for MIME charset header and then for V3 charset header
|
||||
if (envelope != NULL) {
|
||||
envelope->getHeader(env, DtMailMessageContentType, DTM_TRUE, value);
|
||||
if (env.isNotSet()) {
|
||||
mime_cs = firstPart->csFromContentType(value);
|
||||
} else {
|
||||
err = DTM_TRUE;
|
||||
env.clear();
|
||||
}
|
||||
if (mime_cs == NULL || err == DTM_TRUE) {
|
||||
value.clear();
|
||||
envelope->getHeader(env, DtMailMessageV3charset, DTM_TRUE, value);
|
||||
if (env.isNotSet()) {
|
||||
strcpy(v3_cs, *(value[0]));
|
||||
} else {
|
||||
err = DTM_TRUE;
|
||||
env.clear();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
env.logError(DTM_FALSE, "DEBUG dtmailpr: envelope is null\n");
|
||||
#endif
|
||||
env.clear();
|
||||
}
|
||||
|
||||
// Default codeset in case mime_cs and v3_cs are both null.
|
||||
if ((mime_cs == NULL) && (strlen(v3_cs) == 0)) {
|
||||
char *ret = NULL;
|
||||
firstPart->DtXlateOpToStdLocale(DtLCX_OPER_SETLOCALE,
|
||||
setlocale(LC_CTYPE, NULL),
|
||||
NULL,
|
||||
NULL,
|
||||
&ret);
|
||||
strcpy(v3_cs, "DEFAULT");
|
||||
strcat(v3_cs, ".");
|
||||
strcat(v3_cs, ret);
|
||||
if (ret)
|
||||
free(ret);
|
||||
}
|
||||
|
||||
// Get iconv from and to codeset and do conversion.
|
||||
int converted = 0;
|
||||
if (mime_cs) {
|
||||
from_cs = firstPart->csToConvName(mime_cs);
|
||||
#ifdef DEBUG
|
||||
env.logError(DTM_FALSE, "DEBUG dtmailpr: mime_cs = %s\n", mime_cs);
|
||||
#endif
|
||||
} else {
|
||||
from_cs = firstPart->csToConvName(v3_cs);
|
||||
#ifdef DEBUG
|
||||
env.logError(DTM_FALSE, "DEBUG dtmailpr: v3_cs = %s\n", v3_cs);
|
||||
#endif
|
||||
}
|
||||
to_cs = firstPart->locToConvName();
|
||||
|
||||
#ifdef DEBUG
|
||||
if ( from_cs == NULL )
|
||||
env.logError(DTM_FALSE, "DEBUG dtmailpr: from_cs is NULL\n");
|
||||
else
|
||||
env.logError(DTM_FALSE, "DEBUG dtmailpr: from_cs = %s\n", from_cs);
|
||||
|
||||
if ( to_cs == NULL )
|
||||
env.logError(DTM_FALSE, "DEBUG dtmailpr: to_cs is NULL\n");
|
||||
else
|
||||
env.logError(DTM_FALSE, "DEBUG dtmailpr: to_cs = %s\n", to_cs);
|
||||
#endif
|
||||
|
||||
if ( from_cs && to_cs ) {
|
||||
if ( strcasecmp(from_cs, to_cs) != 0 ) {
|
||||
converted = firstPart->csConvert(
|
||||
(char **)&contents,
|
||||
length,
|
||||
0,
|
||||
from_cs,
|
||||
to_cs);
|
||||
#ifdef DEBUG
|
||||
env.logError(DTM_FALSE,
|
||||
"DEBUG dtmailpr: converted = %d\n", converted);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if ( mime_cs )
|
||||
free ( mime_cs );
|
||||
if ( from_cs )
|
||||
free( from_cs );
|
||||
if ( to_cs )
|
||||
free ( to_cs );
|
||||
|
||||
// End of For CHARSET
|
||||
|
||||
newline = new char [2];
|
||||
newline[0] = '\n';
|
||||
newline[1] = '\0';
|
||||
|
||||
//
|
||||
// Print out the message headers.
|
||||
//
|
||||
buf = getPrintedHeaders(header_format);
|
||||
print_proc(stream, buf);
|
||||
print_proc(stream, newline);
|
||||
delete buf;
|
||||
|
||||
//
|
||||
// Print out the message body.
|
||||
//
|
||||
buf = new char [length + 1];
|
||||
memset (buf, 0, (unsigned int) length + 1);
|
||||
memmove (buf, contents, (unsigned int) length);
|
||||
buf [length] = '\0'; // null-terminate that puppy
|
||||
print_proc(stream, buf);
|
||||
print_proc(stream, newline);
|
||||
delete [] buf;
|
||||
|
||||
// For CHARSET
|
||||
if (converted && contents)
|
||||
free(contents);
|
||||
|
||||
// No attachments? We're done.
|
||||
if (numBPs < 2)
|
||||
return;
|
||||
|
||||
int i = 0, attbuflen = 0;
|
||||
char *attbuf = NULL;
|
||||
char *sunbuf = NULL;
|
||||
|
||||
print_proc(stream, newline);
|
||||
for (i = 1; i < numBPs ; i++)
|
||||
{
|
||||
nextpart = bodyParts [i];
|
||||
|
||||
if (nextpart == NULL)
|
||||
fprintf (stderr, "Error getting part!\n");
|
||||
|
||||
length = 0;
|
||||
type = "";
|
||||
sunDataDescription = "";
|
||||
description = "";
|
||||
name = "";
|
||||
mode = -1;
|
||||
|
||||
nextpart->getContents(env,
|
||||
NULL,
|
||||
&length,
|
||||
&type,
|
||||
&name,
|
||||
&mode,
|
||||
&sunDataDescription);
|
||||
if (handleError (env, "getContents") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
if (type == NULL)
|
||||
type = "(type unknown)";
|
||||
|
||||
if (name == NULL)
|
||||
name = "(name unknown)";
|
||||
|
||||
if (sunDataDescription == NULL)
|
||||
{
|
||||
description = "";
|
||||
} else {
|
||||
// should add bracket or something
|
||||
sunbuf = new char [strlen (sunDataDescription) + 10];
|
||||
sprintf(sunbuf, " (%s)", sunDataDescription);
|
||||
description = sunbuf;
|
||||
}
|
||||
|
||||
attbuflen = strlen(name) + strlen(type) + strlen(description);
|
||||
attbuf = new char [attbuflen + 64];
|
||||
sprintf(attbuf,
|
||||
"[%d] \"%s\"%s, %s, %ld bytes",
|
||||
i,
|
||||
name,
|
||||
description,
|
||||
type,
|
||||
length);
|
||||
print_proc(stream, attbuf);
|
||||
print_proc(stream, newline);
|
||||
delete [] attbuf;
|
||||
|
||||
if (sunbuf != NULL)
|
||||
delete [] sunbuf;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
DmxMsg::parse (void)
|
||||
{
|
||||
// store the body parts for later reference
|
||||
|
||||
DtMailEnv env;
|
||||
DtMailBoolean FirstIsText = DTM_FALSE;
|
||||
DtMail::BodyPart *part = NULL, *nextpart = NULL;
|
||||
char *type = NULL, *attr = NULL;
|
||||
|
||||
int bc = message->getBodyCount (env);
|
||||
if (handleError (env, "getBodyCount") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
part = message->getFirstBodyPart (env);
|
||||
if (handleError (env, "getFirstBodyPart") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
part->getContents (env, NULL, NULL, &type, NULL, NULL, NULL);
|
||||
if (handleError (env, "getContents") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
bodyParts = new (DtMail::BodyPart *[bc]);
|
||||
cachedValues = DTM_TRUE;
|
||||
|
||||
// cache values
|
||||
bodyParts [0] = part;
|
||||
numBPs++;
|
||||
|
||||
|
||||
if (type != NULL)
|
||||
{
|
||||
attr = DtDtsDataTypeToAttributeValue (type,
|
||||
DtDTS_DA_IS_TEXT,
|
||||
NULL);
|
||||
if (attr != NULL)
|
||||
{
|
||||
FirstIsText = DTM_TRUE;
|
||||
}
|
||||
//free (type); // it's allocating some data for us
|
||||
} else {
|
||||
FirstIsText = DTM_FALSE;
|
||||
}
|
||||
|
||||
// No attachments? We're done.
|
||||
if (bc < 2)
|
||||
return;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 1; i < bc; i++)
|
||||
{
|
||||
nextpart = NULL;
|
||||
nextpart = message->getNextBodyPart (env,
|
||||
part);
|
||||
if (handleError (env, "getNextBodyPart") == DTM_TRUE)
|
||||
exit (1);
|
||||
|
||||
if (nextpart == NULL)
|
||||
fprintf (stderr, "Error getting part!\n");
|
||||
|
||||
|
||||
bodyParts [i] = nextpart;
|
||||
numBPs++;
|
||||
|
||||
part = nextpart;
|
||||
}
|
||||
}
|
||||
|
||||
1127
cde/programs/dtmail/dtmail/DmxPrintJob.C
Normal file
1127
cde/programs/dtmail/dtmail/DmxPrintJob.C
Normal file
File diff suppressed because it is too large
Load Diff
129
cde/programs/dtmail/dtmail/DmxPrintJob.h
Normal file
129
cde/programs/dtmail/dtmail/DmxPrintJob.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/* $XConsortium: DmxPrintJob.h /main/3 1996/04/12 14:12:32 mgreess $ */
|
||||
|
||||
#ifndef _DMX_PRINT_JOB_H
|
||||
#define _DMX_PRINT_JOB_H
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include "Dmx.h"
|
||||
#include "DmxPrintOptions.h"
|
||||
#include "DmxPrintOutput.h"
|
||||
#include "DmxPrintSetup.h"
|
||||
#include "DtMailTypes.h"
|
||||
#include "MainWindow.h"
|
||||
#include "OptCmd.h"
|
||||
#include "UIComponent.h"
|
||||
|
||||
typedef struct _dmx_msg_info
|
||||
{
|
||||
int end_position;
|
||||
DmxMsg *msg;
|
||||
} DmxMsgInfo;
|
||||
|
||||
class DmxPrintJob : public UIComponent
|
||||
{
|
||||
private:
|
||||
DmxMsg *_next_msg;
|
||||
char *_filename;
|
||||
DmxMailbox *_mailbox;
|
||||
MainWindow *_parent;
|
||||
DmxPrintOutput *_print_output;
|
||||
DmxPrintSetup *_print_setup;
|
||||
DtPrintSetupData *_print_data;
|
||||
Widget _pshell;
|
||||
DtMailBoolean _silent;
|
||||
|
||||
DmxMsgInfo *_spool_msg_info;
|
||||
int _spool_nmsgs_done;
|
||||
int _spool_nmsgs_total;
|
||||
int _spool_npages_done;
|
||||
int _spool_npages_total;
|
||||
|
||||
#ifndef USE_XP_SERVER
|
||||
Widget _nextpage_shell;
|
||||
Widget _nextpage_button;
|
||||
#endif
|
||||
static void cancelCB (Widget, XtPointer, XtPointer);
|
||||
static void closeDisplayCB (Widget, XtPointer, XtPointer);
|
||||
static void pdmNotificationCB (Widget, XtPointer, XtPointer);
|
||||
static void pdmSetupCB (Widget, XtPointer, XtPointer);
|
||||
static void printCB (Widget, XtPointer, XtPointer);
|
||||
static void printOnePageCB (Widget, XtPointer, XtPointer);
|
||||
|
||||
void createPrintShell (void);
|
||||
void createOutputWidgets (void);
|
||||
void doPrint (void);
|
||||
static void finishedPrintToFile(
|
||||
Display*,
|
||||
XPContext,
|
||||
XPGetDocStatus,
|
||||
XPointer);
|
||||
char * getPageHeaderString( DmxMsg*, DmxStringTypeEnum);
|
||||
Boolean loadOutputWidgets (void);
|
||||
void updatePageHeaders(
|
||||
DmxMsg*,
|
||||
DmxStringTypeEnum,
|
||||
DmxStringTypeEnum,
|
||||
DmxStringTypeEnum,
|
||||
DmxStringTypeEnum);
|
||||
public:
|
||||
DmxPrintJob (char*, DtMailBoolean, MainWindow*);
|
||||
~DmxPrintJob (void);
|
||||
|
||||
void cancel (void);
|
||||
void execute (void);
|
||||
};
|
||||
|
||||
#endif // _DMX_PRINT_JOB_H
|
||||
694
cde/programs/dtmail/dtmail/DmxPrintOptions.C
Normal file
694
cde/programs/dtmail/dtmail/DmxPrintOptions.C
Normal file
@@ -0,0 +1,694 @@
|
||||
/* $TOG: DmxPrintOptions.C /main/8 1997/04/30 09:44:12 mgreess $ */
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/DialogS.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/ToggleB.h>
|
||||
#include <Dt/PrintOptionsP.h>
|
||||
|
||||
#include "Dmx.h"
|
||||
#include "DmxPrintOptions.h"
|
||||
#include "DtMail.hh"
|
||||
#include "DtMailError.hh"
|
||||
#include "dtmailopts.h"
|
||||
#include "IndexedOptionMenuUiItem.hh"
|
||||
#include "MailMsg.h"
|
||||
#include "RoamApp.h"
|
||||
#include "TextFieldUiItem.hh"
|
||||
|
||||
#define DMX_ARRAY_SIZE(ary) (sizeof((ary))/sizeof((ary)[0]))
|
||||
|
||||
static DmxpoPropKey hdrftr_keys[] =
|
||||
{
|
||||
{ (int) DTPRINT_OPTION_HEADER_LEFT,
|
||||
DMX_PROPKEY_HEADER_LEFT,
|
||||
DMX_PROPVAL_SUBJECT_HEADER
|
||||
},
|
||||
{ (int) DTPRINT_OPTION_HEADER_RIGHT,
|
||||
DMX_PROPKEY_HEADER_RIGHT,
|
||||
DMX_PROPVAL_EMPTY
|
||||
},
|
||||
{ (int) DTPRINT_OPTION_FOOTER_LEFT,
|
||||
DMX_PROPKEY_FOOTER_LEFT,
|
||||
DMX_PROPVAL_USER_NAME
|
||||
},
|
||||
{ (int) DTPRINT_OPTION_FOOTER_RIGHT,
|
||||
DMX_PROPKEY_FOOTER_RIGHT,
|
||||
DMX_PROPVAL_PAGE_NUMBER
|
||||
}
|
||||
};
|
||||
|
||||
static DmxpoPropKey margin_keys[] =
|
||||
{
|
||||
{ (int) DTPRINT_OPTION_MARGIN_TOP,
|
||||
DMX_PROPKEY_MARGIN_TOP,
|
||||
DMX_PROPVAL_DFLT_MARGIN
|
||||
},
|
||||
{ (int) DTPRINT_OPTION_MARGIN_LEFT,
|
||||
DMX_PROPKEY_MARGIN_LEFT,
|
||||
DMX_PROPVAL_DFLT_MARGIN
|
||||
},
|
||||
{ (int) DTPRINT_OPTION_MARGIN_BOTTOM,
|
||||
DMX_PROPKEY_MARGIN_BOTTOM,
|
||||
DMX_PROPVAL_DFLT_MARGIN
|
||||
},
|
||||
{ (int) DTPRINT_OPTION_MARGIN_RIGHT,
|
||||
DMX_PROPKEY_MARGIN_RIGHT,
|
||||
DMX_PROPVAL_DFLT_MARGIN
|
||||
}
|
||||
};
|
||||
|
||||
static DmxpoPropValue hdrftr_values[] =
|
||||
{
|
||||
{ (int) DMX_NONE_STRING,
|
||||
DMX_PROPVAL_EMPTY,
|
||||
22, 1, "Empty"
|
||||
},
|
||||
{ (int) DMX_CC_HEADER_STRING,
|
||||
DMX_PROPVAL_CC_HEADER,
|
||||
22, 2, "CC Header"
|
||||
},
|
||||
{ (int) DMX_DATE_HEADER_STRING,
|
||||
DMX_PROPVAL_DATE_HEADER,
|
||||
22, 3, "Date Header"
|
||||
},
|
||||
{ (int) DMX_FROM_HEADER_STRING,
|
||||
DMX_PROPVAL_FROM_HEADER,
|
||||
22, 4, "From Header"
|
||||
},
|
||||
{ (int) DMX_SUBJECT_HEADER_STRING,
|
||||
DMX_PROPVAL_SUBJECT_HEADER,
|
||||
22, 5, "Subject Header"
|
||||
},
|
||||
{ (int) DMX_TO_HEADER_STRING,
|
||||
DMX_PROPVAL_TO_HEADER,
|
||||
22, 6, "To Header"
|
||||
},
|
||||
{ (int) DMX_PAGE_NUMBER_STRING,
|
||||
DMX_PROPVAL_PAGE_NUMBER,
|
||||
22, 7, "Page Number"
|
||||
},
|
||||
{ (int) DMX_USER_NAME_STRING,
|
||||
DMX_PROPVAL_USER_NAME,
|
||||
22, 8, "User Name"
|
||||
}
|
||||
};
|
||||
|
||||
static DmxpoPropValue prthdr_values[] =
|
||||
{
|
||||
{ (int) DMX_PRINT_HEADERS_NONE,
|
||||
DMX_PROPVAL_NONE,
|
||||
23, 1, "None" },
|
||||
{ (int) DMX_PRINT_HEADERS_STANDARD,
|
||||
DMX_PROPVAL_STANDARD,
|
||||
23, 2, "Standard" },
|
||||
{ (int) DMX_PRINT_HEADERS_ABBREV,
|
||||
DMX_PROPVAL_ABBREVIATED,
|
||||
23, 3, "Abbreviated" },
|
||||
{ (int) DMX_PRINT_HEADERS_ALL,
|
||||
DMX_PROPVAL_ALL,
|
||||
23, 4, "All" }
|
||||
};
|
||||
|
||||
static DmxpoPropValue msgsep_values[] =
|
||||
{
|
||||
{ (int) DMX_SEPARATOR_NEW_LINE,
|
||||
DMX_PROPVAL_NEW_LINE,
|
||||
24, 1, "New Line" },
|
||||
{ (int) DMX_SEPARATOR_BLANK_LINE,
|
||||
DMX_PROPVAL_BLANK_LINE,
|
||||
24, 2, "Blank Line" },
|
||||
{ (int) DMX_SEPARATOR_CHARACTER_LINE,
|
||||
DMX_PROPVAL_CHARACTER_LINE,
|
||||
24, 3, "Character Line" },
|
||||
{ (int) DMX_SEPARATOR_PAGE_BREAK,
|
||||
DMX_PROPVAL_PAGE_BREAK,
|
||||
24, 4, "New Page" }
|
||||
};
|
||||
|
||||
|
||||
|
||||
DmxPrintOptions::DmxPrintOptions (
|
||||
Widget parent
|
||||
) : UIComponent( "PrintOptions" )
|
||||
{
|
||||
IndexedOptionMenu *iom = (IndexedOptionMenu *) NULL;
|
||||
PropUiItem *pui = (PropUiItem *) NULL;
|
||||
Widget *menu_buttons, w;
|
||||
int nitems;
|
||||
char **strings;
|
||||
void **data;
|
||||
XmString xms;
|
||||
|
||||
_iom_array = new DtVirtArray<IndexedOptionMenu *>(10);
|
||||
_propui_array = new DtVirtArray<PropUiItem *>(10);
|
||||
_propui_array_iterator = 0;
|
||||
_parent = parent;
|
||||
|
||||
//
|
||||
// Create form to hold the printing options
|
||||
//
|
||||
_form = XtVaCreateWidget(
|
||||
"PrintingOptionsPane",
|
||||
xmFormWidgetClass,
|
||||
_parent,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNresizePolicy, XmRESIZE_ANY,
|
||||
NULL
|
||||
);
|
||||
if (_form == (Widget) NULL) return;
|
||||
_w = _form;
|
||||
installDestroyHandler();
|
||||
|
||||
//
|
||||
// Create GUI for the Header/Footer options
|
||||
//
|
||||
nitems = DMX_ARRAY_SIZE(hdrftr_values);;
|
||||
strings = (char **) XtMalloc( nitems * sizeof(char*) );
|
||||
data = (void **) XtMalloc( nitems * sizeof(void*) );
|
||||
for (int i=0; i<nitems; i++)
|
||||
{
|
||||
data[i] = (void*) hdrftr_values[i].prop_string;
|
||||
strings[i] = GETMSG(
|
||||
DT_catd,
|
||||
hdrftr_values[i].set_id,
|
||||
hdrftr_values[i].msg_id,
|
||||
hdrftr_values[i].dflt_string
|
||||
);
|
||||
}
|
||||
|
||||
_hdrftr_frame = _DtPrintCreateHdrFtrFrame( _form, nitems, strings, data);
|
||||
XtVaSetValues(
|
||||
_hdrftr_frame,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
NULL
|
||||
);
|
||||
XtManageChild(_hdrftr_frame);
|
||||
|
||||
//
|
||||
// Create PropUiItem's for the Header/Footer options
|
||||
//
|
||||
menu_buttons = NULL;
|
||||
_DtPrintHdrFtrFrameMenuWidgets( _hdrftr_frame, NULL, NULL, &menu_buttons);
|
||||
for (int j=0, nhdrftrs=DMX_ARRAY_SIZE(hdrftr_keys); j<nhdrftrs; j++)
|
||||
{
|
||||
w = _DtPrintHdrFtrFrameEnumToWidget(
|
||||
_hdrftr_frame,
|
||||
(_DtPrintHdrFtrEnum) hdrftr_keys[j].which
|
||||
);
|
||||
iom =
|
||||
new IndexedOptionMenu(w, nitems, (char**)strings, data, menu_buttons);
|
||||
iom->manage();
|
||||
_iom_array->append(iom);
|
||||
|
||||
pui = (PropUiItem *) new IndexedOptionMenuUiItem(
|
||||
iom,
|
||||
_FROM_MAILRC,
|
||||
hdrftr_keys[j].key
|
||||
);
|
||||
_propui_array->append(pui);
|
||||
}
|
||||
XtFree((char*) menu_buttons);
|
||||
XtFree((char*) data);
|
||||
XtFree((char*) strings);
|
||||
|
||||
|
||||
//
|
||||
// Create GUI for the Margin options
|
||||
//
|
||||
_margin_frame = _DtPrintCreateMarginFrame(_form);
|
||||
XtVaSetValues(
|
||||
_margin_frame,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, _hdrftr_frame,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
NULL
|
||||
);
|
||||
XtManageChild(_margin_frame);
|
||||
|
||||
//
|
||||
// Create PropUiItem's for the Margin options
|
||||
//
|
||||
nitems = DMX_ARRAY_SIZE(margin_keys);
|
||||
for (j=0; j<nitems; j++)
|
||||
{
|
||||
w = _DtPrintMarginFrameEnumToWidget(
|
||||
_margin_frame,
|
||||
(_DtPrintMarginEnum) margin_keys[j].which
|
||||
);
|
||||
pui = (PropUiItem *) new TextFieldUiItem(
|
||||
w,
|
||||
_FROM_MAILRC,
|
||||
margin_keys[j].key,
|
||||
DmxPrintOptions::isValidMarginSpec,
|
||||
(void*) margin_keys[j].which);
|
||||
_propui_array->append(pui);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Create GUI for the Printed Headers option
|
||||
//
|
||||
nitems = DMX_ARRAY_SIZE(prthdr_values);;
|
||||
strings = (char **) XtMalloc( nitems * sizeof(char*) );
|
||||
data = (void **) XtMalloc( nitems * sizeof(void*) );
|
||||
for (i=0; i<nitems; i++)
|
||||
{
|
||||
data[i] = (void*) prthdr_values[i].prop_string;
|
||||
strings[i] = GETMSG(
|
||||
DT_catd,
|
||||
prthdr_values[i].set_id,
|
||||
prthdr_values[i].msg_id,
|
||||
prthdr_values[i].dflt_string
|
||||
);
|
||||
}
|
||||
|
||||
iom = new IndexedOptionMenu(_form, nitems, (char**) strings, data);
|
||||
xms = XmStringCreateLocalized(
|
||||
GETMSG(DT_catd, 25, 1, "Printed Message Headers: ")
|
||||
);
|
||||
XtVaSetValues(
|
||||
iom->baseWidget(),
|
||||
XmNlabelString, xms,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, _margin_frame,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
NULL
|
||||
);
|
||||
iom->manage();
|
||||
_prthdr_iom = iom;
|
||||
_iom_array->append(iom);
|
||||
|
||||
XmStringFree(xms);
|
||||
XtFree((char*) strings);
|
||||
XtFree((char*) data);
|
||||
|
||||
//
|
||||
// Create PropUiItem for the Printed Headers option
|
||||
//
|
||||
pui = (PropUiItem *) new IndexedOptionMenuUiItem(
|
||||
iom,
|
||||
_FROM_MAILRC,
|
||||
DMX_PROPKEY_PRINT_HEADERS
|
||||
);
|
||||
_propui_array->append(pui);
|
||||
|
||||
|
||||
//
|
||||
// Create GUI for the Message Separator option
|
||||
//
|
||||
nitems = DMX_ARRAY_SIZE(msgsep_values);;
|
||||
strings = (char **) XtMalloc( nitems * sizeof(char*) );
|
||||
data = (void **) XtMalloc( nitems * sizeof(void*) );
|
||||
for (i=0; i<nitems; i++)
|
||||
{
|
||||
data[i] = (void*) msgsep_values[i].prop_string;
|
||||
strings[i] = GETMSG(
|
||||
DT_catd,
|
||||
msgsep_values[i].set_id,
|
||||
msgsep_values[i].msg_id,
|
||||
msgsep_values[i].dflt_string
|
||||
);
|
||||
}
|
||||
|
||||
iom = new IndexedOptionMenu(_form, nitems, (char**) strings, data);
|
||||
xms = XmStringCreateLocalized(
|
||||
GETMSG( DT_catd, 25, 2, "Separate Multiple Messages With: ")
|
||||
);
|
||||
XtVaSetValues(
|
||||
iom->baseWidget(),
|
||||
XmNlabelString, xms,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, _prthdr_iom->baseWidget(),
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL
|
||||
);
|
||||
iom->manage();
|
||||
_iom_array->append(iom);
|
||||
_msgsep_iom = iom;
|
||||
|
||||
XmStringFree(xms);
|
||||
XtFree((char*) strings);
|
||||
XtFree((char*) data);
|
||||
|
||||
//
|
||||
// Create PropUiItem for the Message Separator option
|
||||
//
|
||||
pui = (PropUiItem *) new IndexedOptionMenuUiItem(
|
||||
iom,
|
||||
_FROM_MAILRC,
|
||||
DMX_PROPKEY_MESSAGE_SEPARATOR);
|
||||
_propui_array->append(pui);
|
||||
|
||||
//XtRealizeWidget(_w);
|
||||
//XtManageChild(_w);
|
||||
}
|
||||
|
||||
|
||||
DmxPrintOptions::~DmxPrintOptions (void)
|
||||
{
|
||||
int i;
|
||||
PropUiItem *pui;;
|
||||
IndexedOptionMenu *iom;
|
||||
|
||||
if (_propui_array)
|
||||
for (i=0; i<_propui_array->length(); i++)
|
||||
{
|
||||
pui = (*_propui_array)[i];
|
||||
delete pui;
|
||||
}
|
||||
|
||||
if (_iom_array)
|
||||
for (i=0; i<_iom_array->length(); i++)
|
||||
{
|
||||
iom = (*_iom_array)[i];
|
||||
delete iom;
|
||||
}
|
||||
|
||||
if (_w)
|
||||
XtDestroyWidget(_w);
|
||||
}
|
||||
|
||||
PropUiItem *
|
||||
DmxPrintOptions::getFirstProp(void)
|
||||
{
|
||||
_propui_array_iterator = 0;
|
||||
return getNextProp();
|
||||
}
|
||||
|
||||
PropUiItem *
|
||||
DmxPrintOptions::getNextProp(void)
|
||||
{
|
||||
PropUiItem *pui = (PropUiItem *) NULL;
|
||||
|
||||
if (_propui_array_iterator < _propui_array->length())
|
||||
{
|
||||
pui = (*_propui_array)[_propui_array_iterator];
|
||||
_propui_array_iterator++;
|
||||
}
|
||||
return pui;
|
||||
}
|
||||
|
||||
int
|
||||
DmxPrintOptions::getNumProps(void)
|
||||
{
|
||||
return _propui_array->length();
|
||||
}
|
||||
|
||||
const char *
|
||||
DmxPrintOptions::getSeparatorString(void)
|
||||
{
|
||||
DtMail::Session *d_session = NULL;
|
||||
DtMail::MailRc *m_rc = NULL;
|
||||
DtMailEnv error;
|
||||
const char *string = NULL;
|
||||
char *dflt = "-";
|
||||
|
||||
d_session = theRoamApp.session()->session();
|
||||
m_rc = d_session->mailRc(error);
|
||||
|
||||
m_rc->getValue(error, DMX_PROPKEY_SEPARATOR_STRING, &string);
|
||||
if (string == NULL || error.isSet())
|
||||
return strdup(dflt);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
DmxStringTypeEnum
|
||||
DmxPrintOptions::getHdrFtrSpec(_DtPrintHdrFtrEnum which)
|
||||
{
|
||||
DtMail::Session *d_session = NULL;
|
||||
DtMail::MailRc *m_rc = NULL;
|
||||
DtMailEnv error;
|
||||
DmxpoPropKey *key;
|
||||
const char *string = NULL;
|
||||
DmxpoPropValue *value = NULL;
|
||||
DmxStringTypeEnum rtn = DMX_NONE_STRING;
|
||||
|
||||
d_session = theRoamApp.session()->session();
|
||||
m_rc = d_session->mailRc(error);
|
||||
|
||||
key = DmxPrintOptions::enumToPropKey(
|
||||
which,
|
||||
DMX_ARRAY_SIZE(hdrftr_keys),
|
||||
hdrftr_keys
|
||||
);
|
||||
|
||||
if (key != NULL)
|
||||
{
|
||||
m_rc->getValue(error, key->key , &string);
|
||||
if (string == NULL || error.isSet())
|
||||
string = strdup(key->dflt_prop_string);
|
||||
}
|
||||
else
|
||||
return rtn;
|
||||
|
||||
value = stringToPropValue(
|
||||
string,
|
||||
DMX_ARRAY_SIZE(hdrftr_values),
|
||||
hdrftr_values);
|
||||
if (value != NULL)
|
||||
rtn = (DmxStringTypeEnum) value->which;
|
||||
|
||||
if (NULL != string)
|
||||
free((void*) string);
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
const char *
|
||||
DmxPrintOptions::getMarginSpec(_DtPrintMarginEnum which)
|
||||
{
|
||||
DtMail::Session *d_session = NULL;
|
||||
DtMail::MailRc *m_rc = NULL;
|
||||
DtMailEnv error;
|
||||
DmxpoPropKey *key;
|
||||
const char *string = NULL;
|
||||
|
||||
d_session = theRoamApp.session()->session();
|
||||
m_rc = d_session->mailRc(error);
|
||||
|
||||
key = DmxPrintOptions::enumToPropKey(
|
||||
which,
|
||||
DMX_ARRAY_SIZE(margin_keys),
|
||||
margin_keys
|
||||
);
|
||||
|
||||
if (key == NULL)
|
||||
return DMX_PROPVAL_DFLT_MARGIN;
|
||||
|
||||
m_rc->getValue(error, key->key , &string);
|
||||
if (string == NULL || error.isSet())
|
||||
string = strdup(key->dflt_prop_string);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
DmxMsgSeparatorEnum
|
||||
DmxPrintOptions::getMessageSeparator(void)
|
||||
{
|
||||
DtMail::Session *d_session = NULL;
|
||||
DtMail::MailRc *m_rc = NULL;
|
||||
DtMailEnv error;
|
||||
const char *string = NULL;
|
||||
DmxpoPropValue *value = NULL;
|
||||
DmxMsgSeparatorEnum rtn = DMX_SEPARATOR_PAGE_BREAK;
|
||||
|
||||
d_session = theRoamApp.session()->session();
|
||||
m_rc = d_session->mailRc(error);
|
||||
|
||||
m_rc->getValue(error, DMX_PROPKEY_MESSAGE_SEPARATOR , &string);
|
||||
if (string == NULL || error.isSet())
|
||||
return rtn;
|
||||
|
||||
value = stringToPropValue(
|
||||
string,
|
||||
DMX_ARRAY_SIZE(msgsep_values),
|
||||
msgsep_values);
|
||||
if (value != NULL)
|
||||
rtn = (DmxMsgSeparatorEnum) value->which;
|
||||
|
||||
if (NULL != string)
|
||||
free((void*) string);
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
DmxPrintHeadersEnum
|
||||
DmxPrintOptions::getPrintedHeaders(void)
|
||||
{
|
||||
DtMail::Session *d_session = NULL;
|
||||
DtMail::MailRc *m_rc = NULL;
|
||||
DtMailEnv error;
|
||||
const char *string = NULL;
|
||||
DmxpoPropValue *value = NULL;
|
||||
DmxPrintHeadersEnum rtn = DMX_PRINT_HEADERS_STANDARD;
|
||||
|
||||
d_session = theRoamApp.session()->session();
|
||||
m_rc = d_session->mailRc(error);
|
||||
|
||||
m_rc->getValue(error, DMX_PROPKEY_PRINT_HEADERS , &string);
|
||||
if (string == NULL || error.isSet())
|
||||
return rtn;
|
||||
|
||||
value = stringToPropValue(
|
||||
string,
|
||||
DMX_ARRAY_SIZE(prthdr_values),
|
||||
prthdr_values);
|
||||
if (value != NULL)
|
||||
rtn = (DmxPrintHeadersEnum) value->which;
|
||||
|
||||
if (NULL != string)
|
||||
free((void*) string);
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
DmxpoPropKey *
|
||||
DmxPrintOptions::enumToPropKey(int which, int nkeys, DmxpoPropKey *keys)
|
||||
{
|
||||
for (int i=0; i<nkeys; i++)
|
||||
if (keys[i].which == which)
|
||||
return &(keys[i]);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PropUiItem *
|
||||
DmxPrintOptions::propKeyToPropItem(char *key)
|
||||
{
|
||||
for (int i=0; i<_propui_array->length(); i++)
|
||||
{
|
||||
PropUiItem *pui;
|
||||
char *puikey;
|
||||
|
||||
pui = (*_propui_array)[i];
|
||||
puikey = pui->getKey();
|
||||
if (strcmp(puikey, key) == 0)
|
||||
return pui;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DmxpoPropValue *
|
||||
DmxPrintOptions::stringToPropValue(
|
||||
const char *string,
|
||||
int nvalues,
|
||||
DmxpoPropValue *values
|
||||
)
|
||||
{
|
||||
for (int i=0; i<nvalues; i++)
|
||||
if (strcmp(values[i].prop_string, string) == 0)
|
||||
return &(values[i]);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
DmxPrintOptions::isValidMarginSpec(PropUiItem* pui, void* data)
|
||||
{
|
||||
char *i18nMsg;
|
||||
char *errMsg = NULL;
|
||||
char *marginSpec = NULL;
|
||||
XtEnum parseError;
|
||||
Widget text;
|
||||
_DtPrintMarginEnum which = (_DtPrintMarginEnum) data;
|
||||
|
||||
text = pui->getWidget();
|
||||
if (text)
|
||||
marginSpec = _DtPrintGetMarginSpec(text);
|
||||
|
||||
parseError = FALSE;
|
||||
if (marginSpec == NULL || strcmp("", marginSpec) == 0)
|
||||
parseError = TRUE;
|
||||
else
|
||||
(void) XmConvertStringToUnits(
|
||||
XtScreenOfObject(text),
|
||||
marginSpec,
|
||||
XmVERTICAL,
|
||||
XmPIXELS,
|
||||
&parseError);
|
||||
|
||||
if (! parseError) return NULL;
|
||||
|
||||
switch (which)
|
||||
{
|
||||
case DTPRINT_OPTION_MARGIN_TOP:
|
||||
i18nMsg =
|
||||
GETMSG(DT_catd, 26, 1, "Top Margin specifier is invalid: ");
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_RIGHT:
|
||||
i18nMsg =
|
||||
GETMSG(DT_catd, 26, 2, "Right Margin specifier is invalid: ");
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_BOTTOM:
|
||||
i18nMsg =
|
||||
GETMSG(DT_catd, 26, 3, "Bottom Margin specifier is invalid: ");
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_LEFT:
|
||||
i18nMsg =
|
||||
GETMSG(DT_catd, 26, 4, "Left Margin specifier is invalid: ");
|
||||
break;
|
||||
}
|
||||
errMsg = (char*) XtMalloc(strlen(i18nMsg) + strlen(marginSpec) + 1);
|
||||
sprintf(errMsg, "%s%s", i18nMsg, marginSpec);
|
||||
|
||||
return errMsg;
|
||||
}
|
||||
165
cde/programs/dtmail/dtmail/DmxPrintOptions.h
Normal file
165
cde/programs/dtmail/dtmail/DmxPrintOptions.h
Normal file
@@ -0,0 +1,165 @@
|
||||
/* $XConsortium: DmxPrintOptions.h /main/6 1996/09/23 13:15:43 mgreess $ */
|
||||
|
||||
#ifndef _DMX_PRINT_OPTIONS_H
|
||||
#define _DMX_PRINT_OPTIONS_H
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <Dt/PrintOptionsP.h>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include "Dmx.h"
|
||||
#include "IndexedOptionMenu.h"
|
||||
#include "UIComponent.h"
|
||||
|
||||
#define DMX_PROPKEY_HEADER_LEFT "headerleft"
|
||||
#define DMX_PROPKEY_HEADER_RIGHT "headerright"
|
||||
#define DMX_PROPKEY_FOOTER_LEFT "footerleft"
|
||||
#define DMX_PROPKEY_FOOTER_RIGHT "footerright"
|
||||
|
||||
#define DMX_PROPKEY_MARGIN_TOP "margintop"
|
||||
#define DMX_PROPKEY_MARGIN_RIGHT "marginright"
|
||||
#define DMX_PROPKEY_MARGIN_BOTTOM "marginbottom"
|
||||
#define DMX_PROPKEY_MARGIN_LEFT "marginleft"
|
||||
|
||||
#define DMX_PROPKEY_PRINT_HEADERS "printheaders"
|
||||
#define DMX_PROPKEY_MESSAGE_SEPARATOR "messageseparator"
|
||||
#define DMX_PROPKEY_SEPARATOR_STRING "separatorstring"
|
||||
|
||||
#define DMX_PROPVAL_EMPTY "Empty"
|
||||
#define DMX_PROPVAL_CC_HEADER "CCHeader"
|
||||
#define DMX_PROPVAL_DATE_HEADER "DateHeader"
|
||||
#define DMX_PROPVAL_FROM_HEADER "FromHeader"
|
||||
#define DMX_PROPVAL_SUBJECT_HEADER "SubjectHeader"
|
||||
#define DMX_PROPVAL_TO_HEADER "ToHeader"
|
||||
#define DMX_PROPVAL_PAGE_NUMBER "PageNumber"
|
||||
#define DMX_PROPVAL_USER_NAME "UserName"
|
||||
|
||||
#define DMX_PROPVAL_DFLT_MARGIN "1.0 in"
|
||||
|
||||
#define DMX_PROPVAL_NONE "None"
|
||||
#define DMX_PROPVAL_STANDARD "Standard"
|
||||
#define DMX_PROPVAL_ABBREVIATED "Abbreviated"
|
||||
#define DMX_PROPVAL_ALL "All"
|
||||
|
||||
#define DMX_PROPVAL_NEW_LINE "NewLine"
|
||||
#define DMX_PROPVAL_BLANK_LINE "BlankLine"
|
||||
#define DMX_PROPVAL_CHARACTER_LINE "CharacterLine"
|
||||
#define DMX_PROPVAL_PAGE_BREAK "PageBreak"
|
||||
#define DMX_PROPVAL_NEW_JOB "NewJob"
|
||||
|
||||
struct DmxpoPropKey
|
||||
{
|
||||
int which;
|
||||
char *key;
|
||||
char *dflt_prop_string;
|
||||
};
|
||||
|
||||
struct DmxpoPropValue
|
||||
{
|
||||
int which;
|
||||
char *prop_string;
|
||||
int set_id;
|
||||
int msg_id;
|
||||
char *dflt_string;
|
||||
};
|
||||
|
||||
class DmxPrintOptions : public UIComponent
|
||||
{
|
||||
|
||||
private:
|
||||
DtVirtArray<IndexedOptionMenu *>
|
||||
*_iom_array;
|
||||
DtVirtArray<PropUiItem *>
|
||||
*_propui_array;
|
||||
int _propui_array_iterator;
|
||||
|
||||
Widget _parent;
|
||||
Widget _form;
|
||||
|
||||
Widget _hdrftr_frame;
|
||||
Widget _margin_frame;
|
||||
|
||||
IndexedOptionMenu *_msgsep_iom;
|
||||
IndexedOptionMenu *_prthdr_iom;
|
||||
|
||||
PropSource *_prop_source;
|
||||
|
||||
PropUiItem *propKeyToPropItem(char*);
|
||||
static DmxpoPropKey *enumToPropKey(int, int, DmxpoPropKey*);
|
||||
static DmxpoPropValue *stringToPropValue(
|
||||
const char*,
|
||||
int,
|
||||
DmxpoPropValue*);
|
||||
static char *isValidMarginSpec(
|
||||
PropUiItem*,
|
||||
void*);
|
||||
public:
|
||||
|
||||
DmxPrintOptions ( Widget );
|
||||
~DmxPrintOptions (void);
|
||||
|
||||
PropUiItem *getFirstProp(void);
|
||||
PropUiItem *getNextProp(void);
|
||||
int getNumProps(void);
|
||||
|
||||
static DmxStringTypeEnum getHdrFtrSpec(_DtPrintHdrFtrEnum which);
|
||||
static const char *getMarginSpec(_DtPrintMarginEnum which);
|
||||
static DmxMsgSeparatorEnum getMessageSeparator(void);
|
||||
static DmxPrintHeadersEnum getPrintedHeaders(void);
|
||||
static const char *getSeparatorString(void);
|
||||
};
|
||||
|
||||
#endif // _DMX_PRINT_OPTIONS_H
|
||||
763
cde/programs/dtmail/dtmail/DmxPrintOutput.C
Normal file
763
cde/programs/dtmail/dtmail/DmxPrintOutput.C
Normal file
@@ -0,0 +1,763 @@
|
||||
/* $TOG: DmxPrintOutput.C /main/6 1997/07/07 13:57:21 mgreess $ */
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/DialogS.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/Print.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <Dt/Editor.h>
|
||||
|
||||
#include "Dmx.h"
|
||||
#include "DmxPrintOutput.h"
|
||||
#include "RoamMenuWindow.h"
|
||||
|
||||
//
|
||||
// Used to initialize the top, right, bottom, and left margins
|
||||
// between the outside edge of the page (_form) and the inner
|
||||
// page that is written on.
|
||||
//
|
||||
const char *const DmxPrintOutput::_default_margin = ".5in";
|
||||
|
||||
DmxPrintOutput::DmxPrintOutput (
|
||||
Widget pshell
|
||||
) : UIComponent( "PrintOutput" )
|
||||
{
|
||||
Widget w;
|
||||
DtMailBoolean parse_error;
|
||||
|
||||
_w = NULL;
|
||||
_pshell = pshell;
|
||||
|
||||
w = XtVaCreateWidget("Page",
|
||||
xmFormWidgetClass,
|
||||
_pshell,
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL);
|
||||
_form = w;
|
||||
_w = _form;
|
||||
|
||||
w = XtVaCreateWidget("InnerPage",
|
||||
xmFormWidgetClass,
|
||||
_form,
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL);
|
||||
_inner_form = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("HeaderLeft",
|
||||
xmLabelWidgetClass,
|
||||
_inner_form,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
_header_left = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("HeaderRight",
|
||||
xmLabelWidgetClass,
|
||||
_inner_form,
|
||||
XmNalignment, XmALIGNMENT_END,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_WIDGET,
|
||||
XmNleftWidget, _header_left,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
_header_right = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("Editor",
|
||||
#ifdef USE_DTEDITOR
|
||||
dtEditorWidgetClass,
|
||||
#else
|
||||
xmTextWidgetClass,
|
||||
#endif
|
||||
_inner_form,
|
||||
DtNscrollVertical, FALSE,
|
||||
DtNscrollHorizontal, FALSE,
|
||||
DtNshowStatusLine, FALSE,
|
||||
DtNwordWrap, TRUE,
|
||||
XmNeditMode, XmMULTI_LINE_EDIT,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, _header_left,
|
||||
NULL);
|
||||
_editor = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("FooterLeft",
|
||||
xmLabelWidgetClass,
|
||||
_inner_form,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
_footer_left = w;
|
||||
|
||||
w = XtVaCreateManagedWidget("FooterRight",
|
||||
xmLabelWidgetClass,
|
||||
_inner_form,
|
||||
XmNalignment, XmALIGNMENT_END,
|
||||
XmNleftAttachment, XmATTACH_WIDGET,
|
||||
XmNleftWidget, _footer_left,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
_footer_right = w;
|
||||
|
||||
XtVaSetValues(
|
||||
_editor,
|
||||
XmNbottomAttachment, XmATTACH_WIDGET,
|
||||
XmNbottomWidget, _footer_left,
|
||||
NULL);
|
||||
|
||||
installDestroyHandler();
|
||||
XtManageChild(_inner_form);
|
||||
XtManageChild(_form);
|
||||
|
||||
setPageMargins(
|
||||
_default_margin,
|
||||
_default_margin,
|
||||
_default_margin,
|
||||
_default_margin,
|
||||
&parse_error );
|
||||
assert(!parse_error);
|
||||
}
|
||||
|
||||
DmxPrintOutput::~DmxPrintOutput (void)
|
||||
{
|
||||
//
|
||||
// Don't destroy anything here.
|
||||
// The BasicComponent class takes care of destroying
|
||||
// the _form widget.
|
||||
//
|
||||
}
|
||||
|
||||
void DmxPrintOutput::hideFooters (void)
|
||||
{
|
||||
XtUnmanageChild(_footer_left);
|
||||
XtUnmanageChild(_footer_right);
|
||||
XtVaSetValues(_editor, XmNbottomAttachment, XmATTACH_FORM, NULL);
|
||||
}
|
||||
|
||||
void DmxPrintOutput::showFooters (void)
|
||||
{
|
||||
XtManageChild(_footer_left);
|
||||
XtManageChild(_footer_right);
|
||||
XtVaSetValues(
|
||||
_editor,
|
||||
XmNbottomAttachment, XmATTACH_WIDGET,
|
||||
XmNbottomWidget, _footer_left,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void DmxPrintOutput::hideHeaders (void)
|
||||
{
|
||||
XtUnmanageChild(_header_left);
|
||||
XtUnmanageChild(_header_right);
|
||||
XtVaSetValues(_editor, XmNtopAttachment, XmATTACH_FORM, NULL);
|
||||
}
|
||||
|
||||
void DmxPrintOutput::showHeaders (void)
|
||||
{
|
||||
XtManageChild(_header_left);
|
||||
XtManageChild(_header_right);
|
||||
XtVaSetValues(
|
||||
_editor,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, _header_left,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxPrintOutput::setHdrFtrString (_DtPrintHdrFtrEnum which, char *label)
|
||||
{
|
||||
Widget w;
|
||||
XmString xms;
|
||||
|
||||
if (label == (char *) NULL)
|
||||
return;
|
||||
|
||||
switch (which)
|
||||
{
|
||||
case DTPRINT_OPTION_HEADER_LEFT:
|
||||
w = _header_left;
|
||||
break;
|
||||
case DTPRINT_OPTION_HEADER_RIGHT:
|
||||
w = _header_right;
|
||||
break;
|
||||
case DTPRINT_OPTION_FOOTER_LEFT:
|
||||
w = _footer_left;
|
||||
break;
|
||||
case DTPRINT_OPTION_FOOTER_RIGHT:
|
||||
w = _footer_right;
|
||||
break;
|
||||
default:
|
||||
// TBD: Need to log an error.
|
||||
return;
|
||||
}
|
||||
|
||||
xms = XmStringCreateLocalized(label);
|
||||
XtVaSetValues(w, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintOutput::setHdrFtrStrings (
|
||||
char *hdr_left,
|
||||
char *hdr_right,
|
||||
char *ftr_left,
|
||||
char *ftr_right
|
||||
)
|
||||
{
|
||||
XmString xms;
|
||||
|
||||
if (hdr_left)
|
||||
{
|
||||
xms = XmStringCreateLocalized(hdr_left);
|
||||
XtVaSetValues(_header_left, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
|
||||
if (hdr_right)
|
||||
{
|
||||
xms = XmStringCreateLocalized(hdr_right);
|
||||
XtVaSetValues(_header_right, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
|
||||
if (ftr_left)
|
||||
{
|
||||
xms = XmStringCreateLocalized(ftr_left);
|
||||
XtVaSetValues(_footer_left, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
|
||||
if (ftr_right)
|
||||
{
|
||||
xms = XmStringCreateLocalized(ftr_right);
|
||||
XtVaSetValues(_footer_right, XmNlabelString, xms, NULL);
|
||||
XmStringFree(xms);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintOutput::setPageMargin (
|
||||
_DtPrintMarginEnum which,
|
||||
const char *margin,
|
||||
DtMailBoolean *parse_error
|
||||
)
|
||||
{
|
||||
int pixels = 0;
|
||||
XtEnum xt_parse_error = FALSE;
|
||||
char *marginstring = strdup(margin);
|
||||
|
||||
if (parse_error)
|
||||
*parse_error = DTM_FALSE;
|
||||
|
||||
switch (which)
|
||||
{
|
||||
case DTPRINT_OPTION_MARGIN_TOP:
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
marginstring,
|
||||
XmVERTICAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
_margin_top = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_RIGHT:
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
marginstring,
|
||||
XmHORIZONTAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
_margin_right = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_BOTTOM:
|
||||
_margin_bottom = pixels;
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
marginstring,
|
||||
XmVERTICAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
_margin_bottom = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_LEFT:
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
marginstring,
|
||||
XmHORIZONTAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
_margin_left = pixels;
|
||||
break;
|
||||
default:
|
||||
// TBD: Need to log an error.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!xt_parse_error)
|
||||
setInnerPageDimensions(
|
||||
_margin_top,
|
||||
_margin_right,
|
||||
_margin_bottom,
|
||||
_margin_left);
|
||||
else
|
||||
*parse_error = DTM_TRUE;
|
||||
|
||||
free(marginstring);
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintOutput::setPageMargin (_DtPrintMarginEnum which, int margin)
|
||||
{
|
||||
Dimension pixels = (Dimension) margin;
|
||||
|
||||
switch (which)
|
||||
{
|
||||
case DTPRINT_OPTION_MARGIN_TOP:
|
||||
_margin_top = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_RIGHT:
|
||||
_margin_right = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_BOTTOM:
|
||||
_margin_bottom = pixels;
|
||||
break;
|
||||
case DTPRINT_OPTION_MARGIN_LEFT:
|
||||
_margin_left = pixels;
|
||||
break;
|
||||
default:
|
||||
// TBD: Need to log an error.
|
||||
return;
|
||||
}
|
||||
|
||||
setInnerPageDimensions(
|
||||
_margin_top,
|
||||
_margin_right,
|
||||
_margin_bottom,
|
||||
_margin_left);
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintOutput::setPageMargins (
|
||||
const char *top,
|
||||
const char *right,
|
||||
const char *bottom,
|
||||
const char *left,
|
||||
DtMailBoolean *parse_error
|
||||
)
|
||||
{
|
||||
int pixels = 0;
|
||||
XtEnum xt_parse_error = FALSE;
|
||||
char *margin;
|
||||
|
||||
*parse_error = DTM_FALSE;
|
||||
|
||||
margin = strdup(top);
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
margin,
|
||||
XmVERTICAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
free(margin);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
{
|
||||
_margin_top = pixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
*parse_error = DTM_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
margin = strdup(right);
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
margin,
|
||||
XmHORIZONTAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
free(margin);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
{
|
||||
_margin_right = pixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
*parse_error = DTM_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
margin = strdup(bottom);
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
margin,
|
||||
XmVERTICAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
free(margin);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
{
|
||||
_margin_bottom = pixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
*parse_error = DTM_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
margin = strdup(left);
|
||||
pixels = XmConvertStringToUnits(
|
||||
XtScreenOfObject(_pshell),
|
||||
margin,
|
||||
XmHORIZONTAL,
|
||||
XmPIXELS,
|
||||
&xt_parse_error);
|
||||
free(margin);
|
||||
if (!xt_parse_error && pixels > 0)
|
||||
{
|
||||
_margin_left = pixels;
|
||||
}
|
||||
else
|
||||
{
|
||||
*parse_error = DTM_TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
setInnerPageDimensions(
|
||||
_margin_top,
|
||||
_margin_right,
|
||||
_margin_bottom,
|
||||
_margin_left);
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintOutput::setPageMargins (
|
||||
int top,
|
||||
int right,
|
||||
int bottom,
|
||||
int left
|
||||
)
|
||||
{
|
||||
_margin_top = (top > 0) ? (Dimension) top : _margin_top;
|
||||
_margin_right = (right > 0) ? (Dimension) right : _margin_right;
|
||||
_margin_bottom = (bottom > 0) ? (Dimension) bottom : _margin_bottom;
|
||||
_margin_left = (left > 0) ? (Dimension) left : _margin_left;
|
||||
|
||||
setInnerPageDimensions(
|
||||
_margin_top,
|
||||
_margin_right,
|
||||
_margin_bottom,
|
||||
_margin_left);
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintOutput::setWrapToFit (DtMailBoolean onoff)
|
||||
{
|
||||
#ifdef USE_DTEDITOR
|
||||
XtVaSetValues(_editor, DtNwordWrap, onoff, NULL);
|
||||
#else
|
||||
XtVaSetValues(_editor, XmNwordWrap, onoff, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
int DmxPrintOutput::getCharactersPerLine ()
|
||||
{
|
||||
short columns = 0;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
XtVaGetValues(_editor, DtNcolumns, &columns, NULL);
|
||||
#else
|
||||
XtVaGetValues(_editor, XmNcolumns, &columns, NULL);
|
||||
#endif
|
||||
return((int) columns);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int DmxPrintOutput::getNumLines ()
|
||||
{
|
||||
int total = 0;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
#else
|
||||
XtVaGetValues(_editor, XmNtotalLines, &total, NULL);
|
||||
//
|
||||
// Correct for off by one error.
|
||||
//
|
||||
total -= 1;
|
||||
#endif
|
||||
return(total);
|
||||
}
|
||||
|
||||
|
||||
int DmxPrintOutput::getLastPosition ()
|
||||
{
|
||||
XmTextPosition last;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
last = DtEditorGetLastPosition(_editor);
|
||||
#else
|
||||
last = XmTextGetLastPosition(_editor);
|
||||
#endif
|
||||
return((int) last);
|
||||
}
|
||||
|
||||
int DmxPrintOutput::getTopPosition ()
|
||||
{
|
||||
XmTextPosition top;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
XtVaGetValues(_editor, DtNtopCharacter, &top, NULL);
|
||||
#else
|
||||
top = XmTextGetTopCharacter(_editor);
|
||||
#endif
|
||||
return((int) top);
|
||||
}
|
||||
|
||||
DtMailBoolean DmxPrintOutput::pageUp ()
|
||||
{
|
||||
XmTextPosition top_before, top_after;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
return DTM_FALSE;
|
||||
#else
|
||||
top_before = XmTextGetTopCharacter(_editor);
|
||||
XmTextScroll(_editor, -1 * _lines_per_page);
|
||||
top_after = XmTextGetTopCharacter(_editor);
|
||||
|
||||
return (top_before > top_after) ? DTM_TRUE : DTM_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
DtMailBoolean DmxPrintOutput::pageDown ()
|
||||
{
|
||||
XmTextPosition top_before, top_after;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
return DTM_FALSE;
|
||||
#else
|
||||
top_before = XmTextGetTopCharacter(_editor);
|
||||
XmTextScroll(_editor, _lines_per_page);
|
||||
top_after = XmTextGetTopCharacter(_editor);
|
||||
|
||||
return (top_before < top_after) ? DTM_TRUE : DTM_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
void DmxPrintOutput::setTopPosition ( int pos )
|
||||
{
|
||||
XmTextPosition top = (XmTextPosition) pos;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
XtVaSetValues(_editor, DtNtopCharacter, top, NULL);
|
||||
#else
|
||||
XmTextSetTopCharacter(_editor, top);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DmxPrintOutput::appendContents (void* stream, char *contents)
|
||||
{
|
||||
DmxPrintOutput *thisOutput = (DmxPrintOutput *) stream;
|
||||
|
||||
#ifdef USE_DTEDITOR
|
||||
DtEditorContentRec rec;
|
||||
|
||||
rec.type = DtEDITOR_TEXT;
|
||||
rec.value.string = contents;
|
||||
DtEditorInsert(thisOutput->_editor, &rec);
|
||||
#else
|
||||
XmTextPosition pos;
|
||||
|
||||
pos = XmTextGetLastPosition(thisOutput->_editor);
|
||||
XmTextInsert(thisOutput->_editor, pos, contents);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DmxPrintOutput::appendNewLine ()
|
||||
{
|
||||
#ifdef PRINT_TO_VIDEO
|
||||
char *contents = "=========== NewLine ==========\n";
|
||||
#else
|
||||
char *contents = "\n";
|
||||
#endif
|
||||
appendContents((XtPointer) this, contents);
|
||||
}
|
||||
|
||||
void DmxPrintOutput::appendPageBreak ()
|
||||
{
|
||||
char * buf;
|
||||
char *contents = "\n";
|
||||
int nlines, missing;
|
||||
|
||||
nlines = getNumLines();
|
||||
missing = ((nlines % _lines_per_page) > 0) ?
|
||||
(_lines_per_page - (nlines % _lines_per_page)) :
|
||||
0;
|
||||
|
||||
if (! missing)
|
||||
return;
|
||||
|
||||
#ifdef PRINT_TO_VIDEO
|
||||
for (int i=0; i<missing; i++)
|
||||
{
|
||||
char buffer[128];
|
||||
|
||||
sprintf(buffer, "Page Break Line: %d\n", i);
|
||||
appendContents((XtPointer) this, buffer);
|
||||
}
|
||||
fprintf(
|
||||
stdout,
|
||||
"Total Lines: %d; Lines Per Page: %d; Missing Lines: %d\n",
|
||||
nlines,
|
||||
_lines_per_page,
|
||||
missing);
|
||||
#else
|
||||
buf = (char *) malloc((missing * 2) + 1);
|
||||
for (int i=0; i<missing; i++)
|
||||
strcat(buf, contents);
|
||||
|
||||
appendContents(this, contents);
|
||||
|
||||
free(buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DmxPrintOutput::clearContents (void)
|
||||
{
|
||||
#ifdef USE_DTEDITOR
|
||||
DtEditorContentRec content;
|
||||
|
||||
content.type = DtEDITOR_TEXT;
|
||||
rec.value.string = NULL;
|
||||
status = DtEditorSetContents(my_text, &content);
|
||||
#else
|
||||
XmTextSetString(_editor, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Private class methods
|
||||
*/
|
||||
int
|
||||
DmxPrintOutput::doGetLinesPerPage ()
|
||||
{
|
||||
Dimension lpp;
|
||||
|
||||
XtVaGetValues(_editor, XmNrows, &lpp, NULL);
|
||||
return ((int) lpp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxPrintOutput::setInnerPageDimensions (
|
||||
Dimension top,
|
||||
Dimension right,
|
||||
Dimension bottom,
|
||||
Dimension left
|
||||
)
|
||||
{
|
||||
Dimension inner_height, inner_width, inner_x, inner_y,
|
||||
outer_height, outer_width,
|
||||
editor_height, footer_height, header_height;
|
||||
|
||||
XtVaGetValues(_form,
|
||||
XmNheight, &outer_height,
|
||||
XmNwidth, &outer_width,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues(_header_left,
|
||||
XmNheight, &header_height,
|
||||
NULL);
|
||||
|
||||
XtVaGetValues(_footer_left,
|
||||
XmNheight, &footer_height,
|
||||
NULL);
|
||||
|
||||
inner_x = left;
|
||||
inner_y = top;
|
||||
inner_height = ((int) outer_height > (top + bottom)) ?
|
||||
(outer_height - (top + bottom)) :
|
||||
outer_height;
|
||||
inner_width = ((int) outer_width > (left + right)) ?
|
||||
(outer_width - (left + right)) :
|
||||
outer_width;
|
||||
editor_height = ((int) inner_height > (header_height + footer_height)) ?
|
||||
(inner_height - (header_height + footer_height)) :
|
||||
inner_height;
|
||||
|
||||
XtVaSetValues(_editor, XmNheight, editor_height, NULL);
|
||||
|
||||
XtVaSetValues(_inner_form,
|
||||
XmNleftAttachment, XmATTACH_NONE,
|
||||
XmNtopAttachment, XmATTACH_NONE,
|
||||
XmNx, inner_x,
|
||||
XmNy, inner_y,
|
||||
XmNheight, inner_height,
|
||||
XmNwidth, inner_width,
|
||||
NULL);
|
||||
|
||||
_lines_per_page = doGetLinesPerPage();
|
||||
}
|
||||
139
cde/programs/dtmail/dtmail/DmxPrintOutput.h
Normal file
139
cde/programs/dtmail/dtmail/DmxPrintOutput.h
Normal file
@@ -0,0 +1,139 @@
|
||||
/* $TOG: DmxPrintOutput.h /main/3 1997/07/07 13:58:26 mgreess $ */
|
||||
|
||||
#ifndef _DMX_PRINT_OUTPUT_H
|
||||
#define _DMX_PRINT_OUTPUT_H
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <Dt/PrintOptionsP.h>
|
||||
#include "DtMailTypes.h"
|
||||
#include "UIComponent.h"
|
||||
|
||||
class DmxPrintOutput : public UIComponent
|
||||
{
|
||||
public:
|
||||
|
||||
DmxPrintOutput ( Widget );
|
||||
~DmxPrintOutput (void);
|
||||
|
||||
void hideFooters (void);
|
||||
void showFooters (void);
|
||||
void hideHeaders (void);
|
||||
void showHeaders (void);
|
||||
void setHdrFtrString (_DtPrintHdrFtrEnum, char*);
|
||||
void setHdrFtrStrings (char *, char *, char *, char *);
|
||||
|
||||
void setPageMargin (
|
||||
_DtPrintMarginEnum,
|
||||
const char*,
|
||||
DtMailBoolean*
|
||||
);
|
||||
void setPageMargin (_DtPrintMarginEnum, int);
|
||||
void setPageMargins (int, int, int, int);
|
||||
void setPageMargins (
|
||||
const char*,
|
||||
const char*,
|
||||
const char*,
|
||||
const char*,
|
||||
DtMailBoolean*
|
||||
);
|
||||
|
||||
void setWrapToFit (DtMailBoolean);
|
||||
|
||||
int getCharactersPerLine(void);
|
||||
inline int getLinesPerPage(void) { return _lines_per_page; }
|
||||
int getNumLines(void);
|
||||
int getLastPosition(void);
|
||||
int getTopPosition(void);
|
||||
DtMailBoolean pageUp(void);
|
||||
DtMailBoolean pageDown(void);
|
||||
void setTopPosition(int);
|
||||
|
||||
static void appendContents(void*, char*);
|
||||
void appendNewLine();
|
||||
void appendPageBreak();
|
||||
void clearContents(void);
|
||||
|
||||
private:
|
||||
static const char* const
|
||||
_default_margin;
|
||||
|
||||
Widget _pshell;
|
||||
Widget _form;
|
||||
Widget _inner_form;
|
||||
Widget _header_left;
|
||||
Widget _header_right;
|
||||
Widget _editor;
|
||||
Widget _footer_left;
|
||||
Widget _footer_right;
|
||||
|
||||
int _lines_per_page;
|
||||
Dimension _margin_top;
|
||||
Dimension _margin_right;
|
||||
Dimension _margin_bottom;
|
||||
Dimension _margin_left;
|
||||
|
||||
int doGetLinesPerPage();
|
||||
void setInnerPageDimensions(
|
||||
Dimension,
|
||||
Dimension,
|
||||
Dimension,
|
||||
Dimension
|
||||
);
|
||||
};
|
||||
|
||||
#endif // _DMX_PRINT_OUTPUT_H
|
||||
499
cde/programs/dtmail/dtmail/DmxPrintSetup.C
Normal file
499
cde/programs/dtmail/dtmail/DmxPrintSetup.C
Normal file
@@ -0,0 +1,499 @@
|
||||
/* $TOG: DmxPrintSetup.C /main/17 1997/09/03 17:34:59 mgreess $ */
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <Dt/Print.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/ToggleB.h>
|
||||
#include <Xm/ToggleBG.h>
|
||||
|
||||
#include "Dmx.h"
|
||||
#include "DmxPrintOptions.h"
|
||||
#include "DmxPrintSetup.h"
|
||||
#include "DtMailHelp.hh"
|
||||
#include "MailMsg.h"
|
||||
#include "OptCmd.h"
|
||||
#include "RoamApp.h"
|
||||
#include "RoamMenuWindow.h"
|
||||
|
||||
static DtMailBoolean DmxPrintSetup_print_separately = DTM_FALSE;
|
||||
static DtMailBoolean DmxPrintSetup_use_word_wrap = DTM_TRUE;
|
||||
static DtMailBoolean DmxPrintSetup_print_to_file = DTM_FALSE;
|
||||
static char *DmxPrintSetup_printer_name = NULL;
|
||||
#ifdef REUSE_PRINT_SETUP_DIALOGS
|
||||
static Widget DmxPrintSetup_default_dtprint_setup = NULL;
|
||||
#endif
|
||||
|
||||
DmxPrintSetup::DmxPrintSetup (
|
||||
Widget window,
|
||||
XtCallbackProc printCB, XtPointer printClosure,
|
||||
XtCallbackProc cancelCB, XtPointer cancelClosure,
|
||||
XtCallbackProc closeDisplayCB, XtPointer closeDisplayClosure,
|
||||
XtCallbackProc pdmSetupCB, XtPointer pdmSetupClosure)
|
||||
{
|
||||
_parent = window;
|
||||
_dtprint_setup = (Widget) NULL;
|
||||
_widgets = (PrintSetupWidgets *) NULL;
|
||||
_use_word_wrap = DmxPrintSetup_use_word_wrap;
|
||||
_print_separately = DmxPrintSetup_print_separately;
|
||||
_print_to_file = DmxPrintSetup_print_to_file;
|
||||
if (NULL != DmxPrintSetup_printer_name)
|
||||
_printer_name = strdup(DmxPrintSetup_printer_name);
|
||||
else
|
||||
_printer_name = NULL;
|
||||
|
||||
_filename = (char*) malloc(MAXPATHLEN+1);
|
||||
if (NULL != _filename)
|
||||
sprintf(_filename, "%s/dtmail_messages.ps", getenv("HOME"));
|
||||
|
||||
_printCB = printCB;
|
||||
_cancelCB = cancelCB;
|
||||
_closeDisplayCB = closeDisplayCB;
|
||||
_pdmSetupCB = pdmSetupCB;
|
||||
|
||||
_printClosure = printClosure;
|
||||
_cancelClosure = cancelClosure;
|
||||
_closeDisplayClosure = closeDisplayClosure;
|
||||
_pdmSetupClosure = pdmSetupClosure;
|
||||
|
||||
attachPrintSetupDialog();
|
||||
XtRealizeWidget(_dtprint_setup);
|
||||
}
|
||||
|
||||
DmxPrintSetup::~DmxPrintSetup (void)
|
||||
{
|
||||
if (NULL != _printer_name)
|
||||
free(_printer_name);
|
||||
|
||||
if (NULL != _filename)
|
||||
free(_filename);
|
||||
|
||||
detachPrintSetupDialog();
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintSetup::setPrintToFileName (char *filename)
|
||||
{
|
||||
if (NULL != _filename)
|
||||
free(_filename);
|
||||
|
||||
_filename = strdup(filename);
|
||||
|
||||
if (NULL != _filename)
|
||||
XtVaSetValues(_dtprint_setup, DtNfileName, _filename, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintSetup::display (void)
|
||||
{
|
||||
if (_dtprint_setup == NULL) return;
|
||||
|
||||
#ifdef REUSE_PRINT_SETUP_DIALOGS
|
||||
Position x1, y1, x2, y2;
|
||||
Dimension w1, h1, w2, h2;
|
||||
XtVaGetValues(
|
||||
XtParent(_dtprint_setup),
|
||||
XmNx, &x1, XmNy, &y1,
|
||||
XmNwidth, &w1, XmNheight, &h1,
|
||||
NULL);
|
||||
XtVaGetValues(
|
||||
_parent,
|
||||
XmNx, &x2, XmNy, &y2,
|
||||
XmNwidth, &w2, XmNheight, &h2,
|
||||
NULL);
|
||||
XtVaSetValues(
|
||||
XtParent(_dtprint_setup),
|
||||
XmNx, x2 + (w2 - w1) / 2, XmNy, y2 + (h2 - h1) / 2,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
XtManageChild(_dtprint_setup);
|
||||
|
||||
if (NULL != _printer_name)
|
||||
XtVaSetValues(_widgets->printer_name_tf, XmNvalue, _printer_name, NULL);
|
||||
}
|
||||
|
||||
DtMailBoolean
|
||||
DmxPrintSetup::getDefaultPrintData (DtPrintSetupData *print_data)
|
||||
{
|
||||
if (_dtprint_setup == NULL || print_data == NULL) return DTM_FALSE;
|
||||
if (DtPRINT_SUCCESS == DtPrintFillSetupData(_dtprint_setup, print_data))
|
||||
return DTM_TRUE;
|
||||
else
|
||||
return DTM_FALSE;
|
||||
}
|
||||
|
||||
DtMailBoolean
|
||||
DmxPrintSetup::printSeparately (void)
|
||||
{
|
||||
if (DTM_TRUE != _print_to_file)
|
||||
return _print_separately;
|
||||
|
||||
return DTM_FALSE;
|
||||
}
|
||||
|
||||
DtMailBoolean
|
||||
DmxPrintSetup::useWordWrap (void)
|
||||
{
|
||||
return _use_word_wrap;
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintSetup::attachPrintSetupDialog (void)
|
||||
{
|
||||
unsigned char is_set;
|
||||
Widget dialog;
|
||||
|
||||
#ifdef REUSE_PRINT_SETUP_DIALOGS
|
||||
if (DmxPrintSetup_default_dtprint_setup != NULL)
|
||||
{
|
||||
//
|
||||
// Attempt to reuse the last print setup and print display connection.
|
||||
//
|
||||
_dtprint_setup = DmxPrintSetup_default_dtprint_setup;
|
||||
DmxPrintSetup_default_dtprint_setup = NULL;
|
||||
}
|
||||
else
|
||||
_dtprint_setup = createPrintSetupDialog(theRoamApp.baseWidget());
|
||||
#else
|
||||
_dtprint_setup = createPrintSetupDialog(_parent);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Copy the information about the widgets into the setup.
|
||||
//
|
||||
XtVaGetValues(_dtprint_setup, XmNuserData, &_widgets, NULL);
|
||||
|
||||
//
|
||||
// Add the setup-specific callbacks
|
||||
//
|
||||
XtAddCallback(
|
||||
_dtprint_setup,
|
||||
DtNprintCallback,
|
||||
DmxPrintSetup::printCB,
|
||||
(XtPointer) this);
|
||||
XtAddCallback(
|
||||
_dtprint_setup,
|
||||
DtNcancelCallback,
|
||||
_cancelCB,
|
||||
(XtPointer) _cancelClosure);
|
||||
XtAddCallback(
|
||||
_dtprint_setup,
|
||||
DtNclosePrintDisplayCallback,
|
||||
_closeDisplayCB,
|
||||
(XtPointer) _closeDisplayClosure);
|
||||
XtAddCallback(
|
||||
_dtprint_setup,
|
||||
DtNsetupCallback,
|
||||
_pdmSetupCB,
|
||||
(XtPointer) _pdmSetupClosure);
|
||||
|
||||
is_set = (_print_separately) ? XmSET : XmUNSET;
|
||||
XtVaSetValues(_widgets->print_separately_tb, XmNset, is_set, NULL);
|
||||
|
||||
is_set = (_use_word_wrap) ? XmSET : XmUNSET;
|
||||
XtVaSetValues(_widgets->use_word_wrap_tb, XmNset, is_set, NULL);
|
||||
|
||||
if (DTM_TRUE == _print_to_file)
|
||||
XtVaSetValues(
|
||||
_dtprint_setup,
|
||||
DtNprintDestination, DtPRINT_TO_FILE,
|
||||
NULL);
|
||||
else
|
||||
XtVaSetValues(
|
||||
_dtprint_setup,
|
||||
DtNprintDestination, DtPRINT_TO_PRINTER,
|
||||
NULL);
|
||||
|
||||
if (NULL != _printer_name)
|
||||
XtVaSetValues(_dtprint_setup, DtNprinterName, _printer_name, NULL);
|
||||
|
||||
if (NULL != _filename)
|
||||
XtVaSetValues(_dtprint_setup, DtNfileName, _filename, NULL);
|
||||
|
||||
dialog = XtParent(_dtprint_setup);
|
||||
if (NULL != dialog && XtIsShell(dialog))
|
||||
{
|
||||
char *title = (char*) GETMSG(DT_catd, 21, 21, "Mailer - Print Setup");
|
||||
XtVaSetValues(dialog, XmNtitle, title, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Print Setup box is not parented to a shell\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Widget
|
||||
DmxPrintSetup::createPrintSetupDialog (Widget parent)
|
||||
{
|
||||
PrintSetupWidgets *widgets;
|
||||
XmString xms;
|
||||
|
||||
//
|
||||
// Create the app-specific widgets for the Setup Dialog.
|
||||
widgets = (PrintSetupWidgets *) XtMalloc(sizeof(PrintSetupWidgets));
|
||||
|
||||
//
|
||||
// Create the DtPrintSetupDialog and specify that the application
|
||||
// specific area be located below the generic area.
|
||||
// Save the PrintSetupWidgets record as UserData so it can be
|
||||
// retrieved later.
|
||||
//
|
||||
widgets->dtprint_setup =
|
||||
DtCreatePrintSetupDialog(parent, "Setup", NULL, 0);
|
||||
|
||||
XtVaSetValues(
|
||||
widgets->dtprint_setup,
|
||||
DtNworkAreaLocation, DtWORK_AREA_BOTTOM,
|
||||
XmNuserData, widgets,
|
||||
NULL);
|
||||
|
||||
XtAddCallback(
|
||||
widgets->dtprint_setup,
|
||||
XmNhelpCallback,
|
||||
HelpCB,
|
||||
DTMAILPRINTSETUPDIALOG);
|
||||
|
||||
XtAddCallback(
|
||||
widgets->dtprint_setup,
|
||||
XmNdestroyCallback,
|
||||
&DmxPrintSetup::destroyPrintSetupDialogCB,
|
||||
(XtPointer) widgets);
|
||||
|
||||
widgets->form = XtVaCreateWidget(
|
||||
"PrintSetupForm",
|
||||
xmFormWidgetClass,
|
||||
widgets->dtprint_setup,
|
||||
NULL);
|
||||
|
||||
xms = XmStringCreateLocalized(GETMSG(DT_catd, 21, 12, "Print Separately"));
|
||||
widgets->print_separately_tb = XtVaCreateManagedWidget(
|
||||
"PrintSeparatelyTB",
|
||||
xmToggleButtonWidgetClass,
|
||||
widgets->form,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
XmNlabelString, xms,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
XmStringFree(xms);
|
||||
|
||||
xms = XmStringCreateLocalized(GETMSG(DT_catd, 21, 13, "Use Word Wrap"));
|
||||
widgets->use_word_wrap_tb = XtVaCreateManagedWidget(
|
||||
"UseWordWrapTB",
|
||||
xmToggleButtonWidgetClass,
|
||||
widgets->form,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
XmNlabelString, xms,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, widgets->print_separately_tb,
|
||||
NULL);
|
||||
XmStringFree(xms);
|
||||
|
||||
xms = XmStringCreateLocalized(GETMSG(DT_catd, 21, 20, "More ..."));
|
||||
widgets->more_options_pb = XtVaCreateManagedWidget(
|
||||
"PrintOptionsPB",
|
||||
xmPushButtonWidgetClass,
|
||||
widgets->form,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
XmNlabelString, xms,
|
||||
XmNleftAttachment, XmATTACH_NONE,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, widgets->use_word_wrap_tb,
|
||||
NULL);
|
||||
XmStringFree(xms);
|
||||
|
||||
XtAddCallback(
|
||||
widgets->more_options_pb,
|
||||
XmNactivateCallback,
|
||||
&DmxPrintSetup::moreOptionsCB,
|
||||
(XtPointer) NULL);
|
||||
|
||||
widgets->checkbox_tb =
|
||||
XtNameToWidget(widgets->dtprint_setup, "DestRadioBox.button_1");
|
||||
widgets->printer_name_tf = XtNameToWidget(widgets->dtprint_setup, "Name");
|
||||
|
||||
if (NULL != widgets->checkbox_tb)
|
||||
XtAddCallback(
|
||||
widgets->checkbox_tb,
|
||||
XmNvalueChangedCallback,
|
||||
&DmxPrintSetup::destinationChangedCB,
|
||||
(XtPointer) widgets);
|
||||
|
||||
XtManageChild(widgets->form);
|
||||
return(widgets->dtprint_setup);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxPrintSetup::detachPrintSetupDialog (void)
|
||||
{
|
||||
XtRemoveCallback(
|
||||
_dtprint_setup,
|
||||
DtNprintCallback,
|
||||
DmxPrintSetup::printCB,
|
||||
(XtPointer) this);
|
||||
XtRemoveCallback(
|
||||
_dtprint_setup,
|
||||
DtNcancelCallback,
|
||||
_cancelCB,
|
||||
(XtPointer) _cancelClosure);
|
||||
XtRemoveCallback(
|
||||
_dtprint_setup,
|
||||
DtNclosePrintDisplayCallback,
|
||||
_closeDisplayCB,
|
||||
(XtPointer) _closeDisplayClosure);
|
||||
XtRemoveCallback(
|
||||
_dtprint_setup,
|
||||
DtNsetupCallback,
|
||||
_pdmSetupCB,
|
||||
(XtPointer) _pdmSetupClosure);
|
||||
|
||||
//
|
||||
// Leave the Print Setup Dialog for the next print job.
|
||||
//
|
||||
#ifdef REUSE_PRINT_SETUP_DIALOGS
|
||||
if (DmxPrintSetup_default_dtprint_setup != NULL)
|
||||
{
|
||||
XtDestroyWidget(DmxPrintSetup_default_dtprint_setup);
|
||||
DmxPrintSetup_default_dtprint_setup = NULL;
|
||||
}
|
||||
DmxPrintSetup_default_dtprint_setup = _dtprint_setup;
|
||||
#else
|
||||
XtDestroyWidget(_dtprint_setup);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxPrintSetup::savePrintSetupOptions(DtPrintSetupData *print_data)
|
||||
{
|
||||
unsigned char is_set;
|
||||
|
||||
XtVaGetValues(_widgets->print_separately_tb, XmNset, &is_set, NULL);
|
||||
_print_separately = (is_set == XmSET) ? DTM_TRUE : DTM_FALSE;
|
||||
DmxPrintSetup_print_separately = _print_separately;
|
||||
|
||||
XtVaGetValues(_widgets->use_word_wrap_tb, XmNset, &is_set, NULL);
|
||||
_use_word_wrap = (is_set == XmSET) ? DTM_TRUE : DTM_FALSE;
|
||||
DmxPrintSetup_use_word_wrap = _use_word_wrap;
|
||||
|
||||
_print_to_file =
|
||||
(DtPRINT_TO_FILE == print_data->destination) ? DTM_TRUE : DTM_FALSE;
|
||||
DmxPrintSetup_print_to_file = _print_to_file;
|
||||
|
||||
if (NULL != _printer_name)
|
||||
free(_printer_name);
|
||||
_printer_name = strdup(print_data->printer_name);
|
||||
|
||||
if (NULL != DmxPrintSetup_printer_name)
|
||||
free(DmxPrintSetup_printer_name);
|
||||
DmxPrintSetup_printer_name = strdup(_printer_name);
|
||||
|
||||
if (NULL != _filename)
|
||||
free(_filename);
|
||||
_filename = strdup(print_data->dest_info);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxPrintSetup::destinationChangedCB(
|
||||
Widget checkbox_tb,
|
||||
XtPointer client_data,
|
||||
XtPointer)
|
||||
{
|
||||
PrintSetupWidgets *widgets = (PrintSetupWidgets*) client_data;
|
||||
Boolean toggleFlag;
|
||||
|
||||
if (NULL == checkbox_tb) return;
|
||||
|
||||
XtVaGetValues(checkbox_tb, XmNset, &toggleFlag, NULL);
|
||||
if(toggleFlag)
|
||||
XtVaSetValues(
|
||||
widgets->print_separately_tb,
|
||||
XmNsensitive, False,
|
||||
XmNset, False,
|
||||
NULL);
|
||||
else
|
||||
XtVaSetValues(widgets->print_separately_tb, XmNsensitive, True, NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxPrintSetup::destroyPrintSetupDialogCB(Widget, XtPointer widgets, XtPointer)
|
||||
{
|
||||
XtFree((char *) widgets);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DmxPrintSetup::moreOptionsCB(Widget, XtPointer, XtPointer)
|
||||
{
|
||||
OptCmd *optCmd = (OptCmd *) theRoamApp.mailOptions();
|
||||
|
||||
optCmd->displayPrintingOptionsPane();
|
||||
}
|
||||
|
||||
void
|
||||
DmxPrintSetup::printCB(Widget w, XtPointer client_data, XtPointer call_data)
|
||||
{
|
||||
DmxPrintSetup *thisSetup = (DmxPrintSetup*) client_data;
|
||||
DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct*) call_data;
|
||||
|
||||
thisSetup->_printCB(w, thisSetup->_printClosure, call_data);
|
||||
thisSetup->savePrintSetupOptions(pbs->print_data);
|
||||
}
|
||||
135
cde/programs/dtmail/dtmail/DmxPrintSetup.h
Normal file
135
cde/programs/dtmail/dtmail/DmxPrintSetup.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/* $TOG: DmxPrintSetup.h /main/9 1997/08/14 15:53:59 mgreess $ */
|
||||
|
||||
#ifndef _DMX_PRINT_SETUP_H
|
||||
#define _DMX_PRINT_SETUP_H
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <Dt/Print.h>
|
||||
#include "UIComponent.h"
|
||||
|
||||
class DmxPrintSetup
|
||||
{
|
||||
private:
|
||||
typedef struct print_setup_widgets
|
||||
{
|
||||
//
|
||||
// Widgets from the dtmail-specific portion of the PrintSetup Dialog.
|
||||
//
|
||||
Widget dtprint_setup;
|
||||
Widget form;
|
||||
Widget print_separately_tb;
|
||||
Widget use_word_wrap_tb;
|
||||
Widget more_options_pb;
|
||||
|
||||
//
|
||||
// Widgets from the generic portion of the PrintSetup Dialog.
|
||||
//
|
||||
Widget printer_name_tf;
|
||||
Widget checkbox_rc;
|
||||
Widget checkbox_tb;
|
||||
Widget filename_tf;
|
||||
} PrintSetupWidgets;
|
||||
|
||||
Widget _parent;
|
||||
Widget _dtprint_setup;
|
||||
PrintSetupWidgets *_widgets;
|
||||
|
||||
XtCallbackProc _printCB;
|
||||
XtCallbackProc _cancelCB;
|
||||
XtCallbackProc _closeDisplayCB;
|
||||
XtCallbackProc _pdmSetupCB;
|
||||
|
||||
XtPointer _printClosure;
|
||||
XtPointer _cancelClosure;
|
||||
XtPointer _closeDisplayClosure;
|
||||
XtPointer _pdmSetupClosure;
|
||||
|
||||
// Print options specific to this print job.
|
||||
DtMailBoolean _print_separately;
|
||||
DtMailBoolean _use_word_wrap;
|
||||
DtMailBoolean _print_to_file;
|
||||
char *_printer_name;
|
||||
char *_filename;
|
||||
|
||||
void attachPrintSetupDialog(void);
|
||||
Widget createPrintSetupDialog(Widget);
|
||||
void detachPrintSetupDialog(void);
|
||||
void savePrintSetupOptions(DtPrintSetupData*);
|
||||
|
||||
static void destinationChangedCB(Widget, XtPointer, XtPointer);
|
||||
static void destroyPrintSetupDialogCB(Widget, XtPointer, XtPointer);
|
||||
static void moreOptionsCB(Widget, XtPointer, XtPointer);
|
||||
static void printCB(Widget, XtPointer, XtPointer);
|
||||
|
||||
public:
|
||||
DmxPrintSetup (
|
||||
Widget,
|
||||
XtCallbackProc, XtPointer,
|
||||
XtCallbackProc, XtPointer,
|
||||
XtCallbackProc, XtPointer,
|
||||
XtCallbackProc, XtPointer
|
||||
);
|
||||
~DmxPrintSetup (void);
|
||||
|
||||
void setPrintToFileName (char*);
|
||||
void display(void);
|
||||
DtMailBoolean getDefaultPrintData(DtPrintSetupData*);
|
||||
DtMailBoolean printSeparately(void);
|
||||
DtMailBoolean useWordWrap(void);
|
||||
};
|
||||
|
||||
#endif // _DMX_PRINT_SETUP_H
|
||||
342
cde/programs/dtmail/dtmail/DmxUtils.C
Normal file
342
cde/programs/dtmail/dtmail/DmxUtils.C
Normal file
@@ -0,0 +1,342 @@
|
||||
/* $XConsortium: DmxUtils.C /main/3 1996/04/21 19:55:51 drk $ */
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
#include "Dmx.h"
|
||||
|
||||
// fn proto for mailx fn
|
||||
static char * dispname(const char *hdr);
|
||||
|
||||
// error-handling: should do something with minor codes
|
||||
|
||||
DtMailBoolean
|
||||
handleError (DtMailEnv &dterror, char *msg)
|
||||
{
|
||||
if (dterror.isSet () == DTM_TRUE)
|
||||
{
|
||||
fprintf (stderr, "dtmailpr: (%s) %s\n",
|
||||
msg, (const char *)dterror);
|
||||
dterror.logError (DTM_FALSE, "dtmailpr: (%s) %s\n",
|
||||
msg, (const char *)dterror);
|
||||
|
||||
dterror.clear ();
|
||||
return DTM_TRUE;
|
||||
}
|
||||
|
||||
dterror.clear ();
|
||||
return DTM_FALSE;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
errorString (DmxHeaders hdr)
|
||||
{
|
||||
switch (hdr)
|
||||
{
|
||||
case DMXFROM:
|
||||
return "(unknown)";
|
||||
case DMXSUBJ:
|
||||
return "(no subject)";
|
||||
case DMXCLENGTH:
|
||||
return "0";
|
||||
case DMXSTATUS:
|
||||
return " ";
|
||||
case DMXDATE:
|
||||
return "(unknown date)";
|
||||
case DMXTO:
|
||||
return " ";
|
||||
case DMXNUMHDRS:
|
||||
default:
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
getStandardHeaders (DtMailHeaderLine &info)
|
||||
{
|
||||
int i = 0, length = 0;
|
||||
int buflength = 0;
|
||||
char *fbuf;
|
||||
|
||||
const char *header [DMXNUMHDRS];
|
||||
|
||||
for (i = 0; i < DMXNUMHDRS; i++)
|
||||
{
|
||||
length = info.header_values[i].length ();
|
||||
if (length == 0)
|
||||
{
|
||||
header [i] = errorString ((DmxHeaders) i);
|
||||
} else {
|
||||
header [i] = *((info.header_values[i])[0]);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < DMXNUMHDRS; i++)
|
||||
{
|
||||
buflength += strlen (header [i]);
|
||||
}
|
||||
|
||||
fbuf = new char [buflength + 64];
|
||||
|
||||
sprintf(fbuf,
|
||||
"From: %s\nDate: %s\nTo: %s\nSubject: %s\n",
|
||||
dispname (header [DMXFROM]),
|
||||
header [DMXDATE],
|
||||
header [DMXTO],
|
||||
header [DMXSUBJ]);
|
||||
|
||||
return (fbuf); //need to free this after using it
|
||||
}
|
||||
|
||||
// stuff grabbed from mailx...it's ugly, but it looks pretty
|
||||
|
||||
#define NOSTR ((char *) 0) /* Nill string pointer */
|
||||
#define LINESIZE 5120 /* max readable line width */
|
||||
static char *phrase(char *, int , int );
|
||||
|
||||
/*
|
||||
* Return a pointer to a dynamic copy of the argument.
|
||||
*/
|
||||
// changed salloc to malloc
|
||||
char *
|
||||
savestr(char *str)
|
||||
{
|
||||
register char *cp, *cp2, *top;
|
||||
|
||||
for (cp = str; *cp; cp++)
|
||||
;
|
||||
top = (char *)malloc((unsigned)(cp-str + 1));
|
||||
if (top == NOSTR)
|
||||
return(NOSTR);
|
||||
for (cp = str, cp2 = top; *cp; cp++)
|
||||
*cp2++ = *cp;
|
||||
*cp2 = 0;
|
||||
return(top);
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
skin(char *name)
|
||||
{
|
||||
return phrase(name, 0, 0);
|
||||
}
|
||||
/*
|
||||
* Return the full name from an RFC-822 header line
|
||||
* or the last two (or one) component of the address.
|
||||
*/
|
||||
|
||||
static char *
|
||||
dispname(const char *hdr)
|
||||
// made it a const char * instead of a char *
|
||||
{
|
||||
char *cp, *cp2;
|
||||
|
||||
if (hdr == 0)
|
||||
return 0;
|
||||
if (((cp = strchr(hdr, '<')) != 0) && (cp > hdr)) {
|
||||
*cp = 0;
|
||||
if ((*hdr == '"') && ((cp = strrchr(++hdr, '"')) != 0))
|
||||
*cp = 0;
|
||||
return (char *)hdr;
|
||||
} else if ((cp = strchr(hdr, '(')) != 0) {
|
||||
hdr = ++cp;
|
||||
if ((cp = strchr(hdr, '+')) != 0)
|
||||
*cp = 0;
|
||||
if ((cp = strrchr(hdr, ')')) != 0)
|
||||
*cp = 0;
|
||||
return (char *)hdr;
|
||||
}
|
||||
cp = skin((char *)hdr);
|
||||
if ((cp2 = strrchr(cp, '!')) != 0) {
|
||||
while (cp2 >= cp && *--cp2 != '!');
|
||||
cp = ++cp2;
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
|
||||
|
||||
#define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */
|
||||
|
||||
/*
|
||||
* Skin an arpa net address according to the RFC 822 interpretation
|
||||
* of "host-phrase."
|
||||
*/
|
||||
// changed salloc to malloc
|
||||
static char *
|
||||
phrase(char *name, int token, int comma)
|
||||
{
|
||||
register char c;
|
||||
register char *cp, *cp2;
|
||||
char *bufend, *nbufp;
|
||||
int gotlt, lastsp, didq;
|
||||
char nbuf[LINESIZE];
|
||||
int nesting;
|
||||
|
||||
if (name == NOSTR)
|
||||
return(NOSTR);
|
||||
if (strlen(name) >= (unsigned)LINESIZE)
|
||||
nbufp = (char *)malloc(strlen(name));
|
||||
else
|
||||
nbufp = nbuf;
|
||||
gotlt = 0;
|
||||
lastsp = 0;
|
||||
bufend = nbufp;
|
||||
for (cp = name, cp2 = bufend; (c = *cp++) != 0;) {
|
||||
switch (c) {
|
||||
case '(':
|
||||
/*
|
||||
Start of a comment, ignore it.
|
||||
*/
|
||||
nesting = 1;
|
||||
while ((c = *cp) != 0) {
|
||||
cp++;
|
||||
switch(c) {
|
||||
case '\\':
|
||||
if (*cp == 0) goto outcm;
|
||||
cp++;
|
||||
break;
|
||||
case '(':
|
||||
nesting++;
|
||||
break;
|
||||
case ')':
|
||||
--nesting;
|
||||
break;
|
||||
}
|
||||
if (nesting <= 0) break;
|
||||
}
|
||||
outcm:
|
||||
lastsp = 0;
|
||||
break;
|
||||
case '"':
|
||||
/*
|
||||
Start a quoted string.
|
||||
Copy it in its entirety.
|
||||
*/
|
||||
didq = 0;
|
||||
while ((c = *cp) != 0) {
|
||||
cp++;
|
||||
switch (c) {
|
||||
case '\\':
|
||||
if ((c = *cp) == 0) goto outqs;
|
||||
cp++;
|
||||
break;
|
||||
case '"':
|
||||
goto outqs;
|
||||
}
|
||||
if (gotlt == 0 || gotlt == '<') {
|
||||
if (lastsp) {
|
||||
lastsp = 0;
|
||||
*cp2++ = ' ';
|
||||
}
|
||||
if (!didq) {
|
||||
*cp2++ = '"';
|
||||
didq++;
|
||||
}
|
||||
*cp2++ = c;
|
||||
}
|
||||
}
|
||||
outqs:
|
||||
if (didq)
|
||||
*cp2++ = '"';
|
||||
lastsp = 0;
|
||||
break;
|
||||
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\n':
|
||||
if (token && (!comma || c == '\n')) {
|
||||
done:
|
||||
cp[-1] = 0;
|
||||
return cp;
|
||||
}
|
||||
lastsp = 1;
|
||||
break;
|
||||
|
||||
case ',':
|
||||
*cp2++ = c;
|
||||
if (gotlt != '<') {
|
||||
if (token)
|
||||
goto done;
|
||||
bufend = cp2 + 1;
|
||||
gotlt = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case '<':
|
||||
cp2 = bufend;
|
||||
gotlt = c;
|
||||
lastsp = 0;
|
||||
break;
|
||||
|
||||
case '>':
|
||||
if (gotlt == '<') {
|
||||
gotlt = c;
|
||||
break;
|
||||
}
|
||||
|
||||
/* FALLTHROUGH . . . */
|
||||
|
||||
default:
|
||||
if (gotlt == 0 || gotlt == '<') {
|
||||
if (lastsp) {
|
||||
lastsp = 0;
|
||||
*cp2++ = ' ';
|
||||
}
|
||||
*cp2++ = c;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
*cp2 = 0;
|
||||
return (token ? --cp : equal(name, nbufp) ? name :
|
||||
nbufp == nbuf ? savestr(nbuf) : nbufp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
816
cde/programs/dtmail/dtmail/DtEditor.C
Normal file
816
cde/programs/dtmail/dtmail/DtEditor.C
Normal file
@@ -0,0 +1,816 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DtEditor.C /main/11 1998/02/03 10:28:15 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef I_HAVE_NO_IDENT
|
||||
#else
|
||||
#endif
|
||||
|
||||
#ifdef DTEDITOR
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <X11/IntrinsicP.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <Xm/CutPaste.h>
|
||||
|
||||
#include "Help.hh"
|
||||
#include "RoamApp.h"
|
||||
#include "DtEditor.hh"
|
||||
#include "MailMsg.h" // DT_catd defined here
|
||||
|
||||
CDEM_DtWidgetEditor::CDEM_DtWidgetEditor(
|
||||
Widget parent,
|
||||
DtMailEditor *owner_of_editor
|
||||
)
|
||||
{
|
||||
my_parent = parent;
|
||||
my_owner = owner_of_editor;
|
||||
my_text = NULL;
|
||||
my_text_core = NULL;
|
||||
_modified_text = NULL;
|
||||
_modified_text_buflen = 0;
|
||||
|
||||
begin_ins_bracket = NULL;
|
||||
indent_str = NULL;
|
||||
end_ins_bracket = NULL;
|
||||
_auto_show_cursor = FALSE;
|
||||
|
||||
_buffer = NULL;
|
||||
_buf_len = (unsigned long) 0;
|
||||
text_already_selected = FALSE;
|
||||
}
|
||||
|
||||
CDEM_DtWidgetEditor::~CDEM_DtWidgetEditor()
|
||||
{
|
||||
if (my_text) {
|
||||
// No DtEditor API equivalent
|
||||
// Remove the callbacks first.
|
||||
|
||||
XtRemoveCallback(my_text, DtNtextSelectCallback,
|
||||
&CDEM_DtWidgetEditor::text_selected_callback, this);
|
||||
XtRemoveCallback(my_text, DtNtextDeselectCallback,
|
||||
&CDEM_DtWidgetEditor::text_unselected_callback, this);
|
||||
XtRemoveCallback( my_text, XmNhelpCallback, HelpTexteditCB, this ) ;
|
||||
|
||||
XtDestroyWidget(my_text);
|
||||
}
|
||||
if (_buffer) {
|
||||
delete _buffer;
|
||||
_buffer = NULL;
|
||||
}
|
||||
|
||||
if(_modified_text ) {
|
||||
if(_modified_text->ptr) {
|
||||
free(_modified_text->ptr);
|
||||
_modified_text->ptr = NULL;
|
||||
}
|
||||
free(_modified_text);
|
||||
_modified_text = NULL;
|
||||
}
|
||||
if (NULL != indent_str)
|
||||
free((void*) indent_str);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::initialize()
|
||||
{
|
||||
|
||||
int i = 0;
|
||||
|
||||
Arg args[10];
|
||||
int n = 0;
|
||||
|
||||
#if 0
|
||||
short rows, cols;
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mailrc = d_session->mailRc(error);
|
||||
|
||||
const char * value = NULL;
|
||||
mailrc->getValue(error, "popuplines", &value);
|
||||
if (error.isSet()) {
|
||||
value = strdup("24");
|
||||
}
|
||||
rows = strtol(value, NULL, 10);
|
||||
if (NULL != value)
|
||||
free((void*) value);
|
||||
|
||||
// If toolcols is set, overwrite the column width with "toolcols" value.
|
||||
// Otherwise, default resource value will be used.
|
||||
value = NULL;
|
||||
mailrc->getValue(error, "toolcols", &value);
|
||||
if (!error.isSet()){
|
||||
cols = strtol(value, NULL, 10);
|
||||
XtSetArg(args[i], DtNcolumns, cols); i++;
|
||||
if (NULL != value)
|
||||
free((void*) value);
|
||||
} else {
|
||||
/*
|
||||
* Default XmNcolumns
|
||||
* MB_CUR_MAX == 1 : SingleByteLanguage
|
||||
* MB_CUR_MAX > 1 : MultiByteLanguage
|
||||
*/
|
||||
if ( MB_CUR_MAX == 1 )
|
||||
value = "80";
|
||||
else
|
||||
value = "40";
|
||||
|
||||
cols = strtol(value, NULL, 10);
|
||||
XtSetArg(args[i], DtNcolumns, cols); i++;
|
||||
}
|
||||
#endif
|
||||
|
||||
XtSetArg(args[i], DtNeditable, FALSE); i++;
|
||||
XtSetArg(args[i], DtNrows, 24); i++;
|
||||
if ( MB_CUR_MAX == 1 ) {
|
||||
XtSetArg(args[i], DtNcolumns, 80); i++;
|
||||
} else {
|
||||
XtSetArg(args[i], DtNcolumns, 40); i++;
|
||||
}
|
||||
XtSetArg(args[i], DtNcursorPositionVisible, FALSE); i++;
|
||||
|
||||
my_text = DtCreateEditor(my_parent, "Text", args, i);
|
||||
|
||||
update_display_from_props();
|
||||
XtAddCallback(my_text, DtNtextSelectCallback,
|
||||
&CDEM_DtWidgetEditor::text_selected_callback, this);
|
||||
XtAddCallback(my_text, DtNtextDeselectCallback,
|
||||
&CDEM_DtWidgetEditor::text_unselected_callback, this);
|
||||
XtAddCallback( my_text, XmNhelpCallback, HelpTexteditCB, this ) ;
|
||||
|
||||
XtAddEventHandler(my_text, ButtonPressMask,
|
||||
FALSE, MenuButtonHandler,
|
||||
(XtPointer) this);
|
||||
|
||||
XtManageChild(my_text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
CDEM_DtWidgetEditor::get_contents()
|
||||
{
|
||||
|
||||
DtEditorErrorCode status;
|
||||
static DtEditorContentRec content;
|
||||
|
||||
content.type = DtEDITOR_TEXT;
|
||||
|
||||
// Get the contents with hardCarriageReturns = TRUE and
|
||||
// markContentsAsSaved = TRUE.
|
||||
|
||||
/*
|
||||
* If hardCarriageReturns = TRUE, the performace of DtEditorGetContents()
|
||||
* suffers since according to man 3 DtEditorGetContents,
|
||||
*
|
||||
* The hardCarriageReturns argument, if set to True, indicates
|
||||
* that the DtEditor widget should replace any soft line feeds
|
||||
* (word wraps) with <newline>s when saving the data. When
|
||||
* hardCarriageReturns is set to False, any line wrapped
|
||||
* because it reaches the right edge of the window is saved as
|
||||
* one complete line.
|
||||
*
|
||||
* And current default value of DtNwordWrap is TRUE. See dtmail/Dtmail.
|
||||
* My temporary and non-good solution is
|
||||
* - Change default to False.
|
||||
* - If DtNwordWarp == TRUE,
|
||||
* call DtEditorGetContents(my_text, &content, TRUE, TRUE)
|
||||
* if not,
|
||||
* call DtEditorGetContents(my_text, &content, False, TRUE)
|
||||
* This value can be controllable by a resource file or Format menu.
|
||||
*
|
||||
* Goofy ? but...................;-(
|
||||
*/
|
||||
Arg args[1];
|
||||
Boolean ww;
|
||||
|
||||
XtSetArg( args[0], DtNwordWrap, &ww );
|
||||
XtGetValues( my_text, args, 1 );
|
||||
status = DtEditorGetContents(my_text, &content, ww, TRUE);
|
||||
|
||||
return(content.value.string);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_contents(
|
||||
const char *contents,
|
||||
const unsigned long len
|
||||
)
|
||||
{
|
||||
DtEditorContentRec content;
|
||||
DtEditorErrorCode status;
|
||||
|
||||
this->my_owner->needBuf(&_buffer, &_buf_len, len + 1);
|
||||
this->my_owner->stripCRLF(&_buffer, contents, len);
|
||||
|
||||
content.type = DtEDITOR_TEXT;
|
||||
content.value.string = _buffer;
|
||||
status = DtEditorSetContents(my_text, &content);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_contents(
|
||||
const char *path
|
||||
)
|
||||
{
|
||||
DtEditorSetContentsFromFile(my_text, (char *)path);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::clear_contents()
|
||||
{
|
||||
|
||||
// Doesn't work yet. Work around with setting an empty string...
|
||||
// DtEditorReset(my_text);
|
||||
|
||||
DtEditorContentRec content;
|
||||
DtEditorErrorCode status;
|
||||
|
||||
content.type = DtEDITOR_TEXT;
|
||||
content.value.string = NULL;
|
||||
status = DtEditorSetContents(my_text, &content);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::append_to_contents(
|
||||
const char *contents,
|
||||
const unsigned long len
|
||||
)
|
||||
{
|
||||
DtEditorContentRec rec;
|
||||
|
||||
rec.type = DtEDITOR_TEXT;
|
||||
|
||||
if ( contents[len - 1] == 0 ) {
|
||||
rec.value.string = (char *)contents;
|
||||
} else {
|
||||
this->my_owner->needBuf(&_buffer, &_buf_len, len + 1);
|
||||
this->my_owner->stripCRLF(&_buffer, contents, len);
|
||||
rec.value.string = _buffer;
|
||||
}
|
||||
|
||||
DtEditorInsert(my_text, &rec);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::append_to_contents(
|
||||
const char *path
|
||||
)
|
||||
{
|
||||
|
||||
DtEditorAppendFromFile(my_text, (char *)path);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::append_at_cursor(
|
||||
const char *path
|
||||
)
|
||||
{
|
||||
DtEditorInsertFromFile(my_text, (char *) path);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::append_at_cursor(
|
||||
const char *contents,
|
||||
const unsigned long len
|
||||
)
|
||||
{
|
||||
DtEditorContentRec rec;
|
||||
|
||||
rec.type = DtEDITOR_TEXT;
|
||||
|
||||
if ( contents[len - 1] == 0 ) {
|
||||
rec.value.string = (char *)contents;
|
||||
} else {
|
||||
this->my_owner->needBuf(&_buffer, &_buf_len, len + 1);
|
||||
this->my_owner->stripCRLF(&_buffer, contents, len);
|
||||
rec.value.string = _buffer;
|
||||
}
|
||||
//DtEditorAppend(my_text, &rec);
|
||||
// Fix for the defect 179186 05-25-95
|
||||
// The above API will insert "contents" to the end of the buffer
|
||||
// (appending). It should change to DtEditorInsert which insert
|
||||
// string to the current position (the cursor's position)
|
||||
DtEditorInsert(my_text, &rec);
|
||||
}
|
||||
|
||||
Widget
|
||||
CDEM_DtWidgetEditor::get_text_widget()
|
||||
{
|
||||
// We actually need to return the text widget contained
|
||||
// within DtEditor. For now, just return the DtEditor.
|
||||
|
||||
return(my_text);
|
||||
}
|
||||
|
||||
Pixel
|
||||
CDEM_DtWidgetEditor::get_text_foreground()
|
||||
{
|
||||
Pixel fg;
|
||||
|
||||
XtVaGetValues(my_text,
|
||||
DtNtextForeground, &fg,
|
||||
NULL);
|
||||
|
||||
return(fg);
|
||||
}
|
||||
|
||||
|
||||
// DtEditor returns the bg color of the Form widget, not the
|
||||
// text widget that the Form contains.
|
||||
// This explains why the attachment pane color is that of the scroll bar...
|
||||
// DtEditor needs to return the color of its text widget.
|
||||
// OBTW, DtNtextBackground and DtNtextForeground don't work. They
|
||||
// return uninitialized values
|
||||
|
||||
Pixel
|
||||
CDEM_DtWidgetEditor::get_text_background()
|
||||
{
|
||||
Pixel bg;
|
||||
|
||||
XtVaGetValues(my_text,
|
||||
DtNtextBackground, &bg,
|
||||
NULL);
|
||||
|
||||
return(bg);
|
||||
}
|
||||
|
||||
XmFontList
|
||||
CDEM_DtWidgetEditor::get_text_fontList()
|
||||
{
|
||||
XmFontList fl;
|
||||
|
||||
XtVaGetValues(my_text,
|
||||
DtNtextFontList, &fl,
|
||||
NULL);
|
||||
|
||||
return(fl);
|
||||
}
|
||||
|
||||
Dimension
|
||||
CDEM_DtWidgetEditor::get_text_width()
|
||||
{
|
||||
Dimension wid;
|
||||
|
||||
XtVaGetValues(my_text,
|
||||
XmNwidth, &wid,
|
||||
NULL);
|
||||
return (wid);
|
||||
}
|
||||
|
||||
|
||||
Widget
|
||||
CDEM_DtWidgetEditor::get_editor()
|
||||
{
|
||||
return(my_text);
|
||||
}
|
||||
|
||||
int
|
||||
CDEM_DtWidgetEditor::get_columns()
|
||||
{
|
||||
short ncolumns;
|
||||
XtVaGetValues(my_text, DtNcolumns, &ncolumns, NULL);
|
||||
return (int) ncolumns;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
CDEM_DtWidgetEditor::get_rows()
|
||||
{
|
||||
short nrows;
|
||||
XtVaGetValues(my_text, DtNrows, &nrows, NULL);
|
||||
return (int) nrows;
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_editable(Boolean bval)
|
||||
{
|
||||
XtVaSetValues(my_text,
|
||||
DtNeditable, bval,
|
||||
DtNcursorPositionVisible, bval,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_columns(int ncolumns)
|
||||
{
|
||||
XtVaSetValues(my_text, DtNcolumns, ncolumns, NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_rows(int nrows)
|
||||
{
|
||||
XtVaSetValues(my_text, DtNrows, nrows, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::undo_edit()
|
||||
{
|
||||
|
||||
DtEditorUndoEdit(my_text);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::cut_selection()
|
||||
{
|
||||
|
||||
DtEditorCutToClipboard(my_text);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::copy_selection()
|
||||
{
|
||||
|
||||
DtEditorCopyToClipboard(my_text);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::paste_from_clipboard()
|
||||
{
|
||||
|
||||
DtEditorPasteFromClipboard(my_text);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::paste_special_from_clipboard(
|
||||
Editor::InsertFormat format
|
||||
)
|
||||
{
|
||||
int status;
|
||||
unsigned long length, recvd;
|
||||
char *clipboard_data;
|
||||
Display *dpy = XtDisplayOfObject(my_text);
|
||||
Window window = XtWindowOfObject(my_text);
|
||||
|
||||
do {
|
||||
status = XmClipboardInquireLength(dpy, window, "STRING", &length);
|
||||
} while (status == ClipboardLocked);
|
||||
|
||||
if (length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
clipboard_data = XtMalloc((unsigned)length);
|
||||
|
||||
do {
|
||||
status = XmClipboardRetrieve(
|
||||
dpy, window, "STRING", clipboard_data,
|
||||
length, &recvd, NULL
|
||||
);
|
||||
} while (status == ClipboardLocked);
|
||||
|
||||
if (status != ClipboardSuccess || recvd != length) {
|
||||
// Couldn't get all
|
||||
|
||||
XtFree(clipboard_data);
|
||||
return;
|
||||
}
|
||||
|
||||
// Now modify the data such that the necessary formatting occurs
|
||||
// within it. Bracketting will cause a line at the beginning and
|
||||
// end of the data. Indenting will prepend a ">" before each line,
|
||||
// realigning the lines if necessary.
|
||||
// The results are stored in _modified_text so clipboard_data can
|
||||
// be freed immediately after this call.
|
||||
|
||||
this->modifyData(clipboard_data, (unsigned) length, format);
|
||||
XtFree(clipboard_data);
|
||||
|
||||
// Now copy the modified data stripped of CRLFs to a buffer.
|
||||
// Put that buffer into the structure appropriate for DtEditor.
|
||||
|
||||
DtEditorContentRec rec;
|
||||
|
||||
rec.type = DtEDITOR_TEXT;
|
||||
|
||||
// Length needs to be reset since the text now contains
|
||||
// new characters that do the necessary formatting.
|
||||
|
||||
length = _modified_text->length;
|
||||
|
||||
if ( _modified_text->ptr[(unsigned) length - 1] == 0 ) {
|
||||
rec.value.string = (char *)_modified_text->ptr;
|
||||
} else {
|
||||
this->my_owner->needBuf(
|
||||
&_buffer, &_buf_len,
|
||||
(unsigned) length + 1
|
||||
);
|
||||
this->my_owner->stripCRLF(
|
||||
&_buffer, _modified_text->ptr,
|
||||
(unsigned) length);
|
||||
rec.value.string = _buffer;
|
||||
}
|
||||
|
||||
DtEditorInsert(my_text, &rec);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::clear_selection()
|
||||
{
|
||||
|
||||
DtEditorClearSelection(my_text);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::delete_selection()
|
||||
{
|
||||
DtEditorDeleteSelection(my_text);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_word_wrap(
|
||||
Boolean bval
|
||||
)
|
||||
{
|
||||
XtVaSetValues(my_text, DtNwordWrap, bval, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_to_top()
|
||||
{
|
||||
XtVaSetValues(my_text,
|
||||
DtNtopCharacter, 0,
|
||||
DtNcursorPosition, 0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::text_selected_callback(
|
||||
Widget,
|
||||
void * clientData,
|
||||
void *
|
||||
)
|
||||
{
|
||||
|
||||
CDEM_DtWidgetEditor *obj=(CDEM_DtWidgetEditor *) clientData;
|
||||
|
||||
obj->text_selected();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::text_unselected_callback(
|
||||
Widget,
|
||||
void * clientData,
|
||||
void *
|
||||
)
|
||||
{
|
||||
|
||||
CDEM_DtWidgetEditor *obj=(CDEM_DtWidgetEditor *) clientData;
|
||||
|
||||
obj->text_unselected();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::text_selected()
|
||||
{
|
||||
|
||||
if (!text_already_selected) {
|
||||
text_already_selected = TRUE;
|
||||
my_owner->owner()->text_selected();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::text_unselected()
|
||||
{
|
||||
|
||||
my_owner->owner()->text_unselected();
|
||||
text_already_selected = FALSE;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::find_change()
|
||||
{
|
||||
DtEditorInvokeFindChangeDialog(my_text);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::spell()
|
||||
{
|
||||
DtEditorInvokeSpellDialog(my_text);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::format()
|
||||
{
|
||||
DtEditorInvokeFormatDialog(my_text);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::auto_show_cursor_off()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::auto_show_cursor_restore()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::select_all()
|
||||
{
|
||||
DtEditorSelectAll(my_text);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::set_to_bottom()
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
CDEM_DtWidgetEditor::no_text()
|
||||
{
|
||||
char *text = get_contents();
|
||||
int text_len = strlen(text);
|
||||
int result = 1;
|
||||
|
||||
for ( int k = 0; k < text_len; k++ ) {
|
||||
if ( isgraph(text[k]) ) {
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XtFree(text);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::disable_redisplay()
|
||||
{
|
||||
DtEditorDisableRedisplay(my_text);
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::enable_redisplay()
|
||||
{
|
||||
|
||||
DtEditorEnableRedisplay(my_text);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This fucntion modifies the pasted data
|
||||
* with an indent prefix before each new line or brackets it.
|
||||
*/
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::modifyData(
|
||||
char *sp, // source pointer to the insert string
|
||||
int length, // length does not include '\0' char
|
||||
Editor::InsertFormat insert_format
|
||||
)
|
||||
{
|
||||
if(_modified_text == NULL)
|
||||
_modified_text = (XmTextBlockRec *)calloc(1,sizeof(XmTextBlockRec));
|
||||
|
||||
char *maxsp = sp + length; // maxmimum source ptr
|
||||
|
||||
// Allocate memory rounded off to the nearest BUFINC
|
||||
size_t size_req = (size_t)(((length/BUFINC)+1)*BUFINC);
|
||||
if((_modified_text_buflen < size_req) ||
|
||||
((_modified_text_buflen > CDEM_DtWidgetEditor::MAXBUFSZ) &&
|
||||
(size_req < CDEM_DtWidgetEditor::MAXBUFSZ)) )
|
||||
reallocPasteBuf(size_req);
|
||||
|
||||
if(_modified_text->ptr == NULL)
|
||||
return; // No memory available
|
||||
|
||||
switch( insert_format) {
|
||||
case IF_INDENTED:
|
||||
{
|
||||
DtMailEnv error;
|
||||
int ip = 0;
|
||||
|
||||
// Get the indent prefix string
|
||||
DtMail::Session *m_session = theRoamApp.session()->session();
|
||||
m_session->mailRc(error)->getValue(error,"indentprefix", &indent_str);
|
||||
if (error.isSet() || NULL == indent_str)
|
||||
indent_str = strdup("> ");
|
||||
|
||||
size_t indlen = strlen(indent_str);
|
||||
|
||||
// Copy the src buf into dest, inserting indent before '\n'
|
||||
while(sp < maxsp) {
|
||||
|
||||
// Make sure there is enough space
|
||||
// for an indent prefix, one char and a terminating '\0'
|
||||
if(!((ip+indlen+2) < _modified_text_buflen) ) {
|
||||
size_req = (size_t)((((_modified_text_buflen +
|
||||
indlen+2)/BUFINC)+1)*BUFINC);
|
||||
reallocPasteBuf(size_req);
|
||||
if(_modified_text->ptr == NULL)
|
||||
return; // No memory available
|
||||
}
|
||||
|
||||
// Copy the indent string at the beginning
|
||||
if(!ip) {
|
||||
memcpy(_modified_text->ptr, indent_str, indlen);
|
||||
ip += indlen;
|
||||
}
|
||||
|
||||
// Copy the next byte and check for new line
|
||||
_modified_text->ptr[ip++] = *sp++;
|
||||
if(*(sp-1) == '\n') {
|
||||
memcpy(&_modified_text->ptr[ip], indent_str, indlen);
|
||||
ip += indlen;
|
||||
}
|
||||
|
||||
}
|
||||
_modified_text->ptr[ip] = '\0'; // terminate with a null char
|
||||
_modified_text->length = ip; // Do not include '\0' char in len
|
||||
}
|
||||
break;
|
||||
case IF_BRACKETED:
|
||||
{
|
||||
|
||||
if( !begin_ins_bracket)
|
||||
begin_ins_bracket = GETMSG(DT_catd, 1, 201,
|
||||
"\n------------- Begin Included Message -------------\n");
|
||||
if(!end_ins_bracket)
|
||||
end_ins_bracket = GETMSG(DT_catd, 1, 202,
|
||||
"\n------------- End Included Message -------------\n");
|
||||
|
||||
size_t begin_len = strlen(begin_ins_bracket);
|
||||
size_t end_len = strlen(end_ins_bracket);
|
||||
|
||||
// Make sure there is enough space
|
||||
if((size_req = length + begin_len + end_len + 1) >
|
||||
_modified_text_buflen) {
|
||||
size_req = (size_t) ((((size_req)/BUFINC)+1)*BUFINC);
|
||||
reallocPasteBuf(size_req);
|
||||
}
|
||||
|
||||
if(_modified_text->ptr == NULL)
|
||||
return;
|
||||
|
||||
strcpy(_modified_text->ptr, begin_ins_bracket);
|
||||
strncat(_modified_text->ptr,sp,length);
|
||||
strcat(_modified_text->ptr, end_ins_bracket);
|
||||
_modified_text->length = end_len + begin_len + length;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CDEM_DtWidgetEditor::MenuButtonHandler(
|
||||
Widget ,
|
||||
XtPointer cd,
|
||||
XEvent *event,
|
||||
Boolean *)
|
||||
{
|
||||
CDEM_DtWidgetEditor *obj = (CDEM_DtWidgetEditor *)cd;
|
||||
|
||||
if(event->xany.type != ButtonPress)
|
||||
return;
|
||||
|
||||
XButtonEvent *be = (XButtonEvent *)event;
|
||||
|
||||
if(be->button == Button3)
|
||||
obj->my_owner->owner()->postTextPopup(event);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
157
cde/programs/dtmail/dtmail/DtEditor.hh
Normal file
157
cde/programs/dtmail/dtmail/DtEditor.hh
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DtEditor.hh /main/9 1998/02/03 10:28:23 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef DTEDITOR_HH
|
||||
#define DTEDITOR_HH
|
||||
|
||||
// Include the DtWidgetEditor .h file given by HP.
|
||||
|
||||
#include <Dt/Editor.h>
|
||||
|
||||
#include "Editor.hh"
|
||||
#include "DtMailEditor.hh"
|
||||
|
||||
class CDEM_DtWidgetEditor : public Editor
|
||||
{
|
||||
|
||||
public:
|
||||
CDEM_DtWidgetEditor(
|
||||
Widget parent,
|
||||
DtMailEditor *owner_of_editor);
|
||||
~CDEM_DtWidgetEditor();
|
||||
|
||||
// Pure virtual functions of class Editor
|
||||
//
|
||||
virtual void initialize();
|
||||
|
||||
virtual void set_contents(
|
||||
const char *contents,
|
||||
const unsigned long len
|
||||
);
|
||||
|
||||
virtual void set_contents(const char *path);
|
||||
|
||||
virtual char* get_contents();
|
||||
|
||||
virtual void append_to_contents(
|
||||
const char *new_contents,
|
||||
const unsigned long len
|
||||
);
|
||||
|
||||
virtual void append_to_contents(const char *path);
|
||||
|
||||
virtual void append_at_cursor(const char *path);
|
||||
|
||||
virtual void append_at_cursor(
|
||||
const char *contents,
|
||||
const unsigned long len
|
||||
);
|
||||
|
||||
virtual void clear_contents();
|
||||
virtual int no_text();
|
||||
|
||||
virtual Widget get_text_widget();
|
||||
virtual Pixel get_text_foreground();
|
||||
virtual Pixel get_text_background();
|
||||
virtual Dimension get_text_width();
|
||||
virtual XmFontList get_text_fontList();
|
||||
virtual Widget get_editor();
|
||||
|
||||
virtual int get_columns();
|
||||
virtual int get_rows();
|
||||
virtual void set_columns(int ncolumns);
|
||||
virtual void set_editable(Boolean value);
|
||||
virtual void set_rows(int nrows);
|
||||
|
||||
virtual void auto_show_cursor_off();
|
||||
virtual void auto_show_cursor_restore();
|
||||
|
||||
virtual void set_to_top();
|
||||
virtual void set_to_bottom();
|
||||
|
||||
virtual void cut_selection();
|
||||
virtual void copy_selection();
|
||||
virtual void paste_from_clipboard();
|
||||
virtual void paste_special_from_clipboard(Editor::InsertFormat);
|
||||
virtual void clear_selection();
|
||||
virtual void delete_selection();
|
||||
virtual void select_all();
|
||||
|
||||
virtual void disable_redisplay();
|
||||
virtual void enable_redisplay();
|
||||
|
||||
//
|
||||
// End of Pure virtual functions for class Editor.
|
||||
|
||||
// Pure virtual functions of class AbstractEditorParent
|
||||
virtual void text_selected();
|
||||
virtual void text_unselected();
|
||||
|
||||
// Functions specific to DtEditor
|
||||
virtual void set_word_wrap(Boolean value);
|
||||
virtual void undo_edit();
|
||||
virtual void find_change();
|
||||
virtual void spell();
|
||||
virtual void format();
|
||||
|
||||
static void MenuButtonHandler(Widget, XtPointer, XEvent *, Boolean *);
|
||||
|
||||
protected:
|
||||
|
||||
// modify verify callback used during Paste Special
|
||||
static void modify_verify_callback(Widget, XtPointer, XtPointer);
|
||||
|
||||
static void text_selected_callback(Widget, void *, void *);
|
||||
static void text_unselected_callback(Widget, void *, void *);
|
||||
|
||||
|
||||
private:
|
||||
struct PSClientData {
|
||||
CDEM_DtWidgetEditor *obj;
|
||||
Editor::InsertFormat insert_format;
|
||||
};
|
||||
XmTextBlockRec *_modified_text;
|
||||
size_t _modified_text_buflen;
|
||||
enum PasteSpecBuf { MAXBUFSZ = 2048, BUFINC = 512};
|
||||
void modifyData(char *, int, Editor::InsertFormat);
|
||||
void reallocPasteBuf(size_t size_req) {
|
||||
_modified_text->ptr =
|
||||
(char *)realloc((void *)_modified_text->ptr, size_req);
|
||||
_modified_text_buflen = size_req;
|
||||
}
|
||||
|
||||
const char *indent_str;
|
||||
const char *begin_ins_bracket;
|
||||
const char *end_ins_bracket;
|
||||
|
||||
Widget my_parent;
|
||||
Widget my_text;
|
||||
Widget my_text_core;
|
||||
|
||||
DtMailEditor *my_owner;
|
||||
Boolean text_already_selected;
|
||||
Boolean _auto_show_cursor;
|
||||
|
||||
char * _buffer;
|
||||
unsigned long _buf_len;
|
||||
|
||||
};
|
||||
|
||||
#endif // DTEDITOR_HH
|
||||
1162
cde/programs/dtmail/dtmail/DtMail.msg
Normal file
1162
cde/programs/dtmail/dtmail/DtMail.msg
Normal file
File diff suppressed because it is too large
Load Diff
91
cde/programs/dtmail/dtmail/DtMailDialogCallbackData.hh
Normal file
91
cde/programs/dtmail/dtmail/DtMailDialogCallbackData.hh
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: DtMailDialogCallbackData.hh /main/4 1996/04/21 19:41:35 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// This example code is from the book:
|
||||
//
|
||||
// Object-Oriented Programming with C++ and OSF/Motif
|
||||
// by
|
||||
// Douglas Young
|
||||
// Prentice Hall, 1992
|
||||
// ISBN 0-13-630252-1
|
||||
//
|
||||
// Copyright 1991 by Prentice Hall
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software for
|
||||
// any purpose except publication and without fee is hereby granted, provided
|
||||
// that the above copyright notice appear in all copies of the software.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// DtMailDialogCallbackData.h: Auxiliary class used by DtMailGenDialog
|
||||
//////////////////////////////////////////////////////////////
|
||||
#ifndef DTMAILDIALOGCALLBACKDATA
|
||||
#define DTMAILDIALOGCALLBACKDATA
|
||||
|
||||
class DtMailGenDialog;
|
||||
|
||||
typedef void (*DialogCallback)( void * );
|
||||
|
||||
class DtMailDialogCallbackData {
|
||||
|
||||
private:
|
||||
|
||||
DtMailGenDialog *_dialog;
|
||||
DialogCallback _ok;
|
||||
DialogCallback _help;
|
||||
DialogCallback _cancel;
|
||||
DialogCallback _other;
|
||||
void *_clientData;
|
||||
Widget _other_w;
|
||||
|
||||
public:
|
||||
|
||||
DtMailDialogCallbackData ( DtMailGenDialog *dialog,
|
||||
void *clientData,
|
||||
DialogCallback ok,
|
||||
DialogCallback cancel,
|
||||
DialogCallback other,
|
||||
DialogCallback help,
|
||||
Widget other_w)
|
||||
{
|
||||
_dialog = dialog;
|
||||
_ok = ok;
|
||||
_help = help;
|
||||
_cancel = cancel;
|
||||
_other = other;
|
||||
_clientData = clientData;
|
||||
_other_w = other_w;
|
||||
}
|
||||
|
||||
DtMailGenDialog *dialog() { return _dialog; }
|
||||
DialogCallback ok() { return _ok; }
|
||||
DialogCallback help() { return _help; }
|
||||
DialogCallback cancel() { return _cancel; }
|
||||
DialogCallback other() { return _other; }
|
||||
void *clientData() { return _clientData; }
|
||||
Widget other_w() { return _other_w; }
|
||||
};
|
||||
#endif
|
||||
|
||||
580
cde/programs/dtmail/dtmail/DtMailEditor.C
Normal file
580
cde/programs/dtmail/dtmail/DtMailEditor.C
Normal file
@@ -0,0 +1,580 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DtMailEditor.C /main/10 1998/07/24 16:05:41 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef I_HAVE_NO_IDENT
|
||||
#else
|
||||
#endif
|
||||
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/SeparatoG.h>
|
||||
#include <Dt/Dnd.h>
|
||||
#include "DtMailEditor.hh"
|
||||
#include "XmTextEditor.h"
|
||||
#include "AttachArea.h"
|
||||
#include "Attachment.h"
|
||||
#ifdef DTEDITOR
|
||||
#include "DtEditor.hh"
|
||||
#endif
|
||||
|
||||
#include "EUSDebug.hh"
|
||||
|
||||
|
||||
extern "C" {
|
||||
extern XtPointer _XmStringUngenerate (
|
||||
XmString string,
|
||||
XmStringTag tag,
|
||||
XmTextType tag_type,
|
||||
XmTextType output_type);
|
||||
}
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(x) (((x) > 0) ? (x) : (-(x)))
|
||||
#endif
|
||||
|
||||
#ifndef DRAG_THRESHOLD
|
||||
#define DRAG_THRESHOLD 4
|
||||
#endif
|
||||
|
||||
DtMailEditor::DtMailEditor(
|
||||
Widget parent,
|
||||
AbstractEditorParent *owner
|
||||
) : UIComponent("DtMailEditor")
|
||||
{
|
||||
_myOwner = owner;
|
||||
|
||||
// Create a manager widget (say a form) and set it to the private
|
||||
// variable _container. Parent private instances to this widget.
|
||||
// Expose only _container externally (for attachment stuff...)
|
||||
|
||||
_w = XmCreateForm(parent, "DtMailEditor", NULL, 0);
|
||||
installDestroyHandler();
|
||||
|
||||
#ifdef DTEDITOR
|
||||
if ( use_XmTextEditor ) {
|
||||
_myTextEditor = new XmTextEditor(_w, this);
|
||||
} else {
|
||||
_myTextEditor = new CDEM_DtWidgetEditor(_w, this);
|
||||
}
|
||||
#else
|
||||
_myTextEditor = new XmTextEditor(_w, this);
|
||||
#endif
|
||||
|
||||
_myAttachArea = new AttachArea(_w, this, "AttachPane");
|
||||
|
||||
_showAttachArea = TRUE;
|
||||
_doingDrag = FALSE;
|
||||
_separator = NULL;
|
||||
_msgHandle = NULL;
|
||||
_dragX = -1;
|
||||
_dragY = -1;
|
||||
_editable = FALSE;
|
||||
|
||||
}
|
||||
|
||||
DtMailEditor::~DtMailEditor()
|
||||
{
|
||||
unmanageAttachArea();
|
||||
delete _myAttachArea;
|
||||
delete _myTextEditor;
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::initialize()
|
||||
{
|
||||
|
||||
Widget editor_widget;
|
||||
|
||||
_myTextEditor->initialize();
|
||||
|
||||
_separator = XtVaCreateManagedWidget("Sep1",
|
||||
xmSeparatorGadgetClass,
|
||||
_w,
|
||||
XmNtopOffset, 1,
|
||||
XmNbottomOffset, 1,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
|
||||
// Create an *UNMANAGED* attachArea.
|
||||
// If the message has an attachment, the DtMailEditor instance
|
||||
// will receive a manageAttachArea where it will adjust the
|
||||
// attachments and manage the attachArea accordingly
|
||||
|
||||
_myAttachArea->initialize();
|
||||
|
||||
attachDropRegister();
|
||||
if (!_editable)
|
||||
attachDropDisable();
|
||||
|
||||
editor_widget = _myTextEditor->get_editor();
|
||||
|
||||
XtVaSetValues(editor_widget,
|
||||
XmNtopAttachment,XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_WIDGET,
|
||||
XmNbottomWidget, _separator,
|
||||
XmNrightAttachment,XmATTACH_FORM,
|
||||
XmNrightOffset, 4,
|
||||
XmNleftAttachment,XmATTACH_FORM,
|
||||
XmNleftOffset, 3,
|
||||
NULL );
|
||||
|
||||
XtVaSetValues(_myAttachArea->baseWidget(),
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNrightOffset, 3,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNleftOffset, 5,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(_separator,
|
||||
XmNbottomAttachment, XmATTACH_WIDGET,
|
||||
XmNbottomWidget, _myAttachArea->baseWidget(),
|
||||
NULL);
|
||||
|
||||
// Unmanage the attachArea. If a message has attachments,
|
||||
// manageAttachArea() will get called by the consumer of this
|
||||
// class.
|
||||
|
||||
this->unmanageAttachArea();
|
||||
|
||||
XtManageChild(_w);
|
||||
|
||||
}
|
||||
|
||||
AbstractEditorParent *
|
||||
DtMailEditor::owner()
|
||||
{
|
||||
return (_myOwner);
|
||||
}
|
||||
|
||||
Editor*
|
||||
DtMailEditor::textEditor()
|
||||
{
|
||||
return(_myTextEditor);
|
||||
}
|
||||
|
||||
AttachArea*
|
||||
DtMailEditor::attachArea()
|
||||
{
|
||||
return(_myAttachArea);
|
||||
}
|
||||
|
||||
Widget
|
||||
DtMailEditor::container()
|
||||
{
|
||||
return(_w);
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::setEditable(Boolean bval)
|
||||
{
|
||||
textEditor()->set_editable(bval);
|
||||
_editable = bval;
|
||||
if (_editable)
|
||||
attachDropEnable();
|
||||
else
|
||||
attachDropDisable();
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::manageAttachArea()
|
||||
{
|
||||
|
||||
if (!_showAttachArea && (_myAttachArea->getIconCount() == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_myAttachArea->manage();
|
||||
XtManageChild(_separator);
|
||||
|
||||
Widget editor_widget = _myTextEditor->get_editor();
|
||||
|
||||
XtVaSetValues(editor_widget,
|
||||
XmNbottomAttachment, XmATTACH_WIDGET,
|
||||
XmNbottomWidget, _separator,
|
||||
NULL );
|
||||
|
||||
XtVaSetValues(_separator,
|
||||
XmNbottomAttachment, XmATTACH_WIDGET,
|
||||
XmNbottomWidget, _myAttachArea->baseWidget(),
|
||||
NULL);
|
||||
|
||||
XtVaSetValues(_myAttachArea->baseWidget(),
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::unmanageAttachArea()
|
||||
{
|
||||
|
||||
// Already unmanaged?
|
||||
if (!XtIsManaged(_myAttachArea->baseWidget())) return;
|
||||
|
||||
Widget editor_widget = _myTextEditor->get_editor();
|
||||
|
||||
XtVaSetValues(editor_widget,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
NULL );
|
||||
|
||||
_myAttachArea->unmanage();
|
||||
|
||||
XtUnmanageChild(_separator);
|
||||
|
||||
}
|
||||
|
||||
// Initialize _msgHandle
|
||||
void
|
||||
DtMailEditor::setMsgHnd(DtMail::Message * msgHandle)
|
||||
{
|
||||
_msgHandle = msgHandle;
|
||||
}
|
||||
|
||||
// attachTransferCallback
|
||||
//
|
||||
// Handles the transfer of data that is dropped on the attachment list.
|
||||
// The data is turned into an attachment and appended to the list.
|
||||
//
|
||||
void
|
||||
DtMailEditor::attachTransferCallback(
|
||||
Widget /* widget */,
|
||||
XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
{
|
||||
DtDndTransferCallbackStruct *transferInfo =
|
||||
(DtDndTransferCallbackStruct *) call_data;
|
||||
DtDndContext *dropData = transferInfo->dropData;
|
||||
int numItems = dropData->numItems, ii;
|
||||
DtMailEditor *editor = (DtMailEditor *) client_data;
|
||||
DtMailEnv mail_error;
|
||||
DtMailBuffer buf;
|
||||
char *attachname;
|
||||
|
||||
DebugPrintf(3, "In DtMailEditor::attachTransferCallback\n");
|
||||
|
||||
// Initialize mail_error.
|
||||
mail_error.clear();
|
||||
|
||||
switch (transferInfo->dropData->protocol) {
|
||||
|
||||
case DtDND_FILENAME_TRANSFER:
|
||||
|
||||
// Loop through the dropped files and turn each
|
||||
// into an attachment.
|
||||
|
||||
for (ii = 0; ii < numItems; ii++) {
|
||||
editor->owner()->add_att(dropData->data.files[ii]);
|
||||
}
|
||||
break;
|
||||
|
||||
case DtDND_BUFFER_TRANSFER:
|
||||
|
||||
// Loop through the dropped buffers and turn each
|
||||
// into an attachment.
|
||||
|
||||
for (ii = 0; ii < numItems; ii++) {
|
||||
|
||||
buf.buffer = (char *)dropData->data.buffers[ii].bp;
|
||||
buf.size = (unsigned long)dropData->data.buffers[ii].size;
|
||||
attachname = dropData->data.buffers[ii].name;
|
||||
|
||||
if (!attachname)
|
||||
attachname = "Untitled";
|
||||
|
||||
editor->owner()->add_att(attachname, buf);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
transferInfo->status = DtDND_FAILURE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// attachDropRegister
|
||||
//
|
||||
// Register the attachment list to accept drops of buffer and files
|
||||
//
|
||||
void
|
||||
DtMailEditor::attachDropRegister()
|
||||
{
|
||||
static XtCallbackRec transferCBRec[] = {
|
||||
{&DtMailEditor::attachTransferCallback, NULL}, {NULL, NULL} };
|
||||
|
||||
// Pass the DtMailEditor object (this) as clientData.
|
||||
transferCBRec[0].closure = (XtPointer) this;
|
||||
|
||||
DtDndVaDropRegister(_myAttachArea->baseWidget(),
|
||||
DtDND_FILENAME_TRANSFER | DtDND_BUFFER_TRANSFER,
|
||||
(unsigned char)(XmDROP_COPY), transferCBRec,
|
||||
DtNtextIsBuffer, TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
// attachDropEnable
|
||||
//
|
||||
// Enable the attachment list for drops by restoring the operation
|
||||
//
|
||||
void
|
||||
DtMailEditor::attachDropEnable()
|
||||
{
|
||||
Arg args[1];
|
||||
|
||||
XtSetArg(args[0], XmNdropSiteOperations, XmDROP_MOVE | XmDROP_COPY);
|
||||
XmDropSiteUpdate(_myAttachArea->baseWidget(), args, 1);
|
||||
}
|
||||
|
||||
// attachDropDisable
|
||||
//
|
||||
// Disable the attachment list for drops by setting the operation to noop
|
||||
//
|
||||
void
|
||||
DtMailEditor::attachDropDisable()
|
||||
{
|
||||
Arg args[1];
|
||||
|
||||
XtSetArg(args[0], XmNdropSiteOperations, XmDROP_NOOP);
|
||||
XmDropSiteUpdate(_myAttachArea->baseWidget(), args, 1);
|
||||
}
|
||||
|
||||
// attachConvertCallback
|
||||
//
|
||||
// Provides the selected attachments for the drag
|
||||
//
|
||||
void
|
||||
DtMailEditor::attachConvertCallback(
|
||||
Widget /* dragContext */,
|
||||
XtPointer clientData,
|
||||
XtPointer callData)
|
||||
{
|
||||
DtDndConvertCallbackStruct *convertInfo =
|
||||
(DtDndConvertCallbackStruct *) callData;
|
||||
DtDndBuffer *buffers = convertInfo->dragData->data.buffers;
|
||||
DtMailEditor *editor = (DtMailEditor *) clientData;
|
||||
int numIcons = editor->attachArea()->getIconCount();
|
||||
Attachment **list = editor->attachArea()->getList();
|
||||
int ii, current = 0;
|
||||
char *name = NULL;
|
||||
XmString str;
|
||||
DtMailEnv mail_error;
|
||||
|
||||
|
||||
DebugPrintf(3, "In DtMailEditor::attachConvertCallback\n");
|
||||
|
||||
switch(convertInfo->reason) {
|
||||
case DtCR_DND_CONVERT_DATA:
|
||||
for (ii = 0; ii < numIcons; ii++) {
|
||||
if (!list[ii]->isDeleted() && list[ii]->isSelected()) {
|
||||
buffers[current].bp = list[ii]->getContents();
|
||||
buffers[current].size = (int)list[ii]->getContentsSize();
|
||||
str = list[ii]->getLabel();
|
||||
buffers[current].name =
|
||||
(char *) _XmStringUngenerate(
|
||||
str, NULL,
|
||||
XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
|
||||
XmStringFree(str);
|
||||
current++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case DtCR_DND_CONVERT_DELETE:
|
||||
editor->attachArea()->deleteSelectedAttachments(mail_error);
|
||||
break;
|
||||
|
||||
default:
|
||||
convertInfo->status = DtDND_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
// attachDragFinishCallback
|
||||
//
|
||||
// Clean up from the convert callback and restore state
|
||||
//
|
||||
void
|
||||
DtMailEditor::attachDragFinishCallback(
|
||||
Widget /* widget */,
|
||||
XtPointer clientData,
|
||||
XtPointer callData)
|
||||
{
|
||||
DtDndDragFinishCallbackStruct *finishInfo =
|
||||
(DtDndDragFinishCallbackStruct *) callData;
|
||||
DtDndContext *dragData = finishInfo->dragData;
|
||||
DtMailEditor *editor = (DtMailEditor *) clientData;
|
||||
int ii;
|
||||
|
||||
DebugPrintf(3, "In DtMailEditor::attachDragFinishCallback\n");
|
||||
|
||||
editor->setDoingDrag(FALSE);
|
||||
editor->setDragX(-1);
|
||||
editor->setDragY(-1);
|
||||
|
||||
if (editor->editable())
|
||||
editor->attachDropEnable();
|
||||
|
||||
for (ii = 0; ii < dragData->numItems; ii++) {
|
||||
XtFree((char *)dragData->data.buffers[ii].name);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::attachDragStart( Widget widget,
|
||||
XEvent *event)
|
||||
{
|
||||
static XtCallbackRec convertCBRec[] = {
|
||||
{&DtMailEditor::attachConvertCallback, NULL}, {NULL, NULL} };
|
||||
static XtCallbackRec dragFinishCBRec[] = {
|
||||
{&DtMailEditor::attachDragFinishCallback, NULL}, {NULL, NULL} };
|
||||
int itemCount;
|
||||
unsigned char operations;
|
||||
|
||||
convertCBRec[0].closure = (XtPointer) this;
|
||||
dragFinishCBRec[0].closure = (XtPointer) this;
|
||||
|
||||
attachDropDisable();
|
||||
|
||||
// Count the number of items to be dragged.
|
||||
itemCount = attachArea()->getSelectedIconCount();
|
||||
|
||||
setDoingDrag(TRUE);
|
||||
|
||||
if (editable()) {
|
||||
operations = (unsigned char)(XmDROP_COPY | XmDROP_MOVE);
|
||||
} else {
|
||||
operations = (unsigned char)(XmDROP_COPY);
|
||||
}
|
||||
|
||||
if (DtDndVaDragStart(widget, event, DtDND_BUFFER_TRANSFER, itemCount,
|
||||
operations, convertCBRec, dragFinishCBRec,
|
||||
// DtNsourceIcon, dragIcon,
|
||||
NULL)
|
||||
== NULL) {
|
||||
|
||||
DebugPrintf(3, "DragStart returned NULL.\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::attachDragMotionHandler(
|
||||
Widget widget,
|
||||
XEvent *event)
|
||||
{
|
||||
int diffX, diffY;
|
||||
|
||||
if (!doingDrag()) {
|
||||
// If the drag is just starting, set initial button down coordinates.
|
||||
if (dragX() == -1 && dragY() == -1) {
|
||||
setDragX(event->xmotion.x);
|
||||
setDragY(event->xmotion.y);
|
||||
}
|
||||
|
||||
// Find out how far the pointer has moved since the button press.
|
||||
diffX = dragX() - event->xmotion.x;
|
||||
diffY = dragY() - event->xmotion.y;
|
||||
|
||||
if ((ABS(diffX) >= DRAG_THRESHOLD) ||
|
||||
(ABS(diffY) >= DRAG_THRESHOLD)) {
|
||||
attachDragStart(widget, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef notdef
|
||||
void
|
||||
DtMailEditor::attachDragSetup()
|
||||
{
|
||||
Boolean btn1_transfer;
|
||||
Widget widget = _myAttachArea->baseWidget();
|
||||
|
||||
DebugPrintf(3, "In DtMailEditor::attachDragSetup()\n");
|
||||
|
||||
XtAddEventHandler(widget, Button1MotionMask, FALSE,
|
||||
(XtEventHandler)&DtMailEditor::attachDragMotionHandler,
|
||||
(XtPointer)this);
|
||||
|
||||
XtVaGetValues(
|
||||
(Widget)XmGetXmDisplay(XtDisplayOfObject(widget)),
|
||||
"enableBtn1Transfer", &btn1_transfer,
|
||||
NULL);
|
||||
|
||||
if (!btn1_transfer) {
|
||||
XtAddEventHandler(widget, Button2MotionMask, FALSE,
|
||||
(XtEventHandler)&DtMailEditor::attachDragMotionHandler,
|
||||
(XtPointer)this);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
DtMailEditor::stripCRLF(char **buffer, const char * buf, const unsigned long len)
|
||||
{
|
||||
char * out = *buffer;
|
||||
int _len;
|
||||
|
||||
|
||||
for (const char * in = buf; in < (buf + len);) {
|
||||
_len = mblen( in, MB_CUR_MAX );
|
||||
if ( _len <= 0 )
|
||||
break;
|
||||
if ( ( _len == 1 ) && ( *in == '\r' ) ){
|
||||
in += 1;
|
||||
continue;
|
||||
}
|
||||
strncpy( out, in, _len );
|
||||
out += _len, in += _len;
|
||||
}
|
||||
*out = 0;
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::needBuf(char **buffer, unsigned long *buflen, unsigned long newlen)
|
||||
{
|
||||
if (newlen > *buflen) {
|
||||
// Need a bigger buffer.
|
||||
if (*buffer) {
|
||||
delete [] *buffer;
|
||||
}
|
||||
|
||||
*buffer = new char[newlen];
|
||||
*buflen = newlen;
|
||||
} else {
|
||||
// Clear buffer content -- get ready for new data
|
||||
if (*buffer) {
|
||||
memset(*buffer, 0, (unsigned int)*buflen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::showAttachArea()
|
||||
{
|
||||
_showAttachArea = TRUE;
|
||||
this->manageAttachArea();
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
DtMailEditor::hideAttachArea()
|
||||
{
|
||||
_showAttachArea = FALSE;
|
||||
this->unmanageAttachArea();
|
||||
}
|
||||
93
cde/programs/dtmail/dtmail/DtMailEditor.hh
Normal file
93
cde/programs/dtmail/dtmail/DtMailEditor.hh
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DtMailEditor.hh /main/5 1997/06/06 12:45:31 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef DTMAILEDITOR_H
|
||||
#define DTMAILEDITOR_H
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include "Editor.hh"
|
||||
#include "AttachArea.h"
|
||||
|
||||
|
||||
class DtMailEditor : public UIComponent {
|
||||
|
||||
public:
|
||||
|
||||
DtMailEditor(
|
||||
Widget,
|
||||
AbstractEditorParent *
|
||||
);
|
||||
virtual ~DtMailEditor();
|
||||
|
||||
void initialize();
|
||||
AbstractEditorParent *owner();
|
||||
|
||||
Editor *textEditor();
|
||||
AttachArea *attachArea();
|
||||
|
||||
Widget container();
|
||||
|
||||
void showAttachArea();
|
||||
void hideAttachArea();
|
||||
void manageAttachArea();
|
||||
void unmanageAttachArea();
|
||||
void setMsgHnd( DtMail::Message *);
|
||||
static void attachTransferCallback(Widget, XtPointer, XtPointer );
|
||||
void attachDropRegister();
|
||||
void attachDropEnable();
|
||||
void attachDropDisable();
|
||||
static void attachConvertCallback(Widget, XtPointer, XtPointer);
|
||||
static void attachDragFinishCallback(Widget, XtPointer, XtPointer);
|
||||
void attachDragStart(Widget, XEvent *);
|
||||
void attachDragMotionHandler(Widget, XEvent *);
|
||||
//void attachDragSetup();
|
||||
void setEditable(Boolean);
|
||||
Boolean editable() { return _editable; }
|
||||
Boolean doingDrag() { return _doingDrag; }
|
||||
void setDoingDrag(Boolean doingDrag) { _doingDrag = doingDrag; }
|
||||
void setDragX(int n) { _dragX = n; }
|
||||
void setDragY(int n) { _dragY = n; }
|
||||
int dragX() { return _dragX; }
|
||||
int dragY() { return _dragY; }
|
||||
|
||||
// Routines to null terminate buffer.
|
||||
void needBuf(char **, unsigned long *, unsigned long len);
|
||||
void stripCRLF(char **, const char * buf, const unsigned long len);
|
||||
|
||||
private:
|
||||
|
||||
DtMail::Message *_msgHandle;
|
||||
Editor *_myTextEditor;
|
||||
AttachArea *_myAttachArea;
|
||||
Widget _container;
|
||||
Widget _separator;
|
||||
|
||||
Boolean _editable;
|
||||
Boolean _showAttachArea;
|
||||
Boolean _doingDrag;
|
||||
int _dragX;
|
||||
int _dragY;
|
||||
|
||||
// Can be RMW or VMD or SMD
|
||||
AbstractEditorParent *_myOwner;
|
||||
|
||||
};
|
||||
|
||||
#endif // DTMAILEDITOR_HH
|
||||
890
cde/programs/dtmail/dtmail/DtMailGenDialog.C
Normal file
890
cde/programs/dtmail/dtmail/DtMailGenDialog.C
Normal file
@@ -0,0 +1,890 @@
|
||||
/* $TOG: DtMailGenDialog.C /main/15 1999/07/07 15:08:18 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DtMailGenDialog.C /main/15 1999/07/07 15:08:18 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
//////////////////////////////////////////////////////////
|
||||
// DtMailGenDialog.C: Generic dialog based on MessageBox
|
||||
//////////////////////////////////////////////////////////
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/param.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <Dt/Dt.h>
|
||||
#include <Dt/Icon.h>
|
||||
#include <Dt/IconP.h>
|
||||
#include <Dt/IconFile.h>
|
||||
#include <Xm/MessageB.h>
|
||||
#include <Xm/PushBG.h>
|
||||
#include <Xm/MwmUtil.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "DtMailGenDialog.hh"
|
||||
#include "DtMailHelp.hh"
|
||||
#include "Help.hh"
|
||||
#include "MailMsg.h"
|
||||
|
||||
static const char *ABOUT_TITLE = NULL;
|
||||
static char *DTMAIL_VERSION = NULL;
|
||||
static const char *credits = "Dtmail was brought to you by: ";
|
||||
static int doCredits = 0;
|
||||
|
||||
DtMailGenDialog::DtMailGenDialog(char *name, Widget parent, int style)
|
||||
: UIComponent(name)
|
||||
{
|
||||
|
||||
_w = XmCreateMessageDialog(parent, name, NULL, 0);
|
||||
XtVaSetValues(_w, XmNdialogStyle, style, NULL);
|
||||
|
||||
// Disable the frame menu from all dialogs. We don't want
|
||||
// the user to be able to dismiss dialogs through the frame
|
||||
// menu.
|
||||
//
|
||||
XtVaSetValues(
|
||||
XtParent(_w),
|
||||
XmNmwmDecorations, MWM_DECOR_ALL | MWM_DECOR_MENU,
|
||||
NULL);
|
||||
|
||||
_info_dialog = 0;
|
||||
_otherWidget = (Widget) NULL;
|
||||
_textField = (Widget) NULL;
|
||||
_maxTextlen = 0;
|
||||
_clearText = NULL;
|
||||
|
||||
_parentshell = parent;
|
||||
while (_parentshell && !XtIsShell(_parentshell))
|
||||
_parentshell = XtParent(_parentshell);
|
||||
}
|
||||
|
||||
|
||||
Widget
|
||||
DtMailGenDialog::post(void *clientData,
|
||||
DialogCallback ok,
|
||||
DialogCallback cancel,
|
||||
DialogCallback other,
|
||||
DialogCallback help,
|
||||
char *helpId)
|
||||
{
|
||||
// _w is the MessageBox widget created in the constructor...
|
||||
|
||||
Widget dialog = _w;
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert (dialog != NULL);
|
||||
|
||||
// Make sure the dialog buttons are managed
|
||||
Widget ok_button = XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON);
|
||||
Widget cancel_button = XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON);
|
||||
Widget help_button = XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON);
|
||||
|
||||
// Create an object to carry the additional data needed
|
||||
// to cache the dialogs.
|
||||
|
||||
DtMailDialogCallbackData *dcb = new DtMailDialogCallbackData(
|
||||
(DtMailGenDialog *) this,
|
||||
clientData,
|
||||
ok,
|
||||
cancel,
|
||||
other,
|
||||
help,
|
||||
_otherWidget);
|
||||
// Install callback function for each button
|
||||
// support by Motif dialogs. If there is no help callback
|
||||
// unmanage the corresponding button instead, if possible.
|
||||
|
||||
if ( ok )
|
||||
{
|
||||
XtAddCallback(
|
||||
dialog,
|
||||
XmNokCallback, &DtMailGenDialog::okCallback,
|
||||
(XtPointer) dcb);
|
||||
if (!XtIsManaged(ok_button)) XtManageChild(ok_button);
|
||||
}
|
||||
else XtUnmanageChild(ok_button);
|
||||
|
||||
if (cancel)
|
||||
{
|
||||
XtAddCallback(
|
||||
dialog,
|
||||
XmNcancelCallback, &DtMailGenDialog::cancelCallback,
|
||||
(XtPointer) dcb);
|
||||
if (!XtIsManaged(cancel_button)) XtManageChild(cancel_button);
|
||||
}
|
||||
else XtUnmanageChild(cancel_button);
|
||||
|
||||
|
||||
if (other)
|
||||
{
|
||||
XtAddCallback(
|
||||
_otherWidget,
|
||||
XmNactivateCallback, &DtMailGenDialog::otherCallback,
|
||||
(XtPointer) dcb);
|
||||
}
|
||||
else if (_otherWidget) XtUnmanageChild(_otherWidget);
|
||||
|
||||
|
||||
if (help)
|
||||
{
|
||||
XtAddCallback(
|
||||
dialog,
|
||||
XmNhelpCallback, &HelpErrorCB,
|
||||
(XtPointer) helpId);
|
||||
if (!XtIsManaged (help_button)) XtManageChild(help_button);
|
||||
} else XtUnmanageChild(help_button);
|
||||
|
||||
//
|
||||
// Make sure the parent dialog is popped up and occupying the
|
||||
// current workspace.
|
||||
//
|
||||
if (NULL != _parentshell)
|
||||
{
|
||||
XtPopup(_parentshell, XtGrabNone);
|
||||
displayInCurrentWorkspace(_parentshell);
|
||||
}
|
||||
|
||||
// Post the dialog.
|
||||
XtManageChild(dialog);
|
||||
|
||||
if (NULL != _textField && XtIsManaged(_textField))
|
||||
XmProcessTraversal(_textField, XmTRAVERSE_CURRENT);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
void
|
||||
DtMailGenDialog::okCallback(Widget w, XtPointer clientData, XtPointer cbs)
|
||||
{
|
||||
XmPushButtonCallbackStruct * pbcs = (XmPushButtonCallbackStruct *)cbs;
|
||||
|
||||
DtMailDialogCallbackData *dcd = (DtMailDialogCallbackData *) clientData;
|
||||
DtMailGenDialog *obj = (DtMailGenDialog *) dcd->dialog();
|
||||
DialogCallback callback;
|
||||
|
||||
// If caller specified an ok callback, call the function
|
||||
|
||||
if ((callback=dcd->ok()) != NULL) (*callback)(dcd->clientData());
|
||||
|
||||
// If the help widget was popped up, destroy it.
|
||||
Widget helpWidget = getErrorHelpWidget();
|
||||
if (helpWidget)
|
||||
{
|
||||
XtUnmanageChild (helpWidget);
|
||||
XtDestroyWidget (helpWidget);
|
||||
clearErrorHelpWidget();
|
||||
}
|
||||
|
||||
// Reset for the next time
|
||||
|
||||
Widget ow = dcd->other_w();
|
||||
if (ow != NULL)
|
||||
XtRemoveCallback(
|
||||
ow,
|
||||
XmNactivateCallback,
|
||||
&DtMailGenDialog::otherCallback,
|
||||
(XtPointer) dcd);
|
||||
|
||||
obj->cleanup(w, dcd);
|
||||
|
||||
if (obj->_info_dialog &&
|
||||
(pbcs->event->xbutton.state & (ShiftMask | ControlMask)))
|
||||
{
|
||||
#ifdef NEVER
|
||||
// Don't do credits for now
|
||||
doCredits = 1;
|
||||
#endif
|
||||
doCredits = 0;
|
||||
obj->setToAboutDialog();
|
||||
// char * helpId = "About";
|
||||
char * helpId = NULL;
|
||||
int answer = obj->post_and_return(GETMSG(DT_catd, 1, 180, "OK"),
|
||||
helpId);
|
||||
}
|
||||
}
|
||||
|
||||
void DtMailGenDialog::cancelCallback(Widget w, XtPointer clientData, XtPointer)
|
||||
{
|
||||
DtMailDialogCallbackData *dcd = (DtMailDialogCallbackData *) clientData;
|
||||
DtMailGenDialog *obj = (DtMailGenDialog *) dcd->dialog();
|
||||
DialogCallback callback;
|
||||
|
||||
if ((callback=dcd->cancel()) != NULL) (*callback)(dcd->clientData());
|
||||
|
||||
// If the help widget was popped up, destroy it.
|
||||
Widget helpWidget = getErrorHelpWidget();
|
||||
if (helpWidget)
|
||||
{
|
||||
XtUnmanageChild (helpWidget);
|
||||
XtDestroyWidget (helpWidget);
|
||||
clearErrorHelpWidget();
|
||||
}
|
||||
|
||||
|
||||
Widget ow = dcd->other_w();
|
||||
if (ow != NULL)
|
||||
XtRemoveCallback ( ow,
|
||||
XmNactivateCallback,
|
||||
&DtMailGenDialog::otherCallback,
|
||||
(XtPointer) dcd );
|
||||
|
||||
obj->cleanup(w, dcd);
|
||||
}
|
||||
|
||||
void DtMailGenDialog::otherCallback(Widget w, XtPointer clientData, XtPointer)
|
||||
{
|
||||
DtMailDialogCallbackData *dcd = (DtMailDialogCallbackData *) clientData;
|
||||
DtMailGenDialog *obj = (DtMailGenDialog *) dcd->dialog();
|
||||
DialogCallback callback;
|
||||
|
||||
if ((callback=dcd->other()) != NULL) (*callback)(dcd->clientData());
|
||||
|
||||
XtRemoveCallback(
|
||||
w,
|
||||
XmNactivateCallback,
|
||||
&DtMailGenDialog::otherCallback,
|
||||
(XtPointer) dcd);
|
||||
|
||||
Widget pw = XtParent(w);
|
||||
obj->cleanup(pw, dcd);
|
||||
}
|
||||
|
||||
void DtMailGenDialog::helpCallback(Widget, XtPointer clientData, XtPointer)
|
||||
{
|
||||
DtMailDialogCallbackData *dcd = (DtMailDialogCallbackData *) clientData;
|
||||
DtMailGenDialog *obj = (DtMailGenDialog *) dcd->dialog();
|
||||
DialogCallback callback;
|
||||
|
||||
if ((callback=dcd->help()) != NULL) (*callback)(dcd->clientData());
|
||||
}
|
||||
|
||||
void DtMailGenDialog::verifyCallback(Widget, XtPointer clientD, XtPointer callD)
|
||||
{
|
||||
DtMailGenDialog *obj = (DtMailGenDialog*) clientD;
|
||||
XmTextVerifyPtr cbs = (XmTextVerifyPtr) callD;
|
||||
|
||||
obj->verify(cbs);
|
||||
}
|
||||
|
||||
void DtMailGenDialog::verify(XmTextVerifyPtr cbs)
|
||||
{
|
||||
int i;
|
||||
static char buffer[MAXPATHLEN];
|
||||
register char *s, *t;
|
||||
|
||||
#if defined(SHROUDED_TEXTFIELD_DEBUG)
|
||||
printf(
|
||||
"currInsert=%d newInsert=%d startPos=%d endPos=%d\n",
|
||||
cbs->currInsert,cbs->newInsert,cbs->startPos, cbs->endPos);
|
||||
if (cbs->text->ptr) printf("text->ptr=%s\n", cbs->text->ptr);
|
||||
printf("_clearText=%s\n", _clearText);
|
||||
#endif
|
||||
|
||||
for (i=0, s=buffer, t=_clearText; (*t && i<cbs->startPos); i++, s++, t++)
|
||||
*s = *t;
|
||||
|
||||
if (cbs->text->ptr)
|
||||
{
|
||||
strcpy(s, cbs->text->ptr);
|
||||
s += cbs->text->length;
|
||||
}
|
||||
else
|
||||
*s = '\0';
|
||||
|
||||
if (strlen(_clearText) >= cbs->endPos)
|
||||
{
|
||||
t = _clearText+cbs->endPos;
|
||||
if (strlen(t))
|
||||
strcpy(s, t);
|
||||
}
|
||||
|
||||
if (strlen(buffer) >= _maxTextlen)
|
||||
{
|
||||
_maxTextlen *= 2;
|
||||
_clearText = (char*) realloc((void*) _clearText, (size_t) _maxTextlen);
|
||||
assert(NULL!=_clearText);
|
||||
}
|
||||
strcpy(_clearText, buffer);
|
||||
|
||||
if (_shroudText && cbs->text->ptr)
|
||||
for (i=0, s=cbs->text->ptr; i<cbs->text->length; i++, s++)
|
||||
*s = '*';
|
||||
|
||||
#if defined(SHROUDED_TEXTFIELD_DEBUG)
|
||||
printf("text=%s\n", _clearText);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void DtMailGenDialog::cleanup(Widget w, DtMailDialogCallbackData *dcd)
|
||||
{
|
||||
// Remove all callbacks to avoid having duplicate
|
||||
// callback functions installed.
|
||||
|
||||
XtRemoveCallback(
|
||||
w,
|
||||
XmNokCallback, &DtMailGenDialog::okCallback,
|
||||
(XtPointer) dcd );
|
||||
|
||||
XtRemoveCallback(
|
||||
w,
|
||||
XmNcancelCallback, &DtMailGenDialog::cancelCallback,
|
||||
(XtPointer) dcd);
|
||||
|
||||
if (XtHasCallbacks(w, XmNhelpCallback) == XtCallbackHasSome)
|
||||
XtRemoveAllCallbacks(w, XmNhelpCallback);
|
||||
|
||||
if (NULL != _textField && XtIsManaged(_textField))
|
||||
XtUnmanageChild(_textField);
|
||||
|
||||
// Delete the DtMailDialogCallbackData instance for this posting
|
||||
delete dcd;
|
||||
}
|
||||
|
||||
void
|
||||
DtMailGenDialog::forceUpdate( Widget w )
|
||||
{
|
||||
Widget diashell, topshell;
|
||||
Window diawindow, topwindow;
|
||||
|
||||
Display *dpy;
|
||||
XWindowAttributes xwa;
|
||||
|
||||
if (!w) return;
|
||||
|
||||
XtAppContext cxt=XtWidgetToApplicationContext( w );
|
||||
for (diashell=w;!XtIsShell(diashell);diashell=XtParent(diashell));
|
||||
for (topshell=diashell;
|
||||
XtIsTopLevelShell(topshell);
|
||||
topshell=XtParent(topshell));
|
||||
|
||||
dpy=XtDisplay(diashell);
|
||||
diawindow=XtWindow(diashell);
|
||||
topwindow=XtWindow(topshell);
|
||||
while (XGetWindowAttributes(dpy,diawindow,&xwa) &&
|
||||
xwa.map_state != IsViewable && XEventsQueued(dpy,QueuedAlready))
|
||||
{
|
||||
XtAppProcessEvent(cxt, XtIMAll );
|
||||
}
|
||||
XmUpdateDisplay(topshell);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Added this extra functionality
|
||||
|
||||
void
|
||||
genDialogOKCallback( int *data )
|
||||
{
|
||||
*data=1;
|
||||
}
|
||||
|
||||
void
|
||||
genDialogCancelCallback( int *data )
|
||||
{
|
||||
*data=2;
|
||||
}
|
||||
|
||||
void
|
||||
genDialogOtherCallback( int *data )
|
||||
{
|
||||
*data=3;
|
||||
}
|
||||
// post_and_return takes a helpId, which is a string that is used to
|
||||
// reference the related help in the Mailer help volume. The helpId
|
||||
// is passed to post(), which will attach help to the help button in
|
||||
// the dialog.
|
||||
int
|
||||
DtMailGenDialog::post_and_return(char *helpId)
|
||||
{
|
||||
int answer = 0;
|
||||
XmString okLabel, cancelLabel;
|
||||
|
||||
// They may have been set via the overloaded post_and_return()
|
||||
// method before. Reset them to their default values...
|
||||
|
||||
okLabel = XmStringCreateLocalized(GETMSG(DT_catd, 1, 181, "OK"));
|
||||
cancelLabel = XmStringCreateLocalized(GETMSG(DT_catd, 1, 182, "Cancel"));
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( _w != NULL );
|
||||
|
||||
XtVaSetValues(_w,
|
||||
XmNokLabelString, okLabel,
|
||||
XmNcancelLabelString, cancelLabel,
|
||||
NULL);
|
||||
XmStringFree( okLabel);
|
||||
XmStringFree( cancelLabel);
|
||||
|
||||
Widget dialog;
|
||||
if (helpId) {
|
||||
dialog =
|
||||
this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) &genDialogCancelCallback,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) &HelpErrorCB,
|
||||
helpId
|
||||
);
|
||||
} else {
|
||||
dialog =
|
||||
this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) &genDialogCancelCallback,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) NULL,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
forceUpdate( dialog );
|
||||
while ( answer==0 )
|
||||
{
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
}
|
||||
|
||||
// Process just one more event to pop down dialog.
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
|
||||
return(answer);
|
||||
|
||||
}
|
||||
|
||||
// post_and_return(char *, char *) takes the string to be used for the
|
||||
// OK button and the string that contains the helpId for the dialog being
|
||||
// created, and passes them to post().
|
||||
int
|
||||
DtMailGenDialog::post_and_return(
|
||||
char *okLabelString,
|
||||
char *helpId
|
||||
)
|
||||
{
|
||||
int answer = 0;
|
||||
XmString okLabel;
|
||||
|
||||
okLabel = XmStringCreateLocalized(okLabelString);
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( _w != NULL );
|
||||
|
||||
XtVaSetValues(_w,
|
||||
XmNokLabelString, okLabel,
|
||||
NULL);
|
||||
XmStringFree( okLabel);
|
||||
|
||||
Widget dialog;
|
||||
if (helpId) {
|
||||
dialog = this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) &HelpErrorCB,
|
||||
helpId
|
||||
);
|
||||
} else {
|
||||
dialog = this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) NULL,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
forceUpdate( dialog );
|
||||
while ( answer==0 )
|
||||
{
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
}
|
||||
|
||||
// Process just one more event to pop down dialog.
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
|
||||
return(answer);
|
||||
|
||||
}
|
||||
|
||||
// post_and_return(char*, char*, char*) takes the OK button label, Cancel
|
||||
// button label, and the help id for the dialog and passes them to post().
|
||||
int
|
||||
DtMailGenDialog::post_and_return(
|
||||
char *okLabelString,
|
||||
char *cancelLabelString,
|
||||
char *helpId
|
||||
)
|
||||
{
|
||||
int answer = 0;
|
||||
XmString okLabel, cancelLabel;
|
||||
|
||||
okLabel = XmStringCreateLocalized(okLabelString);
|
||||
cancelLabel = XmStringCreateLocalized(cancelLabelString);
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( _w != NULL );
|
||||
|
||||
XtVaSetValues(_w,
|
||||
XmNokLabelString, okLabel,
|
||||
XmNcancelLabelString, cancelLabel,
|
||||
NULL);
|
||||
XmStringFree( okLabel);
|
||||
XmStringFree( cancelLabel);
|
||||
|
||||
Widget dialog = NULL;
|
||||
if (helpId) {
|
||||
dialog = this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) &genDialogCancelCallback,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) &HelpErrorCB,
|
||||
helpId
|
||||
);
|
||||
} else {
|
||||
dialog = this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) &genDialogCancelCallback,
|
||||
( DialogCallback ) NULL,
|
||||
( DialogCallback ) NULL,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
forceUpdate( dialog );
|
||||
while ( answer==0 )
|
||||
{
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll);
|
||||
}
|
||||
|
||||
// Process just one more event to pop down dialog.
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll);
|
||||
|
||||
return(answer);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
DtMailGenDialog::post_and_return(
|
||||
char *okLabelString,
|
||||
char *cancelLabelString,
|
||||
char *otherLabelString,
|
||||
char *helpId
|
||||
)
|
||||
{
|
||||
int answer = 0;
|
||||
XmString okLabel, cancelLabel, otherLabel;
|
||||
|
||||
okLabel = XmStringCreateLocalized(okLabelString);
|
||||
cancelLabel = XmStringCreateLocalized(cancelLabelString);
|
||||
otherLabel = XmStringCreateLocalized(otherLabelString);
|
||||
|
||||
|
||||
// Make sure the dialog exists, and that it is an XmMessageBox
|
||||
// or subclass, since the callbacks assume this widget type
|
||||
|
||||
assert ( _w != NULL );
|
||||
|
||||
Widget dialog = NULL;
|
||||
Widget cancel_w = XmMessageBoxGetChild ( _w, XmDIALOG_CANCEL_BUTTON );
|
||||
|
||||
if (_otherWidget == NULL) {
|
||||
_otherWidget = XtVaCreateWidget(otherLabelString,
|
||||
xmPushButtonGadgetClass, _w,
|
||||
XmNleftAttachment, XmMessageBoxGetChild ( _w,
|
||||
XmDIALOG_OK_BUTTON ),
|
||||
XmNrightAttachment, cancel_w,
|
||||
NULL);
|
||||
XtManageChild (_otherWidget);
|
||||
}
|
||||
|
||||
if (!XtIsManaged(_otherWidget)) {
|
||||
XtManageChild (_otherWidget);
|
||||
}
|
||||
if (!XtIsManaged ( cancel_w ) ) {
|
||||
XtManageChild ( cancel_w );
|
||||
}
|
||||
|
||||
XtVaSetValues(_w,
|
||||
XmNokLabelString, okLabel,
|
||||
XmNcancelLabelString, cancelLabel,
|
||||
NULL);
|
||||
XtVaSetValues(_otherWidget,
|
||||
XmNlabelString, otherLabel,
|
||||
NULL);
|
||||
XmStringFree( okLabel);
|
||||
XmStringFree( cancelLabel);
|
||||
XmStringFree( otherLabel);
|
||||
|
||||
if (helpId) {
|
||||
dialog = this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) &genDialogCancelCallback,
|
||||
( DialogCallback ) &genDialogOtherCallback,
|
||||
( DialogCallback ) &HelpErrorCB,
|
||||
helpId
|
||||
);
|
||||
} else {
|
||||
dialog =
|
||||
this->post((void *) &answer,
|
||||
( DialogCallback ) &genDialogOKCallback,
|
||||
( DialogCallback ) &genDialogCancelCallback,
|
||||
( DialogCallback ) &genDialogOtherCallback,
|
||||
( DialogCallback ) NULL,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
forceUpdate( dialog );
|
||||
while ( answer==0 )
|
||||
{
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
}
|
||||
|
||||
// Process just one more event to pop down dialog.
|
||||
XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
|
||||
|
||||
return(answer);
|
||||
|
||||
}
|
||||
void
|
||||
DtMailGenDialog::setDialog(char * title, char * text, unsigned char type)
|
||||
{
|
||||
XmString titleStr = XmStringCreateLocalized (title);
|
||||
XmString xmStr = XmStringCreateLocalized(text);
|
||||
XtVaSetValues ( _w,
|
||||
XmNmessageString, xmStr,
|
||||
XmNdialogTitle, titleStr,
|
||||
XmNdialogType, type,
|
||||
NULL );
|
||||
XmStringFree(xmStr);
|
||||
XmStringFree ( titleStr );
|
||||
_info_dialog = 0;
|
||||
}
|
||||
|
||||
char *
|
||||
DtMailGenDialog::getTextFieldValue()
|
||||
{
|
||||
if (_clearText) return strdup(_clearText);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
DtMailGenDialog::setToTextFieldDialog(
|
||||
char *title,
|
||||
char *text,
|
||||
int shroud
|
||||
)
|
||||
{
|
||||
if (NULL != _textField)
|
||||
{
|
||||
if (NULL != _clearText) *_clearText = '\0';
|
||||
XtVaSetValues(_textField, XmNvalue, "", NULL);
|
||||
XtManageChild(_textField);
|
||||
}
|
||||
else
|
||||
{
|
||||
_textField = XtVaCreateManagedWidget(
|
||||
"GenDialogTF", xmTextFieldWidgetClass, _w,
|
||||
XmNcolumns, 30,
|
||||
NULL);
|
||||
XtAddCallback(
|
||||
_textField,
|
||||
XmNmodifyVerifyCallback,DtMailGenDialog::verifyCallback,
|
||||
this);
|
||||
_maxTextlen = 256;
|
||||
_clearText = (char*) malloc(_maxTextlen);
|
||||
memset(_clearText, 0, _maxTextlen);
|
||||
assert(NULL!=_clearText);
|
||||
}
|
||||
_shroudText = shroud;
|
||||
setDialog(title, text, XmDIALOG_QUESTION);
|
||||
}
|
||||
|
||||
void
|
||||
DtMailGenDialog::setToQuestionDialog(
|
||||
char *title,
|
||||
char *text
|
||||
)
|
||||
{
|
||||
if (NULL != _textField && XtIsManaged(_textField))
|
||||
XtUnmanageChild(_textField);
|
||||
|
||||
setDialog(title, text, XmDIALOG_QUESTION);
|
||||
}
|
||||
|
||||
void
|
||||
DtMailGenDialog::setToWarningDialog(
|
||||
char *title,
|
||||
char *text
|
||||
)
|
||||
{
|
||||
if (NULL != _textField && XtIsManaged(_textField))
|
||||
XtUnmanageChild(_textField);
|
||||
|
||||
setDialog(title, text, XmDIALOG_WARNING);
|
||||
}
|
||||
|
||||
void
|
||||
DtMailGenDialog::setToErrorDialog(
|
||||
char *title,
|
||||
char *text
|
||||
)
|
||||
{
|
||||
if (NULL != _textField && XtIsManaged(_textField))
|
||||
XtUnmanageChild(_textField);
|
||||
|
||||
setDialog(title, text, XmDIALOG_ERROR);
|
||||
}
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
void
|
||||
DtMailGenDialog::setToInfoDialog(
|
||||
char *title,
|
||||
char *text
|
||||
)
|
||||
{
|
||||
if (NULL != _textField && XtIsManaged(_textField))
|
||||
XtUnmanageChild(_textField);
|
||||
|
||||
setDialog(title, text, XmDIALOG_INFORMATION);
|
||||
}
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
extern "C" Pixmap _DtGetMask(Screen * screen, char * image_name);
|
||||
|
||||
void
|
||||
DtMailGenDialog::setToAboutDialog(void)
|
||||
{
|
||||
if (doCredits) {
|
||||
setDialog((char *)"Credits",
|
||||
(char *)credits,
|
||||
XmDIALOG_INFORMATION);
|
||||
doCredits = 0;
|
||||
}
|
||||
else {
|
||||
if (NULL == ABOUT_TITLE) {
|
||||
char *version;
|
||||
|
||||
ABOUT_TITLE = GETMSG(DT_catd, 1, 235, "Mailer - About Mailer");
|
||||
version = GETMSG(DT_catd, 1, 236, "Mailer Version %d.%d.%d");
|
||||
|
||||
DTMAIL_VERSION = new char [strlen(version) + 16];
|
||||
sprintf(
|
||||
DTMAIL_VERSION, version,
|
||||
DtVERSION, DtREVISION, DtUPDATE_LEVEL);
|
||||
}
|
||||
setDialog((char *)ABOUT_TITLE,
|
||||
(char *)DTMAIL_VERSION,
|
||||
XmDIALOG_INFORMATION);
|
||||
}
|
||||
|
||||
_info_dialog = 1;
|
||||
|
||||
char * icon_filename = XmGetIconFileName(XtScreen(_w),
|
||||
NULL,
|
||||
"DtMail",
|
||||
NULL,
|
||||
DtLARGE);
|
||||
|
||||
if (icon_filename == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Pixmap fg, bg;
|
||||
|
||||
XtVaGetValues (_w,
|
||||
XmNforeground, &fg,
|
||||
XmNbackground, &bg,
|
||||
NULL);
|
||||
|
||||
Pixmap icon = XmGetPixmap(XtScreen(_w),
|
||||
icon_filename,
|
||||
fg, bg);
|
||||
|
||||
Pixmap icon_mask = _DtGetMask(XtScreen(_w), icon_filename);
|
||||
|
||||
Pixmap clipped_icon = icon;
|
||||
if (icon_mask) {
|
||||
Window root;
|
||||
int x, y;
|
||||
unsigned int width, height, border_width, depth;
|
||||
XGetGeometry(XtDisplay(_w),
|
||||
icon,
|
||||
&root,
|
||||
&x, &y,
|
||||
&width, &height,
|
||||
&border_width, &depth);
|
||||
|
||||
XtRealizeWidget(_w);
|
||||
|
||||
clipped_icon = XCreatePixmap(XtDisplay(_w),
|
||||
XtWindow(_w),
|
||||
width,
|
||||
height,
|
||||
depth);
|
||||
|
||||
XGCValues gc_vals;
|
||||
GC gc;
|
||||
memset(&gc_vals, 0, sizeof(gc_vals));
|
||||
gc_vals.background = bg;
|
||||
gc_vals.foreground = bg;
|
||||
gc_vals.fill_style = FillSolid;
|
||||
gc = XCreateGC(XtDisplay(_w),
|
||||
XtWindow(_w),
|
||||
GCForeground | GCBackground | GCFillStyle,
|
||||
&gc_vals);
|
||||
|
||||
XFillRectangle(XtDisplay(_w),
|
||||
clipped_icon,
|
||||
gc,
|
||||
0, 0,
|
||||
width, height);
|
||||
|
||||
XFreeGC(XtDisplay(_w), gc);
|
||||
|
||||
memset(&gc_vals, 0, sizeof(gc_vals));
|
||||
gc_vals.background = bg;
|
||||
gc = XCreateGC(XtDisplay(_w),
|
||||
XtWindow(_w),
|
||||
GCBackground,
|
||||
&gc_vals);
|
||||
|
||||
XSetClipMask(XtDisplay(_w), gc, icon_mask);
|
||||
|
||||
XCopyArea(XtDisplay(_w),
|
||||
icon,
|
||||
clipped_icon,
|
||||
gc,
|
||||
0, 0,
|
||||
width, height,
|
||||
0, 0);
|
||||
XFreeGC(XtDisplay(_w), gc);
|
||||
}
|
||||
|
||||
XtVaSetValues ( _w,
|
||||
XmNsymbolPixmap, clipped_icon,
|
||||
NULL );
|
||||
|
||||
if (NULL != _textField && XtIsManaged(_textField))
|
||||
XtUnmanageChild(_textField);
|
||||
|
||||
}
|
||||
88
cde/programs/dtmail/dtmail/DtMailGenDialog.hh
Normal file
88
cde/programs/dtmail/dtmail/DtMailGenDialog.hh
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: DtMailGenDialog.hh /main/7 1998/02/04 18:38:09 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// DtMailGenDialog.hh: A generic dialog based on MessageBox
|
||||
//////////////////////////////////////////////////////////
|
||||
#ifndef DTMAILGENDIALOG_HH
|
||||
#define DTMAILGENDIALOG_HH
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <Xm/TextF.h>
|
||||
#include "UIComponent.h"
|
||||
#include "DtMailDialogCallbackData.hh"
|
||||
|
||||
class DtMailGenDialog : public UIComponent {
|
||||
|
||||
private:
|
||||
int _info_dialog;
|
||||
Widget _otherWidget;
|
||||
Widget _parentshell;
|
||||
|
||||
Widget _textField;
|
||||
int _shroudText;
|
||||
int _maxTextlen;
|
||||
char *_clearText;
|
||||
|
||||
void cleanup ( Widget, DtMailDialogCallbackData* );
|
||||
|
||||
protected:
|
||||
|
||||
void forceUpdate( Widget );
|
||||
|
||||
static void okCallback(Widget, XtPointer, XtPointer);
|
||||
static void cancelCallback(Widget, XtPointer, XtPointer);
|
||||
static void helpCallback(Widget, XtPointer, XtPointer);
|
||||
static void otherCallback(Widget, XtPointer, XtPointer);
|
||||
|
||||
static void verifyCallback(Widget, XtPointer, XtPointer);
|
||||
void verify(XmTextVerifyPtr cbs);
|
||||
|
||||
void setDialog(char * title, char * text, unsigned char type);
|
||||
|
||||
public:
|
||||
|
||||
DtMailGenDialog(char*,Widget, int style=XmDIALOG_PRIMARY_APPLICATION_MODAL);
|
||||
~DtMailGenDialog() { if (NULL != _clearText) free(_clearText); };
|
||||
|
||||
char *getTextFieldValue(void);
|
||||
|
||||
void setToTextFieldDialog(char *, char *, int shroud = FALSE);
|
||||
void setToQuestionDialog(char *, char *);
|
||||
#ifdef DEAD_WOOD
|
||||
void setToInfoDialog(char *, char *);
|
||||
#endif /* DEAD_WOOD */
|
||||
void setToErrorDialog(char *, char *);
|
||||
void setToWarningDialog(char *, char *);
|
||||
void setToAboutDialog(void);
|
||||
|
||||
virtual Widget post (
|
||||
void *clientData = NULL,
|
||||
DialogCallback ok = NULL,
|
||||
DialogCallback cancel = NULL,
|
||||
DialogCallback other = NULL,
|
||||
DialogCallback help = NULL,
|
||||
char *helpId = NULL);
|
||||
virtual int post_and_return(char *);
|
||||
virtual int post_and_return(char *, char *);
|
||||
virtual int post_and_return(char *, char *, char *);
|
||||
virtual int post_and_return(char *, char *, char *, char *);
|
||||
};
|
||||
#endif
|
||||
138
cde/programs/dtmail/dtmail/DtMailHelp.hh
Normal file
138
cde/programs/dtmail/dtmail/DtMailHelp.hh
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: DtMailHelp.hh /main/5 1996/04/21 19:41:42 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef DTMAILHELP_HH
|
||||
#define DTMAILHELP_HH
|
||||
|
||||
// Help Ids for dtmail.
|
||||
|
||||
#define DTMAILWINDOWID "_HOMETOPIC"
|
||||
|
||||
// RoamMenuWindow
|
||||
#define DTMAILWINDOWMAILBOXMENU "DTMAILVIEWMAINWINDOWMENUBARFILE"
|
||||
#define DTMAILWINDOWMESSAGEMENU "DTMAILVIEWMAINWINDOWMENUBARMESSAGE"
|
||||
#define DTMAILWINDOWEDITMENU "DTMAILVIEWMAINWINDOWMENUBAREDIT"
|
||||
#define DTMAILWINDOWATTACHMENTSMENU "DTMAILVIEWMAINWINDOWMENUBARATTACH"
|
||||
#define DTMAILWINDOWVIEWMENU "DTMAILVIEWMAINWINDOWMENUBARVIEW"
|
||||
#define DTMAILWINDOWCOMPOSEMENU "DTMAILVIEWMAINWINDOWMENUBARCOMPOSE"
|
||||
#define DTMAILWINDOWMOVEMENU "DTMAILVIEWMAINWINDOWMENUBARMOVE"
|
||||
#define DTMAILWINDOWROWOFLABELSID "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWOFLABELS"
|
||||
#define DTMAILMSGLISTID "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2MESSAGELISTSWMESSAGELIST"
|
||||
#define DTMAILNEXTBTNID "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWCOLUMNNEXT"
|
||||
#define DTMAILPREVBTNID "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWCOLUMNPREVIOUS"
|
||||
#define DTMAILDELBTNID "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWCOLUMNDELETE"
|
||||
#define DTMAILPRINTBTNID "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWCOLUMNPRINT"
|
||||
#define DTMAILREPLYBTNID "DTMAILVIEWMAINWINDOWWORK-AREAPANEDWFORM2ROWCOLUMNREPLY"
|
||||
#define APP_MENU_ID "onApplicationMenu"
|
||||
#define VER_MENU_ID "_copyright"
|
||||
|
||||
// SendMsgDialog
|
||||
#define DTMAILCOMPOSEWINDOW "DTMAILCOMPOSEWINDOW"
|
||||
#define DTMAILCOMPOSEFILEMENU "DTMAILCOMPOSEWINDOWMENUBARFILE"
|
||||
#define DTMAILCOMPOSEEDITMENU "DTMAILCOMPOSEWINDOWMENUBAREDIT"
|
||||
#define DTMAILCOMPOSEATTACHMENU "DTMAILCOMPOSEWINDOWMENUBARATTACH"
|
||||
#define DTMAILCOMPOSEFORMATMENU "DTMAILCOMPOSEWINDOWMENUBARFORMAT"
|
||||
|
||||
// Find Message Dialog
|
||||
#define DTMAILFINDDIALOG "DTMAILVIEWMAINWINDOWMESSAGEFIND"
|
||||
|
||||
// Other Mailboxes Dialog
|
||||
#define DTMAILOTHERMAILBOXESDIALOG "DTMAILVIEWMAINWINDOWMOVEMAILBOX"
|
||||
|
||||
// Undelete Messages From List Dialog
|
||||
#define DTMAILUNDELETEFROMLISTDIALOG "DTMAILVIEWMAINWINDOWMESSAGEUNDELETELIST"
|
||||
|
||||
// Rename Attachment Dialog
|
||||
#define DTMAILRENAMEATTACHMENTDIALOG "DTMAILVIEWMAINWINDOWATTACHRENAME"
|
||||
|
||||
// Mailer Format Settings Dialog
|
||||
#define DTMAILCOMPOSEFORMATDIALOG "DTMAILCOMPOSEWINDOWFORMATSETTINGS"
|
||||
|
||||
// Mailer PrintSetupDialog
|
||||
#define DTMAILPRINTSETUPDIALOG "DTMAILPRINTSETUPDIALOG"
|
||||
|
||||
// Mailer Options Dialogs
|
||||
#define DTMAILOPTIONSHEADERLISTDIALOG "DTMAILMAILBOXOPTIONSMESSAGEHEADERLIST"
|
||||
#define DTMAILOPTIONSVIEWDIALOG "DTMAILMAILBOXOPTIONSMESSAGEVIEW"
|
||||
#define DTMAILOPTIONSCOMPOSEDIALOG "DTMAILMAILBOXOPTIONSCOMPOSEWINDOW"
|
||||
#define DTMAILOPTIONSMESSAGEFILINGDIALOG "DTMAILMAILBOXOPTIONSMESSAGEFILING"
|
||||
#define DTMAILOPTIONSVACATIONDIALOG "DTMAILMAILBOXOPTIONSVACATION"
|
||||
#define DTMAILOPTIONSTEMPLATESDIALOG "DTMAILMAILBOXOPTIONSTEMPLATES"
|
||||
#define DTMAILOPTIONSALIASDIALOG "DTMAILMAILBOXOPTIONSALIASES"
|
||||
#define DTMAILOPTIONSADVANCEDDIALOG "DTMAILMAILBOXOPTIONSADVANCED"
|
||||
|
||||
// These helpIds are for the help button in dialogs.
|
||||
#define DTMAILHELPCANTINITTOOLTALK "DTMAILHELPCANTINITTOOLTALK"
|
||||
#define DTMAILHELPCREATEINBOX "DTMAILHELPCREATEINBOX"
|
||||
#define DTMAILHELPCONVERTINBOX "DTMAILHELPCONVERTINBOX"
|
||||
#define DTMAILHELPCREATECONTAINER "DTMAILCREATECONTAINERHELP"
|
||||
#define DTMAILHELPTAKELOCK "DTMAILHELPTAKELOCK"
|
||||
#define DTMAILHELPBADGROUPID "DTMAILHELPNOINSTALLMAIL"
|
||||
#define DTMAILHELPUNKNOWNSTATE "DTMAILHELPUNKNOWNSTATE"
|
||||
#define DTMAILHELPFATALERROR "DTMAILHELPFATALERROR"
|
||||
#define DTMAILHELPERROR "DTMAILHELPERROR"
|
||||
#define DTMAILHELPCLOSECOMPOSEWINDOW "DTMAILHELPCLOSECOMPOSEWINDOW"
|
||||
#define DTMAILHELPPENDINGACTIONS "DTMAILHELPSENDLOSEATTACH"
|
||||
#define DTMAILHELPSELECTONEATTACH "DTMAILHELPSELECTONEATTACH"
|
||||
#define DTMAILHELPBADADDRESS "DTMAILHELPUNKNOWNUSER"
|
||||
#define DTMAILHELPNOMEMORY "DTMAILHELPNOMEMORY"
|
||||
#define DTMAILHELPTRANSPORTFAILED "DTMAILHELPNOSEND"
|
||||
#define DTMAILHELPOKSTARTVACATION "DTMAILHELPOKSTARTVACATION"
|
||||
#define DTMAILHELPREMOVEVACATION "DTMAILHELPREMOVEVACATION"
|
||||
#define DTMAILHELPNOWRITEVACATION "DTMAILHELPNOWRITEVACATION"
|
||||
#define DTMAILHELPEXISTSVACATION "DTMAILHELPEXISTSVACATION"
|
||||
#define DTMAILHELPNOCOMPOSE "DTMAILHELPNOCOMPOSE"
|
||||
#define DTMAILHELPNOTEMPLATE "DTMAILHELPNOTEMPLATE"
|
||||
#define DTMAILHELPCORRUPTTEMPLATE "DTMAILHELPCORRUPTTEMPLATE"
|
||||
#define DTMAILHELPNOMEMTEMPLATE "DTMAILHELPNOMEMTEMPLATE"
|
||||
#define DTMAILHELPNOVIEW "DTMAILHELPNOVIEW"
|
||||
#define DTMAILHELPDIRECTORYONLY "DTMAILHELPDIRECTORYONLY"
|
||||
#define DTMAILHELPSELECTATTACH "DTMAILHELPSELECTATTACH"
|
||||
#define DTMAILHELPDESTROYMARKMSG "DTMAILHELPDESTROYMARKMSG"
|
||||
#define DTMAILHELPNOOPEN "DTMAILHELPNOOPEN"
|
||||
#define DTMAILHELPNOALLOCMEM "DTMAILHELPNOALLOCMEM"
|
||||
#define DTMAILHELPALREADYEXISTS "DTMAILHELPALREADYEXISTS"
|
||||
#define DTMAILHELPNOREPLACE "DTMAILHELPNOREPLACE"
|
||||
#define DTMAILHELPNOCREATE "DTMAILHELPNOCREATE"
|
||||
#define DTMAILHELPNOOVERWRITE "DTMAILHELPNOOVERWRITE"
|
||||
#define DTMAILHELPNOWRITE "DTMAILHELPNOWRITE"
|
||||
#define DTMAILHELPNOLOADVACATION "DTMAILHELPNOLOADVACATION"
|
||||
#define DTMAILHELPCORRUPTVACATION "DTMAILHELPCORRUPTVACATION"
|
||||
#define DTMAILHELPNEEDADDRESSEE "DTMAILHELPNEEDADDRESSEE"
|
||||
#define DTMAILHELPEXECUTEOK "DTMAILHELPEXECUTEOK"
|
||||
#define DTMAILHELPOPENREADONLY "DTMAILHELPOPENREADONLY"
|
||||
#define DTMAILHELPOPENREADWRITEOVERRIDE "DTMAILHELPOPENREADWRITEOVERRIDE"
|
||||
|
||||
// Option defines for menubar help access
|
||||
#define HELP_MAILER_TASKS "Tasks"
|
||||
#define HELP_MAILER_REFERENCE "Reference"
|
||||
|
||||
char *getHelpId(Widget);
|
||||
void printHelpId(char *, Widget);
|
||||
#ifdef DEAD_WOOD
|
||||
void HelpMenuCB(Widget, XtPointer, XtPointer);
|
||||
#endif /* DEAD_WOOD */
|
||||
void HelpCB(Widget, XtPointer, XtPointer);
|
||||
extern void DisplayMain(Widget, char *, char *);
|
||||
extern void DisplayVersion(Widget, char *, char *);
|
||||
static void CloseMainCB(Widget, XtPointer, XtPointer);
|
||||
|
||||
#endif
|
||||
|
||||
122
cde/programs/dtmail/dtmail/DtMailWDM.C
Normal file
122
cde/programs/dtmail/dtmail/DtMailWDM.C
Normal file
@@ -0,0 +1,122 @@
|
||||
/* $XConsortium: DtMailWDM.C /main/3 1996/04/21 19:41:45 drk $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// DtMailWDM.C
|
||||
//////////////////////////////////////////////////////////
|
||||
#include "DtMailWDM.hh"
|
||||
#include "Application.h"
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/MessageB.h>
|
||||
#include "BusyPixmap.h"
|
||||
#include <assert.h>
|
||||
|
||||
DtMailWDM *theDtMailWDM =
|
||||
new DtMailWDM ( "DtMailWDM" );
|
||||
|
||||
DtMailWDM::DtMailWDM ( char *name )
|
||||
: WorkingDialogManager ( name )
|
||||
{
|
||||
_text = NULL;
|
||||
}
|
||||
|
||||
|
||||
Widget
|
||||
DtMailWDM::post (char *title,
|
||||
char *text,
|
||||
void *clientData,
|
||||
DialogCallback ok,
|
||||
DialogCallback cancel,
|
||||
DialogCallback help )
|
||||
{
|
||||
// The the dialog already exists, and is currently in use,
|
||||
// just return this dialog. The DtMailWDM
|
||||
// only supports one dialog.
|
||||
|
||||
if ( _w && XtIsManaged ( _w ) )
|
||||
return _w;
|
||||
|
||||
// Pass the message on to the base class
|
||||
|
||||
DialogManager::post (title, text, clientData, ok, cancel, help );
|
||||
|
||||
forceUpdate( _w );
|
||||
return _w;
|
||||
}
|
||||
|
||||
Widget
|
||||
DtMailWDM::post (char *title,
|
||||
char *text,
|
||||
Widget wid,
|
||||
void *clientData,
|
||||
DialogCallback ok,
|
||||
DialogCallback cancel,
|
||||
DialogCallback help )
|
||||
{
|
||||
// The the dialog already exists, and is currently in use,
|
||||
// just return this dialog. The DtMailWDM
|
||||
// only supports one dialog.
|
||||
|
||||
if ( _w && XtIsManaged ( _w ) )
|
||||
return _w;
|
||||
|
||||
// Pass the message on to the base class
|
||||
|
||||
DialogManager::post (title, text, wid, clientData, ok, cancel, help );
|
||||
|
||||
forceUpdate( _w );
|
||||
return _w;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DtMailWDM::updateAnimation()
|
||||
{
|
||||
if (_w) {
|
||||
XtVaSetValues ( _w,
|
||||
// XmNsymbolPixmap, _busyPixmaps->next(),
|
||||
NULL );
|
||||
forceUpdate( _w );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DtMailWDM::updateDialog(
|
||||
char *text
|
||||
)
|
||||
{
|
||||
|
||||
if ( _w )
|
||||
{
|
||||
|
||||
// Just change the string displayed in the dialog
|
||||
|
||||
XmString xmstr = XmStringCreateLocalized ( text );
|
||||
|
||||
// Update the pixmap too...
|
||||
XtVaSetValues ( _w,
|
||||
// XmNsymbolPixmap, _busyPixmaps->next(),
|
||||
XmNmessageString, xmstr,
|
||||
NULL );
|
||||
XmStringFree ( xmstr );
|
||||
|
||||
}
|
||||
|
||||
forceUpdate( _w );
|
||||
}
|
||||
60
cde/programs/dtmail/dtmail/DtMailWDM.hh
Normal file
60
cde/programs/dtmail/dtmail/DtMailWDM.hh
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: DtMailWDM.hh /main/4 1996/04/21 19:41:48 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// DtMailWDM.hh
|
||||
//////////////////////////////////////////////////////////
|
||||
#ifndef DTMAILWDM_HH
|
||||
#define DTMAILWDM_HH
|
||||
|
||||
#include "WorkingDialogManager.h"
|
||||
|
||||
class DtMailWDM : public WorkingDialogManager {
|
||||
|
||||
protected:
|
||||
|
||||
char *_text;
|
||||
|
||||
public:
|
||||
|
||||
DtMailWDM ( char * );
|
||||
|
||||
virtual Widget post (char *,
|
||||
char *,
|
||||
Widget ,
|
||||
void *clientData = NULL,
|
||||
DialogCallback ok = NULL,
|
||||
DialogCallback cancel = NULL,
|
||||
DialogCallback help = NULL );
|
||||
|
||||
virtual Widget post (char *,
|
||||
char *,
|
||||
void *clientData = NULL,
|
||||
DialogCallback ok = NULL,
|
||||
DialogCallback cancel = NULL,
|
||||
DialogCallback help = NULL );
|
||||
|
||||
void updateAnimation();
|
||||
void updateDialog(char *msg);
|
||||
};
|
||||
|
||||
extern DtMailWDM *theDtMailWDM;
|
||||
|
||||
#endif
|
||||
314
cde/programs/dtmail/dtmail/Dtmail
Normal file
314
cde/programs/dtmail/dtmail/Dtmail
Normal file
@@ -0,0 +1,314 @@
|
||||
!######################################################################
|
||||
!#
|
||||
!# Dtmail
|
||||
!#
|
||||
!# Common Desktop Environment (CDE)
|
||||
!#
|
||||
!# Application Defaults for the CDE Mailer
|
||||
!#
|
||||
!# (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
!# (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
!# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
!# (c) Copyright 1993, 1994 Novell, Inc.
|
||||
!#
|
||||
!#
|
||||
!######################################################################
|
||||
#include "Dt"
|
||||
|
||||
Dtmail*Font: %|nls-107-#Font#|
|
||||
|
||||
!######################################################################
|
||||
!#
|
||||
!# Formatting for the printing output.
|
||||
!#
|
||||
!######################################################################
|
||||
!#
|
||||
!# Formatting when printing to printer.
|
||||
!#
|
||||
|
||||
!# Sizes the PrintShell.
|
||||
Dtmail*Print.width: 8.5in
|
||||
Dtmail*Print.height: 11.0in
|
||||
Dtmail*Print.Page*foreground: black
|
||||
Dtmail*Print.Page*background: white
|
||||
|
||||
!# Places a border around the text portion of the output.
|
||||
Dtmail*Print.Page*shadowThickness: 2
|
||||
Dtmail*Print.Page*topShadowColor: black
|
||||
Dtmail*Print.Page*bottomShadowColor: black
|
||||
|
||||
!# Controls margins and background of the header and footer labels.
|
||||
Dtmail*Print.Page*XmLabel.marginBottom: 0.0in
|
||||
Dtmail*Print.Page*XmLabel.marginTop: 0.0in
|
||||
!Dtmail*Print.Page*XmLabel.background: grey
|
||||
|
||||
!# Fonts for headers, footers, and text.
|
||||
Dtmail*Print.Page*XmLabel.renderTable: %|nls-105-#HeaderLeft#|
|
||||
Dtmail*Print.Page*Editor.renderTable: %|nls-106-#Editor#|
|
||||
|
||||
!#
|
||||
!# Formatting when "printing" to video.
|
||||
!# Debugging only
|
||||
!#
|
||||
Dtmail*PrintVideo.width: 8.5in
|
||||
Dtmail*PrintVideo.height: 9.5in
|
||||
Dtmail*PrintVideo.Page.width: 8.5in
|
||||
Dtmail*PrintVideo.Page.height: 9.5in
|
||||
Dtmail*PrintVideo.Page*foreground: black
|
||||
Dtmail*PrintVideo.Page*background: white
|
||||
|
||||
Dtmail*PrintVideo.Page*shadowThickness: 2
|
||||
Dtmail*PrintVideo.Page*topShadowColor: black
|
||||
Dtmail*PrintVideo.Page*bottomShadowColor: black
|
||||
|
||||
Dtmail*PrintVideo.Page*XmLabel.marginTop: 0.0
|
||||
Dtmail*PrintVideo.Page*XmLabel.marginBottom: 0.0
|
||||
!Dtmail*PrintVideo.Page*XmLabel.background: grey
|
||||
|
||||
|
||||
!######################################################################
|
||||
!#
|
||||
!# Formatting for the Print Setup dialog.
|
||||
!#
|
||||
!######################################################################
|
||||
Dtmail*PrintingOptionsPane*leftOffset: 50
|
||||
Dtmail*PrintingOptionsPane*verticalSpacing: 5
|
||||
|
||||
Dtmail*Message_List*doubleClickInterval: 400
|
||||
|
||||
!######
|
||||
!# Examples of overriding default values
|
||||
!#
|
||||
!# Dtmail*UserFont: -b&h-lucidatypewriter-medium-r-*-sans-*-120-*-*-*-*-*
|
||||
!# Dtmail*SystemFont: -b&h-lucida-medium-r-*-sans-*-120-*-*-*-*-*-*
|
||||
!# Dtmail*GlyphFont: -adobe-symbol-*-*-*-*-*-100-*-*-*-*-adobe-fontspecific
|
||||
!#
|
||||
!# Dtmail*Work_Area*Text*foreground: black
|
||||
!# Dtmail*Work_Area*Text*background: white
|
||||
!# Dtmail*Message_List*foreground: black
|
||||
!# Dtmail*Message_List*background: white
|
||||
|
||||
|
||||
!#
|
||||
!# The width of header fields in the compose window.
|
||||
!#
|
||||
!# The following is changed by IBM.
|
||||
!# Dtmail*ComposeDialog*HeaderArea*form_*columns: 70
|
||||
Dtmail*ComposeDialog*HeaderArea*form_*columns: %|nls-200-#IBM#|
|
||||
|
||||
|
||||
!# The text fields column width in Find dialog
|
||||
Dtmail*find*To.columns: 1
|
||||
Dtmail*find*From.columns: 1
|
||||
Dtmail*find*Subject.columns: 1
|
||||
Dtmail*find*Cc.columns: 1
|
||||
|
||||
|
||||
!######################################################################
|
||||
!#
|
||||
!# The Compose Dialog accelerators and Text for those accelerators
|
||||
!#
|
||||
Dtmail*Send.acceleratorText: %|nls-1-#F3#|
|
||||
Dtmail*menubar*Send.accelerator: %|nls-2-#<Key>F3#|
|
||||
Dtmail*ComposeDialog*menubar*File.Close.acceleratorText: %|nls-3-#Alt+F4#|
|
||||
Dtmail*ComposeDialog*menubar*File.Close.accelerator: %|nls-4-#Alt<Key>F4#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Undo.acceleratorText: %|nls-5-#Ctrl+Z#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Undo.accelerator: %|nls-6-#Ctrl<Key>Z#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Cut.acceleratorText: %|nls-7-#Ctrl+X#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Cut.accelerator: %|nls-8-#Ctrl<Key>X#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Copy.acceleratorText: %|nls-9-#Ctrl+C#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Copy.accelerator: %|nls-10-#Ctrl<Key>C#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Paste.acceleratorText: %|nls-11-#Ctrl+v#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Paste.accelerator: %|nls-12-#Ctrl<Key>V#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Delete.acceleratorText: %|nls-13-#Delete#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Delete.accelerator: %|nls-14-#Delete#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Find/Change.acceleratorText: %|nls-15-#Ctrl+F#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Find/Change.accelerator: %|nls-16-#Ctrl<Key>F#|
|
||||
|
||||
|
||||
!#############################################################
|
||||
!#
|
||||
!# The Main Mailer accelerators and Text for those accelerators
|
||||
!#
|
||||
Dtmail*menubar*Mailbox.Check_for_New_Mail.acceleratorText: %|nls-17-#Ctrl+M#|
|
||||
Dtmail*menubar*Mailbox.Check_for_New_Mail.accelerator: %|nls-18-#Ctrl<Key>M#|
|
||||
Dtmail*menubar*Mailbox.Mail_Options.acceleratorText: %|nls-19-#Ctrl+I#|
|
||||
Dtmail*menubar*Mailbox.Mail_Options.accelerator: %|nls-20-#Ctrl<Key>I#|
|
||||
Dtmail*menubar*Mailbox.Close.acceleratorText: %|nls-21-#Alt+F4#|
|
||||
Dtmail*menubar*Mailbox.Close.accelerator: %|nls-22-#Alt<Key>F4#|
|
||||
Dtmail*menubar*Message*Print.acceleratorText: %|nls-23-#Ctrl+P#|
|
||||
Dtmail*menubar*Message*Print.accelerator: %|nls-24-#Ctrl<Key>P#|
|
||||
Dtmail*menubar*Edit.Copy.acceleratorText: %|nls-25-#Ctrl+C#|
|
||||
Dtmail*menubar*Edit.Copy.accelerator: %|nls-26-#Ctrl<Key>C#|
|
||||
Dtmail*menubar*Compose.New_Message.acceleratorText: %|nls-27-#Ctrl+N#|
|
||||
Dtmail*menubar*Compose.New_Message.accelerator: %|nls-28-#Ctrl<Key>N#|
|
||||
Dtmail*menubar*Compose.Reply_to_Sender.acceleratorText: %|nls-29-#Ctrl+R#|
|
||||
Dtmail*menubar*Compose.Reply_to_Sender.accelerator: %|nls-30-#Ctrl<Key>R#|
|
||||
|
||||
!#############################################################
|
||||
!#
|
||||
!# The Compose Dialog's mnemonic's
|
||||
!#
|
||||
Dtmail*ComposeDialog*menubar*File.mnemonic: %|nls-31-#F#|
|
||||
Dtmail*ComposeDialog*menubar*File.Include.mnemonic: %|nls-32-#I#|
|
||||
Dtmail*Save_As.mnemonic: %|nls-33-#A#|
|
||||
Dtmail*ComposeDialog*menubar*File.Log_Message.mnemonic: %|nls-34-#L#|
|
||||
Dtmail*menubar*Send.mnemonic: %|nls-35-#S#|
|
||||
Dtmail*ComposeDialog*menubar*File.Send_As.mnemonic: %|nls-36-#n#|
|
||||
Dtmail*ComposeDialog*menubar*File.Close.mnemonic: %|nls-37-#C#|
|
||||
Dtmail*ComposeDialog*Undo.mnemonic: %|nls-38-#U#|
|
||||
Dtmail*ComposeDialog*Cut.mnemonic: %|nls-39-#t#|
|
||||
Dtmail*Copy.mnemonic: %|nls-40-#C#|
|
||||
Dtmail*ComposeDialog*Paste.mnemonic: %|nls-41-#P#|
|
||||
Dtmail*menubar*Delete.mnemonic: %|nls-42-#D#|
|
||||
Dtmail*RoamMsgsPopup*Delete.mnemonic: %|nls-42-#D#|
|
||||
Dtmail*Select_All.mnemonic: %|nls-43-#S#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Find/Change.mnemonic: %|nls-44-#F#|
|
||||
Dtmail*ComposeDialog*menubar*Edit.Check_Spelling.mnemonic: %|nls-45-#k#|
|
||||
Dtmail*ComposeDialog*Add_File.mnemonic: %|nls-46-#F#|
|
||||
Dtmail*ComposeDialog*Undelete.mnemonic: %|nls-47-#U#|
|
||||
Dtmail*ComposeDialog*menubar*Attachments.Rename.mnemonic: %|nls-48-#R#|
|
||||
Dtmail*ComposeDialog*menubar*Attachments.Show_List.mnemonic: %|nls-49-#L#|
|
||||
Dtmail*ComposeDialog*menubar*Format.mnemonic: %|nls-50-#r#|
|
||||
Dtmail*ComposeDialog*menubar*Format.Word_Wrap.mnemonic: %|nls-51-#W#|
|
||||
Dtmail*ComposeDialog*menubar*Format.Settings.mnemonic: %|nls-52-#S#|
|
||||
Dtmail*ComposeDialog*menubar*Format.Templates.mnemonic: %|nls-53-#T#|
|
||||
Dtmail*ComposeDialog*menubar*Format.Add_Bcc.mnemonic: %|nls-54-#B#|
|
||||
|
||||
!######################################################################
|
||||
!#
|
||||
!# The Main Mailer mnemonic's
|
||||
!#
|
||||
Dtmail*menubar*Mailbox.mnemonic: %|nls-55-#x#|
|
||||
Dtmail*menubar*Check_for_New_Mail.mnemonic: %|nls-56-#M#|
|
||||
Dtmail*RoamMsgsPopup*Check_for_New_Mail.mnemonic: %|nls-56-#M#|
|
||||
Dtmail*menubar*Mailbox.Open_Inbox.mnemonic: %|nls-57-#I#|
|
||||
Dtmail*menubar*Mailbox.New.mnemonic: %|nls-58-#N#|
|
||||
Dtmail*menubar*Mailbox.Open.mnemonic: %|nls-59-#O#|
|
||||
Dtmail*menubar*Mailbox.Destroy_Deleted_Message.mnemonic: %|nls-60-#D#|
|
||||
Dtmail*menubar*Mailbox.Mail_Options.mnemonic: %|nls-61-#p#|
|
||||
Dtmail*menubar*Mailbox.Close.mnemonic: %|nls-62-#C#|
|
||||
Dtmail*menubar*Message.mnemonic: %|nls-63-#M#|
|
||||
Dtmail*menubar*Message*Open.mnemonic: %|nls-64-#O#|
|
||||
Dtmail*menubar*Save_As_Text.mnemonic: %|nls-65-#A#|
|
||||
Dtmail*RoamMsgsPopup*Save_As_Text.mnemonic: %|nls-65-#A#|
|
||||
Dtmail*menubar*Message*Copy_To.mnemonic: %|nls-66-#C#|
|
||||
Dtmail*menubar*Print.mnemonic: %|nls-67-#P#|
|
||||
Dtmail*RoamMsgsPopup*Print.mnemonic: %|nls-67-#P#|
|
||||
Dtmail*menubar*Message*Find.mnemonic: %|nls-68-#F#|
|
||||
Dtmail**menubar*Undelete_Last.mnemonic: %|nls-69-#L#|
|
||||
Dtmail*RoamMsgsPopup*Undelete_Last.menemonic: %|nls-69-#L#|
|
||||
Dtmail*menubar*Message*Undelete_From_List.mnemonic: %|nls-70-#U#|
|
||||
Dtmail*menubar*Edit.mnemonic: %|nls-71-#E#|
|
||||
Dtmail*menubar*Attachments.mnemonic: %|nls-72-#A#|
|
||||
Dtmail*menubar*View.mnemonic: %|nls-73-#V#|
|
||||
Dtmail*menubar*View.Next.mnemonic: %|nls-74-#N#|
|
||||
Dtmail*menubar*View.Previous.mnemonic: %|nls-75-#P#|
|
||||
Dtmail*menubar*View.Abbreviated_Headers.mnemonic: %|nls-76-#A#|
|
||||
Dtmail*menubar*View.By_Date/Time.mnemonic: %|nls-77-#D#|
|
||||
Dtmail*menubar*View.By_Sender.mnemonic: %|nls-78-#S#|
|
||||
Dtmail*menubar*View.By_Subject.mnemonic: %|nls-79-#b#|
|
||||
Dtmail*menubar*View.By_Size.mnemonic: %|nls-80-#z#|
|
||||
Dtmail*menubar*View.By_Status.mnemonic: %|nls-81-#t#|
|
||||
Dtmail*menubar*Compose.mnemonic: %|nls-82-#p#|
|
||||
Dtmail*menubar*Compose.New_Message.mnemonic: %|nls-83-#M#|
|
||||
Dtmail*menubar*Compose.New__Include_All.mnemonic: %|nls-84-#N#|
|
||||
Dtmail*menubar*Compose.Forward_Message.mnemonic: %|nls-85-#F#|
|
||||
Dtmail*menubar*Reply_to_Sender.mnemonic: %|nls-86-#R#|
|
||||
Dtmail*RoamMsgsPopup*Reply_to_Sender.mnemonic: %|nls-86-#R#|
|
||||
Dtmail*menubar*Compose.Reply_to_All.mnemonic: %|nls-87-#A#|
|
||||
Dtmail*menubar*Compose.Reply_to_Sender__Include.mnemonic: %|nls-88-#S#|
|
||||
Dtmail*menubar*Compose.Reply_to_All__Include.mnemonic: %|nls-89-#I#|
|
||||
Dtmail*menubar*Move.mnemonic: %|nls-90-#o#|
|
||||
Dtmail*RoamMsgsPopup*Move.mnemonic: %|nls-90-#o#|
|
||||
Dtmail*Inbox.mnemonic: %|nls-91-#I#|
|
||||
Dtmail*Other_Mailboxes.mnemonic: %|nls-92-#O#|
|
||||
Dtmail*menubar*Help.mnemonic: %|nls-93-#H#|
|
||||
Dtmail*menubar*Help.Overview.mnemonic: %|nls-94-#v#|
|
||||
Dtmail*menubar*Help.Tasks.mnemonic: %|nls-95-#T#|
|
||||
Dtmail*menubar*Help.Reference.mnemonic: %|nls-96-#R#|
|
||||
Dtmail*menubar*Help.On_Item.mnemonic: %|nls-97-#O#|
|
||||
Dtmail*menubar*Help.Using_Help.mnemonic: %|nls-98-#U#|
|
||||
Dtmail*menubar*Help.About_Mailer.mnemonic: %|nls-99-#A#|
|
||||
|
||||
!##################################################################################
|
||||
####
|
||||
!#
|
||||
!# Some more Main Mailer accelerators and Text
|
||||
!#
|
||||
Dtmail*menubar*Message*Delete.acceleratorText: %|nls-100-#Ctrl+D#|
|
||||
Dtmail*menubar*Message*Delete.accelerator: %|nls-101-#Ctrl<Key>D#|
|
||||
|
||||
!##################################################################################
|
||||
####
|
||||
!# More Mnemonics for Compose window Edit menu
|
||||
Dtmail*ComposeDialog*Clear.mnemonic: %|nls-102-#e#|
|
||||
|
||||
!##################################################################################
|
||||
!! Default column width for Compose window and Main Mailer
|
||||
Dtmail*ComposeDialog*Text*columns: %|nls-103-#80#|
|
||||
Dtmail*Work_Area*Text*columns: %|nls-104-#80#|
|
||||
|
||||
!################################################################
|
||||
!#
|
||||
!# Other Mailer resources
|
||||
!#
|
||||
Dtmail*interval: 5
|
||||
Dtmail*Next: True
|
||||
Dtmail*Next*default: True
|
||||
Dtmail*Start*default: True
|
||||
Dtmail*Message_List*scrollBarDisplayPolicy: STATIC
|
||||
Dtmail*Message_List*visibleItemCount: 15
|
||||
Dtmail*Message_List*width: 600
|
||||
Dtmail*Message_List*listSizePolicy: VARIABLE
|
||||
Dtmail*Message_List*viewHeight: 7
|
||||
Dtmail*Message_List*selectionPolicy: EXTENDED_SELECT
|
||||
Dtmail*Work_Area*Text*editMode: MULTI_LINE_EDIT
|
||||
Dtmail*Message_Send*scrollHorizontal: False
|
||||
!!Dtmail*Message_Send*wordWrap: True
|
||||
Dtmail*ComposeDialog*Work_Area*Text*wordWrap: False
|
||||
Dtmail*Message_View*scrollHorizontal: False
|
||||
Dtmail*Message_View*wordWrap: True
|
||||
Dtmail*Mail_View*scrollVertical: True
|
||||
Dtmail*menubar*tearOffModel: TEAR_OFF_DISABLED
|
||||
!!
|
||||
!!Dtmail*menubar*Compose.tearOffModel: TEAR_OFF_ENABLED
|
||||
!!Dtmail*menubar*Move.tearOffModel: TEAR_OFF_ENABLED
|
||||
!!
|
||||
Dtmail*View*Separator*separatorType: SHADOW_ETCHED_IN
|
||||
Dtmail*ComposeDialog*menubar*File.Log_Message.indicatorType: XmONE_OF_MANY
|
||||
Dtmail*ComposeDialog*menubar*File.Log_Message.set: TRUE
|
||||
Dtmail*ComposeDialog*menubar*File.Log_Message.visibleWhenOff: TRUE
|
||||
Dtmail*ComposeDialog*menubar*Attachments.Show_List.indicatorType: XmONE_OF_MANY
|
||||
Dtmail*ComposeDialog*menubar*Attachments.Show_List.set: TRUE
|
||||
Dtmail*ComposeDialog*menubar*Attachments.Show_List.visibleWhenOff: TRUE
|
||||
Dtmail*ComposeDialog*menubar*Format.Word_Wrap.indicatorType: XmONE_OF_MANY
|
||||
!!Dtmail*ComposeDialog*menubar*Format.Word_Wrap.set: TRUE
|
||||
Dtmail*ComposeDialog*menubar*Format.Word_Wrap.set: False
|
||||
Dtmail*ComposeDialog*menubar*Format.Word_Wrap.set: TRUE
|
||||
Dtmail*ComposeDialog*menubar*Format.Word_Wrap.visibleWhenOff: TRUE
|
||||
Dtmail*menubar*View.Abbreviated_Headers.indicatorType: XmONE_OF_MANY
|
||||
Dtmail*menubar*View.Abbreviated_Headers.set: TRUE
|
||||
Dtmail*menubar*View.Abbreviated_Headers.visibleWhenOff: TRUE
|
||||
*Message_View*Work_Area.width: 600
|
||||
*Message_View*Work_Area.height: 400
|
||||
Dtmail*separateViewWindow*Work_Area.width: 600
|
||||
Dtmail*separateViewWindow*Work_Area.height: 400
|
||||
!########################### eof ###########################
|
||||
!
|
||||
Dtmail*dtb_options_fields_hide.columns: %|nls-201-#IBM#|
|
||||
Dtmail*dtb_options_deadletter_field.dtb_options_deadletter_field_field.columns: %|nls-202-#IBM#|
|
||||
Dtmail*dtb_options_indent_str_tf.columns: %|nls-203-#IBM#|
|
||||
Dtmail*dtb_options_hdr_field.columns: %|nls-204-#IBM#|
|
||||
Dtmail*dtb_options_def_value_field.columns: %|nls-205-#IBM#|
|
||||
Dtmail*dtb_options_sent_mail_tf.columns: %|nls-206-#IBM#|
|
||||
Dtmail*dtb_options_path_file_name_tf.columns: %|nls-207-#IBM#|
|
||||
Dtmail*dtb_options_srt_looking_tf.columns: %|nls-208-#IBM#|
|
||||
Dtmail*dtb_options_vacation_msg_tp_pane.columns: %|nls-209-#IBM#|
|
||||
Dtmail*dtb_options_subject_tf.columns: %|nls-210-#IBM#|
|
||||
Dtmail*dtb_options_menu_label.columns: %|nls-211-#IBM#|
|
||||
Dtmail*dtb_options_path_filename_label.columns: %|nls-212-#IBM#|
|
||||
Dtmail*dtb_options_alias_tf.columns: %|nls-213-#IBM#|
|
||||
Dtmail*dtb_options_addresses_tf.columns: %|nls-214-#IBM#|
|
||||
Dtmail*dtb_options_local_name_tf.columns: %|nls-215-#IBM#|
|
||||
|
||||
448
cde/programs/dtmail/dtmail/Editor.C
Normal file
448
cde/programs/dtmail/dtmail/Editor.C
Normal file
@@ -0,0 +1,448 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: Editor.C /main/11 1998/07/24 16:06:00 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <EUSCompat.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Dt/Dts.h>
|
||||
|
||||
#include "RoamApp.h"
|
||||
#include "MailMsg.h"
|
||||
#include "Editor.hh"
|
||||
#include "str_utils.h"
|
||||
|
||||
Editor::Editor()
|
||||
: UIComponent("Editor")
|
||||
{
|
||||
}
|
||||
|
||||
Editor::~Editor()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AbstractEditorParent::AbstractEditorParent() {
|
||||
_attachmentPopupMenu = NULL;
|
||||
_textPopupMenu = NULL;
|
||||
_menuPopupAtt = NULL;
|
||||
_menuPopupText = NULL;
|
||||
}
|
||||
|
||||
AbstractEditorParent::~AbstractEditorParent()
|
||||
{
|
||||
delete _menuPopupAtt;
|
||||
delete _menuPopupText;
|
||||
}
|
||||
|
||||
DtMailBoolean
|
||||
Editor::set_message(DtMail::Message * msg,
|
||||
char ** status_string,
|
||||
HeaderFormat header_format,
|
||||
InsertFormat format,
|
||||
BracketFormat brackets)
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session *m_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = m_session->mailRc(error);
|
||||
|
||||
*status_string = NULL;
|
||||
|
||||
DtMail::Envelope *env = msg->getEnvelope(error);
|
||||
|
||||
DtMailHeaderHandle hdr_hnd;
|
||||
char *name;
|
||||
DtMailValueSeq value;
|
||||
|
||||
// Here is not the place for getting the indent string
|
||||
// but it'll do for now.
|
||||
const char *indent_str = NULL;
|
||||
mail_rc->getValue(error, "indentprefix", &indent_str);
|
||||
if (error.isSet())
|
||||
indent_str = strdup("> ");
|
||||
|
||||
disable_redisplay();
|
||||
|
||||
int indent = 0;
|
||||
|
||||
if (format == IF_BRACKETED) {
|
||||
char * ins_bracket;
|
||||
switch (brackets) {
|
||||
case BF_FORWARD:
|
||||
ins_bracket = GETMSG(DT_catd, 1, 195, "------------- Begin Forwarded Message -------------\n\n");
|
||||
break;
|
||||
|
||||
case BF_INCLUDE:
|
||||
default:
|
||||
ins_bracket = GETMSG(DT_catd, 1, 196, "------------- Begin Included Message -------------\n\n");
|
||||
break;
|
||||
}
|
||||
|
||||
append_to_contents(ins_bracket, strlen(ins_bracket));
|
||||
}
|
||||
|
||||
// Code from MsgScrollingList - display_message().
|
||||
// We're trying to reduce heap size by not allocating and
|
||||
// deleting space in every loop iteration. So just have a
|
||||
// fixed size buffer initially.
|
||||
//
|
||||
|
||||
// Initial line size. When not enough, allocate more.
|
||||
int line_size = 1024;
|
||||
int tmp_count = 0;
|
||||
char *line = new char[line_size];
|
||||
int hdr_num = 0;
|
||||
|
||||
if (header_format != HF_NONE) {
|
||||
for ( hdr_hnd = env->getFirstHeader(
|
||||
error,
|
||||
&name,
|
||||
value);
|
||||
hdr_hnd && !error.isSet();
|
||||
hdr_hnd = env->getNextHeader(
|
||||
error,
|
||||
hdr_hnd,
|
||||
&name,
|
||||
value), hdr_num++ ) {
|
||||
|
||||
|
||||
if ((header_format == HF_ABBREV)
|
||||
&& (hdr_num != 0 || strcmp(name, "From") != 0)) {
|
||||
DtMailEnv ierror;
|
||||
if (mail_rc->ignore(ierror, name)) {
|
||||
free(name);
|
||||
value.clear();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for ( int val = 0; val < value.length(); val++ ) {
|
||||
tmp_count = strlen(name) +
|
||||
strlen(*(value[val])) +
|
||||
strlen(indent_str) +
|
||||
5;
|
||||
if ( tmp_count > line_size ) { // Need to increase line size.
|
||||
delete [] line;
|
||||
line_size = tmp_count;
|
||||
line = new char[line_size];
|
||||
}
|
||||
memset(line, 0, line_size);
|
||||
if (format == IF_INDENTED) {
|
||||
strcpy(line, indent_str);
|
||||
strcat(line, name);
|
||||
} else {
|
||||
strcpy(line, name);
|
||||
}
|
||||
|
||||
if (hdr_num != 0 || strcmp(name, "From") != 0) {
|
||||
strcat(line, ": ");
|
||||
}
|
||||
else {
|
||||
strcat(line, " ");
|
||||
}
|
||||
|
||||
strcat(line, *(value[val]));
|
||||
strcat(line, "\n");
|
||||
append_to_contents(line, strlen(line));
|
||||
}
|
||||
value.clear();
|
||||
free(name);
|
||||
}
|
||||
}
|
||||
// Don't delete line yet, because it's used below.
|
||||
|
||||
if (format == IF_INDENTED) {
|
||||
append_to_contents(indent_str, strlen(indent_str));
|
||||
}
|
||||
|
||||
if (header_format != HF_NONE) {
|
||||
append_to_contents("\n", 1);
|
||||
}
|
||||
|
||||
DtMail::BodyPart *bp = msg->getFirstBodyPart(error);
|
||||
|
||||
char *type;
|
||||
DtMailBoolean firstBPHandled = DTM_FALSE;
|
||||
|
||||
bp->getContents(error, NULL, NULL, &type, NULL, NULL, NULL);
|
||||
if ( type ) {
|
||||
char *attr = DtDtsDataTypeToAttributeValue(
|
||||
type,
|
||||
DtDTS_DA_IS_TEXT,
|
||||
NULL);
|
||||
if ((attr && strcasecmp(attr, "true") == 0)
|
||||
|| strcoll(type, DtDTS_DT_UNKNOWN) == 0 ) {
|
||||
const void *contents;
|
||||
unsigned long size;
|
||||
bp->lockContents(error, DtMailLockRead);
|
||||
bp->getContents(error, &contents, &size, NULL, NULL, NULL, NULL);
|
||||
|
||||
if (format == IF_INDENTED) {
|
||||
int byte_count = 0;
|
||||
int content_count = (int) size;
|
||||
const char *last = NULL, *content_ptr = NULL;
|
||||
// Parse the result of getContents().
|
||||
// Spit out indent string with each line.
|
||||
// Is contents NULL terminated???
|
||||
for ( last = (const char *)contents,
|
||||
content_ptr = (const char *)contents;
|
||||
content_count > 0;
|
||||
content_ptr++,
|
||||
byte_count++,
|
||||
content_count-- ) {
|
||||
if ((*content_ptr == '\n') ||
|
||||
(content_count == 1) ) {
|
||||
// 2 for null terminator and new line.
|
||||
tmp_count = strlen(indent_str) + byte_count + 2;
|
||||
if ( tmp_count > line_size ) {
|
||||
// Need to increase line size.
|
||||
delete [] line;
|
||||
line_size = tmp_count;
|
||||
line = new char[line_size];
|
||||
}
|
||||
memset(line, 0, line_size);
|
||||
strcpy(line, indent_str);
|
||||
strncat(line, last, byte_count + 1);
|
||||
// Copy the '\n' also
|
||||
append_to_contents(line, strlen(line));
|
||||
last = content_ptr + 1;
|
||||
byte_count = -1;
|
||||
}
|
||||
} // end of for loop
|
||||
} else {
|
||||
append_to_contents((const char *)contents, size);
|
||||
}
|
||||
bp->unlockContents(error);
|
||||
firstBPHandled = DTM_TRUE;
|
||||
if (attr) {
|
||||
DtDtsFreeAttributeValue(attr);
|
||||
attr = NULL;
|
||||
}
|
||||
}
|
||||
free(type);
|
||||
|
||||
// DLP: We will turn off this test for now. We need to study the problem
|
||||
// of text checksums more.
|
||||
//
|
||||
//if (bp->checksum(error) == DtMailCheckBad) {
|
||||
// *status_string = GETMSG(DT_catd, 1, -1, "Digital signature did not match.");
|
||||
//}
|
||||
}
|
||||
delete [] line;
|
||||
|
||||
if (format == IF_BRACKETED) {
|
||||
char * ins_bracket;
|
||||
switch (brackets) {
|
||||
case BF_FORWARD:
|
||||
ins_bracket = GETMSG(DT_catd, 1, 197, "------------- End Forwarded Message -------------\n\n");
|
||||
break;
|
||||
|
||||
case BF_INCLUDE:
|
||||
default:
|
||||
ins_bracket = GETMSG(DT_catd, 1, 198, "------------- End Included Message -------------\n\n");
|
||||
break;
|
||||
}
|
||||
|
||||
append_to_contents(ins_bracket, strlen(ins_bracket));
|
||||
}
|
||||
|
||||
enable_redisplay();
|
||||
|
||||
if (NULL != indent_str)
|
||||
free((void*) indent_str);
|
||||
|
||||
return(firstBPHandled);
|
||||
}
|
||||
|
||||
void
|
||||
Editor::append_newline_to_contents()
|
||||
{
|
||||
append_to_contents("\n", strlen("\n"));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Editor::set_attachment(
|
||||
DtMail::BodyPart *bp,
|
||||
InsertFormat format,
|
||||
BracketFormat brackets)
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session *m_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = m_session->mailRc(error);
|
||||
DtMailValueSeq value;
|
||||
|
||||
char *input, *name, *dttype, *description, *mimetype;
|
||||
const char *indent_str = NULL;
|
||||
unsigned long len;
|
||||
|
||||
if (format == IF_INDENTED)
|
||||
{
|
||||
mail_rc->getValue(error, "indentprefix", &indent_str);
|
||||
if (error.isSet())
|
||||
indent_str = strdup("> ");
|
||||
}
|
||||
|
||||
disable_redisplay();
|
||||
if ((format == IF_BRACKETED) && (brackets == BF_INCLUDE))
|
||||
{
|
||||
char * ins_bracket =
|
||||
GETMSG(
|
||||
DT_catd, 1, 249,
|
||||
"------------- Begin Included Attachment -------------\n\n");
|
||||
|
||||
append_to_contents(ins_bracket, strlen(ins_bracket));
|
||||
}
|
||||
else if (format == IF_INDENTED)
|
||||
{
|
||||
append_to_contents(indent_str, strlen(indent_str));
|
||||
append_newline_to_contents();
|
||||
}
|
||||
|
||||
bp->getContents(error, NULL, &len, &dttype, &name, NULL, &description);
|
||||
|
||||
if ((NULL != name) && (0 != strlen(name)))
|
||||
{
|
||||
if (NULL != indent_str)
|
||||
append_to_contents(indent_str, strlen(indent_str));
|
||||
input = GETMSG(DT_catd, 1, 251, " Attachment Name: ");
|
||||
append_to_contents(input, strlen(input));
|
||||
append_to_contents(name, strlen(name));
|
||||
append_newline_to_contents();
|
||||
}
|
||||
|
||||
if ((NULL != dttype) && (0 != strlen(dttype)))
|
||||
{
|
||||
if (NULL != indent_str)
|
||||
append_to_contents(indent_str, strlen(indent_str));
|
||||
input = GETMSG(DT_catd, 1, 252, " Attachment DtType: ");
|
||||
append_to_contents(input, strlen(input));
|
||||
append_to_contents(dttype, strlen(dttype));
|
||||
append_newline_to_contents();
|
||||
}
|
||||
|
||||
bp->getContentType(error, &mimetype);
|
||||
if ((NULL != mimetype) && (0 != strlen(mimetype)))
|
||||
{
|
||||
if (NULL != indent_str)
|
||||
append_to_contents(indent_str, strlen(indent_str));
|
||||
input = GETMSG(DT_catd, 1, 253, "Attachment ContentType: ");
|
||||
append_to_contents(input, strlen(input));
|
||||
append_to_contents(mimetype, strlen(mimetype));
|
||||
append_newline_to_contents();
|
||||
}
|
||||
|
||||
if ((NULL != description) && (0 != strlen(description)))
|
||||
{
|
||||
if (NULL != indent_str)
|
||||
append_to_contents(indent_str, strlen(indent_str));
|
||||
input = GETMSG(DT_catd, 1, 254, "Attachment Description: ");
|
||||
append_to_contents(input, strlen(input));
|
||||
append_to_contents(description, strlen(description));
|
||||
append_newline_to_contents();
|
||||
}
|
||||
|
||||
if ((format == IF_BRACKETED) && (brackets == BF_INCLUDE))
|
||||
{
|
||||
char * ins_bracket =
|
||||
GETMSG(
|
||||
DT_catd, 1, 250,
|
||||
"------------- End Included Attachment -------------\n\n");
|
||||
|
||||
append_to_contents(ins_bracket, strlen(ins_bracket));
|
||||
}
|
||||
else if (format == IF_INDENTED)
|
||||
{
|
||||
append_to_contents(indent_str, strlen(indent_str));
|
||||
append_newline_to_contents();
|
||||
}
|
||||
enable_redisplay();
|
||||
|
||||
if (NULL != indent_str)
|
||||
free((void*) indent_str);
|
||||
if (NULL != name)
|
||||
free((void*) name);
|
||||
if (NULL != dttype)
|
||||
free((void*) dttype);
|
||||
if (NULL != mimetype)
|
||||
free((void*) mimetype);
|
||||
if (NULL != description)
|
||||
free((void*) description);
|
||||
}
|
||||
|
||||
void
|
||||
Editor::update_display_from_props(void)
|
||||
{
|
||||
int rows, cols;
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mailrc = d_session->mailRc(error);
|
||||
const char * value = NULL;
|
||||
|
||||
mailrc->getValue(error, "popuplines", &value);
|
||||
if (error.isSet()) {
|
||||
value = strdup("24");
|
||||
}
|
||||
rows = (int) strtol(value, NULL, 10);
|
||||
if (NULL != value)
|
||||
free((void*) value);
|
||||
set_rows(rows);
|
||||
|
||||
// If toolcols is set, overwrite the column width with "toolcols" value.
|
||||
// Otherwise, default resource value will be used.
|
||||
value = NULL;
|
||||
error.clear();
|
||||
mailrc->getValue(error, "toolcols", &value);
|
||||
if (!error.isSet()){
|
||||
cols = (int) strtol(value, NULL, 10);
|
||||
if (NULL != value)
|
||||
free((void*) value);
|
||||
} else {
|
||||
/*
|
||||
* MB_CUR_MAX == 1 : SingleByteLanguage
|
||||
* MB_CUR_MAX > 1 : MultiByteLanguage
|
||||
*/
|
||||
if ( MB_CUR_MAX == 1 )
|
||||
cols = 80;
|
||||
else
|
||||
cols = 40;
|
||||
}
|
||||
set_columns(cols);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AbstractEditorParent::postAttachmentPopup(XEvent *event)
|
||||
{
|
||||
XmMenuPosition(_attachmentPopupMenu, (XButtonEvent *)event);
|
||||
XtManageChild(_attachmentPopupMenu);
|
||||
}
|
||||
|
||||
void
|
||||
AbstractEditorParent::postTextPopup(XEvent *event)
|
||||
{
|
||||
if (_textPopupMenu == NULL)
|
||||
return;
|
||||
|
||||
XmMenuPosition(_textPopupMenu, (XButtonEvent *)event);
|
||||
XtManageChild(_textPopupMenu);
|
||||
}
|
||||
|
||||
185
cde/programs/dtmail/dtmail/Editor.hh
Normal file
185
cde/programs/dtmail/dtmail/Editor.hh
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: Editor.hh /main/11 1998/02/03 10:28:56 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef EDITOR_H
|
||||
#define EDITOR_H
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include "MenuBar.h"
|
||||
|
||||
// Get all the Bento-related API and types (CMContainer, etc.)
|
||||
|
||||
#include <DtMail/DtMail.hh>
|
||||
#include "UIComponent.h"
|
||||
|
||||
extern int use_XmTextEditor;
|
||||
|
||||
class DtMailEditor;
|
||||
|
||||
class Editor : public UIComponent {
|
||||
|
||||
public:
|
||||
Editor();
|
||||
virtual ~Editor();
|
||||
|
||||
virtual void initialize() = 0;
|
||||
|
||||
virtual void set_contents(
|
||||
const char *contents,
|
||||
const unsigned long len
|
||||
) = 0;
|
||||
|
||||
virtual void set_contents(const char * path) = 0;
|
||||
|
||||
virtual char * get_contents() = 0;
|
||||
|
||||
virtual void append_to_contents(
|
||||
const char *new_contents,
|
||||
const unsigned long len
|
||||
) = 0;
|
||||
|
||||
virtual void append_to_contents(const char * path) = 0;
|
||||
|
||||
virtual void append_at_cursor(const char *path) = 0;
|
||||
virtual void append_at_cursor(
|
||||
const char *contents,
|
||||
const unsigned long len
|
||||
) = 0;
|
||||
|
||||
enum InsertFormat {
|
||||
IF_NONE, // No special format
|
||||
IF_INDENTED, // Indented with indent_prefix
|
||||
IF_BRACKETED // Bracketed
|
||||
};
|
||||
|
||||
enum BracketFormat {
|
||||
BF_NONE, // No bracketing
|
||||
BF_INCLUDE, // As included message,
|
||||
BF_FORWARD // As forwarded message
|
||||
};
|
||||
|
||||
enum HeaderFormat {
|
||||
HF_NONE, // Do not insert headers in message body.
|
||||
HF_FULL, // Insert all headers.
|
||||
HF_ABBREV // Do not insert ignored headers.
|
||||
};
|
||||
|
||||
virtual void append_newline_to_contents();
|
||||
virtual DtMailBoolean set_message(
|
||||
DtMail::Message * msg,
|
||||
char ** status_string,
|
||||
HeaderFormat header_format = HF_ABBREV,
|
||||
InsertFormat format = IF_NONE,
|
||||
BracketFormat brackets = BF_NONE);
|
||||
|
||||
virtual void set_attachment(
|
||||
DtMail::BodyPart * body_part,
|
||||
InsertFormat format = IF_NONE,
|
||||
BracketFormat brackets = BF_NONE);
|
||||
|
||||
virtual void clear_contents() = 0;
|
||||
virtual int no_text() = 0;
|
||||
|
||||
virtual Widget get_editor() = 0;
|
||||
virtual Widget get_text_widget() = 0;
|
||||
virtual Pixel get_text_foreground() = 0;
|
||||
virtual Pixel get_text_background() = 0;
|
||||
virtual Dimension get_text_width() = 0;
|
||||
virtual XmFontList get_text_fontList() = 0;
|
||||
|
||||
virtual int get_columns() = 0;
|
||||
virtual int get_rows() = 0;
|
||||
virtual void set_columns(int ncolumns) = 0;
|
||||
virtual void set_editable(Boolean value) = 0;
|
||||
virtual void set_rows(int nrows) = 0;
|
||||
virtual void update_display_from_props(void);
|
||||
|
||||
virtual void auto_show_cursor_off() = 0;
|
||||
virtual void auto_show_cursor_restore() = 0;
|
||||
|
||||
virtual void set_to_top() = 0;
|
||||
virtual void set_to_bottom() = 0;
|
||||
|
||||
virtual void find_change() = 0;
|
||||
virtual void spell() = 0;
|
||||
virtual void format() = 0;
|
||||
virtual void set_word_wrap(Boolean value) = 0;
|
||||
virtual void undo_edit() = 0;
|
||||
virtual void cut_selection() = 0;
|
||||
virtual void copy_selection() = 0;
|
||||
virtual void paste_from_clipboard() = 0;
|
||||
virtual void paste_special_from_clipboard(InsertFormat) = 0;
|
||||
virtual void clear_selection() = 0;
|
||||
virtual void delete_selection() = 0;
|
||||
virtual void select_all() = 0;
|
||||
|
||||
virtual void disable_redisplay() = 0;
|
||||
virtual void enable_redisplay() = 0;
|
||||
|
||||
};
|
||||
|
||||
class AbstractEditorParent {
|
||||
protected:
|
||||
Widget _attachmentPopupMenu;
|
||||
Widget _textPopupMenu;
|
||||
MenuBar *_menuPopupAtt;
|
||||
MenuBar *_menuPopupText;
|
||||
public:
|
||||
|
||||
AbstractEditorParent();
|
||||
virtual ~AbstractEditorParent();
|
||||
|
||||
virtual const char *const className()
|
||||
{ return "AbstractEditorParent"; }
|
||||
|
||||
virtual DtMailEditor * get_editor() = 0;
|
||||
|
||||
// Text/attachment (de)selection methods
|
||||
|
||||
virtual void text_selected() = 0;
|
||||
virtual void text_unselected() = 0;
|
||||
virtual void attachment_selected() = 0;
|
||||
virtual void all_attachments_deselected() = 0;
|
||||
virtual void all_attachments_selected() = 0;
|
||||
virtual void add_att(char *) = 0;
|
||||
virtual void add_att(char *, DtMailBuffer) = 0;
|
||||
virtual void add_att(DtMailBuffer) = 0;
|
||||
|
||||
virtual void postAttachmentPopup(XEvent *event);
|
||||
virtual void postTextPopup(XEvent *event);
|
||||
|
||||
virtual void addAttachmentActions(
|
||||
char **,
|
||||
int
|
||||
) = 0;
|
||||
virtual void invokeAttachmentAction(int) = 0;
|
||||
virtual void removeAttachmentActions() = 0;
|
||||
|
||||
virtual void selectAllAttachments() = 0;
|
||||
|
||||
virtual void showAttachArea() = 0;
|
||||
virtual void hideAttachArea() = 0;
|
||||
|
||||
virtual void attachmentFeedback(Boolean) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // EDITOR_HH
|
||||
194
cde/programs/dtmail/dtmail/EncryptedTextFieldUiItem.C
Normal file
194
cde/programs/dtmail/dtmail/EncryptedTextFieldUiItem.C
Normal file
@@ -0,0 +1,194 @@
|
||||
/* $TOG: EncryptedTextFieldUiItem.C /main/2 1997/11/13 13:25:10 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <sys/param.h>
|
||||
#include <Xm/TextF.h>
|
||||
|
||||
#include <DtMail/options_util.h>
|
||||
#include <DtMail/EncryptedTextFieldUiItem.hh>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/DtMailServer.hh>
|
||||
#include <DtMail/DtMailTypes.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
EncryptedTextFieldUiItem::EncryptedTextFieldUiItem(
|
||||
Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
PropUiCallback validator,
|
||||
void *validator_data)
|
||||
: PropUiItem(w, source, search_key, validator, validator_data)
|
||||
{
|
||||
_loading = DTM_FALSE;
|
||||
_maxtextlen = 256;
|
||||
_text = (char*) malloc(_maxtextlen);
|
||||
assert(NULL!=_text);
|
||||
_writeAllowed = DTM_FALSE;
|
||||
|
||||
XtVaSetValues(
|
||||
w,
|
||||
XmNeditable, False,
|
||||
XmNvalue, "",
|
||||
NULL);
|
||||
XtAddCallback(
|
||||
w,
|
||||
XmNmodifyVerifyCallback, EncryptedTextFieldUiItem::verifyCB,
|
||||
(XtPointer) this);
|
||||
|
||||
options_field_init(w, &(this->dirty_bit));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void EncryptedTextFieldUiItem::writeAllowed(DtMailBoolean allowed)
|
||||
{
|
||||
Widget w = getWidget();
|
||||
|
||||
if (_writeAllowed == allowed) return;
|
||||
|
||||
_writeAllowed = allowed;
|
||||
if (DTM_TRUE == _writeAllowed)
|
||||
{
|
||||
char *s;
|
||||
char *value = strdup(_text);
|
||||
|
||||
for (s=value; *s; s++) *s = '*';
|
||||
|
||||
_loading = DTM_TRUE;
|
||||
XtVaSetValues(w, XmNeditable, True, XmNsensitive, True, NULL);
|
||||
options_field_set_value(w, value, this->dirty_bit);
|
||||
_loading = DTM_FALSE;
|
||||
setDirtyBit(True);
|
||||
free(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loading = DTM_TRUE;
|
||||
XtVaSetValues(w, XmNeditable, False, XmNsensitive, False, NULL);
|
||||
options_field_set_value(w, "", this->dirty_bit);
|
||||
_loading = DTM_FALSE;
|
||||
setDirtyBit(True);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void EncryptedTextFieldUiItem::writeFromUiToSource()
|
||||
{
|
||||
if (DTM_TRUE == _writeAllowed)
|
||||
prop_source->setValue(_text, DTM_TRUE);
|
||||
else
|
||||
prop_source->setValue(DTMAS_PROPDFLT_PASSWORD, DTM_TRUE);
|
||||
}
|
||||
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void EncryptedTextFieldUiItem::writeFromSourceToUi()
|
||||
{
|
||||
int i;
|
||||
char *s, *value;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
value = (char *)prop_source->getValue(DTM_TRUE);
|
||||
if (! strcmp(value, PropSourceDEFAULTVALUE)) return;
|
||||
|
||||
validateLength(strlen(value));
|
||||
strcpy(_text, value);
|
||||
|
||||
for (i=0, s=value; i<strlen(value); i++, s++)
|
||||
*s = '*';
|
||||
|
||||
_loading = DTM_TRUE;
|
||||
options_field_set_value(w, value, this->dirty_bit);
|
||||
if (NULL != value) free((void*) value);
|
||||
_loading = DTM_FALSE;
|
||||
}
|
||||
|
||||
// Verifies that the _text array is sufficiently long for a string
|
||||
// of the specified size.
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void EncryptedTextFieldUiItem::validateLength(int length)
|
||||
{
|
||||
length++; // Account for the '\0'
|
||||
if (length >= _maxtextlen)
|
||||
{
|
||||
_maxtextlen *= 2;
|
||||
_text = (char*) realloc((void*) _text, (size_t) _maxtextlen);
|
||||
assert(NULL!=_text);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void EncryptedTextFieldUiItem::verify(XmTextVerifyPtr cbs)
|
||||
{
|
||||
int i;
|
||||
static char buffer[MAXPATHLEN];
|
||||
register char *s, *t;
|
||||
|
||||
#if defined(ENCRYPTED_TEXTFIELD_DEBUG)
|
||||
printf(
|
||||
"currInsert=%d newInsert=%d startPos=%d endPos=%d\n",
|
||||
cbs->currInsert,cbs->newInsert,cbs->startPos, cbs->endPos);
|
||||
if (cbs->text->ptr) printf("text->ptr=%s\n", cbs->text->ptr);
|
||||
printf("_text->ptr=%s\n", _text);
|
||||
#endif
|
||||
|
||||
for (i=0, s=buffer, t=_text; (*t && i<cbs->startPos); i++, s++, t++)
|
||||
*s = *t;
|
||||
|
||||
if (cbs->text->ptr)
|
||||
{
|
||||
strcpy(s, cbs->text->ptr);
|
||||
s += cbs->text->length;
|
||||
}
|
||||
else
|
||||
*s = '\0';
|
||||
|
||||
if (strlen(_text) >= cbs->endPos)
|
||||
{
|
||||
t = _text+cbs->endPos;
|
||||
if (strlen(t))
|
||||
strcpy(s, t);
|
||||
}
|
||||
|
||||
validateLength(strlen(buffer));
|
||||
strcpy(_text, buffer);
|
||||
|
||||
if (cbs->text->ptr)
|
||||
for (i=0, s=cbs->text->ptr; i<cbs->text->length; i++, s++)
|
||||
*s = '*';
|
||||
|
||||
#if defined(ENCRYPTED_TEXTFIELD_DEBUG)
|
||||
printf("text=%s\n", _text);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ValueChangedCallback for the text field. Saves the user input
|
||||
// and echos *'s.
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void EncryptedTextFieldUiItem::verifyCB(
|
||||
Widget w,
|
||||
XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
{
|
||||
EncryptedTextFieldUiItem *etf = (EncryptedTextFieldUiItem*) client_data;
|
||||
XmTextVerifyCallbackStruct *cbs = (XmTextVerifyCallbackStruct*) call_data;
|
||||
|
||||
if (DTM_FALSE == etf->_loading) etf->verify(cbs);
|
||||
}
|
||||
879
cde/programs/dtmail/dtmail/FindDialog.C
Normal file
879
cde/programs/dtmail/dtmail/FindDialog.C
Normal file
@@ -0,0 +1,879 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: FindDialog.C /main/7 1998/07/23 17:59:06 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/MessageB.h>
|
||||
#include <Xm/TextF.h>
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/DialogS.h>
|
||||
#include <Xm/PanedW.h>
|
||||
#include <Xm/LabelG.h>
|
||||
#include <Xm/Text.h>
|
||||
#include <Xm/SeparatoG.h>
|
||||
#include <DtMail/DtMail.h>
|
||||
#include <DtMail/DtMail.hh>
|
||||
#include "FindDialog.h"
|
||||
#include "RoamApp.h"
|
||||
#include "RoamMenuWindow.h"
|
||||
#include "RoamCmds.h"
|
||||
#include "Help.hh"
|
||||
#include "MailMsg.h"
|
||||
#include <EUSCompat.h>
|
||||
#include "str_utils.h"
|
||||
|
||||
|
||||
//
|
||||
// Clear out the data. After this function is complete the
|
||||
// data should look as if the constructor was just called and
|
||||
// before initialize().
|
||||
//
|
||||
void
|
||||
FindDialog::clear()
|
||||
{
|
||||
register unsigned int offset;
|
||||
|
||||
//
|
||||
if (_text_labels != NULL) {
|
||||
for (offset = 0; offset < _num_text_fields; offset++) {
|
||||
if (_text_labels[offset] != NULL) {
|
||||
free(_text_labels[offset]);
|
||||
}
|
||||
}
|
||||
delete _text_labels;
|
||||
}
|
||||
|
||||
//
|
||||
if (_text_values != NULL) {
|
||||
for (offset = 0; offset < _num_text_fields; offset++) {
|
||||
if (_text_values[offset] != NULL) {
|
||||
free(_text_values[offset]);
|
||||
}
|
||||
}
|
||||
delete _text_values;
|
||||
}
|
||||
|
||||
//
|
||||
if (_text_abstract_name != NULL) {
|
||||
for (offset = 0; offset < _num_text_fields; offset++) {
|
||||
if (_text_abstract_name[offset] != NULL) {
|
||||
free(_text_abstract_name[offset]);
|
||||
}
|
||||
}
|
||||
delete _text_abstract_name;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
if (_buttonData != NULL) {
|
||||
for (offset = 0; offset < _num_buttons; offset++) {
|
||||
if (_buttonData[offset].label != NULL) {
|
||||
free(_buttonData[offset].label);
|
||||
}
|
||||
}
|
||||
delete _buttonData;
|
||||
}
|
||||
|
||||
if (_text_fields != NULL) {
|
||||
delete _text_fields;
|
||||
}
|
||||
|
||||
if (_text_names != NULL) {
|
||||
delete _text_names;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// The only constructor.
|
||||
//
|
||||
FindDialog::FindDialog(RoamMenuWindow *parent) : Dialog("find", parent)
|
||||
{
|
||||
_roamWindow = parent;
|
||||
_num_text_fields = 4;
|
||||
_num_buttons = 5;
|
||||
|
||||
//
|
||||
// Allocate storage for labels, widgets, and data.
|
||||
//
|
||||
_text_labels = new char *[_num_text_fields];
|
||||
_text_names = new char *[_num_text_fields];
|
||||
_text_values = new char *[_num_text_fields];
|
||||
_text_abstract_name = new char *[_num_text_fields];
|
||||
_text_fields = new Widget[_num_text_fields];
|
||||
_buttonData = new ActionAreaItem[_num_buttons];
|
||||
_searchForward = TRUE;
|
||||
|
||||
//
|
||||
// Initialize the buttons.
|
||||
//
|
||||
_buttonData[0].label = strdup(GETMSG(DT_catd, 1, 183, "Find"));
|
||||
_buttonData[0].callback = findCallback;
|
||||
_buttonData[0].data = (caddr_t) this;
|
||||
|
||||
#ifdef NL_OBSOLETE
|
||||
/*
|
||||
* NL_COMMENT
|
||||
* This is an obsolete message. Replaced by message 220 in set 1
|
||||
*/
|
||||
_buttonData[1].label = strdup(GETMSG(DT_catd, 1, 184, "Find & Select All"));
|
||||
#endif
|
||||
/*
|
||||
* NL_COMMENT
|
||||
* This message replaces message 184 in set 1
|
||||
*/
|
||||
_buttonData[1].label = strdup(GETMSG(DT_catd, 1, 220, "Select All"));
|
||||
_buttonData[1].callback = findSelectAllCallback;
|
||||
_buttonData[1].data = (caddr_t) this;
|
||||
|
||||
_buttonData[2].label = strdup(GETMSG(DT_catd, 1, 185, "Clear"));
|
||||
_buttonData[2].callback = clearCallback;
|
||||
_buttonData[2].data = (caddr_t) this;
|
||||
|
||||
_buttonData[3].label = strdup(GETMSG(DT_catd, 1, 186, "Close"));
|
||||
_buttonData[3].callback = closeCallback;
|
||||
_buttonData[3].data = (caddr_t) this;
|
||||
|
||||
_buttonData[4].label = strdup(GETMSG(DT_catd, 1, 187, "Help"));
|
||||
_buttonData[4].callback = HelpCB;
|
||||
_buttonData[4].data = (caddr_t) DTMAILFINDDIALOG;
|
||||
|
||||
_text_labels[0] = strdup(GETMSG(DT_catd, 1, 188, "To:"));
|
||||
_text_labels[1] = strdup(GETMSG(DT_catd, 1, 189, "From:"));
|
||||
_text_labels[2] = strdup(GETMSG(DT_catd, 1, 190, "Subject:"));
|
||||
_text_labels[3] = strdup(GETMSG(DT_catd, 1, 191, "Cc:"));
|
||||
|
||||
// These strings should not be translated. They are
|
||||
// the Motif names for the widgets that will be created (they are
|
||||
// not the labels).
|
||||
_text_names[0] = "To";
|
||||
_text_names[1] = "From";
|
||||
_text_names[2] = "Subject";
|
||||
_text_names[3] = "Cc";
|
||||
|
||||
//
|
||||
// Initialize the names of the fields to the abstract
|
||||
// names used by libDtMail.
|
||||
//
|
||||
_text_abstract_name[0] = strdup(DtMailMessageTo);
|
||||
_text_abstract_name[1] = strdup(DtMailMessageSender);
|
||||
_text_abstract_name[2] = strdup(DtMailMessageSubject);
|
||||
_text_abstract_name[3] = strdup(DtMailMessageCc);
|
||||
}
|
||||
|
||||
//
|
||||
// Print a string in the status line of the find dialog.
|
||||
//
|
||||
void
|
||||
FindDialog::setStatus(const char * str)
|
||||
{
|
||||
char *tmpstr = strdup(str);
|
||||
XmString label = XmStringCreateLocalized(tmpstr);
|
||||
|
||||
XtVaSetValues(_status_text,
|
||||
XmNlabelString, label,
|
||||
NULL);
|
||||
|
||||
XmUpdateDisplay(baseWidget());
|
||||
XmStringFree(label);
|
||||
}
|
||||
|
||||
//
|
||||
// Clear the status line of the find dialog.
|
||||
//
|
||||
void
|
||||
FindDialog::clearStatus(void)
|
||||
{
|
||||
setStatus(" ");
|
||||
}
|
||||
|
||||
//
|
||||
// Create the guts of the dialog
|
||||
//
|
||||
Widget
|
||||
FindDialog::createWorkArea(Widget dialog)
|
||||
{
|
||||
// TODO - CHECK ERROR!!!
|
||||
Widget *label = new Widget[_num_text_fields];
|
||||
|
||||
|
||||
register unsigned int offset;
|
||||
|
||||
_name = GETMSG(DT_catd, 1, 192, "Mailer - Find");
|
||||
|
||||
title(_name);
|
||||
|
||||
// make this a modal dialog
|
||||
/*
|
||||
XtVaSetValues (dialog,
|
||||
XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
|
||||
NULL);
|
||||
*/
|
||||
|
||||
printHelpId("dialog", dialog);
|
||||
|
||||
/* add help callback */
|
||||
// XtAddCallback(dialog, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
Widget fd_pane = XtVaCreateWidget ("fd_pane",
|
||||
xmPanedWindowWidgetClass,
|
||||
dialog,
|
||||
XmNsashWidth, 1,
|
||||
XmNsashHeight, 1,
|
||||
NULL);
|
||||
|
||||
printHelpId ("fd_pane", fd_pane);
|
||||
// add help callback
|
||||
// XtAddCallback (fd_pane, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
Widget fd_form = XtVaCreateWidget ("fd_form",
|
||||
xmFormWidgetClass,
|
||||
fd_pane,
|
||||
XmNfractionBase, 100,
|
||||
NULL);
|
||||
|
||||
printHelpId ("fd_form", fd_form);
|
||||
// add help callback
|
||||
// XtAddCallback (fd_form, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
|
||||
Widget _fd_labelbox = XtVaCreateManagedWidget ("_fd_labelbox",
|
||||
xmRowColumnWidgetClass,
|
||||
fd_form,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_POSITION,
|
||||
XmNrightAttachment, XmATTACH_POSITION,
|
||||
XmNleftPosition, 5,
|
||||
XmNrightPosition, 95,
|
||||
XmNpacking, XmPACK_COLUMN,
|
||||
XmNnumColumns, 2,
|
||||
XmNorientation, XmVERTICAL,
|
||||
XmNisAligned, True,
|
||||
XmNentryAlignment, XmALIGNMENT_END,
|
||||
XmNentryVerticalAlignment, XmALIGNMENT_CENTER,
|
||||
NULL);
|
||||
printHelpId ("_fd_labelbox", _fd_labelbox);
|
||||
// add help callback
|
||||
// XtAddCallback (_fd_labelbox, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
|
||||
Widget *_fd_labels = new Widget [_num_text_fields];
|
||||
|
||||
int _fd_i = 0;
|
||||
for (_fd_i = 0; _fd_i < _num_text_fields; _fd_i++)
|
||||
{
|
||||
_fd_labels [_fd_i] = XtVaCreateManagedWidget (
|
||||
_text_labels [_fd_i],
|
||||
xmLabelGadgetClass,
|
||||
_fd_labelbox,
|
||||
NULL);
|
||||
|
||||
printHelpId ("_fd_labels [%s]", _fd_labels [_fd_i]);
|
||||
// naturally, this is bogus --must be fixed to return proper label
|
||||
// add help callback
|
||||
// XtAddCallback(_fd_labels [_fd_i], XmNhelpCallback, HelpCB, helpId);
|
||||
}
|
||||
|
||||
for (_fd_i = 0; _fd_i < _num_text_fields; _fd_i++)
|
||||
{
|
||||
_text_fields [_fd_i] = XtVaCreateManagedWidget (
|
||||
_text_names [_fd_i],
|
||||
xmTextFieldWidgetClass,
|
||||
_fd_labelbox,
|
||||
NULL);
|
||||
printHelpId ("_text_fields [%s]", _text_fields [_fd_i]);
|
||||
// naturally, this is bogus --must be fixed to return proper label
|
||||
// add help callback
|
||||
// XtAddCallback(_text_fields [_fd_i], XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
XtAddCallback(_text_fields [_fd_i], XmNactivateCallback,
|
||||
(XtCallbackProc)textFieldCallback, (XtPointer)this);
|
||||
}
|
||||
|
||||
|
||||
XmString strForward = XmStringCreateLocalized(GETMSG(DT_catd, 1, 193, "Forward"));
|
||||
XmString strBackward = XmStringCreateLocalized(GETMSG(DT_catd, 1, 194, "Backward"));
|
||||
|
||||
Widget fd_direction
|
||||
= XmVaCreateSimpleRadioBox(fd_form,
|
||||
"Direction",
|
||||
0, // Initial selection
|
||||
directionCallback,
|
||||
//NULL,
|
||||
XmVaRADIOBUTTON, strForward, NULL, NULL, NULL,
|
||||
XmVaRADIOBUTTON, strBackward, NULL, NULL, NULL,
|
||||
XmNuserData, this,
|
||||
XmNsensitive, True,
|
||||
XmNtopAttachment, XmATTACH_WIDGET,
|
||||
XmNtopWidget, _fd_labelbox,
|
||||
XmNorientation, XmHORIZONTAL,
|
||||
XmNleftAttachment, XmATTACH_POSITION,
|
||||
XmNleftPosition, 33,
|
||||
NULL);
|
||||
printHelpId ("fd_direction", fd_direction);
|
||||
// add help callback
|
||||
//XtAddCallback (fd_direction, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
XmStringFree(strForward);
|
||||
XmStringFree(strBackward);
|
||||
|
||||
//
|
||||
// Now create the Action Area.
|
||||
//
|
||||
#define TIGHTNESS 20
|
||||
|
||||
register Widget widget;
|
||||
|
||||
Widget fd_action = XtVaCreateWidget("actionArea",
|
||||
xmFormWidgetClass,
|
||||
fd_pane,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNfractionBase, TIGHTNESS * _num_buttons-1,
|
||||
NULL);
|
||||
printHelpId ("actionArea", fd_action);
|
||||
// add help callback
|
||||
//XtAddCallback (fd_action, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
for (offset = 0; offset < _num_buttons; offset++)
|
||||
{ widget = XtVaCreateManagedWidget(_buttonData[offset].label,
|
||||
xmPushButtonWidgetClass, fd_action,
|
||||
|
||||
XmNleftAttachment,
|
||||
offset ? XmATTACH_POSITION:XmATTACH_FORM,
|
||||
|
||||
XmNleftPosition, TIGHTNESS * offset,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
|
||||
XmNrightAttachment,
|
||||
offset != _num_buttons - 1 ? XmATTACH_POSITION : XmATTACH_FORM,
|
||||
|
||||
XmNrightPosition,
|
||||
TIGHTNESS * offset + (TIGHTNESS - 1),
|
||||
|
||||
XmNshowAsDefault, offset == 0,
|
||||
NULL);
|
||||
|
||||
// again, bogus -- doesn't each one need a unique tag?
|
||||
printHelpId ("widget", widget);
|
||||
// add help callback
|
||||
//XtAddCallback (widget, XmNhelpCallback, HelpCB, helpId);
|
||||
|
||||
if (_buttonData[offset].callback != NULL) {
|
||||
XtAddCallback(widget, XmNactivateCallback,
|
||||
_buttonData[offset].callback,
|
||||
_buttonData[offset].data);
|
||||
}
|
||||
|
||||
|
||||
if (offset == 0) {
|
||||
Dimension height;
|
||||
Dimension margin;
|
||||
|
||||
XtVaGetValues(fd_action, XmNmarginHeight, &margin, NULL);
|
||||
XtVaGetValues(widget, XmNheight, &height, NULL);
|
||||
height +=2 * margin;
|
||||
XtVaSetValues(fd_action,
|
||||
XmNdefaultButton, widget,
|
||||
XmNpaneMaximum, height,
|
||||
XmNpaneMinimum, height,
|
||||
NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
_status_text = XtVaCreateManagedWidget("StatusLabel",
|
||||
xmLabelWidgetClass, fd_pane,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
NULL);
|
||||
|
||||
Dimension height;
|
||||
XtWidgetGeometry size;
|
||||
|
||||
size.request_mode = CWHeight;
|
||||
XtQueryGeometry(_status_text, NULL, &size);
|
||||
XtVaSetValues(_status_text,
|
||||
XmNpaneMaximum, size.height,
|
||||
XmNpaneMinimum, size.height,
|
||||
NULL);
|
||||
|
||||
clearStatus();
|
||||
|
||||
XtManageChild (fd_form);
|
||||
XtManageChild (fd_direction);
|
||||
XtManageChild(fd_action);
|
||||
XtManageChild(fd_pane);
|
||||
|
||||
XtManageChild(dialog);
|
||||
|
||||
// Make sure get the height of the dialog after it has been
|
||||
// managed.
|
||||
XtVaGetValues(dialog, XmNheight, &height, NULL);
|
||||
XtVaSetValues(dialog,
|
||||
XmNmappedWhenManaged, True,
|
||||
XmNminHeight, height,
|
||||
NULL);
|
||||
XtRealizeWidget(dialog);
|
||||
|
||||
return (fd_pane);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Look for all matching messages.
|
||||
//
|
||||
Boolean
|
||||
FindDialog::findMatching(Boolean findAll)
|
||||
{
|
||||
// TODO - CHECK ERROR!!!
|
||||
DtMailEnv error;
|
||||
unsigned int matchCount = 0;
|
||||
|
||||
/* NL_COMMENT
|
||||
* This string is displayed on the find dialog status line
|
||||
* when searching for a matching message.
|
||||
*/
|
||||
|
||||
setStatus(GETMSG(DT_catd, 1, 231, "Searching..."));
|
||||
busyCursor();
|
||||
theRoamApp.busyAllWindows(NULL);
|
||||
|
||||
//
|
||||
// Get the active list.
|
||||
//
|
||||
MsgScrollingList * displayList = _roamWindow->list();
|
||||
|
||||
//
|
||||
// Find the max. number of messages that we are to find matching.
|
||||
//
|
||||
int numberMessages = displayList->get_num_messages();
|
||||
|
||||
//
|
||||
// Are there any messages?
|
||||
//
|
||||
if (numberMessages > 0) {
|
||||
|
||||
//
|
||||
// A pointer to the currently interesting message.
|
||||
//
|
||||
register DtMailMessageHandle currentHandle = NULL;
|
||||
|
||||
//
|
||||
// The offset of the currentHandle in the MsgScrollingList.
|
||||
//
|
||||
register int handleOffset;
|
||||
|
||||
//
|
||||
// Find the current message. We would always start from the
|
||||
// currently selected message.
|
||||
//
|
||||
// Get the handle to the currently displaied message.
|
||||
//
|
||||
DtMailMessageHandle initialHandle = displayList->current_msg_handle();
|
||||
|
||||
//
|
||||
// Get the list of DtMailMessageHandle's.
|
||||
|
||||
MsgHndArray * msgHandles = displayList->get_messages();
|
||||
|
||||
//
|
||||
// Up to all of them can match, allocate and clear the list.
|
||||
//
|
||||
DtMailMessageHandle * matchList = NULL;
|
||||
if (findAll) {
|
||||
matchList = new DtMailMessageHandle[numberMessages+1];
|
||||
}
|
||||
unsigned int matchOffset = 0;
|
||||
|
||||
//
|
||||
// Deselect all messages.
|
||||
//
|
||||
XmListDeselectAllItems(displayList->baseWidget());
|
||||
|
||||
//
|
||||
// Start the search from the initially displaied message (+1).
|
||||
//
|
||||
handleOffset = displayList->position(initialHandle) - 1;
|
||||
if (_searchForward) {
|
||||
handleOffset++;
|
||||
if (handleOffset >= numberMessages) {
|
||||
handleOffset = 0;
|
||||
}
|
||||
} else {
|
||||
handleOffset--;
|
||||
if (handleOffset < 0) {
|
||||
handleOffset = numberMessages - 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (; handleOffset < numberMessages;) {
|
||||
currentHandle = msgHandles->at(handleOffset)->message_handle;
|
||||
|
||||
//
|
||||
// See if this message is a match, if it is...
|
||||
//
|
||||
if (compareMessage(currentHandle)) {
|
||||
matchCount++;
|
||||
|
||||
//
|
||||
// If we are finding all, then add to the list.
|
||||
// If not, then display this message and we are done.
|
||||
//
|
||||
if (findAll) {
|
||||
matchList[matchOffset++] = currentHandle;
|
||||
} else {
|
||||
XmListDeselectAllItems(displayList->baseWidget());
|
||||
//displayList->set_selected_item_position(handleOffset);
|
||||
displayList->display_and_select_message(error, currentHandle);
|
||||
break; // Only one.
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If we have looped back to the initial
|
||||
// message (handle), then we are done.
|
||||
//
|
||||
if (currentHandle == initialHandle) {
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the next message.
|
||||
//
|
||||
// If we have reached the end, start over.
|
||||
// (as if the list was a circular list)
|
||||
//
|
||||
// We loop forward (_searchForward == TRUE) else we loop backward.
|
||||
//
|
||||
if (_searchForward) {
|
||||
handleOffset++;
|
||||
if (handleOffset >= numberMessages) {
|
||||
handleOffset = 0;
|
||||
}
|
||||
} else {
|
||||
handleOffset--;
|
||||
if (handleOffset < 0) {
|
||||
handleOffset = numberMessages - 1;
|
||||
}
|
||||
}
|
||||
currentHandle = msgHandles->at(handleOffset)->message_handle;
|
||||
}
|
||||
|
||||
//
|
||||
// Select all the messages that match, and display the last
|
||||
// one in the list.
|
||||
//
|
||||
if (findAll) {
|
||||
|
||||
displayList->select_all_and_display_last(error, matchList, matchCount);
|
||||
if (matchCount > 0) {
|
||||
char *line = new char[80];
|
||||
/* NL_COMMENT
|
||||
* These strings are displayed on the find dialog status line
|
||||
* when one or more matching messages are found. The first
|
||||
* string is displayed when there is one matching message,
|
||||
* and the second string is displayed when there is more than
|
||||
* one. The %d is the number of messages that matched.
|
||||
*/
|
||||
if (matchCount == 1) {
|
||||
strcpy(line, GETMSG(DT_catd, 1, 232, "1 message selected"));
|
||||
} else {
|
||||
sprintf(line, GETMSG(DT_catd, 1, 233, "%d messages selected"),
|
||||
matchCount);
|
||||
}
|
||||
setStatus(line);
|
||||
delete [] line;
|
||||
}
|
||||
|
||||
// Clean up.
|
||||
delete matchList;
|
||||
matchList = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
normalCursor();
|
||||
theRoamApp.unbusyAllWindows();
|
||||
if (error.isNotSet()) {
|
||||
if (matchCount > 0) {
|
||||
if (!findAll) {
|
||||
clearStatus();
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
}
|
||||
/* NL_COMMENT
|
||||
* This string is displayed on the find dialog status line when
|
||||
* no matching messages were found.
|
||||
*/
|
||||
setStatus(GETMSG(DT_catd, 1, 234, "No matches were found"));
|
||||
return(False);
|
||||
}
|
||||
|
||||
Boolean
|
||||
FindDialog::compareMessage(DtMailMessageHandle handle)
|
||||
{
|
||||
Boolean found = False;
|
||||
register unsigned int offset;
|
||||
|
||||
//
|
||||
// Check for something to do.
|
||||
//
|
||||
for (offset = 0; offset < _num_text_fields; offset++) {
|
||||
if (_text_values[offset] != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If all fields are empty then we match anything
|
||||
if (offset >= _num_text_fields) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (offset < _num_text_fields && handle != NULL) {
|
||||
|
||||
// TODO - CHECK ERROR!!!
|
||||
DtMailEnv error;
|
||||
|
||||
//
|
||||
// Get the mail box.
|
||||
//
|
||||
DtMail::MailBox * mbox = _roamWindow->mailbox();
|
||||
|
||||
//
|
||||
// Get the DtMail::Message and Envelope for this handle.
|
||||
//
|
||||
DtMail::Message * message = mbox->getMessage(error, handle);
|
||||
DtMail::Envelope * envelope = message->getEnvelope(error);
|
||||
|
||||
//
|
||||
// Get the meassage header.
|
||||
//
|
||||
DtMailValueSeq header;
|
||||
|
||||
for (offset = 0; offset < _num_text_fields; offset++) {
|
||||
if (_text_values[offset] != NULL) {
|
||||
if (_text_abstract_name[offset] != NULL) {
|
||||
envelope->getHeader(error, _text_abstract_name[offset],
|
||||
DTM_TRUE, header);
|
||||
found = TRUE;
|
||||
} else {
|
||||
envelope->getHeader(error, _text_names[offset],
|
||||
DTM_FALSE, header);
|
||||
found = TRUE;
|
||||
}
|
||||
if (!compareHeader(error, header, _text_values[offset])) {
|
||||
found = False;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// Problem: if we have multiple search fields ... and use
|
||||
// the same "header" array ... "compareHeader" looks for
|
||||
// each "find" field in each (available) header field.
|
||||
// So, make sure only one is available for searching.
|
||||
// Really "offset" should be passed to "compareHeader" ...
|
||||
// That way, correct comparison can be done and the
|
||||
// memory for this array can be released correctly via the
|
||||
// destructor .... since "remove" fails to do so.
|
||||
header.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (offset > _num_text_fields) {
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
return(found);
|
||||
}
|
||||
|
||||
//
|
||||
// See if string 'toFind' is anyware in string 'str'.
|
||||
// A case-insensitive version of strstr().
|
||||
//
|
||||
static const char *
|
||||
strcasestr(const char *str, const char *toFind)
|
||||
{
|
||||
const char *result = NULL; // Default to not found.
|
||||
|
||||
if (str && toFind) { // Sanity check
|
||||
register int offset = 0;
|
||||
register int lenToFind = strlen(toFind);
|
||||
register int lenStr = strlen(str);
|
||||
|
||||
//
|
||||
// If toFind == "", then return the entire string (like strstr()).
|
||||
//
|
||||
if (lenToFind == 0) {
|
||||
result = str;
|
||||
} else {
|
||||
//
|
||||
// Start at each position in the string and look for
|
||||
// toFind - ignore case.
|
||||
//
|
||||
for (offset = 0; offset + lenToFind <= lenStr; offset++) {
|
||||
if (strncasecmp(&str[offset], toFind, lenToFind) == 0) {
|
||||
result = &str[offset];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
Boolean
|
||||
FindDialog::compareHeader(DtMailEnv & error,
|
||||
DtMailValueSeq & header,
|
||||
const char * cmpToString)
|
||||
{
|
||||
register int headerOffset = header.length() - 1;
|
||||
|
||||
error.clear();
|
||||
|
||||
while(headerOffset >= 0) {
|
||||
if ((strcasestr(*(header[headerOffset]), cmpToString)) != NULL) {
|
||||
return(TRUE);
|
||||
}
|
||||
headerOffset--;
|
||||
}
|
||||
return(False);
|
||||
}
|
||||
|
||||
//
|
||||
// Pull all fields out of the dialog and store in the class.
|
||||
//
|
||||
void
|
||||
FindDialog::getAllFields()
|
||||
{
|
||||
register unsigned int offset;
|
||||
|
||||
for (offset = 0; offset < _num_text_fields; offset++) {
|
||||
if (_text_fields[offset] != NULL) {
|
||||
_text_values[offset] = XmTextFieldGetString(_text_fields[offset]);
|
||||
|
||||
// Ignore zero length strings.
|
||||
if (_text_values[offset] != NULL) {
|
||||
if (strlen(_text_values[offset]) == 0) {
|
||||
_text_values[offset] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
FindDialog::textFieldCallback(
|
||||
Widget field,
|
||||
XtPointer data,
|
||||
XtPointer)
|
||||
{
|
||||
char *s;
|
||||
FindDialog *findData = (FindDialog *)data;
|
||||
|
||||
if (*(s = XmTextGetString(field)) == '\0') {
|
||||
// Empty field. Traverse
|
||||
(void) XmProcessTraversal(field, XmTRAVERSE_NEXT_TAB_GROUP);
|
||||
} else {
|
||||
// Field not empty. Do search
|
||||
findData->getAllFields();
|
||||
if (!findData->findMatching(False)) {
|
||||
XBell(XtDisplay(field), 0);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
FindDialog::directionCallback(Widget widget,
|
||||
XtPointer closure,
|
||||
XtPointer)
|
||||
{
|
||||
int which = (int) ((long) closure); // closure contains button #
|
||||
FindDialog *find;
|
||||
|
||||
// Client data is actually on the @!$?@* parent, not the toggle item
|
||||
XtVaGetValues(XtParent(widget), XmNuserData, &find, NULL);
|
||||
|
||||
if (which == 0) {
|
||||
find->setSearchForward(TRUE);
|
||||
} else {
|
||||
find->setSearchForward(False);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
FindDialog::findCallback(Widget /*button*/,
|
||||
XtPointer closure,
|
||||
XtPointer /*call_data*/)
|
||||
{
|
||||
FindDialog *findData = (FindDialog *)closure;
|
||||
|
||||
findData->getAllFields();
|
||||
findData->findMatching(False);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FindDialog::findSelectAllCallback(Widget /*button*/,
|
||||
XtPointer closure,
|
||||
XtPointer /*call_data*/)
|
||||
{
|
||||
FindDialog *findData = (FindDialog *)closure;
|
||||
|
||||
findData->getAllFields();
|
||||
findData->findMatching(TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
FindDialog::clearCallback(Widget /*button*/,
|
||||
XtPointer closure,
|
||||
XtPointer /*call_data*/)
|
||||
{
|
||||
FindDialog *findData = (FindDialog *)closure;
|
||||
register unsigned int offset;
|
||||
|
||||
for (offset = 0; offset < findData->_num_text_fields; offset++) {
|
||||
if (findData->_text_fields[offset] != NULL) {
|
||||
XmTextFieldSetString(findData->_text_fields[offset], "");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
FindDialog::closeCallback(Widget /*button*/,
|
||||
XtPointer closure,
|
||||
XtPointer /*call_data*/)
|
||||
{
|
||||
FindDialog *findData = (FindDialog *)closure;
|
||||
|
||||
findData->popdown();
|
||||
return;
|
||||
}
|
||||
134
cde/programs/dtmail/dtmail/FindDialog.h
Normal file
134
cde/programs/dtmail/dtmail/FindDialog.h
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: FindDialog.h /main/4 1996/04/21 19:42:01 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef FINDDIALOG_H
|
||||
#define FINDDIALOG_H
|
||||
|
||||
#include <DtMail/DtMail.hh>
|
||||
#include "Dialog.h"
|
||||
|
||||
//
|
||||
// This class is used for the 'Mailer - Find' dialog box.
|
||||
//
|
||||
class FindDialog : public Dialog {
|
||||
|
||||
public:
|
||||
FindDialog(RoamMenuWindow * parent);
|
||||
~FindDialog() { clear(); };
|
||||
|
||||
//
|
||||
// These come from 'Dialog'.
|
||||
//
|
||||
void popped_up() { };
|
||||
void popped_down() { };
|
||||
void popup() { XtPopup(_w, XtGrabNone); };
|
||||
void popdown() { XtPopdown(_w); };
|
||||
void widgetDestroyed() {};
|
||||
|
||||
// The set/clear status methods will set and clear the status line.
|
||||
//
|
||||
void setStatus(const char * str);
|
||||
void clearStatus(void);
|
||||
|
||||
Widget createWorkArea(Widget);
|
||||
|
||||
//
|
||||
// Like initialize() except returns success status.
|
||||
//
|
||||
Boolean startup();
|
||||
|
||||
//
|
||||
// Set the search direction for find.
|
||||
//
|
||||
void setSearchForward(Boolean forward) { // True == Forward, False = Backward.
|
||||
_searchForward = forward;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
struct ActionAreaItem {
|
||||
char * label; // Button label.
|
||||
XtCallbackProc callback;
|
||||
caddr_t data;
|
||||
};
|
||||
|
||||
//
|
||||
// Clear out the data. After this function is complete the
|
||||
// data should look as if the constructor was just called and
|
||||
// before initialize().
|
||||
//
|
||||
void clear();
|
||||
|
||||
Boolean findMatching(Boolean findAll = False);
|
||||
|
||||
Boolean compareMessage(DtMailMessageHandle handle);
|
||||
|
||||
Boolean compareHeader(DtMailEnv & error,
|
||||
DtMailValueSeq & seq,
|
||||
const char * cmpToString);
|
||||
|
||||
static void directionCallback(Widget button,
|
||||
XtPointer closure,
|
||||
XtPointer call_data);
|
||||
|
||||
static void findCallback(Widget button,
|
||||
XtPointer closure,
|
||||
XtPointer call_data);
|
||||
|
||||
static void findSelectAllCallback(Widget button,
|
||||
XtPointer closure,
|
||||
XtPointer call_data);
|
||||
|
||||
static void clearCallback(Widget button,
|
||||
XtPointer closure,
|
||||
XtPointer call_data);
|
||||
|
||||
static void closeCallback(Widget button,
|
||||
XtPointer closure,
|
||||
XtPointer call_data);
|
||||
|
||||
static void helpCallback(Widget button,
|
||||
XtPointer closure,
|
||||
XtPointer call_data);
|
||||
|
||||
static void textFieldCallback(Widget, XtPointer, XtPointer);
|
||||
|
||||
//
|
||||
// Pull all fields out of the dialog and store in _text_values;
|
||||
//
|
||||
void getAllFields();
|
||||
|
||||
unsigned int _num_text_fields; // Array size.
|
||||
|
||||
Widget _status_text;
|
||||
Widget * _text_fields;
|
||||
char ** _text_names;
|
||||
char ** _text_abstract_name;
|
||||
char ** _text_labels;
|
||||
char ** _text_values;
|
||||
|
||||
unsigned int _num_buttons; // Array size.
|
||||
ActionAreaItem * _buttonData;
|
||||
|
||||
Boolean _searchForward;
|
||||
RoamMenuWindow * _roamWindow;
|
||||
};
|
||||
|
||||
#endif
|
||||
204
cde/programs/dtmail/dtmail/Fonts.C
Normal file
204
cde/programs/dtmail/dtmail/Fonts.C
Normal file
@@ -0,0 +1,204 @@
|
||||
/* $TOG: Fonts.C /main/8 1997/09/04 08:06:26 mgreess $ */
|
||||
/*
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994 Novell, Inc.
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
*
|
||||
* This code was borrowed from dtcm (Calendar Manager).
|
||||
* Its purpose is to find a font in a particular family that is
|
||||
* the same size as the user font being used.
|
||||
*/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/AtomMgr.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "Fonts.h"
|
||||
|
||||
|
||||
/*
|
||||
* Walk a font_list looking for a FontSet with the
|
||||
* XmFONTLIST_DEFAULT_TAG set. If we fail to find a FontSet with this tag,
|
||||
* return the first FontSet found. If we fail to find a FontSet return
|
||||
* the first font found.
|
||||
*
|
||||
* This function returns either a XFontStruct or a XFontSet. The type can
|
||||
* be determined by the value of type_return which will equal either
|
||||
* XmFONT_IS_FONTSET or XmFONT_IS_FONT.
|
||||
*
|
||||
* The XFontStruct or XFontSet that is returned is not a copy and should
|
||||
* not be freed.
|
||||
*/
|
||||
static XtPointer
|
||||
get_font(
|
||||
XmFontList font_list,
|
||||
XmFontType *type_return)
|
||||
{
|
||||
XmFontContext fl_context;
|
||||
XmFontListEntry fl_entry;
|
||||
XtPointer fl_entry_font = NULL, font_to_use = NULL;
|
||||
char *fl_entry_font_tag;
|
||||
Boolean found_font_set = False,
|
||||
found_font_struct = False,
|
||||
do_break = False;
|
||||
|
||||
*type_return = XmFONT_IS_FONT;
|
||||
|
||||
if (!XmFontListInitFontContext(&fl_context, font_list))
|
||||
return (XtPointer)NULL;
|
||||
|
||||
do
|
||||
{
|
||||
fl_entry = XmFontListNextEntry(fl_context);
|
||||
if (fl_entry)
|
||||
{
|
||||
fl_entry_font = XmFontListEntryGetFont(fl_entry, type_return);
|
||||
if (*type_return == XmFONT_IS_FONTSET)
|
||||
{
|
||||
fl_entry_font_tag = XmFontListEntryGetTag(fl_entry);
|
||||
|
||||
/*
|
||||
* Save the first font set found in-
|
||||
* case the default tag is not set.
|
||||
*/
|
||||
if (!found_font_set)
|
||||
{
|
||||
font_to_use = fl_entry_font;
|
||||
found_font_set = True;
|
||||
found_font_struct = True;
|
||||
|
||||
if (!strcmp(XmFONTLIST_DEFAULT_TAG, fl_entry_font_tag))
|
||||
do_break = True;
|
||||
}
|
||||
else if (!strcmp(XmFONTLIST_DEFAULT_TAG, fl_entry_font_tag))
|
||||
{
|
||||
/* Found right font set */
|
||||
font_to_use = fl_entry_font;
|
||||
do_break = True;
|
||||
}
|
||||
|
||||
if (fl_entry_font_tag != NULL)
|
||||
XtFree((char*) fl_entry_font_tag);
|
||||
|
||||
if (do_break)
|
||||
break;
|
||||
}
|
||||
else if (!found_font_struct)
|
||||
{
|
||||
font_to_use = fl_entry_font;
|
||||
found_font_struct = True;
|
||||
}
|
||||
}
|
||||
} while (fl_entry != NULL);
|
||||
|
||||
XmFontListFreeFontContext(fl_context);
|
||||
|
||||
if (!found_font_set && !found_font_struct)
|
||||
return (XtPointer)NULL;
|
||||
|
||||
return (XtPointer)font_to_use;
|
||||
}
|
||||
|
||||
/*
|
||||
* Strip the font out of a give fontlist.
|
||||
*/
|
||||
Boolean
|
||||
fontlist_to_font(
|
||||
XmFontList font_list,
|
||||
FontType *new_font)
|
||||
{
|
||||
XmFontType type_return;
|
||||
XtPointer font_data;
|
||||
|
||||
if (!font_list) return False;
|
||||
|
||||
font_data = get_font(font_list, &type_return);
|
||||
|
||||
if (!font_data)
|
||||
return False;
|
||||
|
||||
new_font->cf_type = type_return;
|
||||
|
||||
if (type_return == XmFONT_IS_FONTSET)
|
||||
new_font->f.cf_fontset = (XFontSet)font_data;
|
||||
else
|
||||
new_font->f.cf_font = (XFontStruct *)font_data;
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the pixel size of the user font. Try to match a symbol
|
||||
* font to that size. If one can't be found, return NULL, calling
|
||||
* function will probably default to the user font.
|
||||
*/
|
||||
void
|
||||
load_app_font(
|
||||
Widget w,
|
||||
FontType *userfont,
|
||||
char **fontname)
|
||||
{
|
||||
unsigned long pixel_size;
|
||||
Display *dpy = XtDisplay(w);
|
||||
char font_name[128],
|
||||
*font_name_ptr = font_name,
|
||||
**font_names;
|
||||
int nnames;
|
||||
Atom pixel_atom = XmInternAtom(dpy, "PIXEL_SIZE", FALSE);
|
||||
|
||||
/* First get the pixel size from the User Font */
|
||||
if (userfont->cf_type == XmFONT_IS_FONT) {
|
||||
/* If we can't get the pixel size from the user font we
|
||||
* default to a 12 pixel font.
|
||||
*/
|
||||
if (!XGetFontProperty(userfont->f.cf_font, pixel_atom,
|
||||
&pixel_size))
|
||||
pixel_size = 12;
|
||||
} else {
|
||||
XFontStruct **font_struct_list;
|
||||
char **font_name_list;
|
||||
int list_size;
|
||||
|
||||
if (!(list_size = XFontsOfFontSet(userfont->f.cf_fontset,
|
||||
&font_struct_list,
|
||||
&font_name_list))) {
|
||||
pixel_size = 12;
|
||||
} else {
|
||||
if (!XGetFontProperty(font_struct_list[0],
|
||||
pixel_atom,
|
||||
&pixel_size))
|
||||
pixel_size = 12;
|
||||
}
|
||||
}
|
||||
|
||||
/* See if the font exists */
|
||||
sprintf (font_name,
|
||||
"-dt-application-medium-r-normal--%ld-*-*-*-*-*-dtsymbol-*",
|
||||
pixel_size);
|
||||
font_names = XListFonts(dpy, font_name, 1, &nnames);
|
||||
|
||||
if (!nnames) {
|
||||
/* Try again */
|
||||
sprintf (font_name,
|
||||
"-*-symbol-medium-r-normal--%ld-*-*-*-*-*", pixel_size);
|
||||
font_names = XListFonts(dpy, font_name, 1, &nnames);
|
||||
}
|
||||
if (!nnames) {
|
||||
/* Try again with the default size */
|
||||
pixel_size = 12;
|
||||
sprintf (font_name,
|
||||
"-dt-application-medium-r-normal--%ld-*-*-*-*-*-dtsymbol-*",
|
||||
pixel_size);
|
||||
font_names = XListFonts(dpy, font_name, 1, &nnames);
|
||||
}
|
||||
if (!nnames) {
|
||||
*fontname = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
XFreeFontNames(font_names);
|
||||
*fontname = XtNewString (font_name);
|
||||
}
|
||||
|
||||
31
cde/programs/dtmail/dtmail/Fonts.h
Normal file
31
cde/programs/dtmail/dtmail/Fonts.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/* $XConsortium: Fonts.h /main/3 1996/04/21 19:52:59 drk $ */
|
||||
/*
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994 Novell, Inc.
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef FONTS_H
|
||||
#define FONTS_H
|
||||
|
||||
typedef struct _FontType {
|
||||
XmFontType cf_type;
|
||||
union {
|
||||
XFontStruct *cf_font;
|
||||
XFontSet cf_fontset;
|
||||
} f;
|
||||
} FontType;
|
||||
|
||||
extern Boolean
|
||||
fontlist_to_font(
|
||||
XmFontList font_list,
|
||||
FontType *new_font);
|
||||
|
||||
extern void
|
||||
load_app_font(
|
||||
Widget w,
|
||||
FontType *userfont,
|
||||
char **fontname);
|
||||
|
||||
#endif /* FONTS_H */
|
||||
328
cde/programs/dtmail/dtmail/Icon.C
Normal file
328
cde/programs/dtmail/dtmail/Icon.C
Normal file
@@ -0,0 +1,328 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: Icon.C /main/8 1998/10/27 19:42:30 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifdef DEBUG_CB_REASON
|
||||
#define PRINTCB(str) printf("%s\n",str)
|
||||
#else
|
||||
#define PRINTCB(str)
|
||||
#endif
|
||||
|
||||
#include <Dt/Dnd.h>
|
||||
#include "Icon.h"
|
||||
#include "RoamApp.h"
|
||||
#include "DtMailEditor.hh"
|
||||
#include "Editor.hh"
|
||||
#include <Dt/Editor.h>
|
||||
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/StringDefs.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <Xm/ColorObjP.h>
|
||||
|
||||
Icon::Icon (
|
||||
Attachment *classparent,
|
||||
char *name,
|
||||
XmString label, /* label string */
|
||||
unsigned short /* type */,
|
||||
Widget parent,
|
||||
int indx
|
||||
) : UIComponent (name)
|
||||
{
|
||||
#define MAX_NUM_COLORS 8
|
||||
DtMail::BodyPart *bp;
|
||||
DtMailEnv mail_error;
|
||||
char *type = NULL, *icon_name = NULL;
|
||||
char *icon_filename = NULL, *host_prefix = NULL;
|
||||
int n = 0;
|
||||
Arg args[20];
|
||||
int btn1_transfer = 0;
|
||||
int colorUse;
|
||||
short act, inact, prim, second, text;
|
||||
XmPixelSet pixels[XmCO_NUM_COLORS];
|
||||
|
||||
_parent = classparent;
|
||||
_indx = indx;
|
||||
_is_selected = FALSE;
|
||||
_is_armed = FALSE;
|
||||
|
||||
// Get the pixmap image file name for this attachment.
|
||||
bp = _parent->getBodyPart();
|
||||
bp->getContents(mail_error, NULL, NULL, &type, NULL, NULL, NULL);
|
||||
|
||||
// Retrieve the host name.
|
||||
host_prefix = DtDtsDataTypeToAttributeValue(type,
|
||||
DtDTS_DA_DATA_HOST,
|
||||
NULL);
|
||||
|
||||
// Get the name of the icon.
|
||||
icon_name = (char *) DtDtsDataTypeToAttributeValue(type,
|
||||
DtDTS_DA_ICON,
|
||||
NULL);
|
||||
// Retrieve icon file name
|
||||
icon_filename = XmGetIconFileName(XtScreen(parent),
|
||||
NULL,
|
||||
icon_name,
|
||||
host_prefix,
|
||||
DtMEDIUM);
|
||||
|
||||
// Get pixel data.
|
||||
XmeGetColorObjData(XtScreen(parent), &colorUse, pixels, XmCO_NUM_COLORS,
|
||||
&act, &inact, &prim, &second, &text);
|
||||
_cur_fg = pixels[text].fg;
|
||||
_cur_bg = pixels[text].sc;
|
||||
|
||||
n = 0;
|
||||
XtSetArg (args[n], XmNshadowThickness, 0); n++;
|
||||
XtSetArg (args[n], XmNfillOnArm, FALSE); n++;
|
||||
XtSetArg (args[n], XmNhighlightThickness, 2); n++;
|
||||
XtSetArg (args[n], XmNimageName, icon_filename); n++;
|
||||
XtSetArg (args[n], XmNstring, label); n++;
|
||||
XtSetArg( args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
|
||||
XtSetArg( args[n], XmNpixmapPosition, XmPIXMAP_TOP); n++;
|
||||
XtSetArg( args[n], XmNbehavior, XmICON_DRAG); n++;
|
||||
XtSetArg( args[n], XmNfillMode, XmFILL_PARENT); n++;
|
||||
XtSetArg( args[n], XmNbackground, _cur_bg); n++;
|
||||
XtSetArg( args[n], XmNforeground, _cur_fg); n++;
|
||||
|
||||
_w = _DtCreateIcon(parent,"iconGadget", args,n);
|
||||
|
||||
XtAddEventHandler(XtParent(_w), Button1MotionMask, FALSE,
|
||||
(XtEventHandler)&Icon::dragMotionHandler,
|
||||
(XtPointer)this);
|
||||
|
||||
XtVaGetValues((Widget)XmGetXmDisplay(XtDisplay(XtParent(_w))),
|
||||
"enableBtn1Transfer", &btn1_transfer,
|
||||
NULL);
|
||||
|
||||
if (btn1_transfer != True) {
|
||||
XtAddEventHandler(XtParent(_w), Button2MotionMask, FALSE,
|
||||
(XtEventHandler)&Icon::dragMotionHandler,
|
||||
(XtPointer)this);
|
||||
}
|
||||
|
||||
XtAddCallback(
|
||||
_w,
|
||||
XmNcallback,
|
||||
(XtCallbackProc)&Icon::iconCallback,
|
||||
(XtPointer)this
|
||||
);
|
||||
|
||||
if (type) {
|
||||
free(type);
|
||||
type = NULL;
|
||||
}
|
||||
|
||||
if (host_prefix) {
|
||||
DtDtsFreeAttributeValue(host_prefix);
|
||||
host_prefix = NULL;
|
||||
}
|
||||
if (icon_name) {
|
||||
DtDtsFreeAttributeValue(icon_name);
|
||||
icon_name = NULL;
|
||||
}
|
||||
if (icon_filename) {
|
||||
XtFree(icon_filename);
|
||||
icon_filename = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Icon::~Icon()
|
||||
{
|
||||
int btn1_transfer = 0;
|
||||
|
||||
XtRemoveCallback(
|
||||
_w,
|
||||
XmNcallback,
|
||||
(XtCallbackProc)&Icon::iconCallback,
|
||||
(XtPointer)this
|
||||
);
|
||||
XtRemoveEventHandler(XtParent(_w), Button1MotionMask, FALSE,
|
||||
(XtEventHandler)&Icon::dragMotionHandler,
|
||||
(XtPointer)this);
|
||||
|
||||
XtVaGetValues((Widget)XmGetXmDisplay(XtDisplay(XtParent(_w))),
|
||||
"enableBtn1Transfer", &btn1_transfer,
|
||||
NULL);
|
||||
|
||||
if (btn1_transfer != True) {
|
||||
XtRemoveEventHandler(XtParent(_w), Button2MotionMask, FALSE,
|
||||
(XtEventHandler)&Icon::dragMotionHandler,
|
||||
(XtPointer)this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Icon::iconCallback(Widget , XtPointer client_data, XtPointer call_data)
|
||||
{
|
||||
DtIconCallbackStruct *cb = (DtIconCallbackStruct *)call_data;
|
||||
Icon *obj = (Icon *)client_data;
|
||||
XEvent *event;
|
||||
|
||||
if ((event = cb->event) != (XEvent *) NULL) {
|
||||
/*
|
||||
* The following seems rather bogus.... to make assumptions
|
||||
* about the context of a ButtonPress before decoding
|
||||
* the reason for the callback.
|
||||
*/
|
||||
if ((event->type == ButtonPress) &&
|
||||
(! IsModifierKey(XLookupKeysym((XKeyEvent *) event, 0)))) {
|
||||
if (event->xbutton.state & ControlMask)
|
||||
{
|
||||
/* Cntrl Button press processing*/
|
||||
// Need to handle it. Postponed...
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch(cb->reason) {
|
||||
case XmCR_UNHIGHLIGHT:
|
||||
PRINTCB("unhighlight");
|
||||
break;
|
||||
case XmCR_HIGHLIGHT:
|
||||
PRINTCB("highlight");
|
||||
break;
|
||||
case XmCR_ACTIVATE:
|
||||
PRINTCB("activate");
|
||||
break;
|
||||
case XmCR_DISARM:
|
||||
obj->disarm();
|
||||
PRINTCB("disarm");
|
||||
break;
|
||||
case XmCR_ARM:
|
||||
obj->arm();
|
||||
PRINTCB("arm");
|
||||
break;
|
||||
case XmCR_SELECT:
|
||||
PRINTCB("select");
|
||||
obj->select();
|
||||
break;
|
||||
case XmCR_DEFAULT_ACTION:
|
||||
PRINTCB("default_action");
|
||||
obj->defaultAction();
|
||||
break;
|
||||
case XmCR_DRAG:
|
||||
PRINTCB("drag");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Icon::dragMotionHandler(
|
||||
Widget widget,
|
||||
XtPointer clientData,
|
||||
XEvent *event)
|
||||
{
|
||||
Icon *icon = (Icon *) clientData;
|
||||
|
||||
icon->parent()->parent()->owner()->attachDragMotionHandler(widget, event);
|
||||
}
|
||||
|
||||
void
|
||||
Icon::invert()
|
||||
{
|
||||
Arg args[2];
|
||||
int n;
|
||||
Pixel swap;
|
||||
|
||||
n = 0;
|
||||
XtSetArg( args[n], XmNbackground, _cur_fg); n++;
|
||||
XtSetArg( args[n], XmNforeground, _cur_bg); n++;
|
||||
XtSetValues(_w, args, n);
|
||||
|
||||
swap = _cur_fg;
|
||||
_cur_fg = _cur_bg;
|
||||
_cur_bg = swap;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Icon::arm()
|
||||
{
|
||||
// deselect others in all cases
|
||||
_parent->set_selected();
|
||||
|
||||
if(_is_armed == TRUE)
|
||||
return;
|
||||
|
||||
_is_selected = TRUE;
|
||||
|
||||
invert();
|
||||
|
||||
_is_armed = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
Icon::disarm()
|
||||
{
|
||||
if(_is_armed == FALSE || _is_selected == TRUE )
|
||||
return;
|
||||
|
||||
invert();
|
||||
|
||||
_is_armed = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
Icon::unselect()
|
||||
{
|
||||
if(_is_selected == FALSE)
|
||||
return;
|
||||
|
||||
_is_selected = FALSE;
|
||||
|
||||
disarm();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Icon::primitiveSelect()
|
||||
{
|
||||
if(_is_selected == TRUE || _is_armed == TRUE)
|
||||
return;
|
||||
|
||||
_is_selected = TRUE;
|
||||
|
||||
invert();
|
||||
|
||||
_is_armed = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
Icon::select()
|
||||
{
|
||||
if(_is_selected == TRUE)
|
||||
return;
|
||||
|
||||
arm();
|
||||
}
|
||||
|
||||
void
|
||||
Icon::defaultAction()
|
||||
{
|
||||
select();
|
||||
_parent->handleDoubleClick();
|
||||
}
|
||||
70
cde/programs/dtmail/dtmail/Icon.h
Normal file
70
cde/programs/dtmail/dtmail/Icon.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: Icon.h /main/6 1998/01/16 11:21:49 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef ICON_H
|
||||
#define ICON_H
|
||||
|
||||
#include "UIComponent.h"
|
||||
#include "Attachment.h"
|
||||
|
||||
#include <DtMail/DtMail.hh>
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
|
||||
#include <Dt/Dts.h>
|
||||
#include <Dt/IconFile.h>
|
||||
extern "C" {
|
||||
#include <Dt/Icon.h>
|
||||
}
|
||||
|
||||
class Icon : public UIComponent {
|
||||
private:
|
||||
Boolean _is_selected;
|
||||
Boolean _is_armed;
|
||||
Pixel _cur_fg, _cur_bg;
|
||||
void invert(void);
|
||||
void arm(void);
|
||||
void disarm(void);
|
||||
int _indx; /* user data */
|
||||
static void dragMotionHandler(Widget, XtPointer, XEvent*);
|
||||
static void iconCallback(Widget, XtPointer, XtPointer);
|
||||
protected:
|
||||
Attachment *_parent; // associated attachemnt
|
||||
|
||||
public:
|
||||
// Constructor and destructor
|
||||
Icon (Attachment*, char*, XmString label, unsigned short, Widget, int);
|
||||
virtual ~Icon();
|
||||
|
||||
// AV callback methods
|
||||
void select(void);
|
||||
void primitiveSelect(void);
|
||||
void defaultAction(void);
|
||||
void unselect();
|
||||
|
||||
// associated attachment
|
||||
Attachment* parent() { return ( _parent ); }
|
||||
virtual const char *const className() { return ( "Icon" ); }
|
||||
|
||||
// static functions
|
||||
static int maxIconWidth() { return 38; }
|
||||
static int maxIconHeight() { return 38; }
|
||||
};
|
||||
#endif
|
||||
346
cde/programs/dtmail/dtmail/IgnoreListUiItem.C
Normal file
346
cde/programs/dtmail/dtmail/IgnoreListUiItem.C
Normal file
@@ -0,0 +1,346 @@
|
||||
/* $TOG: IgnoreListUiItem.C /main/4 1997/09/03 17:38:42 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: IgnoreListUiItem.C /main/4 1997/09/03 17:38:42 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
#include "RoamApp.h"
|
||||
#include <Xm/List.h>
|
||||
#include <Xm/TextF.h>
|
||||
#include <DtMail/options_util.h>
|
||||
#include "options_ui.h"
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/ListUiItem.hh>
|
||||
#include <DtMail/IgnoreListUiItem.hh>
|
||||
|
||||
void handleIgnoreSelection(Widget w, XtPointer clientdata, XtPointer calldata);
|
||||
extern Boolean props_changed;
|
||||
|
||||
// IgnoreListUiItem::IgnoreListUiItem
|
||||
// IgnoreListUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
IgnoreListUiItem::IgnoreListUiItem(Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
Widget text_entry_widget):ListUiItem(w, source, search_key, NULL)
|
||||
{
|
||||
source = source; search_key = search_key;
|
||||
|
||||
entry_field_widget = text_entry_widget;
|
||||
|
||||
list_items = NULL;
|
||||
deleted_items = NULL;
|
||||
|
||||
XtVaSetValues(w,
|
||||
XmNuserData, this,
|
||||
XmNautomaticSelection, True,
|
||||
XmNselectionPolicy, XmBROWSE_SELECT,
|
||||
NULL);
|
||||
|
||||
XtAddCallback(w,
|
||||
XmNbrowseSelectionCallback,
|
||||
(XtCallbackProc)handleIgnoreSelection,
|
||||
(XtPointer)this);
|
||||
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
void handleIgnoreSelection(Widget w, XtPointer, XtPointer calldata)
|
||||
{
|
||||
IgnoreListUiItem *item;
|
||||
XmListCallbackStruct *list_info = (XmListCallbackStruct *)calldata;
|
||||
char *selection_string = NULL;
|
||||
DtVirtArray<PropStringPair *> *list_items;
|
||||
|
||||
XtVaGetValues(w,
|
||||
XmNuserData, &item,
|
||||
NULL);
|
||||
|
||||
list_items = item->getItemList();
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
// motif index is 1 based
|
||||
//virtarry is 0 based
|
||||
PropStringPair *pair = (*list_items)[list_info->item_position - 1];
|
||||
|
||||
if(pair != NULL)
|
||||
{
|
||||
XtVaSetValues(item->getEntryFieldWidget(),
|
||||
XmNvalue,pair->label,
|
||||
NULL);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// IgnoreListUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void IgnoreListUiItem::writeFromUiToSource()
|
||||
{
|
||||
Widget w = this->getWidget();
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
int i, num_items;
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
num_items = deleted_items->length();
|
||||
|
||||
for(i = 0; i < num_items; i++)
|
||||
{
|
||||
mail_rc->removeIgnore(error,(*deleted_items)[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
num_items = list_items->length();
|
||||
for(i = 0; i < num_items; i++)
|
||||
{
|
||||
mail_rc->addIgnore(error,(*list_items)[i]->label);
|
||||
}
|
||||
}
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
delete deleted_items;
|
||||
deleted_items = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// IgnoreListUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void IgnoreListUiItem::writeFromSourceToUi()
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
DtVirtArray<char *> *char_list = NULL;
|
||||
int list_len, i;
|
||||
PropStringPair *new_pair;
|
||||
|
||||
Widget w = this->getWidget();
|
||||
|
||||
XmListDeleteAllItems(w);
|
||||
|
||||
if(deleted_items != NULL)
|
||||
{
|
||||
delete deleted_items;
|
||||
deleted_items = NULL;
|
||||
}
|
||||
|
||||
if(list_items != NULL)
|
||||
{
|
||||
delete list_items;
|
||||
list_items=NULL;
|
||||
}
|
||||
|
||||
// ignore list code here...
|
||||
char_list = mail_rc->getIgnoreList();
|
||||
|
||||
if(char_list != NULL)
|
||||
{
|
||||
list_len = char_list->length();
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
for(i = 0; i < list_len; i++)
|
||||
{
|
||||
new_pair = new PropStringPair;
|
||||
new_pair->label = strdup((*char_list)[i]);
|
||||
new_pair->value = NULL;
|
||||
|
||||
list_items->append(new_pair);
|
||||
}
|
||||
}
|
||||
|
||||
options_list_init(w, char_list);
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void IgnoreListUiItem::handleAddButtonPress()
|
||||
{
|
||||
Widget entry_field = this->getEntryFieldWidget();
|
||||
char *test_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
|
||||
XtVaGetValues(entry_field,
|
||||
XmNvalue, &test_str,
|
||||
NULL);
|
||||
|
||||
if(test_str != NULL)
|
||||
if( (strlen(test_str) > 1) &&
|
||||
(!XmListItemExists(this->getWidget(),
|
||||
XmStringCreateLocalized(test_str))) )
|
||||
{
|
||||
new_pair = new PropStringPair;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
new_pair->label = strdup(test_str);
|
||||
new_pair->value = NULL;
|
||||
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,pos_list[0] - 1);
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(new_pair->label),
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
pos_list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(list_items == NULL)
|
||||
list_items = new DtVirtArray<PropStringPair *>(10);
|
||||
|
||||
list_items->insert(new_pair,0);
|
||||
XmListAddItem(this->getWidget(),
|
||||
XmStringCreateLocalized(new_pair->label),
|
||||
1);
|
||||
XmListSelectPos(this->getWidget(),
|
||||
1,
|
||||
TRUE);
|
||||
|
||||
XmListSetPos(this->getWidget(),
|
||||
1);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void IgnoreListUiItem::handleChangeButtonPress()
|
||||
{
|
||||
Widget entry_field = this->getEntryFieldWidget();
|
||||
char *test_str = NULL;
|
||||
PropStringPair *new_pair = NULL;
|
||||
XmString replace_string;
|
||||
int *pos_list, num_pos;
|
||||
|
||||
// if nothing selected nothing to change...
|
||||
if(XmListGetSelectedPos(this->getWidget(),
|
||||
&pos_list,
|
||||
&num_pos))
|
||||
{
|
||||
XtVaGetValues(entry_field,
|
||||
XmNvalue, &test_str,
|
||||
NULL);
|
||||
|
||||
if(test_str != NULL)
|
||||
if(strlen(test_str) > 1)
|
||||
{
|
||||
|
||||
new_pair = (*list_items)[pos_list[0] - 1];
|
||||
|
||||
if(deleted_items == NULL)
|
||||
{
|
||||
deleted_items = new DtVirtArray<char *>(10);
|
||||
}
|
||||
|
||||
deleted_items->append(strdup((*list_items)[pos_list[0] -1]->label));
|
||||
|
||||
free(new_pair->label);
|
||||
new_pair->label = strdup(test_str);
|
||||
|
||||
list_items->insert(new_pair,pos_list[0] - 1);
|
||||
replace_string = XmStringCreateLocalized(new_pair->label);
|
||||
|
||||
XmListReplaceItemsPos(this->getWidget(),
|
||||
&replace_string,
|
||||
1,
|
||||
pos_list[0]);
|
||||
|
||||
XmListSelectPos(this->getWidget(),
|
||||
pos_list[0],
|
||||
TRUE);
|
||||
}
|
||||
props_changed = TRUE;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////
|
||||
void IgnoreListUiItem::handleDeleteButtonPress()
|
||||
{
|
||||
Widget list_widget = this->getWidget();
|
||||
int *p_list, p_count;
|
||||
|
||||
// get the selected position
|
||||
if(XmListGetSelectedPos(list_widget,
|
||||
&p_list,
|
||||
&p_count))
|
||||
{
|
||||
|
||||
if(deleted_items == NULL)
|
||||
{
|
||||
deleted_items = new DtVirtArray<char *>(10);
|
||||
}
|
||||
|
||||
deleted_items->append(strdup((*list_items)[p_list[0] -1]->label));
|
||||
|
||||
// delete the item from our list
|
||||
this->list_items->remove(p_list[0] - 1); // remove only first
|
||||
|
||||
// delete the item from the widget
|
||||
XmListDeletePos(list_widget, p_list[0]);
|
||||
|
||||
XtVaSetValues(this->getEntryFieldWidget(),
|
||||
XmNvalue,"",
|
||||
NULL);
|
||||
XmListSelectPos(list_widget,
|
||||
p_list[0],
|
||||
TRUE);
|
||||
props_changed = TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
void IgnoreListUiItem::AddDefaults()
|
||||
{
|
||||
DtMailEnv error;
|
||||
DtMail::Session * d_session = theRoamApp.session()->session();
|
||||
DtMail::MailRc * mail_rc = d_session->mailRc(error);
|
||||
DtVirtArray<char *> *char_list = NULL;
|
||||
int list_len;
|
||||
|
||||
// ignore list code here...
|
||||
char_list = mail_rc->getIgnoreList();
|
||||
|
||||
list_len = char_list->length();
|
||||
if(list_len == 0)
|
||||
{
|
||||
XmTextFieldSetString(entry_field_widget,"Received");
|
||||
handleAddButtonPress();
|
||||
XmTextFieldSetString(entry_field_widget,"");
|
||||
mail_rc->addIgnore(error,"Received");
|
||||
mail_rc->update(error);
|
||||
}
|
||||
}
|
||||
|
||||
71
cde/programs/dtmail/dtmail/Image.C
Normal file
71
cde/programs/dtmail/dtmail/Image.C
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: Image.C /main/4 1996/04/21 19:42:11 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifdef DEAD_WOOD
|
||||
|
||||
#include "Image.h"
|
||||
#include "stdlib.h"
|
||||
Image::Image( Widget w, char *filename )
|
||||
{
|
||||
GC gc;
|
||||
Pixmap bitmap,pixmap;
|
||||
int xhot,yhot;
|
||||
XGCValues values;
|
||||
Display *display=XtDisplay( w );
|
||||
|
||||
_filename=strdup(filename);
|
||||
|
||||
|
||||
|
||||
XReadBitmapFile( display,
|
||||
RootWindowOfScreen(XtScreen(w)),
|
||||
_filename,
|
||||
&_width,
|
||||
&_height,
|
||||
&bitmap,
|
||||
&xhot,
|
||||
&yhot );
|
||||
|
||||
pixmap = XCreatePixmap( display,
|
||||
RootWindowOfScreen( XtScreen(w) ),
|
||||
_width,
|
||||
_height,
|
||||
DefaultDepthOfScreen( XtScreen(w) ));
|
||||
|
||||
// XtVaGetValues( w,
|
||||
// XtNfontColor, &values.foreground,
|
||||
// XtNbackground, &values.background,
|
||||
// NULL );
|
||||
|
||||
gc = XtGetGC( w, GCForeground | GCBackground, &values );
|
||||
|
||||
XCopyPlane( display, bitmap, pixmap, gc, 0, 0, _width, _height, 0 ,0 ,1 );
|
||||
_image = XGetImage( display, pixmap,
|
||||
0, 0,
|
||||
_width, _height,
|
||||
AllPlanes, ZPixmap );
|
||||
|
||||
}
|
||||
|
||||
Image::~Image(){
|
||||
free ( _filename );
|
||||
}
|
||||
|
||||
#endif /* DEAD_WOOD */
|
||||
39
cde/programs/dtmail/dtmail/Image.h
Normal file
39
cde/programs/dtmail/dtmail/Image.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $XConsortium: Image.h /main/4 1996/04/21 19:42:14 drk $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef IMAGE_H
|
||||
#define IMAGE_H
|
||||
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/StringDefs.h>
|
||||
|
||||
|
||||
class Image {
|
||||
private:
|
||||
XImage *_image;
|
||||
unsigned int _width,_height;
|
||||
char *_filename;
|
||||
public:
|
||||
Image( Widget, char * );
|
||||
~Image();
|
||||
XImage *image() { return _image; }
|
||||
};
|
||||
|
||||
#endif
|
||||
126
cde/programs/dtmail/dtmail/Imakefile
Normal file
126
cde/programs/dtmail/dtmail/Imakefile
Normal file
@@ -0,0 +1,126 @@
|
||||
XCOMM $TOG: Imakefile /main/25 1998/02/17 15:18:16 mgreess $
|
||||
|
||||
#define CplusplusSource YES
|
||||
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
|
||||
EXTRA_LOAD_FLAGS = ExtraLoadFlags $(UNSHARED_CXXLIB)
|
||||
|
||||
INCLUDES = -I. -I../include -I../include/MotifApp \
|
||||
-I../include/utils -I../include/DtMail \
|
||||
-I../libDtMail/RFC -I$(CDELIBSRC) -I$(DTHELPSRC)
|
||||
|
||||
#ifndef DtMailDefines
|
||||
# define DtMailDefines
|
||||
#endif
|
||||
DEFINES = -DRELEASE_NOTES -DDTMAIL_TOOLTALK -DDTEDITOR DtMailDefines
|
||||
|
||||
DEPLIBS = ../MotifApp/libMotifApp.a ../libDtMail/libDtMail.a DepDtClientLibs
|
||||
LOCAL_LIBRARIES = ../libDtMail/libDtMail.a ../MotifApp/libMotifApp.a DtClientLibs
|
||||
|
||||
/* Sun needs the widechar library */
|
||||
#ifdef SunArchitecture
|
||||
SYS_LIBRARIES = $(DYNLIBSYSLIB) $(ICONVSYSLIB) $(REGEXSYSLIB) -lw -lm
|
||||
#else
|
||||
SYS_LIBRARIES = $(DYNLIBSYSLIB) $(ICONVSYSLIB) $(REGEXSYSLIB) -lm
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SunArchitecture
|
||||
# ifndef SUNPRODIR
|
||||
SUNPRO_DIR = /opt/SUNWspro
|
||||
# else
|
||||
SUNPRO_DIR = SUNPRODIR
|
||||
# endif
|
||||
|
||||
C++LIBPATH = -L$(SUNPRO_DIR)/lib
|
||||
|
||||
# ifdef USE_SPRO_V3
|
||||
SPRO_V3_OPTIONS = -noex -USPRO_V2
|
||||
# ifdef DEBUGTREE
|
||||
SPRO_V3_OPTIONS += -xsb
|
||||
# endif /* DEBUGTREE */
|
||||
# else
|
||||
EXTRA_CCOPTIONS += -DSPRO_V2
|
||||
# endif /* USE_SPRO_V3 */
|
||||
|
||||
EXTRA_C++OPTIONS = -xF +w $(SPRO_V3_OPTIONS)
|
||||
EXTRA_CCOPTIONS = -xF -xstrconst -Xa -v
|
||||
|
||||
# ifdef USE_EDITRES
|
||||
EXTRA_LIBRARIES = $(XMULIB) ExtraLibraries
|
||||
# endif
|
||||
#endif /* SunArchitecture */
|
||||
|
||||
SRCS = AliasListUiItem.C AlternatesListUiItem.C \
|
||||
AntiCheckBoxUiItem.C AttachArea.C \
|
||||
Attachment.C \
|
||||
CheckBoxUiItem.C CheckForMailUiItem.C \
|
||||
ComposeCmds.C CustomListUiItem.C \
|
||||
Dialog.C DialogShell.C \
|
||||
DmxMailbox.C DmxMessage.C \
|
||||
DmxPrintJob.C DmxPrintOptions.C \
|
||||
DmxPrintOutput.C DmxPrintSetup.C \
|
||||
DmxUtils.C DtEditor.C \
|
||||
DtMailEditor.C DtMailGenDialog.C \
|
||||
DtMailWDM.C Editor.C \
|
||||
EncryptedTextFieldUiItem.C FindDialog.C \
|
||||
Fonts.C Icon.C \
|
||||
IgnoreListUiItem.C Image.C \
|
||||
InboxTextFieldUiItem.C IndexedOptionMenu.C \
|
||||
IndexedOptionMenuUiItem.C ListUiItem.C \
|
||||
MailRcSource.C MailRetrievalOptions.C \
|
||||
MailSession.C \
|
||||
MoveMenuListUiItem.C MsgHndArray.C \
|
||||
MsgScrollingList.C NoOpCmd.C \
|
||||
OptCmd.C PasswordDialogManager.C \
|
||||
PropUi.C QueryDialogManager.C \
|
||||
RoamApp.C RoamCmds.C \
|
||||
RoamInterruptibleCmd.C RoamMenuWindow.C \
|
||||
ScaleUiItem.C SendMsgDialog.C \
|
||||
Sort.C SortCmd.C \
|
||||
SpinBoxUiItem.C StringTab.c \
|
||||
TemplateListUiItem.C TextFieldUiItem.C \
|
||||
Undelete.C ViewMsgDialog.C \
|
||||
WMSaveSession.C XmStrCollector.C \
|
||||
XmTextEditor.C XtArgCollector.C \
|
||||
dtb_utils.C options_stubs.C \
|
||||
options_ui.C options_util.C
|
||||
|
||||
OBJS = AliasListUiItem.o AlternatesListUiItem.o \
|
||||
AntiCheckBoxUiItem.o AttachArea.o \
|
||||
Attachment.o \
|
||||
CheckBoxUiItem.o CheckForMailUiItem.o \
|
||||
ComposeCmds.o CustomListUiItem.o \
|
||||
Dialog.o DialogShell.o \
|
||||
DmxMailbox.o DmxMessage.o \
|
||||
DmxPrintJob.o DmxPrintOptions.o \
|
||||
DmxPrintOutput.o DmxPrintSetup.o \
|
||||
DmxUtils.o DtEditor.o \
|
||||
DtMailEditor.o DtMailGenDialog.o \
|
||||
DtMailWDM.o Editor.o \
|
||||
EncryptedTextFieldUiItem.o FindDialog.o \
|
||||
Fonts.o Icon.o \
|
||||
IgnoreListUiItem.o Image.o \
|
||||
InboxTextFieldUiItem.o IndexedOptionMenu.o \
|
||||
IndexedOptionMenuUiItem.o ListUiItem.o \
|
||||
MailRcSource.o MailRetrievalOptions.o \
|
||||
MailSession.o \
|
||||
MoveMenuListUiItem.o MsgHndArray.o \
|
||||
MsgScrollingList.o NoOpCmd.o \
|
||||
OptCmd.o PasswordDialogManager.o \
|
||||
PropUi.o QueryDialogManager.o \
|
||||
RoamApp.o RoamCmds.o \
|
||||
RoamInterruptibleCmd.o RoamMenuWindow.o \
|
||||
ScaleUiItem.o SendMsgDialog.o \
|
||||
Sort.o SortCmd.o \
|
||||
SpinBoxUiItem.o StringTab.o \
|
||||
TemplateListUiItem.o TextFieldUiItem.o \
|
||||
Undelete.o ViewMsgDialog.o \
|
||||
WMSaveSession.o XmStrCollector.o \
|
||||
XmTextEditor.o XtArgCollector.o \
|
||||
dtb_utils.o options_stubs.o \
|
||||
options_ui.o options_util.o
|
||||
|
||||
# Rules
|
||||
NormalCplusplusObjectRule()
|
||||
|
||||
ComplexCplusplusProgramTarget(dtmail)
|
||||
97
cde/programs/dtmail/dtmail/InboxTextFieldUiItem.C
Normal file
97
cde/programs/dtmail/dtmail/InboxTextFieldUiItem.C
Normal file
@@ -0,0 +1,97 @@
|
||||
/* $TOG: InboxTextFieldUiItem.C /main/1 1998/02/17 12:35:07 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <DtMail/options_util.h>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/InboxTextFieldUiItem.hh>
|
||||
#include <DtMail/DtMail.hh>
|
||||
#include <DtMail/DtMailError.hh>
|
||||
#include "MailSession.hh"
|
||||
#include "RoamApp.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
InboxTextFieldUiItem::InboxTextFieldUiItem(
|
||||
Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
PropUiCallback validator,
|
||||
void * validator_data)
|
||||
: PropUiItem(w, source, search_key, validator, validator_data)
|
||||
{
|
||||
options_field_init(w, &(this->dirty_bit));
|
||||
}
|
||||
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void InboxTextFieldUiItem::writeFromUiToSource()
|
||||
{
|
||||
char *mailspool_file = NULL;
|
||||
char *value;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
MailSession *ses = theRoamApp.session();
|
||||
DtMail::Session *d_session = ses->session();
|
||||
DtMailObjectSpace space;
|
||||
DtMailEnv error;
|
||||
DtMailEnv mail_error;
|
||||
|
||||
d_session->queryImpl(error,
|
||||
d_session->getDefaultImpl(mail_error),
|
||||
DtMailCapabilityMailspoolName,
|
||||
&space,
|
||||
&mailspool_file);
|
||||
value = options_field_get_value(w);
|
||||
|
||||
if (0 == strcmp(value, mailspool_file))
|
||||
prop_source->setValue("MAILSPOOL_FILE");
|
||||
else
|
||||
prop_source->setValue(value);
|
||||
|
||||
if (NULL != mailspool_file) free((void*) mailspool_file);
|
||||
}
|
||||
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void InboxTextFieldUiItem::writeFromSourceToUi()
|
||||
{
|
||||
char *mailspool_file = NULL;
|
||||
char *value;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
MailSession *ses = theRoamApp.session();
|
||||
DtMail::Session *d_session = ses->session();
|
||||
DtMailObjectSpace space;
|
||||
DtMailEnv error;
|
||||
DtMailEnv mail_error;
|
||||
|
||||
d_session->queryImpl(error,
|
||||
d_session->getDefaultImpl(mail_error),
|
||||
DtMailCapabilityMailspoolName,
|
||||
&space,
|
||||
&mailspool_file);
|
||||
value = (char *)prop_source->getValue();
|
||||
|
||||
if (0 == strcmp(value, "MAILSPOOL_FILE"))
|
||||
options_field_set_value(w, mailspool_file, this->dirty_bit);
|
||||
else
|
||||
options_field_set_value(w, value, this->dirty_bit);
|
||||
|
||||
if (NULL != value) free((void*) value);
|
||||
if (NULL != mailspool_file) free((void*) mailspool_file);
|
||||
}
|
||||
253
cde/programs/dtmail/dtmail/IndexedOptionMenu.C
Normal file
253
cde/programs/dtmail/dtmail/IndexedOptionMenu.C
Normal file
@@ -0,0 +1,253 @@
|
||||
/* $TOG: IndexedOptionMenu.C /main/3 1997/11/21 18:42:21 mgreess $ */
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/DialogS.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/ToggleB.h>
|
||||
|
||||
#include "Dmx.h"
|
||||
#include "IndexedOptionMenu.h"
|
||||
#include "MailMsg.h"
|
||||
#include "dtmailopts.h"
|
||||
|
||||
IndexedOptionMenu::IndexedOptionMenu (
|
||||
Widget parent,
|
||||
int nmenu_items,
|
||||
char **strings,
|
||||
void **data
|
||||
) : UIComponent( "IndexedOptionMenu" )
|
||||
{
|
||||
int nargs;
|
||||
Arg args[8];
|
||||
Widget menu;
|
||||
XmString xms;
|
||||
|
||||
_nmenu_items = nmenu_items;
|
||||
if (nmenu_items && strings != NULL)
|
||||
{
|
||||
_strings = (char **) XtMalloc(nmenu_items * sizeof(char*));
|
||||
for (int i=0; i<nmenu_items; i++)
|
||||
_strings[i] = strings[i];
|
||||
}
|
||||
if (nmenu_items && data != NULL)
|
||||
{
|
||||
_data = (void **) XtMalloc(nmenu_items * sizeof(void*));
|
||||
for (int i=0; i<nmenu_items; i++)
|
||||
_data[i] = data[i];
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the pulldown menu for the option menus,
|
||||
* and populate it with pushbuttons.
|
||||
* Attach the original strings used to generate
|
||||
* the button labels to the buttons as userData.
|
||||
*/
|
||||
menu = XmCreatePulldownMenu(parent, "Menu", NULL, 0);
|
||||
_buttons = (Widget *) XtMalloc( _nmenu_items * sizeof(Widget) );
|
||||
for (int i=0; i<_nmenu_items; i++)
|
||||
{
|
||||
static char button_label[32];
|
||||
|
||||
sprintf(button_label, "Button%d", i);
|
||||
_buttons[i] = XmCreatePushButton(menu, button_label, NULL, 0);
|
||||
xms = XmStringCreateLocalized(_strings[i]);
|
||||
XtVaSetValues(
|
||||
_buttons[i],
|
||||
XmNuserData, i,
|
||||
XmNlabelString, xms,
|
||||
NULL);
|
||||
XmStringFree(xms);
|
||||
XtManageChild(_buttons[i]);
|
||||
}
|
||||
|
||||
nargs=0;
|
||||
XtSetArg(args[nargs], XmNsubMenuId, menu); nargs++;
|
||||
_w = XmCreateOptionMenu(parent, "IndexedOptionMenu", args, nargs);
|
||||
installDestroyHandler();
|
||||
|
||||
//XtRealizeWidget(_w);
|
||||
}
|
||||
|
||||
IndexedOptionMenu::IndexedOptionMenu (
|
||||
Widget option_menu,
|
||||
int nmenu_items,
|
||||
char **strings,
|
||||
void **data,
|
||||
Widget *buttons
|
||||
) : UIComponent( "IndexedOptionMenu" )
|
||||
{
|
||||
_w = option_menu;
|
||||
installDestroyHandler();
|
||||
_nmenu_items = nmenu_items;
|
||||
_strings = NULL;
|
||||
_data = NULL;
|
||||
_buttons = NULL;
|
||||
|
||||
if (nmenu_items && strings != NULL)
|
||||
{
|
||||
_strings = (char **) XtMalloc(nmenu_items * sizeof(char*));
|
||||
for (int i=0; i<nmenu_items; i++)
|
||||
_strings[i] = strings[i];
|
||||
}
|
||||
if (nmenu_items && data != NULL)
|
||||
{
|
||||
_data = (void **) XtMalloc(nmenu_items * sizeof(void*));
|
||||
for (int i=0; i<nmenu_items; i++)
|
||||
_data[i] = data[i];
|
||||
}
|
||||
if (nmenu_items && buttons != NULL)
|
||||
{
|
||||
_buttons = (Widget *) XtMalloc( _nmenu_items * sizeof(Widget) );
|
||||
for (int i=0; i<nmenu_items; i++)
|
||||
_buttons[i] = buttons[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IndexedOptionMenu::~IndexedOptionMenu (void)
|
||||
{
|
||||
if (_w != NULL)
|
||||
XtDestroyWidget(_w);
|
||||
if (_buttons)
|
||||
XtFree((char *) _buttons);
|
||||
if (_strings)
|
||||
XtFree((char *) _strings);
|
||||
if (_data)
|
||||
XtFree((char *) _data);
|
||||
}
|
||||
|
||||
void
|
||||
IndexedOptionMenu::addMenuButtonCallback(
|
||||
char* callback_name,
|
||||
XtCallbackProc callback,
|
||||
XtPointer client_data)
|
||||
{
|
||||
for (int i=0; i<_nmenu_items; i++)
|
||||
XtAddCallback(_buttons[i], callback_name, callback, client_data);
|
||||
}
|
||||
|
||||
void*
|
||||
IndexedOptionMenu::getDataSpec (void)
|
||||
{
|
||||
int index = getIndexSpec();
|
||||
return _data[index];
|
||||
}
|
||||
|
||||
int
|
||||
IndexedOptionMenu::getIndexSpec (void)
|
||||
{
|
||||
int data = 0;
|
||||
|
||||
if (_w)
|
||||
{
|
||||
Widget selected;
|
||||
XtVaGetValues(_w, XmNmenuHistory, &selected, NULL);
|
||||
XtVaGetValues(selected, XmNuserData, &data, NULL);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
char*
|
||||
IndexedOptionMenu::getStringSpec(void)
|
||||
{
|
||||
int index = getIndexSpec();
|
||||
return _strings[index];
|
||||
}
|
||||
|
||||
void
|
||||
IndexedOptionMenu::setSpec (int spec)
|
||||
{
|
||||
XtVaSetValues(_w, XmNmenuHistory, _buttons[spec], NULL );
|
||||
}
|
||||
|
||||
void
|
||||
IndexedOptionMenu::setSpec (const char *string)
|
||||
{
|
||||
int spec = stringToIndex(string);
|
||||
if (spec >= _nmenu_items) return;
|
||||
setSpec(spec);
|
||||
}
|
||||
|
||||
void
|
||||
IndexedOptionMenu::setSpec (void *data)
|
||||
{
|
||||
int spec = dataToIndex(data);
|
||||
if (spec >= _nmenu_items) return;
|
||||
setSpec(spec);
|
||||
}
|
||||
|
||||
int
|
||||
IndexedOptionMenu::dataToIndex (void *data)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index=0; index<_nmenu_items; index++)
|
||||
if (! strncmp((char*) _data[index], (char*) data, strlen((char*) data)))
|
||||
return index;
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
int
|
||||
IndexedOptionMenu::stringToIndex (const char *string)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index=0; index<_nmenu_items; index++)
|
||||
if (! strncmp(_strings[index], string, strlen(string)) )
|
||||
return index;
|
||||
|
||||
return index;
|
||||
}
|
||||
85
cde/programs/dtmail/dtmail/IndexedOptionMenu.h
Normal file
85
cde/programs/dtmail/dtmail/IndexedOptionMenu.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/* $XConsortium: IndexedOptionMenu.h /main/2 1996/10/02 11:47:36 mgreess $ */
|
||||
|
||||
#ifndef _INDEXED_OPTION_MENU
|
||||
#define _INDEXED_OPTION_MENU
|
||||
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $:$
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1994 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "UIComponent.h"
|
||||
|
||||
class IndexedOptionMenu : public UIComponent
|
||||
{
|
||||
public:
|
||||
|
||||
IndexedOptionMenu ( Widget, int, char**, void** );
|
||||
IndexedOptionMenu ( Widget, int, char**, void**, Widget* );
|
||||
~IndexedOptionMenu (void);
|
||||
|
||||
void addMenuButtonCallback(char*, XtCallbackProc, XtPointer);
|
||||
int getIndexSpec();
|
||||
char *getStringSpec();
|
||||
void *getDataSpec();
|
||||
void setSpec(int);
|
||||
void setSpec(const char*);
|
||||
void setSpec(void*);
|
||||
|
||||
private:
|
||||
int dataToIndex(void*);
|
||||
int stringToIndex(const char*);
|
||||
|
||||
int _nmenu_items;
|
||||
char **_strings;
|
||||
void **_data;
|
||||
Widget *_buttons;
|
||||
};
|
||||
|
||||
#endif // _INDEXED_OPTION_MENU
|
||||
113
cde/programs/dtmail/dtmail/IndexedOptionMenuUiItem.C
Normal file
113
cde/programs/dtmail/dtmail/IndexedOptionMenuUiItem.C
Normal file
@@ -0,0 +1,113 @@
|
||||
/* $TOG: IndexedOptionMenuUiItem.C /main/4 1997/11/21 17:19:04 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
/*
|
||||
* Common Desktop Environment
|
||||
*
|
||||
* (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
|
||||
* (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
|
||||
* (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1993, 1994, 1995 Novell, Inc.
|
||||
* (c) Copyright 1995 Digital Equipment Corp.
|
||||
* (c) Copyright 1995 Fujitsu Limited
|
||||
* (c) Copyright 1995 Hitachi, Ltd.
|
||||
*
|
||||
*
|
||||
* RESTRICTED RIGHTS LEGEND
|
||||
*
|
||||
*Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
*restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
|
||||
*Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
|
||||
*for non-DOD U.S. Government Departments and Agencies are as set forth in
|
||||
*FAR 52.227-19(c)(1,2).
|
||||
|
||||
*Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
|
||||
*International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
|
||||
*Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
|
||||
*Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
|
||||
*Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
|
||||
*Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
|
||||
*Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
|
||||
*/
|
||||
|
||||
|
||||
#include <DtMail/options_util.h>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/IndexedOptionMenuUiItem.hh>
|
||||
|
||||
extern Boolean props_changed;
|
||||
|
||||
// IndexedOptionMenuUiItem::IndexedOptionMenuUiItem
|
||||
// IndexedOptionMenuUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
IndexedOptionMenuUiItem::IndexedOptionMenuUiItem(
|
||||
IndexedOptionMenu *iom,
|
||||
int source,
|
||||
char *search_key
|
||||
) : PropUiItem(iom->baseWidget(), source, search_key)
|
||||
{
|
||||
_iom = iom;
|
||||
_iom->addMenuButtonCallback(
|
||||
XmNactivateCallback,
|
||||
IndexedOptionMenuUiItem::valueChangedCB,
|
||||
(XtPointer) this);
|
||||
}
|
||||
|
||||
// IndexedOptionMenuUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void IndexedOptionMenuUiItem::writeFromUiToSource()
|
||||
{
|
||||
char *value;
|
||||
Widget w;
|
||||
|
||||
w = this->getWidget();
|
||||
value = (char*) _iom->getDataSpec();
|
||||
prop_source->setValue(value);
|
||||
}
|
||||
|
||||
// IndexedOptionMenuUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void IndexedOptionMenuUiItem::writeFromSourceToUi()
|
||||
{
|
||||
const char *value;
|
||||
|
||||
value = (char *)prop_source->getValue();
|
||||
_iom->setSpec((void*) value);
|
||||
if (NULL != value)
|
||||
free((void*) value);
|
||||
}
|
||||
|
||||
// IndexedOptionMenuUiItem::valueChangedCB()
|
||||
// Marks the item as having its value changed.
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void IndexedOptionMenuUiItem::valueChangedCB(
|
||||
Widget,
|
||||
XtPointer clientdata,
|
||||
XtPointer
|
||||
)
|
||||
{
|
||||
IndexedOptionMenuUiItem *thisIomui;
|
||||
|
||||
thisIomui = (IndexedOptionMenuUiItem *) clientdata;
|
||||
thisIomui->dirty_bit = TRUE;
|
||||
props_changed = TRUE;
|
||||
}
|
||||
|
||||
76
cde/programs/dtmail/dtmail/ListUiItem.C
Normal file
76
cde/programs/dtmail/dtmail/ListUiItem.C
Normal file
@@ -0,0 +1,76 @@
|
||||
/* $TOG: ListUiItem.C /main/4 1997/04/29 16:23:46 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
#include <DtMail/options_util.h>
|
||||
#include <DtMail/PropUi.hh>
|
||||
#include <DtMail/ListUiItem.hh>
|
||||
|
||||
// ListUiItem::ListUiItem
|
||||
// ListUiItem ctor
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
ListUiItem::ListUiItem(Widget w,
|
||||
int source,
|
||||
char *search_key,
|
||||
DtVirtArray<char *> *alias_list
|
||||
):PropUiItem(w, source, search_key)
|
||||
{
|
||||
#ifdef DEAD_WOOD
|
||||
data_source = source;
|
||||
#endif /* DEAD_WOOD */
|
||||
|
||||
if(alias_list != NULL)
|
||||
options_list_init(w, alias_list);
|
||||
|
||||
}
|
||||
|
||||
// ListUiItem::writeFromUiToSource()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void ListUiItem::writeFromUiToSource()
|
||||
{
|
||||
// char *textfield_value;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
// textfield_value = options_field_get_value(w);
|
||||
|
||||
// prop_source->setValue(textfield_value);
|
||||
}
|
||||
|
||||
// ListUiItem::writeFromSourceToUi()
|
||||
// Takes values in the UI and puts them into the source DB
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void ListUiItem::writeFromSourceToUi()
|
||||
{
|
||||
// char *value;
|
||||
Widget w = this->getWidget();
|
||||
|
||||
// value = (char *)prop_source->getValue();
|
||||
|
||||
// options_field_set_value(w, value, this->dirty_bit);
|
||||
|
||||
}
|
||||
void ListUiItem::AddDefaults()
|
||||
{
|
||||
// wrapper
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
80
cde/programs/dtmail/dtmail/MailMsg.h
Normal file
80
cde/programs/dtmail/dtmail/MailMsg.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* $TOG: MailMsg.h /main/5 1998/04/22 14:17:19 mgreess $
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement between
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel without
|
||||
* Sun's specific written approval. This document and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#ifndef MAILMSG_H
|
||||
#define MAILMSG_H
|
||||
|
||||
#include <nl_types.h>
|
||||
#include <Dt/MsgCatP.h>
|
||||
|
||||
/*
|
||||
* DtMail comment tag is NL_COMMENT (NL = National Language).
|
||||
* genmsg will extract comment blocks containing NL_COMMENT.
|
||||
*/
|
||||
|
||||
extern nl_catd DT_catd; /* Catgets file descriptor */
|
||||
|
||||
#define DTMAIL_CAT "DtMail"
|
||||
#define NL_SET 1
|
||||
#define BUTTON_SET 1
|
||||
#define TITLE_SET 1
|
||||
#define LABEL_SET 1
|
||||
#define DIALOG_SET 3
|
||||
#define MSG_SET 3
|
||||
#define ERR_SET 2
|
||||
|
||||
#ifdef XGETTEXT
|
||||
#define MAILMSG(msgid, str) dgettext(NL_SET, msgid, str)
|
||||
#else
|
||||
#define MAILMSG(msgid, str) catgets(DT_catd, NL_SET, msgid, str)
|
||||
#endif
|
||||
|
||||
#ifdef hpV4
|
||||
#define GETMSG(DT_catd, NL_SET, msgid, str) _DtCatgetsCached(DT_catd, NL_SET, msgid, str)
|
||||
#else
|
||||
#define GETMSG(DT_catd, NL_SET, msgid, str) catgets(DT_catd, NL_SET, msgid, str)
|
||||
#endif
|
||||
|
||||
|
||||
/* MailBox.C msgid 100 - 199
|
||||
* MBOX_*
|
||||
*/
|
||||
|
||||
/* MsgScrollingList.C msgid 200 - 299
|
||||
* MSGLIST_*
|
||||
*/
|
||||
|
||||
/* RoamCmds.C msgid 300 - 399
|
||||
* ROCMD_*
|
||||
*/
|
||||
|
||||
/* RoamMenuWindow.C msgid 400 - 499
|
||||
* ROMENU_*
|
||||
*/
|
||||
|
||||
/* SendMsgDialog.C msgid 500 - 599
|
||||
* SEND_*
|
||||
*/
|
||||
|
||||
/* Undelete.C msgid 600 - 699
|
||||
* UNDEL_*
|
||||
*/
|
||||
|
||||
#endif // MAILMSG_H
|
||||
155
cde/programs/dtmail/dtmail/MailRcSource.C
Normal file
155
cde/programs/dtmail/dtmail/MailRcSource.C
Normal file
@@ -0,0 +1,155 @@
|
||||
/* $TOG: MailRcSource.C /main/13 1999/03/25 13:41:38 mgreess $ */
|
||||
/*
|
||||
*+SNOTICE
|
||||
*
|
||||
* RESTRICTED CONFIDENTIAL INFORMATION:
|
||||
*
|
||||
* The information in this document is subject to special
|
||||
* restrictions in a confidential disclosure agreement bertween
|
||||
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
|
||||
* document outside HP, IBM, Sun, USL, SCO, or Univel wihtout
|
||||
* Sun's specific written approval. This documment and all copies
|
||||
* and derivative works thereof must be returned or destroyed at
|
||||
* Sun's request.
|
||||
*
|
||||
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
*+ENOTICE
|
||||
*/
|
||||
|
||||
#include <EUSCompat.h>
|
||||
#include <DtMail/PropSource.hh>
|
||||
#include <DtMail/DtMailTypes.h>
|
||||
#include <DtMail/DtVirtArray.hh>
|
||||
#include "str_utils.h"
|
||||
|
||||
#include "DmxPrintOptions.h"
|
||||
|
||||
static PropDefaults static_defaults[] ={
|
||||
{ "retrieveinterval", "300" },
|
||||
{ "bell", "1" },
|
||||
{ "flash", "0" },
|
||||
{ "headerlines", "15" },
|
||||
{ "showto", "f" },
|
||||
{ "showmsgnum", "f" },
|
||||
{ "popuplines", "24" },
|
||||
{ "toolcols", "80" },
|
||||
{ "indentprefix", ">" },
|
||||
{ "hideattachments", "f" },
|
||||
{ "folder", "~" },
|
||||
{ "filefolder", "~" },
|
||||
{ "dontunifyselection", "f" },
|
||||
{ "dontunifyfileselection", "f" },
|
||||
{ "confirmattachments", "f" },
|
||||
{ "confirmattachmentthreshold", "64" },
|
||||
{ "cachedfilemenusize", "10" },
|
||||
{ "dontdisplaycachedfiles", "f" },
|
||||
{ "record", "" },
|
||||
{ "dontlogmessages", "f" },
|
||||
{ "keepdeleted", "f" },
|
||||
{ "quietdelete", "f" },
|
||||
{ "expert", "f" },
|
||||
{ "strictmime", "f" },
|
||||
{ "cdetooltalklock", "f" },
|
||||
{ "allnet", "f" },
|
||||
{ "metoo", "f" },
|
||||
{ "usealternates", "f" },
|
||||
{ "deaddir", "~/dead_letter" },
|
||||
{ "saveinterval", "30" },
|
||||
{ DMX_PROPKEY_HEADER_LEFT, DMX_PROPVAL_SUBJECT_HEADER },
|
||||
{ DMX_PROPKEY_HEADER_RIGHT, DMX_PROPVAL_EMPTY },
|
||||
{ DMX_PROPKEY_FOOTER_LEFT, DMX_PROPVAL_USER_NAME },
|
||||
{ DMX_PROPKEY_FOOTER_RIGHT, DMX_PROPVAL_PAGE_NUMBER },
|
||||
{ DMX_PROPKEY_MARGIN_TOP, DMX_PROPVAL_DFLT_MARGIN },
|
||||
{ DMX_PROPKEY_MARGIN_RIGHT, DMX_PROPVAL_DFLT_MARGIN },
|
||||
{ DMX_PROPKEY_MARGIN_BOTTOM, DMX_PROPVAL_DFLT_MARGIN },
|
||||
{ DMX_PROPKEY_MARGIN_LEFT, DMX_PROPVAL_DFLT_MARGIN },
|
||||
{ DMX_PROPKEY_PRINT_HEADERS, DMX_PROPVAL_STANDARD },
|
||||
{ DMX_PROPKEY_MESSAGE_SEPARATOR,DMX_PROPVAL_PAGE_BREAK },
|
||||
{ DMX_PROPKEY_SEPARATOR_STRING, "-" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
DtVirtArray<PropDefaults*> *PropSource::_dynamic_defaults =
|
||||
new DtVirtArray<PropDefaults*> (20);
|
||||
|
||||
PropSource::PropSource(DtMail::MailRc *m_rc, char *key)
|
||||
{
|
||||
_mail_rc = m_rc;
|
||||
_key = key;
|
||||
}
|
||||
|
||||
PropSource::~PropSource() {;}
|
||||
|
||||
void
|
||||
PropSource::setDefaultValue(char *key, char *value)
|
||||
{
|
||||
PropDefaults *df;
|
||||
|
||||
for (int i=0; i<_dynamic_defaults->length(); i++)
|
||||
{
|
||||
df = (PropDefaults*) (*_dynamic_defaults)[i];
|
||||
if (0 == strcmp(key, df->key))
|
||||
{
|
||||
if (NULL != df->value) free((void*) df->value);
|
||||
df->value = strdup(value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
df = (PropDefaults*) malloc(sizeof(PropDefaults));
|
||||
df->key = strdup(key);
|
||||
df->value = strdup(value);
|
||||
_dynamic_defaults->append(df);
|
||||
}
|
||||
|
||||
const char *
|
||||
PropSource::getDefaultValue(void)
|
||||
{
|
||||
PropDefaults *df;
|
||||
|
||||
for (int i=0; i<_dynamic_defaults->length(); i++)
|
||||
{
|
||||
df = (PropDefaults*) (*_dynamic_defaults)[i];
|
||||
if (0 == strcmp(_key, df->key)) return strdup(df->value);
|
||||
}
|
||||
|
||||
for (df=static_defaults; df->key; df++)
|
||||
if (strcasecmp(_key, df->key) == 0) return strdup(df->value);
|
||||
|
||||
return strdup(PropSourceDEFAULTVALUE);
|
||||
}
|
||||
|
||||
// MailRcSource::getValue
|
||||
// gets the value from the mailrc hash table and returns it
|
||||
/////////////////////////////////////////////////////////////////
|
||||
const char *MailRcSource::getValue(DtMailBoolean decrypt)
|
||||
{
|
||||
const char *value = NULL;
|
||||
DtMailEnv error;
|
||||
|
||||
_mail_rc->getValue(error, _key , &value, decrypt);
|
||||
|
||||
if (value == NULL || error.isSet())
|
||||
{
|
||||
value = getDefaultValue();
|
||||
return value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// MailRcSource::setValue
|
||||
// Sets the passed value into the mailrc hash tables
|
||||
/////////////////////////////////////////////////////////////////
|
||||
void MailRcSource::setValue(char *value, DtMailBoolean encrypt)
|
||||
{
|
||||
DtMailEnv error;
|
||||
|
||||
const char * d_value = getDefaultValue();
|
||||
|
||||
if (strcmp(d_value, value))
|
||||
_mail_rc->setValue(error, _key , value, encrypt);
|
||||
else
|
||||
_mail_rc->removeValue(error, _key);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user