diff options
Diffstat (limited to 'Linux_C_12')
36 files changed, 12240 insertions, 0 deletions
diff --git a/Linux_C_12/Clean.h b/Linux_C_12/Clean.h new file mode 100644 index 0000000..d92e1a0 --- /dev/null +++ b/Linux_C_12/Clean.h @@ -0,0 +1,28 @@ +
+#define Clean(a)
+
+typedef struct clean_string *CleanString;
+
+/* a string in Clean is:
+ struct clean_string {
+ int clean_string_length;
+ char clean_string_characters[clean_string_length];
+ };
+ The string does not end with a '\0' !
+*/
+
+/* CleanStringLength(clean_string) returns length of the clean_string in characters */
+#define CleanStringLength(clean_string) (*(unsigned int *)(clean_string))
+
+/* CleanStringCharacters(clean_string) returns a pointer to the characters of the clean_string */
+#define CleanStringCharacters(clean_string) ((char*)(1+(unsigned int *)(clean_string)))
+
+/* CleanStringSizeInts(string_length) return size of CleanString in integers */
+#define CleanStringSizeInts(string_length) (1+(((unsigned int)(string_length)+3)>>2))
+
+/* CleanStringVariable(clean_string,string_length) defines variable clean_string with length string_length,
+ before using the clean_string variable, cast to CleanString, except for the macros above */
+#define CleanStringVariable(clean_string,string_length) unsigned int clean_string[CleanStringSizeInts(string_length)]
+
+/* CleanStringSizeBytes(string_length) return size of CleanString in bytes */
+#define CleanStringSizeBytes(string_length) (4+(((unsigned int)(string_length)+3) & -4))
diff --git a/Linux_C_12/cCCallSystem_121.c b/Linux_C_12/cCCallSystem_121.c new file mode 100644 index 0000000..cab13a8 --- /dev/null +++ b/Linux_C_12/cCCallSystem_121.c @@ -0,0 +1,106 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ Routines related to system handling that is not part of standard cross call handling.
+********************************************************************************************/
+#include "cCCallSystem_121.h"
+#include <time.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+OS WinBeep (OS ios)
+{
+ rprintf("WinBeep\n");
+ gdk_beep();
+ return ios;
+}
+
+void WinGetBlinkTime(OS ios, int* blinktime, OS *oos)
+{
+/* return (int) GetCaretBlinkTime(); */
+ rprintf("WinGetBlinkTime -> not implemented\n");
+ *oos = ios;
+}
+
+void WinGetTickCount (OS ios, int *tickCount, OS *oos)
+{
+ static struct timeval s;
+ static gboolean f = TRUE;
+ struct timeval r;
+
+ rprintf("WinGetTickCount\n");
+ if (f)
+ {
+ gettimeofday(&s,NULL);
+ f = FALSE;
+ *oos = ios;
+ *tickCount = 0;
+ return;
+ }
+
+ gettimeofday(&r,NULL);
+ *tickCount = (r.tv_sec-s.tv_sec)*1000 + (r.tv_usec-s.tv_usec)/1000;
+ *oos = ios;
+}
+
+void WinPlaySound (CLEAN_STRING filename, OS ios, Bool *ook, OS *oos)
+{
+/* return PlaySound(filename, NULL, SND_FILENAME | SND_SYNC); */
+ rprintf("WinPlaySound -> not implemented");
+ *ook = FALSE;
+ *oos = ios;
+}
+
+OS WinWait (int delay, OS ios)
+{
+ rprintf("WinWait: %d\n", delay);
+ sleep(delay);
+ return ios;
+}
+
+void WinGetTime (OS ios, int *hr, int *min, int *second, OS *oos)
+{
+ struct timeval t;
+ struct tm theTime;
+
+ printf("WinGetTime\n");
+
+ gettimeofday(&t,NULL);
+ gmtime_r(&t.tv_sec,&theTime);
+
+ *hr = theTime.tm_hour;
+ *min = theTime.tm_min;
+ *second = theTime.tm_sec;
+
+ printf("Time: %d:%d:%d\n", *hr, *min, *second);
+
+ *oos = ios;
+}
+
+void WinGetDate (OS ios, int *year, int *month, int *day,
+ int *weekday, OS *oos)
+{
+ struct timeval t;
+ struct tm theTime;
+
+ printf("WinGetDate\n");
+
+ gettimeofday(&t,NULL);
+ gmtime_r(&t.tv_sec,&theTime);
+ *year = 1900 + theTime.tm_year;
+ *month = 1 + theTime.tm_mon;
+ *day = theTime.tm_mday;
+ /* Clean treats 1 == Weekend, 2 == Weekday */
+ *weekday = ((theTime.tm_wday == 0) || (theTime.tm_wday == 6)) ? 1 : 2;
+
+ printf("Date: %d-%d-%d\n",*month, *day, *year);
+ *oos = ios;
+}
+
+
+
diff --git a/Linux_C_12/cCCallSystem_121.h b/Linux_C_12/cCCallSystem_121.h new file mode 100644 index 0000000..4b49928 --- /dev/null +++ b/Linux_C_12/cCCallSystem_121.h @@ -0,0 +1,10 @@ +#include "intrface_121.h"
+#include "util_121.h"
+
+extern OS WinBeep (OS);
+extern void WinGetTime (OS,int*,int*,int*,OS*);
+extern void WinGetDate (OS,int*,int*,int*,int*,OS*);
+extern OS WinWait (int,OS);
+extern void WinGetBlinkTime (OS,int*,OS*);
+extern void WinGetTickCount (OS,int*,OS*);
+extern void WinPlaySound (CLEAN_STRING,OS,Bool*,OS*);
diff --git a/Linux_C_12/cCCallWindows_121.c b/Linux_C_12/cCCallWindows_121.c new file mode 100644 index 0000000..b6d521e --- /dev/null +++ b/Linux_C_12/cCCallWindows_121.c @@ -0,0 +1,182 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ Routines related to window/dialog handling.
+********************************************************************************************/
+#include "cCCallWindows_121.h"
+#include "cCrossCallWindows_121.h"
+
+OS WinInvalidateWindow (GtkWidget *widget, OS ios)
+{
+ rprintf("WinInvalidateWindow\n");
+ gtk_widget_queue_draw(widget);
+ return ios;
+}
+
+OS WinInvalidateRect (GtkWidget *widget, int left, int top, int right,
+ int bottom, OS ios)
+{
+ /* rprintf("WinInvalidateRect\n"); */
+ gint temp;
+ GdkRectangle* rect = g_new(GdkRectangle,1);
+ if (top > bottom) {
+ temp = top;
+ top = bottom;
+ bottom = top;
+ }
+ rect->x = (gint)left;
+ rect->y = (gint)top;
+ rect->width = (gint)(right - left);
+ rect->height = (gint)(bottom - top);
+ gdk_window_invalidate_rect(GDK_WINDOW(widget),rect, 1);
+ /* FIXME: destroy the Rectangle here? */
+ return ios;
+}
+
+OS WinValidateRect (GtkWidget *widget, int left, int top, int right, int bottom,
+ OS ios)
+{
+ /* GTK Automatically calculates valid regions. */
+ return ios;
+}
+
+OS WinValidateRgn (GtkWidget *widget, GdkRegion *region, OS ios)
+{
+ /* GTK Automatically calculates valid regions. */
+ return ios;
+}
+
+/* Win(M/S)DIClientToOuterSizeDims returns the width and height needed to add/subtract
+ from the client/outer size to obtain the outer/client size.
+ These values must be the same as used by W95AdjustClean(M/S)DIWindowDimensions!
+*/
+void WinMDIClientToOuterSizeDims (int styleFlags, OS ios, int *dw, int *dh, OS* oos)
+{
+/* if ((styleFlags&WS_THICKFRAME) != 0)
+ { // resizable window
+ *dw = 2 * GetSystemMetrics (SM_CXSIZEFRAME);
+ *dh = 2 * GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION);
+ } else
+ { // fixed size window
+ *dw = 2 * GetSystemMetrics (SM_CXFIXEDFRAME);
+ *dh = 2 * GetSystemMetrics (SM_CYFIXEDFRAME) + GetSystemMetrics (SM_CYCAPTION);
+ }
+*/
+ *dw = 0;
+ *dh = 0;
+ printf("WinMDIClientOuterSizeDims -> not implemented\n");
+ *oos = ios;
+}
+
+void WinSDIClientToOuterSizeDims (int styleFlags, OS ios, int *dw, int *dh, OS *oos)
+{
+ *dw = 0; //2 * GetSystemMetrics (SM_CXSIZEFRAME);
+ *dh = 0; //2 * GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION);
+ printf("WinSDIClientOuterSizeDims -> not implemented\n");
+ *oos = ios;
+}
+
+
+/* UpdateWindowScrollbars updates any window scrollbars and non-client area if present.
+ Uses the following access procedures to the GWL_STYLE of a windowhandle:
+ GetGWL_STYLE (hwnd) returns the GWL_STYLE value of hwnd;
+ WindowHasHScroll (hwnd) returns TRUE iff hwnd has a horizontal scrollbar;
+ WindowHasVScroll (hwnd) returns TRUE iff hwnd has a vertical scrollbar;
+*/
+
+void UpdateWindowScrollbars (GtkWidget *widget)
+{
+/* int w,h;
+ RECT rect;
+
+ GetWindowRect (hwnd, &rect);
+ w = rect.right -rect.left;
+ h = rect.bottom-rect.top;
+
+ if (WindowHasHScroll (hwnd))
+ {
+ rect.left = 0;
+ rect.top = h-GetSystemMetrics (SM_CYHSCROLL);
+ rect.right = w;
+ rect.bottom = h;
+ InvalidateRect (hwnd,&rect,FALSE);
+ RedrawWindow (hwnd,&rect,NULL,RDW_FRAME | RDW_VALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN);
+ ValidateRect (hwnd,&rect);
+ }
+ if (WindowHasVScroll (hwnd))
+ {
+ rect.left = w-GetSystemMetrics (SM_CXVSCROLL);
+ rect.top = 0;
+ rect.right = w;
+ rect.bottom = h;
+ InvalidateRect (hwnd,&rect,FALSE);
+ RedrawWindow (hwnd,&rect,NULL,RDW_FRAME | RDW_VALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN);
+ ValidateRect (hwnd,&rect);
+ }
+*/
+ printf("UpdateWindowScrollbars -> not implemented\n");
+}
+
+
+void WinScreenYSize (OS ios, int *py, OS *oos)
+{
+ rprintf("WinScreenYSize\n");
+ *py = gdk_screen_height();
+ *oos = ios;
+}
+
+void WinScreenXSize (OS ios, int *px, OS *oos)
+{
+ rprintf("WinScreenXSize\n");
+ *px = gdk_screen_width();
+ *oos = ios;
+}
+
+void WinMinimumWinSize (int *mx, int *my)
+{
+ rprintf("WinMinimumWinSize\n");
+ *mx = 48;
+ *my = 0;
+}
+
+/* WinScrollbarSize determines system metrics of width and height of scrollbars.
+*/
+void WinScrollbarSize (OS ios, int *width, int *height, OS *oos)
+{
+ GtkRequisition req;
+ GtkWidget *vbar, *hbar;
+ printf ("WinScrollbarSize\n");
+
+ vbar = gtk_vscrollbar_new(NULL);
+ hbar = gtk_hscrollbar_new(NULL);
+
+
+ gtk_widget_size_request(vbar, &req);
+ *width = req.width; /* Width of the vertical arrow */
+ gtk_widget_size_request(hbar, &req);
+ *height = req.height; /* Height of the horizontal bar */
+
+ gtk_widget_destroy(vbar);
+ gtk_widget_destroy(hbar);
+
+ *oos = ios;
+}
+
+void WinMaxFixedWindowSize (int *mx, int *my)
+{
+ rprintf("WinMaxFixedWindowSize\n");
+ *mx = gdk_screen_width();
+ *my = gdk_screen_height();
+}
+
+void WinMaxScrollWindowSize (int *mx, int *my)
+{
+ rprintf("WinMaxScrollWindowSize\n");
+ *mx = gdk_screen_width();
+ *my = gdk_screen_height();
+}
diff --git a/Linux_C_12/cCCallWindows_121.h b/Linux_C_12/cCCallWindows_121.h new file mode 100644 index 0000000..45823ab --- /dev/null +++ b/Linux_C_12/cCCallWindows_121.h @@ -0,0 +1,28 @@ +#include "util_121.h"
+
+extern OS WinInvalidateWindow (OSWindowPtr wnd, OS ios);
+extern OS WinInvalidateRect (OSWindowPtr wnd, int left, int top, int right,
+ int bottom, OS ios);
+extern OS WinValidateRect (OSWindowPtr wnd, int left, int top, int right,
+ int bottom, OS ios);
+extern OS WinValidateRgn (OSWindowPtr wnd, OSRgnHandle rgn, OS ios);
+
+/* Win(M/S)DIClientToOuterSizeDims returns the width and height needed to add/subtract
+ from the client/outer size to obtain the outer/client size.
+ These values must be the same as used by W95AdjustClean(M/S)DIWindowDimensions!
+*/
+extern void WinMDIClientToOuterSizeDims (int styleFlags, OS ios, int *dw, int *dh, OS *oos);
+extern void WinSDIClientToOuterSizeDims (int styleFlags, OS ios, int *dw, int *dh, OS *oos);
+
+/* UpdateWindowScrollbars updates any window scrollbars and non-client area if present.
+*/
+extern void UpdateWindowScrollbars (OSWindowPtr hwnd);
+
+/* Access procedures to dimensions:
+*/
+extern void WinScreenYSize (OS,int*,OS*);
+extern void WinScreenXSize (OS,int*,OS*);
+extern void WinMinimumWinSize (int *mx, int *my);
+extern void WinScrollbarSize (OS ios, int *width, int *height, OS *oos);
+extern void WinMaxFixedWindowSize (int *mx, int *my);
+extern void WinMaxScrollWindowSize (int *mx, int *my);
diff --git a/Linux_C_12/cCrossCallClipboard_121.c b/Linux_C_12/cCrossCallClipboard_121.c new file mode 100644 index 0000000..bc7e2df --- /dev/null +++ b/Linux_C_12/cCrossCallClipboard_121.c @@ -0,0 +1,62 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ Routines related to clipboard handling.
+********************************************************************************************/
+#include "cCrossCallClipboard_121.h"
+#include "cCrossCall_121.h"
+
+
+/* Cross call procedure implementations.
+ Eval<nr> corresponds with a CrossCallEntry generated by NewCrossCallEntry (nr,Eval<nr>).
+*/
+
+void EvalCcRqCLIPBOARDHASTEXT (CrossCallInfo *pcci) /* no arguments; bool result. */
+{
+ printf("EvalCcRqCLIPBOARDHASTEXT\n");
+ MakeReturn1Cci (pcci,(int) gtk_clipboard_wait_is_text_available(gtk_clipboard_get(GDK_NONE)));
+}
+
+void EvalCcRqSETCLIPBOARDTEXT (CrossCallInfo *pcci) /* textptr; no result. */
+{
+ const gchar *text = (const gchar *) pcci->p1;
+
+ printf("EvalCcRqSETCLIPBOARDTEXT\n");
+ gtk_clipboard_set_text (gtk_clipboard_get(GDK_NONE),
+ text, strlen(text));
+
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqGETCLIPBOARDTEXT (CrossCallInfo *pcci) /* no params; string result. */
+{
+ gchar *text, *result;
+ printf("EvalCcRqGETCLIPBOARDTEXT\n");
+
+ text = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_NONE));
+ result = g_strdup(text);
+ g_free(text);
+
+ MakeReturn1Cci (pcci, (int) result);
+}
+
+/* Install the cross call procedures in the gCrossCallProcedureTable of cCrossCall_121.
+*/
+OS InstallCrossCallClipboard (OS ios)
+{
+ CrossCallProcedureTable newTable;
+
+ printf("InstallCrossCallClipboard\n");
+ newTable = EmptyCrossCallProcedureTable ();
+ AddCrossCallEntry (newTable, CcRqCLIPBOARDHASTEXT, EvalCcRqCLIPBOARDHASTEXT);
+ AddCrossCallEntry (newTable, CcRqSETCLIPBOARDTEXT, EvalCcRqSETCLIPBOARDTEXT);
+ AddCrossCallEntry (newTable, CcRqGETCLIPBOARDTEXT, EvalCcRqGETCLIPBOARDTEXT);
+ AddCrossCallEntries (gCrossCallProcedureTable, newTable);
+
+ return ios;
+}
diff --git a/Linux_C_12/cCrossCallClipboard_121.h b/Linux_C_12/cCrossCallClipboard_121.h new file mode 100644 index 0000000..d9bb1f4 --- /dev/null +++ b/Linux_C_12/cCrossCallClipboard_121.h @@ -0,0 +1,5 @@ +#include "util_121.h"
+
+// InstallCrossCallClipboard adds the proper cross call procedures to the
+// cross call procedures managed by cCrossCall_13.c.
+extern OS InstallCrossCallClipboard (OS);
diff --git a/Linux_C_12/cCrossCallFileSelectors_121.c b/Linux_C_12/cCrossCallFileSelectors_121.c new file mode 100644 index 0000000..c36e6d8 --- /dev/null +++ b/Linux_C_12/cCrossCallFileSelectors_121.c @@ -0,0 +1,173 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ Routines related to standard file selector dialogues.
+********************************************************************************************/
+#include "cCrossCallFileSelectors_121.h"
+#include "util_121.h"
+#include "cCrossCall_121.h"
+
+extern GtkWidget *gActiveTopLevelWindow;
+
+void EvalCcRqDIRECTORYDIALOG (CrossCallInfo *pcci) /* no params; bool, textptr result; */
+{
+ GtkWidget *file_selector;
+ printf("EvalCcRqDIRECTORYDIALOG\n");
+ file_selector = gtk_file_selection_new("Select directory");
+
+ if (gActiveTopLevelWindow)
+ {
+ gtk_window_set_transient_for(GTK_WINDOW(file_selector), GTK_WINDOW(gActiveTopLevelWindow));
+ }
+
+ for (;;)
+ {
+ if (gtk_dialog_run(GTK_DIALOG(file_selector)) == GTK_RESPONSE_OK)
+ {
+ gchar *file_name;
+ G_CONST_RETURN gchar *fname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(file_selector));
+ if (!g_file_test(fname, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
+ {
+ GtkWidget *dialog =
+ gtk_message_dialog_new (GTK_WINDOW(file_selector),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s directory not found",
+ fname);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ continue;
+ }
+
+ file_name = g_strdup(fname);
+ gtk_widget_destroy(file_selector);
+ MakeReturn2Cci(pcci, gtk_true(), (int) file_name);
+ return;
+ }
+ else
+ {
+ gtk_widget_destroy(file_selector);
+ MakeReturn2Cci(pcci, gtk_false(), (int) NULL);
+ return;
+ }
+ }
+}
+
+void EvalCcRqFILEOPENDIALOG (CrossCallInfo *pcci) /* no params; bool, textptr result; */
+{
+ GtkWidget *file_selector;
+ printf("EvalCcFILEOPENDIALOG\n");
+ file_selector = gtk_file_selection_new("Open");
+
+ if (gActiveTopLevelWindow)
+ {
+ gtk_widget_set_parent(file_selector, gActiveTopLevelWindow);
+ gtk_window_set_transient_for(GTK_WINDOW(file_selector), GTK_WINDOW(gActiveTopLevelWindow));
+ }
+
+ for (;;)
+ {
+ if (gtk_dialog_run(GTK_DIALOG(file_selector)) == GTK_RESPONSE_OK)
+ {
+ gchar *file_name;
+ G_CONST_RETURN gchar *fname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(file_selector));
+ if (!g_file_test(fname, G_FILE_TEST_EXISTS))
+ {
+ GtkWidget *dialog =
+ gtk_message_dialog_new (GTK_WINDOW(file_selector),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s file not found",
+ fname);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ continue;
+ }
+
+ file_name = g_strdup(fname);
+ gtk_widget_destroy(file_selector);
+ MakeReturn2Cci(pcci, gtk_true(), (int) file_name);
+ return;
+ }
+ else
+ {
+ gtk_widget_destroy(file_selector);
+ MakeReturn2Cci(pcci, gtk_false(), (int) NULL);
+ return;
+ }
+ }
+}
+
+void EvalCcRqFILESAVEDIALOG (CrossCallInfo *pcci) /* promptptr, nameptr; bool, textptr result; */
+{
+ GtkWidget *file_selector;
+ printf("EvalCcFILESAVEDDIALOG\n");
+ file_selector = gtk_file_selection_new((gchar *) pcci->p1);
+
+ if (gActiveTopLevelWindow)
+ {
+ gtk_widget_set_parent(file_selector, gActiveTopLevelWindow);
+ gtk_window_set_transient_for(GTK_WINDOW(file_selector), GTK_WINDOW(gActiveTopLevelWindow));
+ }
+
+ gtk_file_selection_set_filename(file_selector, (gchar *) pcci->p2);
+
+ for (;;)
+ {
+ if (gtk_dialog_run(GTK_DIALOG(file_selector)) == GTK_RESPONSE_OK)
+ {
+ gchar *file_name;
+ G_CONST_RETURN gchar *fname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(file_selector));
+ if (g_file_test(fname, G_FILE_TEST_EXISTS))
+ {
+ gint res;
+ GtkWidget *dialog =
+ gtk_message_dialog_new (GTK_WINDOW(file_selector),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_YES_NO,
+ "%s already exists. Do you want to replace id?",
+ fname);
+ res = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ if (res == GTK_RESPONSE_NO) continue;
+ }
+
+ file_name = g_strdup(fname);
+ gtk_widget_destroy(file_selector);
+ MakeReturn2Cci(pcci, gtk_true(), (int) file_name);
+ return;
+ }
+ else
+ {
+ gtk_widget_destroy(file_selector);
+ MakeReturn2Cci(pcci, gtk_false(), (int) NULL);
+ return;
+ }
+ }
+}
+
+
+/* Install the cross call procedures in the gCrossCallProcedureTable of cCrossCall_121.
+*/
+OS InstallCrossCallFileSelectors(OS ios)
+{
+ CrossCallProcedureTable newTable;
+ printf("InstallCrossCallFileSelectors\n");
+
+ newTable = EmptyCrossCallProcedureTable ();
+ AddCrossCallEntry (newTable, CcRqDIRECTORYDIALOG,EvalCcRqDIRECTORYDIALOG);
+ AddCrossCallEntry (newTable, CcRqFILEOPENDIALOG, EvalCcRqFILEOPENDIALOG);
+ AddCrossCallEntry (newTable, CcRqFILESAVEDIALOG, EvalCcRqFILESAVEDIALOG);
+ AddCrossCallEntries (gCrossCallProcedureTable, newTable);
+
+ return ios;
+}
diff --git a/Linux_C_12/cCrossCallFileSelectors_121.h b/Linux_C_12/cCrossCallFileSelectors_121.h new file mode 100644 index 0000000..792409b --- /dev/null +++ b/Linux_C_12/cCrossCallFileSelectors_121.h @@ -0,0 +1,6 @@ +#include "util_121.h"
+
+
+// InstallCrossCallFileSelectors adds the proper cross call procedures to the
+// cross call procedures managed by cCrossCall_121.c.
+extern OS InstallCrossCallFileSelectors(OS);
diff --git a/Linux_C_12/cCrossCallFont_121.c b/Linux_C_12/cCrossCallFont_121.c new file mode 100644 index 0000000..c0e1cd3 --- /dev/null +++ b/Linux_C_12/cCrossCallFont_121.c @@ -0,0 +1,87 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ Routines related to font handling.
+********************************************************************************************/
+#include "cCrossCallFont_121.h"
+#include "cCrossCall_121.h"
+
+/*
+
+static int CALLBACK EnumFontNameProc (ENUMLOGFONT FAR * lpelf, // pointer to logical-font data
+ NEWTEXTMETRIC FAR * lpntm, // pointer to physical-font data
+ int fontType, // type of font
+ LPARAM lParam // address of application-defined data
+ )
+{
+ SendMessage1ToClean (CcCbFONTNAME, lpelf->elfLogFont.lfFaceName);
+
+ return 1;
+}
+
+static int CALLBACK EnumFontSizeProc (ENUMLOGFONT FAR * lpelf, // pointer to logical-font data
+ NEWTEXTMETRIC FAR * lpntm, // pointer to physical-font data
+ int fontType, // type of font
+ LPARAM lParam // address of application-defined data
+ )
+{
+ SendMessage2ToClean (CcCbFONTSIZE,lpntm->tmHeight - lpntm->tmInternalLeading, fontType == TRUETYPE_FONTTYPE);
+
+ if (fontType == TRUETYPE_FONTTYPE)
+ return 0;
+ else
+ return 1;
+}
+
+*/
+
+/* Cross call procedure implementations.
+ Eval<nr> corresponds with a CrossCallEntry generated by NewCrossCallEntry (nr,Eval<nr>).
+*/
+void EvalCcRqGETFONTNAMES (CrossCallInfo *pcci) // no params; no result.
+{
+/* HDC hdc;
+
+ hdc = GetDC (ghMainWindow);
+ EnumFontFamilies (hdc, NULL, (FONTENUMPROC) EnumFontNameProc, 0);
+ ReleaseDC (ghMainWindow, hdc);
+ MakeReturn0Cci (pcci);
+*/
+ printf("EvalCcRqGETFONTNAMES -> not implemented");
+ MakeReturn0Cci(pcci);
+}
+
+void EvalCcRqGETFONTSIZES (CrossCallInfo *pcci) // textptr; no result.
+{
+/* HDC hdc;
+
+ hdc = GetDC (ghMainWindow);
+ EnumFontFamilies (hdc, (char *) pcci->p1, (FONTENUMPROC) EnumFontSizeProc, 0);
+ ReleaseDC (ghMainWindow, hdc);
+ rfree ((char *) pcci->p1);
+ MakeReturn0Cci (pcci);
+*/
+ printf("EvalCcRqGETFONTSIZES -> not implemented");
+ MakeReturn0Cci(pcci);
+}
+
+
+// InstallCrossCallFont adds the proper cross call procedures to the
+// cross call procedures managed by cCrossCall_121.c.
+OS InstallCrossCallFont (OS ios)
+{
+ CrossCallProcedureTable newTable;
+
+ printf("InstallCrossCallFont\n");
+ newTable = EmptyCrossCallProcedureTable ();
+ AddCrossCallEntry (newTable, CcRqGETFONTNAMES,EvalCcRqGETFONTNAMES);
+ AddCrossCallEntry (newTable, CcRqGETFONTSIZES,EvalCcRqGETFONTSIZES);
+ AddCrossCallEntries (gCrossCallProcedureTable, newTable);
+
+ return ios;
+}
diff --git a/Linux_C_12/cCrossCallFont_121.h b/Linux_C_12/cCrossCallFont_121.h new file mode 100644 index 0000000..ba17c00 --- /dev/null +++ b/Linux_C_12/cCrossCallFont_121.h @@ -0,0 +1,6 @@ +#include "util_121.h"
+
+
+// InstallCrossCallFont adds the proper cross call procedures to the
+// cross call procedures managed by cCrossCall_121.c.
+extern OS InstallCrossCallFont (OS);
diff --git a/Linux_C_12/cCrossCallMenus_121.c b/Linux_C_12/cCrossCallMenus_121.c new file mode 100644 index 0000000..c59e9ca --- /dev/null +++ b/Linux_C_12/cCrossCallMenus_121.c @@ -0,0 +1,477 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ Routines related to menu handling.
+********************************************************************************************/
+#include "cCrossCallMenus_121.h"
+#include "cCrossCall_121.h"
+
+
+/* Cross call procedure implementations.
+ Eval<nr> corresponds with a CrossCallEntry generated by NewCrossCallEntry (nr,Eval<nr>).
+*/
+/* Remove a shortkey from a framewindow shortkey table. */
+
+static gboolean dummy_find_accel(GtkAccelKey *key, GClosure *closure, gpointer data)
+{
+ printf("dummy_find_accel\n");
+ return gtk_true();
+}
+
+void EvalCcRqREMOVEMENUSHORTKEY (CrossCallInfo *pcci) /* frameptr, cmd; no result. */
+{
+ GtkWidget *frame;
+ GtkWidget *box;
+ GtkWidget *menu_item;
+ GtkAccelGroup *accel_group;
+
+ printf("EvalCcRqREMOVEMENUSHORTKEY\n");
+ frame = GTK_WIDGET(pcci->p1);
+ menu_item = GTK_WIDGET(pcci->p2);
+
+ accel_group = ((GtkAccelGroup*)gtk_accel_groups_from_object(G_OBJECT(frame))->data);
+
+ for (;;)
+ {
+ GtkAccelKey *key = gtk_accel_group_find(accel_group, dummy_find_accel, NULL);
+ if (!key) break;
+
+ gtk_widget_remove_accelerator(menu_item,
+ accel_group,
+ key->accel_key,
+ key->accel_mods);
+ }
+
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqMODIFYMENUITEM (CrossCallInfo *pcci) /* hitem, hmenu, textptr; no result. */
+{
+ GtkWidget *menu, *menu_item, *label;
+ gchar *title;
+
+ printf("EvalCcRqMODIFYMENUITEM\n");
+ title = createMnemonicString((gchar *) pcci->p3);
+
+ menu = GTK_WIDGET(pcci->p2);
+ menu_item = GTK_WIDGET(pcci->p1);
+ label = gtk_bin_get_child(GTK_BIN(menu_item));
+ gtk_label_set_text_with_mnemonic(GTK_LABEL(label), title);
+
+ rfree(title);
+
+ MakeReturn0Cci (pcci);
+}
+
+static int in_handler_flag = 0;
+
+static void menuitem_activate_handler(GtkMenuItem *menu_item)
+{
+ printf("menuitem_activate_handler\n");
+ if (in_handler_flag == 0)
+ {
+ in_handler_flag = 1;
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), !(GTK_CHECK_MENU_ITEM(menu_item)->active));
+ SendMessage2ToClean (CcWmCOMMAND, GTK_WIDGET(menu_item), GetModifiers ());
+ in_handler_flag = 0;
+ }
+}
+
+void EvalCcRqINSERTMENUITEM (CrossCallInfo *pcci)
+{
+ gchar *title;
+ GtkWidget *menu, *menu_item, *label;
+ GtkAccelGroup *accel_group;
+ guint graystate, checkstate;
+
+ printf("EvalCcRqINSERTMENUITEM\n");
+ printf("Inserting item with position %d and name %s\n", pcci->p5, (char*)pcci->p3);
+
+ printf("Checking graystate: ");
+ if (pcci->p1)
+ {
+ graystate = 1; // MF_ENABLED
+ } else {
+ graystate = 0; // MF_GRAYED;
+ }
+ printf("%s\n", (graystate ? "enabled" : "grayed"));
+
+ printf("Checking checkstate: ");
+ if (pcci->p4)
+ {
+ checkstate = 1; // MF_CHECKED
+ } else {
+ checkstate = 0; // MF_UNCHECKED
+ }
+ printf("%s\n", (checkstate ? "checked" : "unchecked"));
+
+ printf("Calling Make Mnemonic string with: %s\n", (gchar*)pcci->p3);
+ title = createMnemonicString((gchar *) pcci->p3);
+ printf("Got title: %s\n", title);
+
+ menu = GTK_WIDGET(pcci->p2);
+ printf("Menu widget: %s\n", gtk_menu_get_title(GTK_MENU(menu)));
+
+ printf("Creating new menu item\n");
+ menu_item = gtk_menu_item_new_with_mnemonic(title);
+ gtk_menu_shell_insert( GTK_MENU_SHELL (menu), menu_item, (gint) pcci->p5);
+ //gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), menu_item);
+ //gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), ((pcci->p1 & 1) != 0));
+ //gtk_widget_set_sensitive(menu_item, ((pcci->p1 & 2) != 0));
+
+ gtk_signal_connect_object (GTK_OBJECT (menu_item), "activate",
+ GTK_SIGNAL_FUNC (menuitem_activate_handler), menu_item);
+
+ gtk_widget_show(menu_item);
+
+ printf("About to free title: %s\n", title);
+ rfree(title);
+ printf("Freed title\n");
+
+
+/* if (key != 0)
+ {
+ printf("Creating accellerators\n");
+ accel_group = ((GtkAccelGroup *) gtk_accel_groups_from_object (G_OBJECT(frame))->data);
+
+ gtk_widget_add_accelerator(menu_item, "activate",
+ accel_group,
+ key,
+ GDK_CONTROL_MASK,
+ GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator(menu_item, "activate",
+ accel_group,
+ key,
+ GDK_CONTROL_MASK | GDK_SHIFT_MASK,
+ 0);
+ gtk_widget_add_accelerator(menu_item, "activate",
+ accel_group,
+ key,
+ GDK_CONTROL_MASK | GDK_MOD1_MASK,
+ 0);
+ gtk_widget_add_accelerator(menu_item, "activate",
+ accel_group,
+ key,
+ GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK,
+ 0);
+ }
+*/
+ printf("Creating return Cci\n");
+ MakeReturn1Cci (pcci, (int) menu_item);
+}
+
+/* Cross call procedure implementations.
+ Eval<nr> corresponds with a CrossCallEntry generated by NewCrossCallEntry (nr,Eval<nr>).
+*/
+
+/* Add a shortkey to a framewindow shortkey table. */
+void EvalCcRqADDMENUSHORTKEY (CrossCallInfo *pcci) /* frameptr, cmd, key; no result. */
+{
+/* ProcessShortcutTable table;
+ HWND frameptr;
+ int cmd, key;
+
+ frameptr = (HWND) pcci->p1;
+ cmd = pcci->p2;
+ key = pcci->p3;
+
+ table = (ProcessShortcutTable) GetWindowLong (frameptr,0);
+ table = AddProcessShortcut (key, cmd, table);
+ SetWindowLong (frameptr, 0, (long)table);
+
+ if (gAcceleratorTableIsUpToDate)
+ gAcceleratorTableIsUpToDate = !(ghActiveFrameWindow==frameptr);
+ }
+*/
+ printf("EvalCcRqADDMENUSHORTKEY\n");
+ MakeReturn0Cci (pcci);
+}
+
+static void find_item_callback(GtkWidget *menu_item, gpointer data)
+{
+ printf("find_item_callback\n");
+ if (GTK_IS_MENU_ITEM(menu_item) && GTK_MENU_ITEM (menu_item)->submenu == ((GtkWidget *) data))
+ *((GtkWidget **) data) = menu_item;
+}
+
+void EvalCcRqITEMENABLE (CrossCallInfo *pcci) /* parent, HITEM, onoff; no result. */
+{
+ GtkWidget *menu, *menu_item;
+ printf("EvalCcRqITEMENABLE\n");
+
+ menu = GTK_WIDGET(pcci->p1);
+ menu_item = GTK_WIDGET(pcci->p2);
+
+ printf("Menu widget: %s\n", gtk_menu_get_title((GtkMenu*)menu));
+ printf("EvalCcRqITEMENABLE\n");
+ gtk_widget_set_sensitive(menu_item, (gboolean) pcci->p3);
+
+ MakeReturn0Cci (pcci);
+}
+
+/* Destroy a menu 'physically' */
+void EvalCcRqDESTROYMENU (CrossCallInfo *pcci) /* HMENU; no result. */
+{
+ printf("EvalCcRqDESTROYMENU\n");
+
+ /*
+ * This is handled behind-the-scenes by GTK
+ */
+ MakeReturn0Cci (pcci);
+}
+
+/* Remove a menu logically */
+void EvalCcRqDELETEMENU (CrossCallInfo *pcci) /* HMENU, HITEM; no result. */
+{
+ GtkWidget *menu, *menu_item;
+ printf("EvalCcRqDELETEMENU\n");
+
+ menu = GTK_WIDGET(pcci->p1);
+ menu_item = GTK_WIDGET(pcci->p2);
+
+ gtk_container_foreach(GTK_CONTAINER(menu), find_item_callback, (gpointer) &menu_item);
+ if (menu_item != GTK_WIDGET(pcci->p2))
+ {
+ gtk_menu_item_remove_submenu(GTK_MENU_ITEM(menu_item));
+ gtk_widget_destroy(menu_item);
+ }
+
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqREMOVEMENUITEM (CrossCallInfo *pcci) /* menu, HITEM; no result. */
+{
+ GtkWidget *menu, *menu_item;
+ printf("EvalCcRqREMOVEMENUITEM\n");
+
+ menu = GTK_WIDGET(pcci->p1);
+ menu_item = GTK_WIDGET(pcci->p2);
+
+ gtk_menu_item_remove_submenu(GTK_MENU_ITEM(menu_item));
+ gtk_widget_destroy(menu_item);
+
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqINSERTSEPARATOR (CrossCallInfo *pcci) /* hmenu, pos no result. */
+{
+ GtkWidget *menu, *menu_item;
+ printf("EvalCcRqINSERTSEPARATOR\n");
+
+ menu = GTK_WIDGET(pcci->p1);
+ menu_item = gtk_menu_item_new();
+
+ gtk_menu_insert(GTK_MENU(menu), menu_item, (gint) pcci->p2);
+ gtk_widget_show_all(menu_item);
+
+ MakeReturn1Cci (pcci, (int) menu_item);
+}
+
+void EvalCcRqMODIFYMENU (CrossCallInfo *pcci) /* hitem, hmenu, textptr; no result. */
+{
+ gint i;
+ GtkWidget *menu, *menu_item, *label;
+ gchar *title;
+
+ printf("EvalCcRqMODIFYMENU\n");
+ title = createMnemonicString((gchar *) pcci->p3);
+
+ menu = GTK_WIDGET(pcci->p2);
+ menu_item = GTK_WIDGET(pcci->p1);
+ label = gtk_bin_get_child(GTK_BIN(menu_item));
+ gtk_label_set_text_with_mnemonic(GTK_LABEL(label), title);
+
+ rfree(title);
+
+ MakeReturn0Cci (pcci);
+}
+
+/* Insert a menu into the menu bar. */
+void EvalCcRqINSERTMENU (CrossCallInfo *pcci)
+{
+ gint i;
+ gchar *title;
+ GtkWidget *parent_menu, *root_menu, *sub_menu;
+ GtkAccelGroup *accel_group;
+ printf("EvalCcRqINSERTMENU\n");
+
+ title = createMnemonicString((gchar *) pcci->p3);
+ parent_menu = GTK_WIDGET(pcci->p2);
+ sub_menu = GTK_WIDGET(pcci->p4);
+
+ if (GTK_IS_MENU_BAR(parent_menu))
+ {
+ printf("Adding to a menu bar.\n");
+ printf("Menu Bar Name: %s\n", gtk_menu_get_title((GtkMenu*)parent_menu));
+ GtkWidget *frame = gtk_widget_get_parent(gtk_widget_get_parent(parent_menu));
+ accel_group = ((GtkAccelGroup*)gtk_accel_groups_from_object (G_OBJECT(frame))->data);
+ }
+ else
+ {
+ printf("We're not adding to a menu bar!?!\n");
+ printf("Parent Menu widget: %s\n", gtk_menu_get_title((GtkMenu*)parent_menu));
+ accel_group = gtk_menu_get_accel_group (GTK_MENU(parent_menu));
+ }
+
+ gtk_menu_set_accel_group (GTK_MENU(sub_menu), accel_group);
+
+ root_menu = gtk_menu_item_new_with_mnemonic(title);
+ gtk_widget_set_sensitive(root_menu, (gboolean) pcci->p1);
+ gtk_widget_show_all (root_menu);
+
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), sub_menu);
+
+ printf("Inserting menu called %s at position %d (%s)\n",
+ gtk_menu_get_title(GTK_MENU(root_menu)), (gint) pcci->p5, title);
+ if (GTK_IS_MENU_BAR(parent_menu))
+ {
+ gtk_menu_shell_insert(GTK_MENU_SHELL(parent_menu), root_menu, (gint) pcci->p5);
+ } else {
+ gtk_menu_insert(GTK_MENU(parent_menu), root_menu, (gint) pcci->p5);
+ }
+
+ rfree(title);
+
+ printf("New menu is called: %s\n", gtk_menu_get_title((GtkMenu*)root_menu));
+ MakeReturn1Cci (pcci, (int) sub_menu);
+}
+
+static void enable_menu_callback(GtkWidget *menu_item, gpointer data)
+{
+ printf("enable_menu_callback\n");
+ gint *val = (gint*) data;
+ printf("Checking: %d\n", *val);
+ if (GTK_IS_MENU_ITEM(menu_item)
+ && (*val == 0))
+ {
+ gtk_widget_set_sensitive(menu_item, gtk_true());
+ }
+ else
+ {
+ *val = *val - 1;
+ }
+}
+
+static void disable_menu_callback(GtkWidget *menu_item, gpointer data)
+{
+ printf("disable_menu_callback\n");
+ gint *val = (gint*) data;
+
+ printf("Checking: %d\n", *val);
+ if (GTK_IS_MENU_ITEM(menu_item)
+ && (*val == 0))
+ {
+ gtk_widget_set_sensitive(menu_item, gtk_false());
+ }
+ else
+ {
+ *val = *val - 1;
+ }
+}
+
+void EvalCcRqMENUENABLE (CrossCallInfo *pcci) /* parent, zero based position of menu, onoff; no result. */
+{
+ GtkWidget *parent_menu, *sub_menu;
+ printf("EvalCcRqMENUENABLE\n");
+ gint index = pcci->p2;
+
+ if (pcci->p1 && GTK_IS_CONTAINER(pcci->p1))
+ {
+ printf("We have a container. Checking the widget.\n");
+ parent_menu = GTK_WIDGET(pcci->p1);
+ printf("Parent Menu widget: %s\n",
+ gtk_menu_get_title(GTK_MENU(parent_menu)));
+ gtk_container_foreach(GTK_CONTAINER(parent_menu), pcci->p3 ?
+ enable_menu_callback : disable_menu_callback,
+ (gpointer) (&index));
+ }
+
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqDRAWMBAR (CrossCallInfo *pcci) /* framePtr, clientPtr; no result. */
+{
+ printf("EvalCcRqDRAWMBAR\n");
+ MakeReturn0Cci (pcci);
+}
+
+/* Track pop up menu. */
+void EvalCcRqTRACKPOPMENU (CrossCallInfo *pcci) /* popupmenu,framePtr; BOOL result. */
+{
+ printf("EvalCcRqTRACKPOPMENU\n");
+ if (GTK_IS_MENU(pcci->p1))
+ {
+ GtkWidget *popup_menu = GTK_WIDGET(pcci->p1);
+ GtkWidget *frame = GTK_WIDGET(pcci->p2);
+
+ GdkEvent *event = gtk_get_current_event();
+ gtk_menu_popup(GTK_MENU(popup_menu),NULL,NULL,NULL,NULL,
+ (event->type == GDK_BUTTON_PRESS) ?
+ ((GdkEventButton *) event)->button : 0,
+ gdk_event_get_time(event));
+ }
+
+ MakeReturn1Cci (pcci,(int)gtk_true());
+}
+
+void EvalCcRqCREATEPOPMENU (CrossCallInfo *pcci) /* no params; MENU result. */
+{
+ /*
+ * Establish a new meta-menu that will be used to hold the individual
+ * menu entries later.
+ *
+ * This menu should be added to a menu bar.
+ */
+ printf("EvalCcRqCREATEPOPMENU\n");
+ MakeReturn1Cci (pcci, (int) gtk_menu_new());
+}
+
+void EvalCcRqCHECKMENUITEM (CrossCallInfo *pcci) /* menu, HITEM, on/off; no result. */
+{
+ printf("EvalCcRqCHECKMENUITEM\n");
+ if (GTK_IS_MENU(pcci->p1))
+ {
+ GtkWidget *menu = GTK_WIDGET(pcci->p1);
+ GtkWidget *menu_item = GTK_WIDGET(pcci->p2);
+
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item),
+ (gboolean) pcci->p3);
+ }
+
+ MakeReturn0Cci (pcci);
+}
+
+
+/* Install the cross call procedures in the gCrossCallProcedureTable of cCrossCall_121.
+*/
+OS InstallCrossCallMenus (OS ios)
+{
+ CrossCallProcedureTable newTable;
+
+ printf("InstallCrossCallMenus\n");
+ newTable = EmptyCrossCallProcedureTable ();
+ AddCrossCallEntry (newTable, CcRqADDMENUSHORTKEY, EvalCcRqADDMENUSHORTKEY);
+ AddCrossCallEntry (newTable, CcRqREMOVEMENUSHORTKEY, EvalCcRqREMOVEMENUSHORTKEY);
+ AddCrossCallEntry (newTable, CcRqMODIFYMENUITEM, EvalCcRqMODIFYMENUITEM);
+ AddCrossCallEntry (newTable, CcRqINSERTMENUITEM, EvalCcRqINSERTMENUITEM);
+ AddCrossCallEntry (newTable, CcRqITEMENABLE, EvalCcRqITEMENABLE);
+ AddCrossCallEntry (newTable, CcRqDELETEMENU, EvalCcRqDELETEMENU);
+ AddCrossCallEntry (newTable, CcRqDESTROYMENU, EvalCcRqDESTROYMENU);
+ AddCrossCallEntry (newTable, CcRqREMOVEMENUITEM, EvalCcRqREMOVEMENUITEM);
+ AddCrossCallEntry (newTable, CcRqINSERTSEPARATOR, EvalCcRqINSERTSEPARATOR);
+ AddCrossCallEntry (newTable, CcRqMODIFYMENU, EvalCcRqMODIFYMENU);
+ AddCrossCallEntry (newTable, CcRqINSERTMENU, EvalCcRqINSERTMENU);
+ AddCrossCallEntry (newTable, CcRqMENUENABLE, EvalCcRqMENUENABLE);
+ AddCrossCallEntry (newTable, CcRqDRAWMBAR, EvalCcRqDRAWMBAR);
+ AddCrossCallEntry (newTable, CcRqTRACKPOPMENU, EvalCcRqTRACKPOPMENU);
+ AddCrossCallEntry (newTable, CcRqCREATEPOPMENU, EvalCcRqCREATEPOPMENU);
+ AddCrossCallEntry (newTable, CcRqCHECKMENUITEM, EvalCcRqCHECKMENUITEM);
+ AddCrossCallEntries (gCrossCallProcedureTable, newTable);
+
+ return ios;
+}
diff --git a/Linux_C_12/cCrossCallMenus_121.h b/Linux_C_12/cCrossCallMenus_121.h new file mode 100644 index 0000000..8b567ef --- /dev/null +++ b/Linux_C_12/cCrossCallMenus_121.h @@ -0,0 +1,5 @@ +#include "util_121.h"
+
+/* Install the cross call procedures in the gCrossCallProcedureTable of cCrossCall_121.
+*/
+extern OS InstallCrossCallMenus (OS);
diff --git a/Linux_C_12/cCrossCallPrinter_121.c b/Linux_C_12/cCrossCallPrinter_121.c new file mode 100644 index 0000000..593d736 --- /dev/null +++ b/Linux_C_12/cCrossCallPrinter_121.c @@ -0,0 +1,121 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ Routines related to printer handling.
+********************************************************************************************/
+
+#include "cCrossCallPrinter_121.h"
+
+#if 0
+
+#include "cCrossCall_121.h"
+#include "cprinter_121.h"
+
+extern BOOL bUserAbort;
+extern HWND hDlgPrint; /* MW: hDlgPrint is the handle of the "Cancel Printing" dialog. */
+extern HWND hwndText; /* MW: hwndText is the handle of the page count text in the dialog. */
+
+
+/* Cross call procedure implementations.
+ Eval<nr> corresponds with a CrossCallEntry generated by NewCrossCallEntry (nr,Eval<nr>).
+*/
+void EvalCcRqDO_PRINT_SETUP (CrossCallInfo *pcci)
+{ int ok;
+ PRINTDLG *pdPtr;
+ printSetup(0, pcci->p1,
+ (char*) pcci->p2, (char*) pcci->p3, (char*) pcci->p4, (char*) pcci->p5,
+ &ok, &pdPtr);
+ MakeReturn2Cci (pcci, ok, (int) pdPtr);
+}
+
+void EvalCcRqGET_PRINTER_DC (CrossCallInfo *pcci)
+{ int doDialog,emulateScreenRes,
+ err,first,last,copies,pPrintDlg,deviceContext;
+
+ // unpack doDialog and emulateScreenRes
+ doDialog = (pcci->p1) & 1;
+ emulateScreenRes = (pcci->p1) & 2;
+
+ getDC( doDialog,emulateScreenRes,FALSE,pcci->p2,
+ (char*) pcci->p3,(char*) pcci->p4,(char*) pcci->p5,(char*) pcci->p6,
+ &err,&first,&last,&copies,(PRINTDLG**)&pPrintDlg,&deviceContext);
+ MakeReturn6Cci (pcci,err,first,last,copies,pPrintDlg,deviceContext);
+}
+
+void EvalCcRqSTARTDOC (CrossCallInfo *pcci)
+{
+ HDC hdc = (HDC) pcci->p1;
+ int err;
+
+ EnableWindow (ghMainWindow, FALSE) ;
+ hDlgPrint = CreateCancelDialog ();
+ SetAbortProc (hdc, AbortProc) ;
+ err = startDoc((int) hdc);
+ if (err<=0 && ghMainWindow!=NULL && !bUserAbort)
+ {
+ EnableWindow (ghMainWindow, TRUE) ;
+ DestroyWindow (hDlgPrint) ;
+ };
+ MakeReturn1Cci (pcci,err);
+}
+
+void EvalCcRqENDDOC (CrossCallInfo *pcci)
+{
+ HDC hdc = (HDC) pcci->p1;
+
+ endDoc((int) hdc);
+ if (ghMainWindow!=NULL && !bUserAbort)
+ {
+ EnableWindow (ghMainWindow, TRUE) ;
+ DestroyWindow (hDlgPrint) ;
+ };
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqDISPATCH_MESSAGES_WHILE_PRINTING (CrossCallInfo *pcci)
+{
+ MSG msg ;
+ char *pageMessage= (char *) (pcci->p1);
+
+ SetWindowText(hwndText,pageMessage);
+
+ while (!bUserAbort && PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ if (!hDlgPrint || !IsDialogMessage (hDlgPrint, &msg))
+ {
+ TranslateMessage (&msg) ;
+ DispatchMessage (&msg) ;
+ }
+ }
+ MakeReturn0Cci (pcci);
+}
+
+
+/* Install the cross call procedures in the gCrossCallProcedureTable of cCrossCall_121.
+*/
+void InstallCrossCallPrinter ()
+{
+ CrossCallProcedureTable newTable;
+
+ newTable = EmptyCrossCallProcedureTable ();
+ AddCrossCallEntry (newTable, CcRqDO_PRINT_SETUP, EvalCcRqDO_PRINT_SETUP);
+ AddCrossCallEntry (newTable, CcRqGET_PRINTER_DC, EvalCcRqGET_PRINTER_DC);
+ AddCrossCallEntry (newTable, CcRqSTARTDOC, EvalCcRqSTARTDOC);
+ AddCrossCallEntry (newTable, CcRqENDDOC, EvalCcRqENDDOC);
+ AddCrossCallEntry (newTable, CcRqDISPATCH_MESSAGES_WHILE_PRINTING, EvalCcRqDISPATCH_MESSAGES_WHILE_PRINTING);
+ AddCrossCallEntries (gCrossCallProcedureTable, newTable);
+}
+
+#else
+
+OS InstallCrossCallPrinter (OS ios)
+{
+ return ios;
+}
+
+#endif
diff --git a/Linux_C_12/cCrossCallPrinter_121.h b/Linux_C_12/cCrossCallPrinter_121.h new file mode 100644 index 0000000..3ace0bd --- /dev/null +++ b/Linux_C_12/cCrossCallPrinter_121.h @@ -0,0 +1,6 @@ +#include "util_121.h"
+
+
+/* Install the cross call procedures in the gCrossCallProcedureTable of cCrossCall_121.
+*/
+extern OS InstallCrossCallPrinter (OS);
diff --git a/Linux_C_12/cCrossCallProcedureTable_121.c b/Linux_C_12/cCrossCallProcedureTable_121.c new file mode 100644 index 0000000..9e15e26 --- /dev/null +++ b/Linux_C_12/cCrossCallProcedureTable_121.c @@ -0,0 +1,192 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ Implementation of cross call procedure table.
+ In this table a linked list of cross call entries is kept.
+ A cross call entry is a pair of a cross call code (CcRq...) number (see intrface_121.h)
+ and a pointer to a cross call procedure.
+ Routines related to printer handling.
+********************************************************************************************/
+#include "cCrossCallProcedureTable_121.h"
+#include <stdlib.h>
+
+/*
+ * A CrossCallEntry contains a CcRq number and a pointer to a
+ * CrossCallProcedure.
+ */
+struct _crosscallentry
+{
+ int cce_code; /* CcRq... number */
+ CrossCallProcedure cce_proc; /* The procedure to be called in case of
+ cce_code */
+ CrossCallEntry cce_next; /* The next entry in the list */
+};
+
+/*
+ * A CrossCallProcedureTable contains a linked list of CrossCallEntries.
+ */
+struct _crosscallproceduretable
+{ int ccpt_size; // nr of entries
+ CrossCallEntry ccpt_first; // first entry
+ CrossCallEntry ccpt_last; // last entry
+};
+
+
+/* NewCrossCallEntry creates a CrossCallEntry with cce_next field NULL. */
+CrossCallEntry NewCrossCallEntry (int cce_code, CrossCallProcedure cce_proc)
+{
+ CrossCallEntry cce;
+ /* printf("NewCrossCallEntry\n"); */
+ cce = rmalloc (sizeof (struct _crosscallentry));
+
+ cce->cce_code = cce_code;
+ cce->cce_proc = cce_proc;
+ cce->cce_next = NULL;
+
+ return cce;
+}
+
+/* FreeCrossCallEntry frees a CrossCallEntry. */
+void FreeCrossCallEntry (CrossCallEntry cce)
+{
+ /* printf("FreeCrossCallEntry\n"); */
+ rfree (cce);
+}
+
+/* EmptyCrossCallProcedureTable creates an empty table. */
+CrossCallProcedureTable EmptyCrossCallProcedureTable (void)
+{
+ CrossCallProcedureTable ccpt;
+ /* printf("EmptyCrossCallProcedureTable\n"); */
+ ccpt = rmalloc (sizeof (struct _crosscallproceduretable));
+
+ ccpt->ccpt_size = 0;
+ ccpt->ccpt_first = NULL;
+ ccpt->ccpt_last = NULL;
+
+ return ccpt;
+}
+
+/*
+ * GetCrossCallProcedureTableSize returns the current number of installed
+ * cross call procedures.
+ */
+int GetCrossCallProcedureTableSize (CrossCallProcedureTable ccpt)
+{
+ /* printf("GetCrossCallProcedureTableSize\n"); */
+ return ccpt->ccpt_size;
+}
+
+/* FreeCrossCallProcedureTable frees a CrossCallProcedureTable. */
+void FreeCrossCallProcedureTable (CrossCallProcedureTable ccpt)
+{
+ /* printf("FreeCrossCallProcedureTable\n"); */
+ rfree (ccpt);
+}
+
+/* SearchCrossCallEntry (nr,entry) returns the first CrossCallEntry
+ following/including entry that either:
+ matches nr, or
+ is the entry after which a new entry with nr should be added, or
+ NULL in case nr should be placed before entry.
+*/
+static CrossCallEntry SearchCrossCallEntry (int nr,CrossCallEntry entry)
+{
+ /* printf("SearchCrossCallEntry\n"); */
+ if (nr == entry->cce_code)
+ return entry; // entry found
+ if (nr < entry->cce_code)
+ return NULL; // no entry found
+ if (entry->cce_next == NULL)
+ return entry; // last entry; should insert new entry after this one
+ if (nr < entry->cce_next->cce_code)
+ return entry; // next entry exceeds nr; should insert new entry after this one
+ return SearchCrossCallEntry (nr,entry->cce_next);
+}
+
+/*
+ * AddCrossCallEntry (table,nr,proc) adds a new entry (nr,proc) if an entry
+ * with nr is not already present.
+ */
+void AddCrossCallEntry (CrossCallProcedureTable ccpt, int cce_code,
+ CrossCallProcedure cce_proc)
+{
+ CrossCallEntry entry;
+ /* printf("AddCrossCallEntry\n"); */
+ entry = NewCrossCallEntry (cce_code,cce_proc);
+
+ if (ccpt->ccpt_size == 0)
+ { /* table is empty; create entry and add it */
+ ccpt->ccpt_size = 1;
+ ccpt->ccpt_first = entry;
+ ccpt->ccpt_last = entry;
+ }
+ else if (cce_code < ccpt->ccpt_first->cce_code)
+ { /* entry should be inserted before first entry */
+ ccpt->ccpt_size += 1;
+ entry->cce_next = ccpt->ccpt_first;
+ ccpt->ccpt_first= entry;
+ }
+ else if (cce_code > ccpt->ccpt_first->cce_code)
+ { /* entry could be in table; look for it and add it if not present */
+ CrossCallEntry searchCCE;
+ searchCCE = SearchCrossCallEntry (cce_code,ccpt->ccpt_first);
+
+ if (searchCCE == NULL)
+ {
+ /* printf("\'AddCrossCallEntry\' SearchCrossCallEntry returned NULL CrossCallEntry"); */
+ exit(1);
+ }
+ if (searchCCE->cce_code != cce_code)
+ { /* entry not in table but should be linked after searchCCE */
+ gboolean appendLast = (ccpt->ccpt_last == searchCCE);
+ ccpt->ccpt_size += 1;
+ entry->cce_next = searchCCE->cce_next;
+ searchCCE->cce_next = entry;
+
+ if (appendLast)
+ ccpt->ccpt_last = entry; // adjust last if entry is appended at end
+ }
+ }
+}
+
+/* AddCrossCallEntries (table,entries) adds the entries to table */
+void AddCrossCallEntries (CrossCallProcedureTable theTable, CrossCallProcedureTable entries)
+{
+ CrossCallEntry cce;
+ /* printf("AddCrossCallEntries\n"); */
+ cce = entries->ccpt_first;
+
+ while (cce != NULL)
+ {
+ AddCrossCallEntry (theTable, cce->cce_code, cce->cce_proc);
+ cce = cce->cce_next;
+ }
+}
+
+/*
+ * FindCrossCallEntry returns the found CrossCallProcedure or NULL if not found.
+ */
+CrossCallProcedure FindCrossCallEntry (CrossCallProcedureTable ccpt, int cce_code)
+{
+ /* printf("FindCrossCallEntry\n"); */
+ if (ccpt->ccpt_size == 0)
+ { /* table is empty, return NULL */
+ return NULL;
+ }
+ else
+ {
+ CrossCallEntry searchCCE;
+ searchCCE = SearchCrossCallEntry (cce_code,ccpt->ccpt_first);
+ if (searchCCE && searchCCE->cce_code == cce_code)
+ return searchCCE->cce_proc;
+ else
+ return NULL;
+ }
+}
+
diff --git a/Linux_C_12/cCrossCallProcedureTable_121.h b/Linux_C_12/cCrossCallProcedureTable_121.h new file mode 100644 index 0000000..6be6d2d --- /dev/null +++ b/Linux_C_12/cCrossCallProcedureTable_121.h @@ -0,0 +1,41 @@ +/* Implementation of cross call procedure table.
+ In this table a linked list of cross call entries is kept.
+ A cross call entry is a pair of a cross call code (CcRq...) number (see intrface_121.h)
+ and a pointer to a cross call procedure.
+*/
+#ifndef CROSSCALLPROCEDURETABLE_H
+#define CROSSCALLPROCEDURETABLE_H
+
+#include "util_121.h"
+
+/* A CrossCallProcedure is a procedure that modifies a CrossCallInfo struct. */
+typedef void (*CrossCallProcedure)(CrossCallInfo *);
+
+typedef struct _crosscallentry *CrossCallEntry;
+typedef struct _crosscallproceduretable *CrossCallProcedureTable;
+
+/* NewCrossCallEntry creates a CrossCallEntry with cce_next field NULL. */
+extern CrossCallEntry NewCrossCallEntry (int cce_code, CrossCallProcedure cce_proc);
+
+/* FreeCrossCallEntry frees a CrossCallEntry. */
+extern void FreeCrossCallEntry (CrossCallEntry cce);
+
+/* EmptyCrossCallProcedureTable creates an empty table. */
+extern CrossCallProcedureTable EmptyCrossCallProcedureTable (void);
+
+/* GetCrossCallProcedureTableSize returns the current number of installed cross call procedures. */
+extern int GetCrossCallProcedureTableSize (CrossCallProcedureTable ccpt);
+
+/* FreeCrossCallProcedureTable frees a CrossCallProcedureTable. */
+extern void FreeCrossCallProcedureTable (CrossCallProcedureTable ccpt);
+
+/* AddCrossCallEntry adds the given entry if not already present. */
+extern void AddCrossCallEntry (CrossCallProcedureTable ccpt, int cce_code, CrossCallProcedure cce_proc);
+
+/* AddCrossCallEntries (table,entries) adds the entries to table. */
+extern void AddCrossCallEntries (CrossCallProcedureTable theTable, CrossCallProcedureTable entries);
+
+/* FindCrossCallEntry returns the found CrossCallProcedure or NULL if not found.*/
+extern CrossCallProcedure FindCrossCallEntry (CrossCallProcedureTable ccpt, int cce_code);
+
+#endif
diff --git a/Linux_C_12/cCrossCallWindows_121.c b/Linux_C_12/cCrossCallWindows_121.c new file mode 100644 index 0000000..93509c2 --- /dev/null +++ b/Linux_C_12/cCrossCallWindows_121.c @@ -0,0 +1,2482 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ Routines related to window/dialog handling.
+********************************************************************************************/
+
+#include "cCrossCallWindows_121.h"
+#include "cCCallWindows_121.h"
+#include "cCCallSystem_121.h"
+#include "cCrossCall_121.h"
+#include "cCrossCallxDI_121.h"
+#include <gdk/gdkkeysyms.h>
+
+/* Global data:
+*/
+
+extern GtkWidget *gActiveTopLevelWindow;
+
+//static PAINTSTRUCT gPaintStruct;
+//static LONG stdEditCallback = 0; /* The standard internal Windows callback routine of edit controls. */
+//static LONG stdPopUpCallback = 0; /* The standard internal Windows callback routine of pop up controls. */
+
+//HWND ghCaretWnd = NULL;
+
+GdkCursor *gArrowCursor = NULL;
+GdkCursor *gBusyCursor = NULL;
+GdkCursor *gIBeamCursor = NULL;
+GdkCursor *gCrossCursor = NULL;
+GdkCursor *gFatCrossCursor = NULL;
+GdkCursor *gHiddenCursor = NULL;
+
+GtkWidget *gFirstRadioButton = NULL;
+
+const gchar* SCROLL_SIZE_KEY = "scrollbar-size";
+const gchar* SCROLL_VALUE_CHANGED = "value-changed";
+const gchar* SCROLL_POS_KEY = "current-scroll-position";
+
+/* Some macros needed to support windows-ish scrollbars */
+#define SB_CTL 2
+#define SB_LINEUP 0
+#define SB_LINELEFT 0
+#define SB_LINEDOWN 1
+#define SB_LINERIGHT 1
+#define SB_PAGEUP 2
+#define SB_PAGEDOWN 3
+#define SB_THUMBPOSITION 4
+#define SB_TOP 6
+#define SB_BOTTOM 7
+
+/* Find the first non CompoundControl parent window of the argument. */
+static GtkWidget *GetControlParent (GtkWidget *widget)
+{
+ GtkWidget *parent = widget, *res = NULL, *last = NULL;
+ printf("GetControlParent\n");
+
+ while (parent != NULL)
+ {
+ if (GTK_IS_SCROLLED_WINDOW(parent))
+ res = parent;
+
+ last = parent;
+ parent = gtk_widget_get_parent (parent);
+ }
+
+ return (GTK_IS_DIALOG(last)) ? last : res;
+}
+
+static GtkFixed *GetFixed (GtkWidget *widget)
+{
+ printf("GetFixed\n");
+ if (GTK_IS_DIALOG(widget))
+ {
+ return GTK_FIXED(
+ GTK_WIDGET(gtk_container_children(
+ GTK_CONTAINER(GTK_DIALOG(widget)->vbox))->data));
+ }
+ else
+ {
+ return GTK_FIXED(GTK_BIN(GTK_BIN(widget)->child)->child);
+ }
+}
+
+
+/*********************************************************************************************
+ The callback routine for a compound control.
+*********************************************************************************************/
+#if 0
+static LRESULT CALLBACK CompoundControlProcedure (HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
+{
+ switch (uMess)
+ {
+ case WM_COMMAND:
+ {
+ switch (HIWORD (wParam))
+ {
+ case BN_CLICKED:
+ {
+ if (lParam != 0)
+ {
+ /* Send also modifiers to Clean */
+ SendMessage4ToClean (CcWmBUTTONCLICKED, GetControlParent (hwnd), lParam, GetModifiers (), LOWORD (wParam));
+ }
+ return 0;
+ }
+ break;
+ case CBN_SETFOCUS:
+ {
+ gComboSelection = SendMessage ((HWND) lParam, CB_GETCURSEL, 0, 0);
+ return 0;
+ }
+ break;
+ case CBN_KILLFOCUS:
+ {
+ gComboSelection = -1;
+ return 0;
+ }
+ break;
+ case CBN_SELENDOK:
+ {
+ char text[256];
+ int newsel;
+ HWND combo;
+
+ combo = (HWND) lParam;
+ newsel = SendMessage (combo, CB_GETCURSEL, 0, 0);
+ SendMessage (combo, CB_GETLBTEXT, newsel, (LPARAM) text);
+ if (!SendMessage (combo, CB_GETITEMDATA, newsel, 0))
+ {
+ SendMessage (combo, CB_SETCURSEL, gComboSelection, (LPARAM) text);
+ MessageBeep (0xFFFFFFFF);
+ return 0;
+ }
+ else
+ {
+ gComboSelection = newsel;
+ if (newsel!=CB_ERR)
+ SendMessage3ToClean (CcWmITEMSELECT, GetControlParent (hwnd), combo, newsel);
+ return 1;
+ }
+ }
+ break;
+ }
+ return 0;
+ } break;
+ case WM_PAINT:
+ {
+ HWND parentwindow;
+ HDC hdc;
+ PAINTSTRUCT ps;
+
+ if (GetUpdateRect(hwnd,NULL,FALSE)) // determine if there is really an update area.
+ {
+ parentwindow = GetControlParent (hwnd);
+ hdc = BeginPaint (hwnd, &ps);
+ SendMessage3ToClean (CcWmDRAWCONTROL, parentwindow, hwnd, hdc);
+ EndPaint (hwnd, &ps);
+ }
+ return 0;
+ } break;
+ case WM_HSCROLL:
+ {
+ int nPos,nScrollCode,controlkind;
+ HWND parentwindow, hwndScrollBar;
+
+ nScrollCode = LOWORD (wParam);
+
+ if (nScrollCode != SB_ENDSCROLL) /* Do not send the SB_ENDSCROLL to Clean. */
+ {
+ nPos = (short int) HIWORD (wParam);
+ parentwindow = GetControlParent (hwnd);
+ hwndScrollBar = (HWND) lParam;
+
+ if (hwndScrollBar==0)
+ {
+ controlkind = SB_HORZ; /* lParam==0 in case of Compound scrollbars. */
+ hwndScrollBar = hwnd; /* pass the compound control handle to Clean. */
+ UpdateWindow (hwnd); /* but first ensure that compound control is updated. */
+ }
+ else
+ {
+ controlkind = SB_CTL; /* lParam!==0 in case of SliderControls. */
+ }
+ SendMessage5ToClean (CcWmSCROLLBARACTION, parentwindow, hwndScrollBar, controlkind, nScrollCode, nPos);
+ }
+ return 0;
+ }
+ break;
+ case WM_VSCROLL:
+ {
+ int nPos,nScrollCode,controlkind;
+ HWND parentwindow, hwndScrollBar;
+
+ nScrollCode = LOWORD (wParam);
+
+ if (nScrollCode != SB_ENDSCROLL) /* Do not send the SB_ENDSCROLL to Clean. */
+ {
+ nPos = (short int) HIWORD (wParam);
+ parentwindow = GetControlParent (hwnd);
+ hwndScrollBar = (HWND) lParam;
+
+ if (hwndScrollBar==0)
+ {
+ controlkind = SB_VERT; /* lParam==0 in case of Compound scrollbars. */
+ hwndScrollBar = hwnd; /* pass the compound control handle to Clean. */
+ UpdateWindow (hwnd); /* but first ensure that compound control is updated. */
+ }
+ else
+ {
+ controlkind = SB_CTL; /* lParam!==0 in case of SliderControls. */
+ }
+ SendMessage5ToClean (CcWmSCROLLBARACTION, parentwindow, hwndScrollBar, controlkind, nScrollCode, nPos);
+ }
+ return 0;
+ }
+ break;
+ /* The following cases concerning mouse events
+ (WM_LBUTTONDOWN upto WM_TIMER) have been copied from CustomControlProcedure.
+ */
+ case WM_LBUTTONDOWN:
+ {
+/* SendMouseDownToClean (GetControlParent (hwnd), hwnd, SIGNEDLOWORD (lParam), SIGNEDHIWORD (lParam));*/
+ return 0;
+ } break;
+ case WM_MOUSEMOVE:
+ {
+ if (gInMouseDown)
+ {
+/* SendMouseStillDownToClean (GetControlParent (hwnd), hwnd, SIGNEDLOWORD (lParam), SIGNEDHIWORD (lParam)); */
+ }
+ else
+ {
+/* SendMouseStillUpToClean (GetControlParent (hwnd), hwnd, SIGNEDLOWORD (lParam), SIGNEDHIWORD (lParam)); */
+ }
+ return 0;
+ } break;
+ case WM_LBUTTONUP:
+ {
+ if (gInMouseDown)
+ {
+ ReleaseCapture (); /* rely on WM_CAPTURECHANGED to send the mouseUp event */
+ }
+ return 0;
+ } break;
+ case WM_CANCELMODE:
+ {
+ if (gInMouseDown)
+ {
+ ReleaseCapture (); /* rely on WM_CAPTURECHANGED to send the mouseUp event */
+ }
+ return DefWindowProc (hwnd, uMess, wParam, lParam);
+ } break;
+ case WM_CAPTURECHANGED:
+ {
+ if (gInMouseDown)
+ {
+ POINT p;
+ GetCursorPos (&p);
+ ScreenToClient (hwnd, &p);
+/* SendMouseUpToClean (GetControlParent (hwnd), hwnd, p.x, p.y); */
+ }
+ return 0;
+ } break;
+ /* The following cases concerning key events and focus events
+ (WM_SYSKEYDOWN upto WM_GETDLGCODE) have been copied from CustomControlProcedure.
+ */
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN:
+ {
+ int c = 0;
+ HWND hwndParent;
+
+ c = CheckVirtualKeyCode ((int) wParam);
+
+ if (!c)
+ /* Ignore non-virtual keys, because they arrive as WM_SYSCHAR and WM_CHAR. */
+ {
+ return DefWindowProc (hwnd, uMess, wParam, lParam);
+ }
+ /* Handle virtual keys analogously to keys received as WM_SYSCHAR and WM_CHAR. */
+ hwndParent = GetControlParent (hwnd);
+/* if (gInKey)
+ {
+ if (gCurChar == c)
+ SendKeyStillDownToClean (hwndParent, hwnd, gCurChar);
+ else
+ {
+ SendKeyUpToClean (hwndParent, hwnd, gCurChar);
+ gCurChar = c;
+ SendKeyDownToClean (hwndParent, hwnd, gCurChar);
+ }
+ }
+ else
+ {
+ gCurChar = c;
+ SendKeyDownToClean (hwndParent, hwnd, gCurChar);
+ gInKey = TRUE;
+ }
+*/
+ return 0;
+ }
+ break;
+ case WM_SYSCHAR:
+ case WM_CHAR:
+ {
+ HWND hwndParent = GetControlParent (hwnd);
+
+/* if (gInKey)
+ {
+ if (gCurChar == (int) wParam)
+ SendKeyStillDownToClean (hwndParent, hwnd, gCurChar);
+ else
+ {
+ SendKeyUpToClean (hwndParent, hwnd, gCurChar);
+ gCurChar = wParam;
+ SendKeyDownToClean (hwndParent, hwnd, gCurChar);
+ }
+ }
+ else
+ {
+ gCurChar = wParam;
+ SendKeyDownToClean (hwndParent, hwnd, gCurChar);
+ gInKey = TRUE;
+ }
+*/
+ return 0;
+ }
+ break;
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
+ {
+ if (gInKey)
+ SendKeyUpToClean (GetControlParent (hwnd), hwnd, gCurChar);
+ gInKey = FALSE;
+ gCurChar = 0;
+ return DefWindowProc (hwnd, uMess, wParam, lParam);
+ }
+ break;
+ case WM_KILLFOCUS:
+ {
+ HWND hwndParent = GetControlParent (hwnd);
+ if (gInKey)
+ SendKeyUpToClean (hwndParent, hwnd, gCurChar);
+ gInKey = FALSE;
+ gCurChar = 0;
+ /* WM_KILLFOCUS now also sends the CcWmKILLFOCUS message to
+ Clean (because of the ControlDeactivate attribute).
+ */
+ SendMessage2ToClean (CcWmKILLFOCUS, hwndParent, hwnd);
+ return 0;
+ }
+ break;
+ case WM_SETFOCUS:
+ {
+ /* WM_SETFOCUS sends the CcWmSETFOCUS message to Clean because
+ of the ControlActivate attribute.
+ */
+ SendMessage2ToClean (CcWmSETFOCUS, GetControlParent (hwnd), hwnd);
+ return 0;
+ }
+ break;
+ /* The WM_CLOSE event is generated when a user presses escape inside an EditControl that exists
+ within the CompoundControl which exists within a Dialog.
+ */
+ case WM_CLOSE:
+ {
+ SendMessage1ToClean (CcWmCLOSE, GetControlParent (hwnd));
+ return 0;
+ }
+ break;
+ case WM_GETDLGCODE: /* Inform dialog procedure to pass all keyboard input to the control. */
+ return (DLGC_WANTCHARS | DLGC_WANTARROWS);
+ break;
+ case WM_DRAWITEM:
+ {
+ LPDRAWITEMSTRUCT lpdis;
+ lpdis = (LPDRAWITEMSTRUCT) lParam;
+
+ switch (lpdis->CtlType)
+ {
+ case ODT_COMBOBOX:
+ {
+ char text[256];
+ COLORREF forecolor, bkcolor;
+ SendMessage (lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID, (LPARAM) text);
+ if (lpdis->itemState & ODS_DISABLED)
+ {
+ forecolor = SetTextColor (lpdis->hDC, GetSysColor (COLOR_GRAYTEXT));
+ bkcolor = SetBkColor (lpdis->hDC, GetSysColor (COLOR_3DFACE));
+ }
+ else if (lpdis->itemState & ODS_SELECTED)
+ {
+ if (lpdis->itemData)
+ {
+ forecolor = SetTextColor (lpdis->hDC, GetSysColor (COLOR_HIGHLIGHTTEXT));
+ bkcolor = SetBkColor (lpdis->hDC, GetSysColor (COLOR_HIGHLIGHT));
+ }
+ else
+ {
+ forecolor = SetTextColor (lpdis->hDC, GetSysColor (COLOR_GRAYTEXT));
+ bkcolor = SetBkColor (lpdis->hDC, GetSysColor (COLOR_WINDOW));
+ }
+ }
+ else
+ {
+ if (lpdis->itemData)
+ forecolor = SetTextColor (lpdis->hDC, GetSysColor (COLOR_WINDOWTEXT));
+ else
+ forecolor = SetTextColor (lpdis->hDC, GetSysColor (COLOR_GRAYTEXT));
+ bkcolor = SetBkColor (lpdis->hDC, GetSysColor (COLOR_WINDOW));
+ }
+
+ ExtTextOut (lpdis->hDC, /* device context */
+ lpdis->rcItem.left + 2, /* ref point x */
+ lpdis->rcItem.top + 1, /* ref point y */
+ ETO_CLIPPED | ETO_OPAQUE, /* options */
+ &lpdis->rcItem, /* clipping rect */
+ text, /* text to draw */
+ lstrlen (text), /* length of text to draw */
+ NULL /* no kerning array */
+ );
+
+ SetTextColor (lpdis->hDC, forecolor);
+ SetBkColor (lpdis->hDC, bkcolor);
+
+ if (lpdis->itemState & ODS_FOCUS)
+ DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
+ return 0;
+ } break;
+ case ODT_BUTTON:
+ {
+ HWND parentwindow;
+ parentwindow = GetControlParent (hwnd);
+
+ SendMessage3ToClean (CcWmDRAWCONTROL, parentwindow, lpdis->hwndItem, lpdis->hDC);
+
+ if (lpdis->itemState & ODS_SELECTED)
+ InvertRect (lpdis->hDC, &lpdis->rcItem);
+
+ if (lpdis->itemState & ODS_FOCUS)
+ DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
+ return 0;
+ } break;
+ }
+ return 0;
+ }
+ break;
+ default:
+ return DefWindowProc (hwnd, uMess, wParam, lParam);
+ break;
+ }
+ ErrorExit ("Fatal error: case leak in CompoundControlProcedure (%d).",uMess);
+} /* CompoundControlProcedure */
+#endif
+
+/*********************************************************************************************
+ Cross call procedure implementations.
+ Eval<nr> corresponds with a CrossCallEntry generated by NewCrossCallEntry (nr,Eval<nr>).
+*********************************************************************************************/
+void EvalCcRqBEGINPAINT (CrossCallInfo *pcci) /* hwnd; HDC result. */
+{
+/* HDC hdc;
+ hdc = BeginPaint ((HWND) pcci->p1, &gPaintStruct);
+*/
+
+ rprintf("EvalCcRqBEGINPAINT -> not implemented\n");
+ MakeReturn1Cci (pcci, (int) NULL /*hdc*/);
+}
+
+void EvalCcRqENDPAINT (CrossCallInfo *pcci) /* hwnd; no result. */
+{
+/* EndPaint ((HWND) pcci->p1, &gPaintStruct); */
+ rprintf("EvalCcRqEndPaint -> not implemented\n");
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqFAKEPAINT (CrossCallInfo *pcci) /* hwnd; no result. */
+{
+/* HWND hwnd = (HWND) pcci->p1;
+
+ BeginPaint (hwnd, &gPaintStruct);
+ EndPaint (hwnd,&gPaintStruct);
+ InvalidateRect (hwnd, NULL, FALSE);
+*/
+
+ printf("EvalCcRqFAKEPAINT -> not implemented\n");
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqDESTROYMODALDIALOG (CrossCallInfo *pcci) /* hwnd; no result. */
+{
+ GtkWidget *dialog;
+ printf("EvalCcRqDESTROYMODALDIALOG\n");
+ dialog = GTK_WIDGET(pcci->p1);
+ gtk_dialog_response (GTK_DIALOG(dialog), 0);
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqDESTROYMDIDOCWINDOW (CrossCallInfo *pcci) /* hwndFrame, hwndClient, wPtr; no result. */
+{
+ gint page_num;
+ GtkWidget *frame, *client, *window;
+
+ printf("EvalCcRqDESTROYMDIDOCWINDOW\n");
+ frame = GTK_WIDGET(pcci->p1);
+ client = GTK_WIDGET(pcci->p2);
+ window = GTK_WIDGET(pcci->p3);
+
+ page_num = gtk_notebook_page_num(GTK_NOTEBOOK(client), window);
+ gtk_notebook_remove_page(GTK_NOTEBOOK(client), page_num);
+
+ MakeReturn0Cci (pcci);
+}
+
+static gint client_expose_handler(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
+{
+ printf("client_expose_handler\n");
+ SendMessage6ToClean(CcWmPAINT, (int)gtk_widget_get_parent(gtk_widget_get_parent(widget)),
+ event->area.x,
+ event->area.y,
+ event->area.x+event->area.width,
+ event->area.y+event->area.height,
+ (int) GDK_DRAWABLE(event->window));
+
+ return GTK_WIDGET_GET_CLASS(widget)->expose_event(widget,event);
+}
+
+static void sw_focus_out_handler(GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
+{
+ printf("sw_focus_out_handler\n");
+ if (gInKey)
+ {
+ SendKeyUpToClean (widget, widget, gCurChar);
+ }
+
+ gInKey = gtk_false();
+ gCurChar = 0;
+}
+
+static gboolean sw_button_press_handler(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
+{
+ printf("sw_button_press_handler\n");
+ if (event->button == 1)
+ {
+ GtkWidget *client = gtk_widget_get_parent(widget);
+
+ gInMouseDown = TRUE;
+
+ switch (event->type)
+ {
+ case GDK_BUTTON_PRESS:
+ SendMessage6ToClean (CcWmMOUSE, client, client, BUTTONDOWN, event->x, event->y, GetModifiers());
+ break;
+ case GDK_2BUTTON_PRESS:
+ SendMessage6ToClean (CcWmMOUSE, client, client, BUTTONDOUBLEDOWN, event->x, event->y, GetModifiers());
+ break;
+ case GDK_3BUTTON_PRESS:
+ SendMessage6ToClean (CcWmMOUSE, client, client, BUTTONTRIPLEDOWN, event->x, event->y, GetModifiers());
+ break;
+ }
+ return gtk_true();
+ }
+ return gtk_false();
+}
+
+static gboolean sw_button_release_handler(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
+{
+ printf("sw_button_release_handler\n");
+ if (event->button == 1)
+ {
+ GtkWidget *client = gtk_widget_get_parent(widget);
+
+ gInMouseDown = FALSE;
+ SendMessage6ToClean (CcWmMOUSE, client, client, BUTTONUP, event->x, event->y, GetModifiers());
+ return gtk_true();
+ }
+ return gtk_false();
+}
+
+static gboolean sw_motion_notify_handler(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
+{
+ GtkWidget *client;
+ printf("sw_motion_notify_handler\n");
+ client = gtk_widget_get_parent(widget);
+
+ if (gInMouseDown)
+ {
+ SendMessage6ToClean(CcWmMOUSE, client, client, BUTTONSTILLDOWN, event->x, event->y, GetModifiers());
+ } else {
+ SendMessage6ToClean (CcWmMOUSE, client, client, BUTTONSTILLUP, event->x, event->y, GetModifiers());
+ }
+ return gtk_true();
+}
+
+static void client_size_allocate(GtkWidget *widget, GtkAllocation *allocation, gpointer user_data)
+{
+ GtkWidget *sw;
+ printf("client_size_allocate\n");
+ sw = GTK_WIDGET(user_data);
+ SendMessage4ToClean (CcWmSIZE, sw, allocation->width, allocation->height, (int)FALSE);
+}
+
+static void client_size_request(GtkWidget *widget, GtkRequisition *requisition, gpointer user_data)
+{
+ printf("client_size_request\n");
+ *requisition = *((GtkRequisition *) user_data);
+ printf("client_size_request(%d,%d)\n", requisition->width, requisition->height);
+}
+
+static gboolean client_delete_handler(GtkWidget *widget, GdkEvent *event, gpointer user_data)
+{
+ printf("client_delete_handler(%d,%d)\n", ((GtkRequisition *) user_data)->width, ((GtkRequisition *) user_data)->height);
+ g_free(((GtkRequisition*)user_data));
+ return gtk_true();
+}
+
+static void compute_height(GtkWidget *widget, gpointer data)
+{
+ GtkRequisition requisition;
+ printf("compute_height\n");
+ gtk_widget_size_request(widget,&requisition);
+ *((int *) data) += requisition.height;
+}
+
+/* Create a SDI document window. */
+void EvalCcRqCREATESDIDOCWINDOW (CrossCallInfo *pcci) /* textptr, frameptr, packed pos, w,h, flags; client ptr result. */
+{
+ GtkWidget *window, *fixed, *box, *sw;
+ const gchar *pwintitle;
+ gint left, top, width, height;
+ GtkRequisition *requisition;
+
+ printf("EvalCcRqCREATESDIDOCWINDOW\n");
+ pwintitle = (const gchar *) pcci->p1;
+ window = GTK_WIDGET(pcci->p2);
+ left = pcci->p3>>16;
+ top = (pcci->p3<<16)>>16;
+ width = pcci->p4;
+ height = pcci->p5;
+
+ requisition = g_new(GtkRequisition, 1);
+ requisition->width = 0;
+ requisition->height = 0;
+
+ /* Adjust the pos and size of the frame window. */
+ gtk_widget_set_uposition(window, left, top);
+
+ if (pwintitle)
+ {
+ gtk_window_set_title(GTK_WINDOW(window), pwintitle);
+ }
+
+ /* Create a Scrolled Window */
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ box = gtk_bin_get_child(GTK_BIN(window));
+ gtk_box_pack_end (GTK_BOX (box), sw, TRUE, TRUE, 0);
+
+ /* Create a Fixed Container */
+ fixed = gtk_fixed_new();
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), fixed);
+
+ /* Signals */
+ gtk_signal_connect (GTK_OBJECT(fixed), "expose-event",
+ GTK_SIGNAL_FUNC(client_expose_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(GTK_BIN(sw)->child), "focus-out-event",
+ GTK_SIGNAL_FUNC(sw_focus_out_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(GTK_BIN(sw)->child), "button-press-event",
+ GTK_SIGNAL_FUNC(sw_button_press_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(GTK_BIN(sw)->child), "button-release-event",
+ GTK_SIGNAL_FUNC(sw_button_release_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(GTK_BIN(sw)->child), "motion_notify_event",
+ GTK_SIGNAL_FUNC(sw_motion_notify_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(fixed), "size-allocate",
+ GTK_SIGNAL_FUNC(client_size_allocate),
+ sw);
+ gtk_signal_connect (GTK_OBJECT(fixed), "size-request",
+ GTK_SIGNAL_FUNC(client_size_request),
+ requisition);
+ gtk_signal_connect (GTK_OBJECT(fixed), "delete-event",
+ GTK_SIGNAL_FUNC(client_delete_handler),
+ requisition);
+
+ g_object_set_data(G_OBJECT(sw), SCROLL_SIZE_KEY, (gpointer)requisition);
+
+ SendMessage1ToClean (CcWmCREATE, sw);
+
+ gtk_widget_realize(window);
+
+ {
+ gint depth;
+ GdkRectangle ext_rect, rect;
+
+ gdk_window_get_geometry(window->window, &rect.x, &rect.y, &rect.width, &rect.height, &depth);
+ gdk_window_get_frame_extents (window->window,&ext_rect);
+
+ gtk_container_foreach(GTK_CONTAINER(GTK_BIN(window)->child), compute_height, &ext_rect.height);
+
+ gtk_window_set_default_size(GTK_WINDOW(window), width+(ext_rect.width - rect.width), height+(ext_rect.height - rect.height));
+ }
+
+ gtk_widget_show_all(window);
+
+ gdk_window_set_events(GTK_BIN(sw)->child->window,
+ gdk_window_get_events(GTK_BIN(sw)->child->window) | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK);
+ fprintf(stderr,"EvalCcRqCREATESDIDOCWINDOW - window: %d sw: %d\n",window,sw);
+ MakeReturn1Cci (pcci, (int) sw);
+}
+
+/* Create MDI child window. */
+void EvalCcRqCREATEMDIDOCWINDOW (CrossCallInfo *pcci) /* textptr, clientPtr, behindPtr, packed pos, packed size, flags; HWND result. */
+{
+ GtkWidget *window, *fixed, *client, *behind, *sw;
+ const gchar *pwintitle;
+ gint left, top, width, height;
+ GtkRequisition *requisition;
+ gint index;
+
+ printf("EvalCcRqCREATEMDIDOCWINDOW\n");
+ pwintitle = (const gchar *) pcci->p1;
+ client = GTK_WIDGET(pcci->p2);
+ behind = GTK_WIDGET(pcci->p3);
+ left = pcci->p4>>16;
+ top = (pcci->p4<<16)>>16;
+ width = pcci->p5>>16;
+ height = (pcci->p5<<16)>>16;
+
+ window = gtk_widget_get_parent(gtk_widget_get_parent(client));
+
+ requisition = g_new(GtkRequisition, 1);
+ requisition->width = 0;
+ requisition->height = 0;
+
+ /* Create a Scrolled Window */
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ index = gtk_notebook_page_num(GTK_NOTEBOOK(client), behind);
+ gtk_notebook_insert_page(GTK_NOTEBOOK(client), sw,
+ pwintitle ? gtk_label_new(pwintitle) : NULL,
+ index);
+
+ /* Create a Fixed Container */
+ fixed = gtk_fixed_new();
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), fixed);
+
+ /* Signals */
+ gtk_signal_connect (GTK_OBJECT(fixed), "expose-event",
+ GTK_SIGNAL_FUNC(client_expose_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(GTK_BIN(sw)->child), "focus-out-event",
+ GTK_SIGNAL_FUNC(sw_focus_out_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(GTK_BIN(sw)->child), "button-press-event",
+ GTK_SIGNAL_FUNC(sw_button_press_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(GTK_BIN(sw)->child), "button-release-event",
+ GTK_SIGNAL_FUNC(sw_button_release_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(GTK_BIN(sw)->child), "motion_notify_event",
+ GTK_SIGNAL_FUNC(sw_motion_notify_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(fixed), "size-allocate",
+ GTK_SIGNAL_FUNC(client_size_allocate),
+ sw);
+ gtk_signal_connect (GTK_OBJECT(fixed), "size-request",
+ GTK_SIGNAL_FUNC(client_size_request),
+ requisition);
+ gtk_signal_connect (GTK_OBJECT(fixed), "delete-event",
+ GTK_SIGNAL_FUNC(client_delete_handler),
+ requisition);
+
+ g_object_set_data(G_OBJECT(sw), SCROLL_SIZE_KEY, (gpointer)requisition);
+
+ SendMessage1ToClean (CcWmCREATE, sw);
+
+ gtk_widget_show_all(sw);
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(client), gtk_notebook_page_num(GTK_NOTEBOOK(client),sw));
+
+ gdk_window_set_events(GTK_BIN(sw)->child->window,
+ gdk_window_get_events(GTK_BIN(sw)->child->window) | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK);
+
+ MakeReturn1Cci (pcci, (int) sw);
+}
+
+void EvalCcRqSETWINDOWTITLE (CrossCallInfo *pcci) /* hwnd, textptr no result. */
+{
+ GtkWidget *window;
+ gchar *title = (gchar *) pcci->p2;
+
+ printf("EvalCcRqSETWINDOWTITLE\n");
+ window = GTK_WIDGET(pcci->p1);
+ if (GTK_IS_WINDOW(window))
+ {
+ gtk_window_set_title(GTK_WINDOW(window), title);
+ }
+ else
+ {
+ if (GTK_IS_LABEL(window))
+ {
+ gtk_label_set_text(GTK_LABEL(window), title);
+ }
+ else
+ {
+ if (GTK_IS_BUTTON(window))
+ {
+ title = createMnemonicString(title);
+ gtk_button_set_label(GTK_BUTTON(window), title);
+ rfree(title);
+ }
+ else
+ {
+ if (GTK_IS_ENTRY(window))
+ {
+ gtk_entry_set_text(GTK_ENTRY(window), title);
+ }
+ else
+ {
+ if (GTK_IS_TEXT_VIEW(window))
+ {
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(window));
+ gtk_text_buffer_set_text (buffer, title, strlen(title));
+ }
+ else
+ {
+ printf("EvalCcRqSETWINDOWTITLE -> unknown widget type");
+ }
+ }
+ }
+ }
+ }
+
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqGETWINDOWTEXT (CrossCallInfo *pcci) /* hwnd; textptr result. */
+{
+ G_CONST_RETURN gchar *title = NULL;
+ GtkWidget *window;
+ gchar *textptr;
+
+ printf("EvalCcRqGETWINDOWTEXT\n");
+ window = GTK_WIDGET(pcci->p1);
+
+ if (GTK_IS_WINDOW(window))
+ {
+ title = gtk_window_get_title(GTK_WINDOW(window));
+ }
+ else
+ {
+ if (GTK_IS_LABEL(window))
+ {
+ title = gtk_label_get_text(GTK_LABEL(window));
+ }
+ else
+ {
+ if (GTK_IS_BUTTON(window))
+ {
+ title = gtk_button_get_label(GTK_BUTTON(window));
+ }
+ else
+ {
+ if (GTK_IS_ENTRY(window))
+ {
+ title = gtk_entry_get_text(GTK_ENTRY(window));
+ }
+ else
+ {
+ if (GTK_IS_TEXT_VIEW(window))
+ {
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(window));
+ GtkTextIter start, end;
+
+ gtk_text_buffer_get_start_iter(buffer, &start);
+ gtk_text_buffer_get_end_iter(buffer, &end);
+ title = gtk_text_buffer_get_text (buffer, &start, &end, gtk_true());
+ }
+ else
+ {
+ printf("EvalCcRqSETWINDOWTITLE -> unknown widget type");
+ }
+ }
+ }
+ }
+ }
+
+ if (GTK_IS_BUTTON(window))
+ {
+ textptr = createMnemonicString(title);
+ } else {
+ textptr = g_strdup(title);
+ }
+
+ MakeReturn1Cci (pcci, (gint) textptr);
+}
+
+/* Update rect part of a window. */
+void EvalCcRqUPDATEWINDOWRECT (CrossCallInfo *pcci) /* hwnd, left,top,right,bottom; no result. */
+{
+/* RECT rect;
+ HWND hwnd;
+
+ hwnd = (HWND) pcci->p1;
+ rect.left = pcci->p2;
+ rect.top = pcci->p3;
+ rect.right = pcci->p4;
+ rect.bottom= pcci->p5;
+
+ InvalidateRect (hwnd,&rect,FALSE);
+ UpdateWindow (hwnd);
+ RedrawWindow (hwnd,&rect,NULL,RDW_FRAME | RDW_VALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN);
+*/
+ printf("EvalCcRqUPDATEWINDOWRECT -> not implemented\n");
+ MakeReturn0Cci (pcci);
+}
+
+/* Set the ClientRect. */
+void EvalCcRqSETCLIENTSIZE (CrossCallInfo *pcci) /* hwnd, width, height; no result. */
+{
+/* HWND hwnd;
+ int w,h,curw,curh,clientw,clienth;
+ UINT flags;
+ RECT clientRect,windowRect;
+
+ hwnd = (HWND) pcci->p1;
+ w = pcci->p2;
+ h = pcci->p3;
+ flags = SWP_NOMOVE // retain position
+ | SWP_NOZORDER; // retain Z order
+
+ GetClientRect (hwnd, &clientRect);
+ GetWindowRect (hwnd, &windowRect);
+ clientw = clientRect.right - clientRect.left;
+ clienth = clientRect.bottom- clientRect.top;
+ curw = windowRect.right - windowRect.left;
+ curh = windowRect.bottom- windowRect.top;
+
+ SetWindowPos (hwnd, HWND_TOP, 0,0, curw+w-clientw,curh+h-clienth, flags);*/
+ printf("EvalCcRqSETCLIENTSIZE -> not implemented\n");
+ MakeReturn0Cci (pcci);
+}
+
+/* (En/Dis)able windows/dialogues. */
+void EvalCcRqSETSELECTWINDOW (CrossCallInfo *pcci) /* hwnd, hasHScroll, hasVScroll, toAble, modalContext; no result. */
+{
+#if 0
+ HWND window;
+ BOOL hasHScroll, hasVScroll, toAble, modalContext;
+
+ window = (HWND) pcci->p1;
+ hasHScroll = (BOOL) pcci->p2;
+ hasVScroll = (BOOL) pcci->p3;
+ toAble = (BOOL) pcci->p4;
+ modalContext = (BOOL) pcci->p5;
+
+ if (modalContext) /* if not a modal context, then do not disable window */
+ EnableWindow (window,toAble); /* because it can't be moved, or closed. */
+ if (hasHScroll)
+ EnableScrollBar (window,SB_HORZ,toAble ? ESB_ENABLE_BOTH : ESB_DISABLE_BOTH);
+ if (hasVScroll)
+ EnableScrollBar (window,SB_VERT,toAble ? ESB_ENABLE_BOTH : ESB_DISABLE_BOTH);
+#endif
+ printf("EvalCcRqSETSELECTWINDOW -> not implemented\n");
+ MakeReturn0Cci (pcci);
+}
+
+/* Set the position of windows/controls. */
+void EvalCcRqSETWINDOWPOS (CrossCallInfo *pcci) /* hwnd, x,y, update, include scrollbars ; no result. */
+{
+ GtkWidget *widget, *parent;
+ int x,y;
+ gboolean update,inclScrollbars;
+
+ printf("EvalCcRqSETWINDOWPOS\n");
+ widget = GTK_WIDGET(pcci->p1);
+ x = pcci->p2;
+ y = pcci->p3;
+ update = pcci->p4;
+ inclScrollbars = pcci->p5;
+ parent = gtk_widget_get_parent(widget);
+
+ if (parent)
+ {
+ gtk_fixed_move(GTK_FIXED(parent), widget, x, y);
+ } else {
+ gtk_widget_set_uposition(widget, x, y);
+ }
+
+ if (GTK_WIDGET_VISIBLE(widget) && update!=0)
+ { // only if window is visible and update is requested, proceed to enforce update.
+ if (inclScrollbars)
+ {
+ }
+ else
+ {
+ gtk_widget_queue_draw(widget);
+ }
+ }
+
+ MakeReturn0Cci (pcci);
+}
+
+/* Get the size of the bounding rectangle of windows/controls. */
+void EvalCcRqGETWINDOWSIZE (CrossCallInfo *pcci) /* hwnd; width,height result. */
+{
+ GtkAllocation *alloc;
+ printf("EvalCcRqGETWINDOWSIZE\n");
+ alloc = &((GTK_WIDGET(pcci->p1))->allocation);
+ MakeReturn2Cci (pcci, alloc->width, alloc->height);
+}
+
+/* Set the size of windows/controls. */
+void EvalCcRqSETWINDOWSIZE (CrossCallInfo *pcci) /* hwnd, w,h, update; no result. */
+{
+ GtkWindow *window;
+ gint width, height;
+ gboolean update,inclScrollbars;
+
+ /* printf("EvalCcRqSETWINDOWSIZE\n"); */
+ window = GTK_WINDOW(pcci->p1);
+ width = pcci->p2;
+ height = pcci->p3;
+ update = pcci->p4;
+ gtk_window_resize(window, width, height);
+#if 0
+ if (update!=0) /* still, updates are not sufficient using SetWindowPos only. */
+ UpdateWindowScrollbars (hwnd);
+#endif
+ MakeReturn0Cci (pcci);
+}
+
+/* Activate control. */
+void EvalCcRqACTIVATECONTROL (CrossCallInfo *pcci) /* controlPtr; no result. */
+{
+ printf("EvalCcRqACTIVATERCONTROL\n");
+ gtk_widget_grab_focus(GTK_WIDGET(pcci->p1));
+ MakeReturn0Cci (pcci);
+}
+
+/* Activate window. */
+void EvalCcRqACTIVATEWINDOW (CrossCallInfo *pcci) /* isMDI, clientPtr, thisWindow; no result. */
+{
+ gboolean isMDI;
+ GtkWidget *client, *thisWindow;
+
+ printf("EvalCcRqACTIVATEWINDOW\n");
+ isMDI = (gboolean) pcci->p1;
+ client = GTK_WIDGET(pcci->p2);
+ thisWindow = GTK_WIDGET(pcci->p3);
+
+ if (isMDI)
+ {
+ gtk_notebook_set_page(GTK_NOTEBOOK(client), gtk_notebook_page_num(GTK_NOTEBOOK(client), thisWindow));
+ }
+ else
+ {
+ gtk_window_activate_focus (GTK_WINDOW(thisWindow));
+ }
+
+ MakeReturn0Cci (pcci);
+}
+
+static unsigned char hidden_cursor_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static GdkColor black_color = { 0, 0, 0, 0 };
+
+void EvalCcRqCHANGEWINDOWCURSOR (CrossCallInfo *pcci) /* hwnd, cursor code; no result. It is assumed that the hwnd argument */
+ /* corresponds to either a SDI/MDI window (and not frame). */
+{
+ GtkWidget *widget;
+ int cursorcode;
+
+ printf("EvalCcRqCHANGEWINDOWCURSOR\n");
+ widget = GTK_BIN(GTK_BIN(GTK_WIDGET(pcci->p1))->child)->child;
+ cursorcode = pcci->p2;
+
+ switch (cursorcode)
+ {
+ case CURSARROW:
+ if (!gArrowCursor)
+ {
+ gArrowCursor = gdk_cursor_new(GDK_ARROW);
+ };
+
+ gdk_window_set_cursor(widget->window, gArrowCursor);
+ break;
+ case CURSBUSY:
+ if (!gBusyCursor)
+ {
+ gBusyCursor = gdk_cursor_new(GDK_CLOCK);
+ };
+
+ gdk_window_set_cursor(widget->window, gBusyCursor);
+ break;
+ case CURSIBEAM:
+ if (!gIBeamCursor)
+ {
+ gIBeamCursor = gdk_cursor_new(GDK_XTERM);
+ };
+
+ gdk_window_set_cursor(widget->window, gIBeamCursor);
+ break;
+ case CURSCROSS:
+ if (!gCrossCursor)
+ {
+ gCrossCursor = gdk_cursor_new(GDK_CROSSHAIR);
+ };
+
+ gdk_window_set_cursor(widget->window, gCrossCursor);
+ break;
+ case CURSFATCROSS:
+ if (!gFatCrossCursor)
+ {
+ gFatCrossCursor = gdk_cursor_new(GDK_CROSS);
+ };
+
+ gdk_window_set_cursor(widget->window, gFatCrossCursor);
+ break;
+ case CURSHIDDEN:
+ if (!gHiddenCursor)
+ {
+ GdkPixmap *pixmap;
+
+ pixmap = gdk_bitmap_create_from_data (NULL, hidden_cursor_bits, 16, 16);
+ gHiddenCursor = gdk_cursor_new_from_pixmap (pixmap, pixmap, &black_color, &black_color, 8, 8);
+ gdk_pixmap_unref (pixmap);
+ };
+
+ gdk_window_set_cursor(widget->window, gHiddenCursor);
+ break;
+ }
+
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqOBSCURECURSOR (CrossCallInfo *pcci) /* no params; no result. */
+{
+ GtkWidget *widget;
+
+ printf("EvalCcRqOBSCURECURSOR\n");
+ widget = GTK_WIDGET(pcci->p1);
+
+ if (!gHiddenCursor)
+ {
+ GdkPixmap *pixmap;
+
+ pixmap = gdk_bitmap_create_from_data (NULL, hidden_cursor_bits, 16, 16);
+ gHiddenCursor = gdk_cursor_new_from_pixmap (pixmap, pixmap, &black_color, &black_color, 8, 8);
+ gdk_pixmap_unref (pixmap);
+ };
+
+ gdk_window_set_cursor(widget->window, gHiddenCursor);
+ MakeReturn0Cci (pcci);
+}
+
+void DeleteCursors()
+{
+ printf("DeleteCursors\n");
+ if (gArrowCursor)
+ {
+ gdk_cursor_destroy(gArrowCursor);
+ gArrowCursor = NULL;
+ }
+
+ if (gBusyCursor)
+ {
+ gdk_cursor_destroy(gBusyCursor);
+ gIBeamCursor = NULL;
+ }
+
+ if (gIBeamCursor)
+ {
+ gdk_cursor_destroy(gIBeamCursor);
+ gIBeamCursor = NULL;
+ }
+
+ if (gCrossCursor)
+ {
+ gdk_cursor_destroy(gCrossCursor);
+ gCrossCursor = NULL;
+ }
+
+ if (gFatCrossCursor)
+ {
+ gdk_cursor_destroy(gFatCrossCursor);
+ gFatCrossCursor = NULL;
+ }
+
+ if (gHiddenCursor)
+ {
+ gdk_cursor_destroy(gHiddenCursor);
+ gHiddenCursor = NULL;
+ }
+}
+
+/* Set range of scrollbars. */
+void EvalCcRqSETSCROLLRANGE (CrossCallInfo *pcci) /* hwnd, iBar, min, max, redraw, no result */
+{
+ GtkWidget *widget, *parent;
+ GtkAdjustment *adj;
+ GtkRequisition *requisition;
+ gint iBar, min, max;
+ gboolean redraw;
+
+ printf("EvalCcRqSETSCROLLRANGE\n");
+ widget = GTK_WIDGET(pcci->p1);
+ iBar = pcci->p2;
+ min = pcci->p3;
+ max = pcci->p4;
+ redraw = pcci->p5;
+
+ parent = GTK_SCROLLED_WINDOW(
+ gtk_widget_get_ancestor(widget, GTK_TYPE_SCROLLED_WINDOW));
+
+ if (GTK_IS_SCROLLED_WINDOW(widget))
+ {
+ if (GTK_IS_SCROLLED_WINDOW(parent))
+ {
+ /* If a parent exists, it has to hold a requisition object to
+ * represent the size of this scrollbar. Otherwise the layout
+ * manager can't figure out the right size to make things.
+ */
+ requisition = (GtkRequisition *)g_object_get_data(G_OBJECT(parent),
+ SCROLL_SIZE_KEY);
+
+ if (iBar == 0) /* Horizontal */
+ {
+ requisition->width = max-min;
+ adj = gtk_scrolled_window_get_hadjustment(
+ GTK_SCROLLED_WINDOW(widget));
+ } else { /* Vertical */
+ requisition->height = max-min;
+ adj = gtk_scrolled_window_get_vadjustment(
+ GTK_SCROLLED_WINDOW(widget));
+ }
+ printf("client_size_request(%d,%d)\n", requisition->width,
+ requisition->height);
+ } else {
+ /* This widget has no parent, so no requisition is available
+ * (or needed).
+ */
+ if (iBar == 0) /* Horizontal */
+ {
+ adj = gtk_scrolled_window_get_hadjustment(
+ GTK_SCROLLED_WINDOW(widget));
+ } else { /* Vertical */
+ adj = gtk_scrolled_window_get_vadjustment(
+ GTK_SCROLLED_WINDOW(widget));
+ }
+ }
+ } else {
+ adj = gtk_range_get_adjustment(GTK_RANGE(widget));
+ }
+
+ if (adj)
+ {
+ adj->lower = min;
+ adj->upper = max;
+ adj->step_increment = 1;
+ adj->page_increment = (int)((max - min) / 10);
+ gtk_adjustment_changed(adj);
+ } else {
+ printf("No adjustment to change.\n");
+ }
+
+ MakeReturn0Cci (pcci);
+}
+
+/* Set pos of scrollbars. */
+void EvalCcRqSETSCROLLPOS (CrossCallInfo *pcci) /* hwnd, iBar, thumb, maxx, maxy, extent, no result */
+{
+ GtkWidget *widget;
+ GtkAdjustment *adj;
+ gint thumb, iBar, maxx, maxy, extent;
+
+ widget = GTK_WIDGET(pcci->p1);
+ iBar = pcci->p2;
+ thumb = pcci->p3;
+ maxx = pcci->p4; // maxx is the right-most x coordinate of the enclosing rectangle of the scrollbar
+ maxy = pcci->p5; // maxy is the bottom-most y coordinate of the enclosing rectangle of the scrollbar
+ extent = pcci->p6; // extent is the width (height) of the vertical (horizontal) scrollbar
+
+ printf("EvalCcRqSETSCROLLPOS: %d\n", thumb);
+ if (GTK_IS_SCROLLED_WINDOW(widget))
+ {
+ if (iBar == 0) /* Horizontal */
+ {
+ adj = gtk_scrolled_window_get_hadjustment(
+ GTK_SCROLLED_WINDOW(widget));
+ } else { /* Vertical */
+ adj = gtk_scrolled_window_get_vadjustment(
+ GTK_SCROLLED_WINDOW(widget));
+ }
+ } else {
+ adj = gtk_range_get_adjustment(GTK_RANGE(widget));
+ }
+
+ gtk_adjustment_set_value(adj, (gdouble)thumb);
+ gtk_adjustment_value_changed(adj);
+
+ MakeReturn0Cci (pcci);
+}
+
+/* Set thumb size of scrollbars. */
+void EvalCcRqSETSCROLLSIZE (CrossCallInfo *pcci) /* hwnd, iBar, size, maxx, maxy, extent, no result */
+{
+ GtkWidget *widget, *parent;
+ GtkAdjustment *adj;
+ int size, iBar, maxx, maxy, extent;
+
+ printf("EvalCcRqSETSCROLLSIZE\n");
+ widget = GTK_WIDGET(pcci->p1);
+ iBar = pcci->p2;
+ size = pcci->p3;
+ maxx = pcci->p4; // maxx is the right-most x coordinate of the enclosing rectangle of the scrollbar
+ maxy = pcci->p5; // maxy is the bottom-most y coordinate of the enclosing rectangle of the scrollbar
+ extent = pcci->p6; // extent is the width (height) of the vertical (horizontal) scrollbar
+
+ if (GTK_IS_SCROLLED_WINDOW(widget))
+ {
+ if (iBar == 0) /* Horizontal */
+ {
+ adj = gtk_scrolled_window_get_hadjustment(
+ GTK_SCROLLED_WINDOW(widget));
+ } else { /* Vertical */
+ adj = gtk_scrolled_window_get_vadjustment(
+ GTK_SCROLLED_WINDOW(widget));
+ }
+ } else {
+ adj = gtk_range_get_adjustment(GTK_RANGE(widget));
+ }
+
+ adj->page_size = size;
+ gtk_adjustment_changed(adj);
+
+ MakeReturn0Cci (pcci);
+}
+
+/* Set selection of edit controls. */
+void EvalCcRqSETEDITSELECTION (CrossCallInfo *pcci) /* hwnd, first, last, no result. */
+{
+/* HWND hwnd;
+ int first,last;
+
+ hwnd = (HWND) pcci->p1;
+ first = pcci->p2;
+ last = pcci->p3;
+
+ SendMessage (hwnd, EM_SETSEL, (WPARAM) first, (LPARAM) last); // Set the selection of the edit control.
+ SendMessage (hwnd, EM_SCROLLCARET, 0,0); // Let the caret be displayed - (w/l)Param MUST be 0.
+*/
+ printf("EvalCcRqSETEDITSELECTION -> not implemented\n");
+ MakeReturn0Cci (pcci);
+}
+
+static void dialog_focus_in_handler(GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
+{
+ printf("dialog_focus_in_handler\n");
+ SendMessage1ToClean (CcWmACTIVATE, widget);
+ GTK_WIDGET_GET_CLASS(widget)->focus_in_event(widget, event);
+ gActiveTopLevelWindow = widget;
+}
+
+static void dialog_focus_out_handler(GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
+{
+ printf("dialog_focus_out_handler\n");
+ SendMessage1ToClean (CcWmDEACTIVATE, widget);
+ GTK_WIDGET_GET_CLASS(widget)->focus_out_event(widget, event);
+ gActiveTopLevelWindow = NULL;
+}
+
+static gboolean dialog_close_handler(GtkWidget *dialog, GdkEvent *event, gpointer user_data)
+{
+ printf("dialog_close_handler\n");
+ SendMessage1ToClean(CcWmCLOSE, (int) dialog);
+ gtk_signal_emit_stop_by_name(GTK_OBJECT(dialog), "delete-event");
+ return gtk_true();
+}
+
+/* EvalCcRqCREATEDIALOG is now restricted to modeless dialogues only. */
+void EvalCcRqCREATEDIALOG (CrossCallInfo *pcci) // textptr,parentptr,behindPtr; HWND result.
+{
+ GtkWidget *dialog, *fixed, *defctrl;
+ const gchar *pwintitle;
+ gint x, y, w, h;
+
+ printf("EvalCcRqCREATEDIALOG\n");
+ pwintitle = (const gchar *) pcci->p1;
+
+ dialog = gtk_dialog_new();
+ gtk_dialog_set_has_separator(GTK_DIALOG(dialog), gtk_false());
+ gtk_window_set_resizable(GTK_WINDOW(dialog), gtk_false());
+ gtk_signal_connect (GTK_OBJECT(dialog), "delete-event",
+ GTK_SIGNAL_FUNC(dialog_close_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(dialog), "focus-in-event",
+ GTK_SIGNAL_FUNC(dialog_focus_in_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(dialog), "focus-out-event",
+ GTK_SIGNAL_FUNC(dialog_focus_out_handler),
+ NULL);
+
+ if (pwintitle)
+ {
+ gtk_window_set_title(GTK_WINDOW(dialog), pwintitle);
+ }
+
+ /* Create a Fixed Container */
+ fixed = gtk_fixed_new();
+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), fixed, TRUE, TRUE, 0);
+ gtk_widget_show(fixed);
+
+ SendMessage1ToClean (CcWmINITDIALOG, (int) dialog);
+
+ x = gCci.p1;
+ y = gCci.p2;
+ w = gCci.p3;
+ h = gCci.p4;
+ defctrl = GTK_WIDGET(gCci.p5);
+
+ w += GTK_WINDOW(dialog)->frame_left + GTK_WINDOW(dialog)->frame_right;
+ h += GTK_WINDOW(dialog)->frame_top + GTK_WINDOW(dialog)->frame_bottom;
+
+ /* Adjust the pos and size of the frame window. */
+ gtk_widget_set_size_request(dialog, w, h);
+ if (x == -1 && y == -1)
+ {
+ gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+ }
+ else
+ {
+ gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_NONE);
+ gtk_widget_set_uposition(dialog, x, y);
+ }
+
+ if (defctrl != NULL)
+ {
+ printf("EvalCcRqCREATEDIALOG -- grab focus call\n");
+ gtk_widget_grab_focus(defctrl);
+ }
+
+ gtk_widget_show(dialog);
+
+ printf("Dialog width: %d\n", w);
+
+ MakeReturn1Cci (pcci, (int) dialog);
+}
+
+// Create modal dialogues.
+void EvalCcRqCREATEMODALDIALOG (CrossCallInfo *pcci) /* textptr,parentptr; error code result. */
+{
+ GtkWidget *dialog, *fixed, *defctrl, *parent;
+ const gchar *pwintitle;
+ gint x, y, w, h;
+ guint delete_handler;
+
+ printf("EvalCcRqCREATEMODALDIALOG\n");
+ pwintitle = (const gchar *) pcci->p1;
+ parent = GTK_WIDGET(pcci->p2);
+
+ dialog = gtk_dialog_new();
+ gtk_dialog_set_has_separator(GTK_DIALOG(dialog), gtk_false());
+ gtk_window_set_resizable(GTK_WINDOW(dialog), gtk_false());
+ gtk_signal_connect (GTK_OBJECT(dialog), "focus-in-event",
+ GTK_SIGNAL_FUNC(dialog_focus_in_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(dialog), "focus-out-event",
+ GTK_SIGNAL_FUNC(dialog_focus_out_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(dialog), "delete-event",
+ GTK_SIGNAL_FUNC(dialog_close_handler),
+ NULL);
+
+ if (pwintitle)
+ {
+ gtk_window_set_title(GTK_WINDOW(dialog), pwintitle);
+ }
+
+ /* Create a Fixed Container */
+ fixed = gtk_fixed_new();
+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), fixed, TRUE, TRUE, 0);
+ gtk_widget_show(fixed);
+
+ SendMessage1ToClean (CcWmINITDIALOG, (int) dialog);
+
+ x = gCci.p1;
+ y = gCci.p2;
+ w = gCci.p3;
+ h = gCci.p4;
+ defctrl = GTK_WIDGET(gCci.p5);
+
+ w += GTK_WINDOW(dialog)->frame_left + GTK_WINDOW(dialog)->frame_right;
+ h += GTK_WINDOW(dialog)->frame_top + GTK_WINDOW(dialog)->frame_bottom;
+
+ /* Adjust the pos and size of the frame window. */
+ gtk_widget_set_size_request(dialog, w, h);
+ if (x == -1 && y == -1)
+ {
+ gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
+ }
+ else
+ {
+ gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_NONE);
+ gtk_widget_set_uposition(dialog, x, y);
+ }
+
+ if (defctrl != NULL)
+ {
+ printf("EvalCcRqCREATEMODALDIALOG -- grab focus call\n");
+ gtk_widget_grab_focus(defctrl);
+ }
+
+ while (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_DELETE_EVENT);
+ gtk_widget_destroy(dialog);
+
+ MakeReturn1Cci (pcci,0/*errorcode*/);
+}
+
+static gboolean widget_focus_in_handler(GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
+{
+ GtkWidget *my_widget;
+ printf("widget_focus_in_handler\n");
+ my_widget = GTK_WIDGET(user_data);
+ GTK_WIDGET_GET_CLASS(widget)->focus_in_event(widget, event);
+ SendMessage2ToClean (CcWmSETFOCUS, GetControlParent(my_widget), my_widget);
+ return gtk_true();
+}
+
+static gboolean widget_focus_out_handler(GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
+{
+ GtkWidget *my_widget, *parent;
+ printf("widget_focus_out_handler\n");
+
+ my_widget = GTK_WIDGET(user_data);
+ parent = GetControlParent(my_widget);
+ GTK_WIDGET_GET_CLASS(widget)->focus_in_event(widget, event);
+
+ if (gInKey)
+ {
+ SendKeyUpToClean (parent, my_widget, gCurChar);
+ gInKey = FALSE;
+ gCurChar = 0;
+ }
+
+ SendMessage2ToClean (CcWmKILLFOCUS, parent, my_widget);
+ return gtk_true();
+}
+
+static gboolean widget_key_press_handler(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+{
+ GtkWidget *my_widget, *parent;
+ gint c;
+ printf("widget_key_press_handler\n");
+
+ my_widget = GTK_WIDGET(user_data);
+ parent = GetControlParent(my_widget);
+ c = (event->length > 0) ?
+ event->string[0] : CheckVirtualKeyCode (event->keyval);
+
+ if (!c)
+ {
+ return gtk_false();
+ }
+
+ if (event->keyval == GDK_Tab)
+ {
+ return gtk_false();
+ }
+
+ GTK_WIDGET_GET_CLASS(widget)->key_press_event(widget, event);
+
+ if (gInKey)
+ {
+ if (gCurChar == c)
+ {
+ SendKeyStillDownToClean (parent, my_widget, gCurChar);
+ }
+ else
+ {
+ SendKeyUpToClean (parent, my_widget, gCurChar);
+ gCurChar = c;
+ SendKeyDownToClean (parent, my_widget, gCurChar);
+ }
+ }
+ else
+ {
+ gCurChar = c;
+ SendKeyDownToClean (parent, my_widget, gCurChar);
+ gInKey = TRUE;
+ }
+
+ return gtk_true();
+}
+
+static gboolean widget_key_release_handler(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+{
+ GtkWidget *my_widget;
+ printf("widget_key_release_handler\n");
+
+ my_widget = GTK_WIDGET(user_data);
+
+ if (event->keyval == GDK_Tab)
+ {
+ return gtk_false();
+ }
+
+ GTK_WIDGET_GET_CLASS(widget)->key_press_event(widget, event);
+
+ if (gInKey)
+ {
+ SendKeyUpToClean (GetControlParent(my_widget), my_widget, gCurChar);
+ gInKey = FALSE;
+ gCurChar = 0;
+ }
+
+ return gtk_true();
+}
+
+static gboolean widget_button_press_handler(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
+{
+ printf("widget_button_press_handler\n");
+ if (event->button == 1)
+ {
+ GtkWidget *parent = GetControlParent(widget);
+
+ printf("Widget_button_press_handler -- grab focus call\n");
+ gtk_widget_grab_focus(widget);
+
+ gInMouseDown = TRUE;
+
+ switch (event->type)
+ {
+ case GDK_BUTTON_PRESS:
+ SendMessage6ToClean (CcWmMOUSE, parent, widget, BUTTONDOWN, event->x, event->y, GetModifiers());
+ break;
+ case GDK_2BUTTON_PRESS:
+ SendMessage6ToClean (CcWmMOUSE, parent, widget, BUTTONDOUBLEDOWN, event->x, event->y, GetModifiers());
+ break;
+ case GDK_3BUTTON_PRESS:
+ SendMessage6ToClean (CcWmMOUSE, parent, widget, BUTTONTRIPLEDOWN, event->x, event->y, GetModifiers());
+ break;
+ }
+ return gtk_true();
+ }
+ return gtk_false();
+}
+
+static gboolean widget_button_release_handler(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
+{
+ printf("widget_button_release_handler\n");
+ if (event->button == 1)
+ {
+ GtkWidget *parent = GetControlParent(widget);
+
+ gInMouseDown = FALSE;
+ SendMessage6ToClean (CcWmMOUSE, parent, widget, BUTTONUP, event->x, event->y, GetModifiers());
+ return gtk_true();
+ }
+
+ return gtk_false();
+}
+
+static gboolean widget_motion_notify_handler(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
+{
+ GtkWidget *parent;
+ printf("widget_motion_notify_handler\n");
+
+ parent = GetControlParent(widget);
+
+ if (gInMouseDown)
+ {
+ SendMessage6ToClean(CcWmMOUSE, parent, widget, BUTTONSTILLDOWN, event->x, event->y, GetModifiers());
+ } else {
+ SendMessage6ToClean (CcWmMOUSE, parent, widget, BUTTONSTILLUP, event->x, event->y, GetModifiers());
+ }
+
+ return gtk_true();
+}
+
+/* Create compound controls (window in window) */
+void EvalCcRqCREATECOMPOUND (CrossCallInfo *pcci) /* hwnd, packed pos,w,h, scrollbars, transparent; HWND result. */
+{
+#if 0
+ HWND parentwindow, compoundhandle;
+ int left,top, width,height;
+ int compoundstyle;
+ BOOL transparent;
+ DWORD compoundExStyle;
+
+ parentwindow = (HWND) pcci->p1;
+ left = pcci->p2>>16;
+ top = (pcci->p2<<16)>>16;
+ width = pcci->p3;
+ height = pcci->p4;
+ compoundstyle = pcci->p5;
+ transparent = (BOOL) pcci->p6;
+
+ compoundExStyle = WS_EX_CONTROLPARENT;
+ if (transparent)
+ compoundExStyle |= WS_EX_TRANSPARENT;
+
+ compoundstyle |= WS_CHILD;// | WS_CLIPSIBLINGS;
+
+ /* create the compound window */
+ compoundhandle
+ = CreateWindowEx (compoundExStyle, /* Extended style */
+ CompoundControlClassName, /* Class name */
+ "", /* Window title */
+ compoundstyle, /* style flags */
+ left, top, /* x, y */
+ width, height, /* width, height */
+ parentwindow, /* Parent window */
+ NULL, /* menu handle */
+ (HANDLE) ghInst, /* Instance that owns the window */
+ 0);
+ SetWindowPos (compoundhandle, HWND_BOTTOM, 0,0,0,0, SWP_NOMOVE+SWP_NOSIZE); // This should implement control stack
+#endif
+ printf("EvalCcRqCREATECOMPOUND -> not implemented\n");
+ MakeReturn1Cci (pcci, (int) NULL /*compoundhandle*/);
+}
+
+static void scrollbar_value_changed(GtkRange *range, gpointer user_data)
+{
+ gint scrollCode, controlKind, discr, position, *val;
+ GdkWindow *parent_window;
+ GtkWidget *parent, *widget;
+ GtkAdjustment *adjustment;
+ /* printf("scrollbar_value_changed\n"); */
+
+ parent_window = gtk_widget_get_parent_window(GTK_WIDGET(range));
+ parent = gtk_widget_get_parent(GTK_WIDGET(range));
+ adjustment = gtk_range_get_adjustment(range);
+ position = (gint)gtk_adjustment_get_value(adjustment);
+ val = g_object_get_data(G_OBJECT(range), SCROLL_POS_KEY);
+
+ /* printf("Value: %d -- Old Value: %d\n", (int)position, (int) *val); */
+
+ discr = position - *val;
+ /* printf("discr = %d", (int) discr); */
+
+
+ /*
+ * GTK Handles a lot of the scrollbar plumbing internally. We have to fool the ObjectIO
+ * event loop a bit here. So, we just report a "SB_THUMBPOSITION" message, so it runs around
+ * notifying changes, but does not try to modify the scrollbar itself.
+ */
+ scrollCode = SB_THUMBPOSITION;
+
+ /*
+ * If there is a parent, this is a slider (not a scrollbar)
+ */
+ if (GTK_IS_SCROLLED_WINDOW(parent_window))
+ {
+ /* printf("Not a slider.\n"); */
+ controlKind = (GTK_IS_HSCROLLBAR(range) ?
+ GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
+ widget = GTK_WIDGET(parent_window);
+ parent = GTK_WIDGET(parent_window);
+ } else {
+ /* printf("Hey -- it's a slider!\n"); */
+ controlKind = SB_CTL;
+ widget = GTK_WIDGET(range);
+ parent = GetControlParent(widget);
+ }
+
+ *val = position;
+ g_object_set_data(G_OBJECT(range), SCROLL_POS_KEY, (gpointer)val);
+
+ /*
+ * Force redraw of changed widget, but only during times when the
+ * scrollbar was moved by the user.
+ */
+ if (discr != 0) {
+ SendMessage5ToClean(CcWmSCROLLBARACTION, parent, (int)widget,
+ controlKind, scrollCode, position);
+ }
+
+ gtk_widget_queue_draw(widget);
+}
+
+/* Create scrollbars. */
+void EvalCcRqCREATESCROLLBAR (CrossCallInfo *pcci) /* hwnd, x,y,w,h bool; HWND result. */
+{
+ gint x, y, w, h;
+ gint *val;
+ GtkWidget *scroll;
+ GtkWidget *parent;
+ gboolean ishorizontal;
+
+ /* printf("EvalCcRqCREATESCROLLBAR\n"); */
+ if (pcci->p1 == 0)
+ {
+ MakeReturn0Cci (pcci);
+ }
+
+ parent = GTK_WIDGET(pcci->p1);
+ x = pcci->p2;
+ y = pcci->p3;
+ w = pcci->p4;
+ h = pcci->p5;
+ ishorizontal = pcci->p6;
+
+ if (ishorizontal)
+ {
+ scroll = gtk_hscrollbar_new(NULL);
+ } else {
+ scroll = gtk_vscrollbar_new(NULL);
+ }
+
+ g_signal_connect(GTK_OBJECT(scroll), SCROLL_VALUE_CHANGED, G_CALLBACK(scrollbar_value_changed), parent);/*NULL);*/
+ val = g_new(gint,1);
+ gtk_widget_set_size_request(scroll, w, h);
+ gtk_fixed_put(GetFixed(parent), scroll, x, y);
+ *val = 0;
+ g_object_set_data(G_OBJECT(scroll), SCROLL_POS_KEY, (gpointer)val);
+
+ printf("EvalCcRqCREATESCROLLBAR - %p,%p\n",parent,scroll);
+ MakeReturn1Cci (pcci, (int) scroll);
+}
+
+static void button_clicked (GtkButton *button, gpointer user_data)
+{
+ GtkWidget *wbutton, *window;
+ printf("button_clicked\n");
+
+ wbutton = GTK_WIDGET(button);
+ window = GetControlParent(wbutton);
+
+ switch (GPOINTER_TO_INT(user_data))
+ {
+ case ISOKBUTTON:
+ SendMessage2ToClean (CcWmSPECIALBUTTON, window, ISOKBUTTON);
+ return;
+ case ISCANCELBUTTON:
+ SendMessage2ToClean (CcWmSPECIALBUTTON, window, ISCANCELBUTTON);
+ return;
+ default:
+ SendMessage4ToClean (CcWmBUTTONCLICKED, window, wbutton, GetModifiers (), 0);
+ return;
+ }
+}
+
+static gint button_expose_handler(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
+{
+ GtkWidget *button, *parent;
+ printf("button_expose_handler\n");
+
+ button = gtk_widget_get_parent(widget);
+ parent = gtk_widget_get_parent(gtk_widget_get_parent(gtk_widget_get_parent(button)));
+ SendMessage3ToClean(CcWmDRAWCONTROL, (int) parent, (int) button, (int) GDK_DRAWABLE(event->window));
+ return 0;
+}
+
+void EvalCcRqCREATEBUTTON (CrossCallInfo *pcci) /* hwnd, x,y,w,h, kind; HWND result. */
+{
+ GtkWidget *button, *parent;
+ GtkRequisition asked;
+ gint x, y, w, h, kind;
+
+ printf("EvalCcRqCREATEBUTTON\n");
+ parent = GTK_WIDGET(pcci->p1);
+ x = pcci->p2;
+ y = pcci->p3;
+ w = pcci->p4;
+ h = pcci->p5;
+ kind = pcci->p6;
+
+ if (kind==ISOKBUTTON)
+ {
+ button = gtk_button_new_from_stock("gtk-ok");
+ }
+ else
+ {
+ if (kind==ISCANCELBUTTON)
+ {
+ button = gtk_button_new_from_stock("gtk-quit");
+ }
+ else
+ {
+ button = gtk_button_new();
+ gtk_button_set_use_underline(GTK_BUTTON(button), gtk_true());
+ }
+ }
+
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC(button_clicked),
+ GINT_TO_POINTER(kind));
+ gtk_widget_set_size_request(button, w, h);
+ gtk_fixed_put (GetFixed(parent), button, x, y);
+
+ MakeReturn1Cci (pcci, (int) button);
+}
+
+void EvalCcRqCREATEICONBUT (CrossCallInfo *pcci) /* hwnd, x,y,w,h,kind; HWND result. */
+{
+ GtkWidget *button, *parent, *drawing_area;
+ gint x, y, w, h, kind;
+
+ printf("EvalCcRqCREATEICONBUT\n");
+ parent = GTK_WIDGET(pcci->p1);
+ x = pcci->p2;
+ y = pcci->p3;
+ w = pcci->p4;
+ h = pcci->p5;
+ kind = pcci->p6;
+
+ button = gtk_button_new();
+ drawing_area = gtk_drawing_area_new();
+ gtk_container_add(GTK_CONTAINER(button), drawing_area);
+ gtk_signal_connect(GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC(button_clicked),
+ GINT_TO_POINTER(kind));
+ gtk_signal_connect (GTK_OBJECT(drawing_area), "expose-event",
+ GTK_SIGNAL_FUNC(button_expose_handler),
+ NULL);
+
+ gtk_widget_set_size_request(button, w, h);
+ gtk_fixed_put(GetFixed(parent), button, x, y);
+
+ MakeReturn1Cci(pcci, (int) button);
+}
+
+static gint custom_expose_handler(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
+{
+ GtkWidget *parent;
+ printf("custom_expose_handler\n");
+
+ parent = gtk_widget_get_parent(gtk_widget_get_parent(gtk_widget_get_parent(widget)));
+ SendMessage3ToClean(CcWmDRAWCONTROL, (int) parent, (int) widget, (int) GDK_DRAWABLE(event->window));
+ return 0;
+}
+
+void EvalCcRqCREATECUSTOM (CrossCallInfo *pcci) /* hwnd, x,y,w,h; HWND result. */
+{
+ GtkWidget *ctrl, *parent;
+ gint x, y, w, h;
+
+ printf("EvalCcRqCREATECUSTOM\n");
+ parent = GTK_WIDGET(pcci->p1);
+ x = pcci->p2;
+ y = pcci->p3;
+ w = pcci->p4;
+ h = pcci->p5;
+
+ ctrl = gtk_drawing_area_new();
+ GTK_WIDGET_SET_FLAGS(ctrl, GTK_CAN_FOCUS);
+ gtk_signal_connect(GTK_OBJECT(ctrl), "expose-event",
+ GTK_SIGNAL_FUNC(custom_expose_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(ctrl), "focus-in-event",
+ GTK_SIGNAL_FUNC(widget_focus_in_handler),
+ ctrl);
+ gtk_signal_connect (GTK_OBJECT(ctrl), "focus-out-event",
+ GTK_SIGNAL_FUNC(widget_focus_out_handler),
+ ctrl);
+ gtk_signal_connect (GTK_OBJECT(ctrl), "key-press-event",
+ GTK_SIGNAL_FUNC(widget_key_press_handler),
+ ctrl);
+ gtk_signal_connect (GTK_OBJECT(ctrl), "key-release-event",
+ GTK_SIGNAL_FUNC(widget_key_release_handler),
+ ctrl);
+ gtk_signal_connect (GTK_OBJECT(ctrl), "button-press-event",
+ GTK_SIGNAL_FUNC(widget_button_press_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(ctrl), "button-release-event",
+ GTK_SIGNAL_FUNC(widget_button_release_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(ctrl), "motion_notify_event",
+ GTK_SIGNAL_FUNC(widget_motion_notify_handler),
+ NULL);
+ gtk_widget_set_size_request(ctrl, w, h);
+ gtk_fixed_put (GetFixed(parent), ctrl, x, y);
+
+ gtk_widget_realize(ctrl);
+ gtk_widget_add_events(ctrl, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
+
+ MakeReturn1Cci (pcci, (int) ctrl);
+}
+
+void EvalCcRqCREATESTATICTXT (CrossCallInfo *pcci) /* hwnd, x,y,w,h; HWND result. */
+{
+ int x, y, w, h;
+ GtkWidget *parent, *label;
+
+ printf("EvalCcRqCREATESTATICTXT\n");
+ parent = GTK_WIDGET(pcci->p1);
+ x = pcci->p2;
+ y = pcci->p3;
+ w = pcci->p4;
+ h = pcci->p5;
+
+ printf("Width: %d\n", w);
+
+ label = gtk_label_new(NULL);
+ gtk_widget_set_size_request(label, w, h);
+ gtk_fixed_put (GetFixed(parent), label, x, y);
+
+ MakeReturn1Cci (pcci, (int) label);
+}
+
+void EvalCcRqCREATEEDITTXT (CrossCallInfo *pcci) /* hwnd, x,y,w,h, flags; HWND result. */
+{
+ GtkWidget *edit;
+ GtkWidget *parent;
+ int x, y, w, h, flags;
+
+ printf("EvalCcRqCREATEEDITTXT\n");
+ parent = GTK_WIDGET(pcci->p1);
+ x = pcci->p2;
+ y = pcci->p3;
+ w = pcci->p4;
+ h = pcci->p5;
+ flags = pcci->p6;
+
+ if (flags & EDITISMULTILINE)
+ edit = gtk_text_view_new();
+ else
+ edit = gtk_entry_new();
+
+ printf("Edit Control: %ld\n", edit);
+ printf("Dimensions: x=%d, y=%d, w=%d, h=%d\n", x, y, w, h);
+
+ gtk_widget_set_size_request(edit, w, h);
+ gtk_fixed_put (GetFixed(parent), edit, x, y);
+
+
+ gtk_signal_connect (GTK_OBJECT(edit), "focus-in-event",
+ GTK_SIGNAL_FUNC(widget_focus_in_handler),
+ edit);
+ gtk_signal_connect (GTK_OBJECT(edit), "focus-out-event",
+ GTK_SIGNAL_FUNC(widget_focus_out_handler),
+ edit);
+ if (flags & EDITISKEYSENSITIVE)
+ {
+ gtk_signal_connect (GTK_OBJECT(edit), "key-press-event",
+ GTK_SIGNAL_FUNC(widget_key_press_handler),
+ edit);
+ gtk_signal_connect (GTK_OBJECT(edit), "key-release-event",
+ GTK_SIGNAL_FUNC(widget_key_release_handler),
+ edit);
+ }
+
+ MakeReturn1Cci (pcci, (int) edit);
+}
+
+static void radio_button_clicked (GtkButton *button, gpointer user_data)
+{
+ GtkWidget *wbutton, *window;
+ printf("radio_button_clicked\n");
+
+ wbutton = GTK_WIDGET(button);
+ window = GetControlParent(wbutton);
+
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wbutton)))
+ SendMessage4ToClean (CcWmBUTTONCLICKED, window, wbutton, GetModifiers (), 0);
+
+}
+
+void EvalCcRqCREATERADIOBUT (CrossCallInfo *pcci) /* hwnd, x,y,w,h, isfirst; HWND result. */
+{
+ GtkWidget *radio_btn;
+ GtkWidget *parent;
+ int x, y, w, h, first;
+
+ printf("EvalCcRqCREATERADIOBUT\n");
+ parent = GTK_WIDGET(pcci->p1);
+ x = pcci->p2;
+ y = pcci->p3;
+ w = pcci->p4;
+ h = pcci->p5;
+ first = pcci->p6;
+
+ if (first || !gFirstRadioButton)
+ {
+ radio_btn = gtk_radio_button_new(NULL);
+ gFirstRadioButton = radio_btn;
+ }
+ else
+ {
+ radio_btn = gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(gFirstRadioButton));
+ }
+
+ gtk_button_set_use_underline(GTK_BUTTON(radio_btn), gtk_true());
+ gtk_widget_set_size_request(radio_btn, w, h);
+ gtk_fixed_put (GetFixed(parent), radio_btn, x, y);
+
+ gtk_signal_connect (GTK_OBJECT (radio_btn), "clicked",
+ GTK_SIGNAL_FUNC(radio_button_clicked),
+ NULL);
+
+ MakeReturn1Cci (pcci, (int) radio_btn);
+}
+
+void EvalCcRqCREATECHECKBOX (CrossCallInfo *pcci) /* hwnd, x,y,w,h, isfirst; HWND result. */
+{
+ GtkWidget *check_btn;
+ GtkWidget *parent;
+ int x, y, w, h, first;
+
+ printf("EvalCcRqCREATECHECKBOX\n");
+ parent = GTK_WIDGET(pcci->p1);
+ x = pcci->p2;
+ y = pcci->p3;
+ w = pcci->p4;
+ h = pcci->p5;
+ first = pcci->p6;
+
+
+ check_btn = gtk_check_button_new();
+ gtk_button_set_use_underline(GTK_BUTTON(check_btn), gtk_true());
+ gtk_widget_set_size_request(check_btn, w, h);
+ gtk_fixed_put (GetFixed(parent), check_btn, x, y);
+
+ gtk_signal_connect (GTK_OBJECT (check_btn), "toggled",
+ GTK_SIGNAL_FUNC(button_clicked),
+ NULL);
+
+ MakeReturn1Cci (pcci, (int) check_btn);
+}
+
+void EvalCcRqSETITEMCHECK (CrossCallInfo *pcci) /* hwnd, bool; no result. */
+{
+ GtkWidget *widget;
+ gboolean on;
+
+ printf("EvalCcRqSETITEMCHECK\n");
+ widget = GTK_WIDGET(pcci->p1);
+ on = (gboolean) pcci->p2;
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), on);
+
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqENABLECONTROL (CrossCallInfo *pcci) /* hwnd, bool; no result. */
+{
+ GtkWidget *widget;
+ gboolean newSelect;
+ printf("EvalCcRqENABLECONTROL\n");
+
+ widget = GTK_WIDGET(pcci->p1);
+ newSelect = (gboolean) pcci->p2;
+
+ gtk_widget_set_sensitive(widget, newSelect);
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqSHOWCONTROL (CrossCallInfo *pcci) // hwnd, bool; no result.
+{
+ GtkWidget *control;
+ gboolean show;
+
+ printf("EvalCcRqSHOWCONTROL\n");
+ control = GTK_WIDGET(pcci->p1);
+ printf("Control: %ld\n", control);
+
+ if (control)
+ {
+ show = (gboolean) pcci->p2;
+
+ if (!show)
+ gtk_widget_hide(control);
+ else
+ gtk_widget_show(control);
+ }
+
+ MakeReturn0Cci (pcci);
+}
+
+/* Hide/show windows. */
+void EvalCcRqSHOWWINDOW (CrossCallInfo *pcci) /* hwnd, show, activate; no result. */
+{
+ GtkWidget *window;
+ gboolean show, activate;
+
+ printf("EvalCcRqSHOWWINDOW\n");
+ window = GTK_WIDGET(pcci->p1);
+ show = (gboolean) pcci->p2;
+ activate = (gboolean) pcci->p3;
+
+ if (!show)
+ gtk_widget_hide(window);
+ else
+ gtk_widget_show(window);
+
+ if (activate)
+ gtk_window_activate_default(GTK_WINDOW(window));
+
+ MakeReturn0Cci (pcci);
+}
+
+static void combo_changed_handler(GtkWidget *entry, gpointer user_data)
+{
+ gint newsel = 0;
+ GtkWidget *combo;
+ GList *child;
+ printf("combo_changed_handler\n");
+
+ combo = GTK_WIDGET(user_data);
+ child = GTK_LIST(GTK_COMBO(combo)->list)->children;
+
+ while (child)
+ {
+ GtkWidget *item = GTK_WIDGET(child->data);
+ if (item->state == GTK_STATE_SELECTED)
+ {
+ SendMessage3ToClean (CcWmITEMSELECT, (int) GetControlParent(combo), (int) combo, newsel);
+ return;
+ }
+
+ child = child->next;
+ newsel++;
+ }
+}
+
+void EvalCcRqCREATEPOPUP (CrossCallInfo *pcci) /* hwnd, x,y,w,h,isEditable; HWND hwndPopUp,hwndEdit (if isEditable). */
+{
+ GtkWidget *combo;
+ GtkWidget *parent;
+ int x, y, w, h;
+ gboolean isEditable;
+
+ printf("EvalCcRqCREATEPOPUP\n");
+ parent = GTK_WIDGET(pcci->p1);
+ x = pcci->p2;
+ y = pcci->p3;
+ w = pcci->p4;
+ h = pcci->p5;
+ isEditable = (gboolean) pcci->p6;
+
+ combo = gtk_combo_new();
+ gtk_combo_set_use_arrows_always(GTK_COMBO(combo), gtk_true());
+ gtk_widget_set_size_request(combo, w, h);
+
+ gtk_fixed_put (GetFixed(parent), combo, x, y);
+
+ gtk_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "changed",
+ GTK_SIGNAL_FUNC(combo_changed_handler),
+ combo);
+
+ if (isEditable)
+ {
+ gtk_signal_connect (GTK_OBJECT (GTK_COMBO(combo)->entry), "focus-in-event",
+ GTK_SIGNAL_FUNC(widget_focus_in_handler),
+ combo);
+
+ gtk_signal_connect (GTK_OBJECT (GTK_COMBO(combo)->entry), "focus-out-event",
+ GTK_SIGNAL_FUNC(widget_focus_out_handler),
+ combo);
+
+ gtk_signal_connect (GTK_OBJECT (GTK_COMBO(combo)->entry), "key-press-event",
+ GTK_SIGNAL_FUNC(widget_key_press_handler),
+ combo);
+
+ gtk_signal_connect (GTK_OBJECT (GTK_COMBO(combo)->entry), "key-release-event",
+ GTK_SIGNAL_FUNC(widget_key_release_handler),
+ combo);
+ }
+ else
+ {
+ gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo)->entry), gtk_false());
+ }
+
+ MakeReturn2Cci (pcci, (int) combo, (int) GTK_COMBO(combo)->entry);
+}
+
+void EvalCcRqADDTOPOPUP (CrossCallInfo *pcci) /* hwnd, textptr, enabled, selected, index; Pos result. */
+{
+ gint pos;
+ GtkWidget *combo, *li;
+ gchar *text;
+ gboolean selected;
+
+ printf("EvalCcRqADDTOPOPUP\n");
+ combo = GTK_WIDGET(pcci->p1);
+ text = (gchar *) pcci->p2;
+ selected = (gboolean) pcci->p3;
+
+ li = gtk_list_item_new_with_label(text);
+ gtk_widget_show (li);
+ gtk_container_add(GTK_CONTAINER(GTK_COMBO(combo)->list), li);
+
+ pos = gtk_list_child_position(GTK_LIST(GTK_COMBO(combo)->list), li);
+
+ if (selected)
+ {
+ gtk_list_select_item(GTK_LIST(GTK_COMBO(combo)->list), pos);
+ }
+
+ MakeReturn1Cci (pcci, pos);
+}
+
+void EvalCcRqSELECTPOPUPITEM (CrossCallInfo *pcci) /* hwnd, pos; no result */
+{
+ GtkWidget *combo;
+ gint pos;
+
+ printf("EvalCcRqSELECTPOPUP\n");
+ combo = GTK_WIDGET(pcci->p1);
+ pos = pcci->p2;
+
+ gtk_list_select_item(GTK_LIST(GTK_COMBO(combo)->list), pos);
+
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqRESTACKWINDOW (CrossCallInfo *pcci) /* thewindow,behind; no result. */
+{
+/* HWND thePtr, behindPtr;
+ UINT uflags = SWP_NOMOVE + SWP_NOSIZE; // Do not change current size or location
+
+ thePtr = (HWND) pcci->p1;
+ behindPtr = (HWND) pcci->p2;
+
+ SetWindowPos (thePtr, behindPtr, 0, 0, 0, 0, uflags);
+*/
+ printf("EvalCcRqRESTACKWINDOW -> not implemented\n");
+ MakeReturn0Cci (pcci);
+}
+
+/* Add controls to tooltip area. */
+void EvalCcRqADDCONTROLTIP (CrossCallInfo *pcci) /* parentPtr, controlPtr, textPtr; no result. */
+{
+ GtkWidget *parent, *control;
+ gchar *text;
+ printf("EvalCcRqADDCONTROLTIP\n");
+
+ parent = GTK_WIDGET(pcci->p1);
+ control = GTK_WIDGET(pcci->p2);
+ text = (gchar *)pcci->p3;
+
+ gtk_tooltips_set_tip(GTK_TOOLTIPS(gTooltip), control, text, text);
+
+ MakeReturn0Cci (pcci);
+}
+
+/* Remove controls from tooltip area. */
+void EvalCcRqDELCONTROLTIP (CrossCallInfo *pcci) /* parentPtr, controlPtr; no result. */
+{
+ GtkWidget *parent, *control;
+ printf("EvalCcRqDELCONTROLTIP\n");
+
+ parent = GTK_WIDGET(pcci->p1);
+ control = GTK_WIDGET(pcci->p2);
+
+ gtk_tooltips_set_tip(GTK_TOOLTIPS(gTooltip), control, NULL, NULL);
+
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqCREATECARET(CrossCallInfo *pcci)
+{
+/*
+ HWND hWnd = (HWND) pcci->p1;
+ int nWidth = max(max(GetSystemMetrics(SM_CYBORDER), GetSystemMetrics(SM_CXBORDER)) * 2, pcci->p2);
+ int nHeight = pcci->p3;
+
+ ghCaretWnd = hWnd;
+ CreateCaret(hWnd, NULL, nWidth, nHeight);
+ ShowCaret(hWnd);
+*/
+ printf("EvalCcRqCREATECARET -> not implemented\n");
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqSETCARETPOS(CrossCallInfo *pcci)
+{
+// if (ghCaretWnd == (HWND) pcci->p1)
+// {
+// SetCaretPos(pcci->p2, pcci->p3);
+// };
+ printf("EvalCcRqSETCARETPOS -> not implemented\n");
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqDESTROYCARET(CrossCallInfo *pcci)
+{
+// HWND hWnd = (HWND) pcci->p1;
+//
+/// HideCaret(hWnd);
+// DestroyCaret();
+// ghCaretWnd = NULL;
+ printf("EvalCcRqDESTROYCARET -> not implemented\n");
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqSHOWCARET(CrossCallInfo *pcci)
+{
+// ShowCaret((HWND) pcci->p1);
+ printf("EvalCcRqSHOWCARET -> not implemented\n");
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqHIDECARET(CrossCallInfo *pcci)
+{
+// HideCaret((HWND) pcci->p1);
+ printf("EvalCcRqHIDECARET -> not implemented\n");
+ MakeReturn0Cci (pcci);
+}
+
+/* Install the cross call procedures in the gCrossCallProcedureTable of cCrossCall_121.
+*/
+OS InstallCrossCallWindows (OS ios)
+{
+ CrossCallProcedureTable newTable;
+
+ printf("InstallCrossCallWindows\n");
+ newTable = EmptyCrossCallProcedureTable ();
+ AddCrossCallEntry (newTable, CcRqBEGINPAINT, EvalCcRqBEGINPAINT);
+ AddCrossCallEntry (newTable, CcRqENDPAINT, EvalCcRqENDPAINT);
+ AddCrossCallEntry (newTable, CcRqFAKEPAINT, EvalCcRqFAKEPAINT);
+ AddCrossCallEntry (newTable, CcRqDESTROYMODALDIALOG, EvalCcRqDESTROYMODALDIALOG);
+ AddCrossCallEntry (newTable, CcRqDESTROYMDIDOCWINDOW, EvalCcRqDESTROYMDIDOCWINDOW);
+ AddCrossCallEntry (newTable, CcRqCREATESDIDOCWINDOW, EvalCcRqCREATESDIDOCWINDOW);
+ AddCrossCallEntry (newTable, CcRqCREATEMDIDOCWINDOW, EvalCcRqCREATEMDIDOCWINDOW);
+ AddCrossCallEntry (newTable, CcRqSETWINDOWTITLE, EvalCcRqSETWINDOWTITLE);
+ AddCrossCallEntry (newTable, CcRqGETWINDOWTEXT, EvalCcRqGETWINDOWTEXT);
+ AddCrossCallEntry (newTable, CcRqUPDATEWINDOWRECT, EvalCcRqUPDATEWINDOWRECT);
+ AddCrossCallEntry (newTable, CcRqSETCLIENTSIZE, EvalCcRqSETCLIENTSIZE);
+ AddCrossCallEntry (newTable, CcRqSETSELECTWINDOW, EvalCcRqSETSELECTWINDOW);
+ AddCrossCallEntry (newTable, CcRqSETWINDOWPOS, EvalCcRqSETWINDOWPOS);
+ AddCrossCallEntry (newTable, CcRqGETWINDOWSIZE, EvalCcRqGETWINDOWSIZE);
+ AddCrossCallEntry (newTable, CcRqSETWINDOWSIZE, EvalCcRqSETWINDOWSIZE);
+ AddCrossCallEntry (newTable, CcRqACTIVATECONTROL, EvalCcRqACTIVATECONTROL);
+ AddCrossCallEntry (newTable, CcRqACTIVATEWINDOW, EvalCcRqACTIVATEWINDOW);
+ AddCrossCallEntry (newTable, CcRqCHANGEWINDOWCURSOR, EvalCcRqCHANGEWINDOWCURSOR);
+ AddCrossCallEntry (newTable, CcRqOBSCURECURSOR, EvalCcRqOBSCURECURSOR);
+ AddCrossCallEntry (newTable, CcRqSETSCROLLRANGE, EvalCcRqSETSCROLLRANGE);
+ AddCrossCallEntry (newTable, CcRqSETSCROLLPOS, EvalCcRqSETSCROLLPOS);
+ AddCrossCallEntry (newTable, CcRqSETSCROLLSIZE, EvalCcRqSETSCROLLSIZE);
+ AddCrossCallEntry (newTable, CcRqSETEDITSELECTION, EvalCcRqSETEDITSELECTION);
+ AddCrossCallEntry (newTable, CcRqCREATEDIALOG, EvalCcRqCREATEDIALOG);
+ AddCrossCallEntry (newTable, CcRqCREATEMODALDIALOG, EvalCcRqCREATEMODALDIALOG);
+ AddCrossCallEntry (newTable, CcRqCREATECOMPOUND, EvalCcRqCREATECOMPOUND);
+ AddCrossCallEntry (newTable, CcRqCREATESCROLLBAR, EvalCcRqCREATESCROLLBAR);
+ AddCrossCallEntry (newTable, CcRqCREATEBUTTON, EvalCcRqCREATEBUTTON);
+ AddCrossCallEntry (newTable, CcRqCREATEICONBUT, EvalCcRqCREATEICONBUT);
+ AddCrossCallEntry (newTable, CcRqCREATECUSTOM, EvalCcRqCREATECUSTOM);
+ AddCrossCallEntry (newTable, CcRqCREATESTATICTXT, EvalCcRqCREATESTATICTXT);
+ AddCrossCallEntry (newTable, CcRqCREATEEDITTXT, EvalCcRqCREATEEDITTXT);
+ AddCrossCallEntry (newTable, CcRqCREATERADIOBUT, EvalCcRqCREATERADIOBUT);
+ AddCrossCallEntry (newTable, CcRqCREATECHECKBOX, EvalCcRqCREATECHECKBOX);
+ AddCrossCallEntry (newTable, CcRqSETITEMCHECK, EvalCcRqSETITEMCHECK);
+ AddCrossCallEntry (newTable, CcRqENABLECONTROL, EvalCcRqENABLECONTROL);
+ AddCrossCallEntry (newTable, CcRqSHOWCONTROL, EvalCcRqSHOWCONTROL);
+ AddCrossCallEntry (newTable, CcRqSHOWWINDOW, EvalCcRqSHOWWINDOW);
+ AddCrossCallEntry (newTable, CcRqCREATEPOPUP, EvalCcRqCREATEPOPUP);
+ AddCrossCallEntry (newTable, CcRqADDTOPOPUP, EvalCcRqADDTOPOPUP);
+ AddCrossCallEntry (newTable, CcRqSELECTPOPUPITEM, EvalCcRqSELECTPOPUPITEM);
+ AddCrossCallEntry (newTable, CcRqRESTACKWINDOW, EvalCcRqRESTACKWINDOW);
+ AddCrossCallEntry (newTable, CcRqADDCONTROLTIP, EvalCcRqADDCONTROLTIP);
+ AddCrossCallEntry (newTable, CcRqDELCONTROLTIP, EvalCcRqDELCONTROLTIP);
+ AddCrossCallEntry (newTable, CcRqCREATECARET, EvalCcRqCREATECARET);
+ AddCrossCallEntry (newTable, CcRqSETCARETPOS, EvalCcRqSETCARETPOS);
+ AddCrossCallEntry (newTable, CcRqDESTROYCARET, EvalCcRqDESTROYCARET);
+ AddCrossCallEntry (newTable, CcRqHIDECARET, EvalCcRqHIDECARET);
+ AddCrossCallEntry (newTable, CcRqSHOWCARET, EvalCcRqSHOWCARET);
+ AddCrossCallEntries (gCrossCallProcedureTable, newTable);
+
+ return ios;
+}
+
+int GetUpdateRect(OSWindowPtr hwnd, GdkRectangle *updateRect, gboolean ok)
+{
+ printf("GetUpdateRect\n");
+ return 0;
+}
diff --git a/Linux_C_12/cCrossCallWindows_121.h b/Linux_C_12/cCrossCallWindows_121.h new file mode 100644 index 0000000..9963e28 --- /dev/null +++ b/Linux_C_12/cCrossCallWindows_121.h @@ -0,0 +1,13 @@ +#include "util_121.h"
+extern OSWindowPtr ghCaretWnd;
+
+extern void DeleteCursors(); /* Delete all created mouse cursors */
+
+/*
+ * InstallCrossCallFileSelectors adds the proper cross call procedures to the
+ * cross call procedures managed by cCrossCall_121.c.
+ */
+extern OS InstallCrossCallWindows (OS);
+
+/* GetUpdateRect */
+extern int GetUpdateRect(OSWindowPtr, GdkRectangle*, gboolean);
diff --git a/Linux_C_12/cCrossCall_121.c b/Linux_C_12/cCrossCall_121.c new file mode 100644 index 0000000..d4477e9 --- /dev/null +++ b/Linux_C_12/cCrossCall_121.c @@ -0,0 +1,729 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ cCrossCall_121 defines the infrastructure required by the Object I/O library to call
+ system procedures that interact with the Windows callback mechanism.
+
+ The basic principle in cCrossCall_121 is to have a minimal cross call kernel. If Clean
+ code requires extension of the functionality of the OS thread, then this functionality
+ must be registered before being applicable.
+
+ In this version the request codes are still statically fixed and are assumed to be
+ globally available both in the OS thread and the Clean thread. In a future version this
+ will probably be replaced by a dynamic allocation of cross call request codes.
+********************************************************************************************/
+
+
+/********************************************************************************************
+ Include section.
+********************************************************************************************/
+
+#include "cCrossCall_121.h"
+#include "cCrossCallWindows_121.h" /* Contains the implementation of cursors. */
+#include <gdk/gdkkeysyms.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <stdlib.h>
+
+char** global_argv;
+int global_argc = 0;
+
+#define _MAX_PATH 255
+
+/**********************************************************************************************
+ External global data section.
+**********************************************************************************************/
+CrossCallInfo gCci; /* The global cross call information struct. */
+GtkTooltips *gTooltip = NULL; /* The tooltip control. */
+CrossCallProcedureTable gCrossCallProcedureTable;
+
+/**********************************************************************************************
+ Internal global data section.
+**********************************************************************************************/
+
+static pthread_mutex_t gCleanMutex;
+static pthread_mutex_t gOSMutex;
+static pthread_t gOSThread;
+static gboolean gOSThreadIsRunning = FALSE;
+static gboolean gEventsInited = FALSE; /* What is this? */
+
+static CrossCallInfo *MakeQuitCci (CrossCallInfo * pcci);
+
+
+/* GetModifiers returns the modifiers that are currently pressed.
+*/
+int GetModifiers (void)
+{
+ int mods = 0;
+ GdkModifierType state;
+
+ /*printf("GetModifiers\n");*/
+
+ gdk_event_get_state(gtk_get_current_event(), &state);
+
+ if (state & GDK_SHIFT_MASK) {
+ mods |= SHIFTBIT;
+ }
+ if (state & GDK_CONTROL_MASK) {
+ mods |= CTRLBIT;
+ }
+ if (state & GDK_MOD1_MASK) {
+ mods |= ALTBIT;
+ }
+
+ return mods;
+}
+
+
+/* Translate virtual key codes to the codes shared with Clean.
+ This procedure has been filtered from TranslateKeyboardMessage.
+ If the keycode could not be translated, zero is returned.
+*/
+int CheckVirtualKeyCode (int keycode)
+{
+ int c = 0;
+ /* printf("CheckVirtualKeyCode\n");*/
+ switch (keycode)
+ {
+ case GDK_Up:
+ c = WinUpKey;
+ break;
+ case GDK_Down:
+ c = WinDownKey;
+ break;
+ case GDK_Left:
+ c = WinLeftKey;
+ break;
+ case GDK_Right:
+ c = WinRightKey;
+ break;
+ case GDK_Page_Up:
+ c = WinPgUpKey;
+ break;
+ case GDK_Page_Down:
+ c = WinPgDownKey;
+ break;
+ case GDK_End:
+ c = WinEndKey;
+ break;
+ case GDK_Begin:
+ c = WinBeginKey;
+ break;
+ case GDK_BackSpace:
+ c = WinBackSpKey;
+ break;
+ case GDK_Delete:
+ c = WinDelKey;
+ break;
+ case GDK_Tab:
+ c = WinTabKey;
+ break;
+ case GDK_Return:
+ c = WinReturnKey;
+ break;
+ case GDK_Escape:
+ c = WinEscapeKey;
+ break;
+ case GDK_Help:
+ c = WinHelpKey;
+ break;
+ case GDK_F1:
+ c = WinF1Key;
+ break;
+ case GDK_F2:
+ c = WinF2Key;
+ break;
+ case GDK_F3:
+ c = WinF3Key;
+ break;
+ case GDK_F4:
+ c = WinF4Key;
+ break;
+ case GDK_F5:
+ c = WinF5Key;
+ break;
+ case GDK_F6:
+ c = WinF6Key;
+ break;
+ case GDK_F7:
+ c = WinF7Key;
+ break;
+ case GDK_F8:
+ c = WinF8Key;
+ break;
+ case GDK_F9:
+ c = WinF9Key;
+ break;
+ case GDK_F10:
+ c = WinF10Key;
+ break;
+ case GDK_F11:
+ c = WinF11Key;
+ break;
+ case GDK_F12:
+ c = WinF12Key;
+ break;
+ }
+ return c;
+}
+
+static gboolean TimerCallback (gpointer data)
+{
+ /*printf("TimerCallback\n");*/
+ SendMessage0ToClean (CcWmIDLETIMER);
+ return TRUE;
+}
+
+void HandleCleanRequest (CrossCallInfo * pcci)
+{
+ /*printf("HandleCleanRequest: Message = %d\n", pcci->mess);*/
+ switch (pcci->mess)
+ {
+ case CcRqDOMESSAGE: /* idleTimerOn, sleeptime; no result. */
+ {
+ gboolean gIdleTimerOn = (gboolean) pcci->p1;
+ gint interval = (gint) pcci->p2;
+ /*printf("CcRqDOMESSAGE\n");*/
+
+ if (gIdleTimerOn)
+ {
+ GSource *source = g_timeout_source_new(interval);
+ g_source_set_callback(source,TimerCallback,NULL,NULL);
+ g_source_attach(source,NULL);
+
+ gtk_main_iteration();
+
+ g_source_destroy(source);
+ }
+ else
+ {
+ gtk_main_iteration();
+ }
+
+ MakeReturn0Cci (pcci);
+ }
+ break;
+ default:
+ {
+ CrossCallProcedure action;
+
+ action = FindCrossCallEntry (gCrossCallProcedureTable, pcci->mess);
+ /*printf("Handle Request for action logged for: %d\n", pcci->mess);*/
+
+ if (action == NULL)
+ { /* Cross call request code not installed. */
+ /*printf("\'HandleCleanRequest\' got uninstalled CcRq request code from Haskell: %d\n", pcci->mess);*/
+ exit(1);
+ }
+ else
+ { /* Cross call request code found. Apply it to pcci. */
+ /*printf("Action Requested: %d\n", pcci->mess);*/
+ action (pcci);
+ }
+ }
+ }
+ KickCleanThread (pcci);
+} /* HandleCleanRequest */
+
+void InitGTK()
+{
+ static gboolean gInitiated = FALSE;
+
+ /*printf("InitGTK\n"); */
+ if (!gInitiated)
+ {
+ gtk_set_locale();
+ gtk_init(&global_argc,&global_argv);
+ gInitiated = TRUE;
+ };
+} /* InitGTK */
+
+static gpointer OsThreadFunction (gpointer param);
+
+OS WinStartOsThread(OS os)
+{
+ pthread_attr_t attr;
+ /* rprintf ("WinStartOSThread\n"); */
+
+ InitGTK();
+
+ /* The cross call procedure table is set to the empty table. */
+ gCrossCallProcedureTable = EmptyCrossCallProcedureTable ();
+ /* rprintf ("Created CC Table\n"); */
+
+ pthread_mutex_init(&gCleanMutex,NULL);
+ pthread_mutex_lock(&gCleanMutex);
+ pthread_mutex_init(&gOSMutex,NULL);
+ pthread_mutex_lock(&gOSMutex);
+ gOSThreadIsRunning = TRUE;
+ /* rprintf ("OS is running.\n"); */
+
+ pthread_attr_init(&attr);
+ pthread_create(&gOSThread,&attr,OsThreadFunction,NULL);
+ pthread_attr_destroy(&attr);
+ /* rprintf ("Exiting initializer.\n"); */
+
+ return os;
+} /* WinStartOsThread */
+
+OS WinKillOsThread (OS os)
+{
+ /* printf("WinKillOsThread\n"); */
+ if (gOSThread != FALSE)
+ {
+ gOSThreadIsRunning = FALSE;
+ gOSThread = FALSE;
+
+ DeleteCursors();
+
+ if (gCrossCallProcedureTable)
+ FreeCrossCallProcedureTable (gCrossCallProcedureTable);
+ }
+ return os;
+} /*WinKillOsThread*/
+
+#undef PRINTCROSSCALLS
+
+void WinKickOsThread (int imess,
+ int ip1, int ip2, int ip3,
+ int ip4, int ip5, int ip6,
+ OS ios,
+ int *omess,
+ int *op1, int *op2, int *op3,
+ int *op4, int *op5, int *op6,
+ OS *oos
+ )
+{
+#ifdef PRINTCROSSCALLS
+ rprintf("WinKickOsThread (");
+ printCCI (&gCci);
+ rprintf(")\n");
+#endif
+ gCci.mess = imess;
+ gCci.p1 = ip1;
+ gCci.p2 = ip2;
+ gCci.p3 = ip3;
+ gCci.p4 = ip4;
+ gCci.p5 = ip5;
+ gCci.p6 = ip6;
+
+ if (gOSThread != FALSE)
+ {
+#ifdef PRINTCROSSCALLS
+ rprintf("Unlocking Clean mutex.\n");
+#endif
+ pthread_mutex_unlock(&gCleanMutex);
+#ifdef PRINTCROSSCALLS
+ rprintf("Locking OS mutex.\n");
+#endif
+ pthread_mutex_lock(&gOSMutex);
+#ifdef PRINTCROSSCALLS
+ rprintf("OS mutex locked.\n");
+#endif
+
+ *omess = gCci.mess;
+ *op1 = gCci.p1;
+ *op2 = gCci.p2;
+ *op3 = gCci.p3;
+ *op4 = gCci.p4;
+ *op5 = gCci.p5;
+ *op6 = gCci.p6;
+ *oos = ios;
+ /* printf("Data: %d, %d, %d, %d, %d, %d, %d",
+ gCci.p1, gCci.p2, gCci.p3, gCci.p4,
+ gCci.p5, gCci.p6, ios); */
+ }
+ else
+ {
+ *omess = CcWASQUIT;
+ *op1 = 0;
+ *op2 = 0;
+ *op3 = 0;
+ *op4 = 0;
+ *op5 = 0;
+ *op6 = 0;
+ *oos = ios;
+ }
+} /* WinKickOsThread */
+
+
+#ifdef PRINTCROSSCALLS
+static CrossCallInfo osstack[10];
+static CrossCallInfo clstack[10];
+static int ossp = -1;
+static int clsp = -1;
+#endif
+
+void KickCleanThread (CrossCallInfo * pcci)
+{
+ /* rprintf("KickCleanThread\n"); */
+#ifdef PRINTCROSSCALLS
+ if (ossp == -1)
+ {
+ for (ossp = 0; ossp < 10; ossp++)
+ {
+ osstack[ossp].mess = -1;
+ }
+ ossp = 1;
+ osstack[ossp].mess = -2;
+ }
+
+ if (clsp == -1)
+ {
+ for (clsp = 0; clsp < 10; clsp++)
+ {
+ clstack[clsp].mess = -1;
+ }
+ clsp = 1;
+ clstack[clsp].mess = -2;
+ }
+#endif
+
+ if (pcci != &gCci)
+ {
+ gCci = *pcci;
+ }
+
+#ifdef PRINTCROSSCALLS
+ rprintf ("KCT: started\n");
+ if (gCci.mess < 20)
+ {
+ rprintf (" -- %d --> OS returning <", clsp + ossp - 2);
+ printCCI (&gCci);
+ rprintf ("> from <");
+ printCCI (&(clstack[clsp]));
+ rprintf (">\n");
+ clsp--;
+ }
+ else
+ {
+ ossp++;
+ osstack[ossp] = gCci;
+ rprintf (" -- %d --> OS calling with <", clsp + ossp - 2);
+ printCCI (&gCci);
+ rprintf (">\n");
+ }
+
+ rprintf ("KCT: setting event\n");
+#endif
+ pthread_mutex_unlock(&gOSMutex);
+#ifdef PRINTCROSSCALLS
+ rprintf ("KCT: starting wait\n");
+#endif
+ pthread_mutex_lock(&gCleanMutex);
+#ifdef PRINTCROSSCALLS
+ rprintf ("KCT: wait done.\n");
+#endif
+
+ if (pcci != &gCci)
+ *pcci = gCci;
+
+#ifdef PRINTCROSSCALLS
+ if (gCci.mess < 20)
+ {
+ rprintf (" <-- %d -- Clean returning <", clsp + ossp - 2);
+ printCCI (&gCci);
+ rprintf ("> from <");
+ printCCI (&(osstack[ossp]));
+ rprintf (">\n");
+ ossp--;
+ }
+ else
+ {
+ clsp++;
+ clstack[clsp] = gCci;
+ rprintf (" <-- %d -- Clean calling with <", clsp + ossp - 2);
+ printCCI (&gCci);
+ rprintf (">\n");
+ }
+#endif
+} /* KickCleanThread */
+
+void SendMessageToClean (int mess, int p1, int p2, int p3, int p4, int p5, int p6)
+{
+ /* printf("SendMessageToClean -- Message: %d\n", mess); */
+ gCci.mess = mess;
+ gCci.p1 = p1;
+ gCci.p2 = p2;
+ gCci.p3 = p3;
+ gCci.p4 = p4;
+ gCci.p5 = p5;
+ gCci.p6 = p6;
+
+ KickCleanThread (&gCci);
+ while (!IsReturnCci (&gCci))
+ {
+ HandleCleanRequest (&gCci);
+ }
+}
+
+CrossCallInfo *MakeReturn0Cci (CrossCallInfo * pcci)
+{
+ pcci->mess = CcRETURN0;
+ return pcci;
+}
+
+CrossCallInfo *MakeReturn1Cci (CrossCallInfo * pcci, int v1)
+{
+ pcci->mess = CcRETURN1;
+ pcci->p1 = v1;
+ return pcci;
+}
+
+CrossCallInfo *MakeReturn2Cci (CrossCallInfo * pcci, int v1, int v2)
+{
+ pcci->mess = CcRETURN2;
+ pcci->p1 = v1;
+ pcci->p2 = v2;
+ return pcci;
+}
+
+CrossCallInfo *MakeReturn3Cci (CrossCallInfo * pcci, int v1, int v2, int v3)
+{
+ pcci->mess = CcRETURN3;
+ pcci->p1 = v1;
+ pcci->p2 = v2;
+ pcci->p3 = v3;
+ return pcci;
+}
+
+CrossCallInfo *MakeReturn4Cci (CrossCallInfo * pcci, int v1, int v2, int v3, int v4)
+{
+ pcci->mess = CcRETURN4;
+ pcci->p1 = v1;
+ pcci->p2 = v2;
+ pcci->p3 = v3;
+ pcci->p4 = v4;
+ return pcci;
+}
+
+CrossCallInfo *MakeReturn5Cci (CrossCallInfo * pcci, int v1, int v2, int v3, int v4, int v5)
+{
+ pcci->mess = CcRETURN5;
+ pcci->p1 = v1;
+ pcci->p2 = v2;
+ pcci->p3 = v3;
+ pcci->p4 = v4;
+ pcci->p5 = v5;
+ return pcci;
+}
+
+CrossCallInfo *MakeReturn6Cci (CrossCallInfo * pcci, int v1, int v2, int v3, int v4, int v5, int v6)
+{
+ pcci->mess = CcRETURN6;
+ pcci->p1 = v1;
+ pcci->p2 = v2;
+ pcci->p3 = v3;
+ pcci->p4 = v4;
+ pcci->p5 = v5;
+ pcci->p6 = v6;
+ return pcci;
+}
+
+gboolean IsReturnCci (CrossCallInfo * pcci)
+{
+ /* printf("Checking message %d: ", pcci->mess);*/
+ if (pcci->mess >= CcRETURNmin && pcci->mess <= CcRETURNmax)
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+static gpointer OsThreadFunction (gpointer param)
+{
+ /* printf("OsThreadFunction\n"); */
+ gTooltip = gtk_tooltips_new();
+
+ pthread_mutex_lock(&gCleanMutex);
+
+ while (gOSThreadIsRunning)
+ {
+ HandleCleanRequest (&gCci);
+ }
+
+ pthread_mutex_unlock(&gCleanMutex);
+
+ pthread_mutex_destroy(&gOSMutex);
+ pthread_mutex_destroy(&gCleanMutex);
+
+ return NULL;
+} /* OsThreadFunction */
+
+void WinInitOs (Bool* ok, OS* os)
+{
+ /* printf("WinInitOs\n"); */
+ if (gEventsInited)
+ {
+ *ok = FALSE;
+ rprintf ("WIO: *ok = FALSE\n");
+ }
+ else
+ {
+ *ok = TRUE;
+ gEventsInited = TRUE;
+ rprintf ("WIO: *ok = TRUE\n");
+ }
+ *os = 54321;
+} /* WinInitOs */
+
+Bool WinCloseOs (OS os)
+ {
+ if (gEventsInited)
+ {
+ rprintf ("WCO: return TRUE\n");
+ gEventsInited = FALSE;
+ return TRUE;
+ }
+ else
+ {
+ rprintf ("WCO: return FALSE\n");
+ return FALSE;
+ }
+} /* WinCloseOs */
+
+void WinCallProcess (char* commandline, char* env, char* dir, char* in,
+ char* out, char* err, OS ios, Bool* success, int* exitcode,
+ OS* oos)
+{
+ printf("WinCallProcess --> Not Implemented\n");
+ *oos = ios;
+}
+
+void WinLaunchApp2 (CLEAN_STRING commandline, CLEAN_STRING pathname,
+ BOOL console, OS ios, Bool *success, OS *oos)
+{
+ pid_t pi;
+ BOOL fsuccess;
+ char path[_MAX_PATH];
+ char *cl, *exname, *thepath;
+ int i;
+ int error;
+
+ rprintf ("WLA: starting...\n");
+
+ *success = FALSE;
+ *oos = ios;
+
+ rprintf ("WLA: step 2.\n");
+
+ exname = cstring(pathname);
+ cl = cstring (commandline);
+ strcpy (path, cl);
+ for (i = strlen (path); path[i] != '\\' && i >= 0; i--)
+ {
+ path[i] = 0;
+ }
+
+ if (i == 0)
+ {
+ thepath = NULL;
+ }
+ else
+ { /* path[i] = '\"'; */
+ thepath = path + 1;
+ }
+
+ rprintf ("WLA: step 2a: directory = <%s>\n", thepath);
+
+ rprintf ("WLA: step 3: calling process \"%s\".\n", cl);
+ pi = fork();
+ if (pi == 0)
+ {
+ /* I'm a child -- launch the desired program. */
+ execlp(exname, cl);
+ } else if (pi == -1) {
+ /* Error condition */
+ error = errno;
+ rprintf ("WLA: failure %d\n", error);
+ fsuccess = FALSE;
+ } else {
+ rprintf ("WLA: success\n");
+ fsuccess = TRUE;
+ }
+
+ rprintf ("WLA: step 5: returning\n");
+ *success = fsuccess;
+ *oos = ios;
+ rprintf ("WLA: done...\n");
+}
+
+void WinLaunchApp (CLEAN_STRING commandline, BOOL console, OS ios,
+ Bool *success, OS *oos)
+{
+ printf("WinLaunchApp --> Not implemented\n");
+ *oos = ios;
+}
+
+char* WinGetAppPath (void)
+{
+ int idx, length;
+ char *path = rmalloc(261);
+ char *search = rmalloc(261);
+ pid_t pid = getpid();
+
+ /* printf("WinGetAppPath\n"); */
+
+ /*
+ * NOTE: LINUX Only
+ *
+ * Path to current executable is found by:
+ *
+ * /proc/<pid>/exe (symlink to actual executable
+ *
+ * stat this symlink to get the path
+ */
+ sprintf(search, "/proc/%d/exe", pid);
+ length = readlink(search, path, 261);
+ path[length] = 0x00;
+
+ for (idx = length - 1;
+ path[idx] != '/' && path[idx] != '\\' &&
+ path[idx] != ':';
+ idx--)
+ ;
+
+ path[idx + 1] = 0;
+
+ /* printf("App Path: %s\n", path); */
+
+ return path;
+ /* relying on the calling clean function to de-allocate path. */
+} /* WinGetAppPath */
+
+CLEAN_STRING WinGetModulePath (void)
+{
+ char path[255 + 1];
+
+ printf("WinGetModulePath -- Not Implemented.\n");
+
+ return cleanstring(WinGetAppPath());
+}
+
+void WinFileModifiedDate (CLEAN_STRING name, gboolean* exists, int *yy,
+ int *mm, int *dd, int *h, int *m, int *s)
+{
+ printf("WinFileModifiedDate --> Not implemented.\n");
+ *exists = FALSE;
+ *yy = 0;
+ *mm = 0;
+ *dd = 0;
+ *h = 0;
+ *m = 0;
+ *s = 0;
+}
+
+gboolean WinFileExists (CLEAN_STRING string)
+{
+ printf("WinFileExists --> Not implemented\n");
+ return FALSE;
+}
+
diff --git a/Linux_C_12/cCrossCall_121.h b/Linux_C_12/cCrossCall_121.h new file mode 100644 index 0000000..6bd2ed1 --- /dev/null +++ b/Linux_C_12/cCrossCall_121.h @@ -0,0 +1,87 @@ +#include "util_121.h"
+#include "cCrossCallProcedureTable_121.h"
+#include "cTCP_121.h"
+
+
+/* Global data with external references: */
+extern CrossCallInfo gCci; /* The global cross call information struct. */
+extern int gClipboardCount; /* Keeps track of changes of clipboard. */
+extern CrossCallProcedureTable gCrossCallProcedureTable; /* The cross call procedure table. */
+extern GtkTooltips *gTooltip; /* The tooltip control. */
+
+#if defined(mingw32_TARGET_OS)
+extern char *gAppName; /* The application name. */
+extern HINSTANCE ghInst; /* The handle to the instance of the OS thread. */
+extern HWND ghMainWindow; /* The handle to the main HWND of the OS thread. */
+extern HACCEL gAcceleratorTable; /* Refers to the accelerator table of the active frame. */
+extern BOOL gAcceleratorTableIsUpToDate; /* Flag: TRUE iff accelerator table corresponds with active frame. */
+extern HWND ghActiveFrameWindow; /* The currently active frame window (MDI/SDI). */
+extern HWND ghActiveClientWindow; /* The currently active client window (MDI). */
+extern HWND gActiveDialog; /* The currently active dialogue. */
+extern HWND ghwndLastModalDialog; /* Keeps track of last modal dialog. */
+extern HFONT gDlogFont; /* The handle to the logical FONT that is used in dialogs. */
+extern HFONT gControlFont; /* The handle to the logical FONT that is used in all controls. */
+extern HWND ghTCPWindow; /* The handle to the TCP HWND of the OS thread. */
+
+
+/* Menu(item)IDs are not allowed to exceed OSMenuIDEnd.
+ This is because window ids start at (OSMenuIDEnd+5), and need to be distinct from menu ids
+ in case of MDI processes.
+ The global gMenuItemID (initially 0) is incremented by NextMenuItemID each time a new
+ menu(item)ID is required.
+ This implementation does not reuse freed ids and is therefore not adequate!!
+*/
+#define OSMenuIDEnd 10000
+extern UINT NextMenuItemID (void);
+#endif
+
+
+/* GetModifiers returns the modifiers that are currently pressed.
+*/
+extern int GetModifiers (void);
+
+/* Translate virtual key codes to the codes shared with Clean.
+ If the keycode could not be translated, zero is returned.
+*/
+extern int CheckVirtualKeyCode (int keycode);
+
+
+extern void HandleCleanRequest( CrossCallInfo *pcci );
+extern OS WinStartOsThread (OS);
+extern OS WinKillOsThread (OS);
+extern void WinKickOsThread (int,int,int,int,int,int,int,OS,int*,int*,int*,
+ int*,int*,int*,int*,OS*);
+extern void KickCleanThread( CrossCallInfo *pcci );
+
+extern void SendMessageToClean( int mess, int p1,int p2,int p3, int p4,int p5,int p6 );
+
+/* Shorthands for SendMessageToClean: */
+#define SendMessage0ToClean(mess) SendMessageToClean((mess), 0,0,0,0,0,0)
+#define SendMessage1ToClean(mess, p1) SendMessageToClean((mess), (int)(p1),0,0,0,0,0)
+#define SendMessage2ToClean(mess, p1,p2) SendMessageToClean((mess), (int)(p1),(int)(p2),0,0,0,0)
+#define SendMessage3ToClean(mess, p1,p2,p3) SendMessageToClean((mess), (int)(p1),(int)(p2),(int)(p3),0,0,0)
+#define SendMessage4ToClean(mess, p1,p2,p3,p4) SendMessageToClean((mess), (int)(p1),(int)(p2),(int)(p3),(int)(p4),0,0)
+#define SendMessage5ToClean(mess, p1,p2,p3,p4,p5) SendMessageToClean((mess), (int)(p1),(int)(p2),(int)(p3),(int)(p4),(int)(p5),0)
+#define SendMessage6ToClean(mess, p1,p2,p3,p4,p5,p6) SendMessageToClean((mess), (int)(p1),(int)(p2),(int)(p3),(int)(p4),(int)(p5),(int)(p6))
+
+/* Prototypes of convenience functions that fill CrossCallInfo struct. */
+extern CrossCallInfo *MakeReturn0Cci (CrossCallInfo * pcci);
+extern CrossCallInfo *MakeReturn1Cci (CrossCallInfo * pcci, int v);
+extern CrossCallInfo *MakeReturn2Cci (CrossCallInfo * pcci, int v1, int v2);
+extern CrossCallInfo *MakeReturn3Cci (CrossCallInfo * pcci, int v1, int v2, int v3);
+extern CrossCallInfo *MakeReturn4Cci (CrossCallInfo * pcci, int v1, int v2, int v3, int v4);
+extern CrossCallInfo *MakeReturn5Cci (CrossCallInfo * pcci, int v1, int v2, int v3, int v4, int v5);
+extern CrossCallInfo *MakeReturn6Cci (CrossCallInfo * pcci, int v1, int v2, int v3, int v4, int v5, int v6);
+
+extern BOOL IsReturnCci( CrossCallInfo *pcci );
+
+extern void WinInitOs (gboolean*, OS*);
+extern gboolean WinCloseOs (OS os);
+extern char* WinGetAppPath (void);
+extern CLEAN_STRING WinGetModulePath (void);
+extern void WinFileModifiedDate (CLEAN_STRING name, gboolean* exists, int *yy, int *mm, int *dd, int *h, int *m, int *s);
+extern gboolean WinFileExists (CLEAN_STRING);
+
+extern void WinCallProcess(char*,char*,char*,char*,char*,char*,OS,Bool*,int*,OS*);
+extern void WinLaunchApp(CLEAN_STRING,BOOL,OS,Bool*,OS*);
+extern void WinLaunchApp2(CLEAN_STRING,CLEAN_STRING,BOOL,OS,Bool*,OS*);
diff --git a/Linux_C_12/cCrossCallxDI_121.c b/Linux_C_12/cCrossCallxDI_121.c new file mode 100644 index 0000000..2426cff --- /dev/null +++ b/Linux_C_12/cCrossCallxDI_121.c @@ -0,0 +1,616 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ This module contains the cross call implementations required for
+ NDI, SDI, and MDI document interfaces.
+********************************************************************************************/
+#include "util_121.h"
+#include <gdk/gdkkeysyms.h>
+#include "cCrossCallxDI_121.h"
+#include "cCrossCall_121.h"
+#include "cCCallWindows_121.h"
+
+
+/* Global data with external references:
+*/
+GtkWidget *gActiveTopLevelWindow = NULL;
+gboolean gInMouseDown = FALSE;
+gboolean gInKey = FALSE;
+gint gCurChar;
+
+
+/* GetSDIClientWindow finds the first SDI client window of the argument hwnd.
+ This procedure assumes that hwnd is the handle of a SDI frame window.
+ If no SDI client window could be found then GetSDIClientWindow returns NULL.
+*/
+/*
+static HWND GetSDIClientWindow (HWND hwndFrame)
+{
+ HWND client;
+ char *clientclassname;
+ int classnamelength;
+
+ client = GetWindow (hwndFrame,GW_CHILD);
+ classnamelength = strlen (SDIWindowClassName) + 1;
+ clientclassname = rmalloc (classnamelength);
+ GetClassName (client, clientclassname, classnamelength);
+
+ while (client != NULL && strcmp(clientclassname, SDIWindowClassName) != 0)
+ {
+ client = GetWindow (client,GW_HWNDNEXT);
+ GetClassName (client,clientclassname,classnamelength);
+ }
+ rfree (clientclassname);
+ return client;
+}
+*/
+
+/* Sending keyboard events to Clean thread:
+*/
+void SendKeyDownToClean (GtkWidget *parent, GtkWidget *child, gint c)
+{
+ printf("SendKeyDownToClean\n");
+ SendMessage5ToClean (CcWmKEYBOARD, parent, child, c, KEYDOWN,
+ GetModifiers());
+}
+
+void SendKeyStillDownToClean (GtkWidget *parent, GtkWidget *child, gint c)
+{
+ printf("SendKeyStillDownToClean\n");
+ SendMessage5ToClean (CcWmKEYBOARD, parent, child, c, KEYREPEAT,
+ GetModifiers());
+}
+
+void SendKeyUpToClean (GtkWidget *parent, GtkWidget *child, gint c)
+{
+ printf("SendKeyUpToClean\n");
+ SendMessage5ToClean (CcWmKEYBOARD, parent, child, c, KEYUP, GetModifiers());
+}
+
+static void prcs(GtkWidget *widget, gpointer data)
+{
+ printf("prcs\n");
+ if (GTK_IS_SCROLLED_WINDOW(widget))
+ {
+ *((GtkWidget **) data) = widget;
+ }
+}
+
+static GtkWidget *get_client(GtkWidget *widget)
+{
+ GtkWidget *box;
+ printf("get_client\n");
+
+ box = gtk_bin_get_child(GTK_BIN(widget));
+ if (box)
+ {
+ GtkWidget *client = NULL;
+ gtk_container_foreach(GTK_CONTAINER(box), prcs, (gpointer) &client);
+ return client;
+ }
+
+ return NULL;
+}
+
+static void frame_focus_in_handler(GtkWidget *widget, GdkEventFocus *event,
+ gpointer user_data)
+{
+ printf("frame_focus_in_handler\n");
+ SendMessage1ToClean (CcWmACTIVATE, get_client(widget));
+ GTK_WIDGET_GET_CLASS(widget)->focus_in_event(widget, event);
+ gActiveTopLevelWindow = widget;
+}
+
+static void frame_focus_out_handler(GtkWidget *widget, GdkEventFocus *event,
+ gpointer user_data)
+{
+ GtkWidget *client;
+ printf("frame_focus_out_handler\n");
+
+ client = get_client(widget);
+ if (gInKey)
+ {
+ SendKeyUpToClean (client, client, gCurChar);
+ }
+
+ SendMessage1ToClean (CcWmDEACTIVATE, client);
+ GTK_WIDGET_GET_CLASS(widget)->focus_out_event(widget, event);
+ gActiveTopLevelWindow = NULL;
+}
+
+
+static gboolean frame_delete_handler(GtkWidget *widget, GdkEvent *event,
+ gpointer user_data)
+{
+ printf("frame_delete_handler\n");
+ if (gActiveTopLevelWindow == widget)
+ {
+ gActiveTopLevelWindow = NULL;
+ }
+
+ if (gtk_object_get_data(GTK_OBJECT (widget), "gtk-drag-dest") != NULL)
+ {
+ gtk_drag_dest_unset(widget);
+ }
+
+ SendMessage1ToClean (CcWmPROCESSCLOSE, widget);
+ return gtk_true();
+}
+
+static void frame_drag_data_handler
+ (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *data,
+ guint info,
+ guint time)
+{
+ printf("frame_drag_data_handler\n");
+ if ((data->length >= 0) && (data->format == 8))
+ {
+ char *filenames = rmalloc(data->length);
+ if (filenames)
+ {
+ guchar *s = data->data;
+ guchar *e = s + data->length - 2;
+ gchar *d = filenames;
+
+ while (s < e)
+ {
+ if (*s != '\r') *(d++) = *s;
+ s++;
+ }
+ *d = 0;
+
+ gtk_drag_finish (context, TRUE, FALSE, time);
+ SendMessage2ToClean (CcWmPROCESSDROPFILES, (gint) widget,
+ (gint) filenames);
+ }
+ }
+ else
+ {
+ gtk_drag_finish (context, FALSE, FALSE, time);
+ }
+}
+
+static gboolean frame_key_press_handler(GtkWidget *widget, GdkEventKey *event,
+ gpointer user_data)
+{
+ GtkWidget *client;
+ gint c;
+ printf("frame_key_press_handler\n");
+
+ client = get_client(widget);
+
+ c = (event->length > 0) ?
+ event->string[0] : CheckVirtualKeyCode (event->keyval);
+ if (!c)
+ {
+ return gtk_false();
+ }
+
+ if (event->keyval == GDK_Tab)
+ {
+ return gtk_false();
+ }
+
+ GTK_WIDGET_GET_CLASS(widget)->key_press_event(widget, event);
+
+ if (gInKey)
+ {
+ if (gCurChar == c)
+ {
+ SendKeyStillDownToClean (client, client, gCurChar);
+ }
+ else
+ {
+ SendKeyUpToClean (client, client, gCurChar);
+ gCurChar = c;
+ SendKeyDownToClean (client, client, gCurChar);
+ }
+ }
+ else
+ {
+ gCurChar = c;
+ SendKeyDownToClean (client, client, gCurChar);
+ gInKey = TRUE;
+ }
+
+ return gtk_true();
+}
+
+static gboolean frame_key_release_handler(GtkWidget *widget, GdkEventKey *event,
+ gpointer user_data)
+{
+ GtkWidget *client;
+ printf("frame_key_release_handler\n");
+
+ client = get_client(widget);
+ if (event->keyval == GDK_Tab)
+ return gtk_false();
+
+ GTK_WIDGET_GET_CLASS(widget)->key_press_event(widget, event);
+
+ if (gInKey)
+ {
+ SendKeyUpToClean (client, client, gCurChar);
+ gInKey = FALSE;
+ gCurChar = 0;
+ }
+
+ return gtk_true();
+}
+
+/* Create a SDI frame window. */
+void EvalCcRqCREATESDIFRAMEWINDOW (CrossCallInfo *pcci) /* accept file open; frame ptr, menubar results. */
+{
+ GtkWidget *window, *menuBar, *box;
+
+ printf("EvalCcRqCREATESDIFRAMEWINDOW\n");
+
+ /* Create the menubar. */
+ menuBar = gtk_menu_bar_new();
+
+ /* Create the window. */
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_signal_connect (GTK_OBJECT (window), "focus-in-event",
+ GTK_SIGNAL_FUNC(frame_focus_in_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT (window), "focus-out-event",
+ GTK_SIGNAL_FUNC(frame_focus_out_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT (window), "delete-event",
+ GTK_SIGNAL_FUNC(frame_delete_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(window), "key-press-event",
+ GTK_SIGNAL_FUNC(frame_key_press_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(window), "key-release-event",
+ GTK_SIGNAL_FUNC(frame_key_release_handler),
+ NULL);
+
+ if ((gboolean) pcci->p1) /* respond to file open events. */
+ {
+ static GtkTargetEntry target_table = { "text/uri-list", 0, 0 };
+
+ gtk_drag_dest_set (window,
+ GTK_DEST_DEFAULT_ALL,
+ &target_table, 1, /* no rootwin */
+ GDK_ACTION_COPY | GDK_ACTION_MOVE);
+
+ gtk_signal_connect(GTK_OBJECT(window), "drag_data_received",
+ GTK_SIGNAL_FUNC(frame_drag_data_handler), NULL);
+ }
+
+ gtk_window_add_accel_group (GTK_WINDOW (window), gtk_accel_group_new());
+
+ box = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(window), box);
+ gtk_box_pack_start(GTK_BOX(box), menuBar, FALSE, FALSE, 0);
+ gtk_widget_show(menuBar);
+
+ MakeReturn2Cci (pcci, (int) window, (int) menuBar);
+}
+
+static void frame_close_page_handler(GtkWidget *client)
+{
+ GtkWidget *window;
+ printf("frame_close_page_handler\n");
+
+ window = gtk_notebook_get_nth_page(GTK_NOTEBOOK(client), gtk_notebook_get_current_page(GTK_NOTEBOOK(client)));
+ SendMessage1ToClean(CcWmCLOSE, window);
+}
+
+static void frame_notebook_top_handler(GtkWidget *client)
+{
+ printf("frame_notebook_top_handler\n");
+ gtk_notebook_set_tab_pos(GTK_NOTEBOOK(client), GTK_POS_TOP);
+}
+
+static void frame_notebook_bottom_handler(GtkWidget *client)
+{
+ printf("frame_notebook_bottom_handler\n");
+ gtk_notebook_set_tab_pos(GTK_NOTEBOOK(client), GTK_POS_BOTTOM);
+}
+
+static void frame_notebook_left_handler(GtkWidget *client)
+{
+ printf("frame_notebook_left_handler\n");
+ gtk_notebook_set_tab_pos(GTK_NOTEBOOK(client), GTK_POS_LEFT);
+}
+
+static void frame_notebook_right_handler(GtkWidget *client)
+{
+ printf("frame_notebook_right_handler\n");
+ gtk_notebook_set_tab_pos(GTK_NOTEBOOK(client), GTK_POS_RIGHT);
+}
+
+static void frame_switch_page_handler(GtkNotebook *notebook,
+ GtkNotebookPage *page, gint page_num, gpointer user_data)
+{
+ /* send deactivate message for old */
+ gint old_page_num;
+ printf("frame_switch_page_handler\n");
+ old_page_num = g_list_index(notebook->children, notebook->cur_page);
+
+ SendMessage1ToClean (CcWmDEACTIVATE, gtk_notebook_get_nth_page(notebook,
+ old_page_num));
+
+ /* send activate message for new */
+ SendMessage1ToClean (CcWmACTIVATE, gtk_notebook_get_nth_page(notebook,
+ page_num));
+ gActiveTopLevelWindow = gtk_widget_get_parent(
+ gtk_widget_get_parent(GTK_WIDGET(notebook)));
+
+}
+
+/* Create MDI frame window. */
+void EvalCcRqCREATEMDIFRAMEWINDOW (CrossCallInfo *pcci) /* show, accept file open; frame ptr, client ptr, menubar, windowmenu results. */
+{
+ GtkWidget *window, *client, *menuBar, *box;
+ GtkWidget *notebook_menu, *menu_item, *pages_menu;
+ GtkAccelGroup *accel_group;
+ GSList *group;
+
+ printf("EvalCcRqCREATEMDIFRAMEWINDOW\n");
+ /* Create the window. */
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_signal_connect (GTK_OBJECT(window), "delete-event",
+ GTK_SIGNAL_FUNC(frame_delete_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(window), "key-press-event",
+ GTK_SIGNAL_FUNC(frame_key_press_handler),
+ NULL);
+ gtk_signal_connect (GTK_OBJECT(window), "key-release-event",
+ GTK_SIGNAL_FUNC(frame_key_release_handler),
+ NULL);
+
+
+ if ((gboolean) pcci->p2) /* respond to file open events. */
+ {
+ static GtkTargetEntry target_table = { "text/uri-list", 0, 0 };
+
+ gtk_drag_dest_set (window,
+ GTK_DEST_DEFAULT_ALL,
+ &target_table, 1, /* no rootwin */
+ GDK_ACTION_COPY | GDK_ACTION_MOVE);
+
+ gtk_signal_connect(GTK_OBJECT(window), "drag_data_received",
+ GTK_SIGNAL_FUNC(frame_drag_data_handler), NULL);
+ }
+
+ /* Create accel_group */
+ accel_group = gtk_accel_group_new();
+ gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
+
+ box = gtk_vbox_new(FALSE, 0);
+ gtk_container_add(GTK_CONTAINER(window), box);
+
+ /* Create the menubar. */
+ menuBar = gtk_menu_bar_new();
+ gtk_box_pack_start(GTK_BOX(box), menuBar, FALSE, FALSE, 0);
+
+ /* Create client(notebook) */
+ client = gtk_notebook_new();
+ gtk_notebook_set_scrollable(GTK_NOTEBOOK(client), gtk_true());
+ gtk_signal_connect (GTK_OBJECT(client), "switch-page",
+ GTK_SIGNAL_FUNC(frame_switch_page_handler),
+ NULL);
+ gtk_box_pack_end(GTK_BOX(box), client, TRUE, TRUE, 0);
+
+ if ((gboolean) pcci->p1)
+ gtk_window_maximize(GTK_WINDOW(window));
+ gtk_widget_show_all(window);
+
+ /* Create "Pages" menu */
+ pages_menu = gtk_menu_new();
+ gtk_menu_set_accel_group(GTK_MENU(pages_menu), accel_group);
+
+ menu_item = gtk_menu_item_new_with_label("Pages");
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM (menu_item), pages_menu);
+ gtk_widget_show_all(menu_item);
+
+ gtk_menu_bar_insert(GTK_MENU_BAR(menuBar), menu_item, 0);
+
+ notebook_menu = gtk_menu_new();
+ gtk_menu_set_accel_group(GTK_MENU(notebook_menu), accel_group);
+
+ menu_item = gtk_radio_menu_item_new_with_label(NULL, "Top");
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), gtk_true());
+ group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item));
+ gtk_signal_connect_object (GTK_OBJECT (menu_item), "activate",
+ GTK_SIGNAL_FUNC (frame_notebook_top_handler), client);
+ gtk_menu_append(GTK_MENU(notebook_menu), menu_item);
+
+ menu_item = gtk_radio_menu_item_new_with_label(group, "Bottom");
+ group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item));
+ gtk_signal_connect_object (GTK_OBJECT (menu_item), "activate",
+ GTK_SIGNAL_FUNC (frame_notebook_bottom_handler), client);
+ gtk_menu_append(GTK_MENU(notebook_menu), menu_item);
+
+ menu_item = gtk_radio_menu_item_new_with_label(group, "Left");
+ group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item));
+ gtk_signal_connect_object (GTK_OBJECT (menu_item), "activate",
+ GTK_SIGNAL_FUNC (frame_notebook_left_handler), client);
+ gtk_menu_append(GTK_MENU(notebook_menu), menu_item);
+
+ menu_item = gtk_radio_menu_item_new_with_label(group, "Right");
+ group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menu_item));
+ gtk_signal_connect_object (GTK_OBJECT (menu_item), "activate",
+ GTK_SIGNAL_FUNC (frame_notebook_right_handler), client);
+ gtk_menu_append(GTK_MENU(notebook_menu), menu_item);
+
+ menu_item = gtk_menu_item_new_with_label("Notebook");
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM (menu_item), notebook_menu);
+ gtk_menu_append(GTK_MENU(pages_menu), menu_item);
+
+ menu_item = gtk_menu_item_new();
+ gtk_menu_append(GTK_MENU(pages_menu), menu_item);
+
+ menu_item = gtk_menu_item_new_with_label("Close page");
+ gtk_signal_connect_object (GTK_OBJECT (menu_item), "activate",
+ GTK_SIGNAL_FUNC (frame_close_page_handler), client);
+ gtk_menu_append(GTK_MENU(pages_menu), menu_item);
+
+ gtk_widget_show(menuBar);
+ gtk_widget_show_all(pages_menu);
+
+ MakeReturn4Cci (pcci, (int) window, (int) client, (int) menuBar, (int) pages_menu);
+}
+
+void EvalCcRqDESTROYWINDOW (CrossCallInfo *pcci)
+{
+ printf("EvalCcRqDESTROYWINDOW\n");
+ gtk_widget_destroy(GTK_WIDGET(pcci->p1));
+ MakeReturn0Cci (pcci);
+}
+
+void EvalCcRqGETWINDOWPOS (CrossCallInfo *pcci)
+{
+ /* hwnd; width, heigth result */
+ gint left, top;
+
+ printf("EvalCcRqGETWINDOWPOS\n");
+ gtk_window_get_position(GTK_WINDOW(pcci->p1), &left, &top);
+ MakeReturn2Cci (pcci, left, top);
+}
+
+void EvalCcRqGETCLIENTSIZE (CrossCallInfo *pcci)
+{
+ /* hwnd; width, height result. */
+ printf("EvalCcRqGETCLIENTSIZE\n");
+
+ if (pcci->p1 && (pcci->p1 != OS_NO_WINDOW_PTR))
+ {
+ GtkRequisition requisition;
+ GtkWidget *frame = GTK_WIDGET(pcci->p1);
+ gtk_widget_size_request(frame, &requisition);
+ MakeReturn2Cci (pcci, requisition.width, requisition.height);
+ } else {
+ MakeReturn2Cci (pcci, 0, 0);
+ }
+}
+
+static void toolbar_handler(GtkWidget *widget, gpointer data)
+{
+ GtkWidget *toolbar, *parent;
+
+ printf("toolbar_handler\n");
+ toolbar = gtk_widget_get_parent(widget);
+ parent = gtk_widget_get_parent(gtk_widget_get_parent(toolbar));
+ SendMessage4ToClean (CcWmBUTTONCLICKED, parent, toolbar, GetModifiers(),
+ (int) data);
+}
+
+/* Create a toolbar in a window. */
+void EvalCcRqCREATEMDITOOLBAR (CrossCallInfo *pcci)
+{
+ /* hwnd, width, height; toolbarptr, full toolbar height result; */
+ GtkWidget *parent,*box,*toolbar;
+
+ printf("EvalCcRqCREATEMDITOOLBAR\n");
+ if (pcci->p1 && (pcci->p1 != OS_NO_WINDOW_PTR))
+ {
+ parent = GTK_WIDGET(pcci->p1);
+
+ box = gtk_bin_get_child(GTK_BIN(parent));
+ toolbar = gtk_toolbar_new();
+
+ gtk_box_pack_start (GTK_BOX (box), toolbar, FALSE, FALSE, 0);
+ gtk_widget_show(toolbar);
+
+ gtk_window_maximize(GTK_WINDOW(parent));
+ MakeReturn2Cci (pcci, (int) toolbar, pcci->p3);
+ }
+}
+
+/* Create a toolbar in a SDI window. */
+void EvalCcRqCREATESDITOOLBAR (CrossCallInfo *pcci)
+{
+ GtkWidget *parent,*box,*toolbar;
+ printf("EvalCcRqCREATESDITOOLBAR\n");
+
+ if (pcci->p1 && (pcci->p1 != OS_NO_WINDOW_PTR))
+ {
+ parent = GTK_WIDGET(pcci->p1);
+
+ box = gtk_bin_get_child(GTK_BIN(parent));
+ toolbar = gtk_toolbar_new();
+
+ gtk_box_pack_start (GTK_BOX(box), toolbar, FALSE, FALSE, 0);
+ gtk_widget_show(toolbar);
+
+ MakeReturn2Cci (pcci, (int)toolbar, pcci->p3);
+ }
+}
+
+/* Create a bitmap toolbar item. */
+void EvalCcRqCREATETOOLBARITEM (CrossCallInfo *pcci)
+{
+ GtkWidget *toolbar;
+ GdkPixbuf *pixbuf;
+ gint index;
+
+ printf("EvalCcRqCREATETOOLBARITEM\n");
+ if (pcci->p1 && (pcci->p1 != OS_NO_WINDOW_PTR))
+ {
+ toolbar = GTK_WIDGET(pcci->p1);
+ pixbuf = GDK_PIXBUF(pcci->p2);
+ index = pcci->p3;
+
+ gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), NULL, NULL, NULL,
+ gtk_image_new_from_pixbuf(pixbuf),
+ GTK_SIGNAL_FUNC(toolbar_handler), (gpointer) index);
+ }
+ MakeReturn0Cci (pcci);
+}
+
+/* Create a separator toolbar item. */
+void EvalCcRqCREATETOOLBARSEPARATOR (CrossCallInfo *pcci)
+{
+ GtkWidget *toolbar;
+
+ printf("EvalCcRqCREATETOOLBARSEPARATOR\n");
+ if (pcci->p1 && (pcci->p1 != OS_NO_WINDOW_PTR))
+ {
+ toolbar = GTK_WIDGET(pcci->p1);
+ gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
+ }
+
+ MakeReturn0Cci (pcci);
+}
+
+/* Install the cross call procedures in the gCrossCallProcedureTable of cCrossCall_121.
+*/
+OS InstallCrossCallxDI (OS ios)
+{
+ CrossCallProcedureTable newTable;
+ printf("InstallCrossCallxDI\n");
+
+ newTable = EmptyCrossCallProcedureTable ();
+ AddCrossCallEntry (newTable, CcRqCREATESDIFRAMEWINDOW, EvalCcRqCREATESDIFRAMEWINDOW);
+ AddCrossCallEntry (newTable, CcRqCREATEMDIFRAMEWINDOW, EvalCcRqCREATEMDIFRAMEWINDOW);
+ AddCrossCallEntry (newTable, CcRqDESTROYWINDOW, EvalCcRqDESTROYWINDOW);
+ AddCrossCallEntry (newTable, CcRqGETWINDOWPOS, EvalCcRqGETWINDOWPOS);
+ AddCrossCallEntry (newTable, CcRqGETCLIENTSIZE, EvalCcRqGETCLIENTSIZE);
+ AddCrossCallEntry (newTable, CcRqCREATEMDITOOLBAR, EvalCcRqCREATEMDITOOLBAR);
+ AddCrossCallEntry (newTable, CcRqCREATESDITOOLBAR, EvalCcRqCREATESDITOOLBAR);
+ AddCrossCallEntry (newTable, CcRqCREATETOOLBARITEM, EvalCcRqCREATETOOLBARITEM);
+ AddCrossCallEntry (newTable, CcRqCREATETOOLBARSEPARATOR, EvalCcRqCREATETOOLBARSEPARATOR);
+ AddCrossCallEntries (gCrossCallProcedureTable, newTable);
+
+ return ios;
+}
+
+OS WinSetDoubleDownDist (int dd, OS ios)
+{
+ printf("WinSetDoubleDownDist --> Not Implemented\n");
+ return ios;
+}
diff --git a/Linux_C_12/cCrossCallxDI_121.h b/Linux_C_12/cCrossCallxDI_121.h new file mode 100644 index 0000000..fa75407 --- /dev/null +++ b/Linux_C_12/cCrossCallxDI_121.h @@ -0,0 +1,39 @@ +#include "util_121.h"
+
+
+/* Global data with external references: */
+extern OSWindowPtr ghTopDocWindow;
+extern int gComboSelection;
+extern BOOL gInMouseDown;
+extern BOOL gInKey;
+extern int gCurChar;
+
+/* Registered Windows class names:
+*/
+extern char SDIFrameClassName[]; /* Class for SDI frames. */
+extern char MDIFrameClassName[]; /* Class for MDI frames. */
+extern char SDIWindowClassName[]; /* Class for SDI windows (must have same length as MDIWindowClassName). */
+extern char MDIWindowClassName[]; /* Class for MDI windows (must have same length as SDIWindowClassName). */
+
+/* Managing the double down distance.
+*/
+extern OS WinSetDoubleDownDist (int dd, OS ios);
+
+/* Sending keyboard events to Clean thread:
+*/
+extern void SendKeyDownToClean (OSWindowPtr hwndParent, OSWindowPtr hwndChild, int c);
+extern void SendKeyStillDownToClean (OSWindowPtr hwndParent, OSWindowPtr hwndChild, int c);
+extern void SendKeyUpToClean (OSWindowPtr hwndParent, OSWindowPtr hwndChild, int c);
+
+/* Sending mouse events to Clean thread:
+*/
+extern void SendMouseUpToClean (OSWindowPtr hwndParent, OSWindowPtr hwndChild, int x, int y);
+extern void SendMouseStillDownToClean (OSWindowPtr hwndParent, OSWindowPtr hwndChild, int x, int y);
+extern void SendMouseStillUpToClean (OSWindowPtr hwndParent, OSWindowPtr hwndChild, int x, int y);
+extern void SendMouseDownToClean (OSWindowPtr hwndParent, OSWindowPtr hwndChild, int x, int y);
+
+/*
+ * InstallCrossCallxDI adds the proper cross call procedures to the
+ * cross call procedures managed by cCrossCall_121.c.
+ */
+extern OS InstallCrossCallxDI (OS ios);
diff --git a/Linux_C_12/cTCP_121.c b/Linux_C_12/cTCP_121.c new file mode 100644 index 0000000..e880b82 --- /dev/null +++ b/Linux_C_12/cTCP_121.c @@ -0,0 +1,781 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ Routines related to printing.
+********************************************************************************************/
+//#define FD_SETSIZE "maximal number of sockets to select on" (default is 64)
+
+#include <winsock.h>
+#include "util_121.h"
+#include "Clean.h"
+#include "cTCP_121.h"
+#define trace(x)
+
+/*
+------------------------ THE FUNCTION PROTOTYPES ------------------------------------------
+
+Naming convention: functions, which are called from Clean end with a "C". Function's that
+*/
+
+//************************************************
+// functions, which are called from Clean (semantic is explained in tcp.icl or ostcp.icl)
+
+int os_eom(SOCKET endpointRef);
+int os_disconnected(SOCKET endpointRef);
+int os_connectrequestavailable(SOCKET endpointRef);
+void abortedHost_syncC(CleanString inetAddr, int *errCode, int *ipAddr);
+void abortedHost_asyncC(CleanString inetAddr, int *errCode, HANDLE *endpointRef);
+void openTCP_ListenerC(int portNum, int *pErrCode, SOCKET *pEndpointRef);
+void acceptC(SOCKET endpointRef, int *pErrCode, int *pInetHost, SOCKET *pEndpointRef);
+void os_connectTCPC(int isIOProg, int block, int doTimeout, unsigned int stopTime,
+ int ipAddr, int portnum,
+ int *errCode, int *timeoutExpiredP, int *endpointRefP
+ );
+void sendC(SOCKET endpointRef, CleanString data, int begin, int nBytes, int *pErrCode, int *pSentBytes);
+void receiveC(SOCKET endpointRef, int maxSize, CleanString *data);
+int getRcvBuffSizeC();
+void resizeStringC(CleanString string, int newSize);
+int data_availableC(SOCKET endpointRef);
+void disconnectGracefulC(SOCKET endpointRef);
+void disconnectBrutalC(SOCKET endpointRef);
+void garbageCollectEndpointC(SOCKET endpointRef);
+void os_select_inetevents(SOCKET endpointRef, int receiverCategory,
+ int referenceCount, int getReceiveEvents, int getSendEvents,
+ int aborted
+ );
+void selectChC(int justForMac, int nonBlocking, int doTimeout, unsigned int stopTime,
+ SOCKET *pRChannels, int *justForMac2, SOCKET *pSChannels,
+ int *pErrCode
+ );
+int tcpPossibleC(void);
+
+//************************************************
+// other functions
+
+void StartUp(int abort);
+ // initialize winsock (if not started yet. uses global "tcpStartedUp")
+ // if succesful: tcpStartedUp==TRUE afterwards
+ // if not succesful && abort: aborts
+ // if not succesful && !abort: tcpStartedUp==FALSE afterwards
+void CleanUp(void);
+
+//************************************************
+// functions to deal with the endpoint dictionary:
+
+int insertNewDictionaryItem(SOCKET endpointRef);
+ // allocates memory for new dictionary item, initializes it as far as possible and
+ // adds it to the dictionary. returns error code: 0==ok, 1==not ok
+dictitem* lookup(SOCKET endpointRef);
+ // lookup entry (CFN)
+void setEndpointDataC(int endpointRef, int referenceCount,
+ int hasReceiveNotifier, int hasSendableNotifier, int aborted);
+ // set the corresponding fields of the entry
+void getEndpointDataC(int endpointRef, int *referenceCount,
+ int *hasReceiveNotifier, int *hasSendableNotifier, int *aborted);
+ // returns the corresponding fields of the entry
+void removeDictionaryItem(SOCKET endpointRef);
+ // remove one item via pointer manipulations (must not be called from notifier)
+
+//--------------------- GLOBAL VARIABLES ------------------------------------------
+
+// The inetEventQueue: To append easily a new item to the end of the list, "toLastNext" points
+// to the "next" field of the last list element (or to &inetEventQueue)
+
+
+dictitem *endpointDict = NULL;
+
+int tcpStartedUp = FALSE;
+int rcvBuffSize; // contains the size of the sockets internal buffer for receiving data.
+CleanString pRcvBuff;
+
+extern DNSInfo *DNSInfoList;
+extern HWND ghMainWindow;
+extern void (*exit_tcpip_function)(); // the function will be called, when the Clean
+ // program terminates
+
+//--------------------- FUNCTION IMPLEMENTATION -----------------------------------
+
+int tcpPossibleC(void)
+{
+ printf("tcpPossibleC\n");
+ StartUp(FALSE);
+ return tcpStartedUp;
+}
+
+int os_eom(SOCKET endpointRef)
+{
+ int err, err2;
+ char dummyBuffer[1];
+ dictitem *pDictitem;
+ printf("os_eom\n");
+
+ err = recv( endpointRef, dummyBuffer, 1, MSG_PEEK);
+ err2 = WSAGetLastError();
+ if (err>0)
+ return FALSE;
+ if (err<0 && err2==WSAEWOULDBLOCK)
+ return FALSE;
+ pDictitem = lookup(endpointRef);
+ trace( if (!pDictitem)
+ rMessageBox(NULL, MB_APPLMODAL, "in os_eom", "ERROR");)
+ if (pDictitem->availByteValid)
+ return FALSE;
+ if (err==0)
+ return TRUE;
+ return TRUE;
+}
+
+int os_disconnected(SOCKET endpointRef)
+{
+ int err;
+ char string[1];
+ dictitem *pDictitem;
+ printf("os_disconnected\n");
+
+ pDictitem = lookup(endpointRef);
+ trace( if (!pDictitem)
+ rMessageBox(NULL, MB_APPLMODAL, "in os_disconnected", "ERROR");)
+ if (pDictitem->disconnected)
+ return TRUE;
+ err = send( endpointRef, string, 0, 0);
+ if (err!=SOCKET_ERROR)
+ return FALSE;
+ else
+ return WSAGetLastError()!=WSAEWOULDBLOCK;
+ // only this error can happen with sockets that can still send
+}
+
+int os_connectrequestavailable(SOCKET endpointRef)
+{
+ FD_SET readSet;
+ TIMEVAL timeout;
+ int nr;
+ printf("os_connectrequestavailable\n");
+
+ FD_ZERO(&readSet);
+ FD_SET(endpointRef,&readSet);
+
+ timeout.tv_sec = 0; // Timeout in sec's
+ timeout.tv_usec = 0; // Timeout in microsec's
+ nr = select(0,&readSet,NULL,NULL,&timeout);
+ return nr>0 && FD_ISSET(endpointRef,&readSet);
+}
+
+#define majorVrs 1
+#define minorVrs 1
+
+void StartUp(int abort)
+{
+ printf("StartUp\n");
+ if (!tcpStartedUp)
+ {
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ int err, four=4;
+ SOCKET s;
+
+ wVersionRequested = MAKEWORD(majorVrs, minorVrs);
+ err = WSAStartup(wVersionRequested, &wsaData);
+ if (err != 0) {
+ if (abort) {
+ rMessageBox(NULL, MB_APPLMODAL, "ERROR", "can't start up winsock"
+ "\nprogram aborts");
+ ExitProcess (255);
+ }
+ else
+ return;
+ }
+
+ /* Confirm that the Windows Sockets DLL supports version mj.mi.*/
+ /* Note that if the DLL supports versions greater */
+ /* than mj.mi in addition to mj.mi, it will still return */
+ /* mj.mi in wVersion since that is the version we */
+ /* requested. */
+
+ if ( LOBYTE( wsaData.wVersion ) != majorVrs ||
+ HIBYTE( wsaData.wVersion ) != minorVrs ) {
+ WSACleanup();
+ if (abort) {
+ rMessageBox(NULL, MB_APPLMODAL, "ERROR", "winsock 1.1 or higher not available"
+ "\nprogram aborts");
+ ExitProcess (255);
+ }
+ else
+ return;
+ };
+
+ // initialize rcvBuffSize
+ s = socket(PF_INET, SOCK_STREAM, 0);
+ if (s==INVALID_SOCKET) {
+ rMessageBox(NULL, MB_APPLMODAL, "ERROR", "can't create a socket"
+ "\nprogram aborts");
+ ExitProcess (255);
+ };
+ if (getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char*) &rcvBuffSize, &four)) {
+ rMessageBox(NULL, MB_APPLMODAL, "ERROR", "can't call getsockopt"
+ "\nprogram aborts");
+ ExitProcess (255);
+ };
+
+ pRcvBuff = (CleanString) LocalAlloc(LMEM_FIXED, rcvBuffSize+4);
+ if (pRcvBuff==NULL) {
+ rMessageBox(NULL, MB_APPLMODAL, "ERROR", "out of memory"
+ "\nprogram aborts");
+ ExitProcess (255);
+ };
+ exit_tcpip_function = CleanUp;
+ tcpStartedUp = TRUE;
+ };
+}
+
+
+void lookupHost_syncC(CleanString inetAddr, int *errCode, int *ipAddrP)
+// error code: 0 ok, 1 error (also: addr doesn't exist)
+{
+ HOSTENT *hostentP;
+ unsigned long ipAddr;
+ printf("lookupHost_syncC\n");
+
+ StartUp(TRUE);
+ ipAddr = inet_addr(CleanStringCharacters(inetAddr));
+ if (ipAddr!=INADDR_NONE)
+ {
+ *errCode = 0;
+ *ipAddrP = ntohl(ipAddr);
+ return;
+ };
+ *errCode = 1;
+ hostentP = gethostbyname(CleanStringCharacters(inetAddr)); // string is alphanumerical
+ if (hostentP!=NULL)
+ { *ipAddrP = ntohl(((DWORD *)(*(hostentP->h_addr_list)))[0]);
+ if (*ipAddrP!=0)
+ *errCode = 0;
+ };
+}
+
+void lookupHost_asyncC(CleanString inetAddr, int *errCode, HANDLE *endpointRef)
+// errCode: 0 ok, 1 not ok
+{
+ DNSInfo *newPtr;
+ HANDLE dnsHdl;
+ printf("lookupHost_asyncC\n");
+
+ StartUp(TRUE);
+
+ *errCode = 1;
+ newPtr = (DNSInfo*) LocalAlloc(LMEM_FIXED,sizeof(DNSInfo));
+ if (newPtr==NULL) {
+ *errCode = 1;
+ return;
+ };
+
+ newPtr->next = DNSInfoList;
+ DNSInfoList = newPtr;
+
+ // and fill the fields and initiate DNS lookup.
+ dnsHdl = WSAAsyncGetHostByName(ghMainWindow,PM_DNS_EVENT,CleanStringCharacters(inetAddr),
+ DNSInfoList->junion.freeSpace,
+ MAXGETHOSTSTRUCT);
+ // this will cause the sending of a PM_DNS_EVENT message to the main window.
+ // The wParam value of that message will be equal to dnsHdl so that
+ // the ipAdress of the lookedup host can be retrieved then.
+ // The element of the List should be deallocated then
+ if (dnsHdl==0)
+ return;
+
+ DNSInfoList->dnsHdl = dnsHdl;
+ *errCode = 0;
+ *endpointRef = dnsHdl;
+}
+
+void openTCP_ListenerC(int portNum, int *pErrCode, SOCKET *pEndpointRef)
+// errCode: 0:ok; otherwise:not ok
+{
+ SOCKET s;
+ SOCKADDR_IN srvAdr;
+ printf("openTCP_ListenerC\n");
+
+ StartUp(TRUE);
+
+ *pErrCode = 1;
+
+ s = socket(PF_INET, SOCK_STREAM, 0);
+ if (s==INVALID_SOCKET)
+ return;
+
+ srvAdr.sin_family = AF_INET; // of course internet adress family
+ srvAdr.sin_addr.s_addr = INADDR_ANY; // internet address will be given after "accept"
+ srvAdr.sin_port = htons((short int)portNum);
+
+ *pErrCode = bind(s, (LPSOCKADDR) &srvAdr, sizeof(srvAdr));
+ if (*pErrCode) {
+ closesocket(s);
+ return;
+ };
+
+ *pErrCode = listen(s,5);
+ if (*pErrCode) {
+ closesocket(s);
+ return;
+ };
+ *pEndpointRef = s;
+
+ *pErrCode = insertNewDictionaryItem(s);
+ if (*pErrCode)
+ return;
+
+ setEndpointDataC(s, 1,0,0,0);
+}
+
+void acceptC(SOCKET listener, int *pErrCode, int *pInetHost, SOCKET *pEndpointRef)
+// errCode: 0:ok; otherwise:not ok
+{
+ SOCKET endpointRef;
+ SOCKADDR_IN clientAdr;
+ int clientAdrSize, tru;
+ printf("acceptC\n");
+
+ clientAdrSize = sizeof(clientAdr);
+ endpointRef = accept(listener,(LPSOCKADDR) &clientAdr, &clientAdrSize);
+ tru = TRUE;
+ ioctlsocket(endpointRef, FIONBIO, &tru); // set mode to non blocking
+ *pErrCode = endpointRef==INVALID_SOCKET;
+ if (*pErrCode)
+ return;
+
+ *pInetHost = ntohl(clientAdr.sin_addr.s_addr);
+ *pEndpointRef = endpointRef;
+
+ *pErrCode = insertNewDictionaryItem(endpointRef);
+ if (*pErrCode)
+ return;
+
+ setEndpointDataC(endpointRef,2,0,0,0);
+}
+
+void os_connectTCPC(int onlyForMac, int block, int doTimeout, unsigned int stopTime,
+ int ipAddr, int portnum,
+ int *errCodeP, int *timeoutExpiredP, int *endpointRefP)
+// errCode: 0 ok; 1 not ok
+{
+ SOCKET client;
+ SOCKADDR_IN srvAdr,clientAdr;
+ int err, tru;
+ printf("os_connectTCPC\n");
+
+ *errCodeP = 1;
+ *timeoutExpiredP = FALSE;
+
+ client = socket(PF_INET, SOCK_STREAM, 0);
+ if (client==INVALID_SOCKET)
+ return;
+
+ clientAdr.sin_family = AF_INET; // of course internet adress family
+ clientAdr.sin_addr.s_addr = INADDR_ANY; // internet adress will be given after "connect"
+ clientAdr.sin_port = 0; // the winsock library will choose a free number between 1024 and 5000
+
+ err = bind(client, (LPSOCKADDR) &clientAdr, sizeof(clientAdr));
+ if (err)
+ {
+ closesocket(client);
+ return;
+ };
+
+ srvAdr.sin_family = AF_INET; // of course internet adress family
+ srvAdr.sin_addr.s_addr = htonl(ipAddr);
+ srvAdr.sin_port = htons((short int)portnum);
+
+ tru = TRUE;
+
+ //////////////////////////////////////////////////////////////////////////
+ if (block && doTimeout)
+ {
+ ioctlsocket(client, FIONBIO, &tru); // set mode to non blocking
+ err = connect(client, (LPSOCKADDR) &srvAdr, sizeof(srvAdr));
+ if (!err) {
+ *errCodeP = 0;
+ *timeoutExpiredP = FALSE;
+ *endpointRefP = client;
+ }
+ else if (WSAGetLastError()!=WSAEWOULDBLOCK) {
+ closesocket(client);
+ return;
+ }
+ else
+ {
+ FD_SET writeSet, exptnSet;
+ TIMEVAL timeout;
+ unsigned int now;
+ int noOfWritableSockets, timeoutTicks;
+ FD_ZERO(&writeSet);
+ FD_SET(client,&writeSet);
+ FD_ZERO(&exptnSet);
+ FD_SET(client,&exptnSet);
+
+ now = GetTickCount();
+ timeoutTicks = ((int)stopTime) - ((int)now);
+ if (timeoutTicks<=0)
+ { // timeout expired
+ closesocket(client);
+ *timeoutExpiredP = TRUE;
+ return;
+ };
+ timeout.tv_sec = timeoutTicks / 1000; // Timeout in sec's
+ timeout.tv_usec = (timeoutTicks % 1000)*1000; // Timeout in microsec's
+ noOfWritableSockets = select(0,NULL,&writeSet,&exptnSet,&timeout);
+ *errCodeP = noOfWritableSockets<0
+ || (noOfWritableSockets>0 && FD_ISSET(client,&exptnSet));
+ *timeoutExpiredP = noOfWritableSockets==0;
+ *endpointRefP = client;
+ if (*errCodeP || *timeoutExpiredP) {
+ closesocket(client);
+ return;
+ };
+ };
+ };
+ ///////////////////////////////////////////////////////////////////////////
+ if (block && !doTimeout)
+ {
+ err = connect(client, (LPSOCKADDR) &srvAdr, sizeof(srvAdr));
+ if (err)
+ {
+ closesocket(client);
+ return;
+ };
+
+ ioctlsocket(client, FIONBIO, &tru); // set mode to non blocking
+
+ *errCodeP = 0;
+ *timeoutExpiredP = FALSE;
+ *endpointRefP = client;
+ };
+ ////////////////////////////////////////////////////////////////////////////
+ if (!block)
+ {
+
+ err = WSAAsyncSelect(client,ghMainWindow,PM_SOCKET_EVENT,FD_CONNECT);
+ if (err)
+ {
+ closesocket(client);
+ return;
+ };
+
+ err = connect(client, (LPSOCKADDR) &srvAdr, sizeof(srvAdr));
+ if (err==SOCKET_ERROR)
+ {
+ err = WSAGetLastError(); // a WSAEWOULDBLOCK error is a pretty harmless thing
+ if (err!=WSAEWOULDBLOCK)
+ {
+ closesocket(client);
+ return;
+ };
+ };
+ *errCodeP = 0;
+ *timeoutExpiredP = FALSE;
+ *endpointRefP = client;
+ };
+ //////////////////////////////////////////////////////////////////////////////
+
+ *errCodeP = insertNewDictionaryItem(client);
+ if (*errCodeP)
+ {
+ closesocket(client);
+ return;
+ };
+ if (block)
+ setEndpointDataC(client,2,0,0,0);
+ else
+ {
+ dictitem *ptr;
+ ptr = lookup(client);
+ ptr->referenceCount = 1;
+ ptr->hasReceiveNotifier = 0;
+ ptr->hasSendableNotifier = 1;
+ ptr->aborted = 0;
+ };
+}
+
+void sendC(SOCKET endpointRef, CleanString data, int begin, int nBytes,
+ int *pErrCode, int *pSentBytes)
+{
+ int sentBytes;
+ printf("sendC\n");
+
+ *pErrCode = 0;
+ sentBytes = send(endpointRef, CleanStringCharacters(data)+begin,nBytes, 0);
+ if (sentBytes==SOCKET_ERROR) {
+ int err;
+ sentBytes = 0;
+ err = WSAGetLastError();
+ if (err!=WSAEWOULDBLOCK) {
+ dictitem *pDictitem;
+ pDictitem = lookup(endpointRef);
+ trace( if (!pDictitem)
+ rMessageBox(NULL, MB_APPLMODAL, "in sendC", "ERROR");)
+ pDictitem->disconnected =1;
+ *pErrCode = 1;
+ }
+ };
+ *pSentBytes = sentBytes;
+}
+
+
+void receiveC(SOCKET endpointRef, int maxSize, CleanString *pReceived)
+{
+ int size, received;
+ dictitem *pDictitem;
+ printf("receiveC\n");
+
+ *pReceived = (CleanString) pRcvBuff;
+ size = maxSize<=0 ? rcvBuffSize : maxSize;
+ received = recv( endpointRef, CleanStringCharacters(pRcvBuff), size, 0);
+ pDictitem = lookup(endpointRef);
+ trace( if (!pDictitem)
+ rMessageBox(NULL, MB_APPLMODAL, "in receiveC", "ERROR");)
+ if (received>0) {
+ pDictitem->availByteValid = 0;
+ CleanStringLength(pRcvBuff) = received;
+ }
+ else if (pDictitem->availByteValid) {
+ CleanStringCharacters(pRcvBuff)[0] = pDictitem->availByte;
+ pDictitem->availByteValid = 0;
+ CleanStringLength(pRcvBuff) = 1;
+ }
+ else
+ CleanStringLength(pRcvBuff) = 0;
+}
+
+int data_availableC(SOCKET endpointRef)
+{
+ dictitem *pDictitem;
+ int err;
+ printf("data_availableC\n");
+
+ pDictitem = lookup(endpointRef);
+ trace( if (!pDictitem)
+ rMessageBox(NULL, MB_APPLMODAL, "in data_availableC",
+ "ERROR\nendpoint %i not found", endpointRef);)
+ if (pDictitem->availByteValid)
+ return TRUE;
+ err = recv( endpointRef, &pDictitem->availByte, 1, MSG_PEEK);
+ if (err>0) {
+ pDictitem->availByteValid = 1;
+ return TRUE;
+ };
+ return FALSE;
+}
+
+void disconnectGracefulC(SOCKET endpointRef)
+{
+ printf("disconnecteGracefulC\n");
+ shutdown(endpointRef,1); // 1: graceful
+}
+
+void disconnectBrutalC(SOCKET endpointRef)
+{
+ LINGER linger;
+ printf("disconnectBrutalC\n");
+
+ linger.l_onoff = 1;
+ linger.l_linger = 0;
+ setsockopt(endpointRef, SOL_SOCKET, SO_LINGER, (char*) &linger, sizeof(linger));
+}
+
+void garbageCollectEndpointC(SOCKET endpointRef)
+{
+ dictitem *pDictitem;
+ printf("garbageCollectEndpointC\n");
+
+ pDictitem = lookup(endpointRef);
+ if (pDictitem!=NULL && pDictitem->referenceCount==0) {
+ closesocket(endpointRef);
+ removeDictionaryItem(endpointRef);
+ };
+}
+
+
+void os_select_inetevents( SOCKET endpointRef, int receiverCategory,
+ int referenceCount, int getReceiveEvents, int getSendEvents,
+ int aborted)
+{
+ printf("os_select_inetevents\n");
+ setEndpointDataC(endpointRef, referenceCount, getReceiveEvents, getSendEvents, aborted);
+}
+
+void initFD_SET(FD_SET **ppSet, SOCKET sockets[], int n)
+{
+ int i;
+ FD_SET *pSet;
+ printf("initFD_SET\n");
+
+ pSet = (FD_SET*) LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, n*sizeof(SOCKET)+sizeof(u_int));
+ for(i=0; i<n; i++)
+ FD_SET(sockets[i], pSet);
+ *ppSet = pSet;
+}
+
+void selectChC( int justForMac, int nonBlocking, int doTimeout, unsigned int stopTime,
+ SOCKET *pRChannels, int *justForMac2, SOCKET *pSChannels,
+ int *pErrCode)
+// error code: 0=ok; 1=timeout expired, 3=other errors
+{
+ int nRChannels, nSChannels, i;
+ FD_SET *pReadSet, *pWriteSet;
+ TIMEVAL timeout;
+ unsigned int now;
+ int n, timeoutTicks;
+ printf("selectChC\n");
+
+ nRChannels = (int) pRChannels[-2];
+ nSChannels = (int) pSChannels[-2];
+ if (doTimeout)
+ {
+ now = GetTickCount();
+ timeoutTicks = nonBlocking ? 0 : ((int)stopTime) - ((int)now);
+ if (timeoutTicks<0)
+ {
+ *pErrCode = 1;
+ return;
+ };
+ timeout.tv_sec = timeoutTicks / 1000; // Timeout in sec's
+ timeout.tv_usec = (timeoutTicks % 1000)*1000; // Timeout in microsec's
+ };
+ initFD_SET(&pReadSet, pRChannels, nRChannels);
+ initFD_SET(&pWriteSet, pSChannels, nSChannels);
+ n = select(0,pReadSet,pWriteSet,NULL, doTimeout ? &timeout : NULL);
+ if (n==0)
+ { // timeout expired
+ *pErrCode = 1;
+ return;
+ };
+ if (n<0)
+ {
+ *pErrCode = 3;
+ return;
+ };
+ for(i=0; i<nRChannels; i++)
+ if (FD_ISSET(pRChannels[i], pReadSet))
+ pRChannels[i] = 0;
+ for(i=0; i<nSChannels; i++)
+ if (FD_ISSET(pSChannels[i], pWriteSet))
+ pSChannels[i] = 0;
+ *pErrCode = 0;
+}
+
+// this function is called from Cleans runtime system via *exit_tcpip_function
+void CleanUp(void)
+{
+ dictitem *pDictitem, *pTemp;
+ int referenceCount;
+ pDictitem = endpointDict;
+ printf("CleanUp\n");
+
+ while (pDictitem) {
+ referenceCount = pDictitem->referenceCount;
+ if (referenceCount!=0) {
+ if (referenceCount==1 && pDictitem->aborted) {
+ disconnectBrutalC(pDictitem->endpointRef);
+ }
+ else
+ disconnectGracefulC(pDictitem->endpointRef);
+ closesocket(pDictitem->endpointRef);
+ };
+ pTemp = pDictitem;
+ pDictitem = pDictitem->next;
+ GlobalFree((char*) pTemp);
+ };
+ WSACleanup();
+}
+
+
+//------------------------ FUNCTION IMPLEMENTATIONS FOR THE ENDPOINT DICTIONARY -------
+
+int insertNewDictionaryItem(SOCKET endpointRef)
+{
+ dictitem *newItem;
+ printf("insertNewDictionaryItem\n");
+
+ newItem = (dictitem*) GlobalAlloc(LMEM_FIXED, sizeof(dictitem));
+ if (newItem==NULL)
+ return 1;
+
+ newItem->endpointRef = endpointRef;
+ newItem->next = endpointDict;
+ newItem->availByteValid = 0;
+ newItem->aborted = 0;
+ newItem->disconnected = 0;
+ endpointDict = newItem;
+
+ return 0;
+}
+
+dictitem* lookup(SOCKET endpointRef)
+{
+ dictitem *ptr=endpointDict;
+ printf("lookup\n");
+ while (ptr!=NULL && (ptr->endpointRef!=endpointRef))
+ ptr = ptr->next;
+
+ return ptr;
+}
+
+void setEndpointDataC( int endpointRef, int referenceCount,
+ int hasReceiveNotifier, int hasSendableNotifier, int aborted)
+{
+ dictitem *ptr;
+ printf("setEndpointDataC\n");
+ ptr = lookup((SOCKET) endpointRef);
+
+ if (ptr!=NULL)
+ { ptr->referenceCount = referenceCount;
+ ptr->hasReceiveNotifier = hasReceiveNotifier ? 1 : 0;
+ ptr->hasSendableNotifier = hasSendableNotifier ? 1 : 0;
+ ptr->aborted = aborted ? 1 : 0;
+ };
+ WSAAsyncSelect(endpointRef, ghMainWindow, PM_SOCKET_EVENT,
+ (hasReceiveNotifier ? FD_READ | FD_OOB | FD_ACCEPT | FD_CLOSE : 0)
+ | (hasSendableNotifier ? FD_WRITE | FD_CLOSE : 0));
+}
+
+
+void getEndpointDataC( int endpointRef, int *referenceCount,
+ int *hasReceiveNotifier, int *hasSendableNotifier, int *aborted)
+{
+ dictitem *ptr;
+ printf("getEndpointDataC\n");
+ ptr = lookup((SOCKET) endpointRef);
+
+ if (ptr!=NULL)
+ { *referenceCount = ptr->referenceCount;
+ *hasReceiveNotifier = ptr->hasReceiveNotifier!=0;
+ *hasSendableNotifier = ptr->hasSendableNotifier!=0;
+ *aborted = ptr->aborted!=0;
+ };
+}
+
+
+void removeDictionaryItem(SOCKET endpointRef)
+// the dictionary MUST contain a valid item with the endpointRef
+{
+ dictitem **ptr, *temp;
+ int notRemoved;
+ printf("removeDictionaryItem\n");
+
+ ptr = &endpointDict;
+ notRemoved = TRUE;
+ while(notRemoved)
+ if ((*ptr)->endpointRef==endpointRef)
+ {
+ temp = *ptr;
+ *ptr = (*ptr)->next;
+ GlobalFree((char*) temp);
+ notRemoved = FALSE;
+ }
+ else
+ ptr = &((*ptr)->next);
+}
diff --git a/Linux_C_12/cTCP_121.h b/Linux_C_12/cTCP_121.h new file mode 100644 index 0000000..0707781 --- /dev/null +++ b/Linux_C_12/cTCP_121.h @@ -0,0 +1,59 @@ +#ifndef __CTCP__
+#define __CTCP__
+
+#if defined(mingw32_TARGET_OS)
+#include <winsock.h>
+
+typedef int DNSHdl;
+
+struct DNSInfo
+ { struct DNSInfo *next;
+ HANDLE dnsHdl;
+ union { struct hostent Hostent;
+ char freeSpace[MAXGETHOSTSTRUCT];
+ }
+ junion;
+ };
+typedef struct DNSInfo DNSInfo;
+
+/* the dictionary items */
+struct dictitem
+ { SOCKET endpointRef;
+ struct dictitem *next;
+ char availByte;
+ unsigned availByteValid : 1;
+ unsigned referenceCount : 2;
+ unsigned hasReceiveNotifier : 1;
+ /*
+ * three kinds of receivers: receivers for established connections,
+ * receivers for dns requests, receivers for asynchronous connect
+ */
+ unsigned hasSendableNotifier : 1;
+ unsigned aborted : 1;
+ unsigned disconnected : 1;
+ };
+typedef struct dictitem dictitem;
+
+#define IE_CONNECTREQUEST 0x0001
+#define IE_RECEIVED 0x0004
+#define IE_EOM 0x0010
+#define IE_SENDABLE 0x0100
+#define IE_DISCONNECTED 0x0011
+#define IE_IPADDRESSFOUND 0x2000000F
+#define IE_IPADDRESSNOTFOUND 0x20000010
+#define IE_ASYNCCONNECTCOMPLETE 0x0002
+#define IE_ASYNCCONNECTFAILED 0x0003
+
+#define ListenerReceiver 0
+#define RChanReceiver 1
+#define SChanReceiver 2
+#define DNSReceiver 3
+#define ConnectReceiver 4
+
+/* PA: InitSockets has no definition.
+void InitSockets();
+*/
+extern dictitem* lookup(SOCKET endpointRef);
+#endif
+
+#endif
diff --git a/Linux_C_12/cdebug_121.c b/Linux_C_12/cdebug_121.c new file mode 100644 index 0000000..9b4a438 --- /dev/null +++ b/Linux_C_12/cdebug_121.c @@ -0,0 +1,39 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ Routines useful for debugging.
+********************************************************************************************/
+#include "cdebug_121.h"
+#include "time.h"
+
+int Rand (void)
+{
+ static int holdrand;
+ static int randinited = 0;
+ printf("Rand\n");
+
+ if (!randinited)
+ {
+ holdrand = (int) 0; //GetTickCount ();
+ randinited = -1;
+ }
+
+ holdrand = holdrand * 214013 + 2531011;
+
+ return ((holdrand >> 16) & 0x7fff);
+}
+
+OS ConsolePrint (CLEAN_STRING cleanstr, OS os)
+{
+ char *cstr;
+ printf("ConsolePrint\n");
+
+ cstr = cstring (cleanstr);
+ rprintf (cstr);
+ return os;
+}
diff --git a/Linux_C_12/cdebug_121.h b/Linux_C_12/cdebug_121.h new file mode 100644 index 0000000..f8b830f --- /dev/null +++ b/Linux_C_12/cdebug_121.h @@ -0,0 +1,5 @@ +#include "util_121.h"
+#include "clean_types.h"
+
+extern int Rand (void);
+extern OS ConsolePrint (CLEAN_STRING,OS);
diff --git a/Linux_C_12/clean_types.h b/Linux_C_12/clean_types.h new file mode 100644 index 0000000..d4e9b93 --- /dev/null +++ b/Linux_C_12/clean_types.h @@ -0,0 +1,37 @@ +# undef DEBUG
+#include <stdio.h>
+#if 0
+typedef struct clean_string
+{
+ int length;
+#ifdef SOLARIS
+ char characters[4];
+#else
+ char characters[0];
+#endif
+} *CLEAN_STRING;
+#endif
+
+typedef struct clean_file
+{
+ int number;
+ int position;
+} CLEAN_FILE;
+
+struct file {
+ FILE *file;
+ unsigned long position;
+ unsigned long file_length;
+ char *file_name;
+ long file_number;
+ int device_number;
+ short mode;
+ short filler_1;
+ long filler_2;
+};
+
+#define CLOSED_FILE 0
+#define READ_FILE 1
+#define WRITE_FILE 2
+
+extern struct file file_table[];
diff --git a/Linux_C_12/config.h b/Linux_C_12/config.h new file mode 100644 index 0000000..57baec8 --- /dev/null +++ b/Linux_C_12/config.h @@ -0,0 +1,1080 @@ +/* mk/config.h. Generated automatically by configure. */
+/* mk/config.h.in. Generated automatically from configure.in by autoheader. */
+/* acconfig.h
+
+ Descriptive text for the C preprocessor macros that
+ the fptools configuration script can define.
+ The current version may not use all of them; autoheader copies the ones
+ your configure.in uses into your configuration header file templates.
+
+ The entries are in sort -df order: alphabetical, case insensitive,
+ ignoring punctuation (such as underscores). Although this order
+ can split up related entries, it makes it easier to check whether
+ a given entry is in the file.
+
+ Leave the following blank line there!! Autoheader needs it. */
+
+
+
+
+/* Define to alignment constraint on chars */
+#define ALIGNMENT_CHAR 1
+
+/* Define to alignment constraint on doubles */
+#define ALIGNMENT_DOUBLE 4
+
+/* Define to alignment constraint on floats */
+#define ALIGNMENT_FLOAT 4
+
+/* Define to alignment constraint on ints */
+#define ALIGNMENT_INT 4
+
+/* Define to alignment constraint on longs */
+#define ALIGNMENT_LONG 4
+
+/* Define to alignment constraint on long longs */
+#define ALIGNMENT_LONG_LONG 4
+
+/* Define to alignment constraint on shorts */
+#define ALIGNMENT_SHORT 2
+
+/* Define to alignment constraint on unsigned chars */
+#define ALIGNMENT_UNSIGNED_CHAR 1
+
+/* Define to alignment constraint on unsigned ints */
+#define ALIGNMENT_UNSIGNED_INT 4
+
+/* Define to alignment constraint on unsigned longs */
+#define ALIGNMENT_UNSIGNED_LONG 4
+
+/* Define to alignment constraint on unsigned long longs */
+#define ALIGNMENT_UNSIGNED_LONG_LONG 4
+
+/* Define to alignment constraint on unsigned shorts */
+#define ALIGNMENT_UNSIGNED_SHORT 2
+
+/* Define to alignment constraint on void pointers */
+#define ALIGNMENT_VOID_P 4
+
+/* The value of E2BIG. */
+#define CCONST_E2BIG 7
+
+/* The value of EACCES. */
+#define CCONST_EACCES 13
+
+/* The value of EADDRINUSE. */
+#define CCONST_EADDRINUSE 98
+
+/* The value of EADDRNOTAVAIL. */
+#define CCONST_EADDRNOTAVAIL 99
+
+/* The value of EADV. */
+#define CCONST_EADV 68
+
+/* The value of EAFNOSUPPORT. */
+#define CCONST_EAFNOSUPPORT 97
+
+/* The value of EAGAIN. */
+#define CCONST_EAGAIN 11
+
+/* The value of EALREADY. */
+#define CCONST_EALREADY 114
+
+/* The value of EBADF. */
+#define CCONST_EBADF 9
+
+/* The value of EBADMSG. */
+#define CCONST_EBADMSG 74
+
+/* The value of EBADRPC. */
+#define CCONST_EBADRPC -1
+
+/* The value of EBUSY. */
+#define CCONST_EBUSY 16
+
+/* The value of ECHILD. */
+#define CCONST_ECHILD 10
+
+/* The value of ECOMM. */
+#define CCONST_ECOMM 70
+
+/* The value of ECONNABORTED. */
+#define CCONST_ECONNABORTED 103
+
+/* The value of ECONNREFUSED. */
+#define CCONST_ECONNREFUSED 111
+
+/* The value of ECONNRESET. */
+#define CCONST_ECONNRESET 104
+
+/* The value of EDEADLK. */
+#define CCONST_EDEADLK 35
+
+/* The value of EDESTADDRREQ. */
+#define CCONST_EDESTADDRREQ 89
+
+/* The value of EDIRTY. */
+#define CCONST_EDIRTY -1
+
+/* The value of EDOM. */
+#define CCONST_EDOM 33
+
+/* The value of EDQUOT. */
+#define CCONST_EDQUOT 122
+
+/* The value of EEXIST. */
+#define CCONST_EEXIST 17
+
+/* The value of EFAULT. */
+#define CCONST_EFAULT 14
+
+/* The value of EFBIG. */
+#define CCONST_EFBIG 27
+
+/* The value of EFTYPE. */
+#define CCONST_EFTYPE -1
+
+/* The value of EHOSTDOWN. */
+#define CCONST_EHOSTDOWN 112
+
+/* The value of EHOSTUNREACH. */
+#define CCONST_EHOSTUNREACH 113
+
+/* The value of EIDRM. */
+#define CCONST_EIDRM 43
+
+/* The value of EILSEQ. */
+#define CCONST_EILSEQ 84
+
+/* The value of EINPROGRESS. */
+#define CCONST_EINPROGRESS 115
+
+/* The value of EINTR. */
+#define CCONST_EINTR 4
+
+/* The value of EINVAL. */
+#define CCONST_EINVAL 22
+
+/* The value of EIO. */
+#define CCONST_EIO 5
+
+/* The value of EISCONN. */
+#define CCONST_EISCONN 106
+
+/* The value of EISDIR. */
+#define CCONST_EISDIR 21
+
+/* The value of ELOOP. */
+#define CCONST_ELOOP 40
+
+/* The value of EMFILE. */
+#define CCONST_EMFILE 24
+
+/* The value of EMLINK. */
+#define CCONST_EMLINK 31
+
+/* The value of EMSGSIZE. */
+#define CCONST_EMSGSIZE 90
+
+/* The value of EMULTIHOP. */
+#define CCONST_EMULTIHOP 72
+
+/* The value of ENAMETOOLONG. */
+#define CCONST_ENAMETOOLONG 36
+
+/* The value of ENETDOWN. */
+#define CCONST_ENETDOWN 100
+
+/* The value of ENETRESET. */
+#define CCONST_ENETRESET 102
+
+/* The value of ENETUNREACH. */
+#define CCONST_ENETUNREACH 101
+
+/* The value of ENFILE. */
+#define CCONST_ENFILE 23
+
+/* The value of ENOBUFS. */
+#define CCONST_ENOBUFS 105
+
+/* The value of ENODATA. */
+#define CCONST_ENODATA 61
+
+/* The value of ENODEV. */
+#define CCONST_ENODEV 19
+
+/* The value of ENOENT. */
+#define CCONST_ENOENT 2
+
+/* The value of ENOEXEC. */
+#define CCONST_ENOEXEC 8
+
+/* The value of ENOLCK. */
+#define CCONST_ENOLCK 37
+
+/* The value of ENOLINK. */
+#define CCONST_ENOLINK 67
+
+/* The value of ENOMEM. */
+#define CCONST_ENOMEM 12
+
+/* The value of ENOMSG. */
+#define CCONST_ENOMSG 42
+
+/* The value of ENONET. */
+#define CCONST_ENONET 64
+
+/* The value of ENOPROTOOPT. */
+#define CCONST_ENOPROTOOPT 92
+
+/* The value of ENOSPC. */
+#define CCONST_ENOSPC 28
+
+/* The value of ENOSR. */
+#define CCONST_ENOSR 63
+
+/* The value of ENOSTR. */
+#define CCONST_ENOSTR 60
+
+/* The value of ENOSYS. */
+#define CCONST_ENOSYS 38
+
+/* The value of ENOTBLK. */
+#define CCONST_ENOTBLK 15
+
+/* The value of ENOTCONN. */
+#define CCONST_ENOTCONN 107
+
+/* The value of ENOTDIR. */
+#define CCONST_ENOTDIR 20
+
+/* The value of ENOTEMPTY. */
+#define CCONST_ENOTEMPTY 39
+
+/* The value of ENOTSOCK. */
+#define CCONST_ENOTSOCK 88
+
+/* The value of ENOTTY. */
+#define CCONST_ENOTTY 25
+
+/* The value of ENXIO. */
+#define CCONST_ENXIO 6
+
+/* The value of EOPNOTSUPP. */
+#define CCONST_EOPNOTSUPP 95
+
+/* The value of EPERM. */
+#define CCONST_EPERM 1
+
+/* The value of EPFNOSUPPORT. */
+#define CCONST_EPFNOSUPPORT 96
+
+/* The value of EPIPE. */
+#define CCONST_EPIPE 32
+
+/* The value of EPROCLIM. */
+#define CCONST_EPROCLIM -1
+
+/* The value of EPROCUNAVAIL. */
+#define CCONST_EPROCUNAVAIL -1
+
+/* The value of EPROGMISMATCH. */
+#define CCONST_EPROGMISMATCH -1
+
+/* The value of EPROGUNAVAIL. */
+#define CCONST_EPROGUNAVAIL -1
+
+/* The value of EPROTO. */
+#define CCONST_EPROTO 71
+
+/* The value of EPROTONOSUPPORT. */
+#define CCONST_EPROTONOSUPPORT 93
+
+/* The value of EPROTOTYPE. */
+#define CCONST_EPROTOTYPE 91
+
+/* The value of ERANGE. */
+#define CCONST_ERANGE 34
+
+/* The value of EREMCHG. */
+#define CCONST_EREMCHG 78
+
+/* The value of EREMOTE. */
+#define CCONST_EREMOTE 66
+
+/* The value of EROFS. */
+#define CCONST_EROFS 30
+
+/* The value of ERPCMISMATCH. */
+#define CCONST_ERPCMISMATCH -1
+
+/* The value of ERREMOTE. */
+#define CCONST_ERREMOTE -1
+
+/* The value of ESHUTDOWN. */
+#define CCONST_ESHUTDOWN 108
+
+/* The value of ESOCKTNOSUPPORT. */
+#define CCONST_ESOCKTNOSUPPORT 94
+
+/* The value of ESPIPE. */
+#define CCONST_ESPIPE 29
+
+/* The value of ESRCH. */
+#define CCONST_ESRCH 3
+
+/* The value of ESRMNT. */
+#define CCONST_ESRMNT 69
+
+/* The value of ESTALE. */
+#define CCONST_ESTALE 116
+
+/* The value of ETIME. */
+#define CCONST_ETIME 62
+
+/* The value of ETIMEDOUT. */
+#define CCONST_ETIMEDOUT 110
+
+/* The value of ETOOMANYREFS. */
+#define CCONST_ETOOMANYREFS 109
+
+/* The value of ETXTBSY. */
+#define CCONST_ETXTBSY 26
+
+/* The value of EUSERS. */
+#define CCONST_EUSERS 87
+
+/* The value of EWOULDBLOCK. */
+#define CCONST_EWOULDBLOCK 11
+
+/* The value of EXDEV. */
+#define CCONST_EXDEV 18
+
+/* Define if time.h or sys/time.h define the altzone variable */
+/* #undef HAVE_ALTZONE */
+
+/* Define if you have /bin/sh */
+#define HAVE_BIN_SH 1
+
+/* Define if the HaskellSupport.framework is installed (Mac OS X only) */
+/* #undef HAVE_FRAMEWORK_HASKELLSUPPORT */
+
+/* Define if gcc supports -mno-omit-leaf-frame-pointer */
+#define HAVE_GCC_MNO_OMIT_LFPTR 1
+
+/* Define if you have the GetModuleFileName function. */
+/* #undef HAVE_GETMODULEFILENAME */
+
+/* Define if in_addr_t is available */
+#define HAVE_IN_ADDR_T 1
+
+/* Define if you need -ldl to get dlopen() */
+#define HAVE_LIBDL 1
+
+/* Define if you have the mingwex library. */
+/* #undef HAVE_MINGWEX */
+
+/* Define if struct msghdr contains msg_accrights field */
+/* #undef HAVE_MSGHDR_MSG_ACCRIGHTS */
+
+/* Define if struct msghdr contains msg_control field */
+#define HAVE_MSGHDR_MSG_CONTROL 1
+
+/* Define if RTLD_GLOBAL is available */
+#define HAVE_RTLDGLOBAL 1
+
+/* Define if RTLD_LOCAL is available */
+#define HAVE_RTLDLOCAL 1
+
+/* Define if we can see RTLD_NEXT in dlfcn.h */
+/* #undef HAVE_RTLDNEXT */
+
+/* Define if we can see RTLD_NOW in dlfcn.h */
+#define HAVE_RTLDNOW 1
+
+/* Define if usleep returns void */
+/* #undef USLEEP_RETURNS_VOID */
+
+/* Define if it looks like a Linux sendfile(2) implementation */
+#define HAVE_LINUX_SENDFILE 1
+
+/* Define if it looks like a BSDish sendfile(2) implementation */
+/* #undef HAVE_BSD_SENDFILE */
+
+/* Define if C compiler supports long long types */
+#define HAVE_LONG_LONG 1
+
+/* Define if fcntl.h defines O_BINARY */
+/* #undef HAVE_O_BINARY */
+
+/* Define if compiler supports prototypes. */
+#define HAVE_PROTOTYPES 1
+
+/* Define if readline/readline.h and readline/history.h exist */
+#define HAVE_READLINE_HEADERS 1
+
+/* Define if readline plus any additional libs needed for it exist */
+#define HAVE_READLINE_LIBS 1
+
+/* Define if readline has version >= 4.0. */
+#define HAVE_READLINE_4 1
+
+/* Define if readline has version >= 4.2. */
+#define HAVE_READLINE_4_2 1
+
+/* Define if <unistd.h> defines _SC_GETGR_R_SIZE_MAX */
+/* #undef HAVE_SC_GETGR_R_SIZE_MAX */
+
+/* Define if <unistd.h> defines _SC_GETPW_R_SIZE_MAX */
+/* #undef HAVE_SC_GETPW_R_SIZE_MAX */
+
+/* Define if you have the sigpoll() function */
+#define HAVE_SIGPOLL 1
+
+/* Define if time.h or sys/time.h define the timezone variable */
+#define HAVE_TIMEZONE 1
+
+/* Define if you support the production (and use) of Win32 DLLs. */
+/* #undef HAVE_WIN32_DLL_SUPPORT */
+
+/* Define if you have the WinExec function. */
+/* #undef HAVE_WINEXEC */
+
+/* Define to Haskell type for blkcnt_t */
+#define HTYPE_BLKCNT_T Int32
+
+/* Define to Haskell type for cc_t */
+#define HTYPE_CC_T Word8
+
+/* Define to Haskell type for char */
+#define HTYPE_CHAR Int8
+
+/* Define to Haskell type for clock_t */
+#define HTYPE_CLOCK_T Int32
+
+/* Define to Haskell type for dev_t */
+#define HTYPE_DEV_T Word64
+
+/* Define to Haskell type for signed double */
+#define HTYPE_DOUBLE Double
+
+/* Define to Haskell type for float */
+#define HTYPE_FLOAT Float
+
+/* Define to Haskell type for gid_t */
+#define HTYPE_GID_T Word32
+
+/* Define to Haskell type for GLbitfield */
+/* #undef HTYPE_GLBITFIELD */
+
+/* Define to Haskell type for GLboolean */
+/* #undef HTYPE_GLBOOLEAN */
+
+/* Define to Haskell type for GLbyte */
+/* #undef HTYPE_GLBYTE */
+
+/* Define to Haskell type for GLclampd */
+/* #undef HTYPE_GLCLAMPD */
+
+/* Define to Haskell type for GLclampf */
+/* #undef HTYPE_GLCLAMPF */
+
+/* Define to Haskell type for GLdouble */
+/* #undef HTYPE_GLDOUBLE */
+
+/* Define to Haskell type for GLenum */
+/* #undef HTYPE_GLENUM */
+
+/* Define to Haskell type for GLfloat */
+/* #undef HTYPE_GLFLOAT */
+
+/* Define to Haskell type for GLint */
+/* #undef HTYPE_GLINT */
+
+/* Define to Haskell type for GLshort */
+/* #undef HTYPE_GLSHORT */
+
+/* Define to Haskell type for GLsizei */
+/* #undef HTYPE_GLSIZEI */
+
+/* Define to Haskell type for GLubyte */
+/* #undef HTYPE_GLUBYTE */
+
+/* Define to Haskell type for GLuint */
+/* #undef HTYPE_GLUINT */
+
+/* Define to Haskell type for GLushort */
+/* #undef HTYPE_GLUSHORT */
+
+/* Define to Haskell type for int */
+#define HTYPE_INT Int32
+
+/* Define to Haskell type for ino_t */
+#define HTYPE_INO_T Word32
+
+/* Define to Haskell type for long */
+#define HTYPE_LONG Int32
+
+/* Define to Haskell type for long long */
+#define HTYPE_LONG_LONG Int64
+
+/* Define to Haskell type for mode_t */
+#define HTYPE_MODE_T Word32
+
+/* Define to Haskell type for nlink_t */
+#define HTYPE_NLINK_T Word32
+
+/* Define to Haskell type for off_t */
+#define HTYPE_OFF_T Int32
+
+/* Define to Haskell type for pid_t */
+#define HTYPE_PID_T Int32
+
+/* Define to Haskell type for ptrdiff_t */
+#define HTYPE_PTRDIFF_T Int32
+
+/* Define to Haskell type for short */
+#define HTYPE_SHORT Int16
+
+/* Define to Haskell type for sig_atomic_t */
+#define HTYPE_SIG_ATOMIC_T Int32
+
+/* Define to Haskell type for signed char */
+#define HTYPE_SIGNED_CHAR Int8
+
+/* Define to Haskell type for size_t */
+#define HTYPE_SIZE_T Word32
+
+/* Define to Haskell type for speed_t */
+#define HTYPE_SPEED_T Word32
+
+/* Define to Haskell type for ssize_t */
+#define HTYPE_SSIZE_T Int32
+
+/* Define to Haskell type for time_t */
+#define HTYPE_TIME_T Int32
+
+/* Define to Haskell type for tcflag_t */
+#define HTYPE_TCFLAG_T Word32
+
+/* Define to Haskell type for uid_t */
+#define HTYPE_UID_T Word32
+
+/* Define to Haskell type for unsigned char */
+#define HTYPE_UNSIGNED_CHAR Word8
+
+/* Define to Haskell type for unsigned int */
+#define HTYPE_UNSIGNED_INT Word32
+
+/* Define to Haskell type for unsigned long */
+#define HTYPE_UNSIGNED_LONG Word32
+
+/* Define to Haskell type for unsigned long long */
+#define HTYPE_UNSIGNED_LONG_LONG Word64
+
+/* Define to Haskell type for unsigned short */
+#define HTYPE_UNSIGNED_SHORT Word16
+
+/* Define to Haskell type for wchar_t */
+#define HTYPE_WCHAR_T Int32
+
+/* Define if C Symbols have a leading underscore added by the compiler */
+/* #undef LEADING_UNDERSCORE */
+
+/* Define to the type of the timezone variable (usually long or time_t) */
+#define TYPE_TIMEZONE time_t
+
+/* Define if signal handlers have type void (*)(int)
+ * (Otherwise, they're assumed to have type int (*)(void).)
+ */
+#define VOID_INT_SIGNALS 1
+
+
+/* Leave that blank line there!! Autoheader needs it.
+ If you're adding to this file, keep in mind:
+ The entries are in sort -df order: alphabetical, case insensitive,
+ ignoring punctuation (such as underscores). */
+
+
+/* autoheader doesn't grok AC_CHECK_LIB_NOWARN so we have to add them
+ manually. */
+
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+ systems. This function is required for `alloca.c' support on those systems.
+ */
+/* #undef CRAY_STACKSEG_END */
+
+/* Define if using `alloca.c'. */
+/* #undef C_ALLOCA */
+
+/* Define if you have the `access' function. */
+#define HAVE_ACCESS 1
+
+/* Define if you have `alloca', as a function or macro. */
+#define HAVE_ALLOCA 1
+
+/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
+#define HAVE_ALLOCA_H 1
+
+/* Define if you have the <arpa/inet.h> header file. */
+#define HAVE_ARPA_INET_H 1
+
+/* Define if you have the <assert.h> header file. */
+#define HAVE_ASSERT_H 1
+
+/* Define if you have the <bfd.h> header file. */
+#define HAVE_BFD_H 1
+
+/* Define if you have the <conio.h> header file. */
+/* #undef HAVE_CONIO_H */
+
+/* Define if you have the <console.h> header file. */
+/* #undef HAVE_CONSOLE_H */
+
+/* Define if you have the <ctype.h> header file. */
+#define HAVE_CTYPE_H 1
+
+/* Define if you have the <dirent.h> header file. */
+#define HAVE_DIRENT_H 1
+
+/* Define if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define if you have the `dlopen' function. */
+#define HAVE_DLOPEN 1
+
+/* Define if you have the <dl.h> header file. */
+/* #undef HAVE_DL_H */
+
+/* Define if you have the <dos.h> header file. */
+/* #undef HAVE_DOS_H */
+
+/* Define if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define if you have the `farcalloc' function. */
+/* #undef HAVE_FARCALLOC */
+
+/* Define if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define if you have the `fgetpos' function. */
+#define HAVE_FGETPOS 1
+
+/* Define if you have the <Files.h> header file. */
+/* #undef HAVE_FILES_H */
+
+/* Define if you have the <float.h> header file. */
+#define HAVE_FLOAT_H 1
+
+/* Define if you have the `fseek' function. */
+#define HAVE_FSEEK 1
+
+/* Define if you have the `fsetpos' function. */
+#define HAVE_FSETPOS 1
+
+/* Define if you have the `ftell' function. */
+#define HAVE_FTELL 1
+
+/* Define if you have the `ftime' function. */
+#define HAVE_FTIME 1
+
+/* Define if you have the <ftw.h> header file. */
+#define HAVE_FTW_H 1
+
+/* Define if you have the `getclock' function. */
+/* #undef HAVE_GETCLOCK */
+
+/* Define if you have the `getgrgid_r' function. */
+#define HAVE_GETGRGID_R 1
+
+/* Define if you have the `getgrnam_r' function. */
+#define HAVE_GETGRNAM_R 1
+
+/* Define if you have the `getpagesize' function. */
+#define HAVE_GETPAGESIZE 1
+
+/* Define if you have the `getpwnam_r' function. */
+#define HAVE_GETPWNAM_R 1
+
+/* Define if you have the `getpwuid_r' function. */
+#define HAVE_GETPWUID_R 1
+
+/* Define if you have the `getrusage' function. */
+#define HAVE_GETRUSAGE 1
+
+/* Define if you have the `gettimeofday' function. */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define if you have the <GL/gl.h> header file. */
+#define HAVE_GL_GL_H 1
+
+/* Define if you have the `gmtime_r' function. */
+#define HAVE_GMTIME_R 1
+
+/* Define if you have the <grp.h> header file. */
+#define HAVE_GRP_H 1
+
+/* Define if you have the <ieee754.h> header file. */
+#define HAVE_IEEE754_H 1
+
+/* Define if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define if you have the <io.h> header file. */
+/* #undef HAVE_IO_H */
+
+/* Define if you have the `lchown' function. */
+#define HAVE_LCHOWN 1
+
+/* Define if you have the `bfd' library (-lbfd). */
+#define HAVE_LIBBFD 1
+
+/* Define if you have the `iberty' library (-liberty). */
+#define HAVE_LIBIBERTY 1
+
+/* Define if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define if you have the `localtime_r' function. */
+#define HAVE_LOCALTIME_R 1
+
+/* Define if you have the `lstat' function. */
+#define HAVE_LSTAT 1
+
+/* Define if you have the `macsystem' function. */
+/* #undef HAVE_MACSYSTEM */
+
+/* Define if you have the <malloc.h> header file. */
+#define HAVE_MALLOC_H 1
+
+/* Define if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define if you have the `mktime' function. */
+#define HAVE_MKTIME 1
+
+/* Define if you have the `mprotect' function. */
+#define HAVE_MPROTECT 1
+
+/* Define if you have the <netdb.h> header file. */
+#define HAVE_NETDB_H 1
+
+/* Define if you have the <netinet/in.h> header file. */
+#define HAVE_NETINET_IN_H 1
+
+/* Define if you have the <netinet/tcp.h> header file. */
+#define HAVE_NETINET_TCP_H 1
+
+/* Define if you have the <nlist.h> header file. */
+/* #undef HAVE_NLIST_H */
+
+/* Define if you have the <pascal.h> header file. */
+/* #undef HAVE_PASCAL_H */
+
+/* Define if you have the `PBHSetVolSync' function. */
+/* #undef HAVE_PBHSETVOLSYNC */
+
+/* Define if you have the `pclose' function. */
+#define HAVE_PCLOSE 1
+
+/* Define if you have the `popen' function. */
+#define HAVE_POPEN 1
+
+/* Define if you have the <pthread.h> header file. */
+#define HAVE_PTHREAD_H 1
+
+/* Define if you have the <pwd.h> header file. */
+#define HAVE_PWD_H 1
+
+/* Define if you have the `readdir_r' function. */
+#define HAVE_READDIR_R 1
+
+/* Define if you have the `readlink' function. */
+#define HAVE_READLINK 1
+
+/* Define if you have the `realpath' function. */
+#define HAVE_REALPATH 1
+
+/* Define if you have the `setitimer' function. */
+#define HAVE_SETITIMER 1
+
+/* Define if you have the <sgtty.h> header file. */
+#define HAVE_SGTTY_H 1
+
+/* Define if you have the <siginfo.h> header file. */
+/* #undef HAVE_SIGINFO_H */
+
+/* Define if you have the <signal.h> header file. */
+#define HAVE_SIGNAL_H 1
+
+/* Define if you have the `snprintf' function. */
+#define HAVE_SNPRINTF 1
+
+/* Define if you have the `stat' function. */
+#define HAVE_STAT 1
+
+/* Define if you have the <stat.h> header file. */
+/* #undef HAVE_STAT_H */
+
+/* Define if you have the <stdarg.h> header file. */
+#define HAVE_STDARG_H 1
+
+/* Define if you have the <stddef.h> header file. */
+#define HAVE_STDDEF_H 1
+
+/* Define if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define if you have the <std.h> header file. */
+/* #undef HAVE_STD_H */
+
+/* Define if you have the `strcasecmp' function. */
+#define HAVE_STRCASECMP 1
+
+/* Define if you have the `strcmp' function. */
+#define HAVE_STRCMP 1
+
+/* Define if you have the `strcmpi' function. */
+/* #undef HAVE_STRCMPI */
+
+/* Define if you have the `stricmp' function. */
+/* #undef HAVE_STRICMP */
+
+/* Define if you have the <strings.h> header file. */
+/* #undef HAVE_STRINGS_H */
+
+/* Define if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define if `st_blksize' is member of `struct stat'. */
+/* #undef HAVE_STRUCT_STAT_ST_BLKSIZE */
+
+/* Define if `tm_zone' is member of `struct tm'. */
+/* #undef HAVE_STRUCT_TM_TM_ZONE */
+
+/* Define if your `struct stat' has `st_blksize'. Deprecated, use
+ `HAVE_STRUCT_STAT_ST_BLKSIZE' instead. */
+#define HAVE_ST_BLKSIZE 1
+
+/* Define if you have the `symlink' function. */
+#define HAVE_SYMLINK 1
+
+/* Define if you have the `sysconf' function. */
+#define HAVE_SYSCONF 1
+
+/* Define if you have the <sys/fault.h> header file. */
+/* #undef HAVE_SYS_FAULT_H */
+
+/* Define if you have the <sys/file.h> header file. */
+#define HAVE_SYS_FILE_H 1
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 1
+
+/* Define if you have the <sys/limits.h> header file. */
+/* #undef HAVE_SYS_LIMITS_H */
+
+/* Define if you have the <sys/mman.h> header file. */
+#define HAVE_SYS_MMAN_H 1
+
+/* Define if you have the <sys/param.h> header file. */
+#define HAVE_SYS_PARAM_H 1
+
+/* Define if you have the <sys/procfs.h> header file. */
+#define HAVE_SYS_PROCFS_H 1
+
+/* Define if you have the <sys/resource.h> header file. */
+#define HAVE_SYS_RESOURCE_H 1
+
+/* Define if you have the <sys/signal.h> header file. */
+#define HAVE_SYS_SIGNAL_H 1
+
+/* Define if you have the <sys/socket.h> header file. */
+#define HAVE_SYS_SOCKET_H 1
+
+/* Define if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define if you have the <sys/syscall.h> header file. */
+#define HAVE_SYS_SYSCALL_H 1
+
+/* Define if you have the <sys/timeb.h> header file. */
+#define HAVE_SYS_TIMEB_H 1
+
+/* Define if you have the <sys/timers.h> header file. */
+/* #undef HAVE_SYS_TIMERS_H */
+
+/* Define if you have the <sys/times.h> header file. */
+#define HAVE_SYS_TIMES_H 1
+
+/* Define if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define if you have the <sys/uio.h> header file. */
+#define HAVE_SYS_UIO_H 1
+
+/* Define if you have the <sys/un.h> header file. */
+#define HAVE_SYS_UN_H 1
+
+/* Define if you have the <sys/utsname.h> header file. */
+#define HAVE_SYS_UTSNAME_H 1
+
+/* Define if you have the <sys/vadvise.h> header file. */
+/* #undef HAVE_SYS_VADVISE_H */
+
+/* Define if you have the <sys/wait.h> header file. */
+#define HAVE_SYS_WAIT_H 1
+
+/* Define if you have the <termios.h> header file. */
+#define HAVE_TERMIOS_H 1
+
+/* Define if you have the <termio.h> header file. */
+#define HAVE_TERMIO_H 1
+
+/* Define if you have the `timelocal' function. */
+#define HAVE_TIMELOCAL 1
+
+/* Define if you have the `times' function. */
+#define HAVE_TIMES 1
+
+/* Define if you have the <time.h> header file. */
+#define HAVE_TIME_H 1
+
+/* Define if your `struct tm' has `tm_zone'. Deprecated, use
+ `HAVE_STRUCT_TM_TM_ZONE' instead. */
+#define HAVE_TM_ZONE 1
+
+/* Define if you have the <types.h> header file. */
+/* #undef HAVE_TYPES_H */
+
+/* Define if you don't have `tm_zone' but do have the external array `tzname'.
+ */
+/* #undef HAVE_TZNAME */
+
+/* Define if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define if you have the <utime.h> header file. */
+#define HAVE_UTIME_H 1
+
+/* Define if you have the `vadvise' function. */
+/* #undef HAVE_VADVISE */
+
+/* Define if you have the `valloc' function. */
+#define HAVE_VALLOC 1
+
+/* Define if you have the <values.h> header file. */
+#define HAVE_VALUES_H 1
+
+/* Define if you have the `vfork' function. */
+#define HAVE_VFORK 1
+
+/* Define if you have the <vfork.h> header file. */
+/* #undef HAVE_VFORK_H */
+
+/* Define if you have the `vsnprintf' function. */
+#define HAVE_VSNPRINTF 1
+
+/* Define if you have the <windows.h> header file. */
+/* #undef HAVE_WINDOWS_H */
+
+/* Define if you have the <winsock.h> header file. */
+/* #undef HAVE_WINSOCK_H */
+
+/* Define if you have the `_fullpath' function. */
+/* #undef HAVE__FULLPATH */
+
+/* Define if you have the `_pclose' function. */
+/* #undef HAVE__PCLOSE */
+
+/* Define if you have the `_popen' function. */
+/* #undef HAVE__POPEN */
+
+/* Define if you have the `_snprintf' function. */
+/* #undef HAVE__SNPRINTF */
+
+/* Define if you have the `_stricmp' function. */
+/* #undef HAVE__STRICMP */
+
+/* Define if you have the `_vsnprintf' function. */
+/* #undef HAVE__VSNPRINTF */
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#define RETSIGTYPE void
+
+/* The size of a `char', as computed by sizeof. */
+#define SIZEOF_CHAR 1
+
+/* The size of a `double', as computed by sizeof. */
+#define SIZEOF_DOUBLE 8
+
+/* The size of a `float', as computed by sizeof. */
+#define SIZEOF_FLOAT 4
+
+/* The size of a `int', as computed by sizeof. */
+#define SIZEOF_INT 4
+
+/* The size of a `long', as computed by sizeof. */
+#define SIZEOF_LONG 4
+
+/* The size of a `long long', as computed by sizeof. */
+#define SIZEOF_LONG_LONG 8
+
+/* The size of a `short', as computed by sizeof. */
+#define SIZEOF_SHORT 2
+
+/* The size of a `unsigned char', as computed by sizeof. */
+#define SIZEOF_UNSIGNED_CHAR 1
+
+/* The size of a `unsigned int', as computed by sizeof. */
+#define SIZEOF_UNSIGNED_INT 4
+
+/* The size of a `unsigned long', as computed by sizeof. */
+#define SIZEOF_UNSIGNED_LONG 4
+
+/* The size of a `unsigned long long', as computed by sizeof. */
+#define SIZEOF_UNSIGNED_LONG_LONG 8
+
+/* The size of a `unsigned short', as computed by sizeof. */
+#define SIZEOF_UNSIGNED_SHORT 2
+
+/* The size of a `void *', as computed by sizeof. */
+#define SIZEOF_VOID_P 4
+
+/* If using the C implementation of alloca, define if you know the
+ direction of stack growth for your system; otherwise it will be
+ automatically deduced at run-time.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown */
+/* #undef STACK_DIRECTION */
+
+/* Define if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define if you can safely include both <sys/time.h> and <time.h>. */
+#define TIME_WITH_SYS_TIME 1
+
+/* Define if your <sys/time.h> declares `struct tm'. */
+/* #undef TM_IN_SYS_TIME */
+
+/* Define if the system headers declare usleep to return void. */
+/* #undef USLEEP_RETURNS_VOID */
+
+/* Define if your processor stores words with the most significant byte first
+ (like Motorola and SPARC, unlike Intel and VAX). */
+/* #undef WORDS_BIGENDIAN */
+
+/* Define if the X Window System is missing or not being used. */
+/* #undef X_DISPLAY_MISSING */
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
diff --git a/Linux_C_12/cpicture_121.c b/Linux_C_12/cpicture_121.c new file mode 100644 index 0000000..c036587 --- /dev/null +++ b/Linux_C_12/cpicture_121.c @@ -0,0 +1,1910 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ Routines related to drawing.
+********************************************************************************************/
+#include "util_121.h"
+#include <pango/pango.h>
+#include <pango/pangoft2.h>
+#include "cpicture_121.h"
+#include "cCrossCall_121.h"
+#include "cCrossCallWindows_121.h"
+
+extern void InitGTK();
+
+const gchar* PEN_POS_KEY = "current-pen-position";
+
+void WinGetDC (GtkWidget *widget, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ GdkWindow *window;
+ printf("WinGetDC\n");
+ window = GTK_BIN(GTK_BIN(widget)->child)->child->window;
+
+ gdk_window_ref(window);
+ *outDraw = GDK_DRAWABLE(window);
+ *oos = ios;
+} /* WinGetDC */
+
+OS WinReleaseDC(GtkWidget *widget, GdkDrawable *drawable, OS ios)
+{
+ printf("WinReleaseDC\n");
+ gdk_window_unref(GDK_WINDOW(drawable));
+ return ios;
+} /* WinReleaseDC */
+
+gint OsMMtoVPixels(double mm)
+
+{
+ printf("OsMMtoVPixels\n");
+ InitGTK();
+ return (int) ((mm*gdk_screen_height())/gdk_screen_height_mm());
+}
+
+gint OsMMtoHPixels(double mm)
+{
+ printf("OsMMtoHPixels\n");
+ InitGTK();
+ return (int) ((mm*gdk_screen_width())/gdk_screen_width_mm());
+}
+
+/*------------------------------------*\
+| |
+| Helper functions |
+| |
+\*------------------------------------*/
+
+static GdkGC *theDrawGC, *theEraseGC, *theInvertGC;
+static GdkFont *theFont;
+static PangoFontDescription *theFontDesc;
+static gint penSize;
+static gint penPat;
+static gint penMode;
+static GdkColor penColor;
+static GdkColor backColor;
+static GdkPoint *thePolygon;
+static gint thePolygonIndex;
+static GdkRegion *theClipRgn = NULL;
+
+
+void WinInitPicture (gint size, gint mode, gint pr, gint pg, gint pb,
+ gint br, gint bg, gint bb, gint x, gint y,
+ CLEAN_STRING fname, gint fstyle, gint fsize,
+ gint ox, gint oy, GdkDrawable *inDraw, OS os,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinInitPicture\n");
+ penColor.pixel = 0;
+ penColor.red = pr*257;
+ penColor.green = pg*257;
+ penColor.blue = pb*257;
+
+ backColor.pixel = 0;
+ backColor.red = br*257;
+ backColor.green = bg*257;
+ backColor.blue = bb*257;
+
+ penSize = size;
+ penMode = mode;
+
+ if (inDraw)
+ {
+ printf("inDraw non-null\n");
+ gdk_colormap_alloc_color(gdk_drawable_get_colormap(inDraw), &penColor, FALSE, FALSE);
+ gdk_colormap_alloc_color(gdk_drawable_get_colormap(inDraw), &backColor, FALSE, FALSE);
+
+ theDrawGC = gdk_gc_new(inDraw);
+ gdk_gc_set_foreground(theDrawGC, &penColor);
+ gdk_gc_set_background(theDrawGC, &backColor);
+ gdk_gc_set_clip_origin(theDrawGC, 0, 0);
+ gdk_gc_set_line_attributes(theDrawGC, size, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
+
+ theEraseGC = gdk_gc_new(inDraw);
+ gdk_gc_set_foreground(theEraseGC, &backColor);
+ gdk_gc_set_background(theEraseGC, &penColor);
+ gdk_gc_set_clip_origin(theEraseGC, 0, 0);
+ gdk_gc_set_line_attributes(theEraseGC, size, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
+
+ theInvertGC = gdk_gc_new(inDraw);
+ gdk_gc_set_foreground(theInvertGC, &penColor);
+ gdk_gc_set_background(theInvertGC, &backColor);
+ gdk_gc_set_function(theInvertGC, GDK_INVERT);
+ gdk_gc_set_clip_origin(theInvertGC, 0, 0);
+ }
+ else
+ {
+ theDrawGC = NULL;
+ theEraseGC = NULL;
+ theInvertGC = NULL;
+ }
+
+ theFontDesc = pango_font_description_new();
+ pango_font_description_set_family(theFontDesc,cstring(fname));
+ pango_font_description_set_weight(theFontDesc,(fstyle & iBold) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
+ pango_font_description_set_style(theFontDesc,(fstyle & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
+ /* plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
+ /* plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
+ pango_font_description_set_size(theFontDesc, fsize*PANGO_SCALE);
+ theFont = gdk_font_from_description(theFontDesc);
+
+ /*
+ theClipRgn = NULL;
+ if (clipRgn)
+ {
+ theClipRgn = gdk_region_copy(clipRgn);
+ if (theDrawGC) gdk_gc_set_clip_region(theDrawGC, theClipRgn);
+ if (theEraseGC) gdk_gc_set_clip_region(theEraseGC, theClipRgn);
+ if (theInvertGC) gdk_gc_set_clip_region(theInvertGC, theClipRgn);
+ }
+ */
+
+ /* Remember the pen position */
+ InternalSetPenPos(inDraw, x, y);
+
+ *outDraw = inDraw;
+ *oos = os;
+ printf("WinInitPicture -- returning\n");
+} /* WinInitPicture */
+
+void WinDonePicture (GdkDrawable *inDraw, OS ios,
+ gint *size, gint *mode, gint *pr, gint *pg, gint *pb, gint *br,
+ gint *bg, gint *bb, gint *x, gint *y, CLEAN_STRING *fname,
+ gint *fstyle, gint *fsize, GdkDrawable **outDraw, OS* oos)
+{
+ GdkPoint *p;
+ PangoContext *pc;
+ PangoFontDescription *fontDesc;
+ gchar *fontDescString;
+ GtkWidget *widget;
+ gboolean inDrawIsWidget;
+
+ printf("WinDonePicture\n");
+ inDrawIsWidget = GTK_IS_WIDGET(inDraw);
+
+ if (inDraw)
+ {
+ printf("inDraw non-null\n");
+ gdk_colormap_free_colors(gdk_drawable_get_colormap(inDraw), &penColor, 1);
+ gdk_colormap_free_colors(gdk_drawable_get_colormap(inDraw), &backColor, 1);
+ }
+
+ if (theFont)
+ {
+ gdk_font_unref(theFont);
+ theFont = NULL;
+ }
+ if (theFontDesc)
+ {
+ pango_font_description_free(theFontDesc);
+ theFontDesc = NULL;
+ }
+
+ if (theDrawGC) gdk_gc_unref(theDrawGC);
+ if (theEraseGC) gdk_gc_unref(theEraseGC);
+ if (theInvertGC) gdk_gc_unref(theInvertGC);
+
+ if (theClipRgn)
+ {
+ gdk_region_destroy(theClipRgn);
+ theClipRgn = NULL;
+ }
+
+ *size = penSize;
+ *mode = penMode;
+
+ *pr = penColor.red/257;
+ *pg = penColor.green/257;
+ *pb = penColor.blue/257;
+
+ *br = backColor.red/257;
+ *bg = backColor.green/257;
+ *bb = backColor.blue/257;
+
+ /* inDraw may not have font context */
+ *outDraw = inDraw;
+ if (! inDrawIsWidget)
+ {
+ widget = gtk_label_new(NULL);
+ }
+ else
+ {
+ widget = GTK_WIDGET(inDraw);
+ }
+
+ pc = gtk_widget_get_pango_context(widget);
+
+ fontDesc = pango_context_get_font_description(pc);
+
+ InternalGetPenPos(inDraw, x, y);
+
+ *fname = cleanstring(pango_font_description_get_family(fontDesc));
+ *fstyle= pango_font_description_get_style(fontDesc);
+ *fsize = pango_font_description_get_size(fontDesc);
+
+ g_object_unref(G_OBJECT(pc));
+ if (! inDrawIsWidget)
+ {
+ gtk_widget_destroy(widget);
+ }
+
+ *oos = ios;
+ printf("WinDonePicture -- returning\n");
+} /* WinDonePicture */
+
+/* PA: Set and get the clipping region of a picture:
+ WinClipRgnPicture takes the intersection of the argument clipRgn with the current clipping region.
+ WinSetClipRgnPicture sets the argument clipRgn as the new clipping region.
+ WinGetClipRgnPicture gets the current clipping region.
+*/
+void WinClipRgnPicture (GdkRegion *region, GdkDrawable *drawable, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ GdkRectangle *rectangles;
+ gint n_rectangles, i;
+
+ printf("WinClipRgnPicture\n");
+ if (theClipRgn != NULL)
+ {
+ gdk_region_intersect(theClipRgn, region);
+ }
+ else
+ {
+ if (region)
+ theClipRgn = gdk_region_copy(region);
+ }
+
+ if (theDrawGC) gdk_gc_set_clip_region(theDrawGC, theClipRgn);
+ if (theEraseGC) gdk_gc_set_clip_region(theEraseGC, theClipRgn);
+ if (theInvertGC) gdk_gc_set_clip_region(theInvertGC, theClipRgn);
+
+ *outDraw = drawable;
+ *oos = ios;
+} /* WinClipRgnPicture */
+
+void WinSetClipRgnPicture (GdkRegion *region, GdkDrawable *drawable, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ GdkRectangle *rectangles;
+ gint n_rectangles, i;
+
+ printf("WinSetClipRgnPicture\n");
+ if (theClipRgn != NULL)
+ {
+ gdk_region_destroy(theClipRgn);
+ }
+
+ theClipRgn = region ? gdk_region_copy(region) : NULL;
+
+ if (theDrawGC) gdk_gc_set_clip_region(theDrawGC, theClipRgn);
+ if (theEraseGC) gdk_gc_set_clip_region(theEraseGC, theClipRgn);
+ if (theInvertGC) gdk_gc_set_clip_region(theInvertGC, theClipRgn);
+ *outDraw = drawable;
+ *oos = ios;
+} /* WinSetClipRgnPicture */
+
+void WinGetClipRgnPicture (GdkDrawable *drawable,OS ios,
+ GdkRegion **outRegion, GdkDrawable **outDraw, OS* oos)
+{
+ GdkRegion *r = NULL;
+
+ printf("WinGetClipRgnPicture\n");
+ if (theClipRgn)
+ {
+ r = gdk_region_copy(theClipRgn);
+ }
+
+ *outRegion = r;
+ *outDraw = drawable;
+ *oos = ios;
+} /* WinGetClipRgnPicture */
+
+
+/* Operations to create, modify, and destroy polygon shapes.
+*/
+
+void WinAllocPolyShape (gint size, OS ios, GdkPoint **outPoint, OS *oos)
+{
+ printf("WinAllocPolyShape\n");
+ *outPoint = g_new(GdkPoint,1);
+ *oos = ios;
+} /* WinAllocPolyShape */
+
+OS WinSetPolyPoint (gint i, gint x, gint y, GdkPoint *shape, OS os)
+{
+ printf("WinSetPolyPoint\n");
+ shape[i].x = x;
+ shape[i].y = y;
+
+ return (os);
+} /* WinSetPolyPoint */
+
+OS WinFreePolyShape (GdkPoint *shape, OS os)
+{
+ printf("WinFreePolyShape\n");
+ gdk_drawable_unref(GDK_DRAWABLE(shape));
+ return (os);
+} /* WinFreePolyShape */
+
+
+/*
+ * Operations to create, modify and destroy regions.
+ */
+GdkRegion *WinCreateEmptyRgn()
+{
+ printf("WinCreateEmptyRgn\n");
+ return gdk_region_new();
+} /* WinCreateEmptyRgn */
+
+void WinCreateRectRgn (gint nLeftRect, gint nTopRect, gint nRightRect,
+ gint nBottomRect, OS ios, GdkRegion **rgn, OS *oos)
+{
+ GdkRectangle rectangle;
+ printf("WinCreateRectRgn\n");
+ rectangle.x = nLeftRect;
+ rectangle.y = nTopRect;
+ rectangle.width = nRightRect-nLeftRect;
+ rectangle.height = nBottomRect-nTopRect;
+ *rgn = gdk_region_rectangle(&rectangle);
+ *oos = ios;
+} /* WinCreateRectRgn */
+
+void WinCreatePolygonRgn (GdkPoint *points, gint nPoints,
+ gint fnPolyFillMode, OS ios, GdkRegion **rgn, OS *oos)
+{
+ printf("WinCreatePolygonRgn\n");
+ *rgn = gdk_region_polygon(points,nPoints, fnPolyFillMode == 1 ? GDK_EVEN_ODD_RULE : GDK_WINDING_RULE);
+ *oos = ios;
+} /* WinCreatePolygonRgn */
+
+GdkRegion *WinUnionRgn (GdkRegion *src1, GdkRegion *src2)
+{
+ GdkRegion *dst = NULL;
+ printf("WinUnionRgn\n");
+
+ if (src1)
+ {
+ dst = gdk_region_copy(src1);
+ gdk_region_union(dst, src2);
+ }
+
+ return dst;
+} /* WinUnionRgn */
+
+GdkRegion *WinSectRgn (GdkRegion *src1, GdkRegion *src2)
+{
+ GdkRegion *dst = src2;
+ printf("WinSectRgn\n");
+
+ if (src1)
+ {
+ dst = gdk_region_copy(src1);
+ gdk_region_intersect(dst, src2);
+ }
+
+ return dst;
+} /* WinSectRgn */
+
+GdkRegion *WinDiffRgn (GdkRegion *src1, GdkRegion *src2)
+{
+ GdkRegion *dst = NULL;
+ printf("WinDiffRgn\n");
+
+ if (src1)
+ {
+ dst = gdk_region_copy(src1);
+ gdk_region_subtract(dst, src2);
+ };
+
+ return dst;
+} /* WinDiffRgn */
+
+GdkRegion *WinXorRgn (GdkRegion *src1, GdkRegion *src2)
+{
+ GdkRegion *dst = NULL;
+ printf("WinXorRgn\n");
+
+ if (src1)
+ {
+ dst = gdk_region_copy(src1);
+ gdk_region_xor(dst, src2);
+ }
+
+ return dst;
+} /* WinXorRgn */
+
+void WinGetRgnBox (GdkRegion *region, OS ios, gint *left, gint *top, gint *right,
+ gint *bottom, gboolean *isrect, gboolean *isempty, OS *oos)
+{
+ GdkRegion *tempRegion;
+ GdkRectangle rectangle;
+ printf("WinGetRgnBox\n");
+
+ gdk_region_get_clipbox(region,&rectangle);
+ tempRegion = gdk_region_rectangle(&rectangle);
+
+ *left = rectangle.x;
+ *top = rectangle.y;
+ *right = rectangle.x+rectangle.width;
+ *bottom = rectangle.y+rectangle.height;
+ *isrect = gdk_region_equal(region, tempRegion);
+
+ gdk_region_destroy(tempRegion);
+
+ *oos = ios;
+} /* WinGetRgnBox */
+
+gboolean WinIsEmptyRgn(GdkRegion *region)
+{
+ printf("WinIsEmptyRgn\n");
+ return gdk_region_empty(region);
+}
+
+void WinDisposeRgn (GdkRegion *region)
+{
+ printf("WinDisposeRgn\n");
+ gdk_region_destroy(region);
+}
+
+/*------------------------------------*\
+| Interface functions |
+\*------------------------------------*/
+
+void WinSetPenSize (gint size, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinSetPenSize\n");
+ if (theDrawGC) gdk_gc_set_line_attributes(theDrawGC, size, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
+ if (theEraseGC) gdk_gc_set_line_attributes(theEraseGC, size, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
+ penSize = size;
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinSetPenSize */
+
+void WinSetPenColor (gint red, gint green, gint blue, GdkDrawable *inDraw,
+ OS ios, GdkDrawable **outDraw, OS* oos)
+{
+ printf("WinSetPenColor\n");
+ if (inDraw)
+ {
+ gdk_colormap_free_colors(gdk_drawable_get_colormap(inDraw), &backColor, 1);
+ penColor.pixel = 0;
+ penColor.red = red*257;
+ penColor.green = green*257;
+ penColor.blue = blue*257;
+ gdk_colormap_alloc_color(gdk_drawable_get_colormap(inDraw), &penColor, FALSE, FALSE);
+
+ gdk_gc_set_foreground(theDrawGC, &penColor);
+ gdk_gc_set_background(theEraseGC, &penColor);
+ gdk_gc_set_foreground(theInvertGC, &penColor);
+ }
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinSetPenColor */
+
+void WinSetBackColor (gint red, gint green, gint blue, GdkDrawable *inDraw,
+ OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinSetBackColor\n");
+ if (inDraw)
+ {
+ gdk_colormap_free_colors(gdk_drawable_get_colormap(inDraw), &backColor, 1);
+ backColor.pixel = 0;
+ backColor.red = red*257;
+ backColor.green = green*257;
+ backColor.blue = blue*257;
+ gdk_colormap_alloc_color(gdk_drawable_get_colormap(inDraw), &backColor, FALSE, FALSE);
+
+ gdk_gc_set_background(theDrawGC, &backColor);
+ gdk_gc_set_foreground(theEraseGC, &backColor);
+ gdk_gc_set_background(theInvertGC, &backColor);
+ }
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinSetBackColor */
+
+void WinSetMode (gint mode, GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw,
+ OS *oos)
+{
+ printf("WinSetMode\n");
+ switch (mode)
+ {
+ case iModeCopy:
+ penMode = iModeCopy;
+ if (theDrawGC) gdk_gc_set_function(theDrawGC, GDK_COPY);
+ if (theEraseGC) gdk_gc_set_function(theEraseGC, GDK_COPY);
+ if (theInvertGC) gdk_gc_set_function(theInvertGC, GDK_COPY);
+ break;
+ case iModeXor:
+ penMode = iModeXor;
+ if (theDrawGC) gdk_gc_set_function(theDrawGC, GDK_XOR);
+ if (theEraseGC) gdk_gc_set_function(theEraseGC, GDK_XOR);
+ if (theInvertGC) gdk_gc_set_function(theInvertGC, GDK_XOR);
+ break;
+ case iModeOr:
+ default:
+ if (theDrawGC) gdk_gc_set_function(theDrawGC, GDK_OR);
+ if (theEraseGC) gdk_gc_set_function(theEraseGC, GDK_OR);
+ if (theInvertGC) gdk_gc_set_function(theInvertGC, GDK_OR);
+ break;
+ }
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinSetMode */
+
+void WinSetPattern (gint pattern, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinSetPattern --> Not Implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinSetPattern */
+
+
+/* changed by MW */
+void WinDrawPoint (gint x, gint y, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinDrawPoint\n");
+ if (inDraw) gdk_draw_point(inDraw, theDrawGC, x, y);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinDrawPoint */
+
+void WinDrawLine (gint startx, gint starty, gint endx, gint endy,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinDrawLine\n");
+ if (inDraw) gdk_draw_line(inDraw, theDrawGC, startx, starty, endx, endy);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinDrawLine */
+
+void WinUndrawLine (gint startx, gint starty, gint endx, gint endy,
+ GdkDrawable *inDraw)
+{
+ printf("WinUndrawLine\n");
+ if (inDraw) gdk_draw_line(inDraw, theEraseGC, startx, starty, endx, endy);
+} /* WinDrawLine */
+
+static gfloat PI = 3.1415926535897932384626433832795;
+
+void WinDrawCurve (gint left, gint top, gint right, gint bottom, gint startradx,
+ gint startrady, gint endradx, gint endrady, GdkDrawable *inDraw,
+ OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ gint x = left;
+ gint y = top;
+ gint rx = right;
+ gint ry = bottom;
+ gfloat from = startradx;
+ gfloat to = endradx;
+ gboolean clockwise = TRUE;
+ gint cx, cy;
+
+ printf("WinDrawCurve\n");
+ if (inDraw)
+ {
+ cx = x - floor(cos(from)* abs(rx));
+ cy = y + floor(sin(from)* abs(ry));
+
+ from = (32*360*from)/PI;
+ to = (32*360*to)/PI;
+
+ if (clockwise)
+ gdk_draw_arc(inDraw, theDrawGC, FALSE,
+ cx-rx, cy-ry, 2*rx, 2*ry,
+ floor(from-PI/2),floor(from-to));
+ else
+ gdk_draw_arc(inDraw, theDrawGC, FALSE,
+ cx-rx, cy-ry, 2*rx, 2*ry,
+ floor(to-PI/2),floor(to-from));
+ }
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinDrawCurve */
+
+void WinUndrawCurve(gint x, gint y, gint rx, gint ry, gfloat from, gfloat to,
+ gboolean clockwise,GdkDrawable *drawable)
+{
+ gint cx, cy;
+
+ printf("WinUndrawCurve\n");
+ if (drawable)
+ {
+ cx = x - floor(cos(from)* abs(rx));
+ cy = y + floor(sin(from)* abs(ry));
+
+ from = (32*360*from)/PI;
+ to = (32*360*to)/PI;
+
+ if (clockwise)
+ gdk_draw_arc(drawable, theEraseGC, FALSE,
+ cx-rx, cy-ry, 2*rx, 2*ry,
+ floor(from-PI/2),floor(from-to));
+ else
+ gdk_draw_arc(drawable, theEraseGC, FALSE,
+ cx-rx, cy-ry, 2*rx, 2*ry,
+ floor(to-PI/2),floor(to-from));
+ }
+} /* WinDrawCurve */
+
+void WinDrawChar (gchar c, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ gint x, y;
+ printf("WinDrawChar\n");
+
+ InternalGetPenPos(inDraw, &x, &y);
+ if (inDraw) gdk_draw_text(inDraw, theFont, theDrawGC, x, y, &c, 1);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinDrawChar */
+
+void WinUndrawChar(gint x, gint y, gchar c, GdkDrawable *drawable)
+{
+ printf("WinUndrawChar\n");
+ if (drawable) gdk_draw_text(drawable,theFont,theEraseGC,x,y,&c,1);
+} /* WinDrawChar */
+
+/*void WinDrawString (int x, int y, CLEAN_STRING string, GdkDrawable *inDraw, */
+void WinDrawString (CLEAN_STRING string, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ gint x, y;
+ printf("WinDrawString\n");
+
+ InternalGetPenPos(inDraw, &x, &y);
+ if (inDraw)
+ {
+ printf("Drawing %s\n", cstring(string));
+ gdk_draw_string(inDraw, theFont, theDrawGC, x, y, cstring(string));
+ }
+
+ *outDraw = inDraw;
+ *oos = ios;
+ printf("Leaving drawstring.\n");
+} /* WinDrawString */
+
+void WinUndrawString (gint x, gint y, gchar *string, GdkDrawable *drawable)
+{
+ printf("WinUndrawString\n");
+ if (drawable) gdk_draw_string(drawable,theFont,theEraseGC,x,y,string);
+} /* WinUndrawString */
+
+void WinDrawRectangle (gint left, gint top, gint right, gint bot,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinDrawRectangle\n");
+ if (inDraw)
+ gdk_draw_rectangle(inDraw, theDrawGC, FALSE,
+ left, top,
+ right-left-1,
+ bot-top-1);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinDrawRectangle */
+
+void WinUndrawRectangle (gint left, gint top, gint right, gint bot,
+ GdkDrawable *drawable)
+{
+ printf("WinUndrawRectangle\n");
+ if (drawable)
+ {
+ gdk_draw_rectangle(drawable, theEraseGC, FALSE,
+ left, top,
+ right-left-1,
+ bot-top-1);
+ }
+} /* WinDrawRectangle */
+
+void WinFillRectangle (gint left, gint top, gint right, gint bot,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinFillRectangle\n");
+ if (inDraw)
+ {
+ gdk_draw_rectangle(inDraw, theDrawGC, TRUE,
+ left, top,
+ right-left,
+ bot-top);
+ }
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinFillRectangle */
+
+void WinEraseRectangle (gint left, gint top, gint right, gint bot,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinEraseRectangle\n");
+ if (inDraw)
+ {
+ gdk_draw_rectangle(inDraw, theEraseGC, TRUE,
+ left, top,
+ right-left,
+ bot-top);
+ }
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinEraseRectangle */
+
+void WinInvertRectangle (gint left, gint top, gint right, gint bot,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinInvertRectangle\n");
+ if (inDraw)
+ {
+ gdk_draw_rectangle(inDraw, theInvertGC, TRUE,
+ left, top,
+ right-left,
+ bot-top);
+ }
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinInvertRectangle */
+
+void WinMoveRectangleTo (gint left, gint top, gint right, gint bot, gint x,
+ gint y, GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw,
+ OS *oos)
+{
+ printf("WinMoveRectangleTo is not implemented\n");
+ WinMoveRectangle (left,top, right,bot, x-left, y-top, inDraw,ios,
+ outDraw,oos);
+} /* WinMoveRectangleTo */
+
+void WinMoveRectangle (gint left, gint top, gint right, gint bot, gint dx,
+ gint dy, GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw,
+ OS *oos)
+{
+ printf("WinMoveRectangle is not implemented\n");
+/* int w, h;
+ HWND hwnd;
+
+ hwnd = WindowFromDC (ihdc);
+ if (hwnd != NULL)
+ {
+ RECT r;
+ POINT p;
+
+ GetClientRect (hwnd, &r);
+ GetWindowOrgEx (ihdc, &p);
+ left = max (left, r.left + p.x);
+ top = max (top, r.top + p.y);
+ right = min (right, r.right + p.x);
+ bot = min (bot, r.bottom + p.y);
+ }
+
+ w = right - left;
+ h = bot - top;
+
+ WinCopyRectangle (left, top, right, bot, dx, dy, ihdc);
+
+// StartErasing (ihdc);
+
+ if (dx > w || dy > h)
+ {
+ Rectangle (ihdc, left, top, right + 1, bot + 1);
+ return;
+ }
+
+ if (dx < 0)
+ Rectangle (ihdc, right - dx, top, right + 1, bot + 1);
+ else
+ Rectangle (ihdc, left, top, left + dx + 1, bot + 1);
+
+ if (dy < 0)
+ Rectangle (ihdc, left, bot - dy, right + 1, bot + 1);
+ else
+ Rectangle (ihdc, left, top, right + 1, top + dy + 1);*/
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinMoveRectangle */
+
+void WinCopyRectangleTo (gint left, gint top, gint right, gint bot, gint x,
+ gint y, GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw,
+ OS *oos)
+{
+/* WinCopyRectangle (left,top, right,bot, x-left,y-top, ihdc); */
+ printf("WinCopyRectangleTo is not implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinCopyRectangleTo */
+
+void WinCopyRectangle (gint left, gint top, gint right, gint bottom, gint dx,
+ gint dy, GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw,
+ OS *oos)
+{
+/* RECT scrollRect;
+
+ scrollRect.left = left;
+ scrollRect.top = top;
+ scrollRect.right = right;
+ scrollRect.bottom = bottom;
+
+ if (!ScrollDC (ihdc, dx,dy, &scrollRect, &scrollRect, NULL, NULL))
+ {
+ rMessageBox (NULL,MB_APPLMODAL,"WinCopyRectangle","ScrollDC failed");
+ }*/
+ printf("WinCopyRectangle is not implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinCopyRectangle */
+
+/* PA: new routine to scroll part of the content of a window.
+ It is assumed that scrolling happens in one direction only (dx<>0 && dy==0 || dx==0 && dy<>0).
+ The result rect (oleft,otop,oright,obottom) is the bounding box of the update area that
+ remains to be updated. If all are zero, then nothing needs to be updated.
+*/
+void WinScrollRectangle (gint left, gint top, gint right, gint bottom, gint dx,
+ gint dy, GdkDrawable *inDraw, OS ios, gint *oleft, gint *otop,
+ gint *oright, gint *obottom, GdkDrawable **outDraw, OS *oos)
+{
+/* RECT scrollRect;
+ HRGN hrgnUpdate, hrgnRect;
+
+ scrollRect.left = left;
+ scrollRect.top = top;
+ scrollRect.right = right;
+ scrollRect.bottom = bottom;
+
+ if (dx<0)
+ {
+ hrgnRect = CreateRectRgn (right+dx-1,top-1,right+1,bottom+1);
+ }
+ else if (dx>0)
+ {
+ hrgnRect = CreateRectRgn (left-1,top-1,left+dx+1,bottom+1);
+ }
+ else if (dy<0)
+ {
+ hrgnRect = CreateRectRgn (left-1,bottom+dy-1,right+1,bottom+1);
+ }
+ else if (dy>0)
+ {
+ hrgnRect = CreateRectRgn (left-1,top-1,right+1,top+dy+1);
+ }
+ else
+ {
+ hrgnRect = CreateRectRgn (0,0,0,0);
+ }
+ hrgnUpdate = CreateRectRgn (0,0,1,1);
+
+ if (!ScrollDC (ihdc, dx,dy, &scrollRect, &scrollRect, hrgnUpdate, NULL))
+ {
+ rMessageBox (NULL,MB_APPLMODAL,"WinScrollRectangle","ScrollDC failed");
+ }
+ else
+ {
+ if (CombineRgn (hrgnUpdate, hrgnUpdate, hrgnRect, RGN_DIFF) == NULLREGION)
+ {
+ *oleft = 0;
+ *otop = 0;
+ *oright = 0;
+ *obottom = 0;
+ }
+ else
+ {
+ RECT box;
+ GetRgnBox (hrgnUpdate,&box);
+ *oleft = box.left;
+ *otop = box.top;
+ *oright = box.right;
+ *obottom = box.bottom;
+ }
+ }
+ DeleteObject (hrgnUpdate);
+ DeleteObject (hrgnRect);
+*/
+ printf("WinScrollRectangle is not implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinScrollRectangle */
+
+
+void WinUndrawOval (gint left, gint top, gint right, gint bot,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinUndrawOval\n");
+ if (inDraw) gdk_draw_arc(inDraw,theEraseGC,FALSE,left,top,right-left,bot-top,0,64*360);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinDrawOval */
+
+void WinDrawOval (gint left, gint top, gint right, gint bot,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinDrawOval\n");
+ if (inDraw) gdk_draw_arc(inDraw,theDrawGC,FALSE,left,top,right-left,bot-top,0,64*360);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinDrawOval */
+
+void WinFillOval (gint left, gint top, gint right, gint bot,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinFillOval\n");
+ if (inDraw) gdk_draw_arc(inDraw,theDrawGC,TRUE,left,top,right-left,bot-top,0,64*360);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinFillOval */
+
+void WinEraseOval (gint left, gint top, gint right, gint bot,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinEraseOval\n");
+ if (inDraw) gdk_draw_arc(inDraw,theEraseGC,TRUE,left,top,right-left,bot-top,0,64*360);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinEraseOval */
+
+void WinInvertOval (gint left, gint top, gint right, gint bot,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinInvertOval\n");
+ if (inDraw) gdk_draw_arc(inDraw,theInvertGC,TRUE,left,top,right-left,bot-top,0,64*360);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinInvertOval */
+
+
+void WinFillWedge (gint left, gint top, gint right, gint bottom, gint startradx,
+ gint startrady, gint endradx, gint endrady, GdkDrawable *inDraw,
+ OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ gint cx, cy;
+ gint x = left;
+ gint y = top;
+ gint rx = right;
+ gint ry = bottom;
+ gfloat from = startradx;
+ gfloat to = startrady;
+ gboolean clockwise = TRUE;
+
+ printf("WinFillWedge\n");
+ if (inDraw)
+ {
+ cx = x - floor(cos(from)* abs(rx));
+ cy = y + floor(sin(from)* abs(ry));
+
+ from = (32*360*from)/PI;
+ to = (32*360*to)/PI;
+
+ if (clockwise)
+ gdk_draw_arc(inDraw, theDrawGC, TRUE,
+ cx-rx, cy-ry, 2*rx, 2*ry,
+ floor(from-PI/2),floor(from-to));
+ else
+ gdk_draw_arc(inDraw, theDrawGC, TRUE,
+ cx-rx, cy-ry, 2*rx, 2*ry,
+ floor(to-PI/2),floor(to-from));
+ }
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinFillWedge */
+
+void WinEraseWedge (gint left, gint top, gint right, gint bottom,
+ gint startradx, gint startrady, gint endradx, gint endrady,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ gint cx, cy;
+ gint x = left;
+ gint y = top;
+ gint rx = right;
+ gint ry = bottom;
+ gfloat from = startradx;
+ gfloat to = startrady;
+ gboolean clockwise = TRUE;
+
+ printf("WinEraseWedge\n");
+ if (inDraw)
+ {
+ cx = x - floor(cos(from)* abs(rx));
+ cy = y + floor(sin(from)* abs(ry));
+
+ from = (32*360*from)/PI;
+ to = (32*360*to)/PI;
+
+ if (clockwise)
+ gdk_draw_arc(inDraw, theEraseGC, TRUE,
+ cx-rx, cy-ry, 2*rx, 2*ry,
+ floor(from-PI/2),floor(from-to));
+ else
+ gdk_draw_arc(inDraw, theEraseGC, TRUE,
+ cx-rx, cy-ry, 2*rx, 2*ry,
+ floor(to-PI/2),floor(to-from));
+ }
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinEraseWedge */
+
+void WinInvertWedge (gint left, gint top, gint right, gint bottom,
+ gint startradx, gint startrady, gint endradx, gint endrady,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ gint cx, cy;
+ gint x = left;
+ gint y = top;
+ gint rx = right;
+ gint ry = bottom;
+ gfloat from = startradx;
+ gfloat to = startrady;
+ gboolean clockwise = TRUE;
+
+ printf("WinInvertWedge\n");
+ if (inDraw)
+ {
+ cx = x - floor(cos(from)* abs(rx));
+ cy = y + floor(sin(from)* abs(ry));
+
+ from = (32*360*from)/PI;
+ to = (32*360*to)/PI;
+
+ if (clockwise)
+ gdk_draw_arc(inDraw, theInvertGC, TRUE,
+ cx-rx, cy-ry, 2*rx, 2*ry,
+ floor(from-PI/2),floor(from-to));
+ else
+ gdk_draw_arc(inDraw, theInvertGC, TRUE,
+ cx-rx, cy-ry, 2*rx, 2*ry,
+ floor(to-PI/2),floor(to-from));
+ }
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinInvertWedge */
+
+
+OS WinStartPolygon (gint size, OS ios)
+{
+ printf("WinStartPolygon\n");
+ thePolygon = g_new(GdkPoint, size);
+ thePolygonIndex = 0;
+
+ return ios;
+} /* WinStartPolygon */
+
+OS WinEndPolygon (OS ios)
+{
+ printf("WinEndPolygon\n");
+ rfree (thePolygon);
+ thePolygon = NULL;
+
+ return ios;
+} /* WinEndPolygon */
+
+OS WinAddPolygonPoint (gint x, gint y, OS ios)
+{
+ printf("WinAddPolygonPoint\n");
+ thePolygon[thePolygonIndex].x = x;
+ thePolygon[thePolygonIndex].y = y;
+ thePolygonIndex++;
+
+ return ios;
+} /* WinAddPolygonPoint */
+
+void WinDrawPolygon(GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinDrawPolygon\n");
+ if (inDraw) gdk_draw_polygon(inDraw,theDrawGC,FALSE,thePolygon,thePolygonIndex);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinDrawPolygon */
+
+void WinUndrawPolygon (GdkDrawable *drawable)
+{
+ printf("WinUndrawPolygon\n");
+ if (drawable) gdk_draw_polygon(drawable,theEraseGC,FALSE,thePolygon,thePolygonIndex);
+} /* WinUndrawPolygon */
+
+void WinFillPolygon (GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinFillPolygon\n");
+ if (inDraw) gdk_draw_polygon(inDraw,theDrawGC,TRUE,thePolygon,thePolygonIndex);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinFillPolygon */
+
+void WinErasePolygon (GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinErasePolygon\n");
+ if (inDraw) gdk_draw_polygon(inDraw,theEraseGC,TRUE,thePolygon,thePolygonIndex);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinErasePolygon */
+
+void WinInvertPolygon (GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinInvertPolygon\n");
+ if (inDraw) gdk_draw_polygon(inDraw,theInvertGC,TRUE,thePolygon,thePolygonIndex);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinInvertPolygon */
+
+void WinCreateScreenHDC(OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ GdkWindow* theWindow;
+ GdkScreen* theScreen;
+
+ printf("WinCreateScreenHDC\n");
+ InitGTK();
+ theScreen = gdk_screen_get_default();
+ theWindow = gdk_screen_get_root_window(theScreen);
+
+ *oos = ios;
+ *outDraw = GDK_DRAWABLE(theWindow);
+ printf("WinCreateScreenHDC - %d\n",theWindow);
+} /* WinCreateScreenHDC */
+
+OS WinDestroyScreenHDC (GdkDrawable *drawable, OS os)
+{
+ printf("WinDestroyScreenHDC - %d\n",drawable);
+/* g_object_unref(drawable); */
+ return os;
+} /* WinDestroyScreenHDC */
+
+
+/* WinDrawResizedBitmap draws a bitmap on screen. For reasons of efficiency it uses an
+ already created bitmap handle.
+*/
+void WinDrawResizedBitmap (gint sourcew, gint sourceh, gint destx, gint desty,
+ gint destw, gint desth, GdkPixbuf *pixbuf, GdkDrawable *inDraw,
+ OS ios, GdkDrawable **outDraw, OS *oos)
+{
+/* HDC compatibleDC;
+ POINT sourcesize, destsize, dest, origin;
+ HGDIOBJ prevObj;
+
+ sourcesize.x = sourcew;
+ sourcesize.y = sourceh;
+ origin.x = 0;
+ origin.y = 0;
+ destsize.x = destw;
+ destsize.y = desth;
+ dest.x = destx;
+ dest.y = desty;
+
+ // Create a compatible device context
+ compatibleDC = CreateCompatibleDC (hdc);
+ if (compatibleDC == NULL)
+ rMessageBox (NULL,MB_APPLMODAL,"WinDrawResizedBitmap","CreateCompatibleDC failed");
+
+ // Select bitmap into compatible device context
+ prevObj = SelectObject (compatibleDC, hbmp);
+ SetMapMode (compatibleDC, GetMapMode (hdc));
+ DPtoLP (hdc, &destsize, 1);
+ DPtoLP (hdc, &dest, 1);
+ DPtoLP (compatibleDC, &sourcesize, 1);
+ DPtoLP (compatibleDC, &origin, 1);
+
+ if (!StretchBlt (hdc, dest.x, dest.y, destsize.x, destsize.y, compatibleDC, origin.x, origin.y, sourcesize.x, sourcesize.y, SRCCOPY))
+ rMessageBox (NULL,MB_APPLMODAL,"WinDrawResizedBitmap","StretchBlt failed");
+
+ SelectObject (compatibleDC, prevObj);
+ DeleteDC (compatibleDC);*/
+ printf("WinDrawResizedBitmap is not implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinDrawResizedBitmap */
+
+/* ... MW */
+void WinDrawBitmap (gint w, gint h, gint destx, gint desty, GdkPixbuf *pixbuf,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinDrawBitmap\n");
+ /* if (drawable) gdk_draw_drawable(drawable,theDrawGC,GDK_DRAWABLE(pixbuf),0,0,destx,desty,w,h); */
+ if (inDraw)
+ {
+ gdk_pixbuf_render_to_drawable (pixbuf, inDraw, theDrawGC, 0, 0, destx,
+ desty, w, h, GDK_RGB_DITHER_NONE, 0, 0);
+ }
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinDrawBitmap */
+
+void WinCreateBitmap (gint width, gchar *filename, GdkDrawable *inDraw,OS ios,
+ GdkPixbuf **bitmap, OS* oos)
+{
+ GError *err = NULL;
+
+ printf("WinCreateBitmap\n");
+ InitGTK();
+ *bitmap = gdk_pixbuf_new_from_file(filename, &err);
+
+ /*
+ *pWidth = gdk_pixbuf_get_width(pixbuf);
+ *pHeight = gdk_pixbuf_get_height(pixbuf);
+ */
+
+ *oos = ios;
+} /* WinCreateBitmap */
+
+void WinDisposeBitmap (GdkPixbuf *pixbuf)
+{
+ printf("WinDisposeBitmap\n");
+ gdk_pixbuf_unref(pixbuf);
+}
+
+
+/*-----------------------------
+ Font stuff
+ -----------------------------*/
+
+void WinSetFont (CLEAN_STRING fontName, gint style, gint size,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinSetFont\n");
+ if (theFont) gdk_font_unref(theFont);
+
+ pango_font_description_set_family(theFontDesc,cstring(fontName));
+ pango_font_description_set_weight(theFontDesc,(style & iBold) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
+ pango_font_description_set_style(theFontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
+ /* plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
+ /* plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
+ pango_font_description_set_size(theFontDesc, size*PANGO_SCALE);
+ theFont = gdk_font_from_description(theFontDesc);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinSetFont */
+
+void WinGetFontInfo (CLEAN_STRING fontName, gint style, gint size,
+ gint drawablePassed, GdkDrawable *drawable, OS ios,
+ gint *ascent, gint *descent, gint *maxwidth,
+ gint *leading, OS* oos )
+{
+ PangoContext *pc;
+ PangoFontset *fontset;
+ PangoFontMetrics *metrics;
+ PangoFontDescription *fontDesc;
+ GtkWidget *widget;
+ gchar *fName;
+ gboolean inDrawIsWidget;
+ printf("WinGetFontInfo\n");
+
+ fName = cstring(fontName);
+ inDrawIsWidget = GTK_IS_WIDGET(drawable);
+
+ printf("WinGetFontInfo - %d\n",drawable);
+ if (! inDrawIsWidget)
+ {
+ widget = gtk_label_new(NULL);
+ drawablePassed = 0;
+ } else {widget=GTK_WIDGET(drawable);}
+ pc = gtk_widget_get_pango_context(widget);
+ fontDesc = pango_font_description_new();
+
+ printf("Font Name: %s\n", fName);
+ pango_font_description_set_family(fontDesc,fName);
+ pango_font_description_set_weight(fontDesc,(style & iBold) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
+ pango_font_description_set_style(fontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
+ /* plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
+ /* plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
+ pango_font_description_set_size(fontDesc, size*PANGO_SCALE);
+
+ pango_context_set_font_description(pc, fontDesc);
+ metrics = pango_context_get_metrics (pc, fontDesc,
+ pango_context_get_language(pc));
+
+
+ *ascent = PANGO_PIXELS(pango_font_metrics_get_ascent(metrics));
+ *descent = PANGO_PIXELS(pango_font_metrics_get_descent(metrics));
+ *maxwidth = PANGO_PIXELS(pango_font_metrics_get_approximate_char_width(metrics));
+ *leading = 2; /* FIXME */
+
+ /* Pango gets the heights a bit wrong, so fudge it. */
+ *ascent = (*ascent) + 1;
+ *descent = (*descent) + 1;
+
+ printf("About to free font description\n");
+ g_object_unref(G_OBJECT(pc));
+ if (! inDrawIsWidget)
+ {
+ gtk_widget_destroy(widget);
+ }
+ pango_font_metrics_unref(metrics);
+ pango_font_description_free(fontDesc);
+ printf("Freed it.\n");
+ /* Connect the input and output */
+ *oos = ios;
+} /* WinGetFontInfo */
+
+void WinGetPicFontInfo (GdkDrawable *inDraw, OS ios, gint *ascent,
+ gint *descent, gint *maxwidth, gint *leading,
+ GdkDrawable **outDraw, OS *oos)
+{
+ PangoFontset *fontset;
+ PangoFontMetrics *metrics;
+
+ printf("WinGetPicFontInfo\n");
+ fontset = pango_font_map_load_fontset
+ (pango_ft2_font_map_for_display(),
+ gdk_pango_context_get(),
+ theFontDesc,
+ pango_language_from_string("EN"));
+ metrics = pango_fontset_get_metrics(fontset);
+ *ascent = pango_font_metrics_get_ascent(metrics);
+ *descent = pango_font_metrics_get_descent(metrics);
+ *maxwidth = pango_font_metrics_get_approximate_char_width(metrics);
+ *leading = 2; /* FIXME */
+ pango_font_metrics_unref(metrics);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinGetPicFontInfo */
+
+void WinGetPicStringWidth (CLEAN_STRING string, GdkDrawable *inDraw, OS ios,
+ gint *width, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinGetPicStringWidth\n");
+ *width = gdk_string_width(theFont, cstring(string));
+ printf("Width: %d, String: %s\n", *width, cstring(string));
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinGetPicStringWidth */
+
+void WinGetPicCharWidth (gchar ch, GdkDrawable *inDraw, OS ios, gint *width,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinGetPicCharWidth\n");
+ *width = gdk_char_width(theFont, ch);
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinGetPicCharWidth */
+
+void WinGetStringWidth (CLEAN_STRING string, CLEAN_STRING fontName, gint style,
+ gint size, gint drawablePassed, GdkDrawable *drawable, OS ios,
+ gint *width, OS *oos)
+{
+ GdkFont *font;
+ PangoFontDescription *fontDesc;
+ PangoContext *pc;
+ PangoLayout *pl;
+ GtkWidget *widget;
+ gchar* fName;
+ gboolean inDrawIsWidget;
+ printf("WinGetStringWidth\n");
+
+ fName = cstring(fontName);
+ inDrawIsWidget = GTK_IS_WIDGET(drawable);
+
+ if (! inDrawIsWidget)
+ {
+ widget = gtk_label_new(NULL);
+ }
+ else
+ {
+ widget = GTK_WIDGET(drawable);
+ }
+
+ pc = gtk_widget_get_pango_context(widget);
+ fontDesc = pango_font_description_new();
+
+ printf("Font Name: %s\n", fName);
+ pango_font_description_set_family(fontDesc,fName);
+ pango_font_description_set_weight(fontDesc,(style & iBold) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
+ pango_font_description_set_style(fontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
+ /* plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
+ /* plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
+ pango_font_description_set_size(fontDesc, size*PANGO_SCALE);
+
+ pango_context_set_font_description(pc, fontDesc);
+ pl = pango_layout_new(pc);
+ pango_layout_set_text(pl, string->characters, string->length);
+ pango_layout_get_pixel_size(pl, width, NULL);
+
+ g_object_unref(G_OBJECT(pl));
+ g_object_unref(G_OBJECT(pc));
+ if (! inDrawIsWidget)
+ {
+ gtk_widget_destroy(GTK_WIDGET(widget));
+ }
+ pango_font_description_free(fontDesc);
+
+ /* HACK: Pango seems to generate overly narrow widths based on
+ * the font settings.
+ * a bit too small. So fudge it.
+ */
+ *width = *width * 1.25;
+ printf("Width: %d, String: %s\n", *width, cstring(string));
+
+ *oos = ios;
+} /* WinGetStringWidth */
+
+void WinGetCharWidth (gchar ch, CLEAN_STRING fontName, gint style, gint size,
+ gint drawablePassed, GdkDrawable *drawable, OS ios, gint* width,
+ OS *oos)
+{
+ GdkFont *font;
+ PangoFontDescription *fontDesc;
+ PangoContext *pc;
+ PangoLanguage *lang;
+ PangoFontMetrics *metrics;
+ GtkWidget *widget;
+ gchar *fName;
+ gboolean inDrawIsWidget;
+ printf("WinGetCharWidth\n");
+
+ fName = cstring(fontName);
+ inDrawIsWidget = GTK_IS_WIDGET(drawable);
+
+ if (! inDrawIsWidget)
+ {
+ widget = gtk_label_new(NULL);
+ }
+ else
+ {
+ widget = GTK_WIDGET(drawable);
+ }
+
+ pc = gtk_widget_get_pango_context(widget);
+ fontDesc = pango_font_description_new();
+ printf("Font Name: %s\n", fName);
+
+ pango_font_description_set_family(fontDesc,cstring(fontName));
+ pango_font_description_set_weight(fontDesc,(style & iBold) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
+ pango_font_description_set_style(fontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
+ /* plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
+ /* plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
+ pango_font_description_set_size(fontDesc, size*PANGO_SCALE);
+ lang = pango_context_get_language(pc);
+ metrics = pango_context_get_metrics(pc, fontDesc, lang);
+
+ *width = pango_font_metrics_get_approximate_char_width(metrics);
+
+ pango_font_description_free(fontDesc);
+ pango_font_metrics_unref(metrics);
+ g_object_unref(G_OBJECT(pc));
+ if (! inDrawIsWidget)
+ {
+ gtk_widget_destroy(widget);
+ }
+
+ *oos = ios;
+} /* WinGetCharWidth */
+
+
+void getResolutionC(GdkDrawable *drawable, int *xResP, int *yResP)
+{
+ printf("getResolutionC\n");
+ *xResP = gdk_screen_width();
+ *yResP = gdk_screen_height();
+} /* getResolutionC */
+
+void WinGetPictureScaleFactor(GdkDrawable* inDraw, OS ios, gint *nh, gint *dh,
+ gint *nv, gint *dv, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinGetPictureScaleFactor\n");
+ *nh = 1;
+ *dh = 1;
+ *nv = 1;
+ *dv = 1;
+ *outDraw = inDraw;
+ *oos = ios;
+} /* WinGetPictureScaleFactor */
+
+void WinDefaultFontDef(gchar **fname, gint *fstyle, gint *fsize)
+{
+ printf("WinDefaultFontDef\n");
+ *fname = "helvetica";
+ *fstyle = 0;
+ *fsize = 12;
+}
+
+void WinDialogFontDef(gchar **fname, gint *fstyle, gint *fsize)
+{
+ printf("WinDialogFontDef\n");
+ *fname = "helvetica";
+ *fstyle = 0;
+ *fsize = 12;
+}
+
+void WinSerifFontDef(gchar **fname, gint *fstyle, gint *fsize)
+
+{
+ printf("WinSerifFontDef\n");
+ *fname = "times";
+ *fstyle = 0;
+ *fsize = 10;
+}
+
+void WinSansSerifFontDef(gchar **fname, gint *fstyle, gint *fsize)
+
+{
+ printf("WinSansSerifFontDef\n");
+ *fname = "helvetica";
+ *fstyle = 0;
+ *fsize = 10;
+}
+
+void WinSmallFontDef(gchar **fname, gint *fstyle, gint *fsize)
+{
+ printf("WinSmallFontDef\n");
+ *fname = "helvetica";
+ *fstyle = 0;
+ *fsize = 7;
+}
+
+void WinNonProportionalFontDef(gchar **fname, gint *fstyle, gint *fsize)
+{
+ printf("WinNonProportionalFontDef\n");
+ *fname = "fixed";
+ *fstyle = 0;
+ *fsize = 10;
+}
+
+void WinSymbolFontDef(gchar **fname, gint *fstyle, gint *fsize)
+{
+ printf("WinSymbolFontDef\n");
+ *fname = "adobe-symbol";
+ *fstyle = 0;
+ *fsize = 10;
+}
+
+void WinCombineRgn (GdkRegion *dest, GdkRegion *src1, GdkRegion *src2,
+ gint fnCombineMode, OS ios, GdkRegion **outDest, OS *oos)
+{
+ printf("WinCombineRgn\n");
+ dest = gdk_region_copy(src1);
+
+ switch(fnCombineMode)
+ {
+ case RGN_AND:
+ printf("RGN_AND\n");
+ gdk_region_intersect(dest, src2);
+ break;
+ case (RGN_OR):
+ printf("RGN_OR\n");
+ gdk_region_union(dest, src2);
+ break;
+ case (RGN_DIFF):
+ printf("RGN_DIFF\n");
+ gdk_region_subtract(dest, src2);
+ break;
+ case (RGN_XOR):
+ printf("RGN_XOR\n");
+ gdk_region_xor(dest, src2);
+ break;
+ case (RGN_COPY):
+ default:
+ /* We already copied the region, so just return it */
+ printf("RGN_COPY\n");
+ break;
+ }
+
+ *outDest = dest;
+ *oos = ios;
+}
+
+void WinSetRgnToRect (gint left, gint top, gint right, gint bottom,
+ GdkRegion *rgn, OS ios, GdkRegion **orgn, OS *oos)
+{
+ GdkRegion* r = NULL;
+ printf("WinSetRgnToRect --> Not Implemented\n");
+ *orgn = rgn;
+ *oos = ios;
+}
+
+/*
+ * Review of source indicates this is always called on a GdkRegion*
+ */
+OS WinDeleteObject (GdkRegion* region, OS ios)
+{
+ printf("WinDeleteObject\n");
+ if (region)
+ {
+ gdk_region_destroy(region);
+ }
+ return ios;
+}
+
+void WinClipPicture (gint left, gint top, gint right, gint bot,
+ GdkDrawable *drawable, OS ios, GdkDrawable **outDraw,
+ OS *oos)
+{
+ printf("WinClipPicture\n");
+
+ /* Do something here */
+
+ *outDraw = drawable;
+ *oos = ios;
+}
+
+void InternalGetPenPos (GdkDrawable *context, gint *x, gint *y)
+{
+ GdkPoint *p;
+ printf("InternalGetPenPos: ");
+ p = (GdkPoint*)(g_object_get_data(G_OBJECT(context), PEN_POS_KEY));
+ if (p)
+ {
+ *x = p->x;
+ *y = p->y;
+ rprintf("Pen Pos: (%d, %d)\n", *x, *y);
+ } else {
+ rprintf("No data for current-pen-position.\n");
+ }
+}
+
+void InternalSetPenPos (GdkDrawable *context, gint x, gint y)
+{
+ GdkPoint *p;
+ printf("InternalSetPenPos\n");
+
+ p = g_new(GdkPoint,1);
+ printf("InternalSetPenPos: (%d, %d)\n", x, y);
+
+ p->x = x;
+ p->y = y;
+ g_object_set_data(G_OBJECT(context), PEN_POS_KEY, (gpointer)p);
+}
+
+void WinGetPenPos (GdkDrawable *inDraw, OS ios, gint *x, gint *y,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinGetPenPos\n");
+
+ InternalGetPenPos(inDraw, x, y);
+
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinMovePenTo (gint x, gint y, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinMovePenTo\n");
+
+ InternalSetPenPos(inDraw, x, y);
+
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinMovePen (gint dx, gint dy, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ gint x, y;
+
+ printf("WinMovePen\n");
+ InternalGetPenPos(inDraw, &x, &y);
+ x += dx;
+ y += dy;
+
+ InternalSetPenPos(inDraw, x, y);
+
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinDrawCPoint (gint x, gint y, gint red, gint green, gint blue,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinDrawCPoint --> Not Implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinDrawCLine (gint startX, gint startY, gint endX, gint endY, gint red,
+ gint green, gint blue, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinDrawCLine --> Not Implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinDrawCCurve (gint left, gint top, gint right, gint bot, gint startradx,
+ gint startrady, gint endradx, gint endrady, gint red,
+ gint green, gint blue, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS * oos)
+{
+ printf("WinDrawCCurve --> Not Implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinScrollRectangle2 (gint left, gint top, gint right, gint bot, gint width,
+ gint height, GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw,
+ OS *oos)
+{
+ printf("WinScrollRectangle2 --> Not Implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinDrawRoundRectangle (gint left, gint top, gint right, gint bottom,
+ gint width, gint height, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinDrawRoundRectangle --> Not Implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinFillRoundRectangle (gint left, gint top, gint right, gint bot,
+ gint width, gint height, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinFillRoundRectangle --> Not Implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinEraseRoundRectangle (gint left, gint top, gint right, gint bot,
+ gint width, gint height, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinEraseRoundRectangle --> Not Implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinInvertRoundRectangle (gint left, gint top, gint right, gint bot,
+ gint width, gint height, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinInvertRoundRectangle --> Not Implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinDrawCircle (gint centerx, gint centery, gint radius,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinDrawCircle --> Not Implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinFillCircle (gint centerx, gint centery, gint radius,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinFillCircle --> Not Implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinEraseCircle (gint centerx, gint centery, gint radius,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinEraseCircle --> Not Implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinInvertCircle (gint centerx, gint centery, gint radius,
+ GdkDrawable *inDraw, OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinInvertCircle --> Not Implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinDrawWedge (gint left, gint top, gint right, gint bottom, gint startradx,
+ gint startrady, gint endradx, gint endrady, GdkDrawable *inDraw,
+ OS ios, GdkDrawable **outDraw, OS *oos)
+{
+ gint cx, cy;
+ gint x = left;
+ gint y = top;
+ gint rx = right;
+ gint ry = bottom;
+ gfloat from = startradx;
+ gfloat to = startrady;
+ gboolean clockwise = TRUE;
+
+ printf("WinDrawWedge --> Not Implemented\n");
+
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinPrintResizedBitmap (gint sz2, gint sy2, gint dx1, gint dy1, gint dw,
+ gint dh, gchar* ptr, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinPrintResizedBitmap --> Not implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinSetFontName (CLEAN_STRING fontName, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinSetFontName --> Not Implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinSetFontSize (gint size, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinSetFontSize: %d\n", size);
+ pango_font_description_set_size(theFontDesc, size*PANGO_SCALE);
+ theFont = gdk_font_from_description(theFontDesc);
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinSetFontStyle (gint style, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinSetFontStyle: %d\n", style);
+ pango_font_description_set_style(theFontDesc,(style & iItalic) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
+ /* plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE; */
+ /* plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE; */
+ theFont = gdk_font_from_description(theFontDesc);
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+gint WinGetVertResolution (void)
+{
+ static gint res = 0;
+ printf("WinGetVertResolution\n");
+
+ InitGTK();
+
+ if (res == 0)
+ {
+ GdkScreen* screen;
+ GdkWindow* window;
+ GdkRectangle rect;
+
+ InitGTK();
+ screen = gdk_screen_get_default();
+ window = gdk_screen_get_root_window(screen);
+ gdk_window_get_frame_extents(window, &rect);
+
+ res = rect.height;
+ g_object_unref(window);
+ }
+
+ return res;
+}
+
+gint WinGetHorzResolution (void)
+{
+ static gint res = 0;
+ printf("WinGetHorzResolution\n");
+
+ InitGTK();
+
+ if (res == 0)
+ {
+ GdkScreen* screen;
+ GdkWindow* window;
+ GdkRectangle rect;
+
+ screen = gdk_screen_get_default();
+ window = gdk_screen_get_root_window(screen);
+ gdk_window_get_frame_extents(window, &rect);
+
+ res = rect.width;
+ g_object_unref(window);
+ }
+
+ return res;
+}
+
+void WinLinePen (gint x, gint y, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinLinePen --> Not implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinLinePenTo (gint x, gint y, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos)
+{
+ printf("WinLinePenTo --> Not implemented\n");
+ *outDraw = inDraw;
+ *oos = ios;
+}
+
+void WinCreateEllipseRgn(gint nLeftRect, gint nTopRect, gint nRightRect,
+ gint nBottomRect, OS ios, GdkRegion* rgn, OS* oos)
+{
+ printf("WinCreateEllipseRgn --> Not Implemented\n");
+ *oos = ios;
+}
diff --git a/Linux_C_12/cpicture_121.h b/Linux_C_12/cpicture_121.h new file mode 100644 index 0000000..d6b564a --- /dev/null +++ b/Linux_C_12/cpicture_121.h @@ -0,0 +1,191 @@ +#include "util_121.h"
+#include "intrface_121.h"
+#include <math.h>
+
+#define RGN_AND 1 /* Creates the intersection of the two regions */
+#define RGN_OR 2 /* creates the union of the two regions */
+#define RGN_DIFF 3 /* Returns the parts of region1 not in region2 */
+#define RGN_XOR 4 /* creates the union (not including overlap) */
+#define RGN_COPY 5 /* Creates a copy of the region */
+
+extern void WinGetDC (OSWindowPtr, OS, OSPictContext*, OS*);
+extern OS WinReleaseDC (OSWindowPtr,OSPictContext,OS);
+extern int OsMMtoVPixels(double);
+extern int OsMMtoHPixels(double);
+
+void WinInitPicture (int size, int mode, int pr, int pg, int pb,
+ int br, int bg, int bb, int x, int y,
+ CLEAN_STRING fname, int fstyle, int fsize,
+ int ox, int oy, OSPictContext inDraw, OS os,
+ OSPictContext *outDraw, OS *oos);
+extern void WinDonePicture (OSPictContext,OS,int*,int*,int*,int*,int*,
+ int*,int*,int*,int*,int*,CLEAN_STRING*,int*,int*,
+ OSPictContext*,OS*);
+
+extern void WinClipRgnPicture(OSRgnHandle,OSPictContext,OS,
+ OSPictContext*,OS*);
+extern void WinClipPicture (int,int,int,int,OSPictContext,OS,
+ OSPictContext*,OS*);
+extern void WinSetClipRgnPicture (OSRgnHandle,OSPictContext,OS,
+ OSPictContext*,OS*);
+extern void WinGetClipRgnPicture (OSPictContext,OS,OSRgnHandle*,OSPictContext*,OS*);
+
+/* Operations to create, modify, and destroy polygon shapes.
+*/
+extern void WinAllocPolyShape (int,OS,PointsArray*,OS*);
+extern OS WinSetPolyPoint (int,int,int,PointsArray, OS);
+extern OS WinFreePolyShape (PointsArray,OS);
+
+/* Operations to create, modify and destroy regions.
+*/
+extern OSRgnHandle WinCreateEmptyRgn();
+extern void WinCreateRectRgn(int,int,int,int,OS,OSRgnHandle*,OS*);
+extern void WinCreatePolygonRgn(PointsArray,int,int,OS,OSRgnHandle*,OS*);
+extern void WinSetRgnToRect(int,int,int,int,OSRgnHandle,OS,OSRgnHandle*,OS*);
+/* extern OSRgnHandle WinCombineRgn (HRGN,HRGN,HRGN,int,OS,HRGN*,OS*); */
+extern void WinCombineRgn (OSRgnHandle,OSRgnHandle,OSRgnHandle,int,OS,
+ OSRgnHandle*,OS*);
+extern OSRgnHandle WinUnionRgn(OSRgnHandle rgn1, OSRgnHandle rgn2);
+extern OSRgnHandle WinSectRgn(OSRgnHandle rgn1, OSRgnHandle rgn2);
+extern OSRgnHandle WinDiffRgn(OSRgnHandle rgn1, OSRgnHandle rgn2);
+extern OSRgnHandle WinXorRgn (OSRgnHandle rgn1, OSRgnHandle rgn2);
+extern void WinGetRgnBox(OSRgnHandle,OS,int*,int*,int*,int*,BOOL*,BOOL*,OS*);
+extern BOOL WinIsEmptyRgn(OSRgnHandle rgn);
+extern void WinDisposeRgn(OSRgnHandle rgn);
+
+extern void WinSetPenSize (int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinSetPenColor (int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinSetBackColor (int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinSetMode (int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinSetPattern (int,OSPictContext,OS,OSPictContext*,OS*);
+
+extern void WinDrawPoint (int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinDrawLine (int,int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinUndrawLine(int,int,int,int,OSPictContext);
+extern void WinDrawCurve (int,int,int,int,int,int,int,int,OSPictContext,OS,
+ OSPictContext*,OS*);
+extern void WinUndrawCurve (int,int,int,int,float,float,BOOL,OSPictContext);
+
+extern void WinDrawChar (char,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinUndrawChar (int,int,char,OSPictContext);
+extern void WinDrawString (CLEAN_STRING,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinUndrawString (int,int,char*,OSPictContext);
+
+extern void WinDrawRectangle (int,int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinUndrawRectangle (int,int,int,int,OSPictContext);
+extern void WinFillRectangle (int,int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinEraseRectangle (int,int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinInvertRectangle (int,int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinMoveRectangleTo (int,int,int,int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinMoveRectangle (int,int,int,int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinCopyRectangleTo (int,int,int,int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinCopyRectangle (int,int,int,int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinScrollRectangle (int,int,int,int,int,int,OSPictContext,OS,int*,int*,int*,int*,OSPictContext*,OS*);
+
+extern void WinDrawOval (int,int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinUndrawOval (int,int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinFillOval (int,int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinEraseOval (int,int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinInvertOval (int,int,int,int,OSPictContext,OS,OSPictContext*,OS*);
+
+extern void WinFillWedge (int,int,int,int,int,int,int,int,OSPictContext,
+ OS,OSPictContext*,OS*);
+extern void WinEraseWedge (int,int,int,int,int,int,int,int,OSPictContext,
+ OS,OSPictContext*,OS*);
+extern void WinInvertWedge (int,int,int,int,int,int,int,int,OSPictContext,
+ OS,OSPictContext*,OS*);
+
+extern OS WinStartPolygon (int,OS);
+extern OS WinEndPolygon (OS);
+extern OS WinAddPolygonPoint (int,int,OS);
+extern void WinDrawPolygon (OSPictContext,OS,OSPictContext*,OS*);
+extern void WinUndrawPolygon (OSPictContext);
+extern void WinFillPolygon (OSPictContext,OS,OSPictContext*,OS*);
+extern void WinErasePolygon (OSPictContext,OS,OSPictContext*,OS*);
+extern void WinInvertPolygon (OSPictContext,OS,OSPictContext*,OS*);
+
+/*
+ * Routines that temporarily create and destroy a DISPLAY OSPictContext. Use
+ * this OSPictContext only locally.
+ */
+extern void WinCreateScreenHDC (OS,OSPictContext*,OS*);
+extern OS WinDestroyScreenHDC (OSPictContext,OS);
+
+extern void WinDrawResizedBitmap (int,int,int,int,int,int,OSBmpHandle,
+ OSPictContext,OS,OSPictContext*,OS*);
+extern void WinDrawBitmap (int,int,int,int,OSBmpHandle,OSPictContext,OS,
+ OSPictContext*,OS*);
+extern void WinCreateBitmap (int, char*,OSPictContext,OS,OSBmpHandle*,OS*);
+extern void WinDisposeBitmap(OSBmpHandle);
+
+extern void WinSetFont (CLEAN_STRING,int,int,OSPictContext,OS,OSPictContext*,OS*);
+extern void WinGetFontInfo (CLEAN_STRING,int,int,int,OSPictContext,OS,
+ int*,int*,int*,int*,OS*);
+extern void WinGetPicFontInfo (OSPictContext,OS,int*,int*,int*,int*,
+ OSPictContext*,OS*);
+
+extern void WinGetPicStringWidth (CLEAN_STRING,OSPictContext,OS,int*,OSPictContext*,OS*);
+extern void WinGetPicCharWidth (char,OSPictContext,OS,int*,OSPictContext*,OS*);
+extern void WinGetStringWidth (CLEAN_STRING,CLEAN_STRING,int,int,int,
+ OSPictContext,OS,int*,OS*);
+extern void WinGetCharWidth (char,CLEAN_STRING,int,int,int,OSPictContext,
+ OS,int*,OS*);
+
+/* Get the resolution of a picture */
+extern void getResolutionC(OSPictContext,int*,int*);
+
+/*
+ * Get scaling factors, which have to be applied to coordinates for clipping
+ * regions in case of emulating the screen resolution for printing
+ * (MM_ISOTROPIC)
+ */
+extern void WinGetPictureScaleFactor(OSPictContext,OS,int*,int*,int*,int*,
+ OSPictContext*,OS*);
+
+void WinDialogFontDef(char **fname, int *fstyle, int *fsize);
+void WinDefaultFontDef(char **fname, int *fstyle, int *fsize);
+void WinSerifFontDef(char **fname, int *fstyle, int *fsize);
+void WinSansSerifFontDef(char **fname, int *fstyle, int *fsize);
+void WinSmallFontDef(char **fname, int *fstyle, int *fsize);
+void WinNonProportionalFontDef(char **fname, int *fstyle, int *fsize);
+void WinSymbolFontDef(char **fname, int *fstyle, int *fsize);
+
+extern void WinLinePen (int x, int y, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos);
+extern void WinLinePenTo (int x, int y, GdkDrawable *inDraw, OS ios,
+ GdkDrawable **outDraw, OS *oos);
+
+extern int WinGetVertResolution (void);
+extern int WinGetHorzResolution (void);
+
+extern void WinCreateEllipseRgn (int,int,int,int,OS,GdkRegion*,OS*);
+extern OS WinDeleteObject (GdkRegion*,OS);
+extern void WinGetPenPos(GdkDrawable*, OS, int*, int*, GdkDrawable**, OS* );
+extern void WinMovePenTo (int,int,GdkDrawable*,OS,GdkDrawable**,OS*);
+extern void WinMovePen (int,int,GdkDrawable*,OS,GdkDrawable**,OS*);
+extern void WinDrawCPoint (int,int,int,int,int,GdkDrawable*,
+ OS,GdkDrawable**,OS*);
+extern void WinDrawCLine (int,int,int,int,int,int,int,GdkDrawable*,OS,
+ GdkDrawable**,OS*);
+extern void WinDrawCCurve (int,int,int,int,int,int,int,int,int,int,int,
+ GdkDrawable*,OS,GdkDrawable**,OS*);
+extern void WinDrawRoundRectangle (int,int,int,int,int,int,GdkDrawable*,
+ OS,GdkDrawable**,OS*);
+extern void WinFillRoundRectangle (int,int,int,int,int,int,GdkDrawable*,
+ OS,GdkDrawable**,OS*);
+extern void WinEraseRoundRectangle (int,int,int,int,int,int,GdkDrawable*,
+ OS,GdkDrawable**,OS*);
+extern void WinInvertRoundRectangle (int,int,int,int,int,int,GdkDrawable*,
+ OS,GdkDrawable**,OS*);
+extern void WinDrawCircle (int,int,int,GdkDrawable*,OS,GdkDrawable**,OS*);
+extern void WinFillCircle (int,int,int,GdkDrawable*,OS,GdkDrawable**,OS*);
+extern void WinEraseCircle (int,int,int,GdkDrawable*,OS,GdkDrawable**,OS*);
+extern void WinInvertCircle (int,int,int,GdkDrawable*,OS,GdkDrawable**,OS*);
+
+extern void WinDrawWedge (int,int,int,int,int,int,int,int,GdkDrawable*,
+ OS,GdkDrawable**,OS*);
+extern void WinPrintResizedBitmap (int,int,int,int,int,int,char*,GdkDrawable*,
+ int,GdkDrawable**,int*);
+
+static void InternalGetPenPos( GdkDrawable*, int*, int*);
+static void InternalSetPenPos( GdkDrawable*, int, int);
diff --git a/Linux_C_12/cprinter_121.c b/Linux_C_12/cprinter_121.c new file mode 100644 index 0000000..8e635a3 --- /dev/null +++ b/Linux_C_12/cprinter_121.c @@ -0,0 +1,602 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library and Clean 0.8 I/O library
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ Routines related to printing.
+********************************************************************************************/
+
+#include "util_121.h"
+#include "cpicture_121.h"
+
+#include "cprinter_121.h"
+
+BOOL bUserAbort;
+int semaphor=0;
+
+#if 0
+HWND hDlgPrint;
+HWND hwndButton,hwndText;
+
+extern HWND ghMainWindow;
+extern HINSTANCE ghInst;
+#else
+#define CALLBACK
+#define APIENTRY
+typedef void* HANDLE;
+typedef void* HWND;
+typedef void* DEVMODE;
+typedef void* PRINTDLG;
+typedef void** LPHANDLE;
+typedef char* LPCTSTR;
+#endif
+
+
+#define tachtig 80
+void getDevmodeSizeC(int *size, HANDLE *phPrinter,
+ char **device, char **driver, char **output)
+{
+#if 0
+ char szPrinter[80];
+ char *szDevice, *szDriver, *szOutput;
+
+ GetProfileString("windows", "device", ",,,", szPrinter, 80);
+ szDevice = strtok(szPrinter,",");
+ szDriver = strtok(NULL,", ");
+ szOutput = strtok(NULL,", ");
+ *device = g_strdup(szDevice);
+ *driver = g_strdup(szDriver);
+ *output = g_strdup(szOutput);
+ if (*szDevice=='\0' || *szDriver=='\0' || *szOutput=='\0')
+ {
+ *size = 0;
+ return;
+ };
+ OpenPrinter(szDevice,phPrinter,NULL);
+ *size = DocumentProperties(NULL,*phPrinter,szDevice,NULL,NULL,0);
+#endif
+}
+
+void getDefaultDevmodeC(char *printSetup, LPHANDLE phPrinter, char **device)
+{
+#if 0
+ int size,r1;
+
+ size = ((int*)printSetup)[0];
+ printSetup +=4;
+ r1 = DocumentProperties(NULL,phPrinter,((char*)device)+4,
+ (DEVMODE*)printSetup,NULL,DM_OUT_BUFFER);
+ ClosePrinter(phPrinter);
+#endif
+}
+
+#if 0
+static HDC myCreateIC(LPCTSTR driver, LPCTSTR device, DEVMODE *devmode)
+{
+ HDC icPrint;
+
+ icPrint = CreateIC(driver,device,NULL,devmode);
+ if (!icPrint)
+ icPrint = CreateIC(driver,device,NULL,devmode);
+ /* try once again. Adobe printer drivers sometimes need to be told everything twice */
+ return icPrint;
+}
+#endif
+
+#define GetDeviceCapsWithDefault(icPrint, index, defaullt) (icPrint ? GetDeviceCaps(icPrint, index) : defaullt)
+
+void os_getpagedimensionsC( DEVMODE *devmode, char *device, char *driver,
+ int emulateScreenRes,
+ int *maxX, int *maxY,
+ int *leftPaper, int *topPaper,
+ int *rightPaper, int *bottomPaper,
+ int *xRes, int *yRes
+ )
+{
+#if 0
+ HDC icPrint;
+ int horPaperPixels, verPaperPixels,
+ xResolution,yResolution,
+ scNX, scNY, scDX, scDY;
+
+
+ icPrint = myCreateIC(driver,device, devmode);
+
+ xResolution = GetDeviceCapsWithDefault(icPrint, LOGPIXELSX, 300);
+ yResolution = GetDeviceCapsWithDefault(icPrint, LOGPIXELSY, 300);
+ if (emulateScreenRes) /* for emulation of the screen resolution */
+ {
+ scNX = WinGetHorzResolution(); /* all the deviceCaps will be scaled */
+ scNY = WinGetVertResolution();
+ scDX = xResolution;
+ scDY = yResolution;
+ }
+ else
+ { scNX = 1; scNY = 1; scDX = 1; scDY = 1; };
+
+ horPaperPixels = (GetDeviceCapsWithDefault(icPrint, PHYSICALWIDTH, 2246)*scNX)/scDX;
+ verPaperPixels = (GetDeviceCapsWithDefault(icPrint, PHYSICALHEIGHT, 3250)*scNY)/scDY;
+
+ *maxX = (GetDeviceCapsWithDefault(icPrint, HORZRES, 2241)*scNX)/scDX;
+ *maxY = (GetDeviceCapsWithDefault(icPrint, VERTRES, 3254)*scNY)/scDY;
+
+ *leftPaper = (-GetDeviceCapsWithDefault(icPrint, PHYSICALOFFSETX, 116)*scNX)/scDX;
+ *topPaper = (-GetDeviceCapsWithDefault(icPrint, PHYSICALOFFSETY, 129)*scNY)/scDY;
+ *rightPaper = horPaperPixels - *leftPaper;
+ *bottomPaper = verPaperPixels - *topPaper;
+
+ if (emulateScreenRes)
+ { *xRes = scNX; *yRes = scNY; }
+ else
+ { *xRes = xResolution ; *yRes = yResolution; };
+ DeleteDC(icPrint);
+#endif
+}
+
+static HANDLE setupDevnames(int deviceLength,int driverLength,int outputLength,
+ char *device,char *driver,char *output)
+{
+ HANDLE hDevnames;
+#if 0
+ DEVNAMES *pDevnames;
+ hDevnames = (HANDLE) LocalAlloc(LMEM_MOVEABLE, 16+deviceLength+driverLength+outputLength);
+ pDevnames = LocalLock(hDevnames);
+ pDevnames->wDriverOffset = 16;
+ pDevnames->wDeviceOffset = 16+driverLength;
+ pDevnames->wOutputOffset = 16+driverLength+deviceLength;
+ pDevnames->wDefault = 0;
+ strcpy(((char*)pDevnames)+pDevnames->wDriverOffset, driver);
+ strcpy(((char*)pDevnames)+pDevnames->wDeviceOffset, device);
+ strcpy(((char*)pDevnames)+pDevnames->wOutputOffset, output);
+ LocalUnlock(hDevnames);
+#endif
+ return hDevnames;
+}
+
+static HANDLE setupDevmode(int size, char *pData)
+{
+ HANDLE hDevmode;
+#if 0
+ DEVMODE *pDevmode;
+
+ hDevmode = (HANDLE) LocalAlloc(LMEM_MOVEABLE, size);
+ pDevmode = LocalLock(hDevmode);
+ memcpy((char*)pDevmode, pData, size);
+ LocalUnlock(hDevmode);
+#endif
+ return hDevmode;
+}
+
+void get_printSetup_with_PRINTDLG(PRINTDLG *pd, char **o_devmode,
+ char **o_device, char **o_driver, char **o_output)
+{
+#if 0
+ char *newDriver, *newDevice, *newOutput;
+ DEVMODE *pDevmode;
+ DEVNAMES *pDevnames;
+
+ pDevmode = LocalLock(pd->hDevMode);
+ *o_devmode = g_strdup(pDevmode->dmDeviceName);
+ LocalUnlock(pd->hDevMode);
+ pDevnames = LocalLock(pd->hDevNames);
+ newDriver = ((char*)pDevnames)+(pDevnames->wDriverOffset);
+ newDevice = ((char*)pDevnames)+(pDevnames->wDeviceOffset);
+ newOutput = ((char*)pDevnames)+(pDevnames->wOutputOffset);
+ *o_driver = g_strdup(newDriver);
+ *o_device = g_strdup(newDevice);
+ *o_output = g_strdup(newOutput);
+ LocalUnlock(pd->hDevNames);
+#endif
+}
+
+/* PA: called in Clean. */
+int release_memory_handles(PRINTDLG *pd, int os) {
+#if 0
+ LocalFree(pd->hDevNames);
+ LocalFree(pd->hDevMode);
+#endif
+ return os;
+ }
+
+/*
+ * This function hooks the Print dialog. It's purpose is to set the dialog in
+ * the foreground.
+ */
+static UINT APIENTRY DialogToFrontHook(HWND hdl, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+#if 0
+ if (msg==WM_INITDIALOG)
+ { SetForegroundWindow(hdl);
+ };
+#endif
+ return FALSE;
+}
+
+void printSetup(int calledFromCleanThread, int devmodeSize,
+ char *devmode, char *device, char *driver, char *output,
+ int *ok, PRINTDLG **pdPtr)
+{
+#if 0
+ int deviceLength, driverLength, outputLength;
+ HANDLE hDevnames,hDevmode;
+ static PRINTDLG pd;
+
+ /* Set up DEVNAMES structure */
+
+ /*rMessageBox(NULL, MB_APPLMODAL, "in printSetup", ""); */
+ deviceLength = strlen(device)+1;
+ driverLength = strlen(driver)+1;
+ outputLength = strlen(output)+1;
+
+ hDevnames = setupDevnames(deviceLength,driverLength,outputLength,device,driver,output);
+
+ /* Set up DEVMODE structure */
+ hDevmode = setupDevmode(devmodeSize,devmode);
+
+ /* Set up print dialog record */
+ pd.lStructSize = sizeof(PRINTDLG);
+ pd.hwndOwner = calledFromCleanThread ? NULL : ghMainWindow; /* (NULL = desktop) */
+/* pd.hwndOwner = NULL; // (NULL = desktop) */
+ /*
+ * The handle must belong to the active thread, otherwise PrintDlg
+ * will crash. When this function is called from the Clean thread,
+ * ghMainWindow will not belong to the active thread.
+ */
+ pd.hDevMode = hDevmode;
+ pd.hDevNames = hDevnames;
+ pd.hDC = NULL;
+ pd.Flags = PD_PRINTSETUP | PD_ENABLESETUPHOOK;
+ pd.nFromPage = 1;
+ pd.nToPage = 1;
+ pd.nMinPage = 1;
+ pd.nMaxPage = USHRT_MAX;
+ pd.nCopies = 1;
+ pd.hInstance = NULL;
+ pd.lCustData = 0L;
+ pd.lpfnPrintHook = NULL;
+ pd.lpfnSetupHook = DialogToFrontHook;
+ pd.lpPrintTemplateName = NULL;
+ pd.lpSetupTemplateName = NULL;
+ pd.hPrintTemplate = NULL;
+ pd.hSetupTemplate = NULL;
+
+ /* Open print dialog */
+ *ok = PrintDlg(&pd);
+ *pdPtr = &pd;
+
+ if (hDevnames!=pd.hDevNames) LocalFree(hDevnames);
+ if (hDevmode!=pd.hDevMode) LocalFree(hDevmode);
+#endif
+}
+
+
+int startPage(int hdc)
+{
+#if 0
+ /*rMessageBox(NULL, MB_APPLMODAL, "in startPage", ""); */
+ return StartPage((HDC) hdc) > 0;
+#else
+ return 0;
+#endif
+}
+
+int endPage(int hdc)
+{
+#if 0
+ /*rMessageBox(NULL, MB_APPLMODAL, "in endPage", ""); */
+ return EndPage((HDC) hdc) > 0;
+#else
+ return 0;
+#endif
+}
+
+int startDoc(int hdc)
+ /* err code: >0:no error, <=0: user cancelled file dialog */
+{
+#if 0
+ static DOCINFO docInfo = { sizeof (DOCINFO), "Clean", NULL, NULL, 0 } ;
+
+ /*rMessageBox(NULL, MB_APPLMODAL, "in startDoc", "");*/
+ bUserAbort = FALSE ;
+
+ return StartDoc((HDC) hdc, &docInfo);
+#else
+ return 0;
+#endif
+}
+
+void endDoc(int hdc)
+{
+#if 0
+ /*rMessageBox(NULL, MB_APPLMODAL, "in endDoc", ""); */
+ if (bUserAbort)
+ AbortDoc((HDC) hdc);
+ else
+ EndDoc((HDC) hdc);
+#endif
+}
+
+void deleteDC(int hdc)
+{
+#if 0
+ /*rMessageBox(NULL, MB_APPLMODAL, "in deleteDC", ""); */
+ DeleteDC((HDC) hdc);
+#endif
+}
+
+int wasCanceled(void)
+{
+#if 0
+ /*rMessageBox(NULL, MB_APPLMODAL, "in wasCanceled", ""); */
+ return bUserAbort;
+#else
+ return 0;
+#endif
+}
+
+/* getDC opens the print job dialog and
+ * lets the user change various settings or gets the default printer
+ */
+
+/* c-strings are passed to this function ! */
+void getDC( int doDialog, int emulateScreen, int calledFromCleanThread, int devmodeLength,
+ char *devmode,char *device,char *driver,char *output,
+ int *err,
+ int *first, int *last, int *copies,
+ PRINTDLG **ppPrintDlg,
+ int *deviceContext
+ )
+ /* err code: -1:no error, others: non fatal error */
+{
+#if 0
+ static PRINTDLG pd;
+ HDC hdcPrint;
+ int ok;
+
+ *err = -1;
+
+ if (doDialog)
+ { /* Set up print dialog record */
+ HANDLE hDevnames, hDevmode;
+ int deviceLength,driverLength,outputLength;
+
+ deviceLength = strlen(device)+1;
+ driverLength = strlen(driver)+1;
+ outputLength = strlen(output)+1;
+
+ hDevnames = setupDevnames(deviceLength,driverLength,outputLength,
+ device,driver,output);
+ hDevmode = setupDevmode(devmodeLength,devmode);
+
+ pd.lStructSize = sizeof(PRINTDLG);
+ pd.hwndOwner = calledFromCleanThread ? NULL : ghMainWindow; /* (NULL = desktop) */
+ /*
+ * The handle must belong to the active thread, otherwise PrintDlg
+ * will crash. When this function is called from the Clean thread,
+ * ghMainWindow will not belong to the active thread.
+ */
+ pd.hDevMode = hDevmode;
+ pd.hDevNames = hDevnames;
+ pd.hDC = NULL;
+ pd.Flags = PD_ALLPAGES | PD_COLLATE | PD_RETURNDC | PD_NOSELECTION
+ | PD_ENABLEPRINTHOOK;
+ /* hide some options from print dialog */
+ pd.nFromPage = 1;
+ pd.nToPage = 1;
+ pd.nMinPage = 1;
+ pd.nMaxPage = USHRT_MAX;
+ pd.nCopies = 1;
+ pd.hInstance = NULL;
+ pd.lCustData = 0L;
+ pd.lpfnPrintHook = DialogToFrontHook;
+ pd.lpfnSetupHook = NULL;
+ pd.lpPrintTemplateName = NULL;
+ pd.lpSetupTemplateName = NULL;
+ pd.hPrintTemplate = NULL;
+ pd.hSetupTemplate = NULL;
+
+ /* Open print dialog */
+
+ ok = PrintDlg(&pd);
+
+ if (hDevnames!=pd.hDevNames) LocalFree(hDevnames);
+ if (hDevmode!=pd.hDevMode) LocalFree(hDevmode);
+
+ if (!ok)
+ {
+ *err = CommDlgExtendedError(); /* will return 0 iff user canceled, otherwise positive value */
+ release_memory_handles(&pd, 0);
+ return;
+ }
+
+
+ if (pd.Flags & PD_PAGENUMS)
+ { *first = pd.nFromPage;
+ *last = pd.nToPage;
+ }
+ else
+ { *first = 1;
+ *last = 9999;
+ };
+ *copies = pd.nCopies;
+ *ppPrintDlg = &pd;
+ hdcPrint = pd.hDC;
+ }
+
+ else
+
+ {
+ hdcPrint = CreateDC(driver, device, output, NULL);
+ if (hdcPrint==NULL)
+ { *err = 0; /* non fatal error, iff e.g. no printer driver is installed */
+ return;
+ };
+ *first = 1;
+ *last = 9999;
+ *copies = 1;
+ *ppPrintDlg = NULL;
+ };
+
+ if (emulateScreen)
+ { int pXdpi,pYdpi,sXdpi,sYdpi;
+ pXdpi = GetDeviceCaps(hdcPrint, LOGPIXELSX);
+ pYdpi = GetDeviceCaps(hdcPrint, LOGPIXELSY);
+ sXdpi = WinGetHorzResolution();
+ sYdpi = WinGetVertResolution();
+ SetMapMode(hdcPrint, MM_ISOTROPIC);
+ SetWindowExtEx (hdcPrint,sXdpi, sYdpi, NULL);
+ SetViewportExtEx(hdcPrint,pXdpi, pYdpi, NULL);
+ };
+
+ *deviceContext = (int) hdcPrint;
+ /*rMessageBox(NULL, MB_APPLMODAL, "leaving getDC","");*/
+#endif
+}
+
+
+#if 0
+BOOL CALLBACK PrintDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+ {
+ switch (msg)
+ {
+ case WM_INITDIALOG :
+ EnableMenuItem (GetSystemMenu (hDlg, FALSE), SC_CLOSE,
+ MF_GRAYED) ;
+ return TRUE ;
+ case WM_COMMAND :
+ bUserAbort = TRUE ;
+ EnableWindow (ghMainWindow, TRUE) ;
+ DestroyWindow (hDlg) ;
+ hDlgPrint = 0 ;
+ return TRUE ;
+ }
+ return FALSE;
+ }
+
+BOOL CALLBACK AbortProc (HDC hdcPrn, int iCode)
+ {
+ MSG msg ;
+
+ while (!bUserAbort && PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ if (!hDlgPrint || !IsDialogMessage (hDlgPrint, &msg))
+ {
+ TranslateMessage (&msg) ;
+ DispatchMessage (&msg) ;
+ }
+ }
+ return !bUserAbort ;
+ }
+#endif
+
+
+#define DIALOG_WIDTH 100
+#define DIALOG_HEIGHT 60
+ /* in dialog units */
+
+#if 0
+HWND CreateCancelDialog(void)
+{
+ HWND hwndButton,dlgHdl;
+
+ WORD *p, *pdlgtemplate,baseunitX,baseunitY;
+ int nchar;
+ int scrnWidth,scrnHeight;
+ int buttonX, buttonY, buttonWidth, buttonHeight;
+ int textX, textY, textWidth, textHeight;
+ DWORD lStyle,baseunits;
+ HDC screen;
+ LOGFONT lf;
+
+ /* allocate some memory to play with */
+ pdlgtemplate = p = (PWORD) rmalloc (1000);
+
+ screen = CreateDC ("DISPLAY", NULL, NULL, NULL);
+ scrnWidth = GetDeviceCaps (screen, HORZRES);
+ scrnHeight = GetDeviceCaps (screen, VERTRES);
+ DeleteDC (screen);
+ baseunits = GetDialogBaseUnits();
+
+ /* start to fill in the dlgtemplate information. addressing by WORDs */
+ lStyle = WS_CAPTION | DS_MODALFRAME | WS_SYSMENU;
+
+ baseunitX=LOWORD(baseunits);
+ baseunitY=HIWORD(baseunits);
+
+ *p++ = LOWORD (lStyle);
+ *p++ = HIWORD (lStyle);
+ *p++ = 0; /* LOWORD (lExtendedStyle) */
+ *p++ = 0; /* HIWORD (lExtendedStyle) */
+ *p++ = 0; /* NumberOfItems */
+ *p++ = ((scrnWidth*4)/3)/baseunitX; /* x */
+ *p++ = ((scrnHeight*8)/3)/baseunitY; /* y */
+ *p++ = DIALOG_WIDTH; /* cx */
+ *p++ = DIALOG_HEIGHT; /* cy */
+ *p++ = 0; /* Menu */
+ *p++ = 0; /* Class */
+
+ /* copy the title of the dialog */
+ nchar = NULL; /*nCopyAnsiToWideChar (p, (char *) "Printing in Progress");*/
+ p += nchar;
+
+ dlgHdl = CreateDialogIndirectParam (ghInst, (LPDLGTEMPLATE) pdlgtemplate, ghMainWindow,
+ (DLGPROC) PrintDlgProc, (LPARAM) 0);
+
+ rfree(pdlgtemplate);
+
+ /* Add a text field */
+ textWidth = 19*baseunitX;
+ textHeight = baseunitY;
+ textX = (((DIALOG_WIDTH*baseunitX)/4) - textWidth)
+ / 2;
+ textY = (((DIALOG_HEIGHT*baseunitY)/8) - textHeight)
+ / 4;
+ hwndText = CreateWindow ("static", "",WS_VISIBLE | WS_CHILD | SS_CENTER,
+ textX, textY, textWidth, textHeight,
+ dlgHdl, (HMENU) 0, ghInst, 0);
+
+
+ /* Add a Cancel button: */
+ buttonWidth = 10*baseunitX;
+ buttonHeight = (3*baseunitY)/2;
+ buttonX = (((DIALOG_WIDTH*baseunitX)/4) - buttonWidth)
+ / 2;
+ buttonY = (3 * (((DIALOG_HEIGHT*baseunitY)/8) - buttonHeight))
+ / 5;
+ hwndButton = CreateWindow ("button", "Cancel", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
+ buttonX, buttonY, buttonWidth, buttonHeight,
+ dlgHdl, (HMENU) 0, ghInst, 0);
+/* WinSetFont (&lf,"MS Sans Serif",0,8); */
+ SendMessage(hwndButton,WM_SETFONT,(WPARAM)CreateFontIndirect (&lf),MAKELPARAM (TRUE,0));
+ SendMessage(hwndText,WM_SETFONT,(WPARAM)CreateFontIndirect (&lf),MAKELPARAM (TRUE,0));
+
+ ShowWindow (dlgHdl,SW_SHOWNORMAL);
+ return dlgHdl;
+}
+#endif
+
+/* PA: Called in Clean. */
+int addSemaphor(int add)
+{
+ int old=semaphor;
+ semaphor+=add;
+ return old;
+}
+
+int os_printsetupvalidC(DEVMODE *devmode, char *device, char *driver)
+{
+#if 0
+ HDC icPrint;
+
+ icPrint = myCreateIC(driver,device,devmode);
+ if (icPrint)
+ DeleteDC(icPrint);
+ return icPrint!=NULL;
+#else
+ return 0;
+#endif
+}
+
diff --git a/Linux_C_12/cprinter_121.h b/Linux_C_12/cprinter_121.h new file mode 100644 index 0000000..384abe1 --- /dev/null +++ b/Linux_C_12/cprinter_121.h @@ -0,0 +1,39 @@ +#ifndef _CPRINTER
+#define _CPRINTER
+
+#if defined(mingw32_TARGET_OS)
+/* PA: all made extern */
+extern int startPage(int hdc);
+extern int endPage (int hdc);
+extern int startDoc (int hdc);
+ /* returns err code: >0:no error, <=0: user cancelled file dialog */
+extern void endDoc (int hdc);
+extern void deleteDC(int hdc);
+extern int wasCanceled(void);
+extern void printSetup (int calledFromCleanThread, int devmodeSize,
+ char *devmode, char *device, char *driver, char *output,
+ int *ok, PRINTDLG **pdPtr
+ );
+extern void getDC( int doDialog, int emulateScreen, int calledFromCleanThread, int devmodeLength,
+ char *devmode,char *device,char *driver,char *output,
+ int *err,
+ int *first, int *last, int *copies,
+ PRINTDLG **ppPrintDlg,
+ int *deviceContext
+ );
+ /* err code: -1:no error, others: non fatal error */
+extern void get_printSetup_with_PRINTDLG(PRINTDLG *pd, char **o_devmode,
+ char **o_device, char **o_driver, char **o_output);
+extern void getCaps(HDC hdcPrint, int unq,
+ int *maxX, int *maxY,
+ int *leftPaper, int *topPaper,
+ int *rightPaper, int *bottomPaper,
+ int *unqReturn
+ );
+
+extern BOOL CALLBACK AbortProc (HDC hdcPrn, int iCode);
+extern BOOL CALLBACK PrintDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+extern HWND CreateCancelDialog(void);
+#endif
+
+#endif
diff --git a/Linux_C_12/intrface_121.h b/Linux_C_12/intrface_121.h new file mode 100644 index 0000000..5b30d28 --- /dev/null +++ b/Linux_C_12/intrface_121.h @@ -0,0 +1,260 @@ +/* C module intrface */
+
+#include "util_121.h"
+
+#define MaxRand 32767
+#define iWhitePattern 4
+#define iLtGreyPattern 3
+#define iGreyPattern 2
+#define iDkGreyPattern 1
+#define iBlackPattern 0
+#define iModeNotBic 7
+#define iModeNotXor 6
+#define iModeNotOr 5
+#define iModeNotCopy 4
+#define iModeBic 3
+#define iModeXor 2
+#define iModeOr 1
+#define iModeCopy 0
+#define iStrikeOut 8
+#define iUnderline 4
+#define iItalic 2
+#define iBold 1
+
+#define WinEscapeKey 27
+#define WinReturnKey 13
+#define WinTabKey 9
+#define WinBackSpKey 8
+#define WinF1Key 1001
+#define WinF2Key 1002
+#define WinF3Key 1003
+#define WinF4Key 1004
+#define WinF5Key 1005
+#define WinF6Key 1006
+#define WinF7Key 1007
+#define WinF8Key 1008
+#define WinF9Key 1009
+#define WinF10Key 1010
+#define WinF11Key 1011
+#define WinF12Key 1012
+#define WinHelpKey 1013
+#define WinDelKey 1014
+#define WinEndKey 1015
+#define WinBeginKey 1016
+#define WinPgDownKey 1017
+#define WinPgUpKey 1018
+#define WinRightKey 1019
+#define WinLeftKey 1020
+#define WinDownKey 1021
+#define WinUpKey 1022
+
+#define CTRLBIT 4
+#define ALTBIT 2
+#define SHIFTBIT 1
+#define KEYREPEAT 4
+#define KEYUP 2
+#define KEYDOWN 1
+#define BUTTONSTILLUP 0 /* PA: new constant for mouse handling. */
+#define BUTTONUP 50
+#define BUTTONSTILLDOWN 40
+#define BUTTONTRIPLEDOWN 3
+#define BUTTONDOUBLEDOWN 2
+#define BUTTONDOWN 1
+#define EDITISMULTILINE 1 /* PA: flag value: edit control is multi-line. */
+#define EDITISKEYSENSITIVE 2 /* PA: flag value: edit control sends keyboard events to Clean. */
+
+/* Constants that are passed when creating (custom)button controls.
+*/
+#define ISNORMALBUTTON 0 /* The button is a normal button. */
+#define ISOKBUTTON 1 /* The button is the OK button. */
+#define ISCANCELBUTTON 2 /* The button is the CANCEL button. */
+
+/* Game cross call codes. */
+#define CcRqUSERGAMEEVENT 1905 /* send user event to other objects */
+#define CcRqCREATEGAMEOBJECT 1904 /* create a new game object */
+#define CcRqPLAYSOUNDSAMPLE 1903 /* initialize sound sample */
+#define CcRqRUNGAME 1901 /* run the game engine */
+#define CcRqCREATEGAMEWINDOW 1900 /* create a game window */
+
+/* Print cross call codes. */
+#define CcRqDO_PRINT_SETUP 1828
+#define CcRqDO_HTML_HELP 1827
+#define CcRqGET_PRINTER_DC 1824
+#define CcRqDISPATCH_MESSAGES_WHILE_PRINTING 1823
+#define CcRqENDDOC 1822
+#define CcRqSTARTDOC 1821
+
+#define CcRqCREATETCPWINDOW 1820 /* create TCP window */
+#define CcRqDESTROYMDIDOCWINDOW 1817 /* destroy MDI document window */
+#define CcRqCREATESDIDOCWINDOW 1816 /* create SDI document window */
+#define CcRqCREATEMDIDOCWINDOW 1815 /* create MDI document window */
+#define CcRqCREATEMDIFRAMEWINDOW 1814 /* create MDI frame window */
+#define CcRqCREATESDIFRAMEWINDOW 1813 /* create SDI frame window */
+#define CcRqCLIPBOARDHASTEXT 1812
+#define CcRqGETCLIPBOARDTEXT 1811
+#define CcRqSETCLIPBOARDTEXT 1810
+#define CcRqDIRECTORYDIALOG 1802 /* create directory selector dialog. */
+#define CcRqFILESAVEDIALOG 1801
+#define CcRqFILEOPENDIALOG 1800
+#define CcRqSHOWCONTROL 1755
+#define CcRqSELECTPOPUPITEM 1754
+#define CcRqENABLEPOPUPITEM 1753
+#define CcRqADDTOPOPUP 1752
+#define CcRqSETITEMCHECK 1751
+#define CcRqENABLECONTROL 1750
+#define CcRqCREATECOMPOUND 1729
+#define CcRqCREATESCROLLBAR 1728
+#define CcRqCREATECUSTOM 1727
+#define CcRqCREATEICONBUT 1726
+#define CcRqCREATEPOPUP 1725
+#define CcRqCREATECHECKBOX 1724
+#define CcRqCREATERADIOBUT 1723
+#define CcRqCREATEEDITTXT 1722
+#define CcRqCREATESTATICTXT 1721
+#define CcRqCREATEBUTTON 1720
+#define CcRqCREATEMODALDIALOG 1701 /* create modal dialog. */
+#define CcRqCREATEDIALOG 1700
+#define CcRqCREATETOOLBARSEPARATOR 1603 /* create a toolbar separator item. */
+#define CcRqCREATETOOLBARITEM 1602 /* create a toolbar bitmap item. */
+#define CcRqCREATEMDITOOLBAR 1601 /* create a toolbar for a MDI process. */
+#define CcRqCREATESDITOOLBAR 1600 /* create a toolbar. */
+#define CcCbFONTSIZE 1530
+#define CcCbFONTNAME 1520
+#define CcRqGETFONTSIZES 1510
+#define CcRqGETFONTNAMES 1500
+
+#define CcRqSETCLIENTSIZE 1438 /* set client size. */
+#define CcRqDELCONTROLTIP 1437 /* remove controls from tooltip areas. */
+#define CcRqADDCONTROLTIP 1436 /* add controls to tooltip areas. */
+#define CcRqGETWINDOWSIZE 1435
+#define CcRqRESTACKWINDOW 1434
+#define CcRqSHOWWINDOW 1433
+#define CcRqSETWINDOWSIZE 1432
+#define CcRqSETSELECTWINDOW 1431
+#define CcRqSETWINDOWPOS 1430
+#define CcRqSETEDITSELECTION 1428
+#define CcRqSETSCROLLSIZE 1427
+#define CcRqSETSCROLLPOS 1426
+#define CcRqSETSCROLLRANGE 1425
+#define CcRqOBSCURECURSOR 1422
+#define CcRqCHANGEWINDOWCURSOR 1421
+#define CcRqACTIVATEWINDOW 1420 /* activating window. */
+#define CcRqACTIVATECONTROL 1419 /* activating controls. */
+#define CcRqCREATECARET 1610
+#define CcRqSETCARETPOS 1611
+#define CcRqDESTROYCARET 1612
+#define CcRqHIDECARET 1613
+#define CcRqSHOWCARET 1614
+#define CcRqGETWINDOWPOS 1416
+#define CcRqGETCLIENTSIZE 1415
+#define CcRqUPDATEWINDOWRECT 1412 /* updating rect part of a window/control. */
+#define CcRqGETWINDOWTEXT 1411
+#define CcRqSETWINDOWTITLE 1410
+#define CcRqFAKEPAINT 1405 /* combination of BeginPaint; EndPaint; InvalidateRect; */
+#define CcRqENDPAINT 1404
+#define CcRqBEGINPAINT 1403
+#define CcRqDESTROYWINDOW 1402
+#define CcRqDESTROYMODALDIALOG 1401 /* destroy modal dialog. */
+#define CcRqDRAWMBAR 1265
+#define CcRqTRACKPOPMENU 1256 /* handling pop up menu. */
+#define CcRqCREATEPOPMENU 1255
+#define CcRqINSERTSEPARATOR 1245
+#define CcRqMENUENABLE 1235
+#define CcRqMODIFYMENU 1230
+#define CcRqINSERTMENU 1226 /* inserting a menu in the menu bar. */
+#define CcRqITEMENABLE 1220
+#define CcRqREMOVEMENUSHORTKEY 1217 /* removing a shortkey of a menu item. */
+#define CcRqADDMENUSHORTKEY 1216 /* adding a shortkey of a menu item. */
+#define CcRqMODIFYMENUITEM 1215
+#define CcRqDESTROYMENU 1214
+#define CcRqDELETEMENU 1213 /* deleting a menu */
+#define CcRqREMOVEMENUITEM 1212
+#define CcRqCHECKMENUITEM 1210
+#define CcRqINSERTMENUITEM 1205
+#define CcRqCREATELISTBOX 1206
+#define CcRqADDTOLISTBOX 1207
+#define CcRqSELECTLISTBOXITEM 1208
+#define CcRqMARKLISTBOXITEM 1209
+#define CcRqDOMESSAGE 1100
+
+
+/* Game OS to Clean codes: 500-599 */
+#define CcWmCHECKQUIT 513 /* check user's quit function */
+#define CcWmUSEREVENT 512 /* user defined event */
+#define CcWmSTATISTICS 511 /* request for statistics */
+#define CcWmOBJECTKEYUP 510 /* key released */
+#define CcWmOBJECTKEYDOWN 509 /* key pressed for object */
+#define CcWmOBJECTTIMER 508 /* framecounter reached 0 */
+#define CcWmANIMATION 507 /* animation sequence ended */
+#define CcWmCOLLISION 506 /* collision of two objects */
+#define CcWmTOUCHBOUND 505 /* object touches bound */
+#define CcWmOBJECTDONE 504 /* object is destroyed */
+#define CcWmMOVEOBJECT 503 /* move object */
+#define CcWmINITOBJECT 502 /* initialize new object */
+#define CcWmSCROLL 501 /* calculate layer positions */
+#define CcWmGAMEKEYBOARD 500 /* keyboard input for game */
+
+/* TCP OS to Clean codes: */
+#define CcWmINETEVENT 140
+
+#define CcWmSPECIALBUTTON 133 /* info about OK/CANCEL button selected. */
+#define CcWmPROCESSDROPFILES 132 /* requesting opening of files. */
+#define CcWmGETTOOLBARTIPTEXT 131 /* getting tooltip text. */
+#define CcWmSETFOCUS 130 /* notifying obtaining keyboard input focus. */
+#define CcWmKILLFOCUS 129 /* notifying loss of keyboard input focus. */
+#define CcWmPROCESSCLOSE 127 /* requesting closing of process. */
+#define CcWmDRAWCLIPBOARD 126 /* clipboard handling. Copied from Ronny. */
+#define CcWmGETSCROLLBARINFO 125 /* info about scrollbars. */
+#define CcWmSCROLLBARACTION 124 /* scrollbar handling. */
+#define CcWmDDEEXECUTE 123
+#define CcWmIDLEDIALOG 121 /* initialising modal dialogues. */
+#define CcWmDRAWCONTROL 120
+#define CcWmITEMSELECT 119
+#define CcWmBUTTONCLICKED 118
+#define CcWmINITDIALOG 117
+#define CcWmIDLETIMER 116
+#define CcWmTIMER 115
+#define CcWmNEWVTHUMB 114
+#define CcWmNEWHTHUMB 113
+#define CcWmGETVSCROLLVAL 112
+#define CcWmGETHSCROLLVAL 111
+#define CcWmSIZE 110 /* resize information. */
+#define CcWmMOUSE 109
+#define CcWmKEYBOARD 108
+#define CcWmDEACTIVATE 107
+#define CcWmACTIVATE 106
+#define CcWmCLOSE 105
+#define CcWmCOMMAND 103
+#define CcWmCHAR 102
+#define CcWmCREATE 101
+#define CcWmPAINT 100
+#define CcWmNOTIFY 78 /* notify events. */
+#define CcWINMESSmax 999
+#define CcWINMESSmin 100
+#define CcRETURN6 16
+#define CcRETURN5 15
+#define CcRETURN4 14
+#define CcRETURN3 13
+#define CcRETURN2 12
+#define CcRETURN1 11
+#define CcRETURN0 10
+#define CcRETURNmax 19
+#define CcRETURNmin 10
+#define CcWASQUIT 1
+
+/*
+ * MW: new convention: messages that are passed within the OS thread
+ * begin with PM. They can be in range WM_USER (currently 0x0400)
+ * to 0x7FFF.
+ */
+
+#define PM_SOCKET_EVENT 0x0405
+#define PM_DNS_EVENT 0x0406
+
+/* Cursor types */
+#define CURSHIDDEN 6
+#define CURSARROW 5
+#define CURSFATCROSS 4
+#define CURSCROSS 3
+#define CURSIBEAM 2
+#define CURSBUSY 1
diff --git a/Linux_C_12/util_121.c b/Linux_C_12/util_121.c new file mode 100644 index 0000000..388819c --- /dev/null +++ b/Linux_C_12/util_121.c @@ -0,0 +1,1614 @@ +/********************************************************************************************
+ Clean OS Windows library module version 1.2.1.
+ This module is part of the Clean Object I/O library, version 1.2.1,
+ for the Windows platform.
+********************************************************************************************/
+
+/********************************************************************************************
+ About this module:
+ Generally applicable utility routines.
+********************************************************************************************/
+#include "util_121.h"
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/malloc.h>
+
+
+/* Convenience procedure to fill in LOGFONT struct. */
+/*
+void SetLogFontData (LOGFONT * plf, char *fname, int style, int size)
+{
+ plf->lfHeight = -size;
+ plf->lfWeight = (style & iBold) ? 700 : 400;
+ plf->lfItalic = (style & iItalic) ? TRUE : FALSE;
+ plf->lfUnderline = (style & iUnderline) ? TRUE : FALSE;
+ plf->lfStrikeOut = (style & iStrikeOut) ? TRUE : FALSE;
+
+ rscopy (plf->lfFaceName, fname);
+
+ plf->lfWidth = 0;
+ plf->lfEscapement = 0;
+ plf->lfOrientation = 0;
+ plf->lfCharSet = DEFAULT_CHARSET;
+ plf->lfOutPrecision = OUT_DEFAULT_PRECIS;
+ plf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ plf->lfQuality = DEFAULT_QUALITY;
+ plf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
+}*/ /* SetLogFontData */
+
+
+/* since we don't use the C runtime library, here are some simple
+ routines that would normally come from the C runtime lib.
+*/
+HGLOBAL rmalloc (DWORD bytes)
+{
+ HGLOBAL ptr;
+ printf("rmalloc\n");
+ ptr = malloc(bytes);
+
+ if (!ptr)
+ {
+ rprintf("Out of memory\n");
+ exit(1);
+ }
+
+ return ptr;
+} /* rmalloc */
+
+void rfree (HGLOBAL ptr)
+{
+ printf("rfree\n");
+ free(ptr);
+} /* rfree */
+
+int rstrlen (char *s)
+{
+ int l;
+ printf("rstrlen\n");
+
+ for (l = 0; s[l] != 0; l++)
+ ;
+ return l;
+} /* rstrlen */
+
+void rsncopy (char *d, const char *s, int n)
+{
+ int i;
+ printf("rsncopy\n");
+ for (i = 0; i < n; i++)
+ {
+ d[i] = s[i];
+ }
+} /* rsncopy */
+
+void rscopy (char *d, const char *s)
+{
+ int i;
+ printf("rscopy\n");
+ for (i = 0; s[i] != 0; i++)
+ {
+ d[i] = s[i];
+ }
+ d[i] = s[i];
+} /* rscopy */
+
+BOOL strequal (char *s1, char *s2)
+{
+ int i = 0;
+ printf("strequal\n");
+ while (s1[i] == s2[i])
+ {
+ if (s1[i] == 0)
+ return TRUE;
+ i++;
+ }
+ return FALSE;
+} /* strequal */
+
+BOOL nstrequal (int length, char *s1, char *s2)
+{
+ int i = 0;
+ printf("nstrequal\n");
+ while (s1[i] == s2[i])
+ {
+ if (i >= length)
+ return TRUE;
+ i++;
+ }
+ return FALSE;
+} /* nstrequal */
+
+int rabs (int i)
+{
+ printf("rabs\n");
+ if (i < 0)
+ return -i;
+ else
+ return i;
+} /* rabs */
+
+
+/* clean_strings don't have to end with 0, so we have to make
+ copy the clean string and end it with a 0.
+ global variables used for conversion from c strings to clean strings
+*/
+
+char * cstring (CLEAN_STRING s)
+{
+ static char *cstr = (char *) NULL;
+
+ rprintf("{cstring");
+ if (cstr)
+ {
+ rfree (cstr);
+ }
+
+ cstr = (char *) rmalloc ((s->length) + 1);
+ rsncopy (cstr, s->characters, s->length);
+ cstr[s->length] = 0;
+/* rprintf("}\n"); */
+ return cstr;
+} /* cstring */
+
+
+CLEAN_STRING cleanstring (char *s)
+{
+ static CLEAN_STRING result_clean_string = NULL;
+ rprintf("[cleanstring: ");
+ if (result_clean_string)
+ rfree (result_clean_string);
+ if (! s)
+ {
+ return NULL;
+ }
+
+ result_clean_string = (CLEAN_STRING) rmalloc (sizeof (int) + rstrlen (s) +1);
+ result_clean_string->length = rstrlen (s);
+ rsncopy (result_clean_string->characters, s, rstrlen (s) + 1);
+ rprintf("%s", s);
+ rprintf("]\n");
+ return result_clean_string;
+} /* cleanstring */
+
+OS WinReleaseCString (PSTR cs, OS ios)
+{
+ rprintf("(RCS: \"%s\"", cs);
+
+ if (cs)
+ {
+ rfree (cs);
+ }
+
+ rprintf(")\n");
+
+ return ios;
+} /* WinReleaseCString */
+
+void WinGetCString (PSTR cs, OS ios, CLEAN_STRING * cls, OS * oos)
+{
+ rprintf("<Gcs");
+
+ *cls = cleanstring (cs);
+ *oos = ios;
+ rprintf(">\n");
+} /* WinGetCString */
+
+void WinGetCStringAndFree (PSTR cs, OS ios, CLEAN_STRING * cls, OS * oos)
+{
+ rprintf("{GcsF");
+ *cls = cleanstring (cs);
+ *oos = ios;
+ rfree (cs);
+ rprintf("}\n");
+} /* WinGetCStringAndFree */
+
+
+void WinMakeCString (CLEAN_STRING s, OS ios, PSTR * cs, OS * oos)
+{
+ rprintf("(MCS: \"");
+ *cs = (char *) rmalloc ((s->length) + 1);
+
+ rsncopy (*cs, s->characters, s->length);
+ (*cs)[s->length] = 0;
+
+ *oos = ios;
+ rprintf("\"%s)\n",*cs);
+} /* WinMakeCString */
+
+
+int nCopyAnsiToWideChar (LPWORD lpWCStr, LPSTR lpAnsiIn)
+{
+ int nChar = 0;
+ printf("nCopyAnsiToWideChar\n");
+ do
+ {
+ *lpWCStr++ = (WORD) * lpAnsiIn;
+ nChar++;
+ } while (*lpAnsiIn++);
+
+ return nChar;
+} /* nCopyAnsiToWideChar */
+
+
+/* The following routines are used to write to the console, or convey runtime errors
+ with message boxes.
+*/
+
+static char mbuff[_RPRINTBUFSIZE];
+
+#ifdef LOGFILE
+static BOOL LogFileInited = FALSE;
+static HANDLE hLogFile = NULL;
+
+void rprintf (char *format,...)
+{
+ va_list arglist;
+ int len;
+ int cWritten;
+
+ if (!LogFileInited)
+ {
+ hLogFile = CreateFile (LOGFILE, /* filename */
+ GENERIC_WRITE, /* acces mode */
+ 0, /* share mode */
+ NULL, /* security */
+ CREATE_ALWAYS, /* how to create */
+ FILE_ATTRIBUTE_NORMAL, /* file attributes */
+ NULL); /* template file */
+ if (hLogFile == INVALID_HANDLE_VALUE)
+ {
+ MessageBox (NULL, "Could not open logfile.", NULL, MB_OK | MB_ICONSTOP);
+ ExitProcess (1);
+ };
+ LogFileInited = TRUE;
+ }
+
+ va_start (arglist, format);
+ len = sprintf (mbuff, format, arglist);
+ va_end (arglist);
+
+ if (!WriteFile (hLogFile, /* output handle */
+ mbuff, /* prompt string */
+ len, /* string length */
+ &cWritten, /* bytes written */
+ NULL)) /* not overlapped */
+ {
+ MessageBox (NULL, "Cannot write to stdout --write error.", NULL, MB_OK | MB_ICONSTOP);
+ return;
+ };
+} /* rprintf */
+#endif
+
+/*
+ * void rMessageBox (HWND owner, UINT style, char *title, char *format,...)
+{
+ va_list arglist;
+
+ va_start (arglist, format);
+ wvsprintf (mbuff, format, arglist);
+ va_end (arglist);
+
+ MessageBox (owner, mbuff, title, style);
+}*/ /* rMessageBox */
+
+void CheckF (BOOL theCheck, char *checkText, char *checkMess,
+ char *filename, int linenum)
+{
+ printf("CheckF\n");
+ if (!theCheck)
+ {
+/* rMessageBox (NULL, MB_OK | MB_ICONSTOP,
+ "Internal check failed", "%s\n\ncheck: %s\nfile: %s\nline: %d",
+ checkMess, checkText, filename, linenum);
+ */
+ exit (1);
+ }
+} /* CheckF */
+
+void ErrorExit (char *format,...)
+{
+ va_list arglist;
+
+ va_start (arglist, format);
+ sprintf (mbuff, format, arglist);
+ va_end (arglist);
+
+ /*MessageBox (NULL, mbuff, NULL, MB_OK | MB_ICONSTOP);*/
+ rprintf("%s", mbuff);
+ exit (1);
+} /* ErrorExit */
+
+void DumpMem (int *ptr, int lines)
+{
+ char *cp;
+ int i, j, k;
+
+ rprintf ("DUMP FROM %d\n", ptr);
+
+ for (i = 0; i < lines; i++)
+ {
+ /*rprintf ("%4d: ", i);*/
+ cp = (char *) ptr;
+ for (j = 0; j < 4; j++)
+ {
+ /*rprintf ("%08x ", *ptr);*/
+ ptr++;
+ };
+ /*rprintf ("- ");*/
+ for (j = 0; j < 4; j++)
+ {
+ for (k = 0; k < 4; k++)
+ {
+ char c;
+ c = *cp;
+ if (c < 32 || c > 127)
+ c = '.';
+ /*rprintf ("%C", c);*/
+ cp++;
+ };
+ /*rprintf (" ");*/
+ };
+ /*rprintf ("\n");*/
+ }
+} /* DumpMem */
+
+/*-----------------------------------
+ * support for printing messages
+ *-----------------------------------*/
+char * BOOLstring (BOOL b)
+{
+ if (b)
+ return "TRUE";
+ else
+ return "FALSE";
+} /* BOOLstring */
+
+void printCCI (CrossCallInfo * pcci)
+{
+ switch (pcci->mess)
+ {
+ case CcRETURN0:
+ {
+ rprintf ("CcRETURN0");
+ } break;
+ case CcRETURN1:
+ {
+ rprintf ("CcRETURN1");
+ } break;
+ case CcRETURN2:
+ {
+ rprintf ("CcRETURN2");
+ } break;
+ case CcRETURN3:
+ {
+ rprintf ("CcRETURN3");
+ } break;
+ case CcRETURN4:
+ {
+ rprintf ("CcRETURN4");
+ } break;
+ case CcRETURN5:
+ {
+ rprintf ("CcRETURN5");
+ } break;
+ case CcWmPAINT: /* hwnd, t,l,r,b; no return value. */
+ {
+ rprintf ("CcWmPAINT");
+ } break;
+ case CcWmCREATE: /* hwnd; no return value. */
+ {
+ rprintf ("CcWmCREATE");
+ } break;
+ case CcWmCHAR:
+ {
+ rprintf ("CcWmCHAR");
+ } break;
+ case CcWmCOMMAND: /* HITEM; no return value. */
+ {
+ rprintf ("CcWmCOMMAND");
+ } break;
+ case CcWmCLOSE: /* hwnd; no return value. */
+ {
+ rprintf ("CcWmCLOSE");
+ } break;
+ case CcWmACTIVATE: /* hwnd; no return value. */
+ {
+ rprintf ("CcWmACTIVATE");
+ } break;
+ case CcWmDEACTIVATE: /* hwnd; no return value. */
+ {
+ rprintf ("CcWmDEACTIVATE");
+ } break;
+ case CcWmKEYBOARD: /* hwnd, charcode, keystate, mods; no return
+ value. */
+ {
+ rprintf ("CcWmKEYBOARD");
+ } break;
+ case CcWmMOUSE: /* hwnd, mousestate, x, y, mods; no return
+ value. */
+ {
+ rprintf ("CcWmMOUSE");
+ } break;
+ case CcWmSIZE: /* width, heigth; */
+ {
+ rprintf ("CcWmSIZE");
+ } break;
+ case CcWmGETHSCROLLVAL: /* hwnd; scroll value return. */
+ {
+ rprintf ("CcWmGETHSCROLLVAL");
+ } break;
+ case CcWmGETVSCROLLVAL: /* hwnd; scroll value return. */
+ {
+ rprintf ("CcWmGETVSCROLLVAL");
+ } break;
+ case CcWmNEWHTHUMB: /* hwnd, hthumb; no return value. */
+ {
+ rprintf ("CcWmNEWHTHUMB");
+ } break;
+ case CcWmNEWVTHUMB: /* hwnd, vthumb; no return value. */
+ {
+ rprintf ("CcWmNEWVTHUMB");
+ } break;
+ case CcWmTIMER: /* HITEM, tickcount; no return value. */
+ {
+ rprintf ("CcWmTIMER");
+ } break;
+ case CcWmIDLETIMER: /* no params; no return value. */
+ {
+ rprintf ("CcWmIDLETIMER");
+ } break;
+ case CcWmINITDIALOG: /* hdlg; x y w h hwnd result. */
+ {
+ rprintf ("CcWmINITDIALOG");
+ } break;
+ case CcWmBUTTONCLICKED: /* hdlg, hbut; no return value. */
+ {
+ rprintf ("CcWmBUTTONCLICKED");
+ } break;
+ /* case CcWmCOMBOSELECT: */ /* hwnd, combo, newsel; no return value. */
+ /* {
+ rprintf ("CcWmCOMBOSELECT");
+ } break;*/
+ case CcWmDRAWCONTROL: /* hdlog, hctrl, hdc, x,y, enabled; no return
+ value. */
+ {
+ rprintf ("CcWmDRAWCONTROL");
+ } break;
+ /*case CcWmSETCURSOR:*/ /* hwnd; cursor code return. */
+ /* {
+ rprintf ("CcWmSETCURSOR");
+ } break;*/
+ /* case CcWmLOSEMODELESSDLOG:*/ /* hwnd; bool return value. */
+ /* {
+ rprintf ("CcWmLOSEMODELESSDLOG");
+ } break;*/
+ /* case CcRqBEEP: */ /* no params; no result. */
+ /* {
+ rprintf ("CcRqBEEP");
+ } break; */
+ case CcRqDOMESSAGE: /* no params; no result */
+ {
+ rprintf ("CcRqDOMESSAGE");
+ } break;
+ case CcRqINSERTMENUITEM: /* on/off, hmenu, textptr, marked,
+ pos; HITEM result. */
+ {
+ rprintf ("CcRqINSERTMENUITEM");
+ } break;
+ case CcRqCHECKMENUITEM: /* menu, HITEM, on/off; no result. */
+ {
+ rprintf ("CcRqCHECKMENUITEM");
+ } break;
+ case CcRqREMOVEMENUITEM: /* menu, HITEM; no result. */
+ {
+ rprintf ("CcRqREMOVEMENUITEM");
+ } break;
+ case CcRqMODIFYMENUITEM: /* HITEM, on/off, hmenu, textptr,
+ marked; no result. */
+ {
+ rprintf ("CcRqMODIFYMENUITEM");
+ } break;
+ case CcRqITEMENABLE: /* parent, HITEM, onoff; no result. */
+ {
+ rprintf ("CcRqITEMENABLE");
+ } break;
+ case CcRqMODIFYMENU: /* on/off, hmenu, textptr, hsubmenu, pos; no
+ result. */
+ {
+ rprintf ("CcRqMODIFYMENU");
+ } break;
+ case CcRqMENUENABLE: /* parent, pos, onoff; no result. */
+ {
+ rprintf ("CcRqMENUENABLE");
+ } break;
+ case CcRqINSERTSEPARATOR: /* hmenu, pos; no result. */
+ {
+ rprintf ("CcRqINSERTSEPARATOR");
+ } break;
+ case CcRqCREATEPOPMENU: /* no params; HMENU result. */
+ {
+ rprintf ("CcRqCREATEPOPMENU");
+ } break;
+ case CcRqDRAWMBAR: /* no params; no result. */
+ {
+ rprintf ("CcRqDRAWMBAR");
+ } break;
+ case CcRqDESTROYWINDOW: /* hwnd; no result. */
+ {
+ rprintf ("CcRqDESTROYWINDOW");
+ } break;
+ case CcRqBEGINPAINT: /* hwnd; HDC result. */
+ {
+ rprintf ("CcRqBEGINPAINT");
+ } break;
+ case CcRqENDPAINT: /* hwnd, hdc; no result. */
+ {
+ rprintf ("CcRqENDPAINT");
+ } break;
+ case CcRqSETSCROLLPOS:
+ {
+ rprintf("CcRqSETSCROLLPOS");
+ } break;
+ case CcRqSETSCROLLRANGE:
+ {
+ rprintf("CcRqSETSCROLLRANGE");
+ } break;
+ case CcRqSETSCROLLSIZE:
+ {
+ rprintf("CcRqSETSCROLLSIZE");
+ } break;
+ /*case CcRqGETDC:*/ /* hwnd; HDC result. */
+ /* {
+ rprintf ("CcRqGETDC");
+ } break; */
+ /*case CcRqRELEASEDC: */ /* hwnd, hdc; no result. */
+ /* {
+ rprintf ("CcRqRELEASEDC");
+ } break; */
+ /* case CcRqINVALIDATEWINDOW: */ /* hwnd; no result. */
+ /* {
+ rprintf ("CcRqINVALIDATEWINDOW");
+ } break; */
+ case CcRqSETWINDOWTITLE: /* hwnd, textptr; no result. */
+ {
+ rprintf ("CcRqSETWINDOWTITLE");
+ } break;
+ case CcRqGETWINDOWTEXT: /* hwnd; textptr result. */
+ {
+ rprintf ("CcRqGETWINDOWTEXT");
+ } break;
+ case CcRqGETCLIENTSIZE: /* hwnd; width, height result. */
+ {
+ rprintf ("CcRqGETCLIENTSIZE");
+ } break;
+ case CcRqGETWINDOWPOS: /* hwnd; left, top result. */
+ {
+ rprintf ("CcRqGETWINDOWPOS");
+ } break;
+ case CcRqCHANGEWINDOWCURSOR: /* hwnd, cursor code; no result. */
+ {
+ rprintf ("CcRqCHANGEWINDOWCURSOR");
+ } break;
+ case CcRqOBSCURECURSOR: /* no params; no result. */
+ {
+ rprintf ("CcRqOBSCURECURSOR");
+ } break;
+ /*case CcRqSETGLOBALCURSOR:*/ /* cursorcode; no result. */
+ /* {
+ rprintf ("CcRqSETGLOBALCURSOR");
+ } break;*/
+ /*case CcRqRESETCURSOR:*/ /* no params; no result. */
+ /* {
+ rprintf ("CcRqRESETCURSOR");
+ } break; */
+ case CcRqGETFONTNAMES: /* no params; no result. */
+ {
+ rprintf ("CcRqGETFONTNAMES");
+ } break;
+ case CcRqGETFONTSIZES: /* textptr; no result. */
+ {
+ rprintf ("CcRqGETFONTSIZES");
+ } break;
+ case CcCbFONTNAME: /* textptr; no result. */
+ {
+ rprintf ("CcCbFONTNAME");
+ } break;
+ case CcCbFONTSIZE: /* size, isTrueType; no result. */
+ {
+ rprintf ("CcCbFONTSIZE");
+ } break;
+ /*case CcRqGETCURTIME:*/ /* no params; hours, minutes, seconds. */
+ /* {
+ rprintf ("CcRqGETCURTIME");
+ } break;*/
+ /*case CcRqGETCURDATE:*/ /* no params; year, month, day, weekday. */
+ /* {
+ rprintf ("CcRqGETCURDATE");
+ } break; */
+ /*case CcRqWAIT:*/ /* milliseconds; no result. */
+ /* {
+ rprintf ("CcRqWAIT");
+ } break;*/
+ /*case CcRqGETBLINKTIME:*/ /* no params; millisec result. */
+ /* {
+ rprintf ("CcRqGETBLINKTIME");
+ } break;*/
+ case CcRqCREATEDIALOG: /* textptr; HWND result. */
+ {
+ rprintf ("CcRqCREATEDIALOG");
+ } break;
+ case CcRqCREATEBUTTON: /* hwnd, x,y,w,h, isdefbut; HWND result. */
+ {
+ rprintf ("CcRqCREATEBUTTON");
+ } break;
+ case CcRqCREATESTATICTXT: /* hwnd, x,y,w,h; HWND result. */
+ {
+ rprintf ("CcRqCREATESTATICTXT");
+ } break;
+ case CcRqCREATEEDITTXT: /* hwnd, x,y,w,h, ismultiline; HWND
+ result. */
+ {
+ rprintf ("CcRqCREATEEDITTXT");
+ } break;
+ case CcRqCREATERADIOBUT: /* hwnd, x,y,w,h, isselected; HWND
+ result. */
+ {
+ rprintf ("CcRqCREATERADIOBUT");
+ } break;
+ case CcRqCREATECHECKBOX: /* hwnd, x,y,w,h, isselected; HWND
+ result. */
+ {
+ rprintf ("CcRqCREATECHECKBOX");
+ } break;
+ case CcRqCREATEPOPUP: /* hwnd, x,y,w,h; HWND result. */
+ {
+ rprintf ("CcRqCREATEPOPUP");
+ } break;
+ case CcRqCREATEICONBUT: /* hwnd, x,y,w,h; HWND result. */
+ {
+ rprintf ("CcRqCREATEICONBUT");
+ } break;
+ case CcRqCREATECUSTOM: /* hwnd, x,y,w,h; HWND result. */
+ {
+ rprintf ("CcRqCREATECUSTOM");
+ } break;
+ case CcRqENABLECONTROL: /* hwnd, bool; no result. */
+ {
+ rprintf ("CcRqENABLECONTROL");
+ } break;
+ case CcRqSETITEMCHECK: /* hwnd, bool; no result. */
+ {
+ rprintf ("CcRqSETITEMCHECK");
+ } break;
+ case CcRqADDTOPOPUP: /* hwnd, textptr, enabled, selected; Pos
+ result. */
+ {
+ rprintf ("CcRqADDTOPOPUP");
+ } break;
+ case CcRqENABLEPOPUPITEM: /* hwnd, pos, enabled; no result. */
+ {
+ rprintf ("CcRqENABLEPOPUPITEM");
+ } break;
+ case CcRqSELECTPOPUPITEM: /* hwnd, pos; no result. */
+ {
+ rprintf ("CcRqSELECTPOPUPITEM");
+ } break;
+ case CcRqFILEOPENDIALOG: /* no params; bool, textptr result; */
+ {
+ rprintf ("CcRqFILEOPENDIALOG");
+ } break;
+ case CcRqFILESAVEDIALOG: /* promptptr, nameptr; bool, textptr
+ result; */
+ {
+ rprintf ("CcRqFILESAVEDIALOG");
+ } break;
+ case CcRqSETCLIPBOARDTEXT: /* textptr; no result. */
+ {
+ rprintf ("CcRqSETCLIPBOARDTEXT");
+ } break;
+ case CcRqGETCLIPBOARDTEXT: /* no params; textptr result. */
+ {
+ rprintf ("CcRqGETCLIPBOARDTEXT");
+ } break;
+ case CcRqCLIPBOARDHASTEXT: /* no params; bool result. */
+ {
+ rprintf ("CcRqCLIPBOARDHASTEXT");
+ } break;
+ default:
+ {
+ rprintf ("Unknown CCI: %d", pcci->mess);
+ } break;
+ }
+} /* printCCI */
+
+#ifdef LOGFILE
+void printMessage (char *fname, HWND hWin, UINT uMess, WPARAM wPara, LPARAM lPara)
+{
+ switch (uMess)
+ {
+ case WM_ACTIVATE:
+ {
+ rprintf ("== %s got %s, hwnd = %d, ", fname, "WM_ACTIVATE", hWin);
+ switch (LOWORD (wPara)) /* activation flag */
+ {
+ case WA_ACTIVE:
+ rprintf ("fActive = WA_ACTIVE, ");
+ break;
+ case WA_CLICKACTIVE:
+ rprintf ("fActive = WA_CLICKACTIVE, ");
+ break;
+ case WA_INACTIVE:
+ rprintf ("fActive = WA_INACTIVE, ");
+ break;
+ }
+ /*rprintf ("fMinimized = %s, ", BOOLstring ((BOOL) HIWORD (wPara))); minimized flag */
+ rprintf ("other_hwnd = %d\n", lPara); /* window handle */
+ } break;
+ case WM_ACTIVATEAPP:
+ {
+ rprintf ("== %s got %s, hwnd = %d, fActive = %s, other_thread = %d\n", fname, "WM_ACTIVATEAPP", hWin, BOOLstring ((BOOL) wPara), lPara);
+ } break;
+ case WM_NCHITTEST:
+ {
+ } break;
+ case WM_SETCURSOR:
+ {
+ } break;
+ case WM_MOVE:
+ {
+ rprintf ("== %s got %s, hwnd = %d, x = %d, y = %d\n", fname, "WM_MOVE", hWin, LOWORD (lPara), HIWORD (lPara));
+ } break;
+ case WM_SIZE:
+ {
+ rprintf ("== %s got %s, hwnd = %d, wPara = ", fname, "WM_SIZE", hWin);
+ switch (wPara)
+ {
+ case SIZE_MAXHIDE:
+ rprintf ("SIZE_MAXHIDE");
+ break;
+ case SIZE_MAXIMIZED:
+ rprintf ("SIZE_MAXIMIZED");
+ break;
+ case SIZE_MAXSHOW:
+ rprintf ("SIZE_MAXSHOW");
+ break;
+ case SIZE_MINIMIZED:
+ rprintf ("SIZE_MINIMIZED");
+ break;
+ case SIZE_RESTORED:
+ rprintf ("SIZE_RESTORED");
+ break;
+ default:
+ rprintf ("unknown");
+ break;
+ }
+ rprintf (", width =%d, height = %d\n", LOWORD (lPara), HIWORD (lPara));
+ } break;
+ case WM_HSCROLL:
+ {
+ rprintf ("== %s got %s, hwnd = %d, ", fname, "WM_HSCROLL", hWin);
+ switch ((int) LOWORD (wPara))
+ {
+ case SB_BOTTOM:
+ rprintf ("scrollcode = SB_BOTTOM\n");
+ break;
+ case SB_ENDSCROLL:
+ rprintf ("scrollcode = SB_ENDSCROLL\n");
+ break;
+ case SB_LINELEFT:
+ rprintf ("scrollcode = SB_LINELEFT\n");
+ break;
+ case SB_LINERIGHT:
+ rprintf ("scrollcode = SB_LINERIGHT\n");
+ break;
+ case SB_PAGELEFT:
+ rprintf ("scrollcode = SB_PAGELEFT\n");
+ break;
+ case SB_PAGERIGHT:
+ rprintf ("scrollcode = SB_PAGERIGHT\n");
+ break;
+ case SB_THUMBPOSITION:
+ rprintf ("scrollcode = SB_THUMBPOSITION, nPos = %d\n", HIWORD (wPara));
+ break;
+ case SB_THUMBTRACK:
+ rprintf ("scrollcode = SB_THUMBTRACK, nPos = %d\n", HIWORD (wPara));
+ break;
+ case SB_TOP:
+ rprintf ("scrollcode = SB_TOP\n");
+ break;
+ }
+ } break;
+ case WM_VSCROLL:
+ {
+ rprintf ("== %s got %s, hwnd = %d, ", fname, "WM_VSCROLL", hWin);
+
+ switch (LOWORD (wPara))
+ {
+ case SB_BOTTOM:
+ rprintf ("scrollcode = SB_BOTTOM\n");
+ break;
+ case SB_ENDSCROLL:
+ rprintf ("scrollcode = SB_ENDSCROLL\n");
+ break;
+ case SB_LINEDOWN:
+ rprintf ("scrollcode = SB_LINEDOWN\n");
+ break;
+ case SB_LINEUP:
+ rprintf ("scrollcode = SB_LINEUP\n");
+ break;
+ case SB_PAGEDOWN:
+ rprintf ("scrollcode = SB_PAGEDOWN\n");
+ break;
+ case SB_PAGEUP:
+ rprintf ("scrollcode = SB_PAGEUP\n");
+ break;
+ case SB_THUMBPOSITION:
+ rprintf ("scrollcode = SB_THUMBPOSITION, nPos = %d\n", HIWORD (wPara));
+ break;
+ case SB_THUMBTRACK:
+ rprintf ("scrollcode = SB_THUMBTRACK, nPos = %d\n", HIWORD (wPara));
+ break;
+ case SB_TOP:
+ rprintf ("scrollcode = SB_TOP\n");
+ break;
+ }
+ } break;
+ case WM_TIMER:
+ { /* rprintf("== %s got %s, hwnd = %d, wParam = %d\n", fname,
+ "WM_TIMER", hWin, wPara); */
+ } break;
+ case WM_ENABLE:
+ {
+ rprintf ("== %s got %s, hwnd = %d, wParam = %s\n", fname, "WM_ENABLE", hWin, BOOLstring ((BOOL) wPara));
+ } break;
+ case WM_ENTERIDLE:
+ { /* rprintf("== %s got %s, hwnd = %d\n", fname,
+ "WM_ENTERIDLE", hWin); */
+ } break;
+ case WM_CHAR:
+ {
+ rprintf ("== %s got %s, hwnd = %d, char = \'%c\'[%d]\n", fname, "WM_CHAR", hWin, wPara, wPara);
+ } break;
+/*--------------------------------------------- */
+ case WM_NULL:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NULL", hWin);
+ } break;
+ case WM_CREATE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CREATE", hWin);
+ } break;
+ case WM_DESTROY:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_DESTROY", hWin);
+ } break;
+ case WM_SETFOCUS:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SETFOCUS", hWin);
+ } break;
+ case WM_KILLFOCUS:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_KILLFOCUS", hWin);
+ } break;
+ case WM_SETREDRAW:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SETREDRAW", hWin);
+ } break;
+ case WM_SETTEXT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SETTEXT", hWin);
+ } break;
+ case WM_GETTEXT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_GETTEXT", hWin);
+ } break;
+ case WM_GETTEXTLENGTH:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_GETTEXTLENGTH", hWin);
+ } break;
+ case WM_PAINT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_PAINT", hWin);
+ } break;
+ case WM_CLOSE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CLOSE", hWin);
+ } break;
+ case WM_QUERYENDSESSION:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_QUERYENDSESSION", hWin);
+ } break;
+ case WM_QUIT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_QUIT", hWin);
+ } break;
+ case WM_QUERYOPEN:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_QUERYOPEN", hWin);
+ } break;
+ case WM_ERASEBKGND:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_ERASEBKGND", hWin);
+ } break;
+ case WM_SYSCOLORCHANGE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SYSCOLORCHANGE", hWin);
+ } break;
+ case WM_ENDSESSION:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_ENDSESSION", hWin);
+ } break;
+ case WM_SHOWWINDOW:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SHOWWINDOW", hWin);
+ } break;
+ case WM_SETTINGCHANGE: /* WM_WININICHANGE on NT */
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SETTINGCHANGE", hWin);
+ } break;
+ case WM_DEVMODECHANGE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_DEVMODECHANGE", hWin);
+ } break;
+ case WM_FONTCHANGE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_FONTCHANGE", hWin);
+ } break;
+ case WM_TIMECHANGE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_TIMECHANGE", hWin);
+ } break;
+ case WM_CANCELMODE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CANCELMODE", hWin);
+ } break;
+ case WM_MOUSEACTIVATE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MOUSEACTIVATE", hWin);
+ } break;
+ case WM_CHILDACTIVATE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CHILDACTIVATE", hWin);
+ } break;
+ case WM_QUEUESYNC:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_QUEUESYNC", hWin);
+ } break;
+ case WM_GETMINMAXINFO:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_GETMINMAXINFO", hWin);
+ } break;
+ case WM_PAINTICON:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_PAINTICON", hWin);
+ } break;
+ case WM_ICONERASEBKGND:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_ICONERASEBKGND", hWin);
+ } break;
+ case WM_NEXTDLGCTL:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NEXTDLGCTL", hWin);
+ } break;
+ case WM_SPOOLERSTATUS:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SPOOLERSTATUS", hWin);
+ } break;
+ case WM_DRAWITEM:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_DRAWITEM", hWin);
+ } break;
+ case WM_MEASUREITEM:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MEASUREITEM", hWin);
+ } break;
+ case WM_DELETEITEM:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_DELETEITEM", hWin);
+ } break;
+ case WM_VKEYTOITEM:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_VKEYTOITEM", hWin);
+ } break;
+ case WM_CHARTOITEM:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CHARTOITEM", hWin);
+ } break;
+ case WM_SETFONT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SETFONT", hWin);
+ } break;
+ case WM_GETFONT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_GETFONT", hWin);
+ } break;
+ case WM_SETHOTKEY:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SETHOTKEY", hWin);
+ } break;
+ case WM_GETHOTKEY:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_GETHOTKEY", hWin);
+ } break;
+ case WM_QUERYDRAGICON:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_QUERYDRAGICON", hWin);
+ } break;
+ case WM_COMPAREITEM:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_COMPAREITEM", hWin);
+ } break;
+ case WM_COMPACTING:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_COMPACTING", hWin);
+ } break;
+ case WM_COMMNOTIFY:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_COMMNOTIFY", hWin);
+ } break;
+ case WM_WINDOWPOSCHANGING:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_WINDOWPOSCHANGING", hWin);
+ } break;
+ case WM_WINDOWPOSCHANGED:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_WINDOWPOSCHANGED", hWin);
+ } break;
+ case WM_POWER:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_POWER", hWin);
+ } break;
+ case WM_COPYDATA:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_COPYDATA", hWin);
+ } break;
+ case WM_CANCELJOURNAL:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CANCELJOURNAL", hWin);
+ } break;
+ case WM_NOTIFY:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NOTIFY", hWin);
+ } break;
+ case WM_INPUTLANGCHANGEREQUEST:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_INPUTLANGCHANGEREQUEST", hWin);
+ } break;
+ case WM_INPUTLANGCHANGE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_INPUTLANGCHANGE", hWin);
+ } break;
+ case WM_TCARD:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_TCARD", hWin);
+ } break;
+ case WM_HELP:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_HELP", hWin);
+ } break;
+ case WM_USERCHANGED:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_USERCHANGED", hWin);
+ } break;
+ case WM_NOTIFYFORMAT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NOTIFYFORMAT", hWin);
+ } break;
+ case WM_CONTEXTMENU:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CONTEXTMENU", hWin);
+ } break;
+ case WM_STYLECHANGING:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_STYLECHANGING", hWin);
+ } break;
+ case WM_STYLECHANGED:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_STYLECHANGED", hWin);
+ } break;
+ case WM_DISPLAYCHANGE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_DISPLAYCHANGE", hWin);
+ } break;
+ case WM_GETICON:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_GETICON", hWin);
+ } break;
+ case WM_SETICON:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SETICON", hWin);
+ } break;
+ case WM_NCCREATE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCCREATE", hWin);
+ } break;
+ case WM_NCDESTROY:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCDESTROY", hWin);
+ } break;
+ case WM_NCCALCSIZE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCCALCSIZE", hWin);
+ } break;
+ case WM_NCPAINT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCPAINT", hWin);
+ } break;
+ case WM_NCACTIVATE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCACTIVATE", hWin);
+ } break;
+ case WM_GETDLGCODE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_GETDLGCODE", hWin);
+ } break;
+ case WM_NCMOUSEMOVE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCMOUSEMOVE", hWin);
+ } break;
+ case WM_NCLBUTTONDOWN:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCLBUTTONDOWN", hWin);
+ } break;
+ case WM_NCLBUTTONUP:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCLBUTTONUP", hWin);
+ } break;
+ case WM_NCLBUTTONDBLCLK:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCLBUTTONDBLCLK", hWin);
+ } break;
+ case WM_NCRBUTTONDOWN:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCRBUTTONDOWN", hWin);
+ } break;
+ case WM_NCRBUTTONUP:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCRBUTTONUP", hWin);
+ } break;
+ case WM_NCRBUTTONDBLCLK:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCRBUTTONDBLCLK", hWin);
+ } break;
+ case WM_NCMBUTTONDOWN:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCMBUTTONDOWN", hWin);
+ } break;
+ case WM_NCMBUTTONUP:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCMBUTTONUP", hWin);
+ } break;
+ case WM_NCMBUTTONDBLCLK:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NCMBUTTONDBLCLK", hWin);
+ } break;
+ case WM_KEYDOWN:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_KEYDOWN", hWin);
+ } break;
+ case WM_KEYUP:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_KEYUP", hWin);
+ } break;
+ case WM_DEADCHAR:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_DEADCHAR", hWin);
+ } break;
+ case WM_SYSKEYDOWN:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SYSKEYDOWN", hWin);
+ } break;
+ case WM_SYSKEYUP:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SYSKEYUP", hWin);
+ } break;
+ case WM_SYSCHAR:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SYSCHAR", hWin);
+ } break;
+ case WM_SYSDEADCHAR:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SYSDEADCHAR", hWin);
+ } break;
+ case WM_IME_STARTCOMPOSITION:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_IME_STARTCOMPOSITION", hWin);
+ } break;
+ case WM_IME_ENDCOMPOSITION:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_IME_ENDCOMPOSITION", hWin);
+ } break;
+ case WM_IME_COMPOSITION:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_IME_COMPOSITION", hWin);
+ } break;
+ case WM_INITDIALOG:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_INITDIALOG", hWin);
+ } break;
+ case WM_COMMAND:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_COMMAND", hWin);
+ } break;
+ case WM_SYSCOMMAND:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SYSCOMMAND", hWin);
+ } break;
+ case WM_INITMENU:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_INITMENU", hWin);
+ } break;
+ case WM_INITMENUPOPUP:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_INITMENUPOPUP", hWin);
+ } break;
+ case WM_MENUSELECT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MENUSELECT", hWin);
+ } break;
+ case WM_MENUCHAR:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MENUCHAR", hWin);
+ } break;
+ case WM_CTLCOLORMSGBOX:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CTLCOLORMSGBOX", hWin);
+ } break;
+ case WM_CTLCOLOREDIT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CTLCOLOREDIT", hWin);
+ } break;
+ case WM_CTLCOLORLISTBOX:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CTLCOLORLISTBOX", hWin);
+ } break;
+ case WM_CTLCOLORBTN:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CTLCOLORBTN", hWin);
+ } break;
+ case WM_CTLCOLORDLG:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CTLCOLORDLG", hWin);
+ } break;
+ case WM_CTLCOLORSCROLLBAR:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CTLCOLORSCROLLBAR", hWin);
+ } break;
+ case WM_CTLCOLORSTATIC:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CTLCOLORSTATIC", hWin);
+ } break;
+ case WM_MOUSEMOVE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MOUSEMOVE", hWin);
+ } break;
+ case WM_LBUTTONDOWN:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_LBUTTONDOWN", hWin);
+ } break;
+ case WM_LBUTTONUP:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_LBUTTONUP", hWin);
+ } break;
+ case WM_LBUTTONDBLCLK:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_LBUTTONDBLCLK", hWin);
+ } break;
+ case WM_RBUTTONDOWN:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_RBUTTONDOWN", hWin);
+ } break;
+ case WM_RBUTTONUP:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_RBUTTONUP", hWin);
+ } break;
+ case WM_RBUTTONDBLCLK:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_RBUTTONDBLCLK", hWin);
+ } break;
+ case WM_MBUTTONDOWN:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MBUTTONDOWN", hWin);
+ } break;
+ case WM_MBUTTONUP:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MBUTTONUP", hWin);
+ } break;
+ case WM_MBUTTONDBLCLK:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MBUTTONDBLCLK", hWin);
+ } break;
+ case WM_PARENTNOTIFY:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_PARENTNOTIFY", hWin);
+ } break;
+ case WM_ENTERMENULOOP:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_ENTERMENULOOP", hWin);
+ } break;
+ case WM_EXITMENULOOP:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_EXITMENULOOP", hWin);
+ } break;
+ case WM_NEXTMENU:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_NEXTMENU", hWin);
+ } break;
+ case WM_SIZING:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SIZING", hWin);
+ } break;
+ case WM_CAPTURECHANGED:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CAPTURECHANGED", hWin);
+ } break;
+ case WM_MOVING:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MOVING", hWin);
+ } break;
+ case WM_POWERBROADCAST:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_POWERBROADCAST", hWin);
+ } break;
+ case WM_DEVICECHANGE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_DEVICECHANGE", hWin);
+ } break;
+ case WM_IME_SETCONTEXT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_IME_SETCONTEXT", hWin);
+ } break;
+ case WM_IME_NOTIFY:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_IME_NOTIFY", hWin);
+ } break;
+ case WM_IME_CONTROL:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_IME_CONTROL", hWin);
+ } break;
+ case WM_IME_COMPOSITIONFULL:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_IME_COMPOSITIONFULL", hWin);
+ } break;
+ case WM_IME_SELECT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_IME_SELECT", hWin);
+ } break;
+ case WM_IME_CHAR:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_IME_CHAR", hWin);
+ } break;
+ case WM_IME_KEYDOWN:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_IME_KEYDOWN", hWin);
+ } break;
+ case WM_IME_KEYUP:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_IME_KEYUP", hWin);
+ } break;
+ case WM_MDICREATE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MDICREATE", hWin);
+ } break;
+ case WM_MDIDESTROY:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MDIDESTROY", hWin);
+ } break;
+ case WM_MDIACTIVATE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MDIACTIVATE", hWin);
+ } break;
+ case WM_MDIRESTORE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MDIRESTORE", hWin);
+ } break;
+ case WM_MDINEXT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MDINEXT", hWin);
+ } break;
+ case WM_MDIMAXIMIZE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MDIMAXIMIZE", hWin);
+ } break;
+ case WM_MDITILE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MDITILE", hWin);
+ } break;
+ case WM_MDICASCADE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MDICASCADE", hWin);
+ } break;
+ case WM_MDIICONARRANGE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MDIICONARRANGE", hWin);
+ } break;
+ case WM_MDIGETACTIVE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MDIGETACTIVE", hWin);
+ } break;
+ case WM_MDISETMENU:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MDISETMENU", hWin);
+ } break;
+ case WM_ENTERSIZEMOVE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_ENTERSIZEMOVE", hWin);
+ } break;
+ case WM_EXITSIZEMOVE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_EXITSIZEMOVE", hWin);
+ } break;
+ case WM_DROPFILES:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_DROPFILES", hWin);
+ } break;
+ case WM_MDIREFRESHMENU:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_MDIREFRESHMENU", hWin);
+ } break;
+ case WM_CUT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CUT", hWin);
+ } break;
+ case WM_COPY:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_COPY", hWin);
+ } break;
+ case WM_PASTE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_PASTE", hWin);
+ } break;
+ case WM_CLEAR:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CLEAR", hWin);
+ } break;
+ case WM_UNDO:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_UNDO", hWin);
+ } break;
+ case WM_RENDERFORMAT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_RENDERFORMAT", hWin);
+ } break;
+ case WM_RENDERALLFORMATS:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_RENDERALLFORMATS", hWin);
+ } break;
+ case WM_DESTROYCLIPBOARD:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_DESTROYCLIPBOARD", hWin);
+ } break;
+ case WM_DRAWCLIPBOARD:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_DRAWCLIPBOARD", hWin);
+ } break;
+ case WM_PAINTCLIPBOARD:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_PAINTCLIPBOARD", hWin);
+ } break;
+ case WM_VSCROLLCLIPBOARD:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_VSCROLLCLIPBOARD", hWin);
+ } break;
+ case WM_SIZECLIPBOARD:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_SIZECLIPBOARD", hWin);
+ } break;
+ case WM_ASKCBFORMATNAME:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_ASKCBFORMATNAME", hWin);
+ } break;
+ case WM_CHANGECBCHAIN:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_CHANGECBCHAIN", hWin);
+ } break;
+ case WM_HSCROLLCLIPBOARD:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_HSCROLLCLIPBOARD", hWin);
+ } break;
+ case WM_QUERYNEWPALETTE:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_QUERYNEWPALETTE", hWin);
+ } break;
+ case WM_PALETTEISCHANGING:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_PALETTEISCHANGING", hWin);
+ } break;
+ case WM_PALETTECHANGED:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_PALETTECHANGED", hWin);
+ } break;
+ case WM_HOTKEY:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_HOTKEY", hWin);
+ } break;
+ case WM_PRINT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_PRINT", hWin);
+ } break;
+ case WM_PRINTCLIENT:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_PRINTCLIENT", hWin);
+ } break;
+ case WM_HANDHELDFIRST:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_HANDHELDFIRST", hWin);
+ } break;
+ case WM_HANDHELDLAST:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_HANDHELDLAST", hWin);
+ } break;
+ case WM_AFXFIRST:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_AFXFIRST", hWin);
+ } break;
+ case WM_AFXLAST:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_AFXLAST", hWin);
+ } break;
+ case WM_PENWINFIRST:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_PENWINFIRST", hWin);
+ } break;
+ case WM_PENWINLAST:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_PENWINLAST", hWin);
+ } break;
+ case WM_APP:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_APP", hWin);
+ } break;
+ case WM_USER:
+ {
+ rprintf ("== %s got %s, hwnd = %d\n", fname, "WM_USER", hWin);
+ } break;
+ default:
+ {
+ rprintf ("== %s got UNKOWN MESSAGE %d, hwin = %d\n", fname, uMess, hWin);
+ } break;
+ }
+} /* printMessage */
+#endif
+
+gchar *createMnemonicString(gchar *source)
+{
+ gchar *dest;
+ gchar *s;
+ printf("createMnemonicString\n");
+
+ if (source == NULL)
+ {
+ dest = rmalloc(1);
+ dest[0] = 0x00;
+ return dest;
+ }
+
+ dest = (gchar *) rmalloc(rstrlen(source)*2+1);
+ s = dest;
+
+ printf("Making Mnemonic for: %s\n", source);
+
+ while (*source)
+ {
+ switch (*source)
+ {
+ case '&':
+ *(dest++) = '_';
+ break;
+ case '_':
+ *(dest++) = '_';
+ *(dest++) = '_';
+ default:
+ *(dest++) = *source;
+ }
+
+ source++;
+ }
+
+ *dest = 0;
+ printf("Generated Mnemonic: %s\n", s);
+ return s;
+}
+
+
diff --git a/Linux_C_12/util_121.h b/Linux_C_12/util_121.h new file mode 100644 index 0000000..69e47ca --- /dev/null +++ b/Linux_C_12/util_121.h @@ -0,0 +1,122 @@ +#ifndef _UTILH
+#define _UTILH
+
+#include "config.h"
+#include <stdio.h>
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+
+#undef LOG_CROSSCALL
+#define LOG_MEMORY 1
+
+typedef GtkWidget *OSWindowPtr;
+typedef GdkDrawable *OSPictContext;
+typedef GdkRegion *OSRgnHandle;
+typedef GdkPixbuf *OSBmpHandle;
+typedef GdkPoint *PointsArray;
+
+typedef gboolean BOOL;
+typedef unsigned int UINT;
+typedef unsigned int WORD;
+typedef unsigned int WPARAM;
+typedef unsigned long LPARAM;
+typedef int OS;
+typedef char* PSTR;
+typedef char* LPSTR;
+typedef int* LPWORD;
+
+#define SIGNEDLOWORD(i) ((short) i)
+#define SIGNEDHIWORD(i) ((short) ((i)>>16))
+
+#define OS_NO_WINDOW_PTR -1
+
+/* OS type, threading all calls from Clean.
+*/
+
+typedef int Bool;
+typedef int HITEM;
+typedef void* HGLOBAL;
+typedef unsigned long DWORD;
+
+typedef struct
+{ int mess;
+ int p1;
+ int p2;
+ int p3;
+ int p4;
+ int p5;
+ int p6;
+} CrossCallInfo;
+
+typedef struct clean_string
+ { int length;
+ char characters[1];
+ } *CLEAN_STRING;
+
+
+#include "intrface_121.h"
+
+/* extern void SetLogFontData (LOGFONT*, char*, int, int); */
+
+/* since we don't use the C runtime library, here are some simple
+ routines that would normally come from the C runtime lib.
+*/
+/* PA: extern added */
+extern void rfree( HGLOBAL ptr );
+extern HGLOBAL rmalloc( DWORD bytes );
+
+extern int rstrlen(char *s);
+extern void rsncopy(char *d, const char *s, int n);
+extern void rscopy(char *d, const char *s);
+extern BOOL strequal( char *s1, char *s2 );
+extern BOOL nstrequal( int length, char *s1, char *s2 );
+extern int rabs(int i);
+
+/* clean_strings don't have to end with 0, so we have to make
+ copy the clean string and end it with a 0.
+ global variables used for conversion from c strings to clean strings
+*/
+
+extern char *cstring (CLEAN_STRING s);
+extern CLEAN_STRING cleanstring (char *s);
+/* PA: up to here */
+
+extern OS WinReleaseCString (PSTR,OS);
+extern void WinGetCString (PSTR,OS,CLEAN_STRING*,OS*);
+extern void WinGetCStringAndFree (PSTR,OS,CLEAN_STRING*,OS*);
+extern void WinMakeCString (CLEAN_STRING,OS,PSTR*,OS*);
+
+/* PA: extern added to the end */
+extern int nCopyAnsiToWideChar (LPWORD, LPSTR);
+
+/* The following routines are used to write to the console, or convey runtime errors
+ with message boxes.
+*/
+
+#ifndef _RPRINTBUFSIZE
+#define _RPRINTBUFSIZE 512
+#endif
+
+/*extern void rMessageBox(HWND owner, UINT style, char *title, char *format, ... );*/
+extern void CheckF(BOOL theCheck, char *checkText, char *checkMess, char *filename, int linenum);
+extern void ErrorExit(char *format, ...);
+extern char *BOOLstring( BOOL b );
+
+#define Check(check,mess) CheckF((check),(#check),(mess),__FILE__,__LINE__)
+
+extern void DumpMem( int *ptr, int lines);
+
+/* #define LOGFILE "debuglog.txt" */
+# undef LOGFILE
+
+#ifdef LOGFILE
+extern void rprintf(char *format, ... );
+extern void printCCI( CrossCallInfo *pcci );
+extern void printMessage( char* fname, HWND hWin, UINT uMess, WPARAM wPara, LPARAM lPara);
+#else
+# define rprintf printf
+extern void printCCI( CrossCallInfo *pcci );
+# define printMessage( fname, hWin, uMess, wPara, lPara);
+#endif
+
+#endif
|