Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
1020
cde/programs/dtprintinfo/libUI/BaseUI.C
Normal file
1020
cde/programs/dtprintinfo/libUI/BaseUI.C
Normal file
File diff suppressed because it is too large
Load Diff
445
cde/programs/dtprintinfo/libUI/BaseUI.h
Normal file
445
cde/programs/dtprintinfo/libUI/BaseUI.h
Normal file
@@ -0,0 +1,445 @@
|
||||
/* $TOG: BaseUI.h /main/5 1998/04/06 13:31:37 mgreess $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef BASEUI_H
|
||||
#define BASEUI_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef _BOOLEAN_
|
||||
#define _BOOLEAN_
|
||||
#if (defined(sun) && OSMAJORVERSION <= 5 && OSMINORVERSION <= 3)|| defined(USL) || defined(__uxp__)
|
||||
#include <sys/types.h>
|
||||
#define boolean boolean_t
|
||||
#define true B_TRUE
|
||||
#define false B_FALSE
|
||||
#elif defined(linux)
|
||||
#define false 0
|
||||
#define true 0
|
||||
#define boolean int
|
||||
#else
|
||||
typedef enum
|
||||
{
|
||||
false = 0,
|
||||
true = 1
|
||||
} boolean;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef STRDUP
|
||||
#define STRDUP(string) (string ? strdup(string) : (char*) NULL)
|
||||
#define STRCMP(s1, s2) (s1 && s2 ? strcmp(s1, s2) : (s1 ? 1 : -1))
|
||||
#define STRLEN(string) (string ? strlen(string) : 0)
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BASE_UI,
|
||||
APPLICATION,
|
||||
BUTTON,
|
||||
COMBO_BOX,
|
||||
CONTAINER,
|
||||
DIALOG,
|
||||
LABEL,
|
||||
LIST,
|
||||
GROUP,
|
||||
HELP_SYSTEM,
|
||||
ICON,
|
||||
MAIN_WINDOW,
|
||||
MENU,
|
||||
MENU_BAR,
|
||||
PROMPT,
|
||||
SEPARATOR,
|
||||
SPIN_BUTTON,
|
||||
SCALE,
|
||||
TEXT
|
||||
} UI_Class;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MODELESS,
|
||||
MODAL,
|
||||
INFORMATION,
|
||||
ERROR,
|
||||
WORK_IN_PROGRESS,
|
||||
FILE_SELECTION, // This type is always modal
|
||||
DIRECTORY_SELECTION, // This type is always modal
|
||||
FILE_DIRECTORY_SELECTION, // This type is always modal
|
||||
QUESTION, // This type is always modal
|
||||
WARNING, // This type is always modal
|
||||
PROMPT_DIALOG, // This type is always modal
|
||||
MODAL_WORK_IN_PROGRESS,
|
||||
MODAL_ERROR,
|
||||
MODAL_INFORMATION
|
||||
} DialogType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PULLDOWN_MENU,
|
||||
OPTION_MENU,
|
||||
POPUP_MENU
|
||||
} MenuType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LEFT_JUSTIFIED,
|
||||
CENTERED,
|
||||
RIGHT_JUSTIFIED
|
||||
} LabelType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
VERTICAL_SCALE,
|
||||
HORIZONTAL_SCALE
|
||||
} ScaleType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FIXED_LIST,
|
||||
SCROLLED_LIST
|
||||
} ListType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
READ_ONLY,
|
||||
EDITABLE,
|
||||
SCROLLED_READ_ONLY,
|
||||
SCROLLED_EDITABLE
|
||||
} TextType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SINGLE_SELECT,
|
||||
MULTIPLE_SELECT,
|
||||
EXTENDED_SELECT,
|
||||
BROWSE_SELECT
|
||||
} SelectionType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STRING_PROMPT,
|
||||
MULTI_LINE_STRING_PROMPT,
|
||||
INTEGER_PROMPT,
|
||||
REAL_PROMPT
|
||||
} PromptType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CHECK_BOX,
|
||||
RADIO_GROUP,
|
||||
HORIZONTAL_CHECK_BOX,
|
||||
HORIZONTAL_RADIO_GROUP,
|
||||
FORM_BOX
|
||||
} GroupType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CANVAS,
|
||||
FORM,
|
||||
VERTICAL_ROW_COLUMN,
|
||||
HORIZONTAL_ROW_COLUMN,
|
||||
PANE,
|
||||
WORK_AREA,
|
||||
ICON_LIST,
|
||||
SCROLLED_CANVAS,
|
||||
SCROLLED_FORM,
|
||||
SCROLLED_VERTICAL_ROW_COLUMN,
|
||||
SCROLLED_HORIZONTAL_ROW_COLUMN,
|
||||
SCROLLED_PANE,
|
||||
SCROLLED_WORK_AREA,
|
||||
SCROLLED_ICON_LIST
|
||||
} ContainerType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PUSH_BUTTON,
|
||||
TOGGLE_BUTTON,
|
||||
UP_ARROW_BUTTON,
|
||||
DOWN_ARROW_BUTTON,
|
||||
LEFT_ARROW_BUTTON,
|
||||
RIGHT_ARROW_BUTTON
|
||||
} ButtonType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NO_LINE,
|
||||
SINGLE_LINE,
|
||||
DOUBLE_LINE,
|
||||
SINGLE_DASHED_LINE,
|
||||
DOUBLE_DASHED_LINE,
|
||||
SHADOW_ETCHED_IN,
|
||||
SHADOW_ETCHED_OUT,
|
||||
SHADOW_ETCHED_IN_DASH,
|
||||
SHADOW_ETCHED_OUT_DASH
|
||||
} SeparatorStyle;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_PLACED,
|
||||
GRID,
|
||||
BROWSER,
|
||||
TREE,
|
||||
PROPERTIES
|
||||
} ViewStyle;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NAME_ONLY,
|
||||
VERY_LARGE_ICON,
|
||||
LARGE_ICON,
|
||||
MEDIUM_ICON,
|
||||
SMALL_ICON,
|
||||
TINY_ICON,
|
||||
DETAILS
|
||||
} IconStyle;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LEFT_SLANTED_ARROW_CURSOR,
|
||||
RIGHT_SLANTED_ARROW_CURSOR,
|
||||
WATCH_CURSOR,
|
||||
HOUR_GLASS_CURSOR,
|
||||
IBEAM_CURSOR,
|
||||
CROSS_HAIRS_CURSOR
|
||||
} PointerCursor;
|
||||
|
||||
class BaseUI;
|
||||
|
||||
typedef boolean (*SelectProc) (BaseUI *object);
|
||||
typedef boolean (*CompareProc) (BaseUI **first, BaseUI **second);
|
||||
typedef void (*TimeOutCallback) (BaseUI *object, void *callback_data);
|
||||
typedef void (*ButtonCallback) (void *);
|
||||
typedef void (*DialogCallback) (void *);
|
||||
typedef boolean (*ValidationCallback) (void *client_data, void *call_data);
|
||||
typedef void (*ThreadCallback) (BaseUI *obj, char *output, int rc);
|
||||
|
||||
const NO_SUBCLASS = -1;
|
||||
|
||||
class BaseUI {
|
||||
|
||||
public:
|
||||
|
||||
#ifdef DEBUG
|
||||
static int indent;
|
||||
static boolean trace_calls;
|
||||
static void EnterFunction(char *message);
|
||||
static void LeaveFunction(char *message);
|
||||
#define TraceFunctionCalls(flag) trace_calls = flag
|
||||
#else
|
||||
#define EnterFunction(message)
|
||||
#define LeaveFunction(message)
|
||||
#define TraceFunctionCalls(flag)
|
||||
#endif
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
static int _UniqueID;
|
||||
|
||||
char *_name;
|
||||
char *_category;
|
||||
int _id;
|
||||
BaseUI *_parent;
|
||||
BaseUI **_children;
|
||||
int _numChildren;
|
||||
BaseUI **_allChildren;
|
||||
int _numAllChildren;
|
||||
boolean _has_been_opened;
|
||||
boolean _opened;
|
||||
boolean _visible;
|
||||
boolean _active;
|
||||
boolean _selected;
|
||||
boolean _update;
|
||||
char *_update_message;
|
||||
ViewStyle _viewStyle;
|
||||
IconStyle _iconStyle;
|
||||
|
||||
BaseUI(BaseUI *parent,
|
||||
const char *name,
|
||||
const char *category = NULL);
|
||||
|
||||
// Derived classes must define these functions
|
||||
virtual boolean SetVisiblity(boolean) = 0;
|
||||
virtual boolean SetActivity(boolean) = 0;
|
||||
virtual boolean SetSelected(boolean) = 0;
|
||||
virtual boolean SetName(char *) = 0;
|
||||
virtual boolean SetCategory(char *) = 0;
|
||||
virtual boolean SetOpen(boolean) = 0;
|
||||
virtual boolean SetView(ViewStyle) = 0;
|
||||
virtual boolean SetIcon(IconStyle) = 0;
|
||||
virtual boolean SetParent(BaseUI *new_parent) = 0;
|
||||
virtual void SetAddTimeOut(TimeOutCallback, void *, long interval) = 0;
|
||||
virtual void DoRefresh() = 0;
|
||||
virtual void DoToFront() = 0;
|
||||
virtual void DoContextualHelp() = 0;
|
||||
virtual void DoBeginUpdate() = 0;
|
||||
virtual void DoEndUpdate() = 0;
|
||||
virtual void DoMakeVisible() = 0;
|
||||
virtual boolean DoIsVisible() { return true; }
|
||||
virtual void DoUpdateMessage(char *message) = 0;
|
||||
virtual boolean SetOrder(int) = 0;
|
||||
|
||||
void SetVisible(boolean);
|
||||
void AddToParent();
|
||||
void DeleteFromParent();
|
||||
void AddToParentContainer();
|
||||
void DeleteFromParentContainer();
|
||||
void _Find(void *, int, int *, BaseUI ***, SelectProc, boolean,
|
||||
boolean, boolean, int);
|
||||
BaseUI *_FindBy(char *, int, int *, BaseUI ***, SelectProc, boolean,
|
||||
boolean, boolean);
|
||||
|
||||
// These messages are sent to all parents
|
||||
// up to and including the parent container
|
||||
virtual void NotifyCreate(BaseUI *) { } ;
|
||||
virtual void NotifyDelete(BaseUI *) { } ;
|
||||
virtual void NotifyVisiblity(BaseUI *) { } ;
|
||||
virtual void NotifySelected(BaseUI *) { } ;
|
||||
virtual void NotifyOpen(BaseUI *) { } ;
|
||||
|
||||
public:
|
||||
|
||||
// Not Used By Subclasses, for application programmers only
|
||||
void *ApplicationData;
|
||||
|
||||
virtual ~BaseUI(); // destructor
|
||||
|
||||
virtual boolean HandleHelpRequest();
|
||||
void ContextualHelp();
|
||||
int UniqueID() { return _id; }
|
||||
boolean ObjectExists(int unique_id);
|
||||
|
||||
// Set functions
|
||||
void Visible(boolean); // Set visiblity, calls SetVisiblity
|
||||
void Active(boolean); // Set sensitivity, calls SetActivity
|
||||
void Selected(boolean); // Set selected status, calls SetSelected
|
||||
void Open(boolean); // Set opened status, calls SetOpen
|
||||
void Name(char *); // Set name, calls SetName
|
||||
void Category(char *); // Set category, calls SetCategory
|
||||
void ContainerView(ViewStyle); // Set container view, calls SetView
|
||||
void IconView(IconStyle); // Set icon view, calls SetIcon
|
||||
void Parent(BaseUI *new_parent); // Set parent, calls SetParent
|
||||
virtual void Details(char *) { }
|
||||
|
||||
// Access functions
|
||||
const boolean Visible() { return _visible; }
|
||||
const boolean Active() { return _active; }
|
||||
const boolean Selected() { return _selected; }
|
||||
const boolean Open() { return _opened; }
|
||||
const boolean HasBeenOpened() { return _has_been_opened; }
|
||||
const char * Name() { return _name; }
|
||||
const char * Category() { return _category; }
|
||||
const ViewStyle ContainerView() { return _viewStyle; }
|
||||
const IconStyle IconView() { return _iconStyle; }
|
||||
virtual char * Details() { return NULL; }
|
||||
|
||||
BaseUI * Parent() { return _parent; }
|
||||
BaseUI ** Children() { return _children; }
|
||||
int NumChildren() { return _numChildren; }
|
||||
BaseUI ** AllChildren() { return _allChildren; }
|
||||
int NumAllChildren() { return _numAllChildren; }
|
||||
|
||||
// These are for children
|
||||
BaseUI ** Siblings();
|
||||
int NumSiblings();
|
||||
BaseUI * ContainerParent();
|
||||
int NumContainerChildren();
|
||||
BaseUI ** ContainerChildren();
|
||||
void DeleteChildren();
|
||||
|
||||
virtual void PointerShape(PointerCursor) { }
|
||||
virtual PointerCursor PointerShape() { return LEFT_SLANTED_ARROW_CURSOR; }
|
||||
virtual void AttachAll(int /*offset*/ = 0) { }
|
||||
virtual void AttachTop(int /*offset*/ = 0) { }
|
||||
virtual void AttachBottom(int /*offset */= 0) { }
|
||||
virtual void AttachLeft(int /*offset */= 0) { }
|
||||
virtual void AttachRight(int /*offset */= 0) { }
|
||||
virtual void AttachTop( BaseUI *,
|
||||
int /*offset*/ = 0, boolean /*opposite*/ = false) { }
|
||||
virtual void AttachBottom(BaseUI *,
|
||||
int /*offset*/ = 0, boolean /*opposite*/ = false) { }
|
||||
virtual void AttachLeft( BaseUI *,
|
||||
int /*offset*/ = 0, boolean /*opposite*/ = false) { }
|
||||
virtual void AttachRight( BaseUI *,
|
||||
int /*offset*/ = 0, boolean /*opposite*/ = false) { }
|
||||
virtual void WidthHeight(int /*width*/, int /*height*/) { }
|
||||
virtual void WidthHeight(int * /*width*/, int * /*height*/) { }
|
||||
virtual void Width(int /*width*/) { }
|
||||
virtual int Width() { return 0; }
|
||||
virtual void Height(int /*height*/) { }
|
||||
virtual int Height() { return 0; }
|
||||
virtual void StringWidthHeight(const char * /*string*/, int * /*w*/,
|
||||
int * /*h*/) { }
|
||||
virtual int StringWidth(const char * /*string*/) { return 0; }
|
||||
virtual int StringHeight(const char * /*string*/) { return 0; }
|
||||
|
||||
virtual void Thread(const char * /*cmd*/, ThreadCallback,
|
||||
int /*buf_len*/ = 512) { }
|
||||
virtual void Thread(int /*pid*/, int /*fd*/, ThreadCallback,
|
||||
int /*buf_len*/ = 512) { }
|
||||
virtual void Thread(int /*socket*/, ThreadCallback,
|
||||
int /*buf_len*/ = 512) { }
|
||||
|
||||
// Add timeouts to object (interval is in terms of milliseconds)
|
||||
void AddTimeOut(TimeOutCallback, void *callback_data, long interval);
|
||||
virtual int MicroSleep(long milliseconds);
|
||||
void Refresh();
|
||||
void ToFront();
|
||||
void BeginUpdate();
|
||||
void EndUpdate();
|
||||
void MakeVisible();
|
||||
boolean IsVisible();
|
||||
void UpdateMessage(const char *message);
|
||||
|
||||
BaseUI *FindByName(char *pattern,
|
||||
int depth = 1,
|
||||
int *n_mactches = NULL,
|
||||
BaseUI ***matches = NULL,
|
||||
SelectProc select_proc = NULL,
|
||||
boolean regular_expression = false,
|
||||
boolean case_sensitive = true);
|
||||
BaseUI *FindByCategory(char *pattern,
|
||||
int depth = 1,
|
||||
int *n_mactches = NULL,
|
||||
BaseUI ***matches = NULL,
|
||||
SelectProc select_proc = NULL,
|
||||
boolean regular_expression = false,
|
||||
boolean case_sensitive = true);
|
||||
void OrderByName(boolean flag); // Calls SetOrder
|
||||
void GroupByCategory(boolean flag); // Calls SetOrder
|
||||
int Order(); // Returns order
|
||||
void Order(int new_position); // Calls SetOrder
|
||||
|
||||
// Dumps object to stdout
|
||||
virtual void Dump(boolean verbose = false,
|
||||
int level = 0);
|
||||
// Dumps object heirarchy to stdout
|
||||
void DumpHierarchy(boolean verbose = false,
|
||||
int level = 0);
|
||||
|
||||
// Select/UnSelected all immediate children
|
||||
virtual void SelectAll(boolean select_status = true);
|
||||
|
||||
// Select/UnSelected all children, and their children, etc...
|
||||
virtual void SelectAllDescendants(boolean select_status = true);
|
||||
|
||||
// Open/Close all children, and their children, etc...
|
||||
virtual void OpenAllDescendants(boolean opened = true);
|
||||
|
||||
// Get selected items
|
||||
virtual void Selection(int *n_items,
|
||||
BaseUI ***items = NULL);
|
||||
|
||||
virtual const UI_Class UIClass() { return BASE_UI; }
|
||||
virtual const int UISubClass() { return NO_SUBCLASS; }
|
||||
|
||||
virtual const char *const UIClassName() { return "BaseUI"; }
|
||||
|
||||
};
|
||||
|
||||
#endif // BASEUI_H
|
||||
37
cde/programs/dtprintinfo/libUI/Imakefile
Normal file
37
cde/programs/dtprintinfo/libUI/Imakefile
Normal file
@@ -0,0 +1,37 @@
|
||||
XCOMM $TOG: Imakefile /main/14 1998/08/25 12:59:12 mgreess $
|
||||
|
||||
#define CplusplusSource YES
|
||||
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
|
||||
EXTRA_LOAD_FLAGS = ExtraLoadFlags $(UNSHARED_CXXLIB)
|
||||
|
||||
#define IHaveSubdirs
|
||||
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' 'CXXDEBUGFLAGS=$(CXXDEBUGFLAGS)'
|
||||
|
||||
SUBDIRS = MotifUI
|
||||
|
||||
MakeSubdirs($(SUBDIRS))
|
||||
DependSubdirs($(SUBDIRS))
|
||||
|
||||
INCLUDES = -I. -I./MotifUI
|
||||
|
||||
DEPLIBS = ./MotifUI/libMotifUI.a DepDtClientLibs
|
||||
LOCAL_LIBRARIES = ./MotifUI/libMotifUI.a DtClientLibs
|
||||
SYS_LIBRARIES = DtClientSysLibs DtClientExtraLibs
|
||||
|
||||
#ifdef RsArchitecture
|
||||
DEFINES = -DHAS_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
#ifdef AlphaArchitecture
|
||||
DEFINES = -UNO_REGCOMP
|
||||
#endif
|
||||
|
||||
SRCS = BaseUI.C Test.C
|
||||
OBJS = BaseUI.o Test.o
|
||||
|
||||
NormalCplusplusObjectRule()
|
||||
|
||||
ComplexCplusplusProgramTarget(Test)
|
||||
|
||||
clean::
|
||||
$(RM) *.map
|
||||
363
cde/programs/dtprintinfo/libUI/MotifUI/Application.C
Normal file
363
cde/programs/dtprintinfo/libUI/MotifUI/Application.C
Normal file
@@ -0,0 +1,363 @@
|
||||
/* $TOG: Application.C /main/9 1998/07/24 16:14:41 mgreess $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "Application.h"
|
||||
#include <sys/stat.h>
|
||||
#include <Xm/Protocols.h>
|
||||
|
||||
#ifndef NO_CDE
|
||||
extern "C" {
|
||||
#include <Dt/Dt.h>
|
||||
#include <Dt/EnvControlP.h>
|
||||
#include <Dt/DbUtil.h>
|
||||
#include <Dt/Action.h>
|
||||
#include <Dt/Session.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <stdlib.h> // for putenv function
|
||||
|
||||
const char *SESSION_FLAG = "-session";
|
||||
const char *SESSION_NAME = "session";
|
||||
const char *SESSION_CLASSNAME = "Session";
|
||||
const char *DEFAULT_FONT = "fixed";
|
||||
|
||||
typedef struct
|
||||
{
|
||||
XmFontList user_font;
|
||||
XmFontList system_font;
|
||||
char *session_file;
|
||||
Dimension shadow_thickness;
|
||||
} ApplicationArgs, *ApplicationArgsPtr;
|
||||
|
||||
static XtResource resources[] =
|
||||
{
|
||||
{"userFont", "XmCFontList", XmRFontList, sizeof(XmFontList),
|
||||
XtOffsetOf (ApplicationArgs, user_font), XmRString,
|
||||
#ifdef aix
|
||||
(XtPointer) DEFAULT_FONT
|
||||
#else
|
||||
(XtPointer) "fixed"
|
||||
#endif
|
||||
},
|
||||
{"systemFont", "XmCFontList", XmRFontList, sizeof(XmFontList),
|
||||
XtOffsetOf (ApplicationArgs, system_font), XmRString,
|
||||
#ifdef aix
|
||||
(XtPointer) DEFAULT_FONT
|
||||
},
|
||||
{(char *)SESSION_NAME, (char *)SESSION_CLASSNAME, XtRString, sizeof(char *),
|
||||
#else
|
||||
(XtPointer) "fixed"
|
||||
},
|
||||
{"session", "Session", XtRString, sizeof(char *),
|
||||
#endif
|
||||
XtOffsetOf (ApplicationArgs, session_file), XmRString, (XtPointer) NULL,
|
||||
},
|
||||
{XmNshadowThickness, XmCShadowThickness, XmRHorizontalDimension,
|
||||
sizeof (Dimension), XtOffsetOf (ApplicationArgs, shadow_thickness),
|
||||
XmRImmediate, (XtPointer) 1
|
||||
}
|
||||
};
|
||||
|
||||
static XrmOptionDescRec options[] =
|
||||
{
|
||||
#ifdef aix
|
||||
{(char *)SESSION_FLAG, (char *)SESSION_NAME, XrmoptionSepArg, NULL}
|
||||
#else
|
||||
{"-session", "session", XrmoptionSepArg, NULL}
|
||||
#endif
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
extern void XmeRenderTableGetDefaultFont(XmFontList, XFontStruct **);
|
||||
}
|
||||
|
||||
Application::Application(char *name,
|
||||
char *appClassName,
|
||||
int *_argc,
|
||||
char **_argv)
|
||||
: MotifUI(NULL, name, appClassName, appClassName)
|
||||
{
|
||||
#ifndef NO_CDE
|
||||
_DtEnvControl(DT_ENV_SET);
|
||||
#endif
|
||||
|
||||
XtSetLanguageProc(NULL, NULL, NULL);
|
||||
_w = XtVaAppInitialize(&appContext, appClassName, options, XtNumber(options),
|
||||
_argc, _argv, NULL, XmNallowShellResize, true,
|
||||
XmNtitle, name, XmNiconName, name, NULL);
|
||||
|
||||
topLevel = _w;
|
||||
display = XtDisplay(_w);
|
||||
root = RootWindowOfScreen(XtScreen(_w));
|
||||
white = WhitePixelOfScreen(XtScreen(_w));
|
||||
black = BlackPixelOfScreen(XtScreen(_w));
|
||||
depth = DefaultDepthOfScreen(XtScreen(_w));
|
||||
int numMouseButtons = XGetPointerMapping(display, (unsigned char *)NULL, 0);
|
||||
bMenuButton = (numMouseButtons < 3) ? Button2 : Button3;
|
||||
ApplicationArgs application_args;
|
||||
XtGetApplicationResources(_w, &application_args, resources,
|
||||
XtNumber(resources), NULL, 0);
|
||||
userFont = application_args.user_font;
|
||||
userFont = application_args.system_font;
|
||||
session_info = NULL;
|
||||
attributes = NULL;
|
||||
values = NULL;
|
||||
n_attrs = 0;
|
||||
session_path = NULL;
|
||||
fp = NULL;
|
||||
if (session_file = application_args.session_file)
|
||||
{
|
||||
if (*session_file == '/')
|
||||
session_path = strdup(session_file);
|
||||
else
|
||||
DtSessionRestorePath(topLevel, &session_path, session_file);
|
||||
}
|
||||
|
||||
shadowThickness = application_args.shadow_thickness;
|
||||
{
|
||||
XmFontContext context;
|
||||
if (XmFontListInitFontContext(&context, userFont))
|
||||
{
|
||||
XmFontListEntry entry = XmFontListNextEntry(context);
|
||||
if (entry)
|
||||
{
|
||||
XmFontType _type_return;
|
||||
fs = (XFontStruct *)XmFontListEntryGetFont(entry, &_type_return);
|
||||
if (_type_return != XmFONT_IS_FONT)
|
||||
XmeRenderTableGetDefaultFont(userFont, &fs);
|
||||
font = fs->fid;
|
||||
}
|
||||
XmFontListFreeFontContext(context);
|
||||
}
|
||||
}
|
||||
|
||||
argc = *_argc;
|
||||
argv = _argv;
|
||||
|
||||
InstallDestroyCB();
|
||||
|
||||
// If the user specified -display on the command line, we need
|
||||
// to set the environment variable DISPLAY to this value so that
|
||||
// any aixterms or X applications launched from this program
|
||||
// go to the same display
|
||||
new_display = new char [strlen("DISPLAY=") +
|
||||
strlen(DisplayString(display)) + 1];
|
||||
sprintf(new_display, "DISPLAY=%s", DisplayString(display));
|
||||
putenv(new_display);
|
||||
|
||||
// Make the environment variable ENV set to nothing. This is so that
|
||||
// we don't run the user's ENV every time we open a child process.
|
||||
putenv("ENV=");
|
||||
|
||||
#ifndef NO_CDE
|
||||
if (!DtAppInitialize(appContext, display, topLevel, argv[0], appClassName))
|
||||
{
|
||||
// Fatal Error: could not connect to the messaging system.
|
||||
// DtAppInitialize() has already logged an appropriate error msg
|
||||
exit(-1);
|
||||
}
|
||||
// Load the filetype/action dbs; DtInvokeAction() requires this
|
||||
DtDbLoad();
|
||||
#endif
|
||||
|
||||
Atom xa_WM_SAVE_YOURSELF = XInternAtom(display, "WM_SAVE_YOURSELF", False);
|
||||
XmAddWMProtocols(topLevel, &xa_WM_SAVE_YOURSELF, 1);
|
||||
XmAddWMProtocolCallback(topLevel, xa_WM_SAVE_YOURSELF, SaveSessionCB,
|
||||
(XtPointer)this);
|
||||
XmAddWMProtocolCallback(topLevel,
|
||||
XmInternAtom(display, "WM_DELETE_WINDOW", False),
|
||||
CloseCB, (XtPointer)this);
|
||||
}
|
||||
|
||||
Application::~Application()
|
||||
{
|
||||
if (userFont)
|
||||
XmFontListFree(userFont);
|
||||
delete session_info;
|
||||
delete attributes;
|
||||
delete values;
|
||||
delete new_display;
|
||||
}
|
||||
|
||||
boolean Application::SetName(char *name)
|
||||
{
|
||||
if (!_w)
|
||||
return false;
|
||||
|
||||
XtVaSetValues(_w, XmNtitle, name, XmNiconName, name, NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean Application::SetVisiblity(boolean flag)
|
||||
{
|
||||
if (!_w)
|
||||
return false;
|
||||
|
||||
if (flag)
|
||||
{
|
||||
XtRealizeWidget(_w);
|
||||
XtVaSetValues(_w, XmNallowShellResize, False, NULL);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Application::Run()
|
||||
{
|
||||
XtAppMainLoop(appContext);
|
||||
}
|
||||
|
||||
void Application::SaveSessionCB(Widget, XtPointer client_data, XtPointer)
|
||||
{
|
||||
Application *obj = (Application *)client_data;
|
||||
obj->SaveMe(true);
|
||||
}
|
||||
|
||||
void Application::CloseCB(Widget, XtPointer client_data, XtPointer)
|
||||
{
|
||||
Application *obj = (Application *)client_data;
|
||||
obj->SaveMe();
|
||||
}
|
||||
|
||||
void Application::SaveMe(boolean save_as_session)
|
||||
{
|
||||
char *path = NULL, *name = NULL;
|
||||
|
||||
if (save_as_session)
|
||||
DtSessionSavePath(topLevel, &path, &name);
|
||||
else
|
||||
{
|
||||
name = SessionFile();
|
||||
char *path1 = SessionPath();
|
||||
path = new char[strlen(path1) + strlen(name) + 2];
|
||||
sprintf(path, "%s/%s", path1, name);
|
||||
name = NULL;
|
||||
}
|
||||
if (path && (fp = fopen(path, "w")))
|
||||
{
|
||||
SaveYourSelf();
|
||||
fflush(fp);
|
||||
fclose(fp);
|
||||
fp = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (save_as_session)
|
||||
{
|
||||
char **new_argv = NULL;
|
||||
char **_argv;
|
||||
int _argc;
|
||||
|
||||
XtVaGetValues(topLevel, XmNargc, &_argc, XmNargv, &_argv, NULL);
|
||||
|
||||
int i;
|
||||
if (path && name)
|
||||
{
|
||||
if (_argc > 2 && !STRCMP(SESSION_FLAG, _argv[1]))
|
||||
{
|
||||
new_argv = new char *[_argc + 1];
|
||||
for (i = 0; i < _argc; i++)
|
||||
new_argv[i] = _argv[i];
|
||||
new_argv[2] = name;
|
||||
new_argv[i] = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
int j;
|
||||
|
||||
new_argv = new char *[_argc + 3];
|
||||
new_argv[0] = _argv[0];
|
||||
new_argv[1] = (char *)SESSION_FLAG;
|
||||
new_argv[2] = name;
|
||||
for (i = 1, j = 3; i < _argc; i++, j++)
|
||||
new_argv[j] = _argv[i];
|
||||
new_argv[j] = NULL;
|
||||
_argc += 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
new_argv = new char *[_argc + 1];
|
||||
for (i = 0; i < _argc; i++)
|
||||
new_argv[i] = _argv[i];
|
||||
new_argv[i] = NULL;
|
||||
}
|
||||
XSetCommand(display, XtWindow(topLevel), new_argv, _argc);
|
||||
delete [] new_argv;
|
||||
}
|
||||
if (path)
|
||||
XtFree(path);
|
||||
if (name)
|
||||
XtFree(name);
|
||||
}
|
||||
|
||||
void Application::Save(char *attribute, char *value)
|
||||
{
|
||||
if (fp)
|
||||
fprintf(fp, "%s\n%s\n", attribute, value);
|
||||
}
|
||||
|
||||
char *Application::Restore(char *attribute)
|
||||
{
|
||||
char *value = NULL;
|
||||
if (!session_info)
|
||||
{
|
||||
if (!session_path)
|
||||
{
|
||||
char *name = SessionFile();
|
||||
char *path = SessionPath();
|
||||
session_path = new char[strlen(path) + strlen(name) + 2];
|
||||
sprintf(session_path, "%s/%s", path, name);
|
||||
session_file = strdup(session_path);
|
||||
}
|
||||
struct stat statbuff;
|
||||
if (stat(session_path, &statbuff) != -1)
|
||||
{
|
||||
FILE *fp1;
|
||||
if (fp1 = fopen(session_path, "r"))
|
||||
{
|
||||
session_info = new char[statbuff.st_size + 1];
|
||||
fread(session_info, (unsigned int)statbuff.st_size, 1, fp1);
|
||||
fclose(fp1);
|
||||
session_info[statbuff.st_size] = '\0';
|
||||
char *s, *s1 = session_info;
|
||||
s = s1;
|
||||
while (s && (s = strchr(s1, '\n')))
|
||||
{
|
||||
n_attrs++;
|
||||
s1 = s + 1;
|
||||
}
|
||||
|
||||
n_attrs /= 2;
|
||||
attributes = new char*[n_attrs];
|
||||
values = new char*[n_attrs];
|
||||
s = strtok(session_info, "\n");
|
||||
int i = 0;
|
||||
while (s && *s)
|
||||
{
|
||||
attributes[i] = s;
|
||||
values[i] = strtok(NULL, "\n");
|
||||
s = strtok(NULL, "\n");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!session_info)
|
||||
session_info = strdup("");
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < n_attrs; i++)
|
||||
if (!STRCMP(attributes[i], attribute))
|
||||
{
|
||||
value = values[i];
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
62
cde/programs/dtprintinfo/libUI/MotifUI/Application.h
Normal file
62
cde/programs/dtprintinfo/libUI/MotifUI/Application.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* $XConsortium: Application.h /main/3 1995/11/06 09:38:56 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef APPLICATION_H
|
||||
#define APPLICATION_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
#include <stdio.h>
|
||||
|
||||
class Application : public MotifUI {
|
||||
|
||||
friend int main(int, char **);
|
||||
friend void SaveSessionCB(Widget, XtPointer, XtPointer);
|
||||
friend void CloseCB(Widget, XtPointer, XtPointer);
|
||||
|
||||
protected:
|
||||
|
||||
static void SaveSessionCB(Widget, XtPointer, XtPointer);
|
||||
static void CloseCB(Widget, XtPointer, XtPointer);
|
||||
XFontStruct *fs;
|
||||
FILE *fp;
|
||||
char **attributes;
|
||||
char **values;
|
||||
int n_attrs;
|
||||
char *session_info;
|
||||
char *session_file;
|
||||
char *session_path;
|
||||
char *new_display;
|
||||
virtual void Run();
|
||||
|
||||
public:
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
Application(char *name,
|
||||
char *className,
|
||||
int *argc,
|
||||
char **argv);
|
||||
virtual ~Application();
|
||||
|
||||
boolean SetVisiblity(boolean);
|
||||
boolean SetName(char *);
|
||||
virtual void SaveYourSelf() { }
|
||||
virtual char *SessionFile() { return NULL; }
|
||||
virtual char *SessionPath() { return NULL; }
|
||||
void Save(char *attribute, char *value);
|
||||
char *Restore(char *attribute);
|
||||
void SaveMe(boolean save_as_session = false);
|
||||
|
||||
const UI_Class UIClass() { return APPLICATION; }
|
||||
|
||||
const char *const UIClassName() { return "Application"; }
|
||||
|
||||
};
|
||||
|
||||
#endif /* APPLICATION_H */
|
||||
164
cde/programs/dtprintinfo/libUI/MotifUI/Button.C
Normal file
164
cde/programs/dtprintinfo/libUI/MotifUI/Button.C
Normal file
@@ -0,0 +1,164 @@
|
||||
/* $TOG: Button.C /main/3 1998/07/24 16:14:59 mgreess $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "Button.h"
|
||||
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/ToggleB.h>
|
||||
#include <Xm/ArrowB.h>
|
||||
#include "WorkArea.h"
|
||||
|
||||
Button::Button(MotifUI *parent, char *name, ButtonType button_type,
|
||||
ButtonCallback callback, void * callback_data,
|
||||
char *mnemonic, char *acceleratorText,
|
||||
char *accelerator, char *iconFile)
|
||||
: MotifUI(parent, name, NULL)
|
||||
{
|
||||
CreateButton(parent, name, NULL, button_type, callback, callback_data,
|
||||
mnemonic, acceleratorText, accelerator, iconFile);
|
||||
}
|
||||
|
||||
Button::Button(char *category, MotifUI *parent, char *name,
|
||||
ButtonType button_type, ButtonCallback callback,
|
||||
void * callback_data, char *mnemonic, char *acceleratorText,
|
||||
char *accelerator, char *iconFile)
|
||||
: MotifUI(parent, name, category)
|
||||
{
|
||||
CreateButton(parent, name, category, button_type, callback, callback_data,
|
||||
mnemonic, acceleratorText, accelerator, iconFile);
|
||||
}
|
||||
|
||||
Button::~Button()
|
||||
{
|
||||
delete _iconFile;
|
||||
}
|
||||
|
||||
void Button::IconFile(char *iconFile)
|
||||
{
|
||||
delete _iconFile;
|
||||
_iconFile = STRDUP(iconFile);
|
||||
if (_iconFile)
|
||||
{
|
||||
Pixmap pixmap;
|
||||
char *s = new char[strlen(iconFile) + 6];
|
||||
if (depth == 1)
|
||||
{
|
||||
Pixel bg;
|
||||
XtVaGetValues(_w, XmNbackground, &bg, NULL);
|
||||
if (bg == black)
|
||||
sprintf(s, "%s.m.pm", iconFile);
|
||||
else
|
||||
sprintf(s, "%s.m.bm", iconFile);
|
||||
}
|
||||
else
|
||||
sprintf(s, "%s.m.pm", iconFile);
|
||||
GetPixmaps(_w, s, &pixmap);
|
||||
delete [] s;
|
||||
XtVaSetValues(_w, XmNlabelType, XmPIXMAP, XmNlabelPixmap, pixmap, NULL);
|
||||
}
|
||||
else
|
||||
XtVaSetValues(_w, XmNlabelType, XmSTRING, NULL);
|
||||
}
|
||||
|
||||
void Button::CreateButton(MotifUI *parent, char *name, char * /*category*/,
|
||||
ButtonType button_type, ButtonCallback callback,
|
||||
void * callback_data, char *mnemonic,
|
||||
char *acceleratorText, char *accelerator, char *iconFile)
|
||||
{
|
||||
int IsArrow = false;
|
||||
XmString xm_string = StringCreate(name);
|
||||
Widget parentW;
|
||||
Widget super_node = NULL;
|
||||
|
||||
_iconFile = NULL;
|
||||
_button_type = button_type;
|
||||
|
||||
if (parent->UIClass() == DIALOG)
|
||||
parentW = parent->BaseWidget();
|
||||
else if (parent->UIClass() == ICON)
|
||||
{
|
||||
parentW = XtParent(parent->InnerWidget());
|
||||
super_node = parent->InnerWidget();
|
||||
}
|
||||
else
|
||||
parentW = parent->InnerWidget();
|
||||
if (button_type == PUSH_BUTTON)
|
||||
_w = XtVaCreateManagedWidget("button", xmPushButtonWidgetClass, parentW,
|
||||
XmNlabelString, xm_string,
|
||||
XmNaccelerator, accelerator,
|
||||
XmNmultiClick, XmMULTICLICK_DISCARD,
|
||||
GuiNsuperNode, super_node, NULL);
|
||||
else if (button_type == TOGGLE_BUTTON)
|
||||
_w = XtVaCreateManagedWidget("toggle", xmToggleButtonWidgetClass, parentW,
|
||||
XmNlabelString, xm_string,
|
||||
XmNaccelerator, accelerator,
|
||||
XmNmultiClick, XmMULTICLICK_DISCARD,
|
||||
GuiNsuperNode, super_node, NULL);
|
||||
else
|
||||
{
|
||||
int dir;
|
||||
|
||||
switch (button_type)
|
||||
{
|
||||
case UP_ARROW_BUTTON: dir = XmARROW_UP;
|
||||
case DOWN_ARROW_BUTTON: dir = XmARROW_DOWN;
|
||||
case LEFT_ARROW_BUTTON: dir = XmARROW_LEFT;
|
||||
case RIGHT_ARROW_BUTTON: dir = XmARROW_RIGHT;
|
||||
}
|
||||
_w = XtVaCreateManagedWidget("arrow", xmArrowButtonWidgetClass, parentW,
|
||||
XmNmultiClick, XmMULTICLICK_DISCARD,
|
||||
XmNarrowDirection, dir, NULL);
|
||||
IsArrow = true;
|
||||
}
|
||||
StringFree(xm_string);
|
||||
if (!IsArrow)
|
||||
{
|
||||
if (mnemonic)
|
||||
XtVaSetValues(_w, XmNmnemonic, XStringToKeysym(mnemonic), NULL);
|
||||
if (acceleratorText)
|
||||
{
|
||||
xm_string = StringCreate(acceleratorText);
|
||||
XtVaSetValues(_w, XmNacceleratorText, xm_string, NULL);
|
||||
StringFree(xm_string);
|
||||
}
|
||||
}
|
||||
_callback = callback;
|
||||
_callback_data = callback_data;
|
||||
|
||||
if (button_type == TOGGLE_BUTTON)
|
||||
XtAddCallback(_w, XmNvalueChangedCallback, &Button::ActivateCB,
|
||||
(XtPointer) this);
|
||||
else
|
||||
XtAddCallback(_w, XmNactivateCallback, &Button::ActivateCB,
|
||||
(XtPointer) this);
|
||||
InstallHelpCB();
|
||||
IconFile(iconFile);
|
||||
}
|
||||
|
||||
void Button::ActivateCB(Widget w,
|
||||
XtPointer client_data,
|
||||
XtPointer)
|
||||
{
|
||||
Button *obj = (Button *) client_data;
|
||||
ButtonCallback callback;
|
||||
|
||||
if (XmIsToggleButton(w))
|
||||
{
|
||||
if (obj->Selected())
|
||||
obj->Selected(false);
|
||||
else
|
||||
obj->Selected(true);
|
||||
}
|
||||
if ((callback = obj->_callback))
|
||||
{
|
||||
if (obj->_callback_data)
|
||||
(*callback)(obj->_callback_data);
|
||||
else
|
||||
(*callback)(obj);
|
||||
}
|
||||
}
|
||||
64
cde/programs/dtprintinfo/libUI/MotifUI/Button.h
Normal file
64
cde/programs/dtprintinfo/libUI/MotifUI/Button.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* $XConsortium: Button.h /main/3 1995/11/06 09:39:10 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef BUTTON_H
|
||||
#define BUTTON_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
class Button : public MotifUI {
|
||||
|
||||
private:
|
||||
|
||||
ButtonCallback _callback;
|
||||
void * _callback_data;
|
||||
static void ActivateCB(Widget, XtPointer, XtPointer);
|
||||
ButtonType _button_type;
|
||||
char *_iconFile;
|
||||
void CreateButton(MotifUI *, char *, char *, ButtonType, ButtonCallback,
|
||||
void *, char *, char *, char *, char *);
|
||||
|
||||
public:
|
||||
|
||||
// If the callback_data is NULL, the this pointer will be the callback data
|
||||
Button(MotifUI *parent,
|
||||
char *name,
|
||||
ButtonType button_type = PUSH_BUTTON,
|
||||
ButtonCallback callback = NULL,
|
||||
void * callback_data = NULL,
|
||||
char *mnemonic = NULL,
|
||||
char *acceleratorText = NULL,
|
||||
char *accelerator = NULL,
|
||||
char *iconFile = NULL);
|
||||
|
||||
Button(char *category,
|
||||
MotifUI *parent,
|
||||
char *name,
|
||||
ButtonType button_type = PUSH_BUTTON,
|
||||
ButtonCallback callback = NULL,
|
||||
void * callback_data = NULL,
|
||||
char *mnemonic = NULL,
|
||||
char *acceleratorText = NULL,
|
||||
char *accelerator = NULL,
|
||||
char *iconFile = NULL);
|
||||
|
||||
~Button();
|
||||
|
||||
void Callback(ButtonCallback cb) { _callback = cb; }
|
||||
void CallbackData(void *data) { _callback_data = data; }
|
||||
ButtonCallback Callback() { return _callback; }
|
||||
void * CallbackData() { return _callback_data; }
|
||||
const char *IconFile() { return _iconFile; }
|
||||
void IconFile(char *);
|
||||
|
||||
const UI_Class UIClass() { return BUTTON; }
|
||||
const int UISubClass() { return _button_type; }
|
||||
const char *const UIClassName() { return "Button"; }
|
||||
};
|
||||
|
||||
#endif /* BUTTON_H */
|
||||
138
cde/programs/dtprintinfo/libUI/MotifUI/ComboBoxObj.C
Normal file
138
cde/programs/dtprintinfo/libUI/MotifUI/ComboBoxObj.C
Normal file
@@ -0,0 +1,138 @@
|
||||
/* $XConsortium: ComboBoxObj.C /main/4 1995/11/06 09:39:21 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "ComboBoxObj.h"
|
||||
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/List.h>
|
||||
#include <Xm/ComboBox.h>
|
||||
|
||||
ComboBoxObj::ComboBoxObj(MotifUI *parent,
|
||||
#if defined(USL) || defined(__uxp__)
|
||||
void (*callback)(ComboBoxObj *, char *, int),
|
||||
#else
|
||||
ComboBoxCallback callback,
|
||||
#endif
|
||||
char *name,
|
||||
char **items,
|
||||
int n_items)
|
||||
: MotifUI(parent, name, NULL)
|
||||
{
|
||||
XmString *items_list;
|
||||
int itemCount;
|
||||
if (items && n_items)
|
||||
{
|
||||
items_list = new XmString [n_items];
|
||||
int i;
|
||||
if (n_items > 8)
|
||||
itemCount = 8;
|
||||
else
|
||||
itemCount = n_items;
|
||||
for (i = 0; i < n_items; i++)
|
||||
items_list[i] = StringCreate(items[i]);
|
||||
}
|
||||
else
|
||||
items_list = NULL;
|
||||
_callback = callback;
|
||||
if (name)
|
||||
{
|
||||
XmString xm_string = StringCreate(name);
|
||||
_w = XtVaCreateManagedWidget("form", xmFormWidgetClass,
|
||||
parent->InnerWidget(), NULL);
|
||||
_label = XtVaCreateManagedWidget("form", xmLabelWidgetClass,
|
||||
_w, XmNlabelString, xm_string,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM, NULL);
|
||||
_combo_box = XtVaCreateManagedWidget("combo_box", xmComboBoxWidgetClass,
|
||||
_w, XmNleftWidget, _label,
|
||||
XmNleftAttachment, XmATTACH_WIDGET,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNcomboBoxType, XmDROP_DOWN_LIST,
|
||||
(items_list ? XmNitems : NULL),
|
||||
items_list,
|
||||
XmNitemCount, n_items,
|
||||
XmNvisibleItemCount, itemCount,
|
||||
NULL);
|
||||
StringFree(xm_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
_w = XtVaCreateManagedWidget("combo_box", xmComboBoxWidgetClass,
|
||||
parent->InnerWidget(),
|
||||
XmNcomboBoxType, XmDROP_DOWN_LIST,
|
||||
(items_list ? XmNitems : NULL), items_list,
|
||||
XmNitemCount, n_items,
|
||||
XmNvisibleItemCount, itemCount, NULL);
|
||||
_label = NULL;
|
||||
_combo_box = _w;
|
||||
}
|
||||
_list = XtNameToWidget(_combo_box, "*List");
|
||||
XtAddCallback(_combo_box, XmNselectionCallback, &ComboBoxObj::SelectCB,
|
||||
(XtPointer)this);
|
||||
if (items_list)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < n_items; i++)
|
||||
StringFree(items_list[i]);
|
||||
delete items_list;
|
||||
}
|
||||
}
|
||||
|
||||
char * ComboBoxObj::Item(int item)
|
||||
{
|
||||
XmString *items;
|
||||
int n_items;
|
||||
XtVaGetValues(_list, XmNitems, &items, XmNitemCount, &n_items, NULL);
|
||||
if (item < 0 || item > n_items - 1)
|
||||
return NULL;
|
||||
else
|
||||
return StringExtract(items[item + 1]);
|
||||
}
|
||||
|
||||
char * ComboBoxObj::Item(char *item)
|
||||
{
|
||||
XmString value = StringCreate(item);
|
||||
int n = XmListItemExists(_list, value);
|
||||
StringFree(value);
|
||||
if (n)
|
||||
return item;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ComboBoxObj::Add(char *item)
|
||||
{
|
||||
XmString value = StringCreate(item);
|
||||
XmComboBoxAddItem(_combo_box, value, 0, True);
|
||||
StringFree(value);
|
||||
}
|
||||
|
||||
void ComboBoxObj::Delete(char *item)
|
||||
{
|
||||
XmString value = StringCreate(item);
|
||||
int n = XmListItemPos(_list, value);
|
||||
if (n)
|
||||
XmComboBoxDeletePos(_combo_box, n);
|
||||
StringFree(value);
|
||||
}
|
||||
|
||||
void ComboBoxObj::SelectCB(Widget, XtPointer client_data, XtPointer call_data)
|
||||
{
|
||||
ComboBoxObj *obj = (ComboBoxObj *) client_data;
|
||||
XmComboBoxCallbackStruct * cb = (XmComboBoxCallbackStruct *)call_data;
|
||||
if (obj->_callback)
|
||||
{
|
||||
char *item = obj->StringExtract(cb->item_or_text);
|
||||
(*obj->_callback)(obj, item, cb->item_position);
|
||||
XtFree(item);
|
||||
}
|
||||
}
|
||||
52
cde/programs/dtprintinfo/libUI/MotifUI/ComboBoxObj.h
Normal file
52
cde/programs/dtprintinfo/libUI/MotifUI/ComboBoxObj.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* $XConsortium: ComboBoxObj.h /main/3 1995/11/06 09:39:32 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef COMBOBOXOBJ_H
|
||||
#define COMBOBOXOBJ_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
class ComboBoxObj;
|
||||
|
||||
typedef void (*ComboBoxCallback) (ComboBoxObj *, char *item, int item_position);
|
||||
|
||||
class ComboBoxObj : public MotifUI {
|
||||
|
||||
friend void SelectCB(Widget, XtPointer, XtPointer);
|
||||
|
||||
private:
|
||||
|
||||
static void SelectCB(Widget, XtPointer, XtPointer);
|
||||
|
||||
Widget _label;
|
||||
Widget _list;
|
||||
Widget _combo_box;
|
||||
ComboBoxCallback _callback;
|
||||
|
||||
public:
|
||||
|
||||
#if defined(USL) || defined(__uxp__)
|
||||
ComboBoxObj(MotifUI * parent, void (*)(ComboBoxObj *, char *, int),
|
||||
char *name, char **items, int n_items);
|
||||
#else
|
||||
ComboBoxObj(MotifUI * parent, ComboBoxCallback, char *name,
|
||||
char **items, int n_items);
|
||||
#endif
|
||||
|
||||
void Add(char *item);
|
||||
void Delete(char *item);
|
||||
char * Item(char *item);
|
||||
char * Item(int index);
|
||||
|
||||
const Widget InnerWidget() { return _combo_box; }
|
||||
const UI_Class UIClass() { return COMBO_BOX; }
|
||||
const char *const UIClassName() { return "ComboBox"; }
|
||||
|
||||
};
|
||||
|
||||
#endif /* COMBOBOXOBJ_H */
|
||||
545
cde/programs/dtprintinfo/libUI/MotifUI/Container.C
Normal file
545
cde/programs/dtprintinfo/libUI/MotifUI/Container.C
Normal file
@@ -0,0 +1,545 @@
|
||||
/* $XConsortium: Container.C /main/2 1995/07/17 14:05:19 drk $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "Container.h"
|
||||
#include "IconObj.h"
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/DropSMgr.h>
|
||||
#include "Icon.h"
|
||||
#include "WorkArea.h"
|
||||
#include <Xm/ScrolledW.h>
|
||||
#include <Xm/PanedW.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/DrawingA.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
Container::Container(MotifUI *parent,
|
||||
char *name,
|
||||
ContainerType container_type,
|
||||
SelectionType select_type)
|
||||
: MotifUI(parent, name, NULL)
|
||||
{
|
||||
CreateContainer(parent, name, NULL, container_type, select_type);
|
||||
}
|
||||
|
||||
Container::Container(char *category,
|
||||
MotifUI *parent,
|
||||
char *name,
|
||||
ContainerType container_type,
|
||||
SelectionType select_type)
|
||||
: MotifUI(parent, name, category)
|
||||
{
|
||||
CreateContainer(parent, name, category, container_type, select_type);
|
||||
}
|
||||
|
||||
static XtTranslations trans_tbl = NULL;
|
||||
static XtActionsRec action_table[] = {{"ResizeRC", NULL}};
|
||||
|
||||
void Container::CreateContainer(MotifUI *parent, char * /*name*/,
|
||||
char * /*category*/,
|
||||
ContainerType container_type,
|
||||
SelectionType select_type)
|
||||
{
|
||||
Arg args[15];
|
||||
int n;
|
||||
Pixel pixel;
|
||||
Widget parentW;
|
||||
Widget superNode;
|
||||
int radio_behavior = false;
|
||||
int _shadowThickness;
|
||||
|
||||
if (!trans_tbl)
|
||||
{
|
||||
action_table[0].proc = (XtActionProc) ResizeRC;
|
||||
trans_tbl = XtParseTranslationTable("<Configure>:ResizeRC()");
|
||||
XtAppAddActions(appContext, action_table, XtNumber(action_table));
|
||||
}
|
||||
|
||||
_xm_update_message = NULL;
|
||||
_select_type = select_type;
|
||||
_last_selected = NULL;
|
||||
parentW = parent->InnerWidget();
|
||||
if (GuiIsIcon(parentW))
|
||||
superNode = parentW;
|
||||
else
|
||||
superNode = NULL;
|
||||
if (!XtIsComposite(parentW))
|
||||
parentW = XtParent(parentW);
|
||||
if (select_type == SINGLE_SELECT)
|
||||
radio_behavior = true;
|
||||
|
||||
switch (_container_type = container_type)
|
||||
{
|
||||
case FORM:
|
||||
_w = XtVaCreateManagedWidget("form", xmFormWidgetClass,
|
||||
parentW, NULL);
|
||||
_workArea = _w;
|
||||
break;
|
||||
case SCROLLED_FORM:
|
||||
_w = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass,
|
||||
parentW, NULL);
|
||||
_workArea = XtVaCreateManagedWidget("form", xmFormWidgetClass,
|
||||
_w, NULL);
|
||||
break;
|
||||
case CANVAS:
|
||||
_w = XtVaCreateManagedWidget("canvas", xmDrawingAreaWidgetClass,
|
||||
parentW, NULL);
|
||||
_workArea = _w;
|
||||
break;
|
||||
case SCROLLED_CANVAS:
|
||||
_w = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass,
|
||||
parentW, NULL);
|
||||
_workArea = XtVaCreateManagedWidget("canvas", xmDrawingAreaWidgetClass,
|
||||
_w, NULL);
|
||||
break;
|
||||
case HORIZONTAL_ROW_COLUMN:
|
||||
_w = XtVaCreateManagedWidget("rc", xmRowColumnWidgetClass, parentW,
|
||||
XmNorientation, XmHORIZONTAL,
|
||||
XmNradioBehavior, radio_behavior, NULL);
|
||||
_workArea = _w;
|
||||
break;
|
||||
case SCROLLED_HORIZONTAL_ROW_COLUMN:
|
||||
_w = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass, parentW,
|
||||
GuiNisOpened, false, GuiNisWorkArea, true,
|
||||
GuiNsuperNode, superNode, XmNspacing, 0,
|
||||
XmNscrollBarDisplayPolicy, XmAS_NEEDED,
|
||||
XmNscrollingPolicy, XmAUTOMATIC,
|
||||
XmNheight, Parent()->Height(), NULL);
|
||||
XtAddCallback(_w, XmNtraverseObscuredCallback, MakeChildVisible, NULL);
|
||||
_workArea = XtVaCreateManagedWidget("rc", xmRowColumnWidgetClass, _w,
|
||||
XmNorientation, XmHORIZONTAL,
|
||||
XmNradioBehavior, radio_behavior,
|
||||
XmNpacking, XmPACK_TIGHT,
|
||||
XmNadjustLast, False,
|
||||
XmNuserData, this, NULL);
|
||||
XtAddCallback(XtParent(_workArea), XmNresizeCallback,
|
||||
ResizeSW, (XtPointer) this);
|
||||
XtOverrideTranslations(_workArea, trans_tbl);
|
||||
break;
|
||||
case VERTICAL_ROW_COLUMN:
|
||||
_w = XtVaCreateManagedWidget("rc", xmRowColumnWidgetClass, parentW,
|
||||
XmNradioBehavior, radio_behavior, NULL);
|
||||
_workArea = _w;
|
||||
break;
|
||||
case SCROLLED_VERTICAL_ROW_COLUMN:
|
||||
_w = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass, parentW,
|
||||
GuiNisOpened, false, GuiNisWorkArea, true,
|
||||
GuiNsuperNode, superNode, XmNspacing, 0,
|
||||
XmNradioBehavior, radio_behavior,
|
||||
XmNscrollBarDisplayPolicy, XmAS_NEEDED,
|
||||
XmNscrollingPolicy, XmAUTOMATIC, NULL);
|
||||
_workArea = XtVaCreateManagedWidget("rc", xmRowColumnWidgetClass, _w,
|
||||
XmNradioBehavior, radio_behavior,
|
||||
NULL);
|
||||
break;
|
||||
case PANE:
|
||||
_w = XtVaCreateManagedWidget("pane", xmPanedWindowWidgetClass,
|
||||
parentW, NULL);
|
||||
_workArea = _w;
|
||||
break;
|
||||
case SCROLLED_PANE:
|
||||
_w = XtVaCreateManagedWidget("sw", xmScrolledWindowWidgetClass,
|
||||
parentW, NULL);
|
||||
_workArea = XtVaCreateManagedWidget("form", xmPanedWindowWidgetClass,
|
||||
_w, NULL);
|
||||
break;
|
||||
case WORK_AREA:
|
||||
_w = XtVaCreateManagedWidget("form", workAreaWidgetClass,
|
||||
parentW, NULL);
|
||||
_workArea = _w;
|
||||
break;
|
||||
case ICON_LIST:
|
||||
_w = XtVaCreateManagedWidget("form", workAreaWidgetClass,
|
||||
parentW, GuiNisList, True, NULL);
|
||||
_workArea = _w;
|
||||
break;
|
||||
case SCROLLED_ICON_LIST:
|
||||
case SCROLLED_WORK_AREA:
|
||||
if (Parent()->UIClass() == DIALOG)
|
||||
_shadowThickness = 0;
|
||||
else
|
||||
_shadowThickness = shadowThickness;
|
||||
_w = XtVaCreateManagedWidget("form", xmFormWidgetClass,
|
||||
parentW,
|
||||
XmNshadowThickness, _shadowThickness,
|
||||
XmNshadowType, XmSHADOW_OUT, NULL);
|
||||
n = 0;
|
||||
if (_container_type == SCROLLED_ICON_LIST)
|
||||
{
|
||||
XtSetArg(args[n], GuiNisList, True); n++;
|
||||
}
|
||||
else
|
||||
{
|
||||
XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
|
||||
XtSetArg(args[n], XmNentryVerticalAlignment,
|
||||
XmALIGNMENT_CONTENTS_BOTTOM);
|
||||
n++;
|
||||
}
|
||||
XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
|
||||
XtSetArg(args[n], XmNtopOffset, 6); n++;
|
||||
XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
|
||||
XtSetArg(args[n], XmNleftOffset, 6); n++;
|
||||
XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
|
||||
XtSetArg(args[n], XmNrightOffset, 6); n++;
|
||||
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
|
||||
XtSetArg(args[n], XmNbottomOffset, 6); n++;
|
||||
XtSetArg(args[n], GuiNlineOffset, 20); n++;
|
||||
XtSetArg(args[n], GuiNlineThickness, 2); n++;
|
||||
XtSetArg(args[n], XmNuserData, this); n++;
|
||||
|
||||
_workArea = GuiCreateScrolledWorkArea(_w, "workArea", args, n);
|
||||
XtManageChild(_workArea);
|
||||
break;
|
||||
}
|
||||
|
||||
if (_workArea == _w)
|
||||
{
|
||||
_clipWidget = _sw = _vbar = _hbar = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
_clipWidget = XtParent(_workArea);
|
||||
_sw = XtParent(_clipWidget);
|
||||
XtVaGetValues(_sw, XmNverticalScrollBar, &_vbar,
|
||||
XmNhorizontalScrollBar, &_hbar, NULL);
|
||||
if (container_type == SCROLLED_HORIZONTAL_ROW_COLUMN)
|
||||
XtUnmanageChild(_vbar);
|
||||
|
||||
if (depth > 1 &&
|
||||
(container_type == SCROLLED_WORK_AREA ||
|
||||
container_type == SCROLLED_ICON_LIST))
|
||||
{
|
||||
XtVaGetValues(_vbar, XmNtroughColor, &pixel, NULL);
|
||||
XtVaSetValues(_workArea, XmNbackground, pixel, NULL);
|
||||
XtVaSetValues(_clipWidget, XmNbackground, pixel, NULL);
|
||||
}
|
||||
}
|
||||
InstallHelpCB();
|
||||
InstallDestroyCB();
|
||||
}
|
||||
|
||||
boolean Container::SetIcon(IconStyle)
|
||||
{
|
||||
if (_container_type == SCROLLED_HORIZONTAL_ROW_COLUMN)
|
||||
XtAppAddTimeOut(appContext, 500, ResizeTimeOut, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Container::DoBeginUpdate()
|
||||
{
|
||||
XtAddEventHandler(XtParent(_workArea), ExposureMask, FALSE,
|
||||
&Container::UpdateAreaMessage, (XtPointer) this);
|
||||
|
||||
if (_container_type == SCROLLED_WORK_AREA ||
|
||||
_container_type == WORK_AREA ||
|
||||
_container_type == SCROLLED_ICON_LIST ||
|
||||
_container_type == ICON_LIST)
|
||||
{
|
||||
if (XtIsRealized(_workArea))
|
||||
XtUnmapWidget(_workArea);
|
||||
GuiWorkAreaDisableRedisplay(_workArea);
|
||||
XmDropSiteStartUpdate(XtParent(_workArea));
|
||||
}
|
||||
else
|
||||
XtUnmanageChild(_workArea);
|
||||
}
|
||||
|
||||
void Container::DoEndUpdate()
|
||||
{
|
||||
XtRemoveEventHandler(XtParent(_workArea), ExposureMask, FALSE,
|
||||
&Container::UpdateAreaMessage, (XtPointer) this);
|
||||
StringFree(_xm_update_message);
|
||||
if (XtIsRealized(_workArea))
|
||||
XClearArea(display, XtWindow(XtParent(_workArea)), 0, 0, 0, 0, TRUE);
|
||||
_xm_update_message = NULL;
|
||||
if (_container_type == SCROLLED_WORK_AREA ||
|
||||
_container_type == WORK_AREA ||
|
||||
_container_type == SCROLLED_ICON_LIST ||
|
||||
_container_type == ICON_LIST)
|
||||
{
|
||||
if (XtIsRealized(_workArea))
|
||||
XtMapWidget(_workArea);
|
||||
GuiWorkAreaEnableRedisplay(_workArea);
|
||||
XmDropSiteEndUpdate(XtParent(_workArea));
|
||||
}
|
||||
else
|
||||
{
|
||||
XtManageChild(_workArea);
|
||||
if (_container_type == SCROLLED_HORIZONTAL_ROW_COLUMN)
|
||||
XtAppAddTimeOut(appContext, 500, ResizeTimeOut, this);
|
||||
}
|
||||
}
|
||||
|
||||
void Container::DoUpdateMessage(char *message)
|
||||
{
|
||||
StringFree(_xm_update_message);
|
||||
_xm_update_message = StringCreate(message);
|
||||
if (XtIsRealized(_workArea))
|
||||
XClearArea(display, XtWindow(XtParent(_workArea)), 0, 0, 0, 0, TRUE);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void Container::SelectionPolicy(SelectionType)
|
||||
{
|
||||
}
|
||||
|
||||
void Container::NotifyDelete(BaseUI *obj)
|
||||
{
|
||||
MotifUI::NotifyDelete(obj);
|
||||
if (_last_selected == obj)
|
||||
_last_selected = NULL;
|
||||
if (_container_type == SCROLLED_HORIZONTAL_ROW_COLUMN)
|
||||
XtAppAddTimeOut(appContext, 500, ResizeTimeOut, this);
|
||||
}
|
||||
|
||||
void Container::NotifyVisiblity(BaseUI *obj)
|
||||
{
|
||||
if (_last_selected == obj)
|
||||
_last_selected->Selected(false);
|
||||
}
|
||||
|
||||
void Container::NotifySelected(BaseUI *obj)
|
||||
{
|
||||
switch (_select_type)
|
||||
{
|
||||
case SINGLE_SELECT:
|
||||
if (_last_selected && _last_selected != obj)
|
||||
{
|
||||
if (obj->Selected())
|
||||
_last_selected->Selected(false);
|
||||
}
|
||||
if (obj->Selected())
|
||||
_last_selected = obj;
|
||||
else
|
||||
_last_selected = NULL;
|
||||
break;
|
||||
case MULTIPLE_SELECT:
|
||||
break;
|
||||
case EXTENDED_SELECT:
|
||||
break;
|
||||
case BROWSE_SELECT:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Open Animation stuff
|
||||
|
||||
static GC CreateGC(Widget w);
|
||||
|
||||
void Container::OpenAnimation(MotifUI *obj)
|
||||
{
|
||||
if (!_update || !_w || !XtIsRealized(_w))
|
||||
return;
|
||||
|
||||
Dimension w, h, w2, h2;
|
||||
int x0, y0, x1, y1, x2, y2, x_inc1, y_inc1, x_inc2, y_inc2, n;
|
||||
Window window, area;
|
||||
Widget widget;
|
||||
GC gc;
|
||||
|
||||
if (_clipWidget)
|
||||
widget = _clipWidget;
|
||||
else
|
||||
widget = _w;
|
||||
|
||||
XtVaGetValues(widget, XmNwidth, &w, XmNheight, &h, NULL);
|
||||
XtVaGetValues(obj->BaseWidget(), XmNwidth, &w2, XmNheight, &h2, NULL);
|
||||
|
||||
area = XtWindow(widget);
|
||||
x1 = (int)w2 / 2;
|
||||
y1 = (int)h2 / 2;
|
||||
XTranslateCoordinates(display, XtWindow(obj->BaseWidget()), area,
|
||||
x1, y1, &x0, &y0, &window);
|
||||
n = 8;
|
||||
x_inc1 = -x0 / n;
|
||||
if (x_inc1 == 0)
|
||||
x_inc1 = -1;
|
||||
y_inc1 = -y0 / n;
|
||||
if (y_inc1 == 0)
|
||||
y_inc1 = -1;
|
||||
x_inc2 = (int)(w - x0) / n;
|
||||
if (x_inc2 == 0)
|
||||
x_inc2 = 1;
|
||||
y_inc2 = (int)(h - y0) / n;
|
||||
if (y_inc2 == 0)
|
||||
y_inc2 = 1;
|
||||
x1 = x0 + x_inc1;
|
||||
y1 = y0 + y_inc1;
|
||||
x2 = x0 + x_inc2;
|
||||
y2 = y0 + y_inc2;
|
||||
|
||||
gc = CreateGC(widget);
|
||||
while (--n)
|
||||
{
|
||||
XDrawRectangle(display, area, gc, x1, y1, x2 - x1, y2 - y1);
|
||||
XFlush(display);
|
||||
x1 += x_inc1;
|
||||
y1 += y_inc1;
|
||||
x2 += x_inc2;
|
||||
y2 += y_inc2;
|
||||
MicroSleep(OPEN_TIME);
|
||||
}
|
||||
n = 8;
|
||||
x1 = x0 + x_inc1;
|
||||
y1 = y0 + y_inc1;
|
||||
x2 = x0 + x_inc2;
|
||||
y2 = y0 + y_inc2;
|
||||
|
||||
while (--n)
|
||||
{
|
||||
XDrawRectangle(display, area, gc, x1, y1, x2 - x1, y2 - y1);
|
||||
XFlush(display);
|
||||
x1 += x_inc1;
|
||||
y1 += y_inc1;
|
||||
x2 += x_inc2;
|
||||
y2 += y_inc2;
|
||||
MicroSleep(OPEN_TIME);
|
||||
}
|
||||
XtReleaseGC(widget, gc);
|
||||
}
|
||||
|
||||
static GC CreateGC(Widget w)
|
||||
{
|
||||
XGCValues values;
|
||||
|
||||
XtVaGetValues(w, XmNforeground, &values.foreground,
|
||||
XmNbackground, &values.background, NULL);
|
||||
// Set the fg to the XOR of the fg and bg, so if it is
|
||||
// XOR'ed with bg, the result will be fg and vice-versa.
|
||||
// This effectively achieves inverse video for the line.
|
||||
|
||||
values.foreground = values.foreground ^ values.background;
|
||||
// Set the rubber band gc to use XOR mode and draw a dashed line.
|
||||
|
||||
values.function = GXxor;
|
||||
values.subwindow_mode = IncludeInferiors;
|
||||
return (XtGetGC(w, GCForeground | GCBackground |
|
||||
GCSubwindowMode | GCFunction, &values));
|
||||
}
|
||||
|
||||
void Container::UpdateAreaMessage(Widget widget, XtPointer client_data,
|
||||
XEvent * /*event*/, Boolean * /*continued*/)
|
||||
{
|
||||
unsigned char direction;
|
||||
XGCValues values;
|
||||
XtGCMask valueMask;
|
||||
Dimension width, height;
|
||||
Dimension w, h;
|
||||
int x, y;
|
||||
|
||||
static GC gc = (GC) NULL;
|
||||
|
||||
Container *container = (Container *) client_data;
|
||||
|
||||
if (!container->_xm_update_message)
|
||||
return;
|
||||
|
||||
if (!gc)
|
||||
{
|
||||
XtVaGetValues(widget, XmNforeground, &values.foreground, NULL);
|
||||
if (container->font)
|
||||
valueMask = GCFont | GCForeground;
|
||||
else
|
||||
valueMask = GCForeground;
|
||||
values.font = container->font;
|
||||
gc = XCreateGC(display, root, valueMask, &values);
|
||||
}
|
||||
XClearArea(display, XtWindow(widget), 0, 0, 0, 0, FALSE);
|
||||
XtVaGetValues(widget, XmNwidth, &width, XmNheight, &height, NULL);
|
||||
XtVaGetValues(container->_workArea, XmNstringDirection, &direction, NULL);
|
||||
XmStringExtent(container->userFont, container->_xm_update_message, &w, &h);
|
||||
x = (Dimension)(width - w) / 2;
|
||||
y = (Dimension)(height - h) / 2;
|
||||
XmStringDraw(display, XtWindow(widget), container->userFont,
|
||||
container->_xm_update_message,
|
||||
gc, x, y, w, XmALIGNMENT_CENTER, direction, NULL);
|
||||
}
|
||||
|
||||
void Container::MakeChildVisible(Widget widget, XtPointer, XtPointer call_data)
|
||||
{
|
||||
XmTraverseObscuredCallbackStruct *cb;
|
||||
Widget w;
|
||||
|
||||
cb = (XmTraverseObscuredCallbackStruct *) call_data;
|
||||
w = cb->traversal_destination;
|
||||
XmScrollVisible(widget, w, 0, 0);
|
||||
}
|
||||
|
||||
void Container::ResizeTimeOut(void *data, XtIntervalId * /*id*/)
|
||||
{
|
||||
Container *obj = (Container *)data;
|
||||
int h4 = obj->Parent()->Height();
|
||||
Dimension h1, h2, h3;
|
||||
|
||||
if (obj->NumChildren())
|
||||
{
|
||||
Dimension max_height;
|
||||
MotifUI **children = (MotifUI **)obj->Children();
|
||||
int i;
|
||||
XtWidgetGeometry preferred;
|
||||
|
||||
max_height = 0;
|
||||
for (i = 0; i < obj->NumChildren(); i++)
|
||||
{
|
||||
if (XtIsManaged(children[i]->BaseWidget()))
|
||||
{
|
||||
XtQueryGeometry(children[i]->BaseWidget(), NULL, &preferred);
|
||||
if ((h1 = preferred.height) > max_height)
|
||||
{
|
||||
max_height = h1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Position y;
|
||||
if (max_height)
|
||||
XtVaGetValues(children[0]->BaseWidget(), XmNy, &y, NULL);
|
||||
else
|
||||
y = 0;
|
||||
h1 = max_height + (2 * y);
|
||||
}
|
||||
else
|
||||
XtVaGetValues(obj->_workArea, XmNheight, &h1, NULL);
|
||||
XtVaGetValues(obj->_clipWidget, XmNheight, &h2, NULL);
|
||||
XtVaGetValues(obj->_w, XmNheight, &h3, NULL);
|
||||
h3 = h3 - h2 + h1;
|
||||
if (h2 != h1)
|
||||
{
|
||||
if (h4 > (int)h3)
|
||||
h3 = h4;
|
||||
else if (obj->NumChildren() == 0)
|
||||
return;
|
||||
h4 = h3;
|
||||
}
|
||||
else if (h4 <= (int)h3)
|
||||
return;
|
||||
XtVaSetValues(obj->_w, XmNheight, h4, NULL);
|
||||
obj->Refresh();
|
||||
XtVaGetValues(obj->_w, XmNheight, &h3, NULL);
|
||||
if (h3 != h4)
|
||||
XtAppAddTimeOut(obj->appContext, 500, ResizeTimeOut, obj);
|
||||
}
|
||||
|
||||
void Container::ResizeSW(Widget w, XtPointer client_data, XtPointer)
|
||||
{
|
||||
// Don't calculate resize here, since the scroll bar hasn't been
|
||||
// updated. Instead, add a sufficient timeout to calculate the resize
|
||||
// after the scroll bar has updated it's XmNvalue resource
|
||||
XtAppAddTimeOut(XtWidgetToApplicationContext(w),
|
||||
500, ResizeTimeOut, client_data);
|
||||
}
|
||||
|
||||
void Container::ResizeRC(Widget w, XEvent *, String *, int *)
|
||||
{
|
||||
Container *obj;
|
||||
XtVaGetValues(w, XmNuserData, &obj, NULL);
|
||||
XtAppAddTimeOut(obj->appContext, 500, ResizeTimeOut, obj);
|
||||
}
|
||||
78
cde/programs/dtprintinfo/libUI/MotifUI/Container.h
Normal file
78
cde/programs/dtprintinfo/libUI/MotifUI/Container.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/* $XConsortium: Container.h /main/3 1995/11/06 09:39:43 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef CONTAINER_H
|
||||
#define CONTAINER_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
const long OPEN_TIME = 40000L;
|
||||
|
||||
class Container : public MotifUI {
|
||||
|
||||
friend void UpdateAreaMessage(Widget, XtPointer, XEvent *, Boolean *);
|
||||
friend void MakeChildVisible(Widget, XtPointer, XtPointer);
|
||||
friend void ResizeTimeOut(void *, XtIntervalId *id);
|
||||
friend void ResizeSW(Widget, XtPointer, XtPointer);
|
||||
friend void ResizeRC(Widget, XEvent *, String *, int *);
|
||||
|
||||
|
||||
static void UpdateAreaMessage(Widget, XtPointer, XEvent *, Boolean *);
|
||||
static void MakeChildVisible(Widget, XtPointer, XtPointer);
|
||||
static void ResizeTimeOut(void *, XtIntervalId *id);
|
||||
static void ResizeSW(Widget, XtPointer, XtPointer);
|
||||
static void ResizeRC(Widget, XEvent *, String *, int *);
|
||||
|
||||
protected:
|
||||
|
||||
Widget _sw;
|
||||
Widget _workArea;
|
||||
Widget _clipWidget;
|
||||
Widget _vbar;
|
||||
Widget _hbar;
|
||||
XmString _xm_update_message;
|
||||
BaseUI *_last_selected;
|
||||
IconStyle _style;
|
||||
IconStyle _previous_style;
|
||||
ContainerType _container_type;
|
||||
SelectionType _select_type;
|
||||
virtual boolean SetIcon(IconStyle);
|
||||
|
||||
void NotifySelected(BaseUI *);
|
||||
void NotifyDelete(BaseUI *);
|
||||
void NotifyVisiblity(BaseUI *);
|
||||
void DoBeginUpdate();
|
||||
void DoEndUpdate();
|
||||
void DoUpdateMessage(char *);
|
||||
void CreateContainer(MotifUI *,char *, char *, ContainerType, SelectionType);
|
||||
|
||||
public:
|
||||
|
||||
Container(MotifUI *parent,
|
||||
char *name,
|
||||
ContainerType container_type = SCROLLED_WORK_AREA,
|
||||
SelectionType select_type = SINGLE_SELECT);
|
||||
|
||||
Container(char *category,
|
||||
MotifUI *parent,
|
||||
char *name,
|
||||
ContainerType container_type = SCROLLED_WORK_AREA,
|
||||
SelectionType select_type = SINGLE_SELECT);
|
||||
|
||||
void OpenAnimation(MotifUI *obj);
|
||||
void SelectionPolicy(SelectionType);
|
||||
const SelectionType SelectionPolicy() { return _select_type; }
|
||||
const Widget InnerWidget() { return _workArea; }
|
||||
|
||||
const UI_Class UIClass() { return CONTAINER; }
|
||||
const int UISubClass() { return _container_type; }
|
||||
|
||||
const char *const UIClassName() { return "Container"; }
|
||||
};
|
||||
|
||||
#endif /* CONTAINER_H */
|
||||
240
cde/programs/dtprintinfo/libUI/MotifUI/Debug.c
Normal file
240
cde/programs/dtprintinfo/libUI/MotifUI/Debug.c
Normal file
@@ -0,0 +1,240 @@
|
||||
/* $TOG: Debug.c /main/5 1998/04/06 13:32:19 mgreess $ */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/Xlibint.h>
|
||||
|
||||
#define INT_MESSAGE3 "XIO: fatal IO error %d (%s) on X server \"%s\"\r\n"
|
||||
#define INT_MESSAGE4 " after %lu requests (%lu known processed) with %d events remaining.\r\n"
|
||||
#define INT_MESSAGE5 " The connection was probably broken by a server shudown or KillClient.\r\n"
|
||||
|
||||
static int PrintXError(Display *dpy, XErrorEvent *event, FILE *fp);
|
||||
static char *SysErrorMsg(int n);
|
||||
|
||||
/* Error Handlers */
|
||||
static int XIOError(Display *dpy);
|
||||
static int XError(Display *dpy, XErrorEvent *event);
|
||||
static void _XtError(String);
|
||||
|
||||
static Boolean G_DumpCore;
|
||||
|
||||
void
|
||||
Debug(
|
||||
XtAppContext app_context
|
||||
)
|
||||
{
|
||||
XSetErrorHandler(XError);
|
||||
XSetIOErrorHandler(XIOError);
|
||||
XtAppSetErrorHandler(app_context, _XtError);
|
||||
G_DumpCore = True;
|
||||
}
|
||||
|
||||
/*
|
||||
* NAME: XError
|
||||
* FUNCTION:
|
||||
* RETURNS:
|
||||
*/
|
||||
static int
|
||||
XError(
|
||||
Display *dpy,
|
||||
XErrorEvent *event
|
||||
)
|
||||
{
|
||||
if (PrintXError(dpy, event, stderr) == 0)
|
||||
return 0;
|
||||
if (G_DumpCore)
|
||||
kill(getpid(), SIGQUIT);
|
||||
else
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* NAME: XIOError
|
||||
* FUNCTION:
|
||||
* RETURNS:
|
||||
*/
|
||||
static int
|
||||
XIOError(
|
||||
Display *dpy
|
||||
)
|
||||
{
|
||||
fprintf(stderr, INT_MESSAGE3,
|
||||
errno, SysErrorMsg (errno), DisplayString (dpy));
|
||||
fprintf(stderr, INT_MESSAGE4,
|
||||
NextRequest(dpy) - 1, LastKnownRequestProcessed(dpy), QLength(dpy));
|
||||
|
||||
if (errno == EPIPE)
|
||||
fprintf(stderr, INT_MESSAGE5);
|
||||
if (G_DumpCore)
|
||||
kill(getpid(), SIGQUIT);
|
||||
else
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* NAME: SysErrorMsg
|
||||
* FUNCTION:
|
||||
* RETURNS:
|
||||
*/
|
||||
static char *
|
||||
SysErrorMsg(
|
||||
int n
|
||||
)
|
||||
{
|
||||
#if !defined(linux)
|
||||
extern char *sys_errlist[];
|
||||
extern int sys_nerr;
|
||||
#endif
|
||||
char *s = ((n >= 0 && n < sys_nerr) ? sys_errlist[n] : "unknown error");
|
||||
return (s ? s : "no such error");
|
||||
}
|
||||
|
||||
/*
|
||||
* NAME: PrintXError
|
||||
* FUNCTION:
|
||||
* RETURNS:
|
||||
*/
|
||||
static int
|
||||
PrintXError(
|
||||
Display *dpy,
|
||||
XErrorEvent *event,
|
||||
FILE *fp
|
||||
)
|
||||
{
|
||||
char buffer[BUFSIZ];
|
||||
char mesg[BUFSIZ];
|
||||
char number[32];
|
||||
char *mtype = "XlibMessage";
|
||||
register _XExtension *ext = (_XExtension *)NULL;
|
||||
_XExtension *bext = (_XExtension *)NULL;
|
||||
XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
|
||||
XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
|
||||
fprintf(fp, "%s: %s\n ", mesg, buffer);
|
||||
XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
|
||||
mesg, BUFSIZ);
|
||||
fprintf(fp, mesg, event->request_code);
|
||||
if (event->request_code < 128)
|
||||
{
|
||||
sprintf(number, "%d", event->request_code);
|
||||
XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (ext = dpy->ext_procs;
|
||||
ext && (ext->codes.major_opcode != event->request_code);
|
||||
ext = ext->next)
|
||||
;
|
||||
if (ext)
|
||||
strcpy(buffer, ext->name);
|
||||
else
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
fprintf(fp, " (%s)\n", buffer);
|
||||
if (event->request_code >= 128)
|
||||
{
|
||||
XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
|
||||
mesg, BUFSIZ);
|
||||
fputs(" ", fp);
|
||||
fprintf(fp, mesg, event->minor_code);
|
||||
if (ext)
|
||||
{
|
||||
sprintf(mesg, "%s.%d", ext->name, event->minor_code);
|
||||
XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
|
||||
fprintf(fp, " (%s)", buffer);
|
||||
}
|
||||
fputs("\n", fp);
|
||||
}
|
||||
if (event->error_code >= 128)
|
||||
{
|
||||
/* kludge, try to find the extension that caused it */
|
||||
buffer[0] = '\0';
|
||||
for (ext = dpy->ext_procs; ext; ext = ext->next)
|
||||
{
|
||||
if (ext->error_string)
|
||||
(*ext->error_string)(dpy, event->error_code, &ext->codes,
|
||||
buffer, BUFSIZ);
|
||||
if (buffer[0])
|
||||
{
|
||||
bext = ext;
|
||||
break;
|
||||
}
|
||||
if (ext->codes.first_error &&
|
||||
ext->codes.first_error < (int)event->error_code &&
|
||||
(!bext || ext->codes.first_error > bext->codes.first_error))
|
||||
bext = ext;
|
||||
}
|
||||
if (bext)
|
||||
sprintf(buffer, "%s.%d", bext->name,
|
||||
event->error_code - bext->codes.first_error);
|
||||
else
|
||||
strcpy(buffer, "Value");
|
||||
XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
|
||||
if (mesg[0])
|
||||
{
|
||||
fputs(" ", fp);
|
||||
fprintf(fp, mesg, event->resourceid);
|
||||
fputs("\n", fp);
|
||||
}
|
||||
/* let extensions try to print the values */
|
||||
for (ext = dpy->ext_procs; ext; ext = ext->next)
|
||||
{
|
||||
if (ext->error_values)
|
||||
(*ext->error_values)(dpy, event, fp);
|
||||
}
|
||||
}
|
||||
else if ((event->error_code == BadWindow) ||
|
||||
(event->error_code == BadPixmap) ||
|
||||
(event->error_code == BadCursor) ||
|
||||
(event->error_code == BadFont) ||
|
||||
(event->error_code == BadDrawable) ||
|
||||
(event->error_code == BadColor) ||
|
||||
(event->error_code == BadGC) ||
|
||||
(event->error_code == BadIDChoice) ||
|
||||
(event->error_code == BadValue) ||
|
||||
(event->error_code == BadAtom))
|
||||
{
|
||||
if (event->error_code == BadValue)
|
||||
XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%lx",
|
||||
mesg, BUFSIZ);
|
||||
else if (event->error_code == BadAtom)
|
||||
XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%lx",
|
||||
mesg, BUFSIZ);
|
||||
else
|
||||
XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%lx",
|
||||
mesg, BUFSIZ);
|
||||
fputs(" ", fp);
|
||||
fprintf(fp, mesg, event->resourceid);
|
||||
fputs("\n", fp);
|
||||
}
|
||||
XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%ld",
|
||||
mesg, BUFSIZ);
|
||||
fputs(" ", fp);
|
||||
fprintf(fp, mesg, event->serial);
|
||||
XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%ld",
|
||||
mesg, BUFSIZ);
|
||||
fputs("\n ", fp);
|
||||
fprintf(fp, mesg, dpy->request);
|
||||
fputs("\n", fp);
|
||||
if (event->error_code == BadImplementation)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* NAME: XtError
|
||||
* FUNCTION:
|
||||
* RETURNS:
|
||||
*/
|
||||
static void
|
||||
_XtError(
|
||||
String string
|
||||
)
|
||||
{
|
||||
(void)fprintf(stderr, "XtToolkit Error: %s\n", string);
|
||||
if (G_DumpCore)
|
||||
kill(getpid(), SIGQUIT);
|
||||
else
|
||||
exit(1);
|
||||
}
|
||||
550
cde/programs/dtprintinfo/libUI/MotifUI/Dialog.C
Normal file
550
cde/programs/dtprintinfo/libUI/MotifUI/Dialog.C
Normal file
@@ -0,0 +1,550 @@
|
||||
/* $XConsortium: Dialog.C /main/3 1996/01/19 15:09:18 lehors $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "Dialog.h"
|
||||
#include "Prompt.h"
|
||||
#include "Button.h"
|
||||
|
||||
#include <Xm/MessageB.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/PushB.h>
|
||||
#include <Xm/FileSB.h>
|
||||
#include <Xm/AtomMgr.h>
|
||||
#include <Xm/Protocols.h>
|
||||
#include <Xm/MwmUtil.h>
|
||||
|
||||
#include <Xm/BulletinBP.h>
|
||||
|
||||
// Constructor for a generic dialog
|
||||
Dialog::Dialog(MotifUI *parent, char *title, DialogType dialog_type,
|
||||
boolean has_resize_controls, DialogCallback help_callback,
|
||||
void * help_callback_data, DialogCallback apply_callback,
|
||||
void * apply_callback_data, DialogCallback reset_callback,
|
||||
void * reset_callback_data, ValidationCallback CB,
|
||||
void * validation_data)
|
||||
: MotifUI(parent, title, NULL)
|
||||
{
|
||||
Arg args[10];
|
||||
int n;
|
||||
XmString xm_string = StringCreate(title);
|
||||
|
||||
_validation_callback = CB;
|
||||
_validation_callback_data = validation_data;
|
||||
_help_callback = help_callback;
|
||||
_help_callback_data = help_callback_data;
|
||||
_apply_callback = apply_callback;
|
||||
_apply_callback_data = apply_callback_data;
|
||||
_reset_callback = reset_callback;
|
||||
_reset_callback_data = reset_callback_data;
|
||||
_cancel_button = NULL;
|
||||
_cancel_widget = NULL;
|
||||
|
||||
n = 0;
|
||||
if (has_resize_controls == false)
|
||||
{
|
||||
long mwmDecorations;
|
||||
mwmDecorations = (MWM_DECOR_BORDER | MWM_DECOR_TITLE | MWM_DECOR_MENU);
|
||||
XtSetArg(args[n], XmNmwmDecorations, mwmDecorations); n++;
|
||||
}
|
||||
XtSetArg(args[n], XmNdialogTitle, xm_string); n++;
|
||||
XtSetArg(args[n], XmNmarginHeight, 5); n++;
|
||||
XtSetArg(args[n], XmNmarginWidth, 5); n++;
|
||||
XtSetArg(args[n], XmNallowShellResize, true); n++;
|
||||
XtSetArg(args[n], XmNautoUnmanage, false); n++;
|
||||
switch (_dialog_type = dialog_type)
|
||||
{
|
||||
default:
|
||||
case MODELESS:
|
||||
case INFORMATION:
|
||||
case ERROR:
|
||||
case WORK_IN_PROGRESS:
|
||||
XtSetArg(args[n], XmNdialogStyle, XmDIALOG_MODELESS); n++;
|
||||
_dialog_type = MODELESS;
|
||||
break;
|
||||
case MODAL:
|
||||
case FILE_SELECTION:
|
||||
case QUESTION:
|
||||
case WARNING:
|
||||
case PROMPT_DIALOG:
|
||||
case MODAL_WORK_IN_PROGRESS:
|
||||
case MODAL_ERROR:
|
||||
case MODAL_INFORMATION:
|
||||
XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
|
||||
_dialog_type = MODAL;
|
||||
break;
|
||||
};
|
||||
|
||||
if (parent->UIClass() == APPLICATION)
|
||||
{
|
||||
XtSetArg(args[n], XmNdialogType, XmDIALOG_TEMPLATE); n++;
|
||||
_w = XmCreateMessageBox(parent->InnerWidget(), title, args, n);
|
||||
XtManageChild(_w);
|
||||
}
|
||||
else
|
||||
_w = XmCreateTemplateDialog(parent->InnerWidget(), title, args, n);
|
||||
|
||||
_clientArea = XtVaCreateManagedWidget("form", xmFormWidgetClass, _w, NULL);
|
||||
|
||||
StringFree(xm_string);
|
||||
XmAddWMProtocolCallback(XtParent(_w),
|
||||
XmInternAtom(display, "WM_DELETE_WINDOW", False),
|
||||
&Dialog::CloseCB, (XtPointer) this);
|
||||
InstallHelpCB();
|
||||
}
|
||||
|
||||
// Constructor for info, error, work-in-progress
|
||||
Dialog::Dialog(MotifUI *parent, char *title, char *message,
|
||||
DialogType dialog_type, char *ok_label, char *cancel_label,
|
||||
char *help_label, DialogCallback help,
|
||||
void * help_callback_data, char * /*icon*/)
|
||||
: MotifUI(parent, title, NULL)
|
||||
{
|
||||
Arg args[15];
|
||||
long mwmDecorations;
|
||||
mwmDecorations = (MWM_DECOR_BORDER | MWM_DECOR_TITLE | MWM_DECOR_MENU);
|
||||
|
||||
XmString xm_string = StringCreate(title);
|
||||
XmString xm_message = StringCreate(message);
|
||||
XmString ok_string = StringCreate(ok_label);
|
||||
XmString cancel_string = StringCreate(cancel_label);
|
||||
XmString help_string = StringCreate(help_label);
|
||||
|
||||
XtSetArg(args[0], XmNdialogTitle, xm_string);
|
||||
XtSetArg(args[1], XmNmarginHeight, 5);
|
||||
XtSetArg(args[2], XmNmarginWidth, 5);
|
||||
XtSetArg(args[3], XmNallowShellResize, true);
|
||||
XtSetArg(args[4], XmNautoUnmanage, false);
|
||||
XtSetArg(args[5], XmNmessageString, xm_message);
|
||||
XtSetArg(args[6], XmNmwmDecorations, mwmDecorations);
|
||||
XtSetArg(args[7], XmNokLabelString, ok_string);
|
||||
XtSetArg(args[8], XmNcancelLabelString, cancel_string);
|
||||
XtSetArg(args[9], XmNhelpLabelString, help_string);
|
||||
_help_callback = help;
|
||||
_help_callback_data = help_callback_data;
|
||||
_apply_callback = NULL;
|
||||
_apply_callback_data = NULL;
|
||||
_reset_callback = NULL;
|
||||
_reset_callback_data = NULL;
|
||||
switch (_dialog_type = dialog_type)
|
||||
{
|
||||
case INFORMATION:
|
||||
XtSetArg(args[10], XmNdialogStyle, XmDIALOG_MODELESS);
|
||||
_w = XmCreateInformationDialog(parent->InnerWidget(), title, args, 11);
|
||||
break;
|
||||
|
||||
case QUESTION:
|
||||
XtSetArg(args[10], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);
|
||||
_w = XmCreateQuestionDialog(parent->InnerWidget(), title, args, 11);
|
||||
break;
|
||||
case WARNING:
|
||||
XtSetArg(args[10], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);
|
||||
_w = XmCreateWarningDialog(parent->InnerWidget(), title, args, 11);
|
||||
break;
|
||||
|
||||
case ERROR:
|
||||
XtSetArg(args[10], XmNdialogStyle, XmDIALOG_MODELESS);
|
||||
_w = XmCreateErrorDialog(parent->InnerWidget(), title, args, 11);
|
||||
break;
|
||||
|
||||
case WORK_IN_PROGRESS:
|
||||
mwmDecorations = (MWM_DECOR_BORDER | MWM_DECOR_TITLE);
|
||||
XtSetArg(args[6], XmNmwmDecorations, mwmDecorations);
|
||||
XtSetArg(args[10], XmNdialogStyle, XmDIALOG_MODELESS);
|
||||
_w = XmCreateWorkingDialog(parent->InnerWidget(), title, args, 11);
|
||||
break;
|
||||
|
||||
case MODAL_WORK_IN_PROGRESS:
|
||||
mwmDecorations = (MWM_DECOR_BORDER | MWM_DECOR_TITLE);
|
||||
XtSetArg(args[6], XmNmwmDecorations, mwmDecorations);
|
||||
XtSetArg(args[10], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);
|
||||
_w = XmCreateWorkingDialog(parent->InnerWidget(), title, args, 11);
|
||||
break;
|
||||
|
||||
case MODAL_ERROR:
|
||||
XtSetArg(args[10], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);
|
||||
_w = XmCreateErrorDialog(parent->InnerWidget(), title, args, 11);
|
||||
break;
|
||||
|
||||
case MODAL_INFORMATION:
|
||||
XtSetArg(args[10], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);
|
||||
_w = XmCreateInformationDialog(parent->InnerWidget(), title, args, 11);
|
||||
break;
|
||||
|
||||
case MODAL:
|
||||
XtSetArg(args[10], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);
|
||||
_w = XmCreateMessageDialog(parent->InnerWidget(), title, args, 11);
|
||||
break;
|
||||
|
||||
default:
|
||||
_dialog_type = MODELESS;
|
||||
XtSetArg(args[10], XmNdialogStyle, XmDIALOG_MODELESS);
|
||||
_w = XmCreateMessageDialog(parent->InnerWidget(), title, args, 11);
|
||||
break;
|
||||
}
|
||||
|
||||
if (_dialog_type == QUESTION || _dialog_type == WARNING)
|
||||
XtAddCallback(_w, XmNcancelCallback, &Dialog::DialogCB, (XtPointer) this);
|
||||
else
|
||||
XtUnmanageChild(XmMessageBoxGetChild(_w, XmDIALOG_CANCEL_BUTTON));
|
||||
if (help)
|
||||
XtAddCallback(_w, XmNhelpCallback, &Dialog::DialogCB, (XtPointer) this);
|
||||
else
|
||||
XtUnmanageChild(XmMessageBoxGetChild(_w, XmDIALOG_HELP_BUTTON));
|
||||
if (_dialog_type == WORK_IN_PROGRESS ||
|
||||
_dialog_type == MODAL_WORK_IN_PROGRESS)
|
||||
XtUnmanageChild(XmMessageBoxGetChild(_w, XmDIALOG_OK_BUTTON));
|
||||
else
|
||||
XtAddCallback(_w, XmNokCallback, &Dialog::DialogCB, (XtPointer) this);
|
||||
XmAddWMProtocolCallback(XtParent(_w),
|
||||
XmInternAtom(display, "WM_DELETE_WINDOW", False),
|
||||
&Dialog::CloseCB, (XtPointer) this);
|
||||
InstallHelpCB();
|
||||
StringFree(xm_string);
|
||||
StringFree(xm_message);
|
||||
StringFree(cancel_string);
|
||||
StringFree(ok_string);
|
||||
StringFree(help_string);
|
||||
_clientArea = _w;
|
||||
}
|
||||
|
||||
// Constructor for prompt
|
||||
Dialog::Dialog(MotifUI *parent, char *title, char *caption, boolean editable,
|
||||
PromptType prompt_type, char *default_value,
|
||||
boolean echo_input, ValidationCallback validation_callback,
|
||||
void * validation_callback_data, DialogCallback help_callback,
|
||||
void * help_callback_data, DialogCallback apply_callback,
|
||||
void * apply_callback_data, DialogCallback reset_callback,
|
||||
void * reset_callback_data, char *message, char *icon)
|
||||
: MotifUI(parent, title, NULL)
|
||||
{
|
||||
Arg args[8];
|
||||
int n;
|
||||
XmString xm_string = StringCreate(title);
|
||||
XmString xm_message;
|
||||
Pixmap pixmap;
|
||||
|
||||
_dialog_type = PROMPT_DIALOG;
|
||||
_validation_callback = validation_callback;
|
||||
_validation_callback_data = validation_callback_data;
|
||||
_help_callback = help_callback;
|
||||
_help_callback_data = help_callback_data;
|
||||
_apply_callback = apply_callback;
|
||||
_apply_callback_data = apply_callback_data;
|
||||
_reset_callback = reset_callback;
|
||||
_reset_callback_data = reset_callback_data;
|
||||
n = 0;
|
||||
XtSetArg(args[n], XmNdialogTitle, xm_string); n++;
|
||||
XtSetArg(args[n], XmNmarginHeight, 5); n++;
|
||||
XtSetArg(args[n], XmNmarginWidth, 5); n++;
|
||||
XtSetArg(args[n], XmNallowShellResize, true); n++;
|
||||
XtSetArg(args[n], XmNautoUnmanage, false); n++;
|
||||
XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
|
||||
if (message && *message)
|
||||
{
|
||||
xm_message = StringCreate(message);
|
||||
XtSetArg(args[n], XmNmessageString, xm_message); n++;
|
||||
if (icon && *icon)
|
||||
{
|
||||
pixmap = 0;
|
||||
// XtSetArg(args[n], XmNsymbolPixmap, pixmap); n++;
|
||||
}
|
||||
}
|
||||
|
||||
_w = XmCreateMessageDialog(parent->InnerWidget(), title, args, n);
|
||||
StringFree(xm_string);
|
||||
if (xm_message && *message)
|
||||
StringFree(xm_message);
|
||||
if (help_callback)
|
||||
{
|
||||
XtAddCallback(_w, XmNhelpCallback, &Dialog::DialogCB, (XtPointer) this);
|
||||
}
|
||||
else
|
||||
{
|
||||
XtUnmanageChild(XmMessageBoxGetChild(_w, XmDIALOG_HELP_BUTTON));
|
||||
}
|
||||
_prompt = new Prompt(this, caption, editable, prompt_type, default_value,
|
||||
validation_callback, validation_callback_data,
|
||||
echo_input);
|
||||
XmAddWMProtocolCallback(XtParent(_w),
|
||||
XmInternAtom(display, "WM_DELETE_WINDOW", False),
|
||||
&Dialog::CloseCB, (XtPointer) this);
|
||||
InstallHelpCB();
|
||||
}
|
||||
|
||||
// Constructor for file selection
|
||||
Dialog::Dialog(MotifUI *parent, char *title, char *base_directory,
|
||||
char *search_pattern, DialogType dialog_type,
|
||||
DialogCallback help, void * /*help_callback_data*/)
|
||||
: MotifUI(parent, title, NULL)
|
||||
{
|
||||
Arg args[9];
|
||||
XmString title_string = StringCreate(title);
|
||||
XmString directory_string = StringCreate(base_directory);
|
||||
XmString pattern_string = StringCreate(search_pattern);
|
||||
|
||||
XtSetArg(args[0], XmNdialogTitle, title_string);
|
||||
XtSetArg(args[1], XmNmarginHeight, 5);
|
||||
XtSetArg(args[2], XmNmarginWidth, 5);
|
||||
XtSetArg(args[3], XmNallowShellResize, true);
|
||||
XtSetArg(args[4], XmNautoUnmanage, false);
|
||||
XtSetArg(args[5], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);
|
||||
switch (_dialog_type = dialog_type)
|
||||
{
|
||||
default:
|
||||
case FILE_SELECTION:
|
||||
_dialog_type = FILE_SELECTION;
|
||||
XtSetArg(args[6], XmNfileTypeMask, XmFILE_REGULAR);
|
||||
break;
|
||||
case DIRECTORY_SELECTION:
|
||||
XtSetArg(args[6], XmNfileTypeMask, XmFILE_DIRECTORY);
|
||||
break;
|
||||
case FILE_DIRECTORY_SELECTION:
|
||||
XtSetArg(args[6], XmNfileTypeMask, XmFILE_ANY_TYPE);
|
||||
break;
|
||||
}
|
||||
XtSetArg(args[7], XmNdirectory, directory_string);
|
||||
XtSetArg(args[8], XmNpattern, pattern_string);
|
||||
|
||||
_w = XmCreateFileSelectionDialog(parent->InnerWidget(), title, args, 9);
|
||||
StringFree(title_string);
|
||||
StringFree(directory_string);
|
||||
StringFree(pattern_string);
|
||||
if (help)
|
||||
{
|
||||
_help_callback_data = _help_callback_data;
|
||||
XtAddCallback(_w, XmNhelpCallback, &Dialog::DialogCB, (XtPointer) this);
|
||||
}
|
||||
else
|
||||
{
|
||||
XtUnmanageChild(XmMessageBoxGetChild(_w, XmDIALOG_HELP_BUTTON));
|
||||
}
|
||||
XmAddWMProtocolCallback(XtParent(_w),
|
||||
XmInternAtom(display, "WM_DELETE_WINDOW", False),
|
||||
&Dialog::CloseCB, (XtPointer) this);
|
||||
InstallHelpCB();
|
||||
}
|
||||
|
||||
Dialog::~Dialog()
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
|
||||
void Dialog::DefaultButton(MotifUI *button)
|
||||
{
|
||||
XtVaSetValues(_w, XmNdefaultButton, button->BaseWidget(), NULL);
|
||||
}
|
||||
|
||||
void Dialog::CancelButtonCB(Widget, XtPointer client_data, XtPointer)
|
||||
{
|
||||
Dialog *obj = (Dialog *)client_data;
|
||||
if (obj->_cancel_button)
|
||||
{
|
||||
XtCallCallbacks(obj->_cancel_button->BaseWidget(), XmNactivateCallback,
|
||||
obj->_cancel_button);
|
||||
}
|
||||
}
|
||||
|
||||
void Dialog::CancelButton(MotifUI *button)
|
||||
{
|
||||
if (!_cancel_widget)
|
||||
{
|
||||
_cancel_widget = XtVaCreateWidget("cancel_button",
|
||||
xmPushButtonWidgetClass, _w, NULL);
|
||||
XtAddCallback(_cancel_widget, XmNactivateCallback, CancelButtonCB, this);
|
||||
BB_CancelButton(_w) = _cancel_widget;
|
||||
}
|
||||
_cancel_button = (Button *)button;
|
||||
}
|
||||
|
||||
void Dialog::Width(int w)
|
||||
{
|
||||
XtVaSetValues(XtParent(_w), XmNallowShellResize, true, NULL);
|
||||
MotifUI::Width(w);
|
||||
XtVaSetValues(XtParent(_w), XmNallowShellResize, false, NULL);
|
||||
}
|
||||
|
||||
void Dialog::Height(int w)
|
||||
{
|
||||
XtVaSetValues(XtParent(_w), XmNallowShellResize, true, NULL);
|
||||
MotifUI::Height(w);
|
||||
XtVaSetValues(XtParent(_w), XmNallowShellResize, false, NULL);
|
||||
}
|
||||
|
||||
void Dialog::WidthHeight(int w, int h)
|
||||
{
|
||||
XtVaSetValues(XtParent(_w), XmNallowShellResize, true, NULL);
|
||||
MotifUI::WidthHeight(w, h);
|
||||
XtVaSetValues(XtParent(_w), XmNallowShellResize, false, NULL);
|
||||
}
|
||||
|
||||
boolean Dialog::SetName(char *name)
|
||||
{
|
||||
XmString xm_message = StringCreate(name);
|
||||
XtVaSetValues(_w, XmNmessageString, xm_message, NULL);
|
||||
StringFree(xm_message);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean Dialog::SetVisiblity(boolean flag)
|
||||
{
|
||||
MotifUI::SetVisiblity(flag);
|
||||
if (flag == false)
|
||||
return true;
|
||||
|
||||
boolean is_modal;
|
||||
switch (_dialog_type)
|
||||
{
|
||||
case MODELESS:
|
||||
case INFORMATION:
|
||||
case ERROR:
|
||||
case WORK_IN_PROGRESS:
|
||||
is_modal = false;
|
||||
break;
|
||||
default:
|
||||
is_modal = true;
|
||||
}
|
||||
|
||||
ToFront();
|
||||
XtVaSetValues(XtParent(_w), XmNallowShellResize, False, NULL);
|
||||
if (is_modal)
|
||||
{
|
||||
_status = -1;
|
||||
while (_status == -1 || XtAppPending(appContext))
|
||||
XtAppProcessEvent(appContext, XtIMAll);
|
||||
if (_status)
|
||||
_rc = true;
|
||||
else
|
||||
_rc = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const boolean Dialog::Answer(char **string)
|
||||
{
|
||||
if (_rc)
|
||||
{
|
||||
if (_dialog_type == PROMPT_DIALOG ||
|
||||
_dialog_type == FILE_SELECTION ||
|
||||
_dialog_type == DIRECTORY_SELECTION ||
|
||||
_dialog_type == FILE_DIRECTORY_SELECTION)
|
||||
{
|
||||
*string = STRDUP(_string);
|
||||
}
|
||||
}
|
||||
else
|
||||
*string = NULL;
|
||||
|
||||
return _rc;
|
||||
}
|
||||
|
||||
void Dialog::OK()
|
||||
{
|
||||
if (Apply() == true)
|
||||
{
|
||||
Visible(false);
|
||||
_rc = true;
|
||||
_status = 1;
|
||||
}
|
||||
if (_dialog_type != PROMPT_DIALOG &&
|
||||
_dialog_type != QUESTION &&
|
||||
_dialog_type != WARNING)
|
||||
delete this;
|
||||
}
|
||||
|
||||
void Dialog::Cancel()
|
||||
{
|
||||
Reset();
|
||||
Visible(false);
|
||||
_rc = false;
|
||||
_status = 0;
|
||||
if (_dialog_type != PROMPT_DIALOG &&
|
||||
_dialog_type != QUESTION &&
|
||||
_dialog_type != WARNING)
|
||||
delete this;
|
||||
}
|
||||
|
||||
boolean Dialog::Apply()
|
||||
{
|
||||
boolean rc = true;
|
||||
|
||||
if (_dialog_type == PROMPT_DIALOG)
|
||||
{
|
||||
_string = _prompt->Value();
|
||||
if (_validation_callback)
|
||||
rc = (*_validation_callback)(_validation_callback_data, _string);
|
||||
else
|
||||
rc = true;
|
||||
if (rc == true)
|
||||
{
|
||||
if (_apply_callback)
|
||||
(*_apply_callback)(_apply_callback_data);
|
||||
_prompt->DefaultValue(_string);
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
void Dialog::Reset()
|
||||
{
|
||||
if (_reset_callback)
|
||||
(*_reset_callback)(_reset_callback_data);
|
||||
if (_dialog_type == PROMPT_DIALOG)
|
||||
_prompt->Reset();
|
||||
}
|
||||
|
||||
void Dialog::Help()
|
||||
{
|
||||
if (_help_callback)
|
||||
(*_help_callback)(_help_callback_data);
|
||||
}
|
||||
|
||||
void Dialog::CloseCB()
|
||||
{
|
||||
Cancel();
|
||||
}
|
||||
|
||||
void Dialog::CloseCB(Widget, XtPointer client_data, XtPointer /*call_data*/)
|
||||
{
|
||||
Dialog *dialog = (Dialog *) client_data;
|
||||
dialog->CloseCB();
|
||||
}
|
||||
|
||||
void Dialog::DialogCB(Widget, XtPointer client_data, XtPointer call_data)
|
||||
{
|
||||
XmFileSelectionBoxCallbackStruct *cb;
|
||||
Dialog *dialog = (Dialog *) client_data;
|
||||
|
||||
cb = (XmFileSelectionBoxCallbackStruct *) call_data;
|
||||
switch (cb->reason)
|
||||
{
|
||||
case XmCR_HELP: dialog->Help(); break;
|
||||
case XmCR_OK:
|
||||
if (dialog->_dialog_type == FILE_SELECTION ||
|
||||
dialog->_dialog_type == DIRECTORY_SELECTION ||
|
||||
dialog->_dialog_type == FILE_DIRECTORY_SELECTION)
|
||||
dialog->_string = dialog->StringExtract(cb->value);
|
||||
dialog->OK();
|
||||
break;
|
||||
case XmCR_CANCEL: dialog->Cancel(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void Dialog::ResetCB(void *data)
|
||||
{
|
||||
Dialog *dialog = (Dialog *) data;
|
||||
|
||||
dialog->Reset();
|
||||
}
|
||||
|
||||
void Dialog::ApplyCB(void *data)
|
||||
{
|
||||
Dialog *dialog = (Dialog *) data;
|
||||
|
||||
dialog->Apply();
|
||||
}
|
||||
141
cde/programs/dtprintinfo/libUI/MotifUI/Dialog.h
Normal file
141
cde/programs/dtprintinfo/libUI/MotifUI/Dialog.h
Normal file
@@ -0,0 +1,141 @@
|
||||
/* $XConsortium: Dialog.h /main/3 1995/11/06 09:40:07 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef DIALOG_H
|
||||
#define DIALOG_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
class Button;
|
||||
class Prompt;
|
||||
|
||||
class Dialog : public MotifUI {
|
||||
|
||||
friend void DialogCB(Widget, XtPointer, XtPointer);
|
||||
friend void CloseCB(Widget, XtPointer, XtPointer);
|
||||
friend void CancelButtonCB(Widget, XtPointer, XtPointer);
|
||||
friend void ResetCB(void *);
|
||||
friend void ApplyCB(void *);
|
||||
|
||||
private:
|
||||
|
||||
Widget _clientArea;
|
||||
Widget _cancel_widget;
|
||||
DialogType _dialog_type;
|
||||
boolean _rc;
|
||||
char *_string;
|
||||
Prompt *_prompt;
|
||||
Button *_reset_button;
|
||||
Button *_apply_button;
|
||||
Button *_cancel_button;
|
||||
void * _cancel_callback_data;
|
||||
void * _help_callback_data;
|
||||
void * _reset_callback_data;
|
||||
void * _apply_callback_data;
|
||||
void * _validation_callback_data;
|
||||
DialogCallback _cancel_callback;
|
||||
DialogCallback _help_callback;
|
||||
DialogCallback _reset_callback;
|
||||
DialogCallback _apply_callback;
|
||||
ValidationCallback _validation_callback;
|
||||
|
||||
static void DialogCB(Widget, XtPointer, XtPointer);
|
||||
static void CloseCB(Widget, XtPointer, XtPointer);
|
||||
static void CancelButtonCB(Widget, XtPointer, XtPointer);
|
||||
static void ResetCB(void *);
|
||||
static void ApplyCB(void *);
|
||||
|
||||
int _status;
|
||||
|
||||
void OK();
|
||||
void Cancel();
|
||||
void Reset();
|
||||
boolean Apply();
|
||||
void Help();
|
||||
|
||||
protected:
|
||||
|
||||
virtual boolean SetVisiblity(boolean);
|
||||
boolean SetName(char *);
|
||||
void Width(int w);
|
||||
int Width() { return MotifUI::Width(); }
|
||||
void Height(int h);
|
||||
int Height() { return MotifUI::Height(); }
|
||||
void WidthHeight(int w, int h);
|
||||
void WidthHeight(int *w, int *h) { MotifUI::WidthHeight(w, h); }
|
||||
const Widget InnerWidget() { return _clientArea; }
|
||||
|
||||
public:
|
||||
|
||||
// Constructor for a generic MODELESS or MODAL dialog
|
||||
Dialog(MotifUI *parent,
|
||||
char *name,
|
||||
DialogType dialog_type = MODELESS,
|
||||
boolean has_resize_controls = true,
|
||||
DialogCallback cancel_callback = NULL,
|
||||
void * help_callback_data = NULL,
|
||||
DialogCallback apply_callback = NULL,
|
||||
void * apply_callback_data = NULL,
|
||||
DialogCallback reset_callback = NULL,
|
||||
void * reset_callback_data = NULL,
|
||||
ValidationCallback CB = NULL,
|
||||
void * validation_data = NULL);
|
||||
|
||||
// Constructor for info, error, work-in-progress, question, warning
|
||||
Dialog(MotifUI *parent,
|
||||
char *title,
|
||||
char *message,
|
||||
DialogType dialog_type = INFORMATION,
|
||||
char *ok_label = "OK",
|
||||
char *cancel_label = "Cancel",
|
||||
char *help_label = "Help",
|
||||
DialogCallback helpCB = NULL, // If NULL, no help button is created
|
||||
void *help_data = NULL,
|
||||
char *icon = NULL); // If NULL, use default icon
|
||||
|
||||
// Constructor for prompt
|
||||
Dialog(MotifUI *parent,
|
||||
char *title,
|
||||
char *caption, // This appears left of a input field
|
||||
boolean editable,
|
||||
PromptType prompt_type,
|
||||
char *default_value, // If NULL, no reset button is created
|
||||
boolean echo_input = true,
|
||||
ValidationCallback CB = NULL,
|
||||
void * validation_data = NULL,
|
||||
DialogCallback helpCB = NULL, // If NULL, no help button is created
|
||||
void * help_data = NULL,
|
||||
DialogCallback applyCB = NULL,
|
||||
void * apply_data = NULL,
|
||||
DialogCallback resetCB = NULL,
|
||||
void * reset_data = NULL,
|
||||
char *message = NULL, // The message above the input field
|
||||
char *icon = NULL); // If NULL, no icon will be shown
|
||||
|
||||
// Constructor for file and directory selection
|
||||
Dialog(MotifUI *parent,
|
||||
char *title,
|
||||
char *base_directory,
|
||||
char *search_pattern,
|
||||
DialogType dialog_type = FILE_SELECTION,
|
||||
DialogCallback help = NULL, // If NULL, no help button is created
|
||||
void * help_data = NULL);
|
||||
virtual ~Dialog();
|
||||
|
||||
virtual void CloseCB();
|
||||
void DefaultButton(MotifUI *);
|
||||
void CancelButton(MotifUI *);
|
||||
const boolean Answer(char **string); // user must delete string
|
||||
const boolean Answer() { return _rc; }
|
||||
|
||||
const UI_Class UIClass() { return DIALOG; }
|
||||
const int UISubClass() { return _dialog_type; }
|
||||
const char *const UIClassName() { return "Dialog"; }
|
||||
};
|
||||
|
||||
#endif /* DIALOG_H */
|
||||
717
cde/programs/dtprintinfo/libUI/MotifUI/DtDND.C
Normal file
717
cde/programs/dtprintinfo/libUI/MotifUI/DtDND.C
Normal file
@@ -0,0 +1,717 @@
|
||||
/* $TOG: DtDND.C /main/7 1998/08/03 08:58:53 mgreess $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "stdlib.h"
|
||||
|
||||
#include "DtDND.h"
|
||||
#include "IconObj.h"
|
||||
#include "Icon.h"
|
||||
#include "Dt/Dnd.h"
|
||||
#include <Xm/DragCP.h>
|
||||
#include <Dt/Wsm.h>
|
||||
#include <Dt/Action.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" {
|
||||
extern XtPointer _XmStringUngenerate (
|
||||
XmString string,
|
||||
XmStringTag tag,
|
||||
XmTextType tag_type,
|
||||
XmTextType output_type);
|
||||
}
|
||||
|
||||
#define DRAG_THRESHOLD 10
|
||||
|
||||
// Absolute value macro
|
||||
#ifndef ABS
|
||||
#define ABS(x) (((x) > 0) ? (x) : (-(x)))
|
||||
#endif
|
||||
|
||||
boolean DtDND::FirstTime = true;
|
||||
XtCallbackRec DtDND::transferCBRec[] =
|
||||
{
|
||||
{&DtDND::TransferCB, NULL}, {NULL, NULL}
|
||||
};
|
||||
XtCallbackRec DtDND::convertCBRec[] =
|
||||
{
|
||||
{&DtDND::ConvertCB, NULL}, {NULL, NULL}
|
||||
};
|
||||
XtCallbackRec DtDND::dragFinishCBRec[] =
|
||||
{
|
||||
{&DtDND::DragFinishCB, NULL}, {NULL, NULL}
|
||||
};
|
||||
XtCallbackRec DtDND::dropOnRootCBRec[] =
|
||||
{
|
||||
{&DtDND::DropOnRootCB, NULL}, {NULL, NULL}
|
||||
};
|
||||
XtCallbackRec DtDND::animateCBRec[] =
|
||||
{
|
||||
{&DtDND::AnimateCB, NULL}, {NULL, NULL}
|
||||
};
|
||||
boolean DtDND::DoingDrag = false;
|
||||
GC DtDND::gc;
|
||||
GC DtDND::gc_mask;
|
||||
|
||||
DtDND::DtDND(MotifUI *_obj, DNDCallback _dndCB, boolean _can_drop_on_root)
|
||||
{
|
||||
if (FirstTime)
|
||||
{
|
||||
MotifUI *tmp = (MotifUI *)_obj;
|
||||
Pixmap tmp_pixmap;
|
||||
BaseUI *parent = _obj;
|
||||
while (parent->Parent())
|
||||
parent = parent->Parent();
|
||||
tmp_pixmap = XCreatePixmap(tmp->display, tmp->root, 1, 1, tmp->depth);
|
||||
gc = XCreateGC(tmp->display, tmp_pixmap, 0, NULL);
|
||||
tmp_pixmap = XCreatePixmap(tmp->display, tmp->root, 1, 1, 1);
|
||||
gc_mask = XCreateGC(tmp->display, tmp_pixmap, 0, NULL);
|
||||
XSetFont(tmp->display, gc, tmp->font);
|
||||
FirstTime = false;
|
||||
}
|
||||
|
||||
obj = _obj;
|
||||
can_drop_on_root = _can_drop_on_root;
|
||||
dndCB = _dndCB;
|
||||
dragIcon = NULL;
|
||||
sourceIcon = NULL;
|
||||
|
||||
// Set up Drop
|
||||
transferCBRec[0].closure = (XtPointer)this;
|
||||
animateCBRec[0].closure = (XtPointer)this;
|
||||
if (obj->UIClass() == ICON)
|
||||
{
|
||||
GetRects();
|
||||
XtVaSetValues(obj->BaseWidget(), XmNshadowThickness, 2, NULL);
|
||||
Arg args[6];
|
||||
XtSetArg(args[0], XmNdropSiteType, XmDROP_SITE_SIMPLE);
|
||||
XtSetArg(args[1], XmNanimationStyle, XmDRAG_UNDER_SHADOW_IN);
|
||||
XtSetArg(args[2], XmNnumDropRectangles, 2);
|
||||
XtSetArg(args[3], XmNdropRectangles, &rects);
|
||||
XtSetArg(args[4], DtNdropAnimateCallback, animateCBRec);
|
||||
XtSetArg(args[5], DtNtextIsBuffer, True);
|
||||
DtDndDropRegister(obj->BaseWidget(), DtDND_FILENAME_TRANSFER|
|
||||
DtDND_BUFFER_TRANSFER,
|
||||
(unsigned char)XmDROP_COPY, transferCBRec, args, 6);
|
||||
|
||||
// Set up Drag on Button1
|
||||
XtAddEventHandler(obj->BaseWidget(), Button1MotionMask, False,
|
||||
(XtEventHandler)DragMotionHandler, (XtPointer)this);
|
||||
|
||||
// Set up Drag on Button2 if not using it for BMenu already
|
||||
if (MotifUI::bMenuButton != Button2)
|
||||
{
|
||||
XtAddEventHandler(obj->BaseWidget(), Button2MotionMask, False,
|
||||
(XtEventHandler)DragMotionHandler, (XtPointer)this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Arg args[2];
|
||||
XtSetArg(args[0], DtNdropAnimateCallback, animateCBRec);
|
||||
XtSetArg(args[1], DtNtextIsBuffer, True);
|
||||
DtDndDropRegister(obj->BaseWidget(), DtDND_FILENAME_TRANSFER|
|
||||
DtDND_BUFFER_TRANSFER,
|
||||
(unsigned char)XmDROP_COPY, transferCBRec, args, 2);
|
||||
}
|
||||
pixmap = 0L;
|
||||
mask = 0L;
|
||||
name = NULL;
|
||||
iconFile = NULL;
|
||||
string = NULL;
|
||||
}
|
||||
|
||||
DtDND::~DtDND()
|
||||
{
|
||||
MotifUI *icon = (MotifUI *)obj;
|
||||
if (pixmap && pixmap != XmUNSPECIFIED_PIXMAP)
|
||||
XFreePixmap(icon->display, pixmap);
|
||||
if (mask && mask != XmUNSPECIFIED_PIXMAP)
|
||||
XFreePixmap(icon->display, mask);
|
||||
free(name);
|
||||
delete iconFile;
|
||||
XmStringFree(string);
|
||||
if (sourceIcon)
|
||||
{
|
||||
XtDestroyWidget(sourceIcon);
|
||||
sourceIcon = NULL;
|
||||
}
|
||||
if (dragIcon)
|
||||
{
|
||||
XtDestroyWidget(dragIcon);
|
||||
dragIcon = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void DtDND::GetDragPixmaps()
|
||||
{
|
||||
IconObj *icon = (IconObj *)obj;
|
||||
Pixmap tmp_pixmap, tmp_mask;
|
||||
|
||||
delete iconFile;
|
||||
free(name);
|
||||
XmStringFree(string);
|
||||
if (pixmap && pixmap != XmUNSPECIFIED_PIXMAP)
|
||||
XFreePixmap(icon->display, pixmap);
|
||||
if (mask && mask != XmUNSPECIFIED_PIXMAP)
|
||||
XFreePixmap(icon->display, mask);
|
||||
mask = 0L;
|
||||
pixmap = 0L;
|
||||
name = strdup(icon->Name());
|
||||
icon_size = icon->IconView();
|
||||
selected = icon->Selected();
|
||||
iconFile = new char[strlen(icon->IconFile()) + 6];
|
||||
|
||||
Dimension height, width;
|
||||
unsigned int w, h, junk;
|
||||
|
||||
XtVaGetValues(icon->BaseWidget(), XmNbackground, &bg, XmNforeground, &fg,
|
||||
GuiNselectColor, &selectColor, XmNalignment, &alignment,
|
||||
GuiNshowSelectedPixmap, &showSelectedPixmap,
|
||||
XmNstringDirection, &stringDirection,
|
||||
GuiNtextSelectColor, &textSelectColor,
|
||||
XmNlabelString, &string, XmNfontList, &fontList, NULL);
|
||||
|
||||
XmStringExtent(fontList, string, &width, &height);
|
||||
if (icon_size == LARGE_ICON)
|
||||
string_border_width = 1;
|
||||
else
|
||||
string_border_width = 0;
|
||||
height += 2 * string_border_width;
|
||||
width += 2 * string_border_width;
|
||||
s_x = s_y = string_border_width;
|
||||
p_x = p_y = 0;
|
||||
s_w = width;
|
||||
s_h = height;
|
||||
p_w = p_h = 0;
|
||||
switch (icon_size)
|
||||
{
|
||||
case DETAILS:
|
||||
case SMALL_ICON:
|
||||
sprintf(iconFile, "%s.t.pm", icon->IconFile());
|
||||
icon->GetPixmaps(icon->BaseWidget(), iconFile, &tmp_pixmap, &tmp_mask);
|
||||
if (tmp_pixmap && tmp_pixmap != XmUNSPECIFIED_PIXMAP)
|
||||
{
|
||||
XGetGeometry(icon->display, tmp_pixmap, (Window *) &junk,
|
||||
(int *) &junk, (int *) &junk, &w, &h, &junk, &junk);
|
||||
p_w = w;
|
||||
p_h = h;
|
||||
w += 2;
|
||||
s_x += w;
|
||||
width += w;
|
||||
if (h > height)
|
||||
{
|
||||
s_y = (h - height) / 2;
|
||||
height = h;
|
||||
}
|
||||
else
|
||||
p_y = (height - h) / 2;
|
||||
}
|
||||
break;
|
||||
case LARGE_ICON:
|
||||
sprintf(iconFile, "%s.m.pm", icon->IconFile());
|
||||
icon->GetPixmaps(icon->BaseWidget(), iconFile, &tmp_pixmap, &tmp_mask);
|
||||
if (tmp_pixmap && tmp_pixmap != XmUNSPECIFIED_PIXMAP)
|
||||
{
|
||||
XGetGeometry(icon->display, tmp_pixmap, (Window *) &junk,
|
||||
(int *) &junk, (int *) &junk, &w, &h, &junk, &junk);
|
||||
p_w = w;
|
||||
p_h = h;
|
||||
h += 2;
|
||||
s_y += h;
|
||||
height += h;
|
||||
if (w > width)
|
||||
width = w;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sprintf(iconFile, "%s.m.pm", icon->IconFile());
|
||||
icon->GetPixmaps(icon->BaseWidget(), iconFile, &tmp_pixmap, &tmp_mask);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Create pixmap
|
||||
pixmap = XCreatePixmap(icon->display, icon->root, width, height,
|
||||
icon->depth);
|
||||
if (icon_size != NAME_ONLY &&
|
||||
tmp_pixmap && tmp_pixmap != XmUNSPECIFIED_PIXMAP)
|
||||
{
|
||||
mask = XCreatePixmap(icon->display, icon->root, width, height, 1);
|
||||
// Clear mask
|
||||
XSetForeground(icon->display, gc_mask, 0);
|
||||
XFillRectangle(icon->display, mask, gc_mask, 0, 0, width, height);
|
||||
|
||||
// Set Mask Bits
|
||||
XSetForeground(icon->display, gc_mask, 1);
|
||||
if (icon_size == LARGE_ICON)
|
||||
{
|
||||
#ifndef hpux
|
||||
if (tmp_mask && tmp_mask != XmUNSPECIFIED_PIXMAP)
|
||||
{
|
||||
XSetClipOrigin(icon->display, gc_mask, p_x, p_y);
|
||||
XSetClipMask(icon->display, gc_mask, tmp_mask);
|
||||
XFillRectangle(icon->display, mask, gc_mask, p_x, p_y, p_w, p_h);
|
||||
XSetClipMask(icon->display, gc_mask, None);
|
||||
XSetClipOrigin(icon->display, gc_mask, 0, 0);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
XFillRectangle(icon->display, mask, gc_mask, p_x, p_y, p_w, p_h);
|
||||
}
|
||||
else
|
||||
XFillRectangle(icon->display, mask, gc_mask, p_x, p_y, p_w - 1,
|
||||
p_h - 1);
|
||||
|
||||
if (icon_size == LARGE_ICON)
|
||||
XFillRectangle(icon->display, mask, gc_mask, s_x - string_border_width,
|
||||
s_y - string_border_width,
|
||||
s_w + 2 * string_border_width,
|
||||
s_h + 2 * string_border_width);
|
||||
else
|
||||
XFillRectangle(icon->display, mask, gc_mask, s_x, s_y, s_w - 1,
|
||||
s_h - 1);
|
||||
}
|
||||
// If selected use selectColor as background
|
||||
if (showSelectedPixmap && selected)
|
||||
bg = selectColor;
|
||||
|
||||
// Copy Pixmap to new pixmap
|
||||
XSetClipMask(icon->display, gc, None);
|
||||
XSetFillStyle(icon->display, gc, FillSolid);
|
||||
XSetForeground(icon->display, gc, bg);
|
||||
if (icon_size == LARGE_ICON)
|
||||
XFillRectangle(icon->display, pixmap, gc, p_x, p_y, p_w, p_h);
|
||||
else
|
||||
XFillRectangle(icon->display, pixmap, gc, p_x, p_y, p_w - 1, p_h - 1);
|
||||
XSetClipOrigin(icon->display, gc, p_x, p_y);
|
||||
if (tmp_mask && tmp_mask != XmUNSPECIFIED_PIXMAP)
|
||||
XSetClipMask(icon->display, gc, tmp_mask);
|
||||
else
|
||||
XSetClipMask(icon->display, gc, None);
|
||||
if (icon_size == LARGE_ICON)
|
||||
XCopyArea(icon->display, tmp_pixmap, pixmap, gc, 0, 0, p_w, p_h,
|
||||
p_x, p_y);
|
||||
else
|
||||
XCopyArea(icon->display, tmp_pixmap, pixmap, gc, 0, 0, p_w - 1, p_h - 1,
|
||||
p_x, p_y);
|
||||
XSetClipMask(icon->display, gc, None);
|
||||
XSetClipOrigin(icon->display, gc, 0, 0);
|
||||
DrawString();
|
||||
|
||||
Arg args[11];
|
||||
int n = 0;
|
||||
w = width;
|
||||
h = height;
|
||||
XtSetArg(args[n], XmNwidth, w); n++;
|
||||
XtSetArg(args[n], XmNheight, h); n++;
|
||||
XtSetArg(args[n], XmNmaxWidth, w); n++;
|
||||
XtSetArg(args[n], XmNmaxHeight, h); n++;
|
||||
XtSetArg(args[n], XmNdepth, icon->depth); n++;
|
||||
XtSetArg(args[n], XmNforeground, bg); n++;
|
||||
XtSetArg(args[n], XmNbackground, fg); n++;
|
||||
XtSetArg(args[n], XmNpixmap, pixmap); n++;
|
||||
if (mask)
|
||||
{
|
||||
XtSetArg(args[n], XmNmask, mask);
|
||||
n++;
|
||||
}
|
||||
|
||||
dragIcon = XmCreateDragIcon(icon->BaseWidget(), "dragIcon", args, n);
|
||||
|
||||
n = 0;
|
||||
if (icon_size == LARGE_ICON)
|
||||
sprintf(iconFile, "%s.m.bm", icon->IconFile());
|
||||
else
|
||||
sprintf(iconFile, "%s.t.bm", icon->IconFile());
|
||||
icon->GetPixmaps(icon->BaseWidget(), iconFile, &tmp_pixmap);
|
||||
|
||||
if (!(tmp_pixmap && tmp_pixmap != XmUNSPECIFIED_PIXMAP))
|
||||
{
|
||||
static Pixmap l_pixmap = (Pixmap)NULL, s_pixmap = (Pixmap)NULL;
|
||||
if (icon_size == LARGE_ICON)
|
||||
{
|
||||
if (!l_pixmap)
|
||||
{
|
||||
l_pixmap = XCreatePixmap(icon->display, icon->root, p_w, p_h, 1);
|
||||
XFillRectangle(icon->display, l_pixmap, gc_mask, 0, 0, p_w, p_h);
|
||||
}
|
||||
tmp_pixmap = l_pixmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (icon_size == NAME_ONLY)
|
||||
{
|
||||
p_w = 16;
|
||||
p_h = 16;
|
||||
}
|
||||
if (!s_pixmap)
|
||||
{
|
||||
s_pixmap = XCreatePixmap(icon->display, icon->root, p_w, p_h, 1);
|
||||
XFillRectangle(icon->display, s_pixmap, gc_mask, 0, 0, p_w, p_h);
|
||||
}
|
||||
tmp_pixmap = s_pixmap;
|
||||
}
|
||||
}
|
||||
|
||||
if (icon_size == NAME_ONLY)
|
||||
{
|
||||
w = 16;
|
||||
h = 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
w = p_w;
|
||||
h = p_h;
|
||||
}
|
||||
XtSetArg(args[n], XmNwidth, w); n++;
|
||||
XtSetArg(args[n], XmNheight, h); n++;
|
||||
XtSetArg(args[n], XmNmaxWidth, w); n++;
|
||||
XtSetArg(args[n], XmNmaxHeight, h); n++;
|
||||
XtSetArg(args[n], XmNdepth, 1); n++;
|
||||
XtSetArg(args[n], XmNforeground, icon->black); n++;
|
||||
XtSetArg(args[n], XmNbackground, icon->white); n++;
|
||||
XtSetArg(args[n], XmNpixmap, tmp_pixmap); n++;
|
||||
if (tmp_mask && tmp_mask != XmUNSPECIFIED_PIXMAP)
|
||||
{
|
||||
XtSetArg(args[n], XmNmask, tmp_mask);
|
||||
n++;
|
||||
}
|
||||
|
||||
sourceIcon = XmCreateDragIcon(icon->BaseWidget(), "sourceIcon", args, n);
|
||||
strcpy(iconFile, icon->IconFile());
|
||||
}
|
||||
|
||||
void DtDND::DrawString()
|
||||
{
|
||||
IconObj *icon = (IconObj *)obj;
|
||||
|
||||
// Draw String
|
||||
if (selected)
|
||||
XSetForeground(icon->display, gc, selectColor);
|
||||
else
|
||||
XSetForeground(icon->display, gc, bg);
|
||||
if (icon_size == LARGE_ICON)
|
||||
XFillRectangle(icon->display, pixmap, gc, s_x - string_border_width,
|
||||
s_y - string_border_width, s_w + 2 * string_border_width,
|
||||
s_h + 2 * string_border_width);
|
||||
else
|
||||
XFillRectangle(icon->display, pixmap, gc, s_x, s_y, s_w - 1, s_h - 1);
|
||||
// If selected use selectColor as background
|
||||
if (selected)
|
||||
XSetForeground(icon->display, gc, textSelectColor);
|
||||
else
|
||||
XSetForeground(icon->display, gc, fg);
|
||||
XmStringDraw(icon->display, pixmap, fontList, string, gc, s_x, s_y, s_w,
|
||||
alignment, stringDirection, NULL);
|
||||
}
|
||||
|
||||
void DtDND::GetRects()
|
||||
{
|
||||
Dimension shadow, highlight, margin;
|
||||
|
||||
XtVaGetValues(obj->BaseWidget(), XmNhighlightThickness, &highlight,
|
||||
GuiNiconMarginThickness, &margin,
|
||||
GuiNiconShadowThickness, &shadow, NULL);
|
||||
|
||||
margin += (shadow + highlight);
|
||||
GuiIconGetRects(obj->BaseWidget(), &rects[0], &rects[1]);
|
||||
rects[0].x -= margin;
|
||||
rects[0].y -= margin;
|
||||
rects[0].width += (2 * margin);
|
||||
rects[0].height += (2 * margin);
|
||||
rects[1].x -= margin;
|
||||
rects[1].y -= margin;
|
||||
rects[1].width += (2 * margin);
|
||||
rects[1].height += (2 * margin);
|
||||
}
|
||||
|
||||
void DtDND::UpdateActivity(boolean flag)
|
||||
{
|
||||
Arg args[3];
|
||||
int n = 0;
|
||||
|
||||
if (flag)
|
||||
{
|
||||
XtSetArg(args[n], XmNdropSiteOperations, XmDROP_COPY | XmDROP_MOVE); n++;
|
||||
XtSetArg(args[n], XmNdropSiteActivity, XmDROP_SITE_ACTIVE); n++;
|
||||
if (obj->UIClass() == ICON)
|
||||
XtSetArg(args[n], XmNanimationStyle, XmDRAG_UNDER_SHADOW_IN);
|
||||
else
|
||||
XtSetArg(args[n], XmNanimationStyle, XmDRAG_UNDER_HIGHLIGHT);
|
||||
n++;
|
||||
}
|
||||
else
|
||||
{
|
||||
XtSetArg(args[n], XmNdropSiteOperations, XmDROP_NOOP); n++;
|
||||
XtSetArg(args[n], XmNdropSiteActivity, XmDROP_SITE_INACTIVE); n++;
|
||||
XtSetArg(args[n], XmNanimationStyle, XmDRAG_UNDER_NONE); n++;
|
||||
}
|
||||
XmDropSiteUpdate(obj->BaseWidget(), args, n);
|
||||
if (flag)
|
||||
XmDropSiteConfigureStackingOrder(obj->BaseWidget(), NULL, XmABOVE);
|
||||
else
|
||||
XmDropSiteConfigureStackingOrder(obj->BaseWidget(), NULL, XmBELOW);
|
||||
}
|
||||
|
||||
void DtDND::UpdateRects()
|
||||
{
|
||||
Arg args[2];
|
||||
|
||||
GetRects();
|
||||
XtSetArg(args[0], XmNnumDropRectangles, 2);
|
||||
XtSetArg(args[1], XmNdropRectangles, &rects);
|
||||
XmDropSiteUpdate(obj->BaseWidget(), args, 2);
|
||||
}
|
||||
|
||||
void DtDND::AnimateCB(Widget /*widget*/, XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
{
|
||||
DtDND *obj = (DtDND *)client_data;
|
||||
if (obj->dndCB)
|
||||
{
|
||||
DtDndDropAnimateCallbackStruct *animateInfo;
|
||||
animateInfo = (DtDndDropAnimateCallbackStruct *) call_data;
|
||||
int i = 0, numItems;
|
||||
numItems = animateInfo->dropData->numItems;
|
||||
//for (i = 0; i < numItems; i++)
|
||||
{
|
||||
(*obj->dndCB)(obj->obj, NULL, NULL, ANIMATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DtDND::TransferCB(Widget /*widget*/, XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
{
|
||||
DtDndTransferCallbackStruct *transferInfo;
|
||||
transferInfo = (DtDndTransferCallbackStruct *) call_data;
|
||||
char *value;
|
||||
int len, i, numItems;
|
||||
|
||||
DtDND *obj = (DtDND *)client_data;
|
||||
numItems = transferInfo->dropData->numItems;
|
||||
switch (transferInfo->dropData->protocol)
|
||||
{
|
||||
case DtDND_FILENAME_TRANSFER:
|
||||
if (obj->dndCB)
|
||||
{
|
||||
for (i = 0; i < numItems; i++)
|
||||
{
|
||||
value = transferInfo->dropData->data.files[i];
|
||||
len = strlen(value);
|
||||
(*obj->dndCB)(obj->obj, &value, &len, FILENAME_TRANSFER);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DtDND_TEXT_TRANSFER:
|
||||
if (obj->dndCB)
|
||||
{
|
||||
for (i = 0; i < numItems; i++)
|
||||
{
|
||||
value = (char *) _XmStringUngenerate(
|
||||
transferInfo->dropData->data.strings[i], NULL,
|
||||
XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
|
||||
len = strlen(value);
|
||||
(*obj->dndCB)(obj->obj, &value, &len, TEXT_TRANSFER);
|
||||
if (NULL != value)
|
||||
XtFree(value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DtDND_BUFFER_TRANSFER:
|
||||
if (obj->dndCB)
|
||||
{
|
||||
(*obj->dndCB)(obj->obj, &value, &len, BUFFER_TRANSFER);
|
||||
DtActionArg *aap = new DtActionArg[numItems];
|
||||
memset(aap, 0, numItems * sizeof(DtActionArg));
|
||||
for (i = 0; i < numItems; i++)
|
||||
{
|
||||
aap[i].argClass = DtACTION_BUFFER;
|
||||
aap[i].u.buffer.bp = transferInfo->dropData->data.buffers[i].bp;
|
||||
aap[i].u.buffer.size = transferInfo->dropData->data.buffers[i].size;
|
||||
aap[i].u.buffer.name = transferInfo->dropData->data.buffers[i].name;
|
||||
}
|
||||
MotifUI *tmp = (MotifUI *)obj->obj;
|
||||
DtActionInvoke(tmp->topLevel, value, aap, numItems, NULL, NULL, NULL,
|
||||
1, NULL, NULL);
|
||||
delete aap;
|
||||
delete value;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
transferInfo->status = DtDND_FAILURE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DtDND::DragMotionHandler(Widget /*widget*/, XtPointer client_data,
|
||||
XEvent *event, Boolean * /*continued*/)
|
||||
{
|
||||
static int initialX = -1;
|
||||
static int initialY = -1;
|
||||
int diffX, diffY;
|
||||
DtDND *obj = (DtDND *)client_data;
|
||||
|
||||
if (obj->DoingDrag)
|
||||
return;
|
||||
|
||||
// If the drag is just starting, set initial button down coords
|
||||
if (initialX == -1 && initialY == -1)
|
||||
{
|
||||
initialX = event->xmotion.x;
|
||||
initialY = event->xmotion.y;
|
||||
}
|
||||
// Find out how far pointer has moved since button press
|
||||
diffX = initialX - event->xmotion.x;
|
||||
diffY = initialY - event->xmotion.y;
|
||||
|
||||
if ((ABS(diffX) >= DRAG_THRESHOLD) ||
|
||||
(ABS(diffY) >= DRAG_THRESHOLD))
|
||||
{
|
||||
obj->DoingDrag = true;
|
||||
obj->StartDrag(event);
|
||||
initialX = -1;
|
||||
initialY = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void DtDND::DragFinishCB(Widget /*widget*/, XtPointer client_data,
|
||||
XtPointer /*callData*/)
|
||||
{
|
||||
DtDND *obj = (DtDND *) client_data;
|
||||
obj->DoingDrag = false;
|
||||
}
|
||||
|
||||
void DtDND::StartDrag(XEvent *event)
|
||||
{
|
||||
IconObj *icon = (IconObj *)obj;
|
||||
|
||||
convertCBRec[0].closure = (XtPointer)this;
|
||||
dragFinishCBRec[0].closure = (XtPointer)this;
|
||||
dropOnRootCBRec[0].closure = (XtPointer)this;
|
||||
if ((!STRCMP(name, icon->Name()) || !STRCMP(iconFile, icon->IconFile()) ||
|
||||
icon_size != icon->IconView()) && dragIcon)
|
||||
{
|
||||
XtDestroyWidget(dragIcon);
|
||||
XtDestroyWidget(sourceIcon);
|
||||
dragIcon = NULL;
|
||||
sourceIcon = NULL;
|
||||
}
|
||||
if (!dragIcon)
|
||||
GetDragPixmaps();
|
||||
else if (selected != icon->Selected())
|
||||
{
|
||||
selected = icon->Selected();
|
||||
DrawString();
|
||||
}
|
||||
Arg arg[3];
|
||||
XtSetArg(arg[0], DtNsourceIcon, (XtArgVal)dragIcon);
|
||||
XtSetArg(arg[1], XmNsourceCursorIcon, (XtArgVal)sourceIcon);
|
||||
XtSetArg(arg[2], DtNdropOnRootCallback, dropOnRootCBRec);
|
||||
|
||||
Widget dc = DtDndDragStart(obj->BaseWidget(), event, DtDND_FILENAME_TRANSFER,
|
||||
1, (unsigned char)(XmDROP_COPY | XmDROP_MOVE),
|
||||
convertCBRec, dragFinishCBRec, arg,
|
||||
can_drop_on_root ? 3 : 2);
|
||||
if (dc)
|
||||
{
|
||||
XmDragContext xmDragContext = (XmDragContext) dc;
|
||||
XtVaSetValues((Widget)xmDragContext->drag.curDragOver,
|
||||
XmNdragOverMode, XmPIXMAP, NULL);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "DtDndDragStart returned NULL.\n");
|
||||
}
|
||||
|
||||
void DtDND::ConvertCB(Widget /*dragContext*/, XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
{
|
||||
char *value;
|
||||
DtDndConvertCallbackStruct *convertInfo;
|
||||
int len, i, numFiles;
|
||||
DtDND *obj = (DtDND *) client_data;
|
||||
|
||||
convertInfo = (DtDndConvertCallbackStruct *) call_data;
|
||||
numFiles = convertInfo->dragData->numItems;
|
||||
switch (convertInfo->reason)
|
||||
{
|
||||
case DtCR_DND_CONVERT_DATA:
|
||||
if (obj->dndCB)
|
||||
{
|
||||
for (i = 0; i < numFiles; i++)
|
||||
{
|
||||
value = NULL;
|
||||
(*obj->dndCB)(obj->obj, &value, &len, CONVERT_DATA);
|
||||
if (value && *value)
|
||||
convertInfo->dragData->data.files[i] = value;
|
||||
else
|
||||
{
|
||||
convertInfo->status = DtDND_FAILURE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DtCR_DND_CONVERT_DELETE:
|
||||
if (obj->dndCB)
|
||||
{
|
||||
for (i = 0; i < numFiles; i++)
|
||||
{
|
||||
value = convertInfo->dragData->data.files[i];
|
||||
len = strlen(value);
|
||||
(*obj->dndCB)(obj->obj, &value, &len, CONVERT_DELETE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DtDND::DropOnRootCB(Widget /*dragContext*/, XtPointer client_data,
|
||||
XtPointer call_data)
|
||||
{
|
||||
char *value;
|
||||
int len, x, y, i, numFiles;
|
||||
DtDND *obj = (DtDND *) client_data;
|
||||
DtDndDropCallbackStruct *fileList = (DtDndDropCallbackStruct *)call_data;
|
||||
MotifUI *tmp = (MotifUI *)obj->obj;
|
||||
Atom pCurrent;
|
||||
char *workspace_name = NULL;
|
||||
|
||||
if (DtWsmGetCurrentWorkspace(tmp->display, tmp->root, &pCurrent) ==
|
||||
Success)
|
||||
{
|
||||
workspace_name = XGetAtomName(tmp->display, pCurrent);
|
||||
}
|
||||
|
||||
numFiles = fileList->dropData->numItems;
|
||||
fileList->completeMove = False;
|
||||
x = fileList->x;
|
||||
y = fileList->y;
|
||||
int max_len = 0;
|
||||
for(i = 0; i < numFiles; i++)
|
||||
if ((len = strlen(fileList->dropData->data.files[i])) > max_len)
|
||||
max_len = len;
|
||||
if (workspace_name)
|
||||
value = new char[max_len + strlen(workspace_name) + 30];
|
||||
else
|
||||
value = new char[max_len + 30];
|
||||
for(i = 0; i < numFiles; i++)
|
||||
{
|
||||
if (workspace_name)
|
||||
sprintf(value, "%d\n%d\n%s \n%s", x, y,
|
||||
fileList->dropData->data.files[i], workspace_name);
|
||||
else
|
||||
sprintf(value, "%d\n%d\n%s", x, y, fileList->dropData->data.files[i]);
|
||||
len = strlen(value);
|
||||
(*obj->dndCB)(obj->obj, &value, &len, DROP_ON_ROOT);
|
||||
y += 20;
|
||||
x += 20;
|
||||
}
|
||||
delete value;
|
||||
}
|
||||
94
cde/programs/dtprintinfo/libUI/MotifUI/DtDND.h
Normal file
94
cde/programs/dtprintinfo/libUI/MotifUI/DtDND.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/* $XConsortium: DtDND.h /main/3 1995/11/06 09:40:32 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef DTDND_H
|
||||
#define DTDND_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FILENAME_TRANSFER,
|
||||
TEXT_TRANSFER,
|
||||
DROP_ON_ROOT,
|
||||
BUFFER_TRANSFER,
|
||||
CONVERT_DATA,
|
||||
CONVERT_DELETE,
|
||||
ANIMATE
|
||||
} DNDProtocol;
|
||||
|
||||
typedef void (*DNDCallback) (BaseUI *, char **value, int *len, DNDProtocol);
|
||||
|
||||
class DtDND {
|
||||
|
||||
friend void TransferCB(Widget, XtPointer, XtPointer);
|
||||
friend void ConvertCB(Widget, XtPointer, XtPointer);
|
||||
friend void DragFinishCB(Widget, XtPointer, XtPointer);
|
||||
friend void DropOnRootCB(Widget, XtPointer, XtPointer);
|
||||
friend void AnimateCB(Widget, XtPointer, XtPointer);
|
||||
friend void DragMotionHandler(Widget, XtPointer, XEvent *, Boolean *);
|
||||
|
||||
static void TransferCB(Widget, XtPointer, XtPointer);
|
||||
static void ConvertCB(Widget, XtPointer, XtPointer);
|
||||
static void DragFinishCB(Widget, XtPointer, XtPointer);
|
||||
static void DropOnRootCB(Widget, XtPointer, XtPointer);
|
||||
static void AnimateCB(Widget, XtPointer, XtPointer);
|
||||
static void DragMotionHandler(Widget, XtPointer, XEvent *, Boolean *);
|
||||
|
||||
private:
|
||||
|
||||
static boolean FirstTime;
|
||||
static boolean DoingDrag;
|
||||
static XtCallbackRec transferCBRec[];
|
||||
static XtCallbackRec convertCBRec[];
|
||||
static XtCallbackRec dragFinishCBRec[];
|
||||
static XtCallbackRec dropOnRootCBRec[];
|
||||
static XtCallbackRec animateCBRec[];
|
||||
static GC gc;
|
||||
static GC gc_mask;
|
||||
|
||||
MotifUI *obj;
|
||||
Widget dragIcon;
|
||||
Widget sourceIcon;
|
||||
DNDCallback dndCB;
|
||||
XRectangle rects[2];
|
||||
Pixmap pixmap;
|
||||
Pixmap mask;
|
||||
char *name;
|
||||
char *iconFile;
|
||||
Position s_x, s_y;
|
||||
Pixel bg, fg;
|
||||
unsigned char stringDirection;
|
||||
Pixel textSelectColor;
|
||||
XmString string;
|
||||
Pixel selectColor;
|
||||
unsigned char alignment;
|
||||
Boolean showSelectedPixmap;
|
||||
XmFontList fontList;
|
||||
int string_border_width;
|
||||
int p_x, p_y;
|
||||
int p_w, p_h, s_w, s_h;
|
||||
boolean selected;
|
||||
boolean can_drop_on_root;
|
||||
IconStyle icon_size;
|
||||
|
||||
void GetRects();
|
||||
void GetDragPixmaps();
|
||||
void DrawString();
|
||||
void StartDrag(XEvent *);
|
||||
|
||||
public:
|
||||
|
||||
DtDND(MotifUI *obj, DNDCallback dndCB, boolean can_drop_on_root = false);
|
||||
~DtDND();
|
||||
void UpdateActivity(boolean);
|
||||
void UpdateRects();
|
||||
|
||||
};
|
||||
|
||||
#endif // DTDND_H
|
||||
73
cde/programs/dtprintinfo/libUI/MotifUI/Group.C
Normal file
73
cde/programs/dtprintinfo/libUI/MotifUI/Group.C
Normal file
@@ -0,0 +1,73 @@
|
||||
/* $XConsortium: Group.C /main/2 1995/07/17 14:05:44 drk $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "Group.h"
|
||||
#include "Dialog.h"
|
||||
|
||||
#include <Xm/Frame.h>
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/Form.h>
|
||||
|
||||
Group::Group(MotifUI *parent,
|
||||
char *name,
|
||||
GroupType group_type)
|
||||
: MotifUI(parent, name, NULL)
|
||||
{
|
||||
Widget parentW;
|
||||
|
||||
_group_type = group_type;
|
||||
|
||||
parentW = parent->InnerWidget();
|
||||
XmString xm_string = StringCreate(name);
|
||||
|
||||
_w = XtVaCreateManagedWidget(name, xmFrameWidgetClass, parentW, NULL);
|
||||
if (name)
|
||||
_label = XtVaCreateManagedWidget(name, xmLabelWidgetClass, _w,
|
||||
XmNchildType, XmFRAME_TITLE_CHILD,
|
||||
XmNlabelString, xm_string, NULL);
|
||||
else
|
||||
_label = XtVaCreateWidget(name, xmLabelWidgetClass, _w,
|
||||
XmNchildType, XmFRAME_TITLE_CHILD,
|
||||
XmNlabelString, xm_string, NULL);
|
||||
if (group_type == FORM_BOX)
|
||||
_rc = XtVaCreateManagedWidget(name, xmFormWidgetClass, _w, NULL);
|
||||
else
|
||||
{
|
||||
boolean flag;
|
||||
int orientaion;
|
||||
if (group_type == RADIO_GROUP || group_type == HORIZONTAL_RADIO_GROUP)
|
||||
flag = true;
|
||||
else
|
||||
flag = false;
|
||||
if (group_type == HORIZONTAL_CHECK_BOX ||
|
||||
group_type == HORIZONTAL_RADIO_GROUP)
|
||||
orientaion = XmHORIZONTAL;
|
||||
else
|
||||
orientaion = XmVERTICAL;
|
||||
_rc = XtVaCreateManagedWidget(name, xmRowColumnWidgetClass, _w,
|
||||
XmNradioBehavior, flag,
|
||||
XmNorientation, orientaion, NULL);
|
||||
}
|
||||
StringFree(xm_string);
|
||||
}
|
||||
|
||||
boolean Group::SetName(char *name)
|
||||
{
|
||||
if (name)
|
||||
{
|
||||
XmString xm_string = StringCreate(name);
|
||||
XtVaSetValues(_label, XmNlabelString, xm_string, NULL);
|
||||
StringFree(xm_string);
|
||||
XtManageChild(_label);
|
||||
}
|
||||
else
|
||||
XtUnmanageChild(_label);
|
||||
|
||||
return true;
|
||||
}
|
||||
38
cde/programs/dtprintinfo/libUI/MotifUI/Group.h
Normal file
38
cde/programs/dtprintinfo/libUI/MotifUI/Group.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* $XConsortium: Group.h /main/3 1995/11/06 09:40:43 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef GROUP_H
|
||||
#define GROUP_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
class Group : public MotifUI {
|
||||
|
||||
private:
|
||||
|
||||
Widget _label;
|
||||
Widget _rc;
|
||||
GroupType _group_type;
|
||||
|
||||
public:
|
||||
|
||||
Group(MotifUI *parent,
|
||||
char *name,
|
||||
GroupType group_type = RADIO_GROUP);
|
||||
|
||||
const Widget InnerWidget() { return _rc; }
|
||||
const UI_Class UIClass() { return GROUP; }
|
||||
const int UISubClass() { return _group_type; }
|
||||
const char *const UIClassName() { return "Group"; }
|
||||
|
||||
// Override SetName, need to set label name, not BaseWidget
|
||||
boolean SetName(char *);
|
||||
|
||||
};
|
||||
|
||||
#endif /* GROUP_H */
|
||||
115
cde/programs/dtprintinfo/libUI/MotifUI/HelpSystem.C
Normal file
115
cde/programs/dtprintinfo/libUI/MotifUI/HelpSystem.C
Normal file
@@ -0,0 +1,115 @@
|
||||
/* $XConsortium: HelpSystem.C /main/2 1995/07/17 14:05:53 drk $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "HelpSystem.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Xm/AtomMgr.h>
|
||||
#include <Xm/Protocols.h>
|
||||
#include <Dt/Help.h>
|
||||
#include <Dt/HelpDialog.h>
|
||||
#include <Dt/HelpQuickD.h>
|
||||
#include <Dt/Wsm.h>
|
||||
|
||||
HelpSystem::HelpSystem(MotifUI *parent,
|
||||
char *name,
|
||||
char *volume,
|
||||
char *location_id,
|
||||
HelpStyle style)
|
||||
: MotifUI(parent, name, NULL)
|
||||
{
|
||||
CreateHelpDialog(parent, name, volume, location_id, style);
|
||||
}
|
||||
|
||||
HelpSystem::HelpSystem(char *category,
|
||||
MotifUI *parent,
|
||||
char *name,
|
||||
char *volume,
|
||||
char *location_id,
|
||||
HelpStyle style)
|
||||
: MotifUI(parent, name, category)
|
||||
{
|
||||
CreateHelpDialog(parent, name, volume, location_id, style);
|
||||
}
|
||||
|
||||
void HelpSystem::CreateHelpDialog(MotifUI *parent, char *name, char *volume,
|
||||
char *location_id, HelpStyle style)
|
||||
{
|
||||
Arg args[6];
|
||||
int n;
|
||||
|
||||
_style = style;
|
||||
n = 0;
|
||||
XtSetArg(args[n], XmNtitle, name); n++;
|
||||
XtSetArg(args[n], XmNautoUnmanage, false); n++;
|
||||
XtSetArg(args[n], DtNshowNewWindowButton, false); n++;
|
||||
XtSetArg(args[n], DtNhelpType, DtHELP_TYPE_TOPIC); n++;
|
||||
XtSetArg(args[n], DtNhelpVolume, volume); n++;
|
||||
XtSetArg(args[n], DtNlocationId, location_id); n++;
|
||||
if (_style == HELP_DIALOG)
|
||||
_w = DtCreateHelpDialog(parent->InnerWidget(), "helpDlg", args, n);
|
||||
else
|
||||
_w = DtCreateHelpQuickDialog(parent->InnerWidget(), "helpDlg", args, n);
|
||||
|
||||
DtWsmRemoveWorkspaceFunctions(display, XtWindow(XtParent(_w)));
|
||||
XtAddCallback(_w, DtNhyperLinkCallback,
|
||||
(XtCallbackProc)HyperlinkCB, (XtPointer) this);
|
||||
XtAddCallback(_w, DtNcloseCallback, (XtCallbackProc)CloseCB,
|
||||
(XtPointer) this);
|
||||
XmAddWMProtocolCallback(XtParent(_w),
|
||||
XmInternAtom(display, "WM_DELETE_WINDOW", False),
|
||||
&HelpSystem::CloseCB, (XtPointer) this);
|
||||
}
|
||||
|
||||
boolean HelpSystem::SetVisiblity(boolean flag)
|
||||
{
|
||||
MotifUI::SetVisiblity(flag);
|
||||
if (flag == true && XtIsRealized(XtParent(_w)))
|
||||
XtMapWidget(XtParent(_w));
|
||||
return true;
|
||||
}
|
||||
|
||||
void HelpSystem::HyperlinkCB(Widget, XtPointer data, XtPointer)
|
||||
{
|
||||
HelpSystem *obj = (HelpSystem *)data;
|
||||
}
|
||||
|
||||
void HelpSystem::CloseCB(Widget, XtPointer data, XtPointer)
|
||||
{
|
||||
HelpSystem *obj = (HelpSystem *)data;
|
||||
obj->Visible(false);
|
||||
}
|
||||
|
||||
char *HelpSystem::HelpVolume()
|
||||
{
|
||||
char *value;
|
||||
XtVaGetValues(_w, DtNhelpVolume, &value, NULL);
|
||||
return value;
|
||||
}
|
||||
|
||||
char *HelpSystem::LocationID()
|
||||
{
|
||||
char *value;
|
||||
XtVaGetValues(_w, DtNlocationId, &value, NULL);
|
||||
return value;
|
||||
}
|
||||
|
||||
void HelpSystem::LocationID(char *locationId)
|
||||
{
|
||||
//if (strcmp(LocationID(), locationId))
|
||||
XtVaSetValues(_w, DtNhelpType, DtHELP_TYPE_TOPIC,
|
||||
DtNlocationId, locationId, NULL);
|
||||
}
|
||||
|
||||
void HelpSystem::HelpVolume(char *helpVolume, char *locationId)
|
||||
{
|
||||
//if (strcmp(HelpVolume(), helpVolume) || strcmp(LocationID(), locationId))
|
||||
XtVaSetValues(_w, DtNhelpVolume, helpVolume, DtNlocationId, locationId,
|
||||
DtNhelpType, DtHELP_TYPE_TOPIC, NULL);
|
||||
}
|
||||
60
cde/programs/dtprintinfo/libUI/MotifUI/HelpSystem.h
Normal file
60
cde/programs/dtprintinfo/libUI/MotifUI/HelpSystem.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* $XConsortium: HelpSystem.h /main/3 1995/11/06 09:40:54 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef HELP_SYSTEM_H
|
||||
#define HELP_SYSTEM_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HELP_DIALOG,
|
||||
QUICK_HELP
|
||||
} HelpStyle;
|
||||
|
||||
class HelpSystem : public MotifUI {
|
||||
|
||||
friend void HyperlinkCB(Widget, XtPointer, XtPointer);
|
||||
friend void CloseCB(Widget, XtPointer, XtPointer);
|
||||
|
||||
private:
|
||||
|
||||
static void HyperlinkCB(Widget, XtPointer, XtPointer);
|
||||
static void CloseCB(Widget, XtPointer, XtPointer);
|
||||
void CreateHelpDialog(MotifUI *, char *, char *, char *, HelpStyle);
|
||||
boolean SetVisiblity(boolean flag);
|
||||
|
||||
HelpStyle _style;
|
||||
|
||||
public:
|
||||
|
||||
HelpSystem(MotifUI * parent,
|
||||
char * name,
|
||||
char * volume = NULL,
|
||||
char * location_id = "_hometopic",
|
||||
HelpStyle style = HELP_DIALOG);
|
||||
HelpSystem(char *category,
|
||||
MotifUI * parent,
|
||||
char * name,
|
||||
char * volume = NULL,
|
||||
char * location_id = "_hometopic",
|
||||
HelpStyle style = HELP_DIALOG);
|
||||
|
||||
char *HelpVolume();
|
||||
char *LocationID();
|
||||
void HelpVolume(char *volume,
|
||||
char *location = "_hometopic");
|
||||
void LocationID(char *location);
|
||||
|
||||
const UI_Class UIClass() { return HELP_SYSTEM; }
|
||||
const int UISubClass() { return _style; }
|
||||
const char *const UIClassName() { return "HelpSystem"; }
|
||||
|
||||
};
|
||||
|
||||
#endif // HELP_SYSTEM_H
|
||||
2288
cde/programs/dtprintinfo/libUI/MotifUI/Icon.c
Normal file
2288
cde/programs/dtprintinfo/libUI/MotifUI/Icon.c
Normal file
File diff suppressed because it is too large
Load Diff
158
cde/programs/dtprintinfo/libUI/MotifUI/Icon.h
Normal file
158
cde/programs/dtprintinfo/libUI/MotifUI/Icon.h
Normal file
@@ -0,0 +1,158 @@
|
||||
/* $XConsortium: Icon.h /main/3 1995/11/06 09:41:27 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Icon.h - widget public header file
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _Icon_h
|
||||
#define _Icon_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
externalref WidgetClass iconWidgetClass;
|
||||
|
||||
typedef struct _IconClassRec *IconWidgetClass;
|
||||
typedef struct _IconRec *IconWidget;
|
||||
|
||||
enum {
|
||||
GuiSINGLE_CLICK,
|
||||
GuiDOUBLE_CLICK
|
||||
};
|
||||
|
||||
enum {
|
||||
GuiPIXMAP_TOP,
|
||||
GuiPIXMAP_BOTTOM,
|
||||
GuiPIXMAP_LEFT,
|
||||
GuiPIXMAP_RIGHT
|
||||
};
|
||||
|
||||
enum {
|
||||
GuiNORTHWEST_GRAVITY,
|
||||
GuiNORTH_GRAVITY,
|
||||
GuiNORTHEAST_GRAVITY,
|
||||
GuiWEST_GRAVITY,
|
||||
GuiCENTER_GRAVITY,
|
||||
GuiEAST_GRAVITY,
|
||||
GuiSOUTHWEST_GRAVITY,
|
||||
GuiSOUTH_GRAVITY,
|
||||
GuiSOUTHEAST_GRAVITY
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int reason;
|
||||
XEvent *event;
|
||||
Boolean prev_selected;
|
||||
XmString string;
|
||||
int field_index;
|
||||
XmString field_string;
|
||||
} GuiIconCallbackStruct, *GuiIconCallback;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Boolean free_data;
|
||||
Dimension name_width;
|
||||
int n_fields;
|
||||
int field_spacing;
|
||||
XmString *fields;
|
||||
Dimension *widths;
|
||||
unsigned char *alignments;
|
||||
Boolean *draw_fields;
|
||||
Boolean *selected;
|
||||
Boolean *active;
|
||||
} GuiIconFieldsStruct, *GuiIconFields, **GuiIconFieldsList;
|
||||
|
||||
#define GuiIsIcon(w) XtIsSubclass((w), iconWidgetClass)
|
||||
|
||||
/* Icon Resources */
|
||||
|
||||
extern const char gui_icon_strings[];
|
||||
|
||||
#define GuiNtopLabelString ((char*)&gui_icon_strings[0])
|
||||
#define GuiNbottomLabelString ((char*)&gui_icon_strings[15])
|
||||
#define GuiNpixmapPlacement ((char*)&gui_icon_strings[33])
|
||||
#define GuiCPixmapPlacement ((char*)&gui_icon_strings[49])
|
||||
#define GuiRPixmapPlacement ((char*)&gui_icon_strings[65])
|
||||
#define GuiNdoubleClickCallback ((char*)&gui_icon_strings[81])
|
||||
#define GuiNsingleClickCallback ((char*)&gui_icon_strings[101])
|
||||
#define GuiNselected ((char*)&gui_icon_strings[121])
|
||||
#define GuiCSelected ((char*)&gui_icon_strings[130])
|
||||
#define GuiNiconShadowType ((char*)&gui_icon_strings[139])
|
||||
#define GuiCIconShadowType ((char*)&gui_icon_strings[154])
|
||||
#define GuiNiconShadowThickness ((char*)&gui_icon_strings[169])
|
||||
#define GuiCIconShadowThickness ((char*)&gui_icon_strings[189])
|
||||
#define GuiNtextSelectColor ((char*)&gui_icon_strings[209])
|
||||
#define GuiCTextSelectColor ((char*)&gui_icon_strings[225])
|
||||
#define GuiNselectColor ((char*)&gui_icon_strings[241])
|
||||
#define GuiCSelectColor ((char*)&gui_icon_strings[253])
|
||||
#define GuiNselectColorPersistent ((char*)&gui_icon_strings[265])
|
||||
#define GuiCSelectColorPersistent ((char*)&gui_icon_strings[287])
|
||||
#define GuiNshowSelectedPixmap ((char*)&gui_icon_strings[309])
|
||||
#define GuiCShowSelectedPixmap ((char*)&gui_icon_strings[328])
|
||||
#define GuiNiconMarginThickness ((char*)&gui_icon_strings[347])
|
||||
#define GuiCIconMarginThickness ((char*)&gui_icon_strings[367])
|
||||
#define GuiNactive ((char*)&gui_icon_strings[387])
|
||||
#define GuiCActive ((char*)&gui_icon_strings[394])
|
||||
#define GuiNiconMask ((char*)&gui_icon_strings[401])
|
||||
#define GuiCIconMask ((char*)&gui_icon_strings[410])
|
||||
#define GuiNshrinkOutline ((char*)&gui_icon_strings[419])
|
||||
#define GuiCShrinkOutline ((char*)&gui_icon_strings[433])
|
||||
#define GuiNfields ((char *)&gui_icon_strings[447])
|
||||
#define GuiCFields ((char *)&gui_icon_strings[454])
|
||||
#define GuiNstatePixmap ((char *)&gui_icon_strings[461])
|
||||
#define GuiNstateIconMask ((char *)&gui_icon_strings[473])
|
||||
#define GuiCStateIconMask ((char *)&gui_icon_strings[487])
|
||||
#define GuiNstateGravity ((char *)&gui_icon_strings[501])
|
||||
#define GuiCStateGravity ((char *)&gui_icon_strings[514])
|
||||
#define GuiRStateGravity ((char *)&gui_icon_strings[514])
|
||||
|
||||
/* Public functions */
|
||||
|
||||
extern void GuiIconSetFieldNameWidth(
|
||||
Widget, /* GuiIconWidget */
|
||||
Dimension name_width);
|
||||
|
||||
extern Dimension GuiIconGetFieldNameWidth(Widget);
|
||||
|
||||
extern void GuiIconSetField(
|
||||
Widget, /* GuiIconWidget */
|
||||
int index,
|
||||
XmString new_string, /* NULL does not change value */
|
||||
Dimension new_width, /* 0 does not change value */
|
||||
unsigned char alignments,
|
||||
Boolean draw_field,
|
||||
Boolean selected,
|
||||
Boolean active);
|
||||
|
||||
extern void GuiIconGetField(
|
||||
Widget,
|
||||
int index,
|
||||
XmString *string,
|
||||
Dimension *width,
|
||||
unsigned char *alignments,
|
||||
Boolean *draw_field,
|
||||
Boolean *selected,
|
||||
Boolean *active);
|
||||
|
||||
extern void GuiIconGetRects(
|
||||
Widget, /* GuiIconWidget */
|
||||
XRectangle *, /* Pixmap Rectangle Return */
|
||||
XRectangle * /* Label Rectangle Return */
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* Close scope of 'extern "C"' declaration which encloses file. */
|
||||
#endif
|
||||
|
||||
#endif /* _Icon_h */
|
||||
/* DON'T ADD ANYTHING AFTER THIS #endif */
|
||||
563
cde/programs/dtprintinfo/libUI/MotifUI/IconObj.C
Normal file
563
cde/programs/dtprintinfo/libUI/MotifUI/IconObj.C
Normal file
@@ -0,0 +1,563 @@
|
||||
/* $TOG: IconObj.C /main/4 1998/07/24 16:15:38 mgreess $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "IconObj.h"
|
||||
|
||||
#include "Icon.h"
|
||||
#include "WorkArea.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// #define LargeIconJustification XmALIGNMENT_CENTER
|
||||
#define LargeIconJustification XmALIGNMENT_BEGINNING
|
||||
|
||||
IconObj::IconObj(MotifUI *parent, char *name, char *iconFile, char *details,
|
||||
char *topString, char *bottomString, IconFields fields)
|
||||
: MotifUI(parent, name, NULL)
|
||||
{
|
||||
CreateIconObj(parent, name, NULL, iconFile, details, topString,
|
||||
bottomString, fields);
|
||||
}
|
||||
|
||||
IconObj::IconObj(char *category, MotifUI *parent, char *name, char *iconFile,
|
||||
char *details, char *topString, char *bottomString,
|
||||
IconFields fields)
|
||||
: MotifUI(parent, name, category)
|
||||
{
|
||||
CreateIconObj(parent, name, category, iconFile, details, topString,
|
||||
bottomString, fields);
|
||||
}
|
||||
|
||||
IconObj::~IconObj()
|
||||
{
|
||||
delete _topString;
|
||||
delete _bottomString;
|
||||
delete _details;
|
||||
delete _iconFile;
|
||||
delete _stateIconName;
|
||||
}
|
||||
|
||||
void IconObj::CreateIconObj(MotifUI *parent, char *name, char * /*category*/,
|
||||
char *iconFile, char *details, char *topString,
|
||||
char *bottomString, IconFields _fields)
|
||||
{
|
||||
Pixmap pixmap;
|
||||
Pixmap mask;
|
||||
Pixel bg;
|
||||
Widget p, super_node;
|
||||
XmString xm_string, xm_topString, xm_bottomString;
|
||||
char *s;
|
||||
int shrinkOutline = false;
|
||||
int pixmapPlacement;
|
||||
int alignment;
|
||||
int isOpened;
|
||||
GuiIconFields gui_fields;
|
||||
|
||||
if (fields = _fields)
|
||||
{
|
||||
int i;
|
||||
gui_fields = new GuiIconFieldsStruct;
|
||||
gui_fields->free_data = True;
|
||||
gui_fields->name_width = fields->name_width;
|
||||
gui_fields->field_spacing = fields->field_spacing;
|
||||
gui_fields->n_fields = fields->n_fields;
|
||||
gui_fields->selected = new Boolean[fields->n_fields];
|
||||
gui_fields->draw_fields = new Boolean[fields->n_fields];
|
||||
gui_fields->active = new Boolean[fields->n_fields];
|
||||
gui_fields->widths = new Dimension[fields->n_fields];
|
||||
gui_fields->alignments = new unsigned char[fields->n_fields];
|
||||
gui_fields->fields = new XmString[fields->n_fields];
|
||||
|
||||
unsigned char alignment;
|
||||
for (i = 0; i < fields->n_fields; i++)
|
||||
{
|
||||
gui_fields->widths[i] = fields->fields_widths[i];
|
||||
switch (fields->alignments[i])
|
||||
{
|
||||
case LEFT_JUSTIFIED: alignment = XmALIGNMENT_BEGINNING; break;
|
||||
case CENTERED: alignment = XmALIGNMENT_CENTER; break;
|
||||
case RIGHT_JUSTIFIED: alignment = XmALIGNMENT_END; break;
|
||||
}
|
||||
gui_fields->alignments[i] = alignment;
|
||||
if (fields->active)
|
||||
gui_fields->active[i] = (Boolean)fields->active[i];
|
||||
else
|
||||
gui_fields->active[i] = True;
|
||||
if (fields->draw_fields)
|
||||
gui_fields->draw_fields[i] = (Boolean)fields->draw_fields[i];
|
||||
else
|
||||
gui_fields->draw_fields[i] = True;
|
||||
gui_fields->selected[i] = False;
|
||||
gui_fields->fields[i] = StringCreate(fields->fields[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
gui_fields = NULL;
|
||||
|
||||
// Get small and large pixmaps and masks
|
||||
char icon_type = 'p';
|
||||
if (depth == 1)
|
||||
icon_type = 'b';
|
||||
_iconFile = new char [strlen(iconFile) + 6];
|
||||
_topString = STRDUP(topString);
|
||||
_bottomString = STRDUP(bottomString);
|
||||
_details = STRDUP(details);
|
||||
|
||||
if (display == NULL)
|
||||
{
|
||||
strcpy(_iconFile, iconFile);
|
||||
_stateIconName = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf(_iconFile, "%s.t.%cm", iconFile, icon_type);
|
||||
GetPixmaps(parent->BaseWidget(), _iconFile, &_smallPixmap, &_smallMask);
|
||||
sprintf(_iconFile, "%s.m.%cm", iconFile, icon_type);
|
||||
GetPixmaps(parent->BaseWidget(), _iconFile, &_largePixmap, &_largeMask);
|
||||
strcpy(_iconFile, iconFile);
|
||||
|
||||
s = name;
|
||||
|
||||
BaseUI *par = Parent();
|
||||
if (par && par->UISubClass() == ICON_LIST ||
|
||||
par->UISubClass() == SCROLLED_ICON_LIST)
|
||||
isOpened = true;
|
||||
else
|
||||
isOpened = false;
|
||||
switch (IconView())
|
||||
{
|
||||
case NAME_ONLY:
|
||||
pixmapPlacement = GuiPIXMAP_LEFT;
|
||||
alignment = XmALIGNMENT_BEGINNING;
|
||||
pixmap = mask = XmUNSPECIFIED_PIXMAP;
|
||||
break;
|
||||
case LARGE_ICON:
|
||||
if (ContainerView() == TREE ||
|
||||
(Parent()->UIClass() == CONTAINER &&
|
||||
Parent()->UISubClass() == SCROLLED_VERTICAL_ROW_COLUMN))
|
||||
{
|
||||
isOpened = true;
|
||||
pixmapPlacement = GuiPIXMAP_LEFT;
|
||||
}
|
||||
else
|
||||
pixmapPlacement = GuiPIXMAP_TOP;
|
||||
if (isOpened)
|
||||
alignment = XmALIGNMENT_BEGINNING;
|
||||
else
|
||||
alignment = LargeIconJustification;
|
||||
shrinkOutline = true;
|
||||
pixmap = _largePixmap;
|
||||
mask = _largeMask;
|
||||
break;
|
||||
case DETAILS:
|
||||
s = new char [STRLEN(name) + STRLEN(details) + 2];
|
||||
if (details)
|
||||
sprintf(s, "%s %s", name, details);
|
||||
else
|
||||
strcpy(s, name);
|
||||
// no break
|
||||
case SMALL_ICON:
|
||||
alignment = XmALIGNMENT_BEGINNING;
|
||||
pixmapPlacement = GuiPIXMAP_LEFT;
|
||||
pixmap = _smallPixmap;
|
||||
mask = _smallMask;
|
||||
break;
|
||||
}
|
||||
// Get Parent and colors
|
||||
p = parent->InnerWidget();
|
||||
if (!XtIsComposite(p))
|
||||
p = XtParent(p);
|
||||
XtVaGetValues(p, XmNbackground, &bg, NULL);
|
||||
|
||||
// If p is a icon then set superNode to it, otherwise set superNode to NULL
|
||||
super_node = GuiIsIcon(parent->BaseWidget()) ? parent->BaseWidget() : NULL;
|
||||
xm_string = StringCreate(s);
|
||||
xm_topString = StringCreate(topString);
|
||||
xm_bottomString = StringCreate(bottomString);
|
||||
Pixel text_select_color = black;
|
||||
Pixel select_color = white;
|
||||
if (select_color == bg)
|
||||
{
|
||||
text_select_color = white;
|
||||
select_color = black;
|
||||
}
|
||||
|
||||
_w = XtVaCreateManagedWidget(name, iconWidgetClass, p, GuiNiconMask, mask,
|
||||
XmNlabelPixmap, pixmap, GuiNisOpened, isOpened,
|
||||
XmNalignment, alignment,
|
||||
GuiNsuperNode, super_node,
|
||||
GuiNpixmapPlacement, pixmapPlacement,
|
||||
GuiNshrinkOutline, shrinkOutline,
|
||||
GuiNselectColorPersistent, true,
|
||||
GuiNselectColor, select_color,
|
||||
GuiNtextSelectColor, text_select_color,
|
||||
XmNlabelString, xm_string,
|
||||
GuiNfields, gui_fields,
|
||||
XmNbackground, bg,
|
||||
GuiNtopLabelString, xm_topString,
|
||||
GuiNbottomLabelString, xm_bottomString,
|
||||
XmNuserData, this, NULL);
|
||||
|
||||
StringFree(xm_string);
|
||||
StringFree(xm_topString);
|
||||
StringFree(xm_bottomString);
|
||||
// Delete s if style = details
|
||||
if (IconView() == DETAILS)
|
||||
delete s;
|
||||
_previous_style = IconView();
|
||||
XtAddCallback(_w, GuiNsingleClickCallback, &IconObj::SingleClickCB,
|
||||
(XtPointer) this);
|
||||
XtAddCallback(_w, GuiNdoubleClickCallback, &IconObj::DoubleClickCB,
|
||||
(XtPointer) this);
|
||||
InstallHelpCB();
|
||||
_stateIconName = NULL;
|
||||
}
|
||||
|
||||
void IconObj::StateIconFile(char *stateIconName)
|
||||
{
|
||||
delete _stateIconName;
|
||||
_stateIconName = STRDUP(stateIconName);
|
||||
SetStateIconFile(IconView());
|
||||
}
|
||||
|
||||
void IconObj::SetStateIconFile(IconStyle style)
|
||||
{
|
||||
Pixmap _statePixmap = XmUNSPECIFIED_PIXMAP;
|
||||
Pixmap _stateMask = XmUNSPECIFIED_PIXMAP;
|
||||
if (_stateIconName && style != NAME_ONLY)
|
||||
{
|
||||
char icon_type = 'p';
|
||||
if (depth == 1)
|
||||
icon_type = 'b';
|
||||
char *tmp = new char[strlen(_stateIconName) + 6];
|
||||
if (style == LARGE_ICON)
|
||||
sprintf(tmp, "%s.m.%cm", _stateIconName, icon_type);
|
||||
else
|
||||
sprintf(tmp, "%s.t.%cm", _stateIconName, icon_type);
|
||||
GetPixmaps(_w, tmp, &_statePixmap, &_stateMask);
|
||||
delete [] tmp;
|
||||
}
|
||||
XtVaSetValues(_w, GuiNstatePixmap, _statePixmap,
|
||||
GuiNstateIconMask, _stateMask, NULL);
|
||||
}
|
||||
|
||||
void IconObj::StateIconGravity(StateGravity stateGravity)
|
||||
{
|
||||
XtVaSetValues(_w, GuiNstateGravity, stateGravity, NULL);
|
||||
_state_gravity = stateGravity;
|
||||
}
|
||||
|
||||
int IconObj::NumberFields()
|
||||
{
|
||||
GuiIconFields gui_fields;
|
||||
XtVaGetValues(_w, GuiNfields, &gui_fields, NULL);
|
||||
if (gui_fields)
|
||||
return gui_fields->n_fields;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void IconObj::Field(int index, char **string, int *width, boolean *visible,
|
||||
boolean *active)
|
||||
{
|
||||
XmString s;
|
||||
Dimension wid;
|
||||
unsigned char alignment;
|
||||
Boolean draw_field;
|
||||
Boolean selected;
|
||||
Boolean _active;
|
||||
|
||||
GuiIconGetField(_w, index, &s, &wid, &alignment, &draw_field, &selected,
|
||||
&_active);
|
||||
if (width)
|
||||
*width = (int)wid;
|
||||
if (string)
|
||||
*string = StringExtract(s);
|
||||
if (visible)
|
||||
*visible = draw_field ? true : false;
|
||||
if (active)
|
||||
*active = _active ? true : false;
|
||||
}
|
||||
|
||||
void IconObj::Field(int index, char *string, int width, boolean visible,
|
||||
boolean active)
|
||||
{
|
||||
XmString s;
|
||||
Dimension wid;
|
||||
unsigned char alignment;
|
||||
Boolean draw_field;
|
||||
Boolean selected;
|
||||
Boolean _active;
|
||||
|
||||
GuiIconGetField(_w, index, &s, &wid, &alignment, &draw_field, &selected,
|
||||
&_active);
|
||||
draw_field = visible;
|
||||
_active = active;
|
||||
wid = (Dimension) width;
|
||||
s = StringCreate(string);
|
||||
GuiIconSetField(_w, index, s, wid, alignment, draw_field, selected, _active);
|
||||
}
|
||||
|
||||
void IconObj::BottomString(char *bottomString)
|
||||
{
|
||||
delete _bottomString;
|
||||
_bottomString = STRDUP(bottomString);
|
||||
XmString xm_string = StringCreate(bottomString);
|
||||
XtVaSetValues(_w, GuiNbottomLabelString, xm_string, NULL);
|
||||
StringFree(xm_string);
|
||||
}
|
||||
|
||||
void IconObj::TopString(char *topString)
|
||||
{
|
||||
delete _topString;
|
||||
_topString = STRDUP(topString);
|
||||
XmString xm_string = StringCreate(topString);
|
||||
XtVaSetValues(_w, GuiNtopLabelString, xm_string, NULL);
|
||||
StringFree(xm_string);
|
||||
}
|
||||
|
||||
void IconObj::IconFile(char *iconFile)
|
||||
{
|
||||
delete _iconFile;
|
||||
_iconFile = new char [strlen(iconFile) + 6];
|
||||
|
||||
// Get small and large pixmaps and masks
|
||||
char icon_type = 'p';
|
||||
if (depth == 1)
|
||||
icon_type = 'b';
|
||||
_iconFile = new char [strlen(iconFile) + 6];
|
||||
sprintf(_iconFile, "%s.t.%cm", iconFile, icon_type);
|
||||
GetPixmaps(_w, _iconFile, &_smallPixmap, &_smallMask);
|
||||
sprintf(_iconFile, "%s.m.%cm", iconFile, icon_type);
|
||||
GetPixmaps(_w, _iconFile, &_largePixmap, &_largeMask);
|
||||
|
||||
Pixmap vlargePixmap, vlargeMask;
|
||||
switch (IconView())
|
||||
{
|
||||
case VERY_LARGE_ICON:
|
||||
sprintf(_iconFile, "%s.l.%cm", iconFile, icon_type);
|
||||
GetPixmaps(_w, _iconFile, &vlargePixmap, &vlargeMask);
|
||||
XtVaSetValues(_w, XmNlabelPixmap, vlargePixmap, GuiNiconMask, vlargeMask,
|
||||
NULL);
|
||||
break;
|
||||
case LARGE_ICON:
|
||||
case MEDIUM_ICON:
|
||||
XtVaSetValues(_w, XmNlabelPixmap, _largePixmap, GuiNiconMask, _largeMask,
|
||||
NULL);
|
||||
break;
|
||||
case SMALL_ICON:
|
||||
case TINY_ICON:
|
||||
XtVaSetValues(_w, XmNlabelPixmap, _smallPixmap, GuiNiconMask, _smallMask,
|
||||
NULL);
|
||||
break;
|
||||
}
|
||||
strcpy(_iconFile, iconFile);
|
||||
}
|
||||
|
||||
void IconObj::SetDetail()
|
||||
{
|
||||
if (!_details)
|
||||
return;
|
||||
|
||||
char *name = new char [strlen(_name) + strlen(_details) + 3];
|
||||
|
||||
sprintf(name, "%s %s", _name, _details);
|
||||
XmString xm_string = StringCreate(name);
|
||||
XtVaSetValues(_w, XmNlabelString, xm_string, NULL);
|
||||
StringFree(xm_string);
|
||||
delete [] name;
|
||||
}
|
||||
|
||||
void IconObj::Details(char *details)
|
||||
{
|
||||
delete _details;
|
||||
_details = STRDUP(details);
|
||||
if (IconView() == DETAILS)
|
||||
SetDetail();
|
||||
}
|
||||
|
||||
boolean IconObj::SetName(char *_name)
|
||||
{
|
||||
return MotifUI::SetName(_name);
|
||||
}
|
||||
|
||||
boolean IconObj::SetOpen(boolean flag)
|
||||
{
|
||||
int pixmapPlacement;
|
||||
int alignment;
|
||||
int isOpened;
|
||||
|
||||
BaseUI *parent = Parent();
|
||||
if (ContainerView() == TREE)
|
||||
isOpened = flag;
|
||||
else if (parent && parent->UISubClass() == ICON_LIST ||
|
||||
parent->UISubClass() == SCROLLED_ICON_LIST)
|
||||
isOpened = true;
|
||||
else
|
||||
isOpened = flag;
|
||||
if (IconView() == LARGE_ICON)
|
||||
{
|
||||
if (ContainerView() == TREE ||
|
||||
(parent->UIClass() == CONTAINER &&
|
||||
parent->UISubClass() == SCROLLED_VERTICAL_ROW_COLUMN))
|
||||
{
|
||||
isOpened = true;
|
||||
pixmapPlacement = GuiPIXMAP_LEFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixmapPlacement = GuiPIXMAP_TOP;
|
||||
}
|
||||
if (isOpened)
|
||||
alignment = XmALIGNMENT_BEGINNING;
|
||||
else
|
||||
alignment = LargeIconJustification;
|
||||
}
|
||||
else
|
||||
{
|
||||
alignment = XmALIGNMENT_BEGINNING;
|
||||
pixmapPlacement = GuiPIXMAP_LEFT;
|
||||
}
|
||||
XtVaSetValues(_w, XmNalignment, alignment, GuiNisOpened, isOpened,
|
||||
GuiNpixmapPlacement, pixmapPlacement, NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean IconObj::SetIcon(IconStyle style)
|
||||
{
|
||||
Pixmap pixmap, mask;
|
||||
int shrinkOutline = false;
|
||||
int pixmapPlacement;
|
||||
int alignment;
|
||||
int isOpened;
|
||||
|
||||
BaseUI *parent = Parent();
|
||||
if (ContainerView() == TREE)
|
||||
isOpened = true;
|
||||
else if (parent && parent->UISubClass() == ICON_LIST ||
|
||||
parent->UISubClass() == SCROLLED_ICON_LIST)
|
||||
isOpened = true;
|
||||
else
|
||||
isOpened = Open();
|
||||
switch (style)
|
||||
{
|
||||
case NAME_ONLY:
|
||||
pixmapPlacement = GuiPIXMAP_LEFT;
|
||||
alignment = XmALIGNMENT_BEGINNING;
|
||||
if (_name)
|
||||
{
|
||||
pixmap = XmUNSPECIFIED_PIXMAP;
|
||||
mask = XmUNSPECIFIED_PIXMAP;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixmap = _smallPixmap;
|
||||
mask = _smallMask;
|
||||
}
|
||||
break;
|
||||
case VERY_LARGE_ICON:
|
||||
case LARGE_ICON:
|
||||
case MEDIUM_ICON:
|
||||
if (ContainerView() == TREE ||
|
||||
(parent->UIClass() == CONTAINER &&
|
||||
parent->UISubClass() == SCROLLED_VERTICAL_ROW_COLUMN))
|
||||
{
|
||||
isOpened = true;
|
||||
pixmapPlacement = GuiPIXMAP_LEFT;
|
||||
}
|
||||
else
|
||||
pixmapPlacement = GuiPIXMAP_TOP;
|
||||
if (isOpened)
|
||||
alignment = XmALIGNMENT_BEGINNING;
|
||||
else
|
||||
alignment = LargeIconJustification;
|
||||
shrinkOutline = true;
|
||||
if (style == VERY_LARGE_ICON)
|
||||
{
|
||||
if (depth == 1)
|
||||
strcat(_iconFile, ".l.bm");
|
||||
else
|
||||
strcat(_iconFile, ".l.pm");
|
||||
GetPixmaps(_w, _iconFile, &pixmap, &mask);
|
||||
_iconFile[strlen(_iconFile) - 5] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
pixmap = _largePixmap;
|
||||
mask = _largeMask;
|
||||
}
|
||||
break;
|
||||
case DETAILS:
|
||||
SetDetail();
|
||||
// no break
|
||||
case SMALL_ICON:
|
||||
case TINY_ICON:
|
||||
alignment = XmALIGNMENT_BEGINNING;
|
||||
pixmapPlacement = GuiPIXMAP_LEFT;
|
||||
pixmap = _smallPixmap;
|
||||
mask = _smallMask;
|
||||
break;
|
||||
}
|
||||
if (_previous_style == DETAILS)
|
||||
{
|
||||
XmString xm_string = StringCreate(_name);
|
||||
XtVaSetValues(_w, XmNlabelPixmap, pixmap, GuiNiconMask, mask,
|
||||
XmNlabelString, xm_string, XmNalignment, alignment,
|
||||
GuiNpixmapPlacement, pixmapPlacement,
|
||||
GuiNisOpened, isOpened,
|
||||
GuiNshrinkOutline, shrinkOutline, NULL);
|
||||
StringFree(xm_string);
|
||||
}
|
||||
else
|
||||
XtVaSetValues(_w, XmNlabelPixmap, pixmap, GuiNiconMask, mask,
|
||||
GuiNpixmapPlacement, pixmapPlacement,
|
||||
XmNalignment, alignment, GuiNisOpened, isOpened,
|
||||
GuiNshrinkOutline, shrinkOutline, NULL);
|
||||
|
||||
_previous_style = style;
|
||||
if (_stateIconName)
|
||||
SetStateIconFile(style);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void IconObj::SingleClickCB(Widget,
|
||||
XtPointer client_data,
|
||||
XtPointer)
|
||||
{
|
||||
IconObj *obj = (IconObj *) client_data;
|
||||
|
||||
if (!obj->Name())
|
||||
return;
|
||||
if (obj->Selected())
|
||||
obj->Selected(false);
|
||||
else
|
||||
obj->Selected(true);
|
||||
}
|
||||
|
||||
void IconObj::DoubleClickCB(Widget,
|
||||
XtPointer client_data,
|
||||
XtPointer)
|
||||
{
|
||||
IconObj *obj = (IconObj *) client_data;
|
||||
|
||||
if (obj->Name())
|
||||
{
|
||||
if (obj->Selected())
|
||||
obj->Selected(false);
|
||||
else
|
||||
obj->Selected(true);
|
||||
XmUpdateDisplay(obj->BaseWidget());
|
||||
}
|
||||
|
||||
if (obj->Open())
|
||||
obj->Open(false);
|
||||
else
|
||||
obj->Open(true);
|
||||
}
|
||||
116
cde/programs/dtprintinfo/libUI/MotifUI/IconObj.h
Normal file
116
cde/programs/dtprintinfo/libUI/MotifUI/IconObj.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/* $XConsortium: IconObj.h /main/3 1995/11/06 09:41:52 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef ICONOBJ_H
|
||||
#define ICONOBJ_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int name_width;
|
||||
int n_fields;
|
||||
int field_spacing;
|
||||
char **fields;
|
||||
int *fields_widths;
|
||||
LabelType *alignments;
|
||||
boolean *draw_fields;
|
||||
boolean *selected;
|
||||
boolean *active;
|
||||
} IconFieldsRec, *IconFields, **IconFieldsList;
|
||||
|
||||
typedef enum {
|
||||
NORTHWEST_GRAVITY,
|
||||
NORTH_GRAVITY,
|
||||
NORTHEAST_GRAVITY,
|
||||
WEST_GRAVITY,
|
||||
CENTER_GRAVITY,
|
||||
EAST_GRAVITY,
|
||||
SOUTHWEST_GRAVITY,
|
||||
SOUTH_GRAVITY,
|
||||
SOUTHEAST_GRAVITY
|
||||
} StateGravity;
|
||||
|
||||
class IconObj : public MotifUI {
|
||||
|
||||
private:
|
||||
|
||||
static void SingleClickCB(Widget, XtPointer, XtPointer);
|
||||
static void DoubleClickCB(Widget, XtPointer, XtPointer);
|
||||
|
||||
char *_details;
|
||||
char *_iconFile;
|
||||
char *_topString;
|
||||
char *_bottomString;
|
||||
IconStyle _previous_style;
|
||||
Pixmap _smallPixmap;
|
||||
Pixmap _smallMask;
|
||||
Pixmap _largePixmap;
|
||||
Pixmap _largeMask;
|
||||
IconFields fields;
|
||||
StateGravity _state_gravity;
|
||||
char *_stateIconName;
|
||||
|
||||
void SetDetail();
|
||||
void SetStateIconFile(IconStyle);
|
||||
void CreateIconObj(MotifUI *, char *, char *, char *, char *, char *,
|
||||
char *, IconFields);
|
||||
|
||||
protected:
|
||||
|
||||
// Override SetView and SetOpen for icon
|
||||
virtual boolean SetIcon(IconStyle);
|
||||
virtual boolean SetOpen(boolean);
|
||||
virtual boolean SetName(char *);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
IconObj(MotifUI *parent,
|
||||
char *name,
|
||||
char *icon,
|
||||
char *details = NULL,
|
||||
char *topString = NULL,
|
||||
char *bottomString = NULL,
|
||||
IconFields fields = NULL);
|
||||
|
||||
IconObj(char *category,
|
||||
MotifUI *parent,
|
||||
char *name,
|
||||
char *icon,
|
||||
char *details = NULL,
|
||||
char *topString = NULL,
|
||||
char *bottomString = NULL,
|
||||
IconFields fields = NULL);
|
||||
|
||||
~IconObj();
|
||||
|
||||
void Details(char *); // Set details
|
||||
char *Details() { return _details; } // Access details
|
||||
void TopString(char *); // Set top string
|
||||
char *TopString() { return _topString; } // Access top string
|
||||
void BottomString(char *); // Set bottom string
|
||||
char *BottomString() { return _bottomString; } // Access bottom string
|
||||
void IconFile(char *); // Set top string
|
||||
char *IconFile() { return _iconFile; } // Access top string
|
||||
void StateIconFile(char *); // Set top string
|
||||
char *StateIconFile() { return _stateIconName; }// Access top string
|
||||
void StateIconGravity(StateGravity);
|
||||
StateGravity StateIconGravity() { return _state_gravity; }
|
||||
void Field(int index, char *string, int width, boolean visible = true,
|
||||
boolean active = true);
|
||||
void Field(int index, char **string, int *width, boolean *visible,
|
||||
boolean *active);
|
||||
int NumberFields();
|
||||
|
||||
const UI_Class UIClass() { return ICON; }
|
||||
const char *const UIClassName() { return "IconObj"; }
|
||||
|
||||
};
|
||||
|
||||
#endif /* ICONOBJ_H */
|
||||
118
cde/programs/dtprintinfo/libUI/MotifUI/IconP.h
Normal file
118
cde/programs/dtprintinfo/libUI/MotifUI/IconP.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/* $XConsortium: IconP.h /main/4 1995/11/06 09:42:03 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* IconP.H - widget private header file
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _IconP_h
|
||||
#define _IconP_h
|
||||
|
||||
#include <Xm/XmP.h>
|
||||
#include <Xm/PrimitiveP.h>
|
||||
|
||||
#include "Icon.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define Max(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
typedef struct _IconClassPart {
|
||||
int reserved;
|
||||
} IconClassPart;
|
||||
|
||||
typedef struct _IconClassRec {
|
||||
CoreClassPart core_class;
|
||||
XmPrimitiveClassPart primitive_class;
|
||||
IconClassPart icon_class;
|
||||
} IconClassRec;
|
||||
|
||||
extern IconClassRec iconClassRec;
|
||||
|
||||
typedef struct _IconPart {
|
||||
/* Public Resources */
|
||||
XmString label;
|
||||
XmString top_label;
|
||||
XmString bottom_label;
|
||||
Pixmap pixmap;
|
||||
Pixmap mask;
|
||||
Pixmap state_pixmap;
|
||||
Pixmap state_mask;
|
||||
unsigned char state_gravity;
|
||||
Pixel select_color;
|
||||
XmFontList font;
|
||||
unsigned char alignment;
|
||||
unsigned char string_direction;
|
||||
unsigned char icon_placement;
|
||||
unsigned char icon_shadow_type;
|
||||
Boolean active;
|
||||
Boolean select_color_persistent;
|
||||
Boolean shrink_outline;
|
||||
Boolean word_wrap;
|
||||
Boolean selected;
|
||||
Boolean show_selected_pixmap;
|
||||
Boolean resize_width;
|
||||
Boolean resize_height;
|
||||
Dimension icon_shadow_thickness;
|
||||
Dimension icon_margin_thickness; /* margin around widget */
|
||||
XtCallbackList single_click_callback;
|
||||
XtCallbackList double_click_callback;
|
||||
GuiIconFields fields;
|
||||
|
||||
/* Private stuff */
|
||||
GC gc;
|
||||
GC stipple_gc;
|
||||
GC selected_fg_gc;
|
||||
GC selected_bg_gc;
|
||||
GC mask_gc;
|
||||
GC state_mask_gc;
|
||||
GC mask_stipple_gc;
|
||||
Pixel select_label_color;
|
||||
XmString wrapped_label;
|
||||
XmRegion shadow_region;
|
||||
XmRegion highlight_region;
|
||||
Position pixmap_x;
|
||||
Position pixmap_y;
|
||||
Position label_x;
|
||||
Position label_y;
|
||||
Position top_label_x;
|
||||
Position top_label_y;
|
||||
Position bottom_label_x;
|
||||
Position bottom_label_y;
|
||||
Position state_pixmap_x;
|
||||
Position state_pixmap_y;
|
||||
Dimension pixmap_width;
|
||||
Dimension pixmap_height;
|
||||
Dimension top_label_width;
|
||||
Dimension top_label_height;
|
||||
Dimension bottom_label_width;
|
||||
Dimension bottom_label_height;
|
||||
Dimension label_width;
|
||||
Dimension label_height;
|
||||
Dimension state_pixmap_width;
|
||||
Dimension state_pixmap_height;
|
||||
Time old_time;
|
||||
Boolean old_shrink_outline;
|
||||
} IconPart;
|
||||
|
||||
typedef struct _IconRec {
|
||||
CorePart core;
|
||||
XmPrimitivePart primitive;
|
||||
IconPart icon;
|
||||
} IconRec;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* Close scope of 'extern "C"' declaration which encloses file. */
|
||||
#endif
|
||||
|
||||
#endif /* _IconP_h */
|
||||
/* DON'T ADD ANYTHING AFTER THIS #endif */
|
||||
37
cde/programs/dtprintinfo/libUI/MotifUI/Imakefile
Normal file
37
cde/programs/dtprintinfo/libUI/MotifUI/Imakefile
Normal file
@@ -0,0 +1,37 @@
|
||||
XCOMM $XConsortium: Imakefile /main/4 1996/04/21 19:52:09 drk $
|
||||
#define DoNormalLib YES
|
||||
#define DoSharedLib NO
|
||||
#define DoDebugLib NO
|
||||
#define DoProfileLib NO
|
||||
#define LibName MotifUI
|
||||
#define LibHeaders NO
|
||||
#define LibInstall NO
|
||||
|
||||
#define CplusplusSource YES
|
||||
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
|
||||
|
||||
INCLUDES = -I. -I..
|
||||
|
||||
#ifdef RsArchitecture
|
||||
EXTRA_DEFINES = -DHAS_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
SRCS = Application.C Button.C ComboBoxObj.C \
|
||||
Container.C Debug.c Dialog.C \
|
||||
DtDND.C Group.C HelpSystem.C \
|
||||
Icon.c IconObj.C LabelObj.C \
|
||||
MainWindow.C Menu.C MenuBar.C \
|
||||
MotifThread.C MotifUI.C Prompt.C \
|
||||
ScaleObj.C Sep.C WorkArea.c
|
||||
|
||||
OBJS = Application.o Button.o ComboBoxObj.o \
|
||||
Container.o Debug.o Dialog.o \
|
||||
DtDND.o Group.o HelpSystem.o \
|
||||
Icon.o IconObj.o LabelObj.o \
|
||||
MainWindow.o Menu.o MenuBar.o \
|
||||
MotifThread.o MotifUI.o Prompt.o \
|
||||
ScaleObj.o Sep.o WorkArea.o
|
||||
|
||||
#include <Library.tmpl>
|
||||
|
||||
DependTarget()
|
||||
69
cde/programs/dtprintinfo/libUI/MotifUI/LabelObj.C
Normal file
69
cde/programs/dtprintinfo/libUI/MotifUI/LabelObj.C
Normal file
@@ -0,0 +1,69 @@
|
||||
/* $XConsortium: LabelObj.C /main/2 1995/07/17 14:06:12 drk $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "LabelObj.h"
|
||||
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/Frame.h>
|
||||
#include "WorkArea.h"
|
||||
|
||||
LabelObj::LabelObj(MotifUI *parent,
|
||||
char *name,
|
||||
LabelType style,
|
||||
boolean has_border)
|
||||
: MotifUI(parent, name, NULL)
|
||||
{
|
||||
XmString xm_string = StringCreate(name);
|
||||
Widget p, super_node;
|
||||
Pixel bg;
|
||||
int alignment;
|
||||
|
||||
switch (_style = style)
|
||||
{
|
||||
case LEFT_JUSTIFIED: alignment = XmALIGNMENT_BEGINNING; break;
|
||||
case CENTERED: alignment = XmALIGNMENT_CENTER; break;
|
||||
case RIGHT_JUSTIFIED: alignment = XmALIGNMENT_END; break;
|
||||
}
|
||||
|
||||
p = parent->InnerWidget();
|
||||
if (!XtIsComposite(p))
|
||||
p = XtParent(p);
|
||||
XtVaGetValues(p, XmNbackground, &bg, NULL);
|
||||
// If p is a icon then set superNode to it, otherwise set superNode to NULL
|
||||
super_node = parent->UIClass() == ICON ? parent->BaseWidget() : NULL;
|
||||
if (has_border)
|
||||
{
|
||||
_w = XtVaCreateManagedWidget(name, xmFrameWidgetClass, p,
|
||||
XmNbackground, bg, XmNuserData, this,
|
||||
XmNshadowType, XmSHADOW_OUT,
|
||||
XmNshadowThickness, shadowThickness, NULL);
|
||||
p = _w;
|
||||
}
|
||||
_label = XtVaCreateManagedWidget(name, xmLabelWidgetClass, p,
|
||||
XmNlabelString, xm_string,
|
||||
GuiNsuperNode, super_node,
|
||||
XmNalignment, alignment,
|
||||
XmNbackground, bg, XmNuserData, this, NULL);
|
||||
if (!has_border)
|
||||
_w = _label;
|
||||
|
||||
StringFree(xm_string);
|
||||
}
|
||||
|
||||
void LabelObj::LabelStyle(LabelType style)
|
||||
{
|
||||
int alignment;
|
||||
|
||||
switch (_style = style)
|
||||
{
|
||||
case LEFT_JUSTIFIED: alignment = XmALIGNMENT_BEGINNING; break;
|
||||
case CENTERED: alignment = XmALIGNMENT_CENTER; break;
|
||||
case RIGHT_JUSTIFIED: alignment = XmALIGNMENT_END; break;
|
||||
}
|
||||
XtVaSetValues(_label, XmNalignment, alignment, NULL);
|
||||
}
|
||||
36
cde/programs/dtprintinfo/libUI/MotifUI/LabelObj.h
Normal file
36
cde/programs/dtprintinfo/libUI/MotifUI/LabelObj.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/* $XConsortium: LabelObj.h /main/3 1995/11/06 09:42:24 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef LABELOBJ_H
|
||||
#define LABELOBJ_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
class LabelObj : public MotifUI {
|
||||
|
||||
private:
|
||||
|
||||
Widget _label;
|
||||
LabelType _style;
|
||||
|
||||
public:
|
||||
|
||||
LabelObj(MotifUI * parent,
|
||||
char *name,
|
||||
LabelType style = LEFT_JUSTIFIED,
|
||||
boolean has_border = false);
|
||||
|
||||
void LabelStyle(LabelType style);
|
||||
LabelType LabelStyle() { return _style; }
|
||||
const Widget InnerWidget() { return _label; }
|
||||
const UI_Class UIClass() { return LABEL; }
|
||||
const char *const UIClassName() { return "LabelObj"; }
|
||||
|
||||
};
|
||||
|
||||
#endif /* LABELOBJ_H */
|
||||
263
cde/programs/dtprintinfo/libUI/MotifUI/MainWindow.C
Normal file
263
cde/programs/dtprintinfo/libUI/MotifUI/MainWindow.C
Normal file
@@ -0,0 +1,263 @@
|
||||
/* $XConsortium: MainWindow.C /main/3 1995/11/06 09:42:36 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "Menu.h"
|
||||
#include "IconObj.h"
|
||||
#include "Button.h"
|
||||
#include "Sep.h"
|
||||
#include <Xm/MainW.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include "Icon.h"
|
||||
|
||||
|
||||
XtActionsRec MainWindow::actions[] =
|
||||
{
|
||||
{"PopupMenu", (XtActionProc) &MainWindow::KeyboardPopupMenu}
|
||||
};
|
||||
|
||||
class PopupMenuContainer : public MotifUI
|
||||
{
|
||||
public:
|
||||
|
||||
PopupMenuContainer(MotifUI *);
|
||||
};
|
||||
|
||||
PopupMenuContainer::PopupMenuContainer(MotifUI *parent) :
|
||||
MotifUI(parent, "PopupMenuContainer", NULL)
|
||||
{
|
||||
_w = parent->BaseWidget();
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(MotifUI *parent,
|
||||
char *name,
|
||||
char *widgetName,
|
||||
char *icon,
|
||||
char *icon_name)
|
||||
: MotifUI(parent, name, NULL, widgetName)
|
||||
{
|
||||
CreateMainWindow(parent, name, widgetName, icon, icon_name);
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(char *category,
|
||||
MotifUI *parent,
|
||||
char *name,
|
||||
char *widgetName,
|
||||
char *icon,
|
||||
char *icon_name)
|
||||
: MotifUI(parent, name, category, widgetName)
|
||||
{
|
||||
CreateMainWindow(parent, name, widgetName, icon, icon_name);
|
||||
}
|
||||
|
||||
void MainWindow::CreateMainWindow(MotifUI *parent, char * /*name*/,
|
||||
char *widgetName, char *_icon,
|
||||
char *_icon_name)
|
||||
{
|
||||
_w = XtVaCreateManagedWidget(widgetName, xmMainWindowWidgetClass,
|
||||
parent->BaseWidget(), NULL);
|
||||
XtAppAddActions(appContext, actions, XtNumber(actions));
|
||||
trans = XtParseTranslationTable("#override\n <Key> osfMenu: PopupMenu()");
|
||||
XtAddEventHandler(_w, ButtonPressMask, FALSE, PopupMenu, (XtPointer) this);
|
||||
XtOverrideTranslations(_w, trans);
|
||||
popups = new PopupMenuContainer(this);
|
||||
XtVaSetValues(_w, XmNuserData, this, NULL);
|
||||
LastPopupMenu = NULL;
|
||||
icon = NULL;
|
||||
icon_name = NULL;
|
||||
IconFile(_icon);
|
||||
IconName(_icon_name);
|
||||
InstallHelpCB();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete icon;
|
||||
delete icon_name;
|
||||
}
|
||||
|
||||
void MainWindow::IconFile(char *_icon)
|
||||
{
|
||||
if (_icon)
|
||||
{
|
||||
Pixmap pixmap, mask;
|
||||
GetPixmaps(_w, _icon, &pixmap, &mask);
|
||||
delete icon;
|
||||
if (pixmap != XmUNSPECIFIED_PIXMAP)
|
||||
{
|
||||
if (depth == 1)
|
||||
XtVaSetValues(XtParent(_w), XmNiconPixmap, pixmap, NULL);
|
||||
else
|
||||
XtVaSetValues(XtParent(_w), XmNiconPixmap, pixmap,
|
||||
(mask ? XmNiconMask : NULL), mask, NULL);
|
||||
icon = STRDUP(_icon);
|
||||
}
|
||||
else
|
||||
icon = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::IconName(char *_icon_name)
|
||||
{
|
||||
delete icon_name;
|
||||
if (!_icon_name)
|
||||
icon_name = STRDUP(Name());
|
||||
else
|
||||
icon_name = STRDUP(_icon_name);
|
||||
if (icon_name)
|
||||
XtVaSetValues(XtParent(_w), XmNiconName, icon_name, NULL);
|
||||
}
|
||||
|
||||
void MainWindow::SetWorkWindow(MotifUI *obj)
|
||||
{
|
||||
XtVaSetValues(_w, XmNworkWindow, obj->BaseWidget(), NULL);
|
||||
}
|
||||
|
||||
Button *MainWindow::AddAction(char *name, char *category,
|
||||
ButtonCallback callback,
|
||||
void *callback_data, char *mnemonic,
|
||||
char *acceleratorText, char *accelerator)
|
||||
{
|
||||
Menu *menu = (Menu *)popups->FindByCategory(category);
|
||||
if (!menu)
|
||||
{
|
||||
menu = new Menu(category, popups, true, "", "", NULL, POPUP_MENU);
|
||||
XtVaSetValues(menu->InnerWidget(), XmNpopupEnabled, False, NULL);
|
||||
}
|
||||
return new Button(category, menu, name, PUSH_BUTTON, callback, callback_data,
|
||||
mnemonic, acceleratorText, accelerator);
|
||||
}
|
||||
|
||||
void MainWindow::RegisterPopup(MotifUI *obj)
|
||||
{
|
||||
Menu *menu = (Menu *)popups->FindByCategory((char *)obj->Category());
|
||||
if (!menu)
|
||||
{
|
||||
menu = new Menu((char *)obj->Category(), popups, true, "", "",
|
||||
NULL, POPUP_MENU);
|
||||
XtVaSetValues(menu->InnerWidget(), XmNpopupEnabled, False, NULL);
|
||||
}
|
||||
XtAddEventHandler(obj->InnerWidget(), ButtonPressMask, FALSE,
|
||||
PopupMenu, (XtPointer) this);
|
||||
XtOverrideTranslations(obj->InnerWidget(), trans);
|
||||
XtVaSetValues(obj->InnerWidget(), XmNuserData, obj, NULL);
|
||||
if (obj->UIClass() == CONTAINER)
|
||||
{
|
||||
switch (obj->UISubClass())
|
||||
{
|
||||
case SCROLLED_CANVAS:
|
||||
case SCROLLED_FORM:
|
||||
case SCROLLED_VERTICAL_ROW_COLUMN:
|
||||
case SCROLLED_HORIZONTAL_ROW_COLUMN:
|
||||
case SCROLLED_PANE:
|
||||
case SCROLLED_WORK_AREA:
|
||||
case SCROLLED_ICON_LIST:
|
||||
XtAddEventHandler(XtParent(obj->InnerWidget()), ButtonPressMask, FALSE,
|
||||
PopupMenu, (XtPointer) this);
|
||||
XtOverrideTranslations(XtParent(obj->InnerWidget()), trans);
|
||||
XtVaSetValues(XtParent(obj->InnerWidget()), XmNuserData, obj, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::AddSep(char *category)
|
||||
{
|
||||
Menu *menu = (Menu *)popups->FindByCategory(category);
|
||||
if (!menu)
|
||||
{
|
||||
menu = new Menu(category, popups, true, "", "", NULL, POPUP_MENU);
|
||||
XtVaSetValues(menu->InnerWidget(), XmNpopupEnabled, False, NULL);
|
||||
}
|
||||
new Sep(category, menu);
|
||||
}
|
||||
|
||||
void MainWindow::KeyboardPopupMenu(Widget widget, XEvent *event,
|
||||
String * /*params*/,
|
||||
Cardinal * /*num_params*/)
|
||||
{
|
||||
Widget focus_widget;
|
||||
|
||||
if (!(focus_widget = XmGetFocusWidget(widget)))
|
||||
focus_widget = widget;
|
||||
|
||||
MotifUI *obj;
|
||||
MainWindow *window;
|
||||
XtVaGetValues(focus_widget, XmNuserData, &obj, NULL);
|
||||
window = (MainWindow *) obj;
|
||||
while (window->UIClass() != MAIN_WINDOW)
|
||||
window = (MainWindow *) window->Parent();
|
||||
window->PostMenu(obj, event);
|
||||
}
|
||||
|
||||
void MainWindow::PopupMenu(Widget widget, XtPointer client_data,
|
||||
XEvent *event, Boolean * /*continued*/)
|
||||
{
|
||||
XRectangle pixmap_rect, label_rect;
|
||||
XButtonEvent * ev;
|
||||
Window child, parent, root;
|
||||
int root_x, root_y, win_x, win_y;
|
||||
unsigned int modMask;
|
||||
Display * display = XtDisplay(widget);
|
||||
|
||||
ev = (XButtonEvent *) event;
|
||||
if (ev->button != MotifUI::bMenuButton)
|
||||
return;
|
||||
child = XtWindow(widget);
|
||||
while (child)
|
||||
{
|
||||
parent = child;
|
||||
XQueryPointer(display, parent, &root,
|
||||
&child, &root_x, &root_y, &win_x, &win_y, &modMask);
|
||||
}
|
||||
if (XtWindowToWidget(display, parent))
|
||||
widget = XtWindowToWidget(display, parent);
|
||||
|
||||
MainWindow *window = (MainWindow *) client_data;
|
||||
MotifUI *obj;
|
||||
XtVaGetValues(widget, XmNuserData, &obj, NULL);
|
||||
if (!obj)
|
||||
obj = window;
|
||||
if (obj->UIClass() == ICON)
|
||||
{
|
||||
GuiIconGetRects(widget, &pixmap_rect, &label_rect);
|
||||
if (!(PointInRect(pixmap_rect, win_x, win_y) ||
|
||||
PointInRect(label_rect, win_x, win_y)))
|
||||
{
|
||||
XtVaGetValues(XtParent(widget), XmNuserData, &obj, NULL);
|
||||
}
|
||||
}
|
||||
window->PostMenu(obj, event);
|
||||
}
|
||||
|
||||
void MainWindow::PostMenu(MotifUI *obj, XEvent *event)
|
||||
{
|
||||
BaseUI *popup_menu = popups->FindByCategory((char *)obj->Category());
|
||||
if (LastPopupMenu)
|
||||
XtVaSetValues(LastPopupMenu, XmNpopupEnabled, False, NULL);
|
||||
Widget widget = NULL;
|
||||
if (popup_menu)
|
||||
{
|
||||
popup_menu->Name((char *)obj->Name());
|
||||
PopupObject = obj;
|
||||
PopupObjectUniqueID = PopupObject->UniqueID();
|
||||
widget = ((MotifUI *) popup_menu)->BaseWidget();
|
||||
XtVaSetValues(widget, XmNpopupEnabled, True, NULL);
|
||||
if (event->type == ButtonPress)
|
||||
{
|
||||
XmMenuPosition(widget, (XButtonPressedEvent *) event);
|
||||
XtManageChild(widget);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PopupObject = NULL;
|
||||
PopupObjectUniqueID = 0;
|
||||
}
|
||||
LastPopupMenu = widget;
|
||||
}
|
||||
78
cde/programs/dtprintinfo/libUI/MotifUI/MainWindow.h
Normal file
78
cde/programs/dtprintinfo/libUI/MotifUI/MainWindow.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/* $XConsortium: MainWindow.h /main/3 1995/11/06 09:42:47 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
class PopupMenuContainer;
|
||||
class Button;
|
||||
|
||||
class MainWindow : public MotifUI {
|
||||
|
||||
friend void KeyboardPopupMenu(Widget, XEvent *, String *, Cardinal *);
|
||||
friend void PopupMenu(Widget, XtPointer, XEvent *, Boolean *);
|
||||
|
||||
protected:
|
||||
|
||||
static XtActionsRec actions[];
|
||||
static void KeyboardPopupMenu(Widget, XEvent *, String *, Cardinal *);
|
||||
static void PopupMenu(Widget, XtPointer, XEvent *, Boolean *);
|
||||
|
||||
void PostMenu(MotifUI *, XEvent *);
|
||||
PopupMenuContainer *popups;
|
||||
Widget LastPopupMenu;
|
||||
XtTranslations trans;
|
||||
char *icon;
|
||||
char *icon_name;
|
||||
|
||||
// Derived classes must define Initialize
|
||||
virtual void Initialize() = 0;
|
||||
|
||||
void CreateMainWindow(MotifUI *parent, char *name, char *widgetName,
|
||||
char *icon, char *icon_name);
|
||||
|
||||
public:
|
||||
|
||||
MainWindow(MotifUI *parent,
|
||||
char *name,
|
||||
char *widgetName,
|
||||
char *icon = NULL,
|
||||
char *icon_name = NULL);
|
||||
|
||||
MainWindow(char *category,
|
||||
MotifUI *parent,
|
||||
char *name,
|
||||
char *widgetName,
|
||||
char *icon = NULL,
|
||||
char *icon_name = NULL);
|
||||
virtual ~MainWindow();
|
||||
|
||||
void IconFile(char *icon);
|
||||
void IconName(char *icon_name);
|
||||
char *IconFile() { return icon; }
|
||||
char *IconName() { return icon_name; }
|
||||
|
||||
Button *AddAction(char *name, char *category, ButtonCallback callback,
|
||||
void *callback_data, char *mnemonic = NULL,
|
||||
char *acceleratorText = NULL, char *accelerator = NULL);
|
||||
void RegisterPopup(MotifUI *object);
|
||||
void AddSep(char *category);
|
||||
|
||||
void SetWorkWindow(MotifUI *obj);
|
||||
|
||||
BaseUI *PopupObject;
|
||||
int PopupObjectUniqueID;
|
||||
|
||||
const UI_Class UIClass() { return MAIN_WINDOW; }
|
||||
const char *const UIClassName() { return "MainWindow"; }
|
||||
|
||||
};
|
||||
|
||||
#endif /* MAINWINDOW_H */
|
||||
136
cde/programs/dtprintinfo/libUI/MotifUI/Menu.C
Normal file
136
cde/programs/dtprintinfo/libUI/MotifUI/Menu.C
Normal file
@@ -0,0 +1,136 @@
|
||||
/* $XConsortium: Menu.C /main/3 1995/11/06 09:42:58 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "Menu.h"
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/Separator.h>
|
||||
#include <Xm/CascadeB.h>
|
||||
|
||||
Menu::Menu(MotifUI *parent, char *name, char *mnemonic, MenuType menu_type)
|
||||
: MotifUI(parent, name, NULL)
|
||||
{
|
||||
CreateMenu(parent->InnerWidget(), name, NULL, mnemonic, menu_type);
|
||||
}
|
||||
|
||||
Menu::Menu(MotifUI *parent, boolean /*has_title*/, char *title,
|
||||
char *name, char *mnemonic, MenuType menu_type)
|
||||
: MotifUI(parent, name, NULL)
|
||||
{
|
||||
CreateMenu(parent->InnerWidget(), name, NULL, mnemonic, menu_type);
|
||||
CreateTitle(parent->InnerWidget(), NULL, title);
|
||||
}
|
||||
|
||||
Menu::Menu(char *category, MotifUI *parent, char *name, char *mnemonic,
|
||||
MenuType menu_type)
|
||||
: MotifUI(parent, name, category)
|
||||
{
|
||||
CreateMenu(parent->InnerWidget(), name, category, mnemonic, menu_type);
|
||||
}
|
||||
|
||||
Menu::Menu(char *category, MotifUI *parent, boolean /*has_title*/,
|
||||
char *title, char *name, char *mnemonic, MenuType menu_type)
|
||||
: MotifUI(parent, name, category)
|
||||
{
|
||||
CreateMenu(parent->InnerWidget(), name, category, mnemonic, menu_type);
|
||||
CreateTitle(parent->InnerWidget(), category, title);
|
||||
}
|
||||
|
||||
void Menu::SetRadio(boolean flag)
|
||||
{
|
||||
XtVaSetValues(_w, XmNradioBehavior, flag, NULL);
|
||||
}
|
||||
|
||||
boolean Menu::SetActivity(boolean flag)
|
||||
{
|
||||
XtSetSensitive(_cascadeButton, flag);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Menu::CreateMenu(Widget parent, char *name, char * /*category*/,
|
||||
char *mnemonic, MenuType menu_type)
|
||||
{
|
||||
XmString xm_string = StringCreate(name);
|
||||
|
||||
_title = NULL;
|
||||
_sep = NULL;
|
||||
switch (_menu_type = menu_type)
|
||||
{
|
||||
case PULLDOWN_MENU:
|
||||
_w = XmCreatePulldownMenu(parent, "pulldown_menu", NULL, 0);
|
||||
break;
|
||||
case OPTION_MENU:
|
||||
_w = XmCreateOptionMenu(parent, "option_menu", NULL, 0);
|
||||
break;
|
||||
case POPUP_MENU:
|
||||
_w = XmCreatePopupMenu(parent, "popup_menu", NULL, 0);
|
||||
XtVaSetValues(_w, XmNwhichButton, MotifUI::bMenuButton, NULL);
|
||||
break;
|
||||
}
|
||||
if (_menu_type != POPUP_MENU)
|
||||
{
|
||||
_cascadeButton = XtVaCreateManagedWidget("cascadeButton",
|
||||
xmCascadeButtonWidgetClass,
|
||||
parent,
|
||||
XmNlabelString, xm_string,
|
||||
XmNsubMenuId, _w, NULL);
|
||||
if (depth == 1)
|
||||
{
|
||||
Pixel bg;
|
||||
XtVaGetValues(_cascadeButton, XmNbackground, &bg, NULL);
|
||||
if (bg == white)
|
||||
{
|
||||
XtVaSetValues(_w, XmNuserData, (XtPointer)this, NULL);
|
||||
XtAddCallback(_w, XmNmapCallback, &(Menu::MapCB), NULL);
|
||||
XtAddCallback(_w, XmNunmapCallback, &(Menu::MapCB), NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
StringFree(xm_string);
|
||||
if (mnemonic)
|
||||
XtVaSetValues(_cascadeButton,
|
||||
XmNmnemonic, XStringToKeysym(mnemonic), NULL);
|
||||
InstallHelpCB();
|
||||
}
|
||||
|
||||
void Menu::CreateTitle(Widget /*parent*/, char *title, char * /*category*/)
|
||||
{
|
||||
XmString xm_string = StringCreate(title);
|
||||
|
||||
if (_title)
|
||||
XtVaSetValues(_title, XmNlabelString, xm_string, NULL);
|
||||
else
|
||||
{
|
||||
_title = XtVaCreateManagedWidget("title", xmLabelWidgetClass, _w,
|
||||
XmNlabelString, xm_string, NULL);
|
||||
_sep = XtVaCreateManagedWidget("separator", xmSeparatorWidgetClass, _w,
|
||||
XmNseparatorType, XmDOUBLE_LINE, NULL);
|
||||
}
|
||||
StringFree(xm_string);
|
||||
}
|
||||
|
||||
boolean Menu::SetName(char *name)
|
||||
{
|
||||
CreateTitle(_w, name, (char *) Category());
|
||||
return true;
|
||||
}
|
||||
|
||||
void Menu::MapCB(Widget w, XtPointer /*client_data*/, XtPointer /*call_data*/)
|
||||
{
|
||||
Menu *obj;
|
||||
XtVaGetValues(w, XmNuserData, &obj, NULL);
|
||||
Pixel fg;
|
||||
XtVaGetValues(obj->_cascadeButton, XmNforeground, &fg, NULL);
|
||||
if (fg == white)
|
||||
fg = black;
|
||||
else
|
||||
fg = white;
|
||||
XtVaSetValues(obj->_cascadeButton, XmNforeground, fg, NULL);
|
||||
}
|
||||
66
cde/programs/dtprintinfo/libUI/MotifUI/Menu.h
Normal file
66
cde/programs/dtprintinfo/libUI/MotifUI/Menu.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* $XConsortium: Menu.h /main/3 1995/11/06 09:43:09 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef MENU_H
|
||||
#define MENU_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
class Menu : public MotifUI {
|
||||
|
||||
static void MapCB(Widget, XtPointer, XtPointer);
|
||||
friend void MapCB(Widget, XtPointer, XtPointer);
|
||||
|
||||
protected:
|
||||
|
||||
Widget _cascadeButton;
|
||||
Widget _title;
|
||||
Widget _sep;
|
||||
MenuType _menu_type;
|
||||
|
||||
void CreateMenu(Widget parent, char *name, char *category,
|
||||
char *mnemonic, MenuType menu_type);
|
||||
void CreateTitle(Widget, char *title, char *category);
|
||||
boolean SetName(char *name);
|
||||
|
||||
public:
|
||||
|
||||
Menu(char *category,
|
||||
MotifUI *parent,
|
||||
char *name,
|
||||
char *mnemonic = NULL,
|
||||
MenuType menu_type = PULLDOWN_MENU);
|
||||
Menu(char *category,
|
||||
MotifUI *parent,
|
||||
boolean has_title,
|
||||
char *title,
|
||||
char *name,
|
||||
char *mnemonic = NULL,
|
||||
MenuType menu_type = PULLDOWN_MENU);
|
||||
Menu(MotifUI *parent,
|
||||
char *name,
|
||||
char *mnemonic = NULL,
|
||||
MenuType menu_type = PULLDOWN_MENU);
|
||||
Menu(MotifUI *parent,
|
||||
boolean has_title,
|
||||
char *title,
|
||||
char *name,
|
||||
char *mnemonic = NULL,
|
||||
MenuType menu_type = PULLDOWN_MENU);
|
||||
|
||||
void SetRadio(boolean flag);
|
||||
Widget GetCascade() { return _cascadeButton; }
|
||||
boolean SetActivity(boolean flag);
|
||||
|
||||
const UI_Class UIClass() { return MENU; }
|
||||
const int UISubClass() { return _menu_type; }
|
||||
const char *const UIClassName() { return "Menu"; }
|
||||
|
||||
};
|
||||
|
||||
#endif /* MENU_H */
|
||||
33
cde/programs/dtprintinfo/libUI/MotifUI/MenuBar.C
Normal file
33
cde/programs/dtprintinfo/libUI/MotifUI/MenuBar.C
Normal file
@@ -0,0 +1,33 @@
|
||||
/* $XConsortium: MenuBar.C /main/2 1995/07/17 14:06:37 drk $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "MenuBar.h"
|
||||
#include "Menu.h"
|
||||
#include <Xm/RowColumn.h>
|
||||
|
||||
MenuBar::MenuBar(MotifUI *parent,
|
||||
char *name)
|
||||
: MotifUI(parent, name, NULL)
|
||||
{
|
||||
_w = XtVaCreateManagedWidget("menuBar", xmRowColumnWidgetClass,
|
||||
parent->InnerWidget(),
|
||||
XmNrowColumnType, XmMENU_BAR, NULL);
|
||||
|
||||
XtVaSetValues(parent->InnerWidget(), XmNmenuBar, _w, NULL);
|
||||
InstallHelpCB();
|
||||
}
|
||||
|
||||
void MenuBar::SetHelpMenu(Menu *menu)
|
||||
{
|
||||
XtVaSetValues(_w, XmNmenuHelpWidget, menu->GetCascade(), NULL);
|
||||
}
|
||||
|
||||
MenuBar::~MenuBar()
|
||||
{
|
||||
// Empty
|
||||
}
|
||||
30
cde/programs/dtprintinfo/libUI/MotifUI/MenuBar.h
Normal file
30
cde/programs/dtprintinfo/libUI/MotifUI/MenuBar.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/* $XConsortium: MenuBar.h /main/3 1995/11/06 09:43:42 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef MENUBAR_H
|
||||
#define MENUBAR_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
class Menu;
|
||||
|
||||
class MenuBar : public MotifUI {
|
||||
|
||||
public:
|
||||
|
||||
MenuBar(MotifUI *parent,
|
||||
char *name = "MenuBar");
|
||||
virtual ~MenuBar();
|
||||
void SetHelpMenu(Menu *);
|
||||
|
||||
const UI_Class UIClass() { return MENU_BAR; }
|
||||
const char *const UIClassName() { return "MenuBar"; }
|
||||
|
||||
};
|
||||
|
||||
#endif /* MENUBAR_H */
|
||||
161
cde/programs/dtprintinfo/libUI/MotifUI/MotifThread.C
Normal file
161
cde/programs/dtprintinfo/libUI/MotifUI/MotifThread.C
Normal file
@@ -0,0 +1,161 @@
|
||||
/* $TOG: MotifThread.C /main/3 1998/07/24 16:15:54 mgreess $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "MotifThread.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/wait.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
MotifThread::MotifThread(MotifUI *obj, const char *cmd,
|
||||
MotifThreadCallback cb, ThreadCallback cb1,
|
||||
int buf_len)
|
||||
{
|
||||
CreateThread(obj, cmd, -1, -1, cb, cb1, buf_len);
|
||||
}
|
||||
|
||||
MotifThread::MotifThread(MotifUI *obj, int pid, int fd,
|
||||
MotifThreadCallback cb, ThreadCallback cb1,
|
||||
int buf_len)
|
||||
{
|
||||
CreateThread(obj, NULL, pid, fd, cb, cb1, buf_len);
|
||||
}
|
||||
|
||||
MotifThread::MotifThread(MotifUI *obj, int socket,
|
||||
MotifThreadCallback cb, ThreadCallback cb1,
|
||||
int buf_len)
|
||||
{
|
||||
CreateThread(obj, NULL, -1, socket, cb, cb1, buf_len);
|
||||
}
|
||||
|
||||
void MotifThread::CreateThread(MotifUI *_obj, const char *cmd, int _pid,
|
||||
int _fd, MotifThreadCallback _cb,
|
||||
ThreadCallback _cb1, int _buf_len)
|
||||
{
|
||||
int m_stdout[2];
|
||||
|
||||
cb = _cb;
|
||||
cb1 = _cb1;
|
||||
obj = _obj;
|
||||
output = NULL;
|
||||
out1 = NULL;
|
||||
inputID = 0;
|
||||
if (_buf_len < 0)
|
||||
buf_len = 512;
|
||||
else
|
||||
buf_len = _buf_len;
|
||||
if (cmd)
|
||||
{
|
||||
fd = -1;
|
||||
if (pipe(m_stdout) < 0)
|
||||
{
|
||||
output = strdup(strerror(errno));
|
||||
status = -1;
|
||||
Halt();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((pid = fork()) == 0) // In Child
|
||||
{
|
||||
close(m_stdout[0]);
|
||||
close(1);
|
||||
dup(m_stdout[1]);
|
||||
close(m_stdout[1]);
|
||||
|
||||
execlp("/bin/ksh", "ksh", "-c", cmd, NULL);
|
||||
|
||||
char *msg = strerror(errno);
|
||||
write(1, msg, strlen(msg));
|
||||
exit(-1);
|
||||
}
|
||||
else if (pid == -1)
|
||||
{
|
||||
close(m_stdout[0]);
|
||||
output = strdup(strerror(errno));
|
||||
status = -1;
|
||||
Halt();
|
||||
return;
|
||||
}
|
||||
|
||||
close(m_stdout[1]);
|
||||
fd = m_stdout[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
pid = (pid_t)_pid;
|
||||
fd = _fd;
|
||||
}
|
||||
fcntl(fd, F_SETFL, O_NDELAY);
|
||||
|
||||
len = buf_len;
|
||||
ctr = 1;
|
||||
output = (char *)malloc(buf_len);
|
||||
out1 = output;
|
||||
out2 = out1 + buf_len - 1;
|
||||
|
||||
long mask = XtInputReadMask | XtInputExceptMask;
|
||||
inputID = XtAppAddInput(obj->appContext, fd, (XtPointer)mask,
|
||||
&(MotifThread::GetOutputCB), this);
|
||||
}
|
||||
|
||||
MotifThread::~MotifThread()
|
||||
{
|
||||
if (fd >= 0)
|
||||
Halt();
|
||||
if (inputID)
|
||||
XtRemoveInput(inputID);
|
||||
free(output);
|
||||
}
|
||||
|
||||
void MotifThread::Halt()
|
||||
{
|
||||
if (out1)
|
||||
*out1 = '\0';
|
||||
close(fd);
|
||||
fd = -1;
|
||||
if (pid != -1)
|
||||
{
|
||||
pid_t w;
|
||||
while ((w = wait(&status)) != pid && w != -1);
|
||||
status = (status >> 8) & 0xFF;
|
||||
}
|
||||
else
|
||||
status = 0;
|
||||
(*cb)(this, obj, cb1);
|
||||
}
|
||||
|
||||
void MotifThread::GetOutput()
|
||||
{
|
||||
int n = read(fd, out1, len);
|
||||
if (n == len)
|
||||
{
|
||||
len = buf_len;
|
||||
ctr++;
|
||||
output = (char *)realloc(output, (ctr * len));
|
||||
out1 = output + ((ctr - 1) * len);
|
||||
out2 = out1 + len - 1;
|
||||
}
|
||||
else if (n > 0)
|
||||
{
|
||||
out1 += n;
|
||||
len = out2 - out1 + 1;
|
||||
}
|
||||
else
|
||||
Halt();
|
||||
}
|
||||
|
||||
void MotifThread::GetOutputCB(XtPointer closure, int * /*fid*/,
|
||||
XtInputId * /*id*/)
|
||||
{
|
||||
MotifThread *obj = (MotifThread *)closure;
|
||||
obj->GetOutput();
|
||||
}
|
||||
55
cde/programs/dtprintinfo/libUI/MotifUI/MotifThread.h
Normal file
55
cde/programs/dtprintinfo/libUI/MotifUI/MotifThread.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* $XConsortium: MotifThread.h /main/3 1995/11/06 09:43:54 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef MOTIF_THREAD_H
|
||||
#define MOTIF_THREAD_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
class MotifThread;
|
||||
class MotifUI;
|
||||
|
||||
typedef void (*MotifThreadCallback) (MotifThread *, BaseUI *, ThreadCallback);
|
||||
|
||||
class MotifThread
|
||||
{
|
||||
|
||||
friend void GetOutputCB(XtPointer, int *fid, XtInputId *id);
|
||||
|
||||
private:
|
||||
MotifThreadCallback cb;
|
||||
ThreadCallback cb1;
|
||||
XtInputId inputID;
|
||||
pid_t pid;
|
||||
int buf_len;
|
||||
int fd;
|
||||
int len;
|
||||
int ctr;
|
||||
char *out1;
|
||||
char *out2;
|
||||
MotifUI *obj;
|
||||
|
||||
static void GetOutputCB(XtPointer, int *fid, XtInputId *id);
|
||||
void GetOutput();
|
||||
void CreateThread(MotifUI *, const char *, int, int,
|
||||
MotifThreadCallback, ThreadCallback, int);
|
||||
|
||||
public:
|
||||
char *output;
|
||||
int status;
|
||||
MotifThread(MotifUI *, const char *cmd, MotifThreadCallback, ThreadCallback,
|
||||
int buf_len);
|
||||
MotifThread(MotifUI *, int pid, int fd, MotifThreadCallback, ThreadCallback,
|
||||
int buf_len);
|
||||
MotifThread(MotifUI *, int socket, MotifThreadCallback, ThreadCallback,
|
||||
int buf_len);
|
||||
~MotifThread();
|
||||
void Halt();
|
||||
};
|
||||
|
||||
#endif // MOTIF_THREAD_H
|
||||
987
cde/programs/dtprintinfo/libUI/MotifUI/MotifUI.C
Normal file
987
cde/programs/dtprintinfo/libUI/MotifUI/MotifUI.C
Normal file
@@ -0,0 +1,987 @@
|
||||
/* $TOG: MotifUI.C /main/8 1998/08/03 08:59:09 mgreess $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "MotifUI.h"
|
||||
#include "Menu.h"
|
||||
#include "Dialog.h"
|
||||
#include "Icon.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <X11/cursorfont.h>
|
||||
#include <X11/IntrinsicP.h>
|
||||
|
||||
#ifdef NO_CDE
|
||||
#include "xpm.h"
|
||||
#include <X11/keysym.h>
|
||||
#else
|
||||
#include <Dt/xpm.h>
|
||||
#include <Dt/Help.h>
|
||||
#endif
|
||||
|
||||
#include <Xm/ToggleB.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/ScrolledW.h>
|
||||
#include <Xm/MainW.h>
|
||||
|
||||
PixmapLookupList MotifUI::pixmap_table = NULL;
|
||||
XtAppContext MotifUI::appContext = NULL;
|
||||
XmFontList MotifUI::userFont = NULL;
|
||||
Display * MotifUI::display = NULL;
|
||||
Widget MotifUI::topLevel;
|
||||
Window MotifUI::root;
|
||||
Font MotifUI::font;
|
||||
Pixel MotifUI::black;
|
||||
Pixel MotifUI::white;
|
||||
int MotifUI::shadowThickness;
|
||||
int MotifUI::depth;
|
||||
int MotifUI::bMenuButton;
|
||||
int MotifUI::n_pixmaps = 0;
|
||||
PointerCursor MotifUI::pointer_style = LEFT_SLANTED_ARROW_CURSOR;
|
||||
|
||||
|
||||
MotifUI::MotifUI(MotifUI *parent,
|
||||
const char *name,
|
||||
const char *category,
|
||||
const char *widgetName)
|
||||
: BaseUI(parent, name, category)
|
||||
{
|
||||
_w = NULL;
|
||||
if (widgetName)
|
||||
_widgetName = STRDUP(widgetName);
|
||||
else
|
||||
_widgetName = STRDUP(name);
|
||||
}
|
||||
|
||||
MotifUI::~MotifUI()
|
||||
{
|
||||
if (_w)
|
||||
XtRemoveCallback(_w, XmNdestroyCallback, &MotifUI::WidgetDestroyCB,
|
||||
(XtPointer) this);
|
||||
delete _widgetName;
|
||||
}
|
||||
|
||||
void MotifUI::ThreadCB(MotifThread *_thread, BaseUI *obj, ThreadCallback cb)
|
||||
{
|
||||
(*cb)(obj, _thread->output, _thread->status);
|
||||
delete _thread;
|
||||
}
|
||||
|
||||
void MotifUI::Thread(const char *cmd, ThreadCallback cb, int buf_len)
|
||||
|
||||
{
|
||||
new MotifThread(this, cmd, &(MotifUI::ThreadCB), cb, buf_len);
|
||||
}
|
||||
|
||||
void MotifUI::Thread(int pid, int fd, ThreadCallback cb, int buf_len)
|
||||
{
|
||||
new MotifThread(this, pid, fd, &(MotifUI::ThreadCB), cb, buf_len);
|
||||
}
|
||||
|
||||
void MotifUI::Thread(int socket, ThreadCallback cb, int buf_len)
|
||||
{
|
||||
new MotifThread(this, socket, &(MotifUI::ThreadCB), cb, buf_len);
|
||||
}
|
||||
|
||||
void MotifUI::SetFocus()
|
||||
{
|
||||
DoSetFocus(_w);
|
||||
}
|
||||
|
||||
void MotifUI::DoSetFocus(Widget w)
|
||||
{
|
||||
XmProcessTraversal(w, XmTRAVERSE_CURRENT);
|
||||
}
|
||||
|
||||
boolean MotifUI::DoIsVisible()
|
||||
{
|
||||
boolean rc = true;
|
||||
if (_w)
|
||||
{
|
||||
if (UIClass() == APPLICATION)
|
||||
{
|
||||
if (XtIsRealized(_w))
|
||||
{
|
||||
XWindowAttributes attributes;
|
||||
XGetWindowAttributes(display, XtWindow(_w), &attributes);
|
||||
if (attributes.map_state == IsUnmapped)
|
||||
rc = false;
|
||||
}
|
||||
}
|
||||
else if (XmGetVisibility(_w) == XmVISIBILITY_FULLY_OBSCURED)
|
||||
rc = false;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
void MotifUI::DoMakeVisible()
|
||||
{
|
||||
Widget sw = XtParent(_w);
|
||||
if (sw && !XmIsScrolledWindow(sw))
|
||||
sw = XtParent(sw);
|
||||
if (sw && !XmIsScrolledWindow(sw))
|
||||
sw = XtParent(sw);
|
||||
if (sw && XmIsScrolledWindow(sw) && !XmIsMainWindow(sw))
|
||||
XmScrollVisible(sw, _w, 0, 0);
|
||||
}
|
||||
|
||||
void MotifUI::DoContextualHelp()
|
||||
{
|
||||
Widget context_widget, shell;
|
||||
#ifdef NO_CDE
|
||||
XEvent event;
|
||||
static Cursor cursor = (Cursor) NULL;
|
||||
|
||||
if (cursor == (Cursor) NULL)
|
||||
cursor = XCreateFontCursor(display, XC_question_arrow);
|
||||
#endif
|
||||
|
||||
BaseUI *window = this;
|
||||
while (window->UIClass() != MAIN_WINDOW)
|
||||
window = window->Parent();
|
||||
shell = ((MotifUI *)window)->_w;
|
||||
#ifdef NO_CDE
|
||||
context_widget = XmTrackingEvent(shell, cursor, False, &event);
|
||||
|
||||
if (event.type == KeyPress || event.type == KeyRelease)
|
||||
{
|
||||
int offset;
|
||||
KeySym keySym;
|
||||
|
||||
// Look for ESC key press and stop if we get one
|
||||
if (event.xkey.state & ShiftMask)
|
||||
offset = 1;
|
||||
else
|
||||
offset = 0;
|
||||
|
||||
keySym = XLookupKeysym((XKeyEvent *)&event, offset);
|
||||
if (keySym == XK_Escape)
|
||||
return;
|
||||
}
|
||||
|
||||
if (context_widget != NULL)
|
||||
{
|
||||
#else
|
||||
int returnVal = DtHelpReturnSelectedWidgetId(shell, NULL, &context_widget);
|
||||
if (returnVal == DtHELP_SELECT_VALID)
|
||||
{
|
||||
#endif
|
||||
XmAnyCallbackStruct cb;
|
||||
|
||||
cb.reason = XmCR_HELP;
|
||||
#ifdef NO_CDE
|
||||
cb.event = &event;
|
||||
#endif
|
||||
while (context_widget != NULL)
|
||||
{
|
||||
// If there is no help at this widget, back track to find help
|
||||
if (XtHasCallbacks(context_widget, XmNhelpCallback) ==
|
||||
XtCallbackHasSome)
|
||||
{
|
||||
XtCallCallbacks(context_widget, XmNhelpCallback, &cb);
|
||||
break;
|
||||
}
|
||||
else
|
||||
context_widget = XtParent(context_widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MotifUI::WidgetHelpCB(Widget,
|
||||
XtPointer clientData,
|
||||
XtPointer)
|
||||
{
|
||||
MotifUI * obj = (MotifUI *) clientData;
|
||||
|
||||
obj->HandleHelpRequest();
|
||||
}
|
||||
|
||||
void MotifUI::WidgetDestroyCB(Widget,
|
||||
XtPointer clientData,
|
||||
XtPointer)
|
||||
{
|
||||
MotifUI * obj = (MotifUI *) clientData;
|
||||
|
||||
obj->WidgetDestroyed();
|
||||
}
|
||||
|
||||
void MotifUI::WidgetDestroyed()
|
||||
{
|
||||
_w = NULL;
|
||||
delete _widgetName;
|
||||
}
|
||||
|
||||
void MotifUI::DoRefresh()
|
||||
{
|
||||
if (_w)
|
||||
XmUpdateDisplay(_w);
|
||||
}
|
||||
|
||||
void MotifUI::DoToFront()
|
||||
{
|
||||
if (_w)
|
||||
{
|
||||
if (XtIsShell(XtParent(_w)))
|
||||
XRaiseWindow(display, XtWindow(XtParent(_w)));
|
||||
else
|
||||
XRaiseWindow(display, XtWindow(_w));
|
||||
}
|
||||
}
|
||||
|
||||
void MotifUI::InstallDestroyCB()
|
||||
{
|
||||
if (_w)
|
||||
XtAddCallback(_w, XmNdestroyCallback, &MotifUI::WidgetDestroyCB,
|
||||
(XtPointer) this);
|
||||
}
|
||||
|
||||
void MotifUI::InstallHelpCB()
|
||||
{
|
||||
if (!_w)
|
||||
return;
|
||||
|
||||
if (UIClass() == MENU && UISubClass() != POPUP_MENU)
|
||||
XtAddCallback(((Menu*)this)->GetCascade(), XmNhelpCallback,
|
||||
&MotifUI::WidgetHelpCB, (XtPointer) this);
|
||||
else
|
||||
XtAddCallback(_w, XmNhelpCallback, &MotifUI::WidgetHelpCB,
|
||||
(XtPointer) this);
|
||||
}
|
||||
|
||||
boolean MotifUI::SetSelected(boolean flag)
|
||||
{
|
||||
if (!_w)
|
||||
return false;
|
||||
|
||||
if (GuiIsIcon(_w))
|
||||
XtVaSetValues(_w, GuiNselected, flag, NULL);
|
||||
else if (XmIsToggleButton(_w))
|
||||
XmToggleButtonSetState(_w, flag, False);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean MotifUI::SetName(char *name)
|
||||
{
|
||||
if (!InnerWidget())
|
||||
return false;
|
||||
|
||||
XmString xm_string = StringCreate(name);
|
||||
XtVaSetValues(InnerWidget(), XmNlabelString, xm_string, NULL);
|
||||
StringFree(xm_string);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean MotifUI::SetActivity(boolean flag)
|
||||
{
|
||||
if (!_w)
|
||||
return false;
|
||||
|
||||
if (GuiIsIcon(_w))
|
||||
XtVaSetValues(_w, GuiNactive, flag, NULL);
|
||||
else
|
||||
XtSetSensitive(_w, flag);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean MotifUI::SetVisiblity(boolean flag)
|
||||
{
|
||||
if (!_w)
|
||||
return false;
|
||||
|
||||
if (flag)
|
||||
XtManageChild(_w);
|
||||
else
|
||||
XtUnmanageChild(_w);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MotifUI::GetResources(const XtResourceList resources,
|
||||
const int numResources)
|
||||
{
|
||||
if (_w && resources)
|
||||
XtGetSubresources(XtParent(_w), (XtPointer) this, _widgetName,
|
||||
className(), resources, numResources, NULL, 0);
|
||||
}
|
||||
|
||||
void MotifUI::SetDefaultResources(const Widget,
|
||||
const String *resources)
|
||||
{
|
||||
XrmDatabase rdb = NULL;
|
||||
int i;
|
||||
|
||||
rdb = XrmGetStringDatabase("");
|
||||
|
||||
i = 0;
|
||||
while (resources[i])
|
||||
{
|
||||
char *buf = new char[1000];
|
||||
|
||||
sprintf(buf, "%s%s", _name, resources[i]);
|
||||
XrmPutLineResource(&rdb, buf);
|
||||
i++;
|
||||
|
||||
delete [] buf;
|
||||
}
|
||||
if (rdb)
|
||||
{
|
||||
XrmMergeDatabases(XtDatabase(display), &rdb);
|
||||
XrmSetDatabase(display, rdb);
|
||||
}
|
||||
}
|
||||
|
||||
void MotifUI::NotifyDelete(BaseUI *obj)
|
||||
{
|
||||
MotifUI *p = (MotifUI *) obj;
|
||||
if (p->_w)
|
||||
{
|
||||
XtRemoveCallback(_w, XmNdestroyCallback, &MotifUI::WidgetDestroyCB,
|
||||
(XtPointer) this);
|
||||
XtDestroyWidget(p->_w);
|
||||
p->_w = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void MotifUI::Width(int width)
|
||||
{
|
||||
XtVaSetValues(this->BaseWidget(), XmNwidth, width, NULL);
|
||||
}
|
||||
|
||||
int MotifUI::Width()
|
||||
{
|
||||
Dimension w;
|
||||
XtVaGetValues(this->BaseWidget(), XmNwidth, &w, NULL);
|
||||
return (int) w;
|
||||
}
|
||||
|
||||
void MotifUI::Height(int height)
|
||||
{
|
||||
XtVaSetValues(this->BaseWidget(), XmNheight, height, NULL);
|
||||
}
|
||||
|
||||
int MotifUI::Height()
|
||||
{
|
||||
Dimension h;
|
||||
XtVaGetValues(this->BaseWidget(), XmNheight, &h, NULL);
|
||||
return (int) h;
|
||||
}
|
||||
|
||||
void MotifUI::WidthHeight(int width, int height)
|
||||
{
|
||||
XtVaSetValues(this->BaseWidget(), XmNwidth, width, XmNheight, height, NULL);
|
||||
}
|
||||
|
||||
void MotifUI::WidthHeight(int *width, int *height)
|
||||
{
|
||||
Dimension w, h;
|
||||
|
||||
XtVaGetValues(this->BaseWidget(), XmNwidth, &w, XmNheight, &h, NULL);
|
||||
*width = (int) w;
|
||||
*height = (int) h;
|
||||
}
|
||||
|
||||
void MotifUI::AttachAll(int offset)
|
||||
{
|
||||
XtVaSetValues(this->BaseWidget(),
|
||||
XmNtopAttachment, XmATTACH_NONE,
|
||||
XmNbottomAttachment, XmATTACH_NONE,
|
||||
XmNleftAttachment, XmATTACH_NONE,
|
||||
XmNrightAttachment, XmATTACH_NONE,
|
||||
NULL);
|
||||
XtVaSetValues(this->BaseWidget(),
|
||||
XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, offset,
|
||||
XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, offset,
|
||||
XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, offset,
|
||||
XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, offset,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void MotifUI::AttachTop(int offset)
|
||||
{
|
||||
XtVaSetValues(this->BaseWidget(), XmNtopAttachment, XmATTACH_NONE, NULL);
|
||||
XtVaSetValues(this->BaseWidget(), XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNtopOffset, offset, NULL);
|
||||
}
|
||||
|
||||
void MotifUI::AttachBottom(int offset)
|
||||
{
|
||||
XtVaSetValues(this->BaseWidget(), XmNbottomAttachment, XmATTACH_NONE, NULL);
|
||||
XtVaSetValues(this->BaseWidget(), XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNbottomOffset, offset, NULL);
|
||||
}
|
||||
|
||||
void MotifUI::AttachLeft(int offset)
|
||||
{
|
||||
XtVaSetValues(this->BaseWidget(), XmNleftAttachment, XmATTACH_NONE, NULL);
|
||||
XtVaSetValues(this->BaseWidget(), XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNleftOffset, offset, NULL);
|
||||
}
|
||||
|
||||
void MotifUI::AttachRight(int offset)
|
||||
{
|
||||
XtVaSetValues(this->BaseWidget(), XmNrightAttachment, XmATTACH_NONE, NULL);
|
||||
XtVaSetValues(this->BaseWidget(), XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNrightOffset, offset, NULL);
|
||||
}
|
||||
|
||||
void MotifUI::AttachTop(BaseUI *obj, int offset, boolean opposite)
|
||||
{
|
||||
XtVaSetValues(this->BaseWidget(), XmNtopAttachment, XmATTACH_NONE, NULL);
|
||||
if (obj)
|
||||
{
|
||||
Widget w = ((MotifUI *)obj)->BaseWidget();
|
||||
int attachment;
|
||||
if (opposite)
|
||||
attachment = XmATTACH_OPPOSITE_WIDGET;
|
||||
else
|
||||
attachment = XmATTACH_WIDGET;
|
||||
|
||||
XtVaSetValues(this->BaseWidget(), XmNtopAttachment, attachment,
|
||||
XmNtopWidget, w, XmNtopOffset, offset, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void MotifUI::AttachBottom(BaseUI *obj, int offset, boolean opposite)
|
||||
{
|
||||
XtVaSetValues(this->BaseWidget(), XmNbottomAttachment, XmATTACH_NONE, NULL);
|
||||
if (obj)
|
||||
{
|
||||
Widget w = ((MotifUI *)obj)->BaseWidget();
|
||||
int attachment;
|
||||
if (opposite)
|
||||
attachment = XmATTACH_OPPOSITE_WIDGET;
|
||||
else
|
||||
attachment = XmATTACH_WIDGET;
|
||||
|
||||
XtVaSetValues(this->BaseWidget(), XmNbottomAttachment, attachment,
|
||||
XmNbottomWidget, w, XmNbottomOffset, offset, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void MotifUI::AttachLeft(BaseUI *obj, int offset, boolean opposite)
|
||||
{
|
||||
XtVaSetValues(this->BaseWidget(), XmNleftAttachment, XmATTACH_NONE, NULL);
|
||||
if (obj)
|
||||
{
|
||||
int attachment;
|
||||
if (opposite)
|
||||
attachment = XmATTACH_OPPOSITE_WIDGET;
|
||||
else
|
||||
attachment = XmATTACH_WIDGET;
|
||||
Widget w = ((MotifUI *)obj)->BaseWidget();
|
||||
XtVaSetValues(this->BaseWidget(), XmNleftAttachment, attachment,
|
||||
XmNleftWidget, w, XmNleftOffset, offset, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void MotifUI::AttachRight(BaseUI *obj, int offset, boolean opposite)
|
||||
{
|
||||
XtVaSetValues(this->BaseWidget(), XmNrightAttachment, XmATTACH_NONE, NULL);
|
||||
if (obj)
|
||||
{
|
||||
Widget w = ((MotifUI *)obj)->BaseWidget();
|
||||
int attachment;
|
||||
if (opposite)
|
||||
attachment = XmATTACH_OPPOSITE_WIDGET;
|
||||
else
|
||||
attachment = XmATTACH_WIDGET;
|
||||
|
||||
XtVaSetValues(this->BaseWidget(), XmNrightAttachment, attachment,
|
||||
XmNrightWidget, w, XmNrightOffset, offset, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void MotifUI::StringWidthHeight(const char *string, int *width, int *height)
|
||||
{
|
||||
Dimension w, h;
|
||||
|
||||
XmString xm_string = StringCreate((char *)string);
|
||||
XmStringExtent(userFont, xm_string, &w, &h);
|
||||
*width = w;
|
||||
*height = h;
|
||||
StringFree(xm_string);
|
||||
}
|
||||
|
||||
int MotifUI::StringWidth(const char *string)
|
||||
{
|
||||
int dummy;
|
||||
int width;
|
||||
StringWidthHeight(string, &width, &dummy);
|
||||
return width;
|
||||
}
|
||||
|
||||
int MotifUI::StringHeight(const char *string)
|
||||
{
|
||||
int dummy;
|
||||
int height;
|
||||
StringWidthHeight(string, &dummy, &height);
|
||||
return height;
|
||||
}
|
||||
|
||||
boolean MotifUI::SetOrder(int new_position)
|
||||
{
|
||||
if (XmIsRowColumn(((MotifUI *)Parent())->InnerWidget()))
|
||||
XtVaSetValues(BaseWidget(), XmNpositionIndex, new_position, NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
void MotifUI::Dump(boolean verbose,
|
||||
int level)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
BaseUI::Dump(true, level);
|
||||
|
||||
int i;
|
||||
for (i = -2; i < level; i++) printf(" ");
|
||||
printf("BaseWidget : %08lx\n", _w);
|
||||
}
|
||||
else
|
||||
BaseUI::Dump(false, level);
|
||||
}
|
||||
|
||||
// Time out stuff
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TimeOutCallback fp;
|
||||
BaseUI *obj;
|
||||
void *callback_data;
|
||||
} TimeOutCallbackData;
|
||||
|
||||
static void
|
||||
ObjectTimeProc(XtPointer callback_data, XtIntervalId * /*id*/)
|
||||
{
|
||||
TimeOutCallbackData *data = (TimeOutCallbackData *) callback_data;
|
||||
(*data->fp)(data->obj, data->callback_data);
|
||||
delete data;
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
void MotifUI::SetAddTimeOut(TimeOutCallback timeoutCB,
|
||||
void *callback_data,
|
||||
long interval)
|
||||
{
|
||||
if (!_w)
|
||||
return;
|
||||
|
||||
TimeOutCallbackData * data = new TimeOutCallbackData;
|
||||
data->fp = timeoutCB;
|
||||
data->obj = this;
|
||||
data->callback_data = callback_data;
|
||||
XtAppAddTimeOut(appContext, (unsigned long) interval, ObjectTimeProc, data);
|
||||
}
|
||||
|
||||
void MotifUI::FillBackground(Widget widget, Pixmap pixmap, Pixmap mask)
|
||||
{
|
||||
static Pixmap temp = 0L;
|
||||
static GC gc = 0L;
|
||||
static unsigned int old_width = 0, old_height = 0, old_depth = 0;
|
||||
unsigned int width, height, junk, dep;
|
||||
Window root;
|
||||
XGCValues xgc;
|
||||
|
||||
XGetGeometry(display, pixmap, &root, (int *) &junk,
|
||||
(int *) &junk, &width, &height, &junk, &dep);
|
||||
if (temp &&
|
||||
(old_width < width || old_height < height || old_depth != dep))
|
||||
{
|
||||
// Free resources
|
||||
XFreeGC(display, gc);
|
||||
XFreePixmap(display, temp);
|
||||
temp = 0L;
|
||||
gc = 0L;
|
||||
}
|
||||
|
||||
old_width = width;
|
||||
old_height = height;
|
||||
old_depth = dep;
|
||||
if (dep == 1 && UIClass() == MAIN_WINDOW)
|
||||
XtVaGetValues(widget, XmNforeground, &xgc.foreground, NULL);
|
||||
else
|
||||
XtVaGetValues(widget, XmNbackground, &xgc.foreground, NULL);
|
||||
if (!temp)
|
||||
{
|
||||
temp = XCreatePixmap(display, RootWindowOfScreen(XtScreen(widget)),
|
||||
width, height, dep);
|
||||
xgc.function = GXcopy;
|
||||
gc = XCreateGC(display, pixmap, GCForeground|GCFunction, &xgc);
|
||||
}
|
||||
else
|
||||
XSetForeground(display, gc, xgc.foreground);
|
||||
|
||||
XFillRectangle(display, temp, gc, 0, 0, width, height);
|
||||
if (mask != XmUNSPECIFIED_PIXMAP)
|
||||
XSetClipMask(display, gc, mask);
|
||||
else
|
||||
XSetClipMask(display, gc, None);
|
||||
XCopyArea(display, pixmap, temp, gc, 0, 0, width, height, 0, 0);
|
||||
XSetClipMask(display, gc, None);
|
||||
XCopyArea(display, temp, pixmap, gc, 0, 0, width, height, 0, 0);
|
||||
}
|
||||
|
||||
// Pixmap caching utility
|
||||
void MotifUI::GetPixmaps(Widget w,
|
||||
char *name,
|
||||
Pixmap *pixmap,
|
||||
Pixmap *mask)
|
||||
{
|
||||
// Try to find pixmap in cache
|
||||
PixmapLookupList pixmaps = pixmap_table;
|
||||
int i;
|
||||
for (i = 0; i < n_pixmaps; i++, pixmaps++)
|
||||
if (!strcmp((**pixmaps).name, name))
|
||||
{
|
||||
*pixmap = (**pixmaps).pixmap;
|
||||
if (mask)
|
||||
*mask = (**pixmaps).mask;
|
||||
return;
|
||||
}
|
||||
|
||||
Pixmap _mask;
|
||||
char *s;
|
||||
SubstitutionRec subs[1];
|
||||
char *bmPath;
|
||||
char *PIXMAP_DIR = "/usr/dt/appconfig/icons/%L/%B:"
|
||||
"/usr/dt/appconfig/icons/C/%B:"
|
||||
"/usr/include/X11/bitmaps/%B";
|
||||
|
||||
if (*name == '/')
|
||||
s = name;
|
||||
else
|
||||
{
|
||||
#ifdef NO_CDE
|
||||
if ((s = getenv("XBMLANGPATH")) && *s)
|
||||
#else
|
||||
if ((s = getenv("XMICONSEARCHPATH")) && *s)
|
||||
#endif
|
||||
{
|
||||
bmPath = new char [strlen(s) + strlen(PIXMAP_DIR) + 2];
|
||||
sprintf(bmPath, "%s:%s", PIXMAP_DIR, s);
|
||||
}
|
||||
else
|
||||
bmPath = PIXMAP_DIR;
|
||||
subs[0].match = 'B';
|
||||
subs[0].substitution = name;
|
||||
s = XtFindFile(bmPath, subs, XtNumber(subs), NULL);
|
||||
if (bmPath != PIXMAP_DIR)
|
||||
delete [] bmPath;
|
||||
}
|
||||
|
||||
struct stat statbuf;
|
||||
if (!s || stat(s, &statbuf) < 0)
|
||||
{
|
||||
*pixmap = XmUNSPECIFIED_PIXMAP;
|
||||
if (mask)
|
||||
*mask = XmUNSPECIFIED_PIXMAP;
|
||||
return;
|
||||
}
|
||||
|
||||
int len = strlen(s);
|
||||
if (!strcmp(s + len - 3, ".pm"))
|
||||
{
|
||||
XpmAttributes attributes;
|
||||
memset((char *)&attributes, 0, sizeof(XpmAttributes));
|
||||
#ifdef NO_CDE
|
||||
XpmReadFileToPixmap(display, root, s, pixmap, &_mask, &attributes);
|
||||
#else
|
||||
_DtXpmReadFileToPixmap(display, root, s, pixmap, &_mask, &attributes);
|
||||
#endif
|
||||
|
||||
if (_mask)
|
||||
FillBackground(w, *pixmap, _mask);
|
||||
#ifdef NO_CDE
|
||||
XpmFreeAttributes(&attributes);
|
||||
#else
|
||||
_DtXpmFreeAttributes(&attributes);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UIClass() == MAIN_WINDOW)
|
||||
*pixmap = XmGetPixmapByDepth(XtScreen(w), s, white, black, depth);
|
||||
else
|
||||
*pixmap = XmGetPixmapByDepth(XtScreen(w), s, black, white, depth);
|
||||
char *s1 = new char [len + 3];
|
||||
strcpy(s1, s);
|
||||
strcpy(s1 + len - 3, "_m.bm");
|
||||
if (stat(s1, &statbuf) < 0)
|
||||
_mask = XmUNSPECIFIED_PIXMAP;
|
||||
else
|
||||
{
|
||||
_mask = XmGetPixmapByDepth(XtScreen(w), s1, white, black, 1);
|
||||
FillBackground(w, *pixmap, _mask);
|
||||
}
|
||||
delete [] s1;
|
||||
}
|
||||
if (mask)
|
||||
*mask = _mask;
|
||||
if (s != name)
|
||||
XtFree(s);
|
||||
|
||||
// Add pixmap to table
|
||||
if (!(n_pixmaps % 8))
|
||||
{
|
||||
pixmaps = new PixmapLookup [n_pixmaps + 8];
|
||||
for (i = 0; i < n_pixmaps; i++)
|
||||
pixmaps[i] = pixmap_table[i];
|
||||
for (i = n_pixmaps; i < n_pixmaps + 8; i++)
|
||||
pixmaps[i] = new PixmapLookupStruct;
|
||||
delete []pixmap_table;
|
||||
pixmap_table = pixmaps;
|
||||
}
|
||||
pixmap_table[n_pixmaps]->name = strdup(name);
|
||||
pixmap_table[n_pixmaps]->pixmap = *pixmap;
|
||||
pixmap_table[n_pixmaps]->mask = _mask;
|
||||
n_pixmaps++;
|
||||
}
|
||||
|
||||
// Cursor Shape support
|
||||
|
||||
#define time32_width 32
|
||||
#define time32_height 32
|
||||
#define time32_x_hot 15
|
||||
#define time32_y_hot 15
|
||||
static unsigned char time32_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
|
||||
0x8c, 0x00, 0x00, 0x31, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
|
||||
0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
|
||||
0x8c, 0x00, 0x00, 0x31, 0x0c, 0x7f, 0xfe, 0x30, 0x0c, 0xfe, 0x7f, 0x30,
|
||||
0x0c, 0xfc, 0x3f, 0x30, 0x0c, 0xf8, 0x1f, 0x30, 0x0c, 0xe0, 0x07, 0x30,
|
||||
0x0c, 0x80, 0x01, 0x30, 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x60, 0x06, 0x30,
|
||||
0x0c, 0x18, 0x18, 0x30, 0x0c, 0x04, 0x20, 0x30, 0x0c, 0x02, 0x40, 0x30,
|
||||
0x0c, 0x01, 0x80, 0x30, 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x80, 0x01, 0x32,
|
||||
0x4c, 0xc0, 0x03, 0x32, 0x4c, 0xf0, 0x1f, 0x32, 0x4c, 0xff, 0xff, 0x32,
|
||||
0xcc, 0xff, 0xff, 0x33, 0x8c, 0xff, 0xff, 0x31, 0xfe, 0xff, 0xff, 0x7f,
|
||||
0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
#define time32m_width 32
|
||||
#define time32m_height 32
|
||||
static unsigned char time32m_bits[] = {
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xcf, 0x00, 0x00, 0xf3, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
|
||||
0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
|
||||
0xce, 0x00, 0x00, 0x73, 0x8e, 0x7f, 0xfe, 0x71, 0x0e, 0xff, 0xff, 0x70,
|
||||
0x0e, 0xfe, 0x7f, 0x70, 0x0e, 0xfc, 0x3f, 0x70, 0x0e, 0xf8, 0x1f, 0x70,
|
||||
0x0e, 0xe0, 0x07, 0x70, 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0x78, 0x1e, 0x70,
|
||||
0x0e, 0x1c, 0x38, 0x70, 0x0e, 0x06, 0x60, 0x70, 0x0e, 0x03, 0xc0, 0x70,
|
||||
0x8e, 0x01, 0x80, 0x71, 0xce, 0x00, 0x00, 0x73, 0x6e, 0x80, 0x01, 0x76,
|
||||
0x6e, 0xc0, 0x03, 0x76, 0x6e, 0xf0, 0x1f, 0x76, 0x6e, 0xff, 0xff, 0x76,
|
||||
0xee, 0xff, 0xff, 0x77, 0xcf, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
|
||||
#define time16_x_hot 7
|
||||
#define time16_y_hot 7
|
||||
#define time16_width 16
|
||||
#define time16_height 16
|
||||
static unsigned char time16_bits[] = {
|
||||
0x00, 0x00, 0xfe, 0x7f, 0x14, 0x28, 0x14, 0x28, 0x14, 0x28, 0x24, 0x24,
|
||||
0x44, 0x22, 0x84, 0x21, 0x84, 0x21, 0x44, 0x22, 0x24, 0x24, 0x14, 0x28,
|
||||
0x94, 0x29, 0xd4, 0x2b, 0xfe, 0x7f, 0x00, 0x00};
|
||||
|
||||
#define time16m_width 16
|
||||
#define time16m_height 16
|
||||
static unsigned char time16m_bits[] = {
|
||||
0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
|
||||
0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
|
||||
0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff};
|
||||
|
||||
Cursor MotifUI::InitHourGlassCursor()
|
||||
{
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int xHotspot;
|
||||
unsigned int yHotspot;
|
||||
Pixmap pixmap;
|
||||
Pixmap maskPixmap;
|
||||
XColor xcolors[2];
|
||||
char * bits;
|
||||
char * maskBits;
|
||||
Cursor cursor = None;
|
||||
|
||||
if (XQueryBestCursor(display, root, 32, 32, &width, &height))
|
||||
{
|
||||
if ((width >= 32) && (height >= 32))
|
||||
{
|
||||
width = time32_width;
|
||||
height = time32_height;
|
||||
bits = (char *)time32_bits;
|
||||
maskBits = (char *)time32m_bits;
|
||||
xHotspot = time32_x_hot;
|
||||
yHotspot = time32_y_hot;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = time16_width;
|
||||
height = time16_height;
|
||||
bits = (char *)time16_bits;
|
||||
maskBits = (char *)time16m_bits;
|
||||
xHotspot = time16_x_hot;
|
||||
yHotspot = time16_y_hot;
|
||||
}
|
||||
|
||||
pixmap = XCreateBitmapFromData(display, root, bits, width, height);
|
||||
|
||||
maskPixmap = XCreateBitmapFromData(display, root, maskBits,
|
||||
width, height);
|
||||
xcolors[0].pixel = black;
|
||||
xcolors[1].pixel = white;
|
||||
|
||||
XQueryColors(display,
|
||||
DefaultColormapOfScreen(DefaultScreenOfDisplay (display)),
|
||||
xcolors, 2);
|
||||
cursor = XCreatePixmapCursor(display, pixmap, maskPixmap,
|
||||
&(xcolors[0]), &(xcolors[1]), xHotspot, yHotspot);
|
||||
XFreePixmap(display, pixmap);
|
||||
XFreePixmap(display, maskPixmap);
|
||||
}
|
||||
return cursor;
|
||||
}
|
||||
|
||||
PointerCursor MotifUI::PointerShape()
|
||||
{
|
||||
return pointer_style;
|
||||
}
|
||||
|
||||
void MotifUI::PointerShape(PointerCursor style)
|
||||
{
|
||||
static Cursor left = (Cursor) 0L;
|
||||
static Cursor right = (Cursor) 0L;
|
||||
static Cursor watch = (Cursor) 0L;
|
||||
static Cursor hour_glass = (Cursor) 0L;
|
||||
static Cursor ibeam = (Cursor) 0L;
|
||||
static Cursor cross_hair = (Cursor) 0L;
|
||||
|
||||
if (!_w)
|
||||
return;
|
||||
|
||||
Cursor cursor;
|
||||
switch (pointer_style = style)
|
||||
{
|
||||
case LEFT_SLANTED_ARROW_CURSOR:
|
||||
if (!left)
|
||||
left = XCreateFontCursor(display, XC_left_ptr);
|
||||
cursor = left;
|
||||
break;
|
||||
case RIGHT_SLANTED_ARROW_CURSOR:
|
||||
if (!right)
|
||||
right = XCreateFontCursor(display, XC_right_ptr);
|
||||
cursor = right;
|
||||
break;
|
||||
case WATCH_CURSOR:
|
||||
if (!watch)
|
||||
watch = XCreateFontCursor(display, XC_watch);
|
||||
cursor = watch;
|
||||
break;
|
||||
case HOUR_GLASS_CURSOR:
|
||||
if (!hour_glass)
|
||||
hour_glass = InitHourGlassCursor();
|
||||
cursor = hour_glass;
|
||||
break;
|
||||
case IBEAM_CURSOR:
|
||||
if (!ibeam)
|
||||
ibeam = XCreateFontCursor(display, XC_xterm);
|
||||
cursor = ibeam;
|
||||
break;
|
||||
case CROSS_HAIRS_CURSOR:
|
||||
if (!cross_hair)
|
||||
cross_hair = XCreateFontCursor(display, XC_crosshair);
|
||||
cursor = cross_hair;
|
||||
break;
|
||||
default: cursor = None; break;
|
||||
}
|
||||
|
||||
if (XtIsRealized(_w))
|
||||
XDefineCursor(display, XtWindow(_w), cursor);
|
||||
}
|
||||
|
||||
static int G_width;
|
||||
|
||||
static void VerbosePass1(Widget w, int level)
|
||||
{
|
||||
int i;
|
||||
if (level == 0)
|
||||
G_width = 0;
|
||||
int new_width = (level * 3) + strlen(XrmQuarkToString(w->core.xrm_name)) +
|
||||
strlen(w->core.widget_class->core_class.class_name) + 3;
|
||||
if (new_width > G_width)
|
||||
G_width = new_width;
|
||||
if (XtIsWidget(w))
|
||||
for (i = 0; i < w->core.num_popups; i++)
|
||||
VerbosePass1(w->core.popup_list[i], level + 1);
|
||||
if (XtIsComposite(w))
|
||||
{
|
||||
CompositeWidget cw = (CompositeWidget) w;
|
||||
for (i = 0; i < cw->composite.num_children; i++)
|
||||
VerbosePass1(cw->composite.children[i], level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void MotifUI::DumpWidget(Widget w, boolean verbose, int level)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < level; i++)
|
||||
printf(" ");
|
||||
printf("%s : %s", XrmQuarkToString(w->core.xrm_name),
|
||||
w->core.widget_class->core_class.class_name);
|
||||
if (verbose)
|
||||
{
|
||||
int n = (level * 3) + strlen(XrmQuarkToString(w->core.xrm_name)) +
|
||||
strlen(w->core.widget_class->core_class.class_name) + 3;
|
||||
for ( ; n < G_width; n++)
|
||||
printf(" ");
|
||||
if (XtIsManaged(w))
|
||||
printf(" Managed ");
|
||||
else
|
||||
printf(" Unmanaged");
|
||||
if (XtIsSensitive(w))
|
||||
printf(" Sensitive ");
|
||||
else
|
||||
printf(" Insensitive");
|
||||
if (XtIsRealized(w))
|
||||
printf(" Realized ");
|
||||
else
|
||||
printf(" Unrealized");
|
||||
if (w->core.visible)
|
||||
printf(" Visible\n");
|
||||
else
|
||||
printf(" Invisible\n");
|
||||
}
|
||||
else
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void MotifUI::DumpWidgets(Widget w, boolean verbose, int level)
|
||||
{
|
||||
DumpWidget(w, verbose, level);
|
||||
|
||||
int i;
|
||||
if (XtIsWidget(w))
|
||||
{
|
||||
for (i = 0; i < w->core.num_popups; i++)
|
||||
DumpWidgets(w->core.popup_list[i], verbose, level + 1);
|
||||
}
|
||||
if (XtIsComposite(w))
|
||||
{
|
||||
CompositeWidget cw = (CompositeWidget) w;
|
||||
for (i = 0; i < cw->composite.num_children; i++)
|
||||
DumpWidgets(cw->composite.children[i], verbose, level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void MotifUI::DumpUIHierarchy(boolean verbose, int level)
|
||||
{
|
||||
if (verbose)
|
||||
VerbosePass1(_w, 0);
|
||||
DumpWidgets(_w, verbose, level);
|
||||
}
|
||||
179
cde/programs/dtprintinfo/libUI/MotifUI/MotifUI.h
Normal file
179
cde/programs/dtprintinfo/libUI/MotifUI/MotifUI.h
Normal file
@@ -0,0 +1,179 @@
|
||||
/* $XConsortium: MotifUI.h /main/6 1996/10/21 17:29:46 mgreess $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef MOTIFUI_H
|
||||
#define MOTIFUI_H
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
|
||||
#if defined(USL) || defined(__uxp__)
|
||||
#undef STRDUP /* get rid of memutil.h definition. Use def in BaseUI.h. */
|
||||
#endif
|
||||
|
||||
#include "BaseUI.h"
|
||||
#include "MotifThread.h"
|
||||
|
||||
extern "C" {
|
||||
extern XtPointer _XmStringUngenerate (
|
||||
XmString string,
|
||||
XmStringTag tag,
|
||||
XmTextType tag_type,
|
||||
XmTextType output_type);
|
||||
}
|
||||
|
||||
|
||||
#define AnyUI MotifUI
|
||||
#define HasDumpUI 1
|
||||
|
||||
#define PointInRect(RECT, X, Y) \
|
||||
(X >= (int) (RECT).x && \
|
||||
Y >= (int) (RECT).y && \
|
||||
X <= (int) (RECT).x + (int) (RECT).width && \
|
||||
Y <= (int) (RECT).y + (int) (RECT).height)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
Pixmap pixmap;
|
||||
Pixmap mask;
|
||||
} PixmapLookupStruct, *PixmapLookup, **PixmapLookupList;
|
||||
|
||||
class DtDND;
|
||||
class MotifThread;
|
||||
|
||||
class MotifUI : public BaseUI {
|
||||
|
||||
friend class DtDND;
|
||||
|
||||
private:
|
||||
|
||||
static void WidgetDestroyCB(Widget, XtPointer, XtPointer);
|
||||
static void WidgetHelpCB(Widget, XtPointer, XtPointer);
|
||||
Cursor InitHourGlassCursor();
|
||||
static void DumpWidget(Widget w, boolean verbose = false, int level = 0);
|
||||
static void DumpWidgets(Widget w, boolean verbose = false, int level = 0);
|
||||
static void ThreadCB(MotifThread *_thread, BaseUI *obj, ThreadCallback cb);
|
||||
|
||||
protected:
|
||||
|
||||
Widget _w;
|
||||
char *_widgetName;
|
||||
|
||||
MotifUI(MotifUI *parent,
|
||||
const char *name,
|
||||
const char *category,
|
||||
const char *widgetName = NULL);
|
||||
void InstallDestroyCB();
|
||||
void InstallHelpCB();
|
||||
virtual void WidgetDestroyed();
|
||||
void GetPixmaps(Widget widget, char *iconFile, Pixmap *pixmap,
|
||||
Pixmap *mask = NULL);
|
||||
void FillBackground(Widget widget, Pixmap pixmap, Pixmap mask);
|
||||
void SetDefaultResources(const Widget, const String *);
|
||||
void GetResources(const XtResourceList, const int);
|
||||
XmString StringCreate(char *string)
|
||||
{ if (string) return XmStringCreateLocalized(string);
|
||||
else return NULL;
|
||||
}
|
||||
void StringFree(XmString string)
|
||||
{ if (string) XmStringFree(string); string = NULL; }
|
||||
char * StringExtract(XmString string)
|
||||
{ char *s = NULL;
|
||||
s = (char *) _XmStringUngenerate(
|
||||
string, NULL,
|
||||
XmMULTIBYTE_TEXT, XmMULTIBYTE_TEXT);
|
||||
return s; };
|
||||
|
||||
// Definitions for BaseUI virtual functions
|
||||
virtual boolean SetCategory(char * /*name*/) { return true; }
|
||||
virtual boolean SetName(char *name);
|
||||
virtual boolean SetActivity(boolean flag);
|
||||
virtual boolean SetVisiblity(boolean flag);
|
||||
virtual boolean SetSelected(boolean flag);
|
||||
void DoSetFocus(Widget);
|
||||
void DoRefresh();
|
||||
void DoToFront();
|
||||
void DoContextualHelp();
|
||||
virtual void DoMakeVisible();
|
||||
virtual boolean DoIsVisible();
|
||||
virtual void DoBeginUpdate() { }
|
||||
virtual void DoEndUpdate() { }
|
||||
virtual void DoUpdateMessage(char * /*message*/) { }
|
||||
virtual boolean SetOrder(int new_postion);
|
||||
|
||||
// Containers widgets should override SetView
|
||||
virtual boolean SetView(ViewStyle) { return true; }
|
||||
|
||||
// Containers and icon widgets should override these
|
||||
virtual boolean SetOpen(boolean) { return true; }
|
||||
|
||||
// Icon widgets should override these
|
||||
virtual boolean SetIcon(IconStyle) { return true; }
|
||||
virtual boolean SetParent(BaseUI *) { return true; }
|
||||
|
||||
virtual void NotifyDelete(BaseUI *);
|
||||
static PixmapLookupList pixmap_table;
|
||||
static int n_pixmaps;
|
||||
static PointerCursor pointer_style;
|
||||
|
||||
public:
|
||||
|
||||
static Widget topLevel;
|
||||
static Display *display;
|
||||
static XtAppContext appContext;
|
||||
static XmFontList userFont;
|
||||
static Font font;
|
||||
static Window root;
|
||||
static Pixel black;
|
||||
static Pixel white;
|
||||
static int depth;
|
||||
static int shadowThickness;
|
||||
static int bMenuButton;
|
||||
|
||||
virtual ~MotifUI();
|
||||
|
||||
void Thread(const char *cmd, ThreadCallback, int buf_len);
|
||||
void Thread(int pid, int fd, ThreadCallback, int buf_len);
|
||||
void Thread(int socket, ThreadCallback, int buf_len);
|
||||
|
||||
virtual void SetFocus();
|
||||
void PointerShape(PointerCursor style);
|
||||
PointerCursor PointerShape();
|
||||
virtual void WidthHeight(int w, int h);
|
||||
virtual void WidthHeight(int *w, int *h);
|
||||
virtual void Width(int w);
|
||||
virtual int Width();
|
||||
virtual void Height(int h);
|
||||
virtual int Height();
|
||||
void AttachAll(int offset = 0);
|
||||
void AttachTop(int offset = 0);
|
||||
void AttachBottom(int offset = 0);
|
||||
void AttachLeft(int offset = 0);
|
||||
void AttachRight(int offset = 0);
|
||||
void AttachTop(BaseUI *, int offset = 0, boolean opposite = false);
|
||||
void AttachBottom(BaseUI *, int offset = 0, boolean opposite = false);
|
||||
void AttachLeft(BaseUI *, int offset = 0, boolean opposite = false);
|
||||
void AttachRight(BaseUI *, int offset = 0, boolean opposite = false);
|
||||
void StringWidthHeight(const char *string, int *w, int *h);
|
||||
int StringWidth(const char *string);
|
||||
int StringHeight(const char *string);
|
||||
void SetAddTimeOut(TimeOutCallback, void *callback_data, long interval);
|
||||
void DumpUIHierarchy(boolean verbose = false, int level = 0);
|
||||
|
||||
const Widget BaseWidget() { return _w; }
|
||||
virtual const Widget InnerWidget() { return _w; }
|
||||
|
||||
void Dump(boolean verbose = false,
|
||||
int level = 0);
|
||||
|
||||
// returns a classname to be used in GetResources
|
||||
virtual const char *const className() { return "MotifUI"; }
|
||||
|
||||
};
|
||||
|
||||
#endif /* MOTIFUI_H */
|
||||
172
cde/programs/dtprintinfo/libUI/MotifUI/Prompt.C
Normal file
172
cde/programs/dtprintinfo/libUI/MotifUI/Prompt.C
Normal file
@@ -0,0 +1,172 @@
|
||||
/* $TOG: Prompt.C /main/4 1998/08/03 08:59:18 mgreess $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "stdlib.h"
|
||||
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/Frame.h>
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/Text.h>
|
||||
|
||||
#include "Prompt.h"
|
||||
#include "Dialog.h"
|
||||
|
||||
Prompt::Prompt(MotifUI *parent,
|
||||
char *name,
|
||||
boolean editable,
|
||||
PromptType prompt_type,
|
||||
char *default_value,
|
||||
ValidationCallback /*CB*/,
|
||||
void * /*validation_data*/,
|
||||
boolean /*echo_input*/,
|
||||
int n_columns,
|
||||
int n_rows,
|
||||
int captionWidth)
|
||||
: MotifUI(parent, name, NULL)
|
||||
{
|
||||
int editMode;
|
||||
int wordWrap;
|
||||
Widget parentW;
|
||||
Pixel bg;
|
||||
|
||||
parentW = parent->InnerWidget();
|
||||
|
||||
_prompt_type = prompt_type;
|
||||
_value = NULL;
|
||||
if (_default_value)
|
||||
_default_value = STRDUP(default_value);
|
||||
else
|
||||
_default_value = strdup("");
|
||||
if (_prompt_type == MULTI_LINE_STRING_PROMPT)
|
||||
{
|
||||
wordWrap = true;
|
||||
editMode = XmMULTI_LINE_EDIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
wordWrap = false;
|
||||
editMode = XmSINGLE_LINE_EDIT;
|
||||
}
|
||||
XtVaGetValues(parentW, XmNbackground, &bg, NULL);
|
||||
_w = XtVaCreateManagedWidget(name, xmFormWidgetClass, parentW, NULL);
|
||||
XmString xm_string = StringCreate(name);
|
||||
_caption = XtVaCreateManagedWidget(name, xmLabelWidgetClass, _w,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNalignment, XmALIGNMENT_END,
|
||||
XmNlabelString, xm_string,
|
||||
XmNwidth, captionWidth, NULL);
|
||||
StringFree(xm_string);
|
||||
if (editMode == XmMULTI_LINE_EDIT && editable == false)
|
||||
{
|
||||
Widget _frame;
|
||||
_frame = XtVaCreateManagedWidget(name, xmFrameWidgetClass, _w,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment,
|
||||
(name ? XmATTACH_WIDGET : XmATTACH_FORM),
|
||||
XmNleftWidget, _caption,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNshadowType, XmSHADOW_ETCHED_IN,
|
||||
XmNshadowThickness, 2, NULL);
|
||||
_text = XtVaCreateManagedWidget(name, xmTextWidgetClass, _frame,
|
||||
XmNvalue, default_value,
|
||||
XmNrows, n_rows, XmNcolumns, n_columns,
|
||||
XmNeditMode, editMode,
|
||||
XmNwordWrap, wordWrap,
|
||||
XmNeditable, editable,
|
||||
XmNbackground, bg,
|
||||
XmNcursorPositionVisible, false,
|
||||
XmNtraversalOn, false,
|
||||
XmNshadowThickness, 0, NULL);
|
||||
}
|
||||
else
|
||||
_text = XtVaCreateManagedWidget(name, xmTextWidgetClass, _w,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment,
|
||||
(name ? XmATTACH_WIDGET : XmATTACH_FORM),
|
||||
XmNleftWidget, _caption,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNvalue, default_value,
|
||||
XmNrows, n_rows, XmNcolumns, n_columns,
|
||||
XmNeditMode, editMode,
|
||||
XmNwordWrap, wordWrap,
|
||||
editable ? NULL : XmNeditable, editable,
|
||||
XmNbackground, bg,
|
||||
XmNcursorPositionVisible, false,
|
||||
XmNtraversalOn, false,
|
||||
XmNshadowThickness, 0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
Prompt::~Prompt()
|
||||
{
|
||||
free(_default_value);
|
||||
XtFree(_value);
|
||||
}
|
||||
|
||||
void Prompt::Reset()
|
||||
{
|
||||
Value(_default_value);
|
||||
}
|
||||
|
||||
void Prompt::DefaultValue(char *value)
|
||||
{
|
||||
free(_default_value);
|
||||
_default_value = STRDUP(value);
|
||||
}
|
||||
|
||||
void Prompt::Value(int *number)
|
||||
{
|
||||
XtFree(_value);
|
||||
_value = XmTextGetString(_text);
|
||||
sscanf(_value, "%d", number);
|
||||
}
|
||||
|
||||
void Prompt::Value(float *number)
|
||||
{
|
||||
XtFree(_value);
|
||||
_value = XmTextGetString(_text);
|
||||
sscanf(_value, "%f", number);
|
||||
}
|
||||
|
||||
char * Prompt::Value()
|
||||
{
|
||||
XtFree(_value);
|
||||
_value = XmTextGetString(_text);
|
||||
return _value;
|
||||
}
|
||||
|
||||
boolean Prompt::Value(int number)
|
||||
{
|
||||
char value[50];
|
||||
|
||||
sprintf(value, "%d", number);
|
||||
XmTextSetString(_text, value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean Prompt::Value(float number)
|
||||
{
|
||||
char value[50];
|
||||
|
||||
sprintf(value, "%f", number);
|
||||
XmTextSetString(_text, value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean Prompt::Value(char *string)
|
||||
{
|
||||
XmTextSetString(_text, string);
|
||||
|
||||
return true;
|
||||
}
|
||||
62
cde/programs/dtprintinfo/libUI/MotifUI/Prompt.h
Normal file
62
cde/programs/dtprintinfo/libUI/MotifUI/Prompt.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* $XConsortium: Prompt.h /main/3 1995/11/06 09:44:30 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef PROMPT_H
|
||||
#define PROMPT_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
class Prompt : public MotifUI {
|
||||
|
||||
private:
|
||||
|
||||
Widget _caption;
|
||||
Widget _text;
|
||||
PromptType _prompt_type;
|
||||
char *_default_value;
|
||||
char *_value;
|
||||
ValidationCallback CB;
|
||||
void * validation_data;
|
||||
|
||||
public:
|
||||
|
||||
Prompt(MotifUI * parent,
|
||||
char *name = "prompt",
|
||||
boolean editable = true,
|
||||
PromptType prompt_type = STRING_PROMPT,
|
||||
char *default_value = NULL,
|
||||
ValidationCallback CB = NULL,
|
||||
void * validation_data = NULL,
|
||||
boolean echo_input = true,
|
||||
int n_column = 20,
|
||||
int n_rows = 1,
|
||||
int captionWidth = 0);
|
||||
~Prompt();
|
||||
|
||||
void SetFocus() { DoSetFocus(_text); }
|
||||
void Reset(); // Reset to default value
|
||||
|
||||
char * Value(); // Access value as STRING
|
||||
void Value(int *); // Access value as INTEGER
|
||||
void Value(float *); // Access value as REAL_NUMBER
|
||||
|
||||
boolean Value(int); // Set value
|
||||
boolean Value(float); // Set value
|
||||
boolean Value(char *); // Set value
|
||||
|
||||
void DefaultValue(char *); // Set value
|
||||
|
||||
char * DefaultValue() { return _default_value; }
|
||||
|
||||
const UI_Class UIClass() { return PROMPT; }
|
||||
const int UISubClass() { return _prompt_type; }
|
||||
const char *const UIClassName() { return "Prompt"; }
|
||||
|
||||
};
|
||||
|
||||
#endif /* PROMPT_H */
|
||||
234
cde/programs/dtprintinfo/libUI/MotifUI/ScaleObj.C
Normal file
234
cde/programs/dtprintinfo/libUI/MotifUI/ScaleObj.C
Normal file
@@ -0,0 +1,234 @@
|
||||
/* $XConsortium: ScaleObj.C /main/2 1995/07/17 14:07:10 drk $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "ScaleObj.h"
|
||||
|
||||
#include <Xm/Scale.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/Label.h>
|
||||
|
||||
ScaleObj::ScaleObj(MotifUI *parent,
|
||||
char *title,
|
||||
int value,
|
||||
int numDecimalPoints,
|
||||
int max,
|
||||
int min,
|
||||
int scaleMultiple,
|
||||
ScaleType style,
|
||||
boolean showValue)
|
||||
: MotifUI(parent, title, NULL)
|
||||
{
|
||||
CreateScale(parent, title, value, numDecimalPoints, max, min, scaleMultiple,
|
||||
style, showValue);
|
||||
}
|
||||
|
||||
ScaleObj::ScaleObj(char *category,
|
||||
MotifUI *parent,
|
||||
char *title,
|
||||
int value,
|
||||
int numDecimalPoints,
|
||||
int max,
|
||||
int min,
|
||||
int scaleMultiple,
|
||||
ScaleType style,
|
||||
boolean showValue)
|
||||
: MotifUI(parent, title, category)
|
||||
{
|
||||
CreateScale(parent, title, value, numDecimalPoints, max, min, scaleMultiple,
|
||||
style, showValue);
|
||||
}
|
||||
|
||||
void ScaleObj::CreateScale(MotifUI *parent, char *title, int value,
|
||||
int numDecimalPoints, int max, int min,
|
||||
int scaleMultiple, ScaleType style, boolean showValue)
|
||||
{
|
||||
_style = style;
|
||||
_value = value;
|
||||
_numDecimalPoints = numDecimalPoints;
|
||||
_max = max;
|
||||
_min = min;
|
||||
_scaleMultiple = scaleMultiple;
|
||||
_style = style;
|
||||
_showValue = showValue;
|
||||
CheckValues(false);
|
||||
|
||||
int orientation;
|
||||
short points = _numDecimalPoints;
|
||||
if (_style == VERTICAL_SCALE)
|
||||
orientation = XmVERTICAL;
|
||||
else
|
||||
orientation = XmHORIZONTAL;
|
||||
|
||||
XmString xm_string = StringCreate(title);
|
||||
_w = XtVaCreateManagedWidget(title, xmFormWidgetClass,
|
||||
parent->InnerWidget(), NULL);
|
||||
_minLabel = XtVaCreateWidget(title, xmLabelWidgetClass, _w,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM, NULL);
|
||||
_maxLabel = XtVaCreateWidget(title, xmLabelWidgetClass, _w,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM, NULL);
|
||||
_scale = XtVaCreateManagedWidget(title, xmScaleWidgetClass, _w,
|
||||
XmNmaximum, _max,
|
||||
XmNminimum, _min, XmNvalue, _value,
|
||||
XmNscaleMultiple, _scaleMultiple,
|
||||
XmNdecimalPoints, points,
|
||||
XmNtitleString, xm_string,
|
||||
XmNshowValue, _showValue,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNorientation, orientation, NULL);
|
||||
StringFree(xm_string);
|
||||
SetString(_minLabel, _min);
|
||||
SetString(_maxLabel, _max);
|
||||
ShowValue(_showValue);
|
||||
}
|
||||
|
||||
boolean ScaleObj::SetName(char *name)
|
||||
{
|
||||
XmString xm_string = StringCreate(name);
|
||||
XtVaSetValues(_w, XmNtitleString, xm_string, NULL);
|
||||
StringFree(xm_string);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScaleObj::CheckValues(boolean do_it)
|
||||
{
|
||||
if (_min > _max)
|
||||
{
|
||||
int tmp = _min;
|
||||
_min = _max;
|
||||
_max = tmp;
|
||||
}
|
||||
if ((_max - _min) == 0)
|
||||
_max += 1;
|
||||
if (_numDecimalPoints < 0)
|
||||
_numDecimalPoints = 0;
|
||||
if (_value > _max)
|
||||
_value = _max;
|
||||
else if (_value < _min)
|
||||
_value = _min;
|
||||
if (_scaleMultiple < 0)
|
||||
_scaleMultiple = 1;
|
||||
else if (_scaleMultiple > (_max - _min))
|
||||
{
|
||||
if ((_scaleMultiple = (_max - _min) / 10) == 0)
|
||||
_scaleMultiple = 1;
|
||||
}
|
||||
if (do_it)
|
||||
{
|
||||
short points = _numDecimalPoints;
|
||||
XtVaSetValues(_scale, XmNmaximum, _max, XmNminimum, _min,
|
||||
XmNscaleMultiple, _scaleMultiple,
|
||||
XmNdecimalPoints, points, XmNvalue, _value, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void ScaleObj::SetString(Widget w, int value)
|
||||
{
|
||||
char number[20];
|
||||
if (_numDecimalPoints == 0)
|
||||
sprintf(number, "%d", value);
|
||||
else
|
||||
{
|
||||
char fmt[10];
|
||||
sprintf(fmt, "%%.%df", _numDecimalPoints);
|
||||
int n = 1, i;
|
||||
for (i = 0; i < _numDecimalPoints; i++)
|
||||
n *= 10;
|
||||
sprintf(number, fmt, (float) value / n);
|
||||
}
|
||||
XmString xm_string = StringCreate(number);
|
||||
XtVaSetValues(w, XmNlabelString, xm_string, NULL);
|
||||
StringFree(xm_string);
|
||||
}
|
||||
|
||||
void ScaleObj::Style(ScaleType value)
|
||||
{
|
||||
int orientation;
|
||||
|
||||
if (value == VERTICAL_SCALE)
|
||||
orientation = XmVERTICAL;
|
||||
else
|
||||
orientation = XmHORIZONTAL;
|
||||
XtVaSetValues(_scale, XmNorientation, orientation, NULL);
|
||||
}
|
||||
|
||||
int ScaleObj::Value()
|
||||
{
|
||||
XtVaGetValues(_scale, XmNvalue, &_value, NULL);
|
||||
return _value;
|
||||
}
|
||||
|
||||
void ScaleObj::Value(int value)
|
||||
{
|
||||
if (_value == value)
|
||||
return;
|
||||
_value = value;
|
||||
CheckValues(true);
|
||||
}
|
||||
|
||||
void ScaleObj::NumDecimalPoints(int value)
|
||||
{
|
||||
_numDecimalPoints = value;
|
||||
CheckValues(true);
|
||||
}
|
||||
|
||||
void ScaleObj::Maximum(int value)
|
||||
{
|
||||
if (_max == value)
|
||||
return;
|
||||
_max = value;
|
||||
int old_min = _min;
|
||||
CheckValues(true);
|
||||
SetString(_maxLabel, _max);
|
||||
if (old_min != _min)
|
||||
SetString(_minLabel, _min);
|
||||
}
|
||||
|
||||
void ScaleObj::Minumum(int value)
|
||||
{
|
||||
if (_min == value)
|
||||
return;
|
||||
_min = value;
|
||||
int old_max = _max;
|
||||
CheckValues(true);
|
||||
SetString(_minLabel, _min);
|
||||
if (old_max != _max)
|
||||
SetString(_maxLabel, _max);
|
||||
}
|
||||
|
||||
void ScaleObj::Multiple(int value)
|
||||
{
|
||||
_scaleMultiple = value;
|
||||
CheckValues(true);
|
||||
}
|
||||
|
||||
void ScaleObj::ShowValue(boolean value)
|
||||
{
|
||||
_showValue = value;
|
||||
if (_showValue)
|
||||
{
|
||||
XtManageChild(_minLabel);
|
||||
XtManageChild(_maxLabel);
|
||||
XtVaSetValues(_scale, XmNshowValue, _showValue, XmNleftWidget, _minLabel,
|
||||
XmNleftAttachment, XmATTACH_WIDGET,
|
||||
XmNrightAttachment, XmATTACH_WIDGET,
|
||||
XmNrightWidget, _maxLabel, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
XtUnmanageChild(_minLabel);
|
||||
XtUnmanageChild(_maxLabel);
|
||||
XtVaSetValues(_scale, XmNshowValue, _showValue,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM, NULL);
|
||||
}
|
||||
}
|
||||
81
cde/programs/dtprintinfo/libUI/MotifUI/ScaleObj.h
Normal file
81
cde/programs/dtprintinfo/libUI/MotifUI/ScaleObj.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* $XConsortium: ScaleObj.h /main/3 1995/11/06 09:44:42 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef SCALEOBJ_H
|
||||
#define SCALEOBJ_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
class ScaleObj : public MotifUI {
|
||||
|
||||
private:
|
||||
|
||||
ScaleType _style;
|
||||
int _value;
|
||||
int _numDecimalPoints;
|
||||
int _max;
|
||||
int _min;
|
||||
int _scaleMultiple;
|
||||
boolean _showValue;
|
||||
Widget _scale;
|
||||
Widget _minLabel;
|
||||
Widget _maxLabel;
|
||||
|
||||
void SetString(Widget w, int value);
|
||||
void CheckValues(boolean);
|
||||
void CreateScale(MotifUI *, char *, int, int, int, int, int, ScaleType,
|
||||
boolean);
|
||||
|
||||
boolean SetName(char *name);
|
||||
|
||||
public:
|
||||
|
||||
ScaleObj(MotifUI * parent,
|
||||
char *title,
|
||||
int value,
|
||||
int numDecimalPoints = 0,
|
||||
int max = 100,
|
||||
int min = 1,
|
||||
int scaleMultiple = 5,
|
||||
ScaleType style = VERTICAL_SCALE,
|
||||
boolean showValue = false);
|
||||
ScaleObj(char *category,
|
||||
MotifUI * parent,
|
||||
char *title,
|
||||
int value,
|
||||
int numDecimalPoints = 0,
|
||||
int max = 100,
|
||||
int min = 1,
|
||||
int scaleMultiple = 5,
|
||||
ScaleType style = VERTICAL_SCALE,
|
||||
boolean showValue = false);
|
||||
|
||||
void Style(ScaleType);
|
||||
void Value(int);
|
||||
void NumDecimalPoints(int);
|
||||
void Maximum(int);
|
||||
void Minumum(int);
|
||||
void Multiple(int);
|
||||
void ShowValue(boolean);
|
||||
|
||||
ScaleType Style() { return _style; }
|
||||
int Value();
|
||||
int NumDecimalPoints() { return _numDecimalPoints; }
|
||||
int Maximum() { return _max; }
|
||||
int Minumum() { return _min; }
|
||||
int Multiple() { return _scaleMultiple; }
|
||||
boolean ShowValue() { return _showValue; }
|
||||
|
||||
const Widget InnerWidget() { return _scale; }
|
||||
const UI_Class UIClass() { return SCALE; }
|
||||
const int UISubClass() { return _style; }
|
||||
const char *const UIClassName() { return "Scale"; }
|
||||
|
||||
};
|
||||
|
||||
#endif /* SCALEOBJ_H */
|
||||
34
cde/programs/dtprintinfo/libUI/MotifUI/Sep.C
Normal file
34
cde/programs/dtprintinfo/libUI/MotifUI/Sep.C
Normal file
@@ -0,0 +1,34 @@
|
||||
/* $XConsortium: Sep.C /main/2 1995/07/17 14:07:18 drk $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "Sep.h"
|
||||
|
||||
#include <Xm/Separator.h>
|
||||
|
||||
Sep::Sep(MotifUI *parent,
|
||||
SeparatorStyle style)
|
||||
: MotifUI(parent, "sep", NULL)
|
||||
{
|
||||
_style = style;
|
||||
|
||||
_w = XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass,
|
||||
parent->InnerWidget(),
|
||||
XmNseparatorType, style, NULL);
|
||||
}
|
||||
|
||||
Sep::Sep(char *category,
|
||||
MotifUI *parent,
|
||||
SeparatorStyle style)
|
||||
: MotifUI(parent, "sep", category)
|
||||
{
|
||||
_style = style;
|
||||
|
||||
_w = XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass,
|
||||
parent->InnerWidget(),
|
||||
XmNseparatorType, style, NULL);
|
||||
}
|
||||
34
cde/programs/dtprintinfo/libUI/MotifUI/Sep.h
Normal file
34
cde/programs/dtprintinfo/libUI/MotifUI/Sep.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* $XConsortium: Sep.h /main/3 1995/11/06 09:44:53 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef SEP_H
|
||||
#define SEP_H
|
||||
|
||||
#include "MotifUI.h"
|
||||
|
||||
class Sep : public MotifUI {
|
||||
|
||||
private:
|
||||
|
||||
SeparatorStyle _style;
|
||||
|
||||
public:
|
||||
|
||||
Sep(MotifUI * parent,
|
||||
SeparatorStyle style = SHADOW_ETCHED_IN);
|
||||
Sep(char *category,
|
||||
MotifUI * parent,
|
||||
SeparatorStyle style = SHADOW_ETCHED_IN);
|
||||
|
||||
const UI_Class UIClass() { return SEPARATOR; }
|
||||
const int UISubClass() { return _style; }
|
||||
const char *const UIClassName() { return "Sep"; }
|
||||
|
||||
};
|
||||
|
||||
#endif /* SEP_H */
|
||||
1364
cde/programs/dtprintinfo/libUI/MotifUI/WorkArea.c
Normal file
1364
cde/programs/dtprintinfo/libUI/MotifUI/WorkArea.c
Normal file
File diff suppressed because it is too large
Load Diff
99
cde/programs/dtprintinfo/libUI/MotifUI/WorkArea.h
Normal file
99
cde/programs/dtprintinfo/libUI/MotifUI/WorkArea.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/* $XConsortium: WorkArea.h /main/3 1995/11/06 09:45:18 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef WORKAREA_H
|
||||
#define WORKAREA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
externalref WidgetClass workAreaWidgetClass;
|
||||
|
||||
typedef struct _WorkAreaClassRec *WorkAreaWidgetClass;
|
||||
typedef struct _WorkAreaRec *WorkAreaWidget;
|
||||
|
||||
enum {
|
||||
GuiATTACH_TOP,
|
||||
GuiATTACH_BOTTOM,
|
||||
GuiATTACH_LEFT,
|
||||
GuiATTACH_RIGHT
|
||||
};
|
||||
|
||||
#define GuiIsWorkArea(w) XtIsSubclass((w), workAreaWidgetClass)
|
||||
|
||||
extern const char gui_workarea_strings[];
|
||||
|
||||
#define GuiNisList ((char*)&gui_workarea_strings[0])
|
||||
#define GuiNattachment ((char*)&gui_workarea_strings[7])
|
||||
#define GuiCAttachment ((char*)&gui_workarea_strings[18])
|
||||
#define GuiRAttachment ((char*)&gui_workarea_strings[29])
|
||||
#define GuiNisWorkArea ((char*)&gui_workarea_strings[40])
|
||||
#define GuiNautoResizeWidth ((char*)&gui_workarea_strings[51])
|
||||
#define GuiNisOpened ((char*)&gui_workarea_strings[67])
|
||||
#define GuiNisTransient ((char*)&gui_workarea_strings[76])
|
||||
#define GuiNlineThickness ((char*)&gui_workarea_strings[88])
|
||||
#define GuiCLineThickness ((char*)&gui_workarea_strings[102])
|
||||
#define GuiNlineOffset ((char*)&gui_workarea_strings[116])
|
||||
#define GuiCLineOffset ((char*)&gui_workarea_strings[127])
|
||||
#define GuiNnodeLineLength ((char*)&gui_workarea_strings[138])
|
||||
#define GuiCNodeLineLength ((char*)&gui_workarea_strings[153])
|
||||
#define GuiNnumberSubNodes ((char*)&gui_workarea_strings[168])
|
||||
#define GuiCNumberSubNodes ((char*)&gui_workarea_strings[183])
|
||||
#define GuiNnumberColumns ((char*)&gui_workarea_strings[198])
|
||||
#define GuiCNumberColumns ((char*)&gui_workarea_strings[212])
|
||||
#define GuiNsubNodes ((char*)&gui_workarea_strings[226])
|
||||
#define GuiCSubNodes ((char*)&gui_workarea_strings[235])
|
||||
#define GuiNhorizontalSpace ((char*)&gui_workarea_strings[244])
|
||||
#define GuiNverticalSpace ((char*)&gui_workarea_strings[260])
|
||||
#define GuiCSpace ((char*)&gui_workarea_strings[274])
|
||||
#define GuiNsuperNode ((char*)&gui_workarea_strings[280])
|
||||
#define GuiCSuperNode ((char*)&gui_workarea_strings[290])
|
||||
extern Widget GuiCreateWorkArea(
|
||||
Widget parent,
|
||||
char *name,
|
||||
ArgList arglist,
|
||||
Cardinal argcount);
|
||||
|
||||
extern Widget GuiCreateScrolledWorkArea(
|
||||
Widget parent,
|
||||
char *name,
|
||||
ArgList arglist,
|
||||
Cardinal argcount);
|
||||
|
||||
/*
|
||||
* Use the following two functions to improve performance when managing and
|
||||
* unmanaging many children all at once.
|
||||
*/
|
||||
|
||||
extern void GuiWorkAreaEnableRedisplay(Widget /* workArea widget */);
|
||||
extern void GuiWorkAreaDisableRedisplay(Widget /* workArea widget */);
|
||||
|
||||
/*
|
||||
* GuiWorkAreaReorderChildren reorders a parent's subnodes. Can be use to sort
|
||||
* or move subnodes. The subnode list can be a subset of the parents's
|
||||
* subnodes and it can be moved relative to another position (widget).
|
||||
* The default position is to start the reorder as the first subnode.
|
||||
*
|
||||
* If position == parent_subnode, start reorder as first subnode.
|
||||
* If position == NULL, subnode_list[n_subnodes] will be the last sub_node
|
||||
* of parent_subnode. If position is a widget in the parent's subnodes,
|
||||
* start the reorder after it.
|
||||
*/
|
||||
|
||||
extern void GuiWorkAreaReorderChildren(
|
||||
Widget parent_subnode,
|
||||
WidgetList subnode_list,
|
||||
int n_subnodes,
|
||||
Widget position);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* Close scope of 'extern "C"' declaration which encloses file. */
|
||||
#endif
|
||||
|
||||
#endif /* WORKAREA_H */
|
||||
89
cde/programs/dtprintinfo/libUI/MotifUI/WorkAreaP.h
Normal file
89
cde/programs/dtprintinfo/libUI/MotifUI/WorkAreaP.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/* $XConsortium: WorkAreaP.h /main/3 1995/11/06 09:45:29 rswiston $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#ifndef WORKAREAP_H
|
||||
#define WORKAREAP_H
|
||||
|
||||
#include <Xm/ManagerP.h>
|
||||
|
||||
#include "WorkArea.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _WorkAreaClassPart {
|
||||
int ignore;
|
||||
} WorkAreaClassPart;
|
||||
|
||||
typedef struct _WorkAreaClassRec {
|
||||
CoreClassPart core_class;
|
||||
CompositeClassPart composite_class;
|
||||
ConstraintClassPart constraint_class;
|
||||
XmManagerClassPart manager_class;
|
||||
WorkAreaClassPart workArea_class;
|
||||
} WorkAreaClassRec;
|
||||
|
||||
externalref WorkAreaClassRec workAreaClassRec;
|
||||
|
||||
typedef struct _WorkAreaPart {
|
||||
/* public resources */
|
||||
Dimension horizontal_spacing;
|
||||
Dimension vertical_spacing;
|
||||
Dimension line_thickness;
|
||||
Dimension line_offset;
|
||||
Dimension node_line_length;
|
||||
unsigned char alignment;
|
||||
unsigned char vertical_alignment;
|
||||
unsigned char packing;
|
||||
Boolean auto_resize_width;
|
||||
Boolean is_list;
|
||||
|
||||
/* private resources */
|
||||
Dimension old_width;
|
||||
Dimension old_height;
|
||||
Boolean delay_layout; /* Set with GuiWorkAreaDoLayout function */
|
||||
GC gc;
|
||||
Widget workArea_root;
|
||||
} WorkAreaPart;
|
||||
|
||||
typedef struct _WorkAreaRec {
|
||||
CorePart core;
|
||||
CompositePart composite;
|
||||
ConstraintPart constraint;
|
||||
XmManagerPart manager;
|
||||
WorkAreaPart workArea;
|
||||
} WorkAreaRec;
|
||||
|
||||
typedef struct _WorkAreaConstraintsPart {
|
||||
/* public resources */
|
||||
Widget super_node;
|
||||
Boolean is_workArea;
|
||||
unsigned char orientation;
|
||||
unsigned char attachment;
|
||||
Boolean is_opened;
|
||||
Boolean is_transient;
|
||||
WidgetList sub_nodes; /* Can only be queried. Can be set indirectly
|
||||
with the GuiWorkAreaReorderChildren function */
|
||||
int n_sub_nodes;
|
||||
int n_columns; /* Used when orientation is horizontal. Zero
|
||||
means there are infinite columns */
|
||||
Position x, y; /* Can be set if is_transient == TRUE */
|
||||
} WorkAreaConstraintsPart;
|
||||
|
||||
typedef struct _WorkAreaConstraintsRec {
|
||||
WorkAreaConstraintsPart workArea;
|
||||
} WorkAreaConstraintsRec, *WorkAreaConstraints;
|
||||
|
||||
#define WORKAREA_CONSTRAINT(w) ((WorkAreaConstraints)((w)->core.constraints))
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* Close scope of 'extern "C"' declaration which encloses file. */
|
||||
#endif
|
||||
|
||||
#endif /* WORKAREAP_H */
|
||||
144
cde/programs/dtprintinfo/libUI/Test.C
Normal file
144
cde/programs/dtprintinfo/libUI/Test.C
Normal file
@@ -0,0 +1,144 @@
|
||||
/* $XConsortium: Test.C /main/2 1995/07/17 14:07:26 drk $ */
|
||||
/* *
|
||||
* (c) Copyright 1993, 1994 Hewlett-Packard Company *
|
||||
* (c) Copyright 1993, 1994 International Business Machines Corp. *
|
||||
* (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
|
||||
* (c) Copyright 1993, 1994 Novell, Inc. *
|
||||
*/
|
||||
|
||||
#include "Application.h"
|
||||
#include "MainWindow.h"
|
||||
#include "MenuBar.h"
|
||||
#include "Menu.h"
|
||||
#include "Button.h"
|
||||
#include "Container.h"
|
||||
#include "IconObj.h"
|
||||
#include "Sep.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static void ExitCB(void *data)
|
||||
{
|
||||
delete ((BaseUI *)data)->Parent();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
static void PrintUICB(void *data)
|
||||
{
|
||||
((AnyUI *) data)->DumpUIHierarchy(true);
|
||||
}
|
||||
|
||||
static void PrintObjectsCB(void *data)
|
||||
{
|
||||
((BaseUI *) data)->DumpHierarchy();
|
||||
}
|
||||
|
||||
class TestWindow : public MainWindow
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
Container *container;
|
||||
|
||||
TestWindow(MotifUI *p,char *name) : MainWindow(p,name,NULL,"Fpprnt.l.pm") { }
|
||||
void Initialize();
|
||||
};
|
||||
|
||||
void TestWindow::Initialize()
|
||||
{
|
||||
MenuBar *mbar;
|
||||
Menu *menu;
|
||||
|
||||
mbar = new MenuBar(this);
|
||||
container = new Container("PrinterSubSystem", this, "Printers");
|
||||
container->WidthHeight(600, 400);
|
||||
container->ContainerView(TREE);
|
||||
SetWorkWindow(container);
|
||||
|
||||
// File menu
|
||||
menu = new Menu(mbar, "File", "F");
|
||||
new Button(menu, "Exit", PUSH_BUTTON, ExitCB, this, "x", "ALT+F4");
|
||||
|
||||
// Edit menu
|
||||
menu = new Menu(mbar, "Edit", "E");
|
||||
new Button(menu, "Cut", PUSH_BUTTON, NULL, NULL, "t", "Shift+Del");
|
||||
new Button(menu, "Copy", PUSH_BUTTON, NULL, NULL, "C", "Ctrl+Ins");
|
||||
new Button(menu, "Paste", PUSH_BUTTON, NULL, NULL, "P", "Shift+Ins");
|
||||
new Button(menu, "Delete", PUSH_BUTTON, NULL, NULL, "D");
|
||||
|
||||
// View menu
|
||||
menu = new Menu(mbar, "View", "V");
|
||||
new Button(menu, "New", PUSH_BUTTON, NULL, NULL, "N");
|
||||
new Sep(menu);
|
||||
new Button(menu, "Select All", PUSH_BUTTON, NULL, NULL, "S", "Ctrl+/");
|
||||
new Button(menu, "Unselect All", PUSH_BUTTON, NULL, NULL, "U", "Ctrl+\\");
|
||||
new Sep(menu);
|
||||
new Button(menu, "Set Preferences...", PUSH_BUTTON, NULL, NULL, "P");
|
||||
new Sep(menu);
|
||||
new Button(menu, "Save Settings...", PUSH_BUTTON, NULL, NULL, "t");
|
||||
|
||||
// Actions Menu
|
||||
menu = new Menu(mbar, "Actions", "A");
|
||||
new Button(menu, "Monitor", PUSH_BUTTON, NULL, NULL, "M");
|
||||
new Button(menu, "Cancel Job", PUSH_BUTTON, NULL, NULL, "C");
|
||||
|
||||
// Help Menu
|
||||
menu = new Menu(mbar, "Help", "H");
|
||||
new Button(menu, "Introduction", PUSH_BUTTON, NULL, NULL, "I");
|
||||
new Sep(menu);
|
||||
new Button(menu, "Tasks", PUSH_BUTTON, NULL, NULL, "T");
|
||||
new Button(menu, "Reference", PUSH_BUTTON, NULL, NULL, "R");
|
||||
new Button(menu, "On Item", PUSH_BUTTON, NULL, NULL, "O");
|
||||
new Sep(menu);
|
||||
new Button(menu, "Using Help", PUSH_BUTTON, NULL, NULL, "U");
|
||||
new Sep(menu);
|
||||
new Button(menu, "Version", PUSH_BUTTON, NULL, NULL, "V");
|
||||
mbar->SetHelpMenu(menu);
|
||||
|
||||
// Debug menu
|
||||
menu = new Menu(mbar, "Debug", "G");
|
||||
new Button(menu, "Print Objects", PUSH_BUTTON, PrintObjectsCB, Parent());
|
||||
new Button(menu, "Print UI", PUSH_BUTTON, PrintUICB, Parent());
|
||||
|
||||
}
|
||||
|
||||
int main(int argc,
|
||||
char **argv)
|
||||
{
|
||||
Application *app = new Application("Printer", "Dtprinter", &argc, argv);
|
||||
TestWindow *window = new TestWindow(app, "Printer");
|
||||
window->Initialize();
|
||||
|
||||
window->AddAction("Exit", "PrinterSubSystem", ExitCB, NULL, "x", "Alt+F4");
|
||||
window->AddAction("Properties...", "Queue", NULL, NULL, "p",
|
||||
"Ctrl+Backspace");
|
||||
window->AddSep("Queue");
|
||||
window->AddAction("Start", "Queue", NULL, NULL, "S");
|
||||
window->AddAction("Stop", "Queue", NULL, NULL, "t");
|
||||
window->AddSep("Queue");
|
||||
window->AddAction("Monitor", "Queue", NULL, NULL, "M");
|
||||
window->AddAction("Cancel", "PrintJob", NULL, NULL, "C");
|
||||
|
||||
window->RegisterPopup(window->container);
|
||||
|
||||
IconObj *lp0 = new IconObj("Queue", window->container, "lp0", "Fpprnt");
|
||||
window->RegisterPopup(lp0);
|
||||
IconObj *tmp = new IconObj("PrintJob", lp0, "job1", "DtPrtjb");
|
||||
window->RegisterPopup(tmp);
|
||||
tmp = new IconObj("PrintJob", lp0, "job2", "DtPrtjb");
|
||||
window->RegisterPopup(tmp);
|
||||
tmp = new IconObj("PrintJob", lp0, "job3", "DtPrtjb");
|
||||
window->RegisterPopup(tmp);
|
||||
IconObj *lp1 = new IconObj("Queue", window->container, "lp1", "Fpprnt");
|
||||
window->RegisterPopup(lp1);
|
||||
tmp = new IconObj("PrintJob", lp1, "job4", "DtPrtjb");
|
||||
window->RegisterPopup(tmp);
|
||||
tmp = new IconObj("PrintJob", lp1, "job5", "DtPrtjb");
|
||||
window->RegisterPopup(tmp);
|
||||
|
||||
app->Visible(true);
|
||||
app->Run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user