motiftools-xmt-cvs Mailing List for Xmt - Motif Tools
Brought to you by:
motiftools
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
(1) |
Apr
(22) |
May
(10) |
Jun
|
Jul
|
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
(14) |
Nov
|
Dec
|
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(8) |
From: Grant M. <grm...@us...> - 2004-12-14 19:42:08
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19284 Modified Files: Imakefile Log Message: Add new utility function files to Imakefile Index: Imakefile =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/Imakefile,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** Imakefile 7 May 2002 04:52:43 -0000 1.10 --- Imakefile 14 Dec 2004 19:41:57 -0000 1.11 *************** *** 25,28 **** --- 25,29 ---- AskForString.c \ AssertClass.c \ + BackgroundWorker.c \ BSearch.c \ BitmapCvt.c \ *************** *** 92,95 **** --- 93,97 ---- Quarks.c \ RGBtoHSL.c \ + RunApplication.c \ Screen.c \ SetValue.c \ *************** *** 140,143 **** --- 142,146 ---- AskForString.o \ AssertClass.o \ + BackgroundWorker.o \ BSearch.o \ BitmapCvt.o \ *************** *** 205,208 **** --- 208,212 ---- Quarks.o \ RGBtoHSL.o \ + RunApplication.o \ Screen.o \ SetValue.o \ *************** *** 270,273 **** --- 274,278 ---- AppResP.h \ AppRes.h \ + BackgroundWorker.h \ Chooser.h \ ChooserP.h \ *************** *** 318,321 **** --- 323,327 ---- ProgressP.h \ QuarksP.h \ + RunApplication.h \ ScreenP.h \ SetValue.h \ |
From: Grant M. <grm...@us...> - 2004-12-14 19:41:16
|
Update of /cvsroot/motiftools/xmt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19125 Modified Files: Xmt.tmpl Log Message: Add Xmt.tmpl define for pthreads (for background/parallel task util. function) Index: Xmt.tmpl =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt.tmpl,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** Xmt.tmpl 27 Oct 2003 21:29:05 -0000 1.7 --- Xmt.tmpl 14 Dec 2004 19:41:08 -0000 1.8 *************** *** 90,93 **** --- 90,100 ---- /* + * Determine whether to use POSIX threads or fork() for XmtBackgroundWorker. + * The default is to use fork; if you wish to use POSIX threads uncomment + * this line. + */ + THREADDEFINES = /* -DUSE_PTHREADS */ + + /* * Determine which form of errno -> string mapping your OS supports. * The default is set for an OS that supports strerror(). *************** *** 349,353 **** * file or client, we'll set them here. */ ! DEFINES = $(MEMDEFINES) $(OLDMOTIFDEFINES) $(BSDEFINES) $(HPDEFINES) $(DECDEFINES) $(IBMDEFINES) $(TEAROFFDEFINES) $(STRERRORDEFINES) $(SYSERRLISTDEFINES) $(XMTPPDEFINES) $(NUTCRACKERBUGDEFINES) $(DISABLEDNDDEFINES) $(USECOMPONENTDEFINES) /* --- 356,360 ---- * file or client, we'll set them here. */ ! DEFINES = $(MEMDEFINES) $(THREADDEFINES) $(OLDMOTIFDEFINES) $(BSDEFINES) $(HPDEFINES) $(DECDEFINES) $(IBMDEFINES) $(TEAROFFDEFINES) $(STRERRORDEFINES) $(SYSERRLISTDEFINES) $(XMTPPDEFINES) $(NUTCRACKERBUGDEFINES) $(DISABLEDNDDEFINES) $(USECOMPONENTDEFINES) /* |
From: Grant M. <grm...@us...> - 2004-12-14 19:37:24
|
Update of /cvsroot/motiftools/xmt/examples/RunApplication In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18274 Added Files: RunApp.c Log Message: Example for new run application utility function --- NEW FILE --- #include <stdio.h> #include <Xmt/Xmt.h> #include <Xmt/ExtButton.h> #include <Xmt/WorkingBox.h> #include <Xmt/RunApplication.h> static Widget dialog; static void doneCallback(Widget w, XtPointer a, XtPointer b) { XtUnmanageChild(dialog); } static void doBg(Widget w, XtPointer a, XtPointer b) { char *arguments[] = { "date", "+%d-%b-%Y", NULL }; Arg args[10]; int n = 0; int error; int status; XtSetArg(args[n], XmtNmessage, "Running application"); n++; XtSetArg(args[n], XmtNshowScale, False); n++; dialog = XmtCreateWorkingDialog(w, "run", args, n); XtManageChild(dialog); status = XmtRunApplicationCallback("date", arguments, False, NULL, &error, w, doneCallback, NULL); if (status != XmtRUN_SUCCESS) { printf("failure: %d e=%d\n", status, error); XtUnmanageChild(dialog); } } int main(argc,argv) int argc; char **argv; { XtAppContext app; Widget toplevel, layout, button; toplevel = XtAppInitialize(&app, "BgWorker", NULL, 0, &argc, argv, NULL, NULL, 0); layout = XmtCreateLayout(toplevel, "layout", NULL, 0); XtManageChild(layout); button = XtVaCreateManagedWidget("pushMe", xmtExtButtonWidgetClass, layout, NULL); XtAddCallback(button, XmNactivateCallback, doBg, NULL); XtRealizeWidget(toplevel); XtAppMainLoop(app); } |
From: Grant M. <grm...@us...> - 2004-12-14 19:36:46
|
Update of /cvsroot/motiftools/xmt/examples/BackgroundWorker In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18105 Added Files: worker.c Log Message: Example for new background/parallel utility function --- NEW FILE --- #include <stdio.h> #include <Xmt/Xmt.h> #include <Xmt/ExtButton.h> #include <Xmt/WorkingBox.h> #include <Xmt/BackgroundWorker.h> static void worker(void *workerInstance, void *myData) { int i; printf("Worker begins\n"); for (i = 0; i < 100; i += 4) { sleep(1); XmtWorkerSetPercent(workerInstance, i); } printf("Worker ends\n"); } static void doBg(Widget w, XtPointer a, XtPointer b) { XmtBackgroundWorkingBox(w, worker, "Processing", True, NULL, NULL); } int main(argc,argv) int argc; char **argv; { XtAppContext app; Widget toplevel, layout, button; toplevel = XtAppInitialize(&app, "BgWorker", NULL, 0, &argc, argv, NULL, NULL, 0); layout = XmtCreateLayout(toplevel, "layout", NULL, 0); XtManageChild(layout); button = XtVaCreateManagedWidget("pushMe", xmtExtButtonWidgetClass, layout, NULL); XtAddCallback(button, XmNactivateCallback, doBg, NULL); XtRealizeWidget(toplevel); XtAppMainLoop(app); } |
From: Grant M. <grm...@us...> - 2004-12-14 19:35:44
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17853 Added Files: BackgroundWorker.c BackgroundWorker.h RunApplication.c RunApplication.h Log Message: New utilities: run parallel/background task, run application --- NEW FILE --- /* * Motif Tools Library, Version 3.1 * $Id: BackgroundWorker.c,v 1.1 2004/12/14 19:35:34 grmcdorman Exp $ * * Written by Grant McDorman * Copyright (c) 2004 Grant McDorman * All Rights Reserved. See the file COPYRIGHT for details. * This is open source software. See the file LICENSE for details. * There is no warranty for this software. See NO_WARRANTY for details. * * $Log: BackgroundWorker.c,v $ * Revision 1.1 2004/12/14 19:35:34 grmcdorman * New utilities: run parallel/background task, run application * */ #include <Xmt/BackgroundWorker.h> #include <Xmt/WorkingBox.h> #ifdef USE_PTHREADS #include <pthread.h> #else #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #endif typedef struct { int pipe[2]; /* communication pipe */ Widget dialog; /* working box dialog */ XmtWorker worker; /* worker */ XmtUIWorker uiWorker; /* UI worker */ void *worker_data;/* argument for worker */ int running; /* true (nonzero) while running */ } worker_data; static void *thread_master(void *vdata) { worker_data *data = (worker_data *) vdata; (data->worker)(vdata, data->worker_data); data->running = 0; close(data->pipe[1]); #ifdef USE_PTHREADS pthread_exit(0); #else exit(0); #endif } static void monitor(XtPointer closure, int *source, XtInputId *id) { int status; char buffer[1]; worker_data *data = (worker_data *) closure; status = read(*source, buffer, 1); if (status <= 0) { /* pipe closed */ data->running = 0; } else if (buffer[0] >= 0) { /* buffer[0] represents percent to report to working box */ if (XtIsSubclass(data->dialog, xmtWorkingBoxWidgetClass)) { XmtWorkingBoxSetScaleValue(data->dialog, buffer[0]); } } /* else application specific */ { if (data->uiWorker != NULL) { /* pass message char w/o high bit */ (data->uiWorker)(data->worker_data, buffer[0] & ~0x80); } } } /* Tell the UI thread to update a progress bar */ void XmtWorkerSetPercent(void *boxdata, int percent) { worker_data *data = (worker_data *) boxdata; char message[1]; message[0] = (char) percent; write(data->pipe[1], message, 1); } /* Cause the UI thread to wake up */ void XmtWorkerMessage(void *boxdata, char message) { worker_data *data = (worker_data *) boxdata; char buffer[1]; buffer[0] = ( (char) 0x80 ) | message; write(data->pipe[1], buffer, 1); } int XmtBackgroundWorkingBox(Widget parent, XmtWorker worker, String message, Boolean showScale, void *argument, XmtUIWorker uiWorker) { int status; Arg args[10]; int n = 0; Widget dialog; XtSetArg(args[n], XmtNmessage, message); n++; XtSetArg(args[n], XmtNshowScale, showScale); n++; dialog = XmtCreateWorkingDialog(parent, "xmtBackgroundWorker", args, n); XtManageChild(dialog); status = XmtBackgroundWorker(dialog, worker, argument, uiWorker); XtDestroyWidget(dialog); return status; } int XmtBackgroundWorker(Widget any, XmtWorker worker, void *argument, XmtUIWorker uiWorker) { worker_data data; int status; int max_fd; XtAppContext app_context = XtWidgetToApplicationContext(any); XtInputId inputId; #ifdef USE_PTHREADS pthread_t a_thread; #else pid_t a_pid; #endif status = pipe(data.pipe); if (status != 0) return status; data.worker = worker; data.worker_data = argument; data.uiWorker = uiWorker; data.running = 1; /* Put up the working dialog */ data.dialog = any; /* Arrange to listen on worker's pipe */ inputId = XtAppAddInput(app_context, data.pipe[0], (XtPointer) (XtInputReadMask | XtInputExceptMask), monitor, &data); XmUpdateDisplay(data.dialog); #ifdef USE_PTHREADS /* Using threads. */ status = pthread_create(&a_thread, NULL, thread_master, &data); if (status != 0) { close(data.pipe[0]); close(data.pipe[1]); return status; } /* X event loop until done. */ do { XtAppProcessEvent(app_context, XtIMXEvent | XtIMTimer | XtIMAlternateInput #ifdef XtIMSignal | XtIMSignal #endif ); } while (data.running); /* cleanup */ pthread_join(a_thread, NULL); #else /* use fork() */ a_pid = fork(); if (a_pid == 0) { /* child */ close(data.pipe[0]); /* close reading end */ thread_master(&data); /* run process */ exit(0); /* done */ } else if (a_pid > 0) { /* parent */ close(data.pipe[1]); /* close writing end */ do { XtAppProcessEvent(app_context, XtIMXEvent | XtIMTimer | XtIMAlternateInput #ifdef XtIMSignal | XtIMSignal #endif ); } while (data.running); /* reap zombie */ waitpid(a_pid, &status, 0); } else { /* error */ close(data.pipe[0]); close(data.pipe[1]); return a_pid; } #endif XtRemoveInput(inputId); close(data.pipe[0]); close(data.pipe[1]); return 0; } --- NEW FILE --- /* * Motif Tools Library, Version 3.1 * $Id: BackgroundWorker.h,v 1.1 2004/12/14 19:35:34 grmcdorman Exp $ * * Written by Grant McDorman * Copyright (c) 2004 by Grant McDorman * All Rights Reserved. See the file COPYRIGHT for details. * This is open source software. See the file LICENSE for details. * There is no warranty for this software. See NO_WARRANTY for details. * * $Log: BackgroundWorker.h,v $ * Revision 1.1 2004/12/14 19:35:34 grmcdorman * New utilities: run parallel/background task, run application * * */ #ifndef _XmtBackgroundWorker_h #define _XmtBackgroundWorker_h #include <X11/Intrinsic.h> #ifdef __cplusplus extern "C" { #endif /* XmtWorker runs in the background. It must *not* do any UI related operations. * It may be run as a separate process (i.e. fork()) or as a thread. To send * messages to the UI process/thread, it can call XmtWorkingBoxWorkerMessage. * * If XmtBackgroundWorkingBox is used, or XmtBackgroundWorker is passed an * XmtWorkingBox, the worker can also call XmtWorkingBoxWorkerSetPercent * to update the progress indicator on the working box. * * 'boxHandle' is an opaque pointer to be used in XmtWorkingBoxWorkerSetPercent * or XmtWorkingBoxWorkerMessage. 'argument' is the arbitrary pointer passed * to XmtBackgroundWorker or XmtBackgroundWorkingBox. */ typedef void (*XmtWorker)(void *boxHandle, void *argument); /* XmtUIWorker is called in the UI context when the worker calls * XmtWorkingBoxWorkerMessage. The message value ranges from 0 to 127. */ typedef void (*XmtUIWorker)(void *argument, char message); /* Worker: call this to set percentage on XmtWorkingBox progress indicator. */ extern void XmtWorkerSetPercent(void *boxdata, int percent); /* Worker: call this to get XmtUIWorker called with the value of 'message'. */ extern void XmtWorkerMessage(void *boxdata, char message); /* Create and display an XmtWorkingBox (with the name xmtBackgroundWorker), * and then call XmtBackgroundWorker with the passed arguments and the working box. * Returns XmtBackgroundWorker return value. XmtUIWorker can be NULL */ extern int XmtBackgroundWorkingBox(Widget parent, XmtWorker worker, String message, Boolean showProgress, void *argument, XmtUIWorker workerMsg); /* Run 'XmtWorker' in the background. Return 0 when successful; otherwise returns system * error code. XmtUIWorker can be NULL. */ extern int XmtBackgroundWorker(Widget any, XmtWorker worker, void *argument, XmtUIWorker workerMsg); #ifdef __cplusplus }; #endif #endif --- NEW FILE --- /* * Motif Tools Library, Version 3.1 * $Id: RunApplication.c,v 1.1 2004/12/14 19:35:34 grmcdorman Exp $ * * Written by Grant McDorman * Copyright (c) 2004 by Grant McDorman * All Rights Reserved. See the file COPYRIGHT for details. * This is open source software. See the file LICENSE for details. * There is no warranty for this software. See NO_WARRANTY for details. * * $Log: RunApplication.c,v $ * Revision 1.1 2004/12/14 19:35:34 grmcdorman * New utilities: run parallel/background task, run application * * */ #include <Xmt/RunApplication.h> #include <errno.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <fcntl.h> #include <signal.h> typedef struct RunDataStruct { XmtRunApplicationCallbackStruct callbackData; XtCallbackProc doneCallback; XtPointer doneCallbackClosure; Widget any; struct RunDataStruct *next; } RunData; #define PIPE_READ_INDEX 0 #define PIPE_WRITE_INDEX 1 static int monitoring = 0; static void (*old_SIGCHLD)(int); static RunData *firstData = NULL; static int monitor_pipe[2]; static XtInputId monitor_id; #define ERROR_RETURN(x, status) {\ close(pipe_fds[PIPE_READ_INDEX]); \ close(pipe_fds[PIPE_WRITE_INDEX]); \ if (error != NULL) *error = status; \ if (data != NULL) XtFree((char *)data); \ return x; \ } #define CHECK_STATUS(x, status) if (status != 0) { ERROR_RETURN(x, status) } /* * Some child process has exited. Look in our list; if it belongs to us, * hande it. */ static void exitNotify(XtPointer closure, int *source, XtInputId *id) { RunData *data, *prior; pid_t pid; for (data = firstData, prior = NULL; data != NULL; ) { /* try to reap child */ do { pid = waitpid(data->callbackData.pid, &data->callbackData.exit_status, WNOHANG); } while (pid == -1 && errno == EINTR); if (pid == data->callbackData.pid) { (*data->doneCallback)(data->any, (XtPointer) &data->callbackData, data->doneCallbackClosure); if (prior != NULL) { prior->next = data->next; } else { firstData = data->next; } prior = data; data = data->next; XtFree((char *) prior); } else { data = data->next; } } /* if we're no longer monitoring anything, clean up */ if (firstData == NULL) { XtRemoveInput(monitor_id); close(monitor_pipe[0]); close(monitor_pipe[1]); signal(SIGCHLD, old_SIGCHLD); old_SIGCHLD = NULL; monitoring = 0; } } /* * write a byte on monitor pipe to wake up exitNotify handler */ static void handle_SIGCHLD(int value) { static char buffer[1] = { 'C' }; write(monitor_pipe[PIPE_WRITE_INDEX], buffer, 1); if (old_SIGCHLD != NULL && old_SIGCHLD != SIG_IGN && old_SIGCHLD != SIG_DFL) { (*old_SIGCHLD)(value); } } XmtRunStatus XmtRunApplicationCallback(const char *program, char * const*arguments, int detached, pid_t *pid, int *error, Widget any, XtCallbackProc doneCallback, XtPointer doneCallbackClosure) { pid_t child; int pipe_fds[2]; int status; char buffer[1]; void (*old_signal)(int); RunData *data = NULL;; if (!detached && doneCallback != NULL) { if (!monitoring) { old_SIGCHLD = signal(SIGCHLD, handle_SIGCHLD); status = pipe(monitor_pipe); CHECK_STATUS(XmtRUN_FAIL_PIPE, status); monitor_id = XtAppAddInput(XtWidgetToApplicationContext(any), monitor_pipe[PIPE_READ_INDEX], (XtPointer) XtInputReadMask, exitNotify, (XtPointer) data); monitoring = 1; } data = (RunData *) XtMalloc(sizeof *data); data->callbackData.any = any; data->callbackData.exit_status = ~0; data->doneCallback = doneCallback; data->doneCallbackClosure = doneCallbackClosure; } status = pipe(pipe_fds); CHECK_STATUS(XmtRUN_FAIL_PIPE, status) status = fcntl(pipe_fds[PIPE_READ_INDEX], F_SETFD, FD_CLOEXEC); CHECK_STATUS(XmtRUN_FAIL_FCNTL, status); status = fcntl(pipe_fds[PIPE_WRITE_INDEX], F_SETFD, FD_CLOEXEC); CHECK_STATUS(XmtRUN_FAIL_FCNTL, status); child = fork(); if (child < 0) { close(pipe_fds[PIPE_READ_INDEX]); close(pipe_fds[PIPE_WRITE_INDEX]); ERROR_RETURN(XmtRUN_FAIL_FORK, child) } if (child == 0) { /* child */ close(pipe_fds[PIPE_READ_INDEX]); if (detached) { /* fork again to detach */ pid_t child2 = fork(); if (child2 < 0) { buffer[0] = (char) XmtRUN_FAIL_FORK; write(pipe_fds[PIPE_WRITE_INDEX], buffer, 1); write(pipe_fds[PIPE_WRITE_INDEX], &child2, sizeof child2); exit(0); } if (child2 != 0) { /* process to exit */ exit(0); } } /* if this succeeds, it will close the pipe */ status = execvp(program, arguments); /* execv failure */ buffer[0] = (char) XmtRUN_FAIL_EXEC; write(pipe_fds[PIPE_WRITE_INDEX], buffer, 1); write(pipe_fds[PIPE_WRITE_INDEX], &status, sizeof status); exit(0); } /* parent process. Read from pipe; this will fail * or return a status value. */ if (data != NULL) { data->callbackData.pid = child; } /* close write side of pipe, so the read will fail if/when * the child closes it */ close(pipe_fds[PIPE_WRITE_INDEX]); /* * attempt to read a byte from the pipe */ old_signal = signal(SIGPIPE, SIG_IGN); /* prevent SIGPIPE from causing problems */ status = read(pipe_fds[PIPE_READ_INDEX], buffer, 1); (void) signal(SIGPIPE, old_signal); /* restore SIGPIPE handling */ if (status == 1 || detached) { /* reap child process if it's detached or if it failed. */ waitpid(child, NULL, NULL); } if (status == 1) { /* read worked. That means the child process failed; * the detailed error code follows. */ status = 0; read(pipe_fds[PIPE_READ_INDEX], &status, sizeof status); ERROR_RETURN(buffer[0], status); } /* * Worked. Add to list, if monitoring requested. */ if (data != NULL) { data->next = firstData; firstData = data; } close(pipe_fds[PIPE_READ_INDEX]); /* * Check for exit, in case the child process exited before processing competed. */ exitNotify(NULL, NULL, NULL); return XmtRUN_SUCCESS; } XmtRunStatus XmtRunApplication(const char *program, char *const*arguments, int detached, pid_t *pid, int *error) { return XmtRunApplicationCallback(program, arguments, detached, pid, error, NULL, NULL, NULL); } --- NEW FILE --- /* * Motif Tools Library, Version 3.1 * $Id: RunApplication.h,v 1.1 2004/12/14 19:35:34 grmcdorman Exp $ * * Written by Grant McDorman * Copyright (c) 2004 by Grant McDorman * All Rights Reserved. See the file COPYRIGHT for details. * This is open source software. See the file LICENSE for details. * There is no warranty for this software. See NO_WARRANTY for details. * * $Log: RunApplication.h,v $ * Revision 1.1 2004/12/14 19:35:34 grmcdorman * New utilities: run parallel/background task, run application * * */ #ifndef _XmtRunApplication_h #define _XmtRunApplication_h #ifdef __cplusplus extern "C" { #endif #include <sys/types.h> /* pid_t */ #include <X11/Intrinsic.h> typedef struct { pid_t pid; Widget any; int exit_status; } XmtRunApplicationCallbackStruct; typedef enum { XmtRUN_SUCCESS=0, XmtRUN_FAIL_PIPE, XmtRUN_FAIL_FORK, XmtRUN_FAIL_FCNTL, XmtRUN_FAIL_EXEC, XmtRUN_FAIL_OTHER } XmtRunStatus; /* Start program 'program' with null-terminated argument list 'arguments'. If 'detached' true, * detach (so you don't get zombie processes). Return PID of new program in 'pid' (can be NULL); * return system error code in 'error'. Call 'doneCallback' when done IF detached false (can be NULL). * * execvp is used to run the program, so if the program isn't an absolute path, $PATH is searched to * find it. */ extern XmtRunStatus XmtRunApplicationCallback(const char *program, char *const*arguments, int detached, pid_t *pid, int *error, Widget any, XtCallbackProc doneCallback, XtPointer doneCallbackClosure); /* Start program 'program' with null-terminated argument list 'arguments'. If 'detached' true, * detach (so you don't get zombie processes). Return PID of new program in 'pid' (can be NULL); * return system error code in 'error'. * * Equivalent to XmtRunApplicationCallback(program, arguments, detached,pid, error, NULL, NULL, NULL). */ extern XmtRunStatus XmtRunApplication(const char *program, char *const*arguments, int detached, pid_t *pid, int *error); #ifdef __cplusplus }; #endif #endif |
From: Grant M. <grm...@us...> - 2004-12-14 19:34:54
|
Update of /cvsroot/motiftools/xmt/examples/RunApplication In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17551/RunApplication Log Message: Directory /cvsroot/motiftools/xmt/examples/RunApplication added to the repository |
From: Grant M. <grm...@us...> - 2004-12-14 19:34:53
|
Update of /cvsroot/motiftools/xmt/examples/BackgroundWorker In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17551/BackgroundWorker Log Message: Directory /cvsroot/motiftools/xmt/examples/BackgroundWorker added to the repository |
From: Grant M. <grm...@us...> - 2004-12-10 01:47:10
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3884 Modified Files: ExtToggle.c Log Message: This contains two fixes for ExtToggle: * The indicator should be centered according to the first line of text. * In Motif 2.x, the indicator appearance is now correctly selected, using proper Motif rules. Index: ExtToggle.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/ExtToggle.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** ExtToggle.c 15 Aug 2002 01:27:25 -0000 1.7 --- ExtToggle.c 10 Dec 2004 01:47:00 -0000 1.8 *************** *** 10,13 **** --- 10,19 ---- * * $Log$ + * Revision 1.8 2004/12/10 01:47:00 grmcdorman + * This contains two fixes for ExtToggle: + * * The indicator should be centered according to the first line of text. + * * In Motif 2.x, the indicator appearance is now correctly selected, using + * proper Motif rules. + * * Revision 1.7 2002/08/15 01:27:25 grmcdorman * Correct error in resources *************** *** 702,705 **** --- 708,770 ---- /* Toggle Drawing Support */ + + /**************************************************************** + * IndicatorType + * On Motif 1.x, the only supported indicator type is the square + * (N of Many) or the diamond (1 of N). + * + * On Motif 2.x, the appearance is controlled by a combination of + * the indicatorOn, indicatorType, and XmDisplay enableToggleVisual + * resources. + * + * Fortunately, the choice between N of the set and one of the set + * doesn't change. + * + * So this function returns the indicator appearance as follows: + * For an N_OF_MANY, the value of indicatorOn is returned, + * adjusted according to XmDisplay.enableVisual if appropriate. + * + * For the others - all one of a set, i.e. radio-button style - + * the value of indicatorType is returned, adjusted according + * to XmDisplay.enableVisual if appropriate. + * + ****************************************************************/ + #if NeedFunctionPrototypes + static int GetIndicatorType(XmtExtToggleWidget lw) + #else + static int GetIndicatorType(lw) + XmtExtToggleWidget lw; + #endif + { + int indicator = lw->toggle.ind_on; + int type = lw->toggle.ind_type; + + #if defined(XmNenableToggleVisual) + Widget xmDisplay = XmGetXmDisplay(XtDisplay( (Widget) lw ) ); + Boolean enableToggleVisual; + XtVaGetValues(xmDisplay, XmNenableToggleVisual, &enableToggleVisual, NULL); + + switch (type) { + case XmONE_OF_MANY: + type = enableToggleVisual ? XmONE_OF_MANY_ROUND : XmONE_OF_MANY_DIAMOND; + break; + case XmN_OF_MANY: + if (indicator == XmINDICATOR_FILL) { + type = enableToggleVisual ? XmINDICATOR_CHECK_BOX : XmINDICATOR_BOX; + } else { + type = indicator; + } + break; + /* default: type as is */ + } + #else + /* Motif 1.x: no fancy stuff */ + if (type == XmN_OF_MANY) { + type = indicator + } + #endif + return type; + } + /**************************************************************** * DrawToggle *************** *** 716,719 **** --- 781,788 ---- int size = lw->toggle.indicator_dim; int x, y; + #if XmVersion >= 2000 + Dimension text_height; + int line_count; + #endif if (lw->label.string_direction == XmSTRING_DIRECTION_R_TO_L) { *************** *** 736,739 **** --- 805,826 ---- } else { y = lw->ext_toggle.label_y; + #if XmVersion >= 2000 + /* + * Center vertically to first line of text (as done in later Motif + * versions). ... note that this is broken if the text contains + * different height lines. (Yes, I did look at the Motif source.) + * + * A non-broken version would extract the XmString substring to the + * first separator, and use that for the height. + */ + + text_height = XmStringHeight(lw->label.font, lw->label._label); + line_count = XmStringLineCount(lw->label._label); + if (line_count < 1) line_count = 1; + /* single line height */ + text_height /= line_count; + + y += (text_height - size) / 2; + #endif } *************** *** 744,752 **** DrawToggleNOfMany(lw, draw_set, x, y, size); #if XmVersion >= 2000 ! } else if (lw->toggle.ind_type == XmONE_OF_MANY_ROUND) { DrawToggleOneOfManyRound(lw, draw_set, x, y, size); #endif ! } else /* lw->toggle.ind_type == XmONE_OF_MANY || ! lw->toggle.ind_type == XmONE_OF_MANY_DIAMOND*/ { DrawToggleOneOfManyDiamond(lw, draw_set, x, y, size); } --- 831,838 ---- DrawToggleNOfMany(lw, draw_set, x, y, size); #if XmVersion >= 2000 ! } else if (GetIndicatorType(lw) == XmONE_OF_MANY_ROUND) { DrawToggleOneOfManyRound(lw, draw_set, x, y, size); #endif ! } else /* GetIndicatorType(lw) == XmONE_OF_MANY_DIAMOND */ { DrawToggleOneOfManyDiamond(lw, draw_set, x, y, size); } *************** *** 770,773 **** --- 856,860 ---- int inside_x, inside_y, inside_size; int shadow = DETAIL_SHADOW_THICKNESS(lw); + int type = GetIndicatorType(lw); /* Motif adjusts square toggle size to look similar to rectangular */ *************** *** 783,787 **** #if XmVersion >= 2000 ! if (lw->toggle.ind_on & XmINDICATOR_3D_BOX) { XmeDrawShadows(lw->core.screen->display, lw->ext_toggle.buffer_pixmap, lw->primitive.top_shadow_GC, lw->primitive.bottom_shadow_GC, --- 870,874 ---- #if XmVersion >= 2000 ! if (type & XmINDICATOR_3D_BOX) { XmeDrawShadows(lw->core.screen->display, lw->ext_toggle.buffer_pixmap, lw->primitive.top_shadow_GC, lw->primitive.bottom_shadow_GC, *************** *** 815,821 **** } #if XmVersion >= 2000 ! if (lw->toggle.ind_on != XmINDICATOR_BOX && ! (lw->toggle.ind_on & (XmINDICATOR_CHECK | XmINDICATOR_CROSS)) && draw_set) { ! /* FIXME: this may not be right in all circumstances. */ XSetClipMask(lw->core.screen->display, lw->label.normal_GC, None); XmeDrawIndicator(lw->core.screen->display, lw->ext_toggle.buffer_pixmap, --- 902,911 ---- } #if XmVersion >= 2000 ! /* Draw the marker (cross, check) as indicated */ ! if (type != XmINDICATOR_BOX && ! (type & (XmINDICATOR_CHECK | XmINDICATOR_CROSS)) && draw_set) { ! /* FIXME: this may not be right in all circumstances. ! * To date it has worked, though. ! */ XSetClipMask(lw->core.screen->display, lw->label.normal_GC, None); XmeDrawIndicator(lw->core.screen->display, lw->ext_toggle.buffer_pixmap, *************** *** 824,828 **** inside_size, inside_size, 0, ! lw->toggle.ind_on); } #endif --- 914,918 ---- inside_size, inside_size, 0, ! type); } #endif *************** *** 830,834 **** /**************************************************************** ! * DrawToggleOneOfManyDiamond - does not work in Motif 1.x ****************************************************************/ #if NeedFunctionPrototypes --- 920,924 ---- /**************************************************************** ! * DrawToggleOneOfManyDiamond - may not work in Motif 1.x ****************************************************************/ #if NeedFunctionPrototypes |
From: Grant M. <grm...@us...> - 2003-10-29 16:38:25
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv4816 Modified Files: Pixmap.c Log Message: GC allocated in XmtCreateStippledPixmap was not freed Index: Pixmap.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/Pixmap.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** Pixmap.c 27 Oct 2003 20:19:59 -0000 1.10 --- Pixmap.c 29 Oct 2003 16:38:22 -0000 1.11 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.11 2003/10/29 16:38:22 grmcdorman + * GC allocated in XmtCreateStippledPixmap was not freed + * * Revision 1.10 2003/10/27 20:19:59 grmcdorman * Major performance rework for XmtRecolorPixmap *************** *** 954,957 **** --- 957,961 ---- XmDestroyPixmap(w->core.screen, stipple); + XFreeGC(w->core.screen->display, gc); return computed; |
From: Grant M. <grm...@us...> - 2003-10-28 00:16:20
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv8912 Modified Files: ExtWidgets.h ExtLabelS.c Log Message: Move strings to keep binary compatibility Index: ExtWidgets.h =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/ExtWidgets.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** ExtWidgets.h 14 Aug 2003 02:17:24 -0000 1.6 --- ExtWidgets.h 27 Oct 2003 20:18:59 -0000 1.7 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.7 2003/10/27 20:18:59 grmcdorman + * Move strings to keep binary compatibility + * * Revision 1.6 2003/08/14 02:17:24 grmcdorman * New XmtExtLabelSetPixmap function *************** *** 61,64 **** --- 64,69 ---- /* + * WARNING: Add names at the end of the list to maintain binary compatiblity. + * * List of resource names: * XmtNarmMask *************** *** 81,85 **** * XmtNselectPixmapMask * XmtNshadowType - * XmtNshape * XmtNshowBoth * XmtNspacing --- 86,89 ---- *************** *** 95,99 **** * XmtCPosition * XmtCShadowType - * XmtCShape * XmtCShowBoth * XmtCSpacing --- 99,102 ---- *************** *** 109,112 **** --- 112,120 ---- * XmtRVerticalAlignment * + * New names below: + * XmtNshape + * XmtCShape + * + * * Run this file through this awk script: * BEGIN { cnt = 0; } *************** *** 129,132 **** --- 137,141 ---- * to get the body of the ExtLabelS.c file. */ + #ifndef XmtNarmMask #define XmtNarmMask ((char*)&XmtExtLabelStrings[0]) *************** *** 186,263 **** #define XmtNshadowType ((char*)&XmtExtLabelStrings[300]) #endif - #ifndef XmtNshape - #define XmtNshape ((char*)&XmtExtLabelStrings[311]) - #endif #ifndef XmtNshowBoth ! #define XmtNshowBoth ((char*)&XmtExtLabelStrings[317]) #endif #ifndef XmtNspacing ! #define XmtNspacing ((char*)&XmtExtLabelStrings[326]) #endif #ifndef XmtNtoggleMode ! #define XmtNtoggleMode ((char*)&XmtExtLabelStrings[334]) #endif #ifndef XmtNverticalAlignment ! #define XmtNverticalAlignment ((char*)&XmtExtLabelStrings[345]) #endif #ifndef XmtCAlignment ! #define XmtCAlignment ((char*)&XmtExtLabelStrings[363]) #endif #ifndef XmtCDetailShadowThickness ! #define XmtCDetailShadowThickness ((char*)&XmtExtLabelStrings[373]) #endif #ifndef XmtCIndeterminatePixmap ! #define XmtCIndeterminatePixmap ((char*)&XmtExtLabelStrings[395]) #endif #ifndef XmtCMargin ! #define XmtCMargin ((char*)&XmtExtLabelStrings[415]) #endif #ifndef XmtCMask ! #define XmtCMask ((char*)&XmtExtLabelStrings[422]) #endif #ifndef XmtCMotifBugs ! #define XmtCMotifBugs ((char*)&XmtExtLabelStrings[427]) #endif #ifndef XmtCPosition ! #define XmtCPosition ((char*)&XmtExtLabelStrings[437]) #endif #ifndef XmtCShadowType ! #define XmtCShadowType ((char*)&XmtExtLabelStrings[446]) ! #endif ! #ifndef XmtCShape ! #define XmtCShape ((char*)&XmtExtLabelStrings[457]) #endif #ifndef XmtCShowBoth ! #define XmtCShowBoth ((char*)&XmtExtLabelStrings[463]) #endif #ifndef XmtCSpacing ! #define XmtCSpacing ((char*)&XmtExtLabelStrings[472]) #endif #ifndef XmtCStyle ! #define XmtCStyle ((char*)&XmtExtLabelStrings[480]) #endif #ifndef XmtRAlignment ! #define XmtRAlignment ((char*)&XmtExtLabelStrings[486]) #endif #ifndef XmtRBoolean ! #define XmtRBoolean ((char*)&XmtExtLabelStrings[496]) #endif #ifndef XmtRDimension ! #define XmtRDimension ((char*)&XmtExtLabelStrings[504]) #endif #ifndef XmtRBitmask ! #define XmtRBitmask ((char*)&XmtExtLabelStrings[514]) #endif #ifndef XmtRExtLabelPosition ! #define XmtRExtLabelPosition ((char*)&XmtExtLabelStrings[522]) #endif #ifndef XmtRInsensitiveStyle ! #define XmtRInsensitiveStyle ((char*)&XmtExtLabelStrings[539]) #endif #ifndef XmtRShadowType ! #define XmtRShadowType ((char*)&XmtExtLabelStrings[556]) #endif #ifndef XmtRVerticalAlignment ! #define XmtRVerticalAlignment ((char*)&XmtExtLabelStrings[567]) #endif --- 195,272 ---- #define XmtNshadowType ((char*)&XmtExtLabelStrings[300]) #endif #ifndef XmtNshowBoth ! #define XmtNshowBoth ((char*)&XmtExtLabelStrings[311]) #endif #ifndef XmtNspacing ! #define XmtNspacing ((char*)&XmtExtLabelStrings[320]) #endif #ifndef XmtNtoggleMode ! #define XmtNtoggleMode ((char*)&XmtExtLabelStrings[328]) #endif #ifndef XmtNverticalAlignment ! #define XmtNverticalAlignment ((char*)&XmtExtLabelStrings[339]) #endif #ifndef XmtCAlignment ! #define XmtCAlignment ((char*)&XmtExtLabelStrings[357]) #endif #ifndef XmtCDetailShadowThickness ! #define XmtCDetailShadowThickness ((char*)&XmtExtLabelStrings[367]) #endif #ifndef XmtCIndeterminatePixmap ! #define XmtCIndeterminatePixmap ((char*)&XmtExtLabelStrings[389]) #endif #ifndef XmtCMargin ! #define XmtCMargin ((char*)&XmtExtLabelStrings[409]) #endif #ifndef XmtCMask ! #define XmtCMask ((char*)&XmtExtLabelStrings[416]) #endif #ifndef XmtCMotifBugs ! #define XmtCMotifBugs ((char*)&XmtExtLabelStrings[421]) #endif #ifndef XmtCPosition ! #define XmtCPosition ((char*)&XmtExtLabelStrings[431]) #endif #ifndef XmtCShadowType ! #define XmtCShadowType ((char*)&XmtExtLabelStrings[440]) #endif #ifndef XmtCShowBoth ! #define XmtCShowBoth ((char*)&XmtExtLabelStrings[451]) #endif #ifndef XmtCSpacing ! #define XmtCSpacing ((char*)&XmtExtLabelStrings[460]) #endif #ifndef XmtCStyle ! #define XmtCStyle ((char*)&XmtExtLabelStrings[468]) #endif #ifndef XmtRAlignment ! #define XmtRAlignment ((char*)&XmtExtLabelStrings[474]) #endif #ifndef XmtRBoolean ! #define XmtRBoolean ((char*)&XmtExtLabelStrings[484]) #endif #ifndef XmtRDimension ! #define XmtRDimension ((char*)&XmtExtLabelStrings[492]) #endif #ifndef XmtRBitmask ! #define XmtRBitmask ((char*)&XmtExtLabelStrings[502]) #endif #ifndef XmtRExtLabelPosition ! #define XmtRExtLabelPosition ((char*)&XmtExtLabelStrings[510]) #endif #ifndef XmtRInsensitiveStyle ! #define XmtRInsensitiveStyle ((char*)&XmtExtLabelStrings[527]) #endif #ifndef XmtRShadowType ! #define XmtRShadowType ((char*)&XmtExtLabelStrings[544]) #endif #ifndef XmtRVerticalAlignment ! #define XmtRVerticalAlignment ((char*)&XmtExtLabelStrings[555]) ! #endif ! #ifndef XmtNshape ! #define XmtNshape ((char*)&XmtExtLabelStrings[573]) ! #endif ! #ifndef XmtCShape ! #define XmtCShape ((char*)&XmtExtLabelStrings[579]) #endif Index: ExtLabelS.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/ExtLabelS.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** ExtLabelS.c 13 Aug 2002 23:38:56 -0000 1.5 --- ExtLabelS.c 27 Oct 2003 20:18:59 -0000 1.6 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.6 2003/10/27 20:18:59 grmcdorman + * Move strings to keep binary compatibility + * * Revision 1.5 2002/08/13 23:38:56 grmcdorman * ExtToggle: bug fix, XmtExtToggleSet state did not work when toggle was insensitive. *************** *** 69,73 **** 's','e','l','e','c','t','P','i','x','m','a','p','M','a','s','k', 0, 's','h','a','d','o','w','T','y','p','e', 0, - 's','h','a','p','e', 0, 's','h','o','w','B','o','t','h', 0, 's','p','a','c','i','n','g', 0, --- 72,75 ---- *************** *** 82,86 **** 'P','o','s','i','t','i','o','n', 0, 'S','h','a','d','o','w','T','y','p','e', 0, - 'S','h','a','p','e', 0, 'S','h','o','w','B','o','t','h', 0, 'S','p','a','c','i','n','g', 0, --- 84,87 ---- *************** *** 94,96 **** --- 95,99 ---- 'S','h','a','d','o','w','T','y','p','e', 0, 'V','e','r','t','i','c','a','l','A','l','i','g','n','m','e','n','t', 0, + 's','h','a','p','e', 0, + 'S','h','a','p','e', 0, }; |
From: Grant M. <grm...@us...> - 2003-10-27 21:33:56
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv23794/d Modified Files: PixelCvt.c Visual.c Log Message: Change XmtGetVisual/_XmtFetchVisual to handle case when called with uninitialized widget. Also provide capability to handle non-standard widgets with Visual resource Index: PixelCvt.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/PixelCvt.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** PixelCvt.c 19 Sep 2001 02:57:18 -0000 1.2 --- PixelCvt.c 27 Oct 2003 21:29:04 -0000 1.3 *************** *** 10,13 **** --- 10,18 ---- * * $Log$ + * Revision 1.3 2003/10/27 21:29:04 grmcdorman + * Change XmtGetVisual/_XmtFetchVisual to handle case when called + * with uninitialized widget. Also provide capability to handle non-standard widgets + * with Visual resource + * * Revision 1.2 2001/09/19 02:57:18 grmcdorman * This change makes the following modifications: *************** *** 62,66 **** Widget rootshell = *((Widget *)args[0].addr); Colormap colormap = *((Colormap *)args[1].addr); ! Visual *visual = *((Visual **)args[2].addr); int status; Pixel pixel; --- 67,72 ---- Widget rootshell = *((Widget *)args[0].addr); Colormap colormap = *((Colormap *)args[1].addr); ! /* pointer to Visual is returned */ ! Visual *visual = ((Visual *)args[2].addr); int status; Pixel pixel; Index: Visual.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/Visual.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** Visual.c 19 Sep 2001 02:57:18 -0000 1.2 --- Visual.c 27 Oct 2003 21:29:04 -0000 1.3 *************** *** 10,13 **** --- 10,18 ---- * * $Log$ + * Revision 1.3 2003/10/27 21:29:04 grmcdorman + * Change XmtGetVisual/_XmtFetchVisual to handle case when called + * with uninitialized widget. Also provide capability to handle non-standard widgets + * with Visual resource + * * Revision 1.2 2001/09/19 02:57:18 grmcdorman * This change makes the following modifications: *************** *** 46,54 **** #endif { while(!XtIsShell(w)) w = XtParent(w); ! if (((ShellWidget)w)->shell.visual != (Visual *)CopyFromParent) ! return ((ShellWidget)w)->shell.visual; ! else ! return DefaultVisualOfScreen(XtScreen(w)); } --- 51,75 ---- #endif { + #define NOVISUAL ((Visual *)-1) + #define COPYVISUAL ((Visual *)CopyFromParent) + + Visual *vis = NOVISUAL; + #ifdef SEARCHVISUAL + /* Don't assume only Shells have a Visual resource; search everything. */ + /* DANGER: This may crash'n'burn if the supplied widget is not initialized. */ + Arg args[1]; + XtSetArg(args[0], XmNvisual, &vis); + + XtGetValues(w, args, 1); + while (w != NULL && !XtIsShell(w) && vis == NOVISUAL) { + w = XtParent(w); + XtGetValues(w, args, 1); + } + if (vis == NOVISUAL) vis = COPYVISUAL; + #else while(!XtIsShell(w)) w = XtParent(w); ! vis = ((ShellWidget)w)->shell.visual; ! #endif ! return vis == COPYVISUAL ? DefaultVisualOfScreen(w->core.screen) : vis; } *************** *** 66,75 **** #endif { ! while(!XtIsShell(w)) w = XtParent(w); ! value->size = sizeof(Visual *); ! if (((ShellWidget)w)->shell.visual != (Visual *)CopyFromParent) ! value->addr = (XPointer) &((ShellWidget)w)->shell.visual; ! else ! value->addr = (XPointer) &DefaultVisualOfScreen(XtScreen(w)); } --- 87,138 ---- #endif { ! /* ! * We have a bit of an odd situation when we start with a Shell. ! * It's possible for this function to be invoked by string-to-pixel ! * conversion for the Core part of the Shell widget; this means that ! * the Shell part is not initialized. ! * ! * As a result, the shell.visual field is garbage. ! * ! * The rest of the time, everything is OK. ! * ! * So, to fix this we need to either: ! * 1) detect when this function is called with an uninitialized ! * Shell widget ! * or 2) detect when this function is called to convert the Core ! * pixel fields for a Shell widget ! * ! * The trick is that the shell is not inserted in its parent's ! * popup list until it's fully initialized. Thus, we can detect ! * case (1). In this case, it should be OK to return the default ! * visual, as the only Pixel fields in the Shell widget are those ! * in Core: background and borderPixel. Since the shell is not ! * a visible object (at least normally), we can use the default ! * visual - and if the result is wrong, it won't really matter. ! * ! * Of course, this doesn't work for the top-level (application) ! * shell, but we probably won't get called for that (usually ! * the converter that uses this function is installed after that ! * shell is created). ! */ ! int use_default = 0; ! if (XtIsShell(w) && !XtIsRealized(w) && w->core.parent != NULL) { ! Widget parent = w->core.parent; ! int i; ! use_default = 1; ! for (i = 0; i < parent->core.num_popups; i++) { ! if (parent->core.popup_list[i] == w) { ! use_default = 0; ! break; ! } ! } ! } ! ! value->size = sizeof(Visual); ! if (use_default) { ! value->addr = (XPointer) DefaultVisualOfScreen(w->core.screen); ! } else { ! value->addr = (XPointer) XmtGetVisual(XtIsShell(w) ? w : XtParent(w)); ! } } |
From: Grant M. <grm...@us...> - 2003-10-27 21:33:54
|
Update of /cvsroot/motiftools/xmt In directory sc8-pr-cvs1:/tmp/cvs-serv23794 Modified Files: Xmt.tmpl Log Message: Change XmtGetVisual/_XmtFetchVisual to handle case when called with uninitialized widget. Also provide capability to handle non-standard widgets with Visual resource Index: Xmt.tmpl =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt.tmpl,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** Xmt.tmpl 14 Aug 2003 02:25:25 -0000 1.6 --- Xmt.tmpl 27 Oct 2003 21:29:05 -0000 1.7 *************** *** 218,221 **** --- 218,233 ---- USECOMPONENTDEFINES = /* -DUSE_XmSTRING_COMPONENT */ + /* + * Define the variable below if you have some custom, non-shell + * widgets that have a Visual resource. This will allow + * XmtGetVisual to find the visual on these widgets. + * + * If this not defined, XmtGetVisual will only look at shell + * widgets. + * + * IF you don't understand what this is, leave it undefined. + */ + USECOMPONENTDEFINES = /* -DSEARCHVISUAL */ + /* * If you want XmtFindFile to use something other than the default |
From: Grant M. <grm...@us...> - 2003-10-27 21:33:54
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv24148 Modified Files: Xpm.c Log Message: Add comment about spurious Purify warning Index: Xpm.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/Xpm.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** Xpm.c 24 Apr 2002 23:09:22 -0000 1.3 --- Xpm.c 27 Oct 2003 21:30:13 -0000 1.4 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.4 2003/10/27 21:30:13 grmcdorman + * Add comment about spurious Purify warning + * * Revision 1.3 2002/04/24 23:09:22 grmcdorman * Fixes for sizing, add Default button support. Also, calculated pixmaps are now cached. *************** *** 1496,1499 **** --- 1499,1506 ---- XPutImage(dpy, *mask_return, gc, mask, 0, 0, 0, 0, mask->width, mask->height); + /* Note: Purify flags this as a 'freeing msmatched memory' (FMM), + * as the mask storage was allocated by XtMalloc() but is being + * freed by free(). This is harmless and can be ignored. + */ XDestroyImage(mask); XFreeGC(dpy, gc); |
From: Grant M. <grm...@us...> - 2003-10-27 20:29:06
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv9547 Modified Files: NameToWidget.c Log Message: Improved - and failsafe - detection of uninitialized widget Index: NameToWidget.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/NameToWidget.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** NameToWidget.c 19 Sep 2001 02:57:18 -0000 1.3 --- NameToWidget.c 27 Oct 2003 20:22:05 -0000 1.4 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.4 2003/10/27 20:22:05 grmcdorman + * Improved - and failsafe - detection of uninitialized widget + * * Revision 1.3 2001/09/19 02:57:18 grmcdorman * This change makes the following modifications: *************** *** 94,98 **** static XrmQuark selfq = NULLQUARK; static XrmQuark questionq = NULLQUARK; ! #if NeedFunctionPrototypes static Widget GetParent(Widget w) --- 97,142 ---- static XrmQuark selfq = NULLQUARK; static XrmQuark questionq = NULLQUARK; ! ! /* Detect if a widget is not initialized. This will be the case when: ! * 1) this widget is a Shell, and does not appear in the parent's ! * list of popups. ! * or 2) this widget is not a Shell, and does not appear in the parent's ! * list of children. ! */ ! #if NeedFunctionPrototypes ! static int WidgetInitialized(Widget w) ! #else ! static int WidgetInitialized(w) ! Widget w; ! #endif ! { ! int initialized = 1; ! int i; ! ! if (w->core.parent != NULL) { ! Widget container = w->core.parent; ! int initialized = 0; ! if (XtIsShell(w)) { ! /* shell; look in parent's popup list */ ! for (i = 0; i < container->core.num_popups; i++) { ! if (container->core.popup_list[i] == w) { ! initialized = 1; ! break; ! } ! } ! } else if XtIsComposite(container) { ! /* ordinary widget */ ! CompositeWidget composite = (CompositeWidget) container; ! for (i = 0; i < composite->composite.num_children; i++) { ! if (composite->composite.children[i] == w) { ! initialized = 1; ! break; ! } ! } ! } ! } ! return initialized; ! } ! #if NeedFunctionPrototypes static Widget GetParent(Widget w) *************** *** 149,152 **** --- 193,199 ---- int i; + /* An uninitialized widget can't have any children or popups. */ + if (!WidgetInitialized(w)) return NULL; + /* * Check the names of all normal children. *************** *** 167,172 **** /* popup children names */ ! /* try to handle unintialized 'num_popups' */ ! if (w->core.num_popups < 50 && w->core.num_popups > 0) for(i = 0; i < w->core.num_popups; i++) if (w->core.popup_list[i]->core.xrm_name == q) --- 214,218 ---- /* popup children names */ ! if (w->core.num_popups > 0) for(i = 0; i < w->core.num_popups; i++) if (w->core.popup_list[i]->core.xrm_name == q) *************** *** 183,187 **** /* popup children classes */ /* try to handle unintialized 'num_popups' */ ! if (w->core.num_popups < 50 && w->core.num_popups > 0) for(i = 0; i < w->core.num_popups; i++) if (XtClass(w->core.popup_list[i])->core_class.xrm_class == q) --- 229,233 ---- /* popup children classes */ /* try to handle unintialized 'num_popups' */ ! if (w->core.num_popups > 0) for(i = 0; i < w->core.num_popups; i++) if (XtClass(w->core.popup_list[i])->core_class.xrm_class == q) *************** *** 395,399 **** } w2 = (*matchproc)(names, bindings, num_quarks, root->core.popup_list, ! root->core.num_popups < 50 && root->core.num_popups > 0 ? root->core.num_popups : 0, in_depth, &d2, found_depth); *out_depth = (d1 < d2 ? d1 : d2); --- 441,445 ---- } w2 = (*matchproc)(names, bindings, num_quarks, root->core.popup_list, ! WidgetInitialized(root) && root->core.num_popups > 0 ? root->core.num_popups : 0, in_depth, &d2, found_depth); *out_depth = (d1 < d2 ? d1 : d2); |
From: Grant M. <grm...@us...> - 2003-10-27 20:24:40
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv9129 Modified Files: Pixmap.c Log Message: Major performance rework for XmtRecolorPixmap Index: Pixmap.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/Pixmap.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** Pixmap.c 13 May 2003 02:16:44 -0000 1.9 --- Pixmap.c 27 Oct 2003 20:19:59 -0000 1.10 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.10 2003/10/27 20:19:59 grmcdorman + * Major performance rework for XmtRecolorPixmap + * * Revision 1.9 2003/05/13 02:16:44 grmcdorman * Performance improvement for XmtRecolorPixmap. *************** *** 729,732 **** --- 732,745 ---- XGCValues values; unsigned int width, height, depth; + Visual *visual; + XColor pseudo_map[256]; + int use_map = 0; + int use_masks = 0; + int red_shift; + int green_shift; + int blue_shift; + int red_mask; + int green_mask; + int blue_mask; width = height = 0; *************** *** 750,802 **** width, height, depth); if (image != NULL && computed != None) { ! /* Convert by batching blocks of color queries, for maximum efficiency. */ int x, y; ! int ipx; ! static XColor color_list[256]; ! static int x_list[256]; ! static int y_list[256]; ! ipx = 0; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { ! x_list[ipx] = x; ! y_list[ipx] = y; ! color_list[ipx++].pixel = XGetPixel(image, x, y); ! if (ipx == XtNumber(color_list)) { ! XQueryColors(w->core.screen->display, w->core.colormap, color_list, ipx); ! while (ipx > 0) { ! --ipx; ! intensity = (color_list[ipx].red + color_list[ipx].blue + color_list[ipx].green) / 3; ! /* find the closest of the two colours */ ! delta1 = abs(intensity - intensity1); ! delta2 = abs(intensity - intensity2); ! if (delta1 < delta2) { ! color_list[ipx].pixel = colour1; ! } else { ! color_list[ipx].pixel = colour2; ! } ! ! XPutPixel(image, x_list[ipx], y_list[ipx], color_list[ipx].pixel); ! } ! ipx = 0; } ! } ! } ! if (ipx > 0) { ! /* finish up */ ! XQueryColors(w->core.screen->display, w->core.colormap, color_list, ipx); ! while (ipx > 0) { ! --ipx; ! intensity = (color_list[ipx].red + color_list[ipx].blue + color_list[ipx].green) / 3; ! /* find the closest of the two colours */ delta1 = abs(intensity - intensity1); delta2 = abs(intensity - intensity2); if (delta1 < delta2) { ! color_list[ipx].pixel = colour1; } else { ! color_list[ipx].pixel = colour2; } ! XPutPixel(image, x_list[ipx], y_list[ipx], color_list[ipx].pixel); } } --- 763,856 ---- width, height, depth); + /* + * Simply calling XQueryColor for each pixel in the image gets expensive + * VERY quickly. + * + * On depth-8 PseudoColour screens, we can get the entire colourmap and avoid a bunch of + * XQueryColor calls. + * + * On TrueColour screens, we can do the Pixel->RGB conversion ourselves, and again avoid + * the XQueryColor calls. + */ + visual = XmtGetVisual(w); + if (visual->class == TrueColor || visual->class == DirectColor) { + int i; + int shift; + int mask; + + use_masks = 1; + + shift = 0; + mask = red_mask = visual->red_mask; + while ( mask != 0 && (mask & 1) != 0) { + mask >>= 1; + shift++; + } + red_shift = shift; + + shift = 0; + mask = green_mask = visual->green_mask; + while ( mask != 0 && (mask & 1) != 0) { + mask >>= 1; + shift++; + } + green_shift = shift; + + shift = 0; + mask = blue_mask = visual->blue_mask; + while ( mask != 0 && (mask & 1) != 0) { + mask >>= 1; + shift++; + } + blue_shift = shift; + + } else if (visual->class == PseudoColor && depth <= 8) { + int i; + for (i = 0; i < (1<<depth); i++) { + pseudo_map[i].pixel = i; + } + XQueryColors(w->core.screen->display, w->core.colormap, pseudo_map, (1<<depth)); + use_map = 1; + } if (image != NULL && computed != None) { ! Pixel pix; int x, y; ! Pixel red, green, blue; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { ! pix = XGetPixel(image, x, y); ! if (use_map) { ! /* Pixels are 16 bit; shift off the lower insignificant bits. */ ! pix >>= (16 - depth); ! red = pseudo_map[pix].red; ! green = pseudo_map[pix].green; ! blue = pseudo_map[pix].blue; ! } else if (use_masks) { ! red = (pix & red_mask) >> red_shift; ! green = (pix & green_mask) >> green_shift; ! blue = (pix & blue_mask) >> blue_shift; ! } else { ! /* Some wierd visual. Drop back to slow but safe XQueryColor. ! * We could convert these in batches (say 256) but this should be ! * so rare that it probably isn't worth the bloat. ! */ ! XColor color; ! color.pixel = pix; ! XQueryColor(w->core.screen->display, w->core.colormap, &color); ! red = color.red; ! green = color.green; ! blue = color.blue; ! } ! intensity = (red + blue + green) / 3; delta1 = abs(intensity - intensity1); delta2 = abs(intensity - intensity2); if (delta1 < delta2) { ! pix= colour1; } else { ! pix = colour1; } ! XPutPixel(image, x, y, pix); } } |
From: Grant M. <grm...@us...> - 2003-10-27 20:23:39
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv8823 Modified Files: ExtWidgets.c Log Message: XmtINSENSITIVE_GRAY dynamic pixmap creation was not done unless both the widget and an ancestor were insensitive Index: ExtWidgets.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/ExtWidgets.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** ExtWidgets.c 25 Oct 2003 00:41:09 -0000 1.10 --- ExtWidgets.c 27 Oct 2003 20:18:21 -0000 1.11 *************** *** 12,15 **** --- 12,19 ---- * * $Log$ + * Revision 1.11 2003/10/27 20:18:21 grmcdorman + * XmtINSENSITIVE_GRAY dynamic pixmap creation was not done unless + * both the widget and an ancestor were insensitive + * * Revision 1.10 2003/10/25 00:41:09 grmcdorman * Clean up some warnings *************** *** 109,113 **** /* Allocate insensitive pixmaps if required. */ if (elw->check_mask && lw->core.window != None && ! !lw->core.sensitive && !lw->core.ancestor_sensitive) { XmtIExtCheckPixmapInsens(elw, lw); elw->check_mask = False; --- 113,117 ---- /* Allocate insensitive pixmaps if required. */ if (elw->check_mask && lw->core.window != None && ! (!lw->core.sensitive || !lw->core.ancestor_sensitive)) { XmtIExtCheckPixmapInsens(elw, lw); elw->check_mask = False; |
From: Grant M. <grm...@us...> - 2003-10-27 17:37:32
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv8718 Modified Files: CliP.h MsgLineP.h Log Message: Solaris 8 bug: Xm/TextP makes XmText record too small Index: CliP.h =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/CliP.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** CliP.h 19 Sep 2001 02:57:18 -0000 1.2 --- CliP.h 27 Oct 2003 17:35:03 -0000 1.3 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.3 2003/10/27 17:35:03 grmcdorman + * Solaris 8 bug: Xm/TextP makes XmText record too small + * * Revision 1.2 2001/09/19 02:57:18 grmcdorman * This change makes the following modifications: *************** *** 58,61 **** --- 61,68 ---- typedef struct _XmtCliPart { + long pad[4]; /* Sun XmText seems to have some storage + * undeclared in Xm/TextP.h (two longwords, actually; we'll + * allocate 4 to be safe) + */ /* resources */ Boolean save_history; /* whether to save input in command history */ Index: MsgLineP.h =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/MsgLineP.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** MsgLineP.h 19 Sep 2001 02:57:18 -0000 1.2 --- MsgLineP.h 27 Oct 2003 17:35:03 -0000 1.3 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.3 2003/10/27 17:35:03 grmcdorman + * Solaris 8 bug: Xm/TextP makes XmText record too small + * * Revision 1.2 2001/09/19 02:57:18 grmcdorman * This change makes the following modifications: *************** *** 71,74 **** --- 74,81 ---- typedef struct _XmtMsgLinePart { + long pad[4]; /* Sun XmText seems to have some storage + * undeclared in Xm/TextP.h (two longwords, actually; we'll + * allocate 4 to be safe) + */ /* resources */ XtTranslations translations; |
From: Grant M. <grm...@us...> - 2003-10-27 17:36:11
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv8372 Modified Files: InputFieldP.h Log Message: Fix comment re Solaris bug [not a 64-bit only bug] Index: InputFieldP.h =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/InputFieldP.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** InputFieldP.h 25 Oct 2003 00:42:15 -0000 1.4 --- InputFieldP.h 27 Oct 2003 17:33:36 -0000 1.5 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.5 2003/10/27 17:33:36 grmcdorman + * Fix comment re Solaris bug [not a 64-bit only bug] + * * Revision 1.4 2003/10/25 00:42:15 grmcdorman * Bug fix for Solaris 64 bit *************** *** 93,97 **** typedef struct _XmtInputFieldPart { ! long pad[4]; /* Sun XmText, in 64-bit mode, seems to have some storage * undeclared in Xm/TextP.h (two longwords, actually; we'll * allocate 4 to be safe) --- 96,100 ---- typedef struct _XmtInputFieldPart { ! long pad[4]; /* Sun XmText seems to have some storage * undeclared in Xm/TextP.h (two longwords, actually; we'll * allocate 4 to be safe) |
From: Grant M. <grm...@us...> - 2003-10-25 00:48:09
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv8670 Modified Files: LayoutGadget.c Log Message: Fix memory leak Index: LayoutGadget.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/LayoutGadget.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** LayoutGadget.c 19 Sep 2001 02:57:18 -0000 1.2 --- LayoutGadget.c 25 Oct 2003 00:42:44 -0000 1.3 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.3 2003/10/25 00:42:44 grmcdorman + * Fix memory leak + * * Revision 1.2 2001/09/19 02:57:18 grmcdorman * This change makes the following modifications: *************** *** 222,228 **** #if XmVersion >= 1002 /* always inherit the base class extension. - * We assume that there aren't any other extension records. */ ! roc->rect_class.extension = (XtPointer)&baseClassExt; #endif } --- 225,239 ---- #if XmVersion >= 1002 /* always inherit the base class extension. */ ! if (roc->rect_class.extension != NULL) { ! /* There is another extension. */ ! XmBaseClassExt copy; ! copy = XtNew(XmBaseClassExtRec); ! memcpy(copy, &baseClassExt, sizeof *copy); ! copy->next_extension = roc->rect_class.extension; ! roc->rect_class.extension = copy; ! } else { ! roc->rect_class.extension = (XtPointer)&baseClassExt; ! } #endif } |
From: Grant M. <grm...@us...> - 2003-10-25 00:45:56
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv8572 Modified Files: InputFieldP.h Log Message: Bug fix for Solaris 64 bit Index: InputFieldP.h =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/InputFieldP.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** InputFieldP.h 20 Jul 2001 23:07:49 -0000 1.3 --- InputFieldP.h 25 Oct 2003 00:42:15 -0000 1.4 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.4 2003/10/25 00:42:15 grmcdorman + * Bug fix for Solaris 64 bit + * * Revision 1.3 2001/07/20 23:07:49 grmcdorman * This change provides two optional Motif/NuTCracker bug workarounds. *************** *** 90,93 **** --- 93,100 ---- typedef struct _XmtInputFieldPart { + long pad[4]; /* Sun XmText, in 64-bit mode, seems to have some storage + * undeclared in Xm/TextP.h (two longwords, actually; we'll + * allocate 4 to be safe) + */ /* resources */ String input; /* The string that goes in the text widget */ |
From: Grant M. <grm...@us...> - 2003-10-25 00:44:09
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv8387 Modified Files: ExtWidgets.c Log Message: Clean up some warnings Index: ExtWidgets.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/ExtWidgets.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** ExtWidgets.c 14 Aug 2003 02:17:24 -0000 1.9 --- ExtWidgets.c 25 Oct 2003 00:41:09 -0000 1.10 *************** *** 12,15 **** --- 12,18 ---- * * $Log$ + * Revision 1.10 2003/10/25 00:41:09 grmcdorman + * Clean up some warnings + * * Revision 1.9 2003/08/14 02:17:24 grmcdorman * New XmtExtLabelSetPixmap function *************** *** 71,74 **** --- 74,84 ---- #endif + /* not all versions of Motif declare this */ + #ifdef _NO_PROTO + extern _XmString _XmStringCreate(); + #else + extern _XmString _XmStringCreate(XmString cs); + #endif + #ifndef max # define max(a, b) ((a) > (b) ? (a) : (b)) *************** *** 1143,1147 **** int eventBase, errorBase; ! if (XtIsRealized(lw)) { // Don't crash if Shape doesn't exist on the server. if (XShapeQueryExtension(lw->core.screen->display, &eventBase, &errorBase)) { --- 1153,1157 ---- int eventBase, errorBase; ! if (XtIsRealized((Widget) lw)) { // Don't crash if Shape doesn't exist on the server. if (XShapeQueryExtension(lw->core.screen->display, &eventBase, &errorBase)) { |
From: Grant M. <grm...@us...> - 2003-10-25 00:42:59
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv7518 Modified Files: Cli.c Log Message: Avoid index by -1 into buffer Index: Cli.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/Cli.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -r1.1.1.1 -r1.2 *** Cli.c 10 Feb 2001 13:41:41 -0000 1.1.1.1 --- Cli.c 25 Oct 2003 00:35:32 -0000 1.2 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.2 2003/10/25 00:35:32 grmcdorman + * Avoid index by -1 into buffer + * * Revision 1.1.1.1 2001/02/10 13:41:41 motiftools * Initial import of Xmt310 to CVS *************** *** 744,748 **** /* if last character was \, then this is not the end of the command line */ ! if (cw->cli.escape_newlines && buf[len-1] == '\\') { XtFree(buf); XmTextInsert(w, cw->cli.inputpos+len, "\n"); --- 747,751 ---- /* if last character was \, then this is not the end of the command line */ ! if (len > 0 && cw->cli.escape_newlines && buf[len-1] == '\\') { XtFree(buf); XmTextInsert(w, cw->cli.inputpos+len, "\n"); |
From: Grant M. <grm...@us...> - 2003-08-14 02:38:13
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv30287 Modified Files: ExtWidgets.c ExtWidgets.h Log Message: New XmtExtLabelSetPixmap function Index: ExtWidgets.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/ExtWidgets.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** ExtWidgets.c 13 May 2003 02:15:34 -0000 1.8 --- ExtWidgets.c 14 Aug 2003 02:17:24 -0000 1.9 *************** *** 12,15 **** --- 12,18 ---- * * $Log$ + * Revision 1.9 2003/08/14 02:17:24 grmcdorman + * New XmtExtLabelSetPixmap function + * * Revision 1.8 2003/05/13 02:15:34 grmcdorman * New function: XmtExtLabelSetString, which efficiently (and with minimum flicker) sets the label string for the XmtExt* widgets. *************** *** 176,180 **** Pixmap background; Position bg_x, bg_y; - Widget pixmapOwner = (Widget) lw; int unusedmask = ~(GCFunction|GCPlaneMask|GCFillStyle| --- 179,182 ---- *************** *** 1187,1190 **** --- 1189,1246 ---- } lw->label._label = _XmStringCreate(string); + /* Resize if permitted. */ + if (lw->label.recompute_size) { + /* Compute wanted size */ + XmtIExtCalculateWantedSize(epart, (XmLabelWidget) lw, 0, 0); + if (epart->wanted_height != lw->core.height || + epart->wanted_width != lw->core.width) { + /* will call resize() if needed */ + XtResizeWidget(label, epart->wanted_width, epart->wanted_height, lw->core.border_width); + } + if (epart->buffer_pixmap != None && lw->core.window != None) { + XFreePixmap(lw->core.screen->display, epart->buffer_pixmap); + epart->buffer_pixmap = None; + } + } + + /* Relayout. */ + XmtIExtLayout(epart, (XmLabelWidget) lw); + + /* Redraw via a top-level expose callback. */ + (lw->core.widget_class->core_class.expose)((Widget) lw, NULL, NULL); + } + + /************************************************************/ + /* XmtExtLabelSetPixmap */ + /* This function quickly sets the pixmaps and mask on the */ + /* widget. This should prevent flicker, unless the */ + /* widget has to be resized. */ + /* It can also be called when the pixmaps have been */ + /* modified by the application drawing into them. */ + /************************************************************/ + #if NeedFunctionPrototypes + void XmtExtLabelSetPixmap(Widget label, Pixmap pixmap, Pixmap mask) + #else + void XmtExtLabelSetPixmap(label, pixmap, mask) + Widget label; + XmString string; + Pixmap pixmap; + Pixmap mask; + #endif + { + XmLabelWidget lw; + XmtExtPart *epart; + lw = (XmLabelWidget) label; + + epart = GetExtPart(label); + if (epart == NULL) { + XtAppWarning(XtWidgetToApplicationContext(label), + "Non-XmtExt widget passed to XmtExtLabelSetPixmap\n"); + return; + } + + lw->label.pixmap = pixmap; + epart->mask = mask; + /* Resize if permitted. */ if (lw->label.recompute_size) { Index: ExtWidgets.h =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/ExtWidgets.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** ExtWidgets.h 13 May 2003 02:15:35 -0000 1.5 --- ExtWidgets.h 14 Aug 2003 02:17:24 -0000 1.6 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.6 2003/08/14 02:17:24 grmcdorman + * New XmtExtLabelSetPixmap function + * * Revision 1.5 2003/05/13 02:15:35 grmcdorman * New function: XmtExtLabelSetString, which efficiently (and with minimum flicker) sets the label string for the XmtExt* widgets. *************** *** 260,269 **** --- 263,280 ---- _XFUNCPROTOBEGIN + /* + * Common functions + * + * Use XmtExtLabelSetPixmap to cause a redraw if the pixmap's contents have changed, or + * if any mask's contents have changed. + */ #if NeedFunctionPrototypes extern void XmtGetBackgroundPixmap(Widget w, Pixmap *background, Position *x, Position *y); extern void XmtExtLabelSetString(Widget label, XmString string); + extern void XmtExtLabelSetPixmap(Widget label, Pixmap pixmap, Pixmap mask); #else extern void XmtExtLabelSetString(/*label, string*/); extern void XmtGetBackgroundPixmap(/*w, background, x, y*/); + extern void XmtExtLabelSetPixmap(/*label, pixmap, mask*/); #endif _XFUNCPROTOEND |
From: Grant M. <grm...@us...> - 2003-08-14 02:29:29
|
Update of /cvsroot/motiftools/xmt In directory sc8-pr-cvs1:/tmp/cvs-serv31433 Modified Files: Xmt.tmpl Log Message: Compile-configuration to fix @f[] with patched Motif Index: Xmt.tmpl =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt.tmpl,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** Xmt.tmpl 26 Sep 2001 02:47:00 -0000 1.5 --- Xmt.tmpl 14 Aug 2003 02:25:25 -0000 1.6 *************** *** 211,214 **** --- 211,221 ---- DISABLEDNDDEFINES = /* -DDISABLE_INPUTFIELD_DRAGDROP */ + /* + * Define the variable below if the font '@f[]' code doesn't + * work in the Xmt string converter. This is known to be the + * case on Solaris 8 with Motif patches. + */ + USECOMPONENTDEFINES = /* -DUSE_XmSTRING_COMPONENT */ + /* * If you want XmtFindFile to use something other than the default *************** *** 330,334 **** * file or client, we'll set them here. */ ! DEFINES = $(MEMDEFINES) $(OLDMOTIFDEFINES) $(BSDEFINES) $(HPDEFINES) $(DECDEFINES) $(IBMDEFINES) $(TEAROFFDEFINES) $(STRERRORDEFINES) $(SYSERRLISTDEFINES) $(XMTPPDEFINES) $(NUTCRACKERBUGDEFINES) $(DISABLEDNDDEFINES) /* --- 337,341 ---- * file or client, we'll set them here. */ ! DEFINES = $(MEMDEFINES) $(OLDMOTIFDEFINES) $(BSDEFINES) $(HPDEFINES) $(DECDEFINES) $(IBMDEFINES) $(TEAROFFDEFINES) $(STRERRORDEFINES) $(SYSERRLISTDEFINES) $(XMTPPDEFINES) $(NUTCRACKERBUGDEFINES) $(DISABLEDNDDEFINES) $(USECOMPONENTDEFINES) /* |
From: Grant M. <grm...@us...> - 2003-08-14 02:29:29
|
Update of /cvsroot/motiftools/xmt/Xmt In directory sc8-pr-cvs1:/tmp/cvs-serv31433/Xmt Modified Files: XmStringCvt.c Log Message: Compile-configuration to fix @f[] with patched Motif Index: XmStringCvt.c =================================================================== RCS file: /cvsroot/motiftools/xmt/Xmt/XmStringCvt.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** XmStringCvt.c 19 Sep 2001 02:57:18 -0000 1.2 --- XmStringCvt.c 14 Aug 2003 02:25:25 -0000 1.3 *************** *** 10,13 **** --- 10,16 ---- * * $Log$ + * Revision 1.3 2003/08/14 02:25:25 grmcdorman + * Compile-configuration to fix @f[] with patched Motif + * * Revision 1.2 2001/09/19 02:57:18 grmcdorman * This change makes the following modifications: *************** *** 100,104 **** component_type = XmSTRING_COMPONENT_TAB; break; ! case 'f': /* * treat @f the same as an unterminated @b. --- 103,111 ---- component_type = XmSTRING_COMPONENT_TAB; break; ! case 'f': ! #ifdef USE_XmSTRING_COMPONENT ! component_type = XmSTRING_COMPONENT_TAG; ! break; ! #else /* * treat @f the same as an unterminated @b. *************** *** 107,110 **** --- 114,118 ---- * to make as much sense, anyway. */ + #endif case 'b': component_type = XmSTRING_COMPONENT_RENDITION_BEGIN; |