Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user