* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
#define WQU widget->u.q
-BOOL CALLBACK stringproc(HWND, UINT, WPARAM, LPARAM);
-BOOL CALLBACK choiceproc(HWND, UINT, WPARAM, LPARAM);
+BOOL CALLBACK stringproc (HWND, UINT, WPARAM, LPARAM);
+BOOL CALLBACK choiceproc (HWND, UINT, WPARAM, LPARAM);
-int GQcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GQcreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
DWORD wflags;
int ai;
WQU->mode = G_QWSTRING;
wflags = WS_OVERLAPPEDWINDOW;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRMODE:
- if (Strcmp("string", attrp[ai].u.t) == 0)
- WQU->mode = G_QWSTRING;
- else if (Strcmp("file", attrp[ai].u.t) == 0)
- WQU->mode = G_QWFILE;
- else if (Strcmp("choice", attrp[ai].u.t) == 0)
- WQU->mode = G_QWCHOICE;
- else {
- Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
- return -1;
- }
- break;
- case G_ATTRUSERDATA:
- widget->udata = attrp[ai].u.u;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ switch (attrp[ai].id) {
+ case G_ATTRMODE:
+ if (strcmp ("string", attrp[ai].u.t) == 0)
+ WQU->mode = G_QWSTRING;
+ else if (strcmp ("file", attrp[ai].u.t) == 0)
+ WQU->mode = G_QWFILE;
+ else if (strcmp ("choice", attrp[ai].u.t) == 0)
+ WQU->mode = G_QWCHOICE;
+ else {
+ Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
+ return -1;
+ }
+ break;
+ case G_ATTRUSERDATA:
+ widget->udata = attrp[ai].u.u;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
switch (WQU->mode) {
case G_QWSTRING:
- widget->w = 0;
- break;
+ widget->w = 0;
+ break;
case G_QWFILE:
- widget->w = 0;
- break;
+ widget->w = 0;
+ break;
case G_QWCHOICE:
- widget->w = 0;
- break;
+ widget->w = 0;
+ break;
}
return 0;
}
-int GQsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GQsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
int ai;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRMODE:
- Gerr(POS, G_ERRCANNOTSETATTR2, "mode");
- return -1;
- case G_ATTRUSERDATA:
- widget->udata = attrp[ai].u.u;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ switch (attrp[ai].id) {
+ case G_ATTRMODE:
+ Gerr (POS, G_ERRCANNOTSETATTR2, "mode");
+ return -1;
+ case G_ATTRUSERDATA:
+ widget->udata = attrp[ai].u.u;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
return 0;
}
-int GQgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GQgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
int ai;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRMODE:
- switch (WQU->mode) {
- case G_QWSTRING:
- attrp[ai].u.t = "string";
- break;
- case G_QWFILE:
- attrp[ai].u.t = "file";
- break;
- case G_QWCHOICE:
- attrp[ai].u.t = "choice";
- break;
- }
- break;
- case G_ATTRUSERDATA:
- attrp[ai].u.u = widget->udata;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ switch (attrp[ai].id) {
+ case G_ATTRMODE:
+ switch (WQU->mode) {
+ case G_QWSTRING:
+ attrp[ai].u.t = "string";
+ break;
+ case G_QWFILE:
+ attrp[ai].u.t = "file";
+ break;
+ case G_QWCHOICE:
+ attrp[ai].u.t = "choice";
+ break;
+ }
+ break;
+ case G_ATTRUSERDATA:
+ attrp[ai].u.u = widget->udata;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
return 0;
}
-int GQdestroywidget(Gwidget_t * widget)
-{
+int GQdestroywidget (Gwidget_t *widget) {
return 0;
}
static char *stringp;
static int stringn;
-int GQqueryask(Gwidget_t * widget, char *prompt, char *args,
- char *responsep, int responsen)
-{
+int GQqueryask (
+ Gwidget_t *widget, char *prompt, char *args,
+ char *responsep, int responsen
+) {
OPENFILENAME ofn;
char buf[256];
char *s1, *s2;
switch (WQU->mode) {
case G_QWSTRING:
- stringp = responsep;
- stringn = responsen;
- buttons[0] = prompt;
- buttons[1] = args;
- DialogBox(hinstance, (LPCSTR) "STRINGDIALOG", (HWND) NULL,
- stringproc);
- Gpopdownflag = TRUE;
- if (stringp)
- return 0;
- return -1;
- break;
+ stringp = responsep;
+ stringn = responsen;
+ buttons[0] = prompt;
+ buttons[1] = args;
+ DialogBox (hinstance, (LPCSTR) "STRINGDIALOG", (HWND) NULL, stringproc);
+ Gpopdownflag = TRUE;
+ if (stringp)
+ return 0;
+ return -1;
+ break;
case G_QWFILE:
- strcpy(buf, args);
- ofn.lStructSize = sizeof(OPENFILENAME);
- ofn.hwndOwner = (HWND) NULL;
- ofn.lpstrFilter = "All Files (*.*)\0*.*\0";
- ofn.lpstrCustomFilter = NULL;
- ofn.nMaxCustFilter = 0;
- ofn.nFilterIndex = 1;
- ofn.lpstrFile = buf;
- ofn.nMaxFile = 256;
- ofn.lpstrFileTitle = NULL;
- ofn.nMaxFileTitle = 0;
- ofn.lpstrInitialDir = NULL;
- ofn.lpstrTitle = prompt;
- ofn.Flags = 0;
- ofn.lpstrDefExt = NULL;
- if (!GetOpenFileName(&ofn)) {
- Gpopdownflag = TRUE;
- return -1;
- }
- strncpy(responsep, buf, responsen);
- Gpopdownflag = TRUE;
- break;
+ strcpy (buf, args);
+ ofn.lStructSize = sizeof (OPENFILENAME);
+ ofn.hwndOwner = (HWND) NULL;
+ ofn.lpstrFilter = "All Files (*.*)\0*.*\0";
+ ofn.lpstrCustomFilter = NULL;
+ ofn.nMaxCustFilter = 0;
+ ofn.nFilterIndex = 1;
+ ofn.lpstrFile = buf;
+ ofn.nMaxFile = 256;
+ ofn.lpstrFileTitle = NULL;
+ ofn.nMaxFileTitle = 0;
+ ofn.lpstrInitialDir = NULL;
+ ofn.lpstrTitle = prompt;
+ ofn.Flags = 0;
+ ofn.lpstrDefExt = NULL;
+ if (!GetOpenFileName (&ofn)) {
+ Gpopdownflag = TRUE;
+ return -1;
+ }
+ strncpy (responsep, buf, responsen);
+ Gpopdownflag = TRUE;
+ break;
case G_QWCHOICE:
- if (!args)
- return -1;
- WQU->button = 0;
- choicew = widget;
- buttons[0] = prompt;
- for (s1 = args, i = 1; *s1; i++) {
- buttons[i] = s1;
- s2 = s1;
- while (*s2 && *s2 != '|')
- s2++;
- c = *s2, *s2 = 0;
- s1 = s2;
- if (c)
- s1++;
- }
- buttons[i] = NULL;
- DialogBox(hinstance, "CHOICEDIALOG", (HWND) NULL, choiceproc);
- if (WQU->button > 0)
- strncpy(responsep, buttons[WQU->button], responsen);
- for (s2 = args; s2 < s1; s2++)
- if (!*s2)
- *s2 = '|';
- Gpopdownflag = TRUE;
- if (WQU->button > 0)
- return 0;
- return -1;
- break;
+ if (!args)
+ return -1;
+ WQU->button = 0;
+ choicew = widget;
+ buttons[0] = prompt;
+ for (s1 = args, i = 1; *s1; i++) {
+ buttons[i] = s1;
+ s2 = s1;
+ while (*s2 && *s2 != '|')
+ s2++;
+ c = *s2, *s2 = 0;
+ s1 = s2;
+ if (c)
+ s1++;
+ }
+ buttons[i] = NULL;
+ DialogBox (hinstance, "CHOICEDIALOG", (HWND) NULL, choiceproc);
+ if (WQU->button > 0)
+ strncpy (responsep, buttons[WQU->button], responsen);
+ for (s2 = args; s2 < s1; s2++)
+ if (!*s2)
+ *s2 = '|';
+ Gpopdownflag = TRUE;
+ if (WQU->button > 0)
+ return 0;
+ return -1;
+ break;
}
if (responsep[0] && responsep[strlen(responsep) - 1] == '\n')
- responsep[strlen(responsep) - 1] = 0;
+ responsep[strlen(responsep) - 1] = 0;
return 0;
}
-BOOL CALLBACK stringproc(HWND hdlg, UINT message,
- WPARAM wparam, LPARAM lparam)
-{
+BOOL CALLBACK stringproc (
+ HWND hdlg, UINT message, WPARAM wparam, LPARAM lparam
+) {
switch (message) {
case WM_INITDIALOG:
- SetDlgItemText(hdlg, IDC_STATIC1, (LPCSTR) buttons[0]);
- if (buttons[1])
- SetDlgItemText(hdlg, IDC_EDIT1, (LPCSTR) buttons[1]);
- return TRUE;
- break;
+ SetDlgItemText (hdlg, IDC_STATIC1, (LPCSTR) buttons[0]);
+ if (buttons[1])
+ SetDlgItemText (hdlg, IDC_EDIT1, (LPCSTR) buttons[1]);
+ return TRUE;
+ break;
case WM_COMMAND:
- switch (wparam) {
- case IDOK:
- GetDlgItemText(hdlg, IDC_EDIT1, stringp, stringn);
- EndDialog(hdlg, TRUE);
- return TRUE;
- case IDCANCEL:
- stringp = NULL;
- EndDialog(hdlg, TRUE);
- return TRUE;
- break;
- }
+ switch (wparam) {
+ case IDOK:
+ GetDlgItemText (hdlg, IDC_EDIT1, stringp, stringn);
+ EndDialog (hdlg, TRUE);
+ return TRUE;
+ case IDCANCEL:
+ stringp = NULL;
+ EndDialog(hdlg, TRUE);
+ return TRUE;
+ break;
+ }
}
return FALSE;
}
-BOOL CALLBACK choiceproc(HWND hdlg, UINT message,
- WPARAM wparam, LPARAM lparam)
-{
+BOOL CALLBACK choiceproc (HWND hdlg, UINT message,
+ WPARAM wparam, LPARAM lparam) {
int sel, i;
switch (message) {
case WM_INITDIALOG:
- SetDlgItemText(hdlg, IDC_STATIC1, (LPCSTR) buttons[0]);
- for (i = 1; buttons[i]; i++)
- SendDlgItemMessage(hdlg, IDC_LIST1, LB_ADDSTRING,
- 0, (LPARAM) buttons[i]);
- return TRUE;
- break;
+ SetDlgItemText (hdlg, IDC_STATIC1, (LPCSTR) buttons[0]);
+ for (i = 1; buttons[i]; i++)
+ SendDlgItemMessage (
+ hdlg, IDC_LIST1, LB_ADDSTRING, 0, (LPARAM) buttons[i]
+ );
+ return TRUE;
+ break;
case WM_COMMAND:
- if ((sel = (int) SendDlgItemMessage(hdlg, IDC_LIST1,
- LB_GETCURSEL, 0, 0)) >= 0) {
- choicew->u.q->button = sel + 1;
- EndDialog(hdlg, TRUE);
- }
- return TRUE;
- break;
+ if ((sel = (int) SendDlgItemMessage (
+ hdlg, IDC_LIST1, LB_GETCURSEL, 0, 0
+ )) >= 0) {
+ choicew->u.q->button = sel + 1;
+ EndDialog (hdlg, TRUE);
+ }
+ return TRUE;
+ break;
}
return FALSE;
}
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
#include "gcommon.h"
#include "mem.h"
-int GScreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GScreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
PIXsize_t ps;
DWORD wflags;
int ai;
if (!parent) {
- Gerr(POS, G_ERRNOPARENTWIDGET);
- return -1;
+ Gerr (POS, G_ERRNOPARENTWIDGET);
+ return -1;
}
wflags = WS_CHILDWINDOW | WS_HSCROLL | WS_VSCROLL;
ps.x = ps.y = MINSWSIZE;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRSIZE:
- GETSIZE(attrp[ai].u.s, ps, MINSWSIZE);
- break;
- case G_ATTRBORDERWIDTH:
- wflags |= WS_BORDER;
- break;
- case G_ATTRCHILDCENTER:
- Gerr(POS, G_ERRCANNOTSETATTR1, "childcenter");
- return -1;
- case G_ATTRMODE:
- if (Strcmp("forcebars", attrp[ai].u.t) != 0) {
- Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
- return -1;
- }
- break;
- case G_ATTRWINDOWID:
- Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
- return -1;
- case G_ATTRUSERDATA:
- widget->udata = attrp[ai].u.u;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ switch (attrp[ai].id) {
+ case G_ATTRSIZE:
+ GETSIZE (attrp[ai].u.s, ps, MINSWSIZE);
+ break;
+ case G_ATTRBORDERWIDTH:
+ wflags |= WS_BORDER;
+ break;
+ case G_ATTRCHILDCENTER:
+ Gerr (POS, G_ERRCANNOTSETATTR1, "childcenter");
+ return -1;
+ case G_ATTRMODE:
+ if (strcmp ("forcebars", attrp[ai].u.t) != 0) {
+ Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
+ return -1;
+ }
+ break;
+ case G_ATTRWINDOWID:
+ Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
+ return -1;
+ case G_ATTRUSERDATA:
+ widget->udata = attrp[ai].u.u;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
- Gadjustwrect(parent, &ps);
- if (!(widget->w = CreateWindow("ScrollClass", "scroll", wflags, 0, 0,
- ps.x, ps.y, parent->w,
- (HMENU) (widget - &Gwidgets[0]),
- hinstance, NULL))) {
- Gerr(POS, G_ERRCANNOTCREATEWIDGET);
- return -1;
+ Gadjustwrect (parent, &ps);
+ if (!(widget->w = CreateWindow (
+ "ScrollClass", "scroll", wflags, 0, 0,
+ ps.x, ps.y, parent->w, (HMENU) (widget - &Gwidgets[0]),
+ hinstance, NULL
+ ))) {
+ Gerr (POS, G_ERRCANNOTCREATEWIDGET);
+ return -1;
}
- ShowWindow(widget->w, SW_SHOW);
- UpdateWindow(widget->w);
+ ShowWindow (widget->w, SW_SHOW);
+ UpdateWindow (widget->w);
if (parent && parent->type == G_ARRAYWIDGET)
- Gawinsertchild(parent, widget);
+ Gawinsertchild (parent, widget);
return 0;
}
-int GSsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GSsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
Gwidget_t *parent, *child;
PIXpoint_t po;
PIXsize_t ps, pps, cps;
wflags1 = SWP_NOMOVE | SWP_NOZORDER;
wflags2 = SWP_NOSIZE | SWP_NOZORDER;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRSIZE:
- GETSIZE(attrp[ai].u.s, ps, MINSWSIZE);
- Gadjustwrect(parent, &ps);
- SetWindowPos(widget->w, (HWND) NULL, 0, 0, ps.x, ps.y,
- wflags1);
- break;
- case G_ATTRBORDERWIDTH:
- Gerr(POS, G_ERRCANNOTSETATTR2, "borderwidth");
- return -1;
- case G_ATTRCHILDCENTER:
- for (wi = 0; wi < Gwidgetn; wi++) {
- child = &Gwidgets[wi];
- if (child->inuse && child->pwi == widget - &Gwidgets[0])
- break;
- }
- if (wi == Gwidgetn)
- return 0;
- GETORIGIN(attrp[ai].u.p, po);
- GetClientRect(widget->w, &r);
- pps.x = r.right - r.left, pps.y = r.bottom - r.top;
- po.x -= pps.x / 2, po.y -= pps.y / 2;
- GetWindowRect(child->w, &r);
- cps.x = r.right - r.left, cps.y = r.bottom - r.top;
- if (po.x < 0)
- po.x = 0;
- if (po.y < 0)
- po.y = 0;
- if (po.x > cps.x - pps.x)
- po.x = cps.x - pps.x;
- if (po.y > cps.y - pps.y)
- po.y = cps.y - pps.y;
- SetWindowPos(child->w, (HWND) NULL, -po.x, -po.y, 0, 0,
- wflags2);
- SetScrollPos(widget->w, SB_HORZ, po.x, TRUE);
- SetScrollPos(widget->w, SB_VERT, po.y, TRUE);
- break;
- case G_ATTRMODE:
- if (Strcmp("forcebars", attrp[ai].u.t) != 0) {
- Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
- return -1;
- }
- break;
- case G_ATTRWINDOWID:
- Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
- return -1;
- case G_ATTRUSERDATA:
- widget->udata = attrp[ai].u.u;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ switch (attrp[ai].id) {
+ case G_ATTRSIZE:
+ GETSIZE (attrp[ai].u.s, ps, MINSWSIZE);
+ Gadjustwrect (parent, &ps);
+ SetWindowPos (widget->w, (HWND) NULL, 0, 0, ps.x, ps.y, wflags1);
+ break;
+ case G_ATTRBORDERWIDTH:
+ Gerr (POS, G_ERRCANNOTSETATTR2, "borderwidth");
+ return -1;
+ case G_ATTRCHILDCENTER:
+ for (wi = 0; wi < Gwidgetn; wi++) {
+ child = &Gwidgets[wi];
+ if (child->inuse && child->pwi == widget - &Gwidgets[0])
+ break;
+ }
+ if (wi == Gwidgetn)
+ return 0;
+ GETORIGIN (attrp[ai].u.p, po);
+ GetClientRect (widget->w, &r);
+ pps.x = r.right - r.left, pps.y = r.bottom - r.top;
+ po.x -= pps.x / 2, po.y -= pps.y / 2;
+ GetWindowRect (child->w, &r);
+ cps.x = r.right - r.left, cps.y = r.bottom - r.top;
+ if (po.x < 0)
+ po.x = 0;
+ if (po.y < 0)
+ po.y = 0;
+ if (po.x > cps.x - pps.x)
+ po.x = cps.x - pps.x;
+ if (po.y > cps.y - pps.y)
+ po.y = cps.y - pps.y;
+ SetWindowPos (child->w, (HWND) NULL, -po.x, -po.y, 0, 0, wflags2);
+ SetScrollPos (widget->w, SB_HORZ, po.x, TRUE);
+ SetScrollPos (widget->w, SB_VERT, po.y, TRUE);
+ break;
+ case G_ATTRMODE:
+ if (strcmp ("forcebars", attrp[ai].u.t) != 0) {
+ Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
+ return -1;
+ }
+ break;
+ case G_ATTRWINDOWID:
+ Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
+ return -1;
+ case G_ATTRUSERDATA:
+ widget->udata = attrp[ai].u.u;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
return 0;
}
-int GSgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GSgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
Gwidget_t *child;
RECT r;
int width, height, ai, wi;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRSIZE:
- GetWindowRect(widget->w, &r);
- attrp[ai].u.s.x = r.right - r.left;
- attrp[ai].u.s.y = r.bottom - r.top;
- break;
- case G_ATTRBORDERWIDTH:
- Gerr(POS, G_ERRCANNOTGETATTR, "borderwidth");
- return -1;
- case G_ATTRCHILDCENTER:
- for (wi = 0; wi < Gwidgetn; wi++) {
- child = &Gwidgets[wi];
- if (child->inuse && child->pwi == widget - &Gwidgets[0])
- break;
- }
- if (wi == Gwidgetn) {
- Gerr(POS, G_ERRNOCHILDWIDGET);
- return -1;
- }
- GetWindowRect(widget->w, &r);
- width = r.right - r.left;
- height = r.bottom - r.top;
- GetWindowRect(widget->w, &r);
- attrp[ai].u.p.x = width / 2 - r.left;
- attrp[ai].u.p.y = height / 2 - r.top;
- break;
- case G_ATTRMODE:
- attrp[ai].u.t = "forcebars";
- break;
- case G_ATTRWINDOWID:
- sprintf(&Gbufp[0], "0x%lx", widget->w);
- attrp[ai].u.t = &Gbufp[0];
- break;
- case G_ATTRUSERDATA:
- attrp[ai].u.u = widget->udata;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ switch (attrp[ai].id) {
+ case G_ATTRSIZE:
+ GetWindowRect (widget->w, &r);
+ attrp[ai].u.s.x = r.right - r.left;
+ attrp[ai].u.s.y = r.bottom - r.top;
+ break;
+ case G_ATTRBORDERWIDTH:
+ Gerr (POS, G_ERRCANNOTGETATTR, "borderwidth");
+ return -1;
+ case G_ATTRCHILDCENTER:
+ for (wi = 0; wi < Gwidgetn; wi++) {
+ child = &Gwidgets[wi];
+ if (child->inuse && child->pwi == widget - &Gwidgets[0])
+ break;
+ }
+ if (wi == Gwidgetn) {
+ Gerr (POS, G_ERRNOCHILDWIDGET);
+ return -1;
+ }
+ GetWindowRect (widget->w, &r);
+ width = r.right - r.left;
+ height = r.bottom - r.top;
+ GetWindowRect (widget->w, &r);
+ attrp[ai].u.p.x = width / 2 - r.left;
+ attrp[ai].u.p.y = height / 2 - r.top;
+ break;
+ case G_ATTRMODE:
+ attrp[ai].u.t = "forcebars";
+ break;
+ case G_ATTRWINDOWID:
+ sprintf (&Gbufp[0], "0x%lx", widget->w);
+ attrp[ai].u.t = &Gbufp[0];
+ break;
+ case G_ATTRUSERDATA:
+ attrp[ai].u.u = widget->udata;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
return 0;
}
-int GSdestroywidget(Gwidget_t * widget)
-{
+int GSdestroywidget (Gwidget_t *widget) {
Gwidget_t *parent;
parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
if (parent && parent->type == G_ARRAYWIDGET)
- Gawdeletechild(parent, widget);
- DestroyWindow(widget->w);
+ Gawdeletechild (parent, widget);
+ DestroyWindow (widget->w);
return 0;
}
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
#define WTU widget->u.t
-int GTcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GTcreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
PIXsize_t ps;
DWORD wflags;
char *s;
int ai;
if (!parent) {
- Gerr(POS, G_ERRNOPARENTWIDGET);
- return -1;
+ Gerr (POS, G_ERRNOPARENTWIDGET);
+ return -1;
}
wflags = WS_CHILDWINDOW;
WTU->func = NULL;
ps.x = ps.y = MINTWSIZE;
s = "";
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRSIZE:
- GETSIZE(attrp[ai].u.s, ps, MINTWSIZE);
- break;
- case G_ATTRBORDERWIDTH:
- wflags |= WS_BORDER;
- break;
- case G_ATTRTEXT:
- s = attrp[ai].u.t;
- break;
- case G_ATTRAPPENDTEXT:
- Gerr(POS, G_ERRCANNOTSETATTR1, "appendtext");
- return -1;
- case G_ATTRMODE:
- if (Strcmp("oneline", attrp[ai].u.t) != 0 &&
- Strcmp("input", attrp[ai].u.t) != 0 &&
- Strcmp("output", attrp[ai].u.t) != 0) {
- Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
- return -1;
- }
- break;
- case G_ATTRWINDOWID:
- Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
- return -1;
- case G_ATTRNEWLINECB:
- WTU->func = attrp[ai].u.func;
- break;
- case G_ATTRUSERDATA:
- widget->udata = attrp[ai].u.u;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ switch (attrp[ai].id) {
+ case G_ATTRSIZE:
+ GETSIZE (attrp[ai].u.s, ps, MINTWSIZE);
+ break;
+ case G_ATTRBORDERWIDTH:
+ wflags |= WS_BORDER;
+ break;
+ case G_ATTRTEXT:
+ s = attrp[ai].u.t;
+ break;
+ case G_ATTRAPPENDTEXT:
+ Gerr (POS, G_ERRCANNOTSETATTR1, "appendtext");
+ return -1;
+ case G_ATTRMODE:
+ if (
+ strcmp ("oneline", attrp[ai].u.t) != 0 &&
+ strcmp ("input", attrp[ai].u.t) != 0 &&
+ strcmp ("output", attrp[ai].u.t) != 0
+ ) {
+ Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
+ return -1;
+ }
+ break;
+ case G_ATTRWINDOWID:
+ Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
+ return -1;
+ case G_ATTRNEWLINECB:
+ WTU->func = attrp[ai].u.func;
+ break;
+ case G_ATTRUSERDATA:
+ widget->udata = attrp[ai].u.u;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
- Gadjustwrect(parent, &ps);
+ Gadjustwrect (parent, &ps);
wflags |= (ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL);
if (ps.y > 40)
- wflags |= (WS_HSCROLL | WS_VSCROLL);
- if (!(widget->w = CreateWindow("EDIT", s, wflags, 0, 0, ps.x, ps.y,
- parent->w,
- (HMENU) (widget - &Gwidgets[0]),
- hinstance, NULL))) {
- Gerr(POS, G_ERRCANNOTCREATEWIDGET);
- return -1;
+ wflags |= (WS_HSCROLL | WS_VSCROLL);
+ if (!(widget->w = CreateWindow (
+ "EDIT", s, wflags, 0, 0, ps.x, ps.y,
+ parent->w, (HMENU) (widget - &Gwidgets[0]), hinstance, NULL
+ ))) {
+ Gerr (POS, G_ERRCANNOTCREATEWIDGET);
+ return -1;
}
- ShowWindow(widget->w, SW_SHOW);
- UpdateWindow(widget->w);
+ ShowWindow (widget->w, SW_SHOW);
+ UpdateWindow (widget->w);
if (parent && parent->type == G_ARRAYWIDGET)
- Gawinsertchild(parent, widget);
+ Gawinsertchild (parent, widget);
return 0;
}
-int GTsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GTsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
Gwidget_t *parent;
PIXsize_t ps;
DWORD wflags1;
parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
wflags1 = SWP_NOMOVE | SWP_NOZORDER;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRSIZE:
- GETSIZE(attrp[ai].u.s, ps, MINTWSIZE);
- Gadjustwrect(parent, &ps);
- SetWindowPos(widget->w, (HWND) NULL, 0, 0, ps.x, ps.y,
- wflags1);
- break;
- case G_ATTRBORDERWIDTH:
- Gerr(POS, G_ERRCANNOTSETATTR2, "borderwidth");
- return -1;
- case G_ATTRTEXT:
- Gnocallbacks = TRUE;
- SendMessage(widget->w, WM_SETTEXT, 0, "");
- SendMessage(widget->w, EM_SETSEL, -1, 32760);
- SendMessage(widget->w, EM_REPLACESEL, 0,
- (LPARAM) attrp[ai].u.t);
- SendMessage(widget->w, EM_SETSEL, -1, 32760);
- /* SendMessage (widget->w, EM_REPLACESEL, 0, (LPARAM) "\r\n"); */
- /* SendMessage (widget->w, EM_SETSEL, -1, 32760); */
- Gnocallbacks = FALSE;
- break;
- case G_ATTRAPPENDTEXT:
- Gnocallbacks = TRUE;
- SendMessage(widget->w, EM_SETSEL, -1, 32760);
- SendMessage(widget->w, EM_REPLACESEL, 0,
- (LPARAM) attrp[ai].u.t);
- SendMessage(widget->w, EM_SETSEL, -1, 32760);
- SendMessage(widget->w, EM_REPLACESEL, 0, (LPARAM) "\r\n");
- SendMessage(widget->w, EM_SETSEL, -1, 32760);
- Gnocallbacks = FALSE;
- break;
- case G_ATTRMODE:
- if (Strcmp("oneline", attrp[ai].u.t) != 0 &&
- Strcmp("input", attrp[ai].u.t) != 0 &&
- Strcmp("output", attrp[ai].u.t) != 0) {
- Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
- return -1;
- }
- break;
- case G_ATTRWINDOWID:
- Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
- return -1;
- case G_ATTRUSERDATA:
- widget->udata = attrp[ai].u.u;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ switch (attrp[ai].id) {
+ case G_ATTRSIZE:
+ GETSIZE (attrp[ai].u.s, ps, MINTWSIZE);
+ Gadjustwrect (parent, &ps);
+ SetWindowPos (widget->w, (HWND) NULL, 0, 0, ps.x, ps.y, wflags1);
+ break;
+ case G_ATTRBORDERWIDTH:
+ Gerr (POS, G_ERRCANNOTSETATTR2, "borderwidth");
+ return -1;
+ case G_ATTRTEXT:
+ Gnocallbacks = TRUE;
+ SendMessage (widget->w, WM_SETTEXT, 0, "");
+ SendMessage (widget->w, EM_SETSEL, -1, 32760);
+ SendMessage (widget->w, EM_REPLACESEL, 0, (LPARAM) attrp[ai].u.t);
+ SendMessage (widget->w, EM_SETSEL, -1, 32760);
+#if 0
+ SendMessage (widget->w, EM_REPLACESEL, 0, (LPARAM) "\r\n");
+ SendMessage (widget->w, EM_SETSEL, -1, 32760);
+#endif
+ Gnocallbacks = FALSE;
+ break;
+ case G_ATTRAPPENDTEXT:
+ Gnocallbacks = TRUE;
+ SendMessage (widget->w, EM_SETSEL, -1, 32760);
+ SendMessage (widget->w, EM_REPLACESEL, 0, (LPARAM) attrp[ai].u.t);
+ SendMessage (widget->w, EM_SETSEL, -1, 32760);
+ SendMessage (widget->w, EM_REPLACESEL, 0, (LPARAM) "\r\n");
+ SendMessage (widget->w, EM_SETSEL, -1, 32760);
+ Gnocallbacks = FALSE;
+ break;
+ case G_ATTRMODE:
+ if (
+ strcmp ("oneline", attrp[ai].u.t) != 0 &&
+ strcmp ("input", attrp[ai].u.t) != 0 &&
+ strcmp ("output", attrp[ai].u.t) != 0
+ ) {
+ Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
+ return -1;
+ }
+ break;
+ case G_ATTRWINDOWID:
+ Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
+ return -1;
+ case G_ATTRUSERDATA:
+ widget->udata = attrp[ai].u.u;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
return 0;
}
-int GTgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GTgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
RECT r;
int rtn, ai, i, j;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRSIZE:
- GetWindowRect(widget->w, &r);
- attrp[ai].u.s.x = r.right - r.left;
- attrp[ai].u.s.y = r.bottom - r.top;
- break;
- case G_ATTRBORDERWIDTH:
- Gerr(POS, G_ERRCANNOTGETATTR, "borderwidth");
- return -1;
- case G_ATTRTEXT:
- if ((rtn = GetWindowTextLength(widget->w)) + 1 > Gbufn) {
- Gbufp = Marraygrow(Gbufp, (long) (rtn + 1) * BUFSIZE);
- Gbufn = rtn + 1;
- }
- GetWindowText(widget->w, &Gbufp[0], Gbufn - 1);
- for (i = 0, j = 0; Gbufp[i]; i++)
- if (Gbufp[i] != '\r')
- Gbufp[j++] = Gbufp[i];
- Gbufp[j++] = 0;
- attrp[ai].u.t = &Gbufp[0];
- break;
- case G_ATTRAPPENDTEXT:
- Gerr(POS, G_ERRCANNOTGETATTR, "appendtext");
- return -1;
- case G_ATTRMODE:
- attrp[ai].u.t = "oneline";
- break;
- case G_ATTRWINDOWID:
- sprintf(&Gbufp[0], "0x%lx", widget->w);
- attrp[ai].u.t = &Gbufp[0];
- break;
- case G_ATTRNEWLINECB:
- attrp[ai].u.func = WTU->func;
- break;
- case G_ATTRUSERDATA:
- attrp[ai].u.u = widget->udata;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ switch (attrp[ai].id) {
+ case G_ATTRSIZE:
+ GetWindowRect (widget->w, &r);
+ attrp[ai].u.s.x = r.right - r.left;
+ attrp[ai].u.s.y = r.bottom - r.top;
+ break;
+ case G_ATTRBORDERWIDTH:
+ Gerr (POS, G_ERRCANNOTGETATTR, "borderwidth");
+ return -1;
+ case G_ATTRTEXT:
+ if ((rtn = GetWindowTextLength (widget->w)) + 1 > Gbufn) {
+ Gbufp = Marraygrow (Gbufp, (long) (rtn + 1) * BUFSIZE);
+ Gbufn = rtn + 1;
+ }
+ GetWindowText (widget->w, &Gbufp[0], Gbufn - 1);
+ for (i = 0, j = 0; Gbufp[i]; i++)
+ if (Gbufp[i] != '\r')
+ Gbufp[j++] = Gbufp[i];
+ Gbufp[j++] = 0;
+ attrp[ai].u.t = &Gbufp[0];
+ break;
+ case G_ATTRAPPENDTEXT:
+ Gerr (POS, G_ERRCANNOTGETATTR, "appendtext");
+ return -1;
+ case G_ATTRMODE:
+ attrp[ai].u.t = "oneline";
+ break;
+ case G_ATTRWINDOWID:
+ sprintf (&Gbufp[0], "0x%lx", widget->w);
+ attrp[ai].u.t = &Gbufp[0];
+ break;
+ case G_ATTRNEWLINECB:
+ attrp[ai].u.func = WTU->func;
+ break;
+ case G_ATTRUSERDATA:
+ attrp[ai].u.u = widget->udata;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
return 0;
}
-int GTdestroywidget(Gwidget_t * widget)
-{
+int GTdestroywidget (Gwidget_t *widget) {
Gwidget_t *parent;
parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
if (parent && parent->type == G_ARRAYWIDGET)
- Gawdeletechild(parent, widget);
- DestroyWindow(widget->w);
+ Gawdeletechild (parent, widget);
+ DestroyWindow (widget->w);
return 0;
}
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
#define WVU widget->u.v
-int GVcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GVcreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
PIXpoint_t po;
PIXsize_t ps;
DWORD wflags;
po.x = po.y = CW_USEDEFAULT;
ps.x = ps.y = MINVWSIZE;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRORIGIN:
- GETORIGIN(attrp[ai].u.p, po);
- break;
- case G_ATTRSIZE:
- GETSIZE(attrp[ai].u.s, ps, MINVWSIZE);
- break;
- case G_ATTRNAME:
- s = attrp[ai].u.t;
- break;
- case G_ATTRZORDER:
- Gerr(POS, G_ERRCANNOTSETATTR1, "zorder");
- return -1;
- case G_ATTRWINDOWID:
- Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
- return -1;
- case G_ATTREVENTCB:
- WVU->func = attrp[ai].u.func;
- break;
- case G_ATTRUSERDATA:
- widget->udata = attrp[ai].u.u;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ switch (attrp[ai].id) {
+ case G_ATTRORIGIN:
+ GETORIGIN (attrp[ai].u.p, po);
+ break;
+ case G_ATTRSIZE:
+ GETSIZE (attrp[ai].u.s, ps, MINVWSIZE);
+ break;
+ case G_ATTRNAME:
+ s = attrp[ai].u.t;
+ break;
+ case G_ATTRZORDER:
+ Gerr (POS, G_ERRCANNOTSETATTR1, "zorder");
+ return -1;
+ case G_ATTRWINDOWID:
+ Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
+ return -1;
+ case G_ATTREVENTCB:
+ WVU->func = attrp[ai].u.func;
+ break;
+ case G_ATTRUSERDATA:
+ widget->udata = attrp[ai].u.u;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
- if (!(widget->w = CreateWindow("LeftyClass", s, wflags, po.x, po.y,
- ps.x, ps.y, (HWND) 0, (HMENU) 0,
- hinstance, NULL))) {
- Gerr(POS, G_ERRCANNOTCREATEWIDGET);
- return -1;
+ if (!(widget->w = CreateWindow (
+ "LeftyClass", s, wflags, po.x, po.y,
+ ps.x, ps.y, (HWND) 0, (HMENU) 0, hinstance, NULL
+ ))) {
+ Gerr (POS, G_ERRCANNOTCREATEWIDGET);
+ return -1;
}
- ShowWindow(widget->w, SW_SHOW);
- UpdateWindow(widget->w);
+ ShowWindow (widget->w, SW_SHOW);
+ UpdateWindow (widget->w);
return 0;
}
-int GVsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GVsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
PIXpoint_t po;
PIXsize_t ps;
DWORD wflags1, wflags2, wflags3, wflags4;
wflags3 = SWP_NOSIZE | SWP_NOMOVE;
wflags4 = SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRORIGIN:
- GETORIGIN(attrp[ai].u.p, po);
- SetWindowPos(widget->w, (HWND) NULL, po.x, po.y, 0, 0,
- wflags2);
- break;
- case G_ATTRSIZE:
- GETSIZE(attrp[ai].u.s, ps, MINVWSIZE);
- SetWindowPos(widget->w, (HWND) NULL, 0, 0, ps.x, ps.y,
- wflags1);
- break;
- case G_ATTRNAME:
- SetWindowText(widget->w, attrp[ai].u.t);
- return -1;
- case G_ATTRZORDER:
- if (Strcmp(attrp[ai].u.t, "top") == 0)
- SetWindowPos(widget->w, (HWND) HWND_TOP, 0, 0, 0, 0,
- wflags3);
- else if (Strcmp(attrp[ai].u.t, "bottom") == 0)
- SetWindowPos(widget->w, (HWND) HWND_BOTTOM,
- 0, 0, 0, 0, wflags4);
- else {
- Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
- return -1;
- }
- break;
- case G_ATTRWINDOWID:
- Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
- return -1;
- case G_ATTREVENTCB:
- WVU->func = attrp[ai].u.func;
- break;
- case G_ATTRUSERDATA:
- widget->udata = attrp[ai].u.u;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ switch (attrp[ai].id) {
+ case G_ATTRORIGIN:
+ GETORIGIN (attrp[ai].u.p, po);
+ SetWindowPos (widget->w, (HWND) NULL, po.x, po.y, 0, 0, wflags2);
+ break;
+ case G_ATTRSIZE:
+ GETSIZE (attrp[ai].u.s, ps, MINVWSIZE);
+ SetWindowPos (widget->w, (HWND) NULL, 0, 0, ps.x, ps.y, wflags1);
+ break;
+ case G_ATTRNAME:
+ SetWindowText (widget->w, attrp[ai].u.t);
+ return -1;
+ case G_ATTRZORDER:
+ if (strcmp (attrp[ai].u.t, "top") == 0)
+ SetWindowPos (widget->w, (HWND) HWND_TOP, 0, 0, 0, 0, wflags3);
+ else if (strcmp (attrp[ai].u.t, "bottom") == 0)
+ SetWindowPos (
+ widget->w, (HWND) HWND_BOTTOM, 0, 0, 0, 0, wflags4
+ );
+ else {
+ Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
+ return -1;
+ }
+ break;
+ case G_ATTRWINDOWID:
+ Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
+ return -1;
+ case G_ATTREVENTCB:
+ WVU->func = attrp[ai].u.func;
+ break;
+ case G_ATTRUSERDATA:
+ widget->udata = attrp[ai].u.u;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
return 0;
}
-int GVgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GVgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
RECT r;
int ai;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRORIGIN:
- GetWindowRect(widget->w, &r);
- attrp[ai].u.p.x = r.left, attrp[ai].u.p.y = r.top;
- break;
- case G_ATTRSIZE:
- GetWindowRect(widget->w, &r);
- attrp[ai].u.s.x = r.right - r.left;
- attrp[ai].u.s.y = r.bottom - r.top;
- break;
- case G_ATTRNAME:
- Gerr(POS, G_ERRNOTIMPLEMENTED);
- return -1;
- case G_ATTRZORDER:
- Gerr(POS, G_ERRNOTIMPLEMENTED);
- return -1;
- case G_ATTRWINDOWID:
- sprintf(&Gbufp[0], "0x%lx", widget->w);
- attrp[ai].u.t = &Gbufp[0];
- break;
- case G_ATTREVENTCB:
- attrp[ai].u.func = WVU->func;
- break;
- case G_ATTRUSERDATA:
- attrp[ai].u.u = widget->udata;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ switch (attrp[ai].id) {
+ case G_ATTRORIGIN:
+ GetWindowRect (widget->w, &r);
+ attrp[ai].u.p.x = r.left, attrp[ai].u.p.y = r.top;
+ break;
+ case G_ATTRSIZE:
+ GetWindowRect (widget->w, &r);
+ attrp[ai].u.s.x = r.right - r.left;
+ attrp[ai].u.s.y = r.bottom - r.top;
+ break;
+ case G_ATTRNAME:
+ Gerr (POS, G_ERRNOTIMPLEMENTED);
+ return -1;
+ case G_ATTRZORDER:
+ Gerr (POS, G_ERRNOTIMPLEMENTED);
+ return -1;
+ case G_ATTRWINDOWID:
+ sprintf (&Gbufp[0], "0x%lx", widget->w);
+ attrp[ai].u.t = &Gbufp[0];
+ break;
+ case G_ATTREVENTCB:
+ attrp[ai].u.func = WVU->func;
+ break;
+ case G_ATTRUSERDATA:
+ attrp[ai].u.u = widget->udata;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
return 0;
}
-int GVdestroywidget(Gwidget_t * widget)
-{
+int GVdestroywidget (Gwidget_t *widget) {
WVU->closing = TRUE;
- DestroyWindow(widget->w);
+ DestroyWindow (widget->w);
return 0;
}
CAPTION "Dialog"
FONT 8, "MS Sans Serif"
BEGIN
- LISTBOX IDC_LIST1,40,21,105,71,LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
+ LISTBOX IDC_LIST1,40,21,105,71,LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
WS_TABSTOP
CTEXT "Static",IDC_STATIC1,8,3,171,12
END
// TEXTINCLUDE
//
-1 TEXTINCLUDE DISCARDABLE
+1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
-2 TEXTINCLUDE DISCARDABLE
+2 TEXTINCLUDE DISCARDABLE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"\0"
END
-3 TEXTINCLUDE DISCARDABLE
+3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
#define IDC_STATIC -1
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
#include "gcommon.h"
#include "mem.h"
-int GAcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GAcreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
return -1;
}
-int GAsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GAsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GAgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GAgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GAdestroywidget(Gwidget_t * widget)
-{
+int GAdestroywidget (Gwidget_t *widget) {
return 0;
}
-int Gaworder(Gwidget_t * widget, void *data, Gawordercb func)
-{
+int Gaworder (Gwidget_t *widget, void *data, Gawordercb func) {
return 0;
}
-int Gawsetmode(Gwidget_t * widget, int mode)
-{
+int Gawsetmode (Gwidget_t *widget, int mode) {
return 0;
}
-int Gawgetmode(Gwidget_t * widget)
-{
+int Gawgetmode (Gwidget_t *widget) {
return 0;
}
-void Gawdefcoordscb(int wi, Gawdata_t * dp)
-{
+void Gawdefcoordscb (int wi, Gawdata_t *dp) {
}
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
#include "gcommon.h"
-int GBcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GBcreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
return -1;
return 0;
}
-int GBsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GBsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GBgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GBgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GBdestroywidget(Gwidget_t * widget)
-{
+int GBdestroywidget (Gwidget_t *widget) {
return 0;
}
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
#include "gcommon.h"
#include "mem.h"
-int GCcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GCcreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
return -1;
}
-int GCsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GCsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GCgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GCgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GCdestroywidget(Gwidget_t * widget)
-{
+int GCdestroywidget (Gwidget_t *widget) {
return 0;
}
-int GCcanvasclear(Gwidget_t * widget)
-{
+int GCcanvasclear (Gwidget_t *widget) {
return 0;
}
-int GCsetgfxattr(Gwidget_t * widget, Ggattr_t * ap)
-{
+int GCsetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
return 0;
}
-int GCgetgfxattr(Gwidget_t * widget, Ggattr_t * ap)
-{
+int GCgetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
return 0;
}
-int GCarrow(Gwidget_t * widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t * ap)
-{
+int GCarrow (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
return 0;
}
-int GCline(Gwidget_t * widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t * ap)
-{
+int GCline (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
return 0;
}
-int GCbox(Gwidget_t * widget, Grect_t gr, Ggattr_t * ap)
-{
+int GCbox (Gwidget_t *widget, Grect_t gr, Ggattr_t *ap) {
return 0;
}
-int GCpolygon(Gwidget_t * widget, int gpn, Gpoint_t * gpp, Ggattr_t * ap)
-{
+int GCpolygon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
return 0;
}
-int GCsplinegon(Gwidget_t * widget, int gpn, Gpoint_t * gpp, Ggattr_t * ap)
-{
+int GCsplinegon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
return 0;
}
-int GCarc(Gwidget_t * widget, Gpoint_t gc, Gsize_t gs, double ang1,
- double ang2, Ggattr_t * ap)
-{
+int GCarc (
+ Gwidget_t *widget, Gpoint_t gc, Gsize_t gs, double ang1,
+ double ang2, Ggattr_t *ap
+) {
return 0;
}
-int GCtext(Gwidget_t * widget, Gtextline_t * tlp, int n, Gpoint_t go,
- char *fn, double fs, char *justs, Ggattr_t * ap)
-{
+int GCtext (
+ Gwidget_t *widget, Gtextline_t *tlp, int n, Gpoint_t go,
+ char *fn, double fs, char *justs, Ggattr_t *ap
+) {
return 0;
}
-int GCgettextsize(Gwidget_t * widget, Gtextline_t * tlp, int n, char *fn,
- double fs, Gsize_t * gsp)
-{
+int GCgettextsize (
+ Gwidget_t *widget, Gtextline_t *tlp, int n, char *fn,
+ double fs, Gsize_t *gsp
+) {
return -1;
}
-int GCcreatebitmap(Gwidget_t * widget, Gbitmap_t * bitmap, Gsize_t s)
-{
+int GCcreatebitmap (Gwidget_t *widget, Gbitmap_t *bitmap, Gsize_t s) {
return 0;
}
-int GCdestroybitmap(Gbitmap_t * bitmap)
-{
+int GCdestroybitmap (Gbitmap_t *bitmap) {
return 0;
}
#define COMPDIFF(a, b) (((a) > (b)) ? (a) - (b) : (b) - (a))
-#define CDIFF(a, b) (COMPDIFF (a.red, b[0]) + COMPDIFF (a.green, b[1]) + \
- COMPDIFF (a.blue, b[2]))
+#define CDIFF(a, b) ( \
+ COMPDIFF (a.red, b[0]) + COMPDIFF (a.green, b[1]) + \
+ COMPDIFF (a.blue, b[2]) \
+)
#define CMINMAXDIFF 20000
-int GCreadbitmap(Gwidget_t * widget, Gbitmap_t * bitmap, FILE * fp)
-{
+int GCreadbitmap (Gwidget_t *widget, Gbitmap_t *bitmap, FILE *fp) {
return 0;
}
-int GCwritebitmap(Gbitmap_t * bitmap, FILE * fp)
-{
+int GCwritebitmap (Gbitmap_t *bitmap, FILE *fp) {
return 0;
}
-int GCbitblt(Gwidget_t * widget, Gpoint_t gp, Grect_t gr,
- Gbitmap_t * bitmap, char *mode, Ggattr_t * ap)
-{
+int GCbitblt (
+ Gwidget_t *widget, Gpoint_t gp, Grect_t gr, Gbitmap_t *bitmap,
+ char *mode, Ggattr_t *ap
+) {
return 0;
}
-int GCgetmousecoords(Gwidget_t * widget, Gpoint_t * gpp, int *count)
-{
+int GCgetmousecoords (Gwidget_t *widget, Gpoint_t *gpp, int *count) {
return 0;
}
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
int Gscreenn;
int Gdepth;
-int Ginitgraphics(void)
-{
+int Ginitgraphics (void) {
return 0;
}
-int Gtermgraphics(void)
-{
+int Gtermgraphics (void) {
return 0;
}
-int Gsync(void)
-{
+int Gsync (void) {
return 0;
}
-int Gresetbstate(int wi)
-{
+int Gresetbstate (int wi) {
return 0;
}
-int Gprocessevents(int waitflag, Geventmode_t mode)
-{
+int Gprocessevents (int waitflag, int mode) {
return 0;
}
extern "C" {
#endif
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#ifndef _GCOMMON_H
#define _GCOMMON_H
- typedef struct {
- int x, y;
- } XPoint;
- typedef int Widget;
- typedef int Display;
-
- extern Widget Groot;
- extern Display *Gdisplay;
- extern int Gpopdownflag;
- extern int Gscreenn;
- extern int Gdepth;
-
- int Ginitgraphics(void);
- int Gtermgraphics(void);
- int Gsync(void);
-
- int GAcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
- int GAsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GAgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GAdestroywidget(Gwidget_t *);
-
- int GBcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
- int GBsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GBgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GBdestroywidget(Gwidget_t *);
-
- int GCcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
- int GCsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GCgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GCdestroywidget(Gwidget_t *);
- int GCcanvasclear(Gwidget_t *);
- int GCsetgfxattr(Gwidget_t *, Ggattr_t *);
- int GCgetgfxattr(Gwidget_t *, Ggattr_t *);
- int GCarrow(Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
- int GCline(Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
- int GCbox(Gwidget_t *, Grect_t, Ggattr_t *);
- int GCpolygon(Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
- int GCsplinegon(Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
- int GCarc(Gwidget_t *, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
- int GCtext(Gwidget_t *, Gtextline_t *, int, Gpoint_t,
- char *, double, char *, Ggattr_t *);
- int GCgettextsize(Gwidget_t *, Gtextline_t *, int, char *, double,
- Gsize_t *);
- int GCcreatebitmap(Gwidget_t *, Gbitmap_t *, Gsize_t);
- int GCdestroybitmap(Gbitmap_t *);
- int GCreadbitmap(Gwidget_t *, Gbitmap_t *, FILE *);
- int GCwritebitmap(Gbitmap_t *, FILE *);
- int GCbitblt(Gwidget_t *, Gpoint_t, Grect_t, Gbitmap_t *, char *,
- Ggattr_t *);
- int GCgetmousecoords(Gwidget_t *, Gpoint_t *, int *);
-
- int GLcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
- int GLsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GLgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GLdestroywidget(Gwidget_t *);
-
- int GMcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
- int GMsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GMgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GMdestroywidget(Gwidget_t *);
- int GMmenuaddentries(Gwidget_t *, int, char **);
- int GMmenudisplay(Gwidget_t *, Gwidget_t *);
-
- int GPcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
- int GPsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GPgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GPdestroywidget(Gwidget_t *);
- int GPcanvasclear(Gwidget_t *);
- int GPsetgfxattr(Gwidget_t *, Ggattr_t *);
- int GPgetgfxattr(Gwidget_t *, Ggattr_t *);
- int GParrow(Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
- int GPline(Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
- int GPbox(Gwidget_t *, Grect_t, Ggattr_t *);
- int GPpolygon(Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
- int GPsplinegon(Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
- int GParc(Gwidget_t *, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
- int GPtext(Gwidget_t *, Gtextline_t *, int, Gpoint_t,
- char *, double, char *, Ggattr_t *);
- int GPcreatebitmap(Gwidget_t *, Gbitmap_t *, Gsize_t);
- int GPdestroybitmap(Gbitmap_t *);
- int GPreadbitmap(Gwidget_t *, Gbitmap_t *, FILE *);
- int GPwritebitmap(Gbitmap_t *, FILE *);
- int GPbitblt(Gwidget_t *, Gpoint_t, Grect_t, Gbitmap_t *, char *,
- Ggattr_t *);
-
- int GQcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
- int GQsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GQgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GQdestroywidget(Gwidget_t *);
- int GQqueryask(Gwidget_t *, char *, char *, char *, int);
-
- int GScreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
- int GSsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GSgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GSdestroywidget(Gwidget_t *);
-
- int GTcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
- int GTsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GTgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GTdestroywidget(Gwidget_t *);
-
- int GVcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
- int GVsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GVgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
- int GVdestroywidget(Gwidget_t *);
-
- void Gawdefcoordscb(int, Gawdata_t *);
-
-#endif /* _GCOMMON_H */
+typedef struct {
+ int x, y;
+} XPoint;
+typedef int Widget;
+typedef int Display;
+
+extern Widget Groot;
+extern Display *Gdisplay;
+extern int Gpopdownflag;
+extern int Gscreenn;
+extern int Gdepth;
+
+int Ginitgraphics (void);
+int Gtermgraphics (void);
+int Gsync (void);
+
+int GAcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GAsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GAgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GAdestroywidget (Gwidget_t *);
+
+int GBcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GBsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GBgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GBdestroywidget (Gwidget_t *);
+
+int GCcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GCsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GCgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GCdestroywidget (Gwidget_t *);
+int GCcanvasclear (Gwidget_t *);
+int GCsetgfxattr (Gwidget_t *, Ggattr_t *);
+int GCgetgfxattr (Gwidget_t *, Ggattr_t *);
+int GCarrow (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
+int GCline (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
+int GCbox (Gwidget_t *, Grect_t, Ggattr_t *);
+int GCpolygon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
+int GCsplinegon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
+int GCarc (Gwidget_t *, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
+int GCtext (
+ Gwidget_t *, Gtextline_t *, int, Gpoint_t,
+ char *, double, char *, Ggattr_t *
+);
+int GCgettextsize (Gwidget_t *, Gtextline_t *, int, char *, double, Gsize_t *);
+int GCcreatebitmap (Gwidget_t *, Gbitmap_t *, Gsize_t);
+int GCdestroybitmap (Gbitmap_t *);
+int GCreadbitmap (Gwidget_t *, Gbitmap_t *, FILE *);
+int GCwritebitmap (Gbitmap_t *, FILE *);
+int GCbitblt (Gwidget_t *, Gpoint_t, Grect_t, Gbitmap_t *, char *, Ggattr_t *);
+int GCgetmousecoords (Gwidget_t *, Gpoint_t *, int *);
+
+int GLcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GLsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GLgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GLdestroywidget (Gwidget_t *);
+
+int GMcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GMsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GMgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GMdestroywidget (Gwidget_t *);
+int GMmenuaddentries (Gwidget_t *, int, char **);
+int GMmenudisplay (Gwidget_t *, Gwidget_t *);
+
+int GPcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GPsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GPgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GPdestroywidget (Gwidget_t *);
+int GPcanvasclear (Gwidget_t *);
+int GPsetgfxattr (Gwidget_t *, Ggattr_t *);
+int GPgetgfxattr (Gwidget_t *, Ggattr_t *);
+int GParrow (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
+int GPline (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
+int GPbox (Gwidget_t *, Grect_t, Ggattr_t *);
+int GPpolygon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
+int GPsplinegon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
+int GParc (Gwidget_t *, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
+int GPtext (
+ Gwidget_t *, Gtextline_t *, int, Gpoint_t,
+ char *, double, char *, Ggattr_t *
+);
+int GPcreatebitmap (Gwidget_t *, Gbitmap_t *, Gsize_t);
+int GPdestroybitmap (Gbitmap_t *);
+int GPreadbitmap (Gwidget_t *, Gbitmap_t *, FILE *);
+int GPwritebitmap (Gbitmap_t *, FILE *);
+int GPbitblt (Gwidget_t *, Gpoint_t, Grect_t, Gbitmap_t *, char *, Ggattr_t *);
+
+int GQcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GQsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GQgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GQdestroywidget (Gwidget_t *);
+int GQqueryask (Gwidget_t *, char *, char *, char *, int);
+
+int GScreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GSsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GSgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GSdestroywidget (Gwidget_t *);
+
+int GTcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GTsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GTgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GTdestroywidget (Gwidget_t *);
+
+int GVcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
+int GVsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GVgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
+int GVdestroywidget (Gwidget_t *);
+
+void Gawdefcoordscb (int, Gawdata_t *);
+
+#endif /* _GCOMMON_H */
#ifdef __cplusplus
}
#endif
+
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
#include "gcommon.h"
-int GLcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GLcreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
return -1;
}
-int GLsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GLsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GLgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GLgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GLdestroywidget(Gwidget_t * widget)
-{
+int GLdestroywidget (Gwidget_t *widget) {
return 0;
}
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
#include "gcommon.h"
-int GMcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GMcreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
return -1;
}
-int GMsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GMsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GMgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GMgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GMdestroywidget(Gwidget_t * widget)
-{
+int GMdestroywidget (Gwidget_t *widget) {
return 0;
}
-int GMmenuaddentries(Gwidget_t * widget, int en, char **ep)
-{
+int GMmenuaddentries (Gwidget_t *widget, int en, char **ep) {
return 0;
}
-int GMmenudisplay(Gwidget_t * parent, Gwidget_t * widget)
-{
+int GMmenudisplay (Gwidget_t *parent, Gwidget_t *widget) {
return -1;
}
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
char *Gpscanvasname = "out.ps";
-int GPcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GPcreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
return -1;
}
-int GPsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GPsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GPgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GPgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GPdestroywidget(Gwidget_t * widget)
-{
+int GPdestroywidget (Gwidget_t *widget) {
return 0;
}
-int GPcanvasclear(Gwidget_t * widget)
-{
+int GPcanvasclear (Gwidget_t *widget) {
return 0;
}
-int GPsetgfxattr(Gwidget_t * widget, Ggattr_t * ap)
-{
+int GPsetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
return 0;
}
-int GPgetgfxattr(Gwidget_t * widget, Ggattr_t * ap)
-{
+int GPgetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
return 0;
}
-int GParrow(Gwidget_t * widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t * ap)
-{
+int GParrow (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
return 0;
}
-int GPline(Gwidget_t * widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t * ap)
-{
+int GPline (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
return 0;
}
-int GPbox(Gwidget_t * widget, Grect_t gr, Ggattr_t * ap)
-{
+int GPbox (Gwidget_t *widget, Grect_t gr, Ggattr_t *ap) {
return 0;
}
-int GPpolygon(Gwidget_t * widget, int gpn, Gpoint_t * gpp, Ggattr_t * ap)
-{
+int GPpolygon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
return 0;
}
-int GPsplinegon(Gwidget_t * widget, int gpn, Gpoint_t * gpp, Ggattr_t * ap)
-{
+int GPsplinegon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
return 0;
}
-int GParc(Gwidget_t * widget, Gpoint_t gc, Gsize_t gs,
- double ang1, double ang2, Ggattr_t * ap)
-{
+int GParc (
+ Gwidget_t *widget, Gpoint_t gc, Gsize_t gs,
+ double ang1, double ang2, Ggattr_t *ap
+) {
return 0;
}
-int GPtext(Gwidget_t * widget, Gtextline_t * tlp, int n, Gpoint_t go,
- char *fn, double fs, char *justs, Ggattr_t * ap)
-{
+int GPtext (
+ Gwidget_t *widget, Gtextline_t *tlp, int n, Gpoint_t go, char *fn,
+ double fs, char *justs, Ggattr_t *ap
+) {
return 0;
}
-static char *findfont(char *name)
-{
+static char *findfont (char *name) {
return NULL;
}
-int GPcreatebitmap(Gwidget_t * widget, Gbitmap_t * bitmap, Gsize_t s)
-{
+int GPcreatebitmap (Gwidget_t *widget, Gbitmap_t *bitmap, Gsize_t s) {
return 0;
}
-int GPdestroybitmap(Gbitmap_t * bitmap)
-{
+int GPdestroybitmap (Gbitmap_t *bitmap) {
return 0;
}
-int GPreadbitmap(Gwidget_t * widget, Gbitmap_t * bitmap, FILE * fp)
-{
+int GPreadbitmap (Gwidget_t *widget, Gbitmap_t *bitmap, FILE *fp) {
return 0;
}
-int GPwritebitmap(Gbitmap_t * bitmap, FILE * fp)
-{
+int GPwritebitmap (Gbitmap_t *bitmap, FILE *fp) {
return -1;
}
-int GPbitblt(Gwidget_t * widget, Gpoint_t gp, Grect_t gr,
- Gbitmap_t * bitmap, char *mode, Ggattr_t * ap)
-{
+int GPbitblt (
+ Gwidget_t *widget, Gpoint_t gp, Grect_t gr, Gbitmap_t *bitmap,
+ char *mode, Ggattr_t *ap
+) {
return 0;
}
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
#include "gcommon.h"
-int GQcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GQcreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
return -1;
}
-int GQsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GQsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GQgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GQgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GQdestroywidget(Gwidget_t * widget)
-{
+int GQdestroywidget (Gwidget_t *widget) {
return 0;
}
-int GQqueryask(Gwidget_t * widget, char *prompt, char *args,
- char *responsep, int responsen)
-{
+int GQqueryask (
+ Gwidget_t *widget, char *prompt, char *args,
+ char *responsep, int responsen
+) {
return 0;
}
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
#include "gcommon.h"
-int GScreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GScreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
return -1;
}
-int GSsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GSsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GSgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GSgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GSdestroywidget(Gwidget_t * widget)
-{
+int GSdestroywidget (Gwidget_t *widget) {
return 0;
}
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
#include "gcommon.h"
#include "mem.h"
-int GTcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GTcreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
return -1;
}
-int GTsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GTsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GTgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GTgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GTdestroywidget(Gwidget_t * widget)
-{
+int GTdestroywidget (Gwidget_t *widget) {
return 0;
}
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
#include "gcommon.h"
-int GVcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GVcreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
return -1;
}
-int GVsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GVsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GVgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GVgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
return 0;
}
-int GVdestroywidget(Gwidget_t * widget)
-{
+int GVdestroywidget (Gwidget_t *widget) {
return 0;
}
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
extern WidgetClass arrayWidgetClass;
-static void awcallback(Widget, XtPointer, XtPointer);
+static void awcallback (Widget, XtPointer, XtPointer);
-int GAcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GAcreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
+) {
PIXsize_t ps;
int ai;
XColor c;
int color;
if (!parent) {
- Gerr(POS, G_ERRNOPARENTWIDGET);
- return -1;
+ Gerr (POS, G_ERRNOPARENTWIDGET);
+ return -1;
}
WAU->func = NULL;
ps.x = ps.y = MINAWSIZE;
RESETARGS;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRSIZE:
- GETSIZE(attrp[ai].u.s, ps, MINAWSIZE);
- break;
- case G_ATTRBORDERWIDTH:
- ADD2ARGS(XtNborderWidth, attrp[ai].u.i);
- break;
- case G_ATTRMODE:
- if (Strcmp("horizontal", attrp[ai].u.t) == 0) {
- ADD2ARGS(XtNorientation, XtorientHorizontal);
- WAU->mode = G_AWHARRAY;
- } else if (Strcmp("vertical", attrp[ai].u.t) == 0) {
- WAU->mode = G_AWVARRAY;
- } else {
- Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
- return -1;
+ switch (attrp[ai].id) {
+ case G_ATTRSIZE:
+ GETSIZE (attrp[ai].u.s, ps, MINAWSIZE);
+ break;
+ case G_ATTRBORDERWIDTH:
+ ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
+ break;
+ case G_ATTRMODE:
+ if (strcmp ("horizontal", attrp[ai].u.t) == 0) {
+ ADD2ARGS (XtNorientation, XtorientHorizontal);
+ WAU->mode = G_AWHARRAY;
+ } else if (strcmp ("vertical", attrp[ai].u.t) == 0) {
+ WAU->mode = G_AWVARRAY;
+ } else {
+ Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
+ return -1;
+ }
+ break;
+ case G_ATTRLAYOUT:
+ if (strcmp ("on", attrp[ai].u.t) == 0)
+ Gawsetmode (widget, FALSE);
+ else if (strcmp ("off", attrp[ai].u.t) == 0)
+ Gawsetmode (widget, TRUE);
+ else {
+ Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
+ return -1;
+ }
+ break;
+ case G_ATTRCOLOR:
+ color = attrp[ai].u.c.index;
+ if (color != 0 && color != 1) {
+ Gerr (POS, G_ERRBADCOLORINDEX, color);
+ return -1;
+ }
+ c.red = attrp[ai].u.c.r * 257;
+ c.green = attrp[ai].u.c.g * 257;
+ c.blue = attrp[ai].u.c.b * 257;
+ if (XAllocColor (
+ Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
+ )) {
+ if (color == 0)
+ ADD2ARGS (XtNbackground, c.pixel);
+ else
+ ADD2ARGS (XtNforeground, c.pixel);
}
- break;
- case G_ATTRLAYOUT:
- if (Strcmp("on", attrp[ai].u.t) == 0)
- Gawsetmode(widget, FALSE);
- else if (Strcmp("off", attrp[ai].u.t) == 0)
- Gawsetmode(widget, TRUE);
- else {
- Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
- return -1;
- }
- break;
- case G_ATTRCOLOR:
- color = attrp[ai].u.c.index;
- if (color != 0 && color != 1) {
- Gerr(POS, G_ERRBADCOLORINDEX, color);
- return -1;
- }
- c.red = attrp[ai].u.c.r * 257;
- c.green = attrp[ai].u.c.g * 257;
- c.blue = attrp[ai].u.c.b * 257;
- if (XAllocColor
- (Gdisplay, DefaultColormap(Gdisplay, Gscreenn), &c)) {
- if (color == 0)
- ADD2ARGS(XtNbackground, c.pixel);
- else
- ADD2ARGS(XtNforeground, c.pixel);
- }
- break;
- case G_ATTRWINDOWID:
- Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
- return -1;
- case G_ATTRRESIZECB:
- WAU->func = (Gawcoordscb) attrp[ai].u.func;
- break;
- case G_ATTRUSERDATA:
- widget->udata = attrp[ai].u.u;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ break;
+ case G_ATTRWINDOWID:
+ Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
+ return -1;
+ case G_ATTRRESIZECB:
+ WAU->func = (Gawcoordscb) attrp[ai].u.func;
+ break;
+ case G_ATTRUSERDATA:
+ widget->udata = attrp[ai].u.u;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
- ADD2ARGS(XtNwidth, ps.x);
- ADD2ARGS(XtNheight, ps.y);
- if (!(widget->w = XtCreateWidget("array", arrayWidgetClass,
- parent->w, argp, argn))) {
- Gerr(POS, G_ERRCANNOTCREATEWIDGET);
- return -1;
+ ADD2ARGS (XtNwidth, ps.x);
+ ADD2ARGS (XtNheight, ps.y);
+ if (!(widget->w = XtCreateWidget (
+ "array", arrayWidgetClass, parent->w, argp, argn
+ ))) {
+ Gerr (POS, G_ERRCANNOTCREATEWIDGET);
+ return -1;
}
- XtAddCallback(widget->w, XtNcallback, awcallback, (XtPointer) NULL);
- Glazymanage(widget->w);
+ XtAddCallback (widget->w, XtNcallback, awcallback, (XtPointer) NULL);
+ Glazymanage (widget->w);
return 0;
}
-int GAsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GAsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
PIXsize_t ps;
int ai;
RESETARGS;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRSIZE:
- GETSIZE(attrp[ai].u.s, ps, MINAWSIZE);
- ADD2ARGS(XtNwidth, ps.x);
- ADD2ARGS(XtNheight, ps.y);
- break;
- case G_ATTRBORDERWIDTH:
- ADD2ARGS(XtNborderWidth, attrp[ai].u.i);
- break;
- case G_ATTRMODE:
- Gerr(POS, G_ERRCANNOTSETATTR2, "mode");
- return -1;
- case G_ATTRLAYOUT:
- if (Strcmp("on", attrp[ai].u.t) == 0)
- Gawsetmode(widget, FALSE);
- else if (Strcmp("off", attrp[ai].u.t) == 0)
- Gawsetmode(widget, TRUE);
- else {
- Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
- return -1;
- }
- break;
- case G_ATTRWINDOWID:
- Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
- return -1;
- case G_ATTRRESIZECB:
- WAU->func = (Gawcoordscb) attrp[ai].u.func;
- break;
- case G_ATTRUSERDATA:
- widget->udata = attrp[ai].u.u;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ switch (attrp[ai].id) {
+ case G_ATTRSIZE:
+ GETSIZE (attrp[ai].u.s, ps, MINAWSIZE);
+ ADD2ARGS (XtNwidth, ps.x);
+ ADD2ARGS (XtNheight, ps.y);
+ break;
+ case G_ATTRBORDERWIDTH:
+ ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
+ break;
+ case G_ATTRMODE:
+ Gerr (POS, G_ERRCANNOTSETATTR2, "mode");
+ return -1;
+ case G_ATTRLAYOUT:
+ if (strcmp ("on", attrp[ai].u.t) == 0)
+ Gawsetmode (widget, FALSE);
+ else if (strcmp ("off", attrp[ai].u.t) == 0)
+ Gawsetmode (widget, TRUE);
+ else {
+ Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
+ return -1;
+ }
+ break;
+ case G_ATTRWINDOWID:
+ Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
+ return -1;
+ case G_ATTRRESIZECB:
+ WAU->func = (Gawcoordscb) attrp[ai].u.func;
+ break;
+ case G_ATTRUSERDATA:
+ widget->udata = attrp[ai].u.u;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
- XtSetValues(widget->w, argp, argn);
+ XtSetValues (widget->w, argp, argn);
return 0;
}
-int GAgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GAgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
Dimension width, height;
int ai;
for (ai = 0; ai < attrn; ai++) {
- RESETARGS;
- switch (attrp[ai].id) {
- case G_ATTRSIZE:
- ADD2ARGS(XtNwidth, &width);
- ADD2ARGS(XtNheight, &height);
- XtGetValues(widget->w, argp, argn);
- attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
- break;
- case G_ATTRBORDERWIDTH:
- ADD2ARGS(XtNborderWidth, &width);
- XtGetValues(widget->w, argp, argn);
- attrp[ai].u.i = width;
- break;
- case G_ATTRMODE:
- attrp[ai].u.t = (WAU->mode == G_AWHARRAY) ?
- "horizontal" : "vertical";
- break;
- case G_ATTRLAYOUT:
- attrp[ai].u.t = (Gawgetmode(widget)) ? "off" : "on";
- break;
- case G_ATTRWINDOWID:
- sprintf(&Gbufp[0], "0x%lx", XtWindow(widget->w));
- attrp[ai].u.t = &Gbufp[0];
- break;
- case G_ATTRRESIZECB:
- attrp[ai].u.func = (void *) (WAU->func);
- break;
- case G_ATTRUSERDATA:
- attrp[ai].u.u = widget->udata;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ RESETARGS;
+ switch (attrp[ai].id) {
+ case G_ATTRSIZE:
+ ADD2ARGS (XtNwidth, &width);
+ ADD2ARGS (XtNheight, &height);
+ XtGetValues (widget->w, argp, argn);
+ attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
+ break;
+ case G_ATTRBORDERWIDTH:
+ ADD2ARGS (XtNborderWidth, &width);
+ XtGetValues (widget->w, argp, argn);
+ attrp[ai].u.i = width;
+ break;
+ case G_ATTRMODE:
+ attrp[ai].u.t = (
+ WAU->mode == G_AWHARRAY
+ ) ? "horizontal" : "vertical";
+ break;
+ case G_ATTRLAYOUT:
+ attrp[ai].u.t = (Gawgetmode (widget)) ? "off" : "on";
+ break;
+ case G_ATTRWINDOWID:
+ sprintf (&Gbufp[0], "0x%lx", XtWindow (widget->w));
+ attrp[ai].u.t = &Gbufp[0];
+ break;
+ case G_ATTRRESIZECB:
+ attrp[ai].u.func = WAU->func;
+ break;
+ case G_ATTRUSERDATA:
+ attrp[ai].u.u = widget->udata;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
return 0;
}
-int GAdestroywidget(Gwidget_t * widget)
-{
- XtDestroyWidget(widget->w);
+int GAdestroywidget (Gwidget_t *widget) {
+ XtDestroyWidget (widget->w);
return 0;
}
-static void awcallback(Widget w, XtPointer clientdata, XtPointer calldata)
-{
+static void awcallback (Widget w, XtPointer clientdata, XtPointer calldata) {
Gwidget_t *widget;
- if (!(widget = findwidget((unsigned long) w, G_ARRAYWIDGET)))
- return;
+ if (!(widget = findwidget ((unsigned long) w, G_ARRAYWIDGET)))
+ return;
if (WAU->func)
- (*WAU->func) (widget - &Gwidgets[0], (Gawdata_t *) calldata);
+ (*WAU->func) (widget - &Gwidgets[0], (Gawdata_t *) calldata);
else
- Gawdefcoordscb(widget - &Gwidgets[0], (Gawdata_t *) calldata);
+ Gawdefcoordscb (widget - &Gwidgets[0], (Gawdata_t *) calldata);
}
/* the rest of this file contains the implementation of the array widget */
typedef struct _ArrayRec *ArrayWidget;
typedef struct _ArrayClassPart {
- int dummy; /* not used */
+ int dummy; /* not used */
} ArrayClassPart;
typedef struct _ArrayClassRec {
static XtResource resources[] = {
{
- XtNcallback,
- XtCCallback,
- XtRCallback,
- sizeof(XtPointer),
- XtOffsetOf(ArrayRec, array.callbacks),
- XtRCallback, (XtPointer) NULL}
- ,
+ XtNcallback,
+ XtCCallback,
+ XtRCallback,
+ sizeof (XtPointer),
+ XtOffsetOf (ArrayRec, array.callbacks),
+ XtRCallback, (XtPointer) NULL
+ },
{
- XtNorientation,
- XtCOrientation,
- XtROrientation,
- sizeof(XtOrientation),
- XtOffsetOf(ArrayRec, array.orientation),
- XtRImmediate, (XtPointer) XtorientVertical}
+ XtNorientation,
+ XtCOrientation,
+ XtROrientation,
+ sizeof (XtOrientation),
+ XtOffsetOf (ArrayRec, array.orientation),
+ XtRImmediate, (XtPointer) XtorientVertical
+ }
};
-static void ClassInitialize(void);
-static void Initialize(Widget, Widget, ArgList, Cardinal *);
-static void Destroy(Widget);
-static void Resize(Widget);
-static Boolean SetValues(Widget, Widget, Widget, ArgList, Cardinal *);
-static XtGeometryResult GeometryManager(Widget,
- XtWidgetGeometry *,
- XtWidgetGeometry *);
-static void ChangeManaged(Widget);
-static void InsertChild(Widget);
-static void DeleteChild(Widget);
-static void dolayout(ArrayWidget, int);
+static void ClassInitialize (void);
+static void Initialize (Widget, Widget, ArgList, Cardinal *);
+static void Destroy (Widget);
+static void Resize (Widget);
+static Boolean SetValues (Widget, Widget, Widget, ArgList, Cardinal *);
+static XtGeometryResult GeometryManager (
+ Widget, XtWidgetGeometry *, XtWidgetGeometry *
+);
+static void ChangeManaged (Widget);
+static void InsertChild (Widget);
+static void DeleteChild (Widget);
+static void dolayout (ArrayWidget, int);
ArrayClassRec arrayClassRec = {
- { /* core_class fields */
- /* superclass */ (WidgetClass) & compositeClassRec,
- /* class_name */ "Array",
- /* widget_size */ sizeof(ArrayRec),
- /* class_initialize */ ClassInitialize,
- /* class_part_init */ NULL,
- /* class_inited */ FALSE,
- /* initialize */ Initialize,
- /* initialize_hook */ NULL,
- /* realize */ XtInheritRealize,
- /* actions */ NULL,
- /* num_actions */ 0,
- /* resources */ resources,
- /* num_resources */ XtNumber(resources),
- /* xrm_class */ NULLQUARK,
- /* compress_motion */ TRUE,
- /* compress_exposure */ TRUE,
- /* compress_enterleave */ TRUE,
- /* visible_interest */ FALSE,
- /* destroy */ Destroy,
- /* resize */ Resize,
- /* expose */ XtInheritExpose,
- /* set_values */ SetValues,
- /* set_values_hook */ NULL,
- /* set_values_almost */ XtInheritSetValuesAlmost,
- /* get_values_hook */ NULL,
- /* accept_focus */ NULL,
- /* version */ XtVersion,
- /* callback_private */ NULL,
- /* tm_table */ NULL,
- /* query_geometry */ XtInheritQueryGeometry,
- /* display_accelerator */ XtInheritDisplayAccelerator,
- /* extension */ NULL
- }
- ,
- { /* composite_class fields */
- /* geometry_manager */ GeometryManager,
- /* change_managed */ ChangeManaged,
- /* insert_child */ InsertChild,
- /* delete_child */ DeleteChild,
- /* extension */ NULL
- }
- ,
- { /* array_class fields */
- /* dummy */ 0
- }
+ { /* core_class fields */
+ /* superclass */ (WidgetClass) &compositeClassRec,
+ /* class_name */ "Array",
+ /* widget_size */ sizeof(ArrayRec),
+ /* class_initialize */ ClassInitialize,
+ /* class_part_init */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ XtInheritRealize,
+ /* actions */ NULL,
+ /* num_actions */ 0,
+ /* resources */ resources,
+ /* num_resources */ XtNumber (resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ Destroy,
+ /* resize */ Resize,
+ /* expose */ XtInheritExpose,
+ /* set_values */ SetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ NULL,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+ { /* composite_class fields */
+ /* geometry_manager */ GeometryManager,
+ /* change_managed */ ChangeManaged,
+ /* insert_child */ InsertChild,
+ /* delete_child */ DeleteChild,
+ /* extension */ NULL
+ },
+ { /* array_class fields */
+ /* dummy */ 0
+ }
};
-WidgetClass arrayWidgetClass = (WidgetClass) & arrayClassRec;
+WidgetClass arrayWidgetClass = (WidgetClass)&arrayClassRec;
-int Gaworder(Gwidget_t * widget, void *data, Gawordercb func)
-{
+int Gaworder (Gwidget_t *widget, void *data, Gawordercb func) {
ArrayWidget aw;
aw = (ArrayWidget) widget->w;
(*func) (data, &aw->array.data);
- dolayout(aw, TRUE);
+ dolayout (aw, TRUE);
return 0;
}
-int Gawsetmode(Gwidget_t * widget, int mode)
-{
+int Gawsetmode (Gwidget_t *widget, int mode) {
ArrayWidget aw;
aw = (ArrayWidget) widget->w;
aw->array.batchmode = mode;
- dolayout(aw, TRUE);
+ dolayout (aw, TRUE);
return 0;
}
-int Gawgetmode(Gwidget_t * widget)
-{
+int Gawgetmode (Gwidget_t *widget) {
ArrayWidget aw;
aw = (ArrayWidget) widget->w;
return aw->array.batchmode;
}
-void Gawdefcoordscb(int wi, Gawdata_t * dp)
-{
+void Gawdefcoordscb (int wi, Gawdata_t *dp) {
Gawcarray_t *cp;
int sx, sy, csx, csy, ci;
sx = dp->sx, sy = dp->sy;
csx = csy = 0;
for (ci = 0; ci < dp->cj; ci++) {
- cp = &dp->carray[ci];
- if (!cp->flag)
- continue;
- cp->ox = csx, cp->oy = csy;
- if (dp->type == G_AWVARRAY)
- cp->sx = sx - 2 * cp->bs, csy += cp->sy + 2 * cp->bs;
- else
- cp->sy = sy - 2 * cp->bs, csx += cp->sx + 2 * cp->bs;
+ cp = &dp->carray[ci];
+ if (!cp->flag)
+ continue;
+ cp->ox = csx, cp->oy = csy;
+ if (dp->type == G_AWVARRAY)
+ cp->sx = sx - 2 * cp->bs, csy += cp->sy + 2 * cp->bs;
+ else
+ cp->sy = sy - 2 * cp->bs, csx += cp->sx + 2 * cp->bs;
}
if (dp->type == G_AWVARRAY)
- dp->sy = csy;
+ dp->sy = csy;
else
- dp->sx = csx;
+ dp->sx = csx;
}
-static void ClassInitialize(void)
-{
- XtAddConverter(XtRString, XtROrientation, XmuCvtStringToOrientation,
- NULL, (Cardinal) 0);
+static void ClassInitialize (void) {
+ XtAddConverter (
+ XtRString, XtROrientation, XmuCvtStringToOrientation, NULL, 0
+ );
}
-static void Initialize(Widget reqw, Widget neww,
- ArgList args, Cardinal * num_args)
-{
+static void Initialize (
+ Widget reqw, Widget neww, ArgList args, Cardinal *num_args
+) {
ArrayWidget aw;
aw = (ArrayWidget) neww;
if (aw->array.orientation == XtorientVertical)
- aw->array.data.type = G_AWVARRAY;
+ aw->array.data.type = G_AWVARRAY;
else
- aw->array.data.type = G_AWHARRAY;
- aw->array.data.carray = Marrayalloc((long) CHILDINCR * CHILDSIZE);
+ aw->array.data.type = G_AWHARRAY;
+ aw->array.data.carray = Marrayalloc ((long) CHILDINCR * CHILDSIZE);
aw->array.data.cn = CHILDINCR;
aw->array.data.cj = 0;
aw->array.batchmode = FALSE;
if (aw->core.width == 0)
- aw->core.width = 100;
+ aw->core.width = 100;
if (aw->core.height == 0)
- aw->core.height = 100;
+ aw->core.height = 100;
}
-static void Destroy(Widget w)
-{
+static void Destroy (Widget w) {
ArrayWidget aw;
aw = (ArrayWidget) w;
- Marrayfree(aw->array.data.carray);
+ Marrayfree (aw->array.data.carray);
aw->array.data.cn = aw->array.data.cj = 0;
}
-static void Resize(Widget w)
-{
- dolayout((ArrayWidget) w, FALSE);
+static void Resize (Widget w) {
+ dolayout ((ArrayWidget) w, FALSE);
}
-static Boolean SetValues(Widget curw, Widget reqw, Widget neww,
- ArgList args, Cardinal * num_args)
-{
+static Boolean SetValues (
+ Widget curw, Widget reqw, Widget neww, ArgList args, Cardinal *num_args
+) {
ArrayWidget curaw;
ArrayWidget newaw;
curaw = (ArrayWidget) curw;
newaw = (ArrayWidget) neww;
if (curaw->array.orientation != newaw->array.orientation) {
- if (newaw->array.orientation == XtorientVertical)
- newaw->array.data.type = G_AWVARRAY;
- else
- newaw->array.data.type = G_AWHARRAY;
- dolayout(newaw, TRUE);
- return TRUE;
+ if (newaw->array.orientation == XtorientVertical)
+ newaw->array.data.type = G_AWVARRAY;
+ else
+ newaw->array.data.type = G_AWHARRAY;
+ dolayout (newaw, TRUE);
+ return TRUE;
}
return FALSE;
}
-static XtGeometryResult GeometryManager(Widget w,
- XtWidgetGeometry * req,
- XtWidgetGeometry * rep)
-{
+static XtGeometryResult GeometryManager (
+ Widget w, XtWidgetGeometry *req, XtWidgetGeometry *rep
+) {
Dimension width, height;
if (req->request_mode & ~(CWX | CWY | CWWidth | CWHeight))
- return XtGeometryNo;
+ return XtGeometryNo;
if (req->request_mode & (CWX | CWY | CWWidth | CWHeight)) {
- width = (req->request_mode & CWWidth) ? req->width : w->core.width;
- height =
- (req->request_mode & CWHeight) ? req->height : w->core.height;
- w->core.width = width, w->core.height = height;
- dolayout((ArrayWidget) XtParent(w), TRUE);
- return XtGeometryYes;
+ width = (req->request_mode & CWWidth) ? req->width : w->core.width;
+ height = (req->request_mode & CWHeight) ? req->height : w->core.height;
+ w->core.width = width, w->core.height = height;
+ dolayout ((ArrayWidget) XtParent (w), TRUE);
+ return XtGeometryYes;
}
return XtGeometryYes;
}
-static void ChangeManaged(Widget w)
-{
+static void ChangeManaged (Widget w) {
ArrayWidget aw;
aw = (ArrayWidget) w;
if (!aw->array.batchmode)
- dolayout(aw, TRUE);
+ dolayout (aw, TRUE);
}
-static void InsertChild(Widget w)
-{
+static void InsertChild (Widget w) {
ArrayWidget aw;
CompositeWidgetClass sclass;
sclass = (CompositeWidgetClass) compositeWidgetClass;
(*sclass->composite_class.insert_child) (w);
- aw = (ArrayWidget) XtParent(w);
+ aw = (ArrayWidget) XtParent (w);
if (aw->array.data.cj == aw->array.data.cn) {
- aw->array.data.carray = Marraygrow(aw->array.data.carray,
- (long) (aw->array.data.cn +
- CHILDINCR) * CHILDSIZE);
- aw->array.data.cn += CHILDINCR;
+ aw->array.data.carray = Marraygrow (
+ aw->array.data.carray,
+ (long) (aw->array.data.cn + CHILDINCR) * CHILDSIZE
+ );
+ aw->array.data.cn += CHILDINCR;
}
aw->array.data.carray[aw->array.data.cj++].w = w;
}
-static void DeleteChild(Widget w)
-{
+static void DeleteChild (Widget w) {
ArrayWidget aw;
CompositeWidgetClass sclass;
int ci;
sclass = (CompositeWidgetClass) compositeWidgetClass;
(*sclass->composite_class.delete_child) (w);
- aw = (ArrayWidget) XtParent(w);
+ aw = (ArrayWidget) XtParent (w);
for (ci = 0; ci < aw->array.data.cj; ci++)
- if (aw->array.data.carray[ci].w == w)
- break;
+ if (aw->array.data.carray[ci].w == w)
+ break;
if (ci < aw->array.data.cj) {
- for (; ci + 1 < aw->array.data.cj; ci++)
- aw->array.data.carray[ci].w = aw->array.data.carray[ci + 1].w;
- aw->array.data.cj--;
+ for (; ci + 1 < aw->array.data.cj; ci++)
+ aw->array.data.carray[ci].w = aw->array.data.carray[ci + 1].w;
+ aw->array.data.cj--;
}
}
-static void dolayout(ArrayWidget aw, int flag)
-{
+static void dolayout (ArrayWidget aw, int flag) {
XtWidgetGeometry req, ret_req;
Gawdata_t *dp;
Gawcarray_t *cp;
int sx, sy, ci;
if (aw->array.batchmode)
- return;
+ return;
dp = &aw->array.data;
for (ci = 0; ci < dp->cj; ci++) {
- if (!XtIsManaged(dp->carray[ci].w)) {
- dp->carray[ci].flag = 0;
- continue;
- }
- cp = &dp->carray[ci];
- cp->flag = 1;
- cp->ox = cp->w->core.x;
- cp->oy = cp->w->core.y;
- cp->sx = cp->w->core.width;
- cp->sy = cp->w->core.height;
- cp->bs = cp->w->core.border_width;
+ if (!XtIsManaged (dp->carray[ci].w)) {
+ dp->carray[ci].flag = 0;
+ continue;
+ }
+ cp = &dp->carray[ci];
+ cp->flag = 1;
+ cp->ox = cp->w->core.x;
+ cp->oy = cp->w->core.y;
+ cp->sx = cp->w->core.width;
+ cp->sy = cp->w->core.height;
+ cp->bs = cp->w->core.border_width;
}
dp->sx = aw->core.width, dp->sy = aw->core.height;
- XtCallCallbackList((Widget) aw, aw->array.callbacks, dp);
+ XtCallCallbackList ((Widget) aw, aw->array.callbacks, dp);
if ((sx = dp->sx) < MINAWSIZE)
- sx = MINAWSIZE;
+ sx = MINAWSIZE;
if ((sy = dp->sy) < MINAWSIZE)
- sy = MINAWSIZE;
+ sy = MINAWSIZE;
if (flag && (aw->core.width != sx || aw->core.height != sy)) {
- req.width = sx, req.height = sy;
- req.request_mode = CWWidth | CWHeight;
- if (XtMakeGeometryRequest((Widget) aw, &req, &ret_req) ==
- XtGeometryAlmost) {
- req = ret_req;
- XtMakeGeometryRequest((Widget) aw, &req, &ret_req);
- dp->sx = req.width, dp->sy = req.height;
- XtCallCallbackList((Widget) aw, aw->array.callbacks, dp);
- }
+ req.width = sx, req.height = sy;
+ req.request_mode = CWWidth | CWHeight;
+ if (XtMakeGeometryRequest (
+ (Widget) aw, &req, &ret_req
+ ) == XtGeometryAlmost) {
+ req = ret_req;
+ XtMakeGeometryRequest ((Widget) aw, &req, &ret_req);
+ dp->sx = req.width, dp->sy = req.height;
+ XtCallCallbackList ((Widget) aw, aw->array.callbacks, dp);
+ }
}
for (ci = 0; ci < dp->cj; ci++) {
- cp = &dp->carray[ci];
- if (!cp->flag)
- continue;
- XtConfigureWidget(cp->w, cp->ox, cp->oy, cp->sx, cp->sy, cp->bs);
+ cp = &dp->carray[ci];
+ if (!cp->flag)
+ continue;
+ XtConfigureWidget (cp->w, cp->ox, cp->oy, cp->sx, cp->sy, cp->bs);
}
}
* AT&T Research, Florham Park NJ *
**********************************************************/
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
+/* Lefteris Koutsofios - AT&T Labs Research */
#include "common.h"
#include "g.h"
#define WBU widget->u.b
-static void bwcallback(Widget, XtPointer, XtPointer);
+static void bwcallback (Widget, XtPointer, XtPointer);
-int GBcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
- int attrn, Gwattr_t * attrp)
-{
+int GBcreatewidget (
+ Gwidget_t *parent, Gwidget_t *widget,
+ int attrn, Gwattr_t *attrp
+) {
PIXsize_t ps;
char *s;
int ai;
int color;
if (!parent) {
- Gerr(POS, G_ERRNOPARENTWIDGET);
- return -1;
+ Gerr (POS, G_ERRNOPARENTWIDGET);
+ return -1;
}
WBU->func = NULL;
ps.x = ps.y = MINBWSIZE;
s = NULL;
RESETARGS;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRSIZE:
- GETSIZE(attrp[ai].u.s, ps, MINBWSIZE);
- break;
- case G_ATTRBORDERWIDTH:
- ADD2ARGS(XtNborderWidth, attrp[ai].u.i);
- break;
- case G_ATTRTEXT:
- s = attrp[ai].u.t;
- ADD2ARGS(XtNlabel, s);
- break;
- case G_ATTRCOLOR:
- color = attrp[ai].u.c.index;
- if (color != 0 && color != 1) {
- Gerr(POS, G_ERRBADCOLORINDEX, color);
- return -1;
+ switch (attrp[ai].id) {
+ case G_ATTRSIZE:
+ GETSIZE (attrp[ai].u.s, ps, MINBWSIZE);
+ break;
+ case G_ATTRBORDERWIDTH:
+ ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
+ break;
+ case G_ATTRTEXT:
+ s = attrp[ai].u.t;
+ ADD2ARGS (XtNlabel, s);
+ break;
+ case G_ATTRCOLOR:
+ color = attrp[ai].u.c.index;
+ if (color != 0 && color != 1) {
+ Gerr (POS, G_ERRBADCOLORINDEX, color);
+ return -1;
+ }
+ c.red = attrp[ai].u.c.r * 257;
+ c.green = attrp[ai].u.c.g * 257;
+ c.blue = attrp[ai].u.c.b * 257;
+ if (XAllocColor (
+ Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
+ )) {
+ if (color == 0)
+ ADD2ARGS (XtNbackground, c.pixel);
+ else
+ ADD2ARGS (XtNforeground, c.pixel);
}
- c.red = attrp[ai].u.c.r * 257;
- c.green = attrp[ai].u.c.g * 257;
- c.blue = attrp[ai].u.c.b * 257;
- if (XAllocColor
- (Gdisplay, DefaultColormap(Gdisplay, Gscreenn), &c)) {
- if (color == 0)
- ADD2ARGS(XtNbackground, c.pixel);
- else
- ADD2ARGS(XtNforeground, c.pixel);
- }
- break;
- case G_ATTRWINDOWID:
- Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
- return -1;
- case G_ATTRBUTTONCB:
- WBU->func = (Gbuttoncb) attrp[ai].u.func;
- break;
- case G_ATTRUSERDATA:
- widget->udata = attrp[ai].u.u;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ break;
+ case G_ATTRWINDOWID:
+ Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
+ return -1;
+ case G_ATTRBUTTONCB:
+ WBU->func = (Gbuttoncb) attrp[ai].u.func;
+ break;
+ case G_ATTRUSERDATA:
+ widget->udata = attrp[ai].u.u;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
if (!s || s[0] == '\000') {
- ADD2ARGS(XtNwidth, ps.x);
- ADD2ARGS(XtNheight, ps.y);
+ ADD2ARGS (XtNwidth, ps.x);
+ ADD2ARGS (XtNheight, ps.y);
} else {
- if (ps.x > MINBWSIZE)
- ADD2ARGS(XtNwidth, ps.x);
- if (ps.y > MINBWSIZE)
- ADD2ARGS(XtNheight, ps.y);
+ if (ps.x > MINBWSIZE)
+ ADD2ARGS (XtNwidth, ps.x);
+ if (ps.y > MINBWSIZE)
+ ADD2ARGS (XtNheight, ps.y);
}
- ADD2ARGS(XtNhighlightThickness, 0);
- ADD2ARGS(XtNinternalHeight, 0);
- ADD2ARGS(XtNinternalWidth, 0);
- ADD2ARGS(XtNjustify, XtJustifyLeft);
- if (!(widget->w = XtCreateWidget("command", commandWidgetClass,
- parent->w, argp, argn))) {
- Gerr(POS, G_ERRCANNOTCREATEWIDGET);
- return -1;
+ ADD2ARGS (XtNhighlightThickness, 0);
+ ADD2ARGS (XtNinternalHeight, 0);
+ ADD2ARGS (XtNinternalWidth, 0);
+ ADD2ARGS (XtNjustify, XtJustifyLeft);
+ if (!(widget->w = XtCreateWidget (
+ "command", commandWidgetClass, parent->w, argp, argn
+ ))) {
+ Gerr (POS, G_ERRCANNOTCREATEWIDGET);
+ return -1;
}
- XtAddCallback(widget->w, XtNcallback, bwcallback,
- (XtPointer) widget->udata);
- Glazymanage(widget->w);
+ XtAddCallback (
+ widget->w, XtNcallback, bwcallback, (XtPointer) widget->udata
+ );
+ Glazymanage (widget->w);
return 0;
}
-int GBsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GBsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
PIXsize_t ps;
int ai;
XColor c;
RESETARGS;
for (ai = 0; ai < attrn; ai++) {
- switch (attrp[ai].id) {
- case G_ATTRSIZE:
- GETSIZE(attrp[ai].u.s, ps, MINBWSIZE);
- ADD2ARGS(XtNwidth, ps.x);
- ADD2ARGS(XtNheight, ps.y);
- break;
- case G_ATTRBORDERWIDTH:
- ADD2ARGS(XtNborderWidth, attrp[ai].u.i);
- break;
- case G_ATTRTEXT:
- ADD2ARGS(XtNlabel, attrp[ai].u.t);
- break;
- case G_ATTRCOLOR:
- color = attrp[ai].u.c.index;
- if (color != 0 && color != 1) {
- Gerr(POS, G_ERRBADCOLORINDEX, color);
- return -1;
- }
- c.red = attrp[ai].u.c.r * 257;
- c.green = attrp[ai].u.c.g * 257;
- c.blue = attrp[ai].u.c.b * 257;
- if (XAllocColor
- (Gdisplay, DefaultColormap(Gdisplay, Gscreenn), &c)) {
- if (color == 0)
- ADD2ARGS(XtNbackground, c.pixel);
- else
- ADD2ARGS(XtNforeground, c.pixel);
+ switch (attrp[ai].id) {
+ case G_ATTRSIZE:
+ GETSIZE (attrp[ai].u.s, ps, MINBWSIZE);
+ ADD2ARGS (XtNwidth, ps.x);
+ ADD2ARGS (XtNheight, ps.y);
+ break;
+ case G_ATTRBORDERWIDTH:
+ ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
+ break;
+ case G_ATTRTEXT:
+ ADD2ARGS (XtNlabel, attrp[ai].u.t);
+ break;
+ case G_ATTRCOLOR:
+ color = attrp[ai].u.c.index;
+ if (color != 0 && color != 1) {
+ Gerr (POS, G_ERRBADCOLORINDEX, color);
+ return -1;
+ }
+ c.red = attrp[ai].u.c.r * 257;
+ c.green = attrp[ai].u.c.g * 257;
+ c.blue = attrp[ai].u.c.b * 257;
+ if (XAllocColor (
+ Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
+ )) {
+ if (color == 0)
+ ADD2ARGS (XtNbackground, c.pixel);
+ else
+ ADD2ARGS (XtNforeground, c.pixel);
}
- break;
- case G_ATTRWINDOWID:
- Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
- return -1;
- case G_ATTRBUTTONCB:
- WBU->func = (Gbuttoncb) attrp[ai].u.func;
- break;
- case G_ATTRUSERDATA:
- widget->udata = attrp[ai].u.u;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ break;
+ case G_ATTRWINDOWID:
+ Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
+ return -1;
+ case G_ATTRBUTTONCB:
+ WBU->func = (Gbuttoncb) attrp[ai].u.func;
+ break;
+ case G_ATTRUSERDATA:
+ widget->udata = attrp[ai].u.u;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
- XtSetValues(widget->w, argp, argn);
+ XtSetValues (widget->w, argp, argn);
return 0;
}
-int GBgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
+int GBgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
Dimension width, height;
char *s;
int ai;
for (ai = 0; ai < attrn; ai++) {
- RESETARGS;
- switch (attrp[ai].id) {
- case G_ATTRSIZE:
- ADD2ARGS(XtNwidth, &width);
- ADD2ARGS(XtNheight, &height);
- XtGetValues(widget->w, argp, argn);
- attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
- break;
- case G_ATTRBORDERWIDTH:
- ADD2ARGS(XtNborderWidth, &width);
- XtGetValues(widget->w, argp, argn);
- attrp[ai].u.i = width;
- break;
- case G_ATTRTEXT:
- ADD2ARGS(XtNlabel, &s);
- XtGetValues(widget->w, argp, argn);
- attrp[ai].u.t = s;
- break;
- case G_ATTRWINDOWID:
- sprintf(&Gbufp[0], "0x%lx", XtWindow(widget->w));
- attrp[ai].u.t = &Gbufp[0];
- break;
- case G_ATTRBUTTONCB:
- attrp[ai].u.func = (void *) (WBU->func);
- break;
- case G_ATTRUSERDATA:
- attrp[ai].u.u = widget->udata;
- break;
- default:
- Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
- return -1;
- }
+ RESETARGS;
+ switch (attrp[ai].id) {
+ case G_ATTRSIZE:
+ ADD2ARGS (XtNwidth, &width);
+ ADD2ARGS (XtNheight, &height);
+ XtGetValues (widget->w, argp, argn);
+ attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
+ break;
+ case G_ATTRBORDERWIDTH:
+ ADD2ARGS (XtNborderWidth, &width);
+ XtGetValues (widget->w, argp, argn);
+ attrp[ai].u.i = width;
+ break;
+ case G_ATTRTEXT:
+ ADD2ARGS (XtNlabel, &s);
+ XtGetValues (widget->w, argp, argn);
+ attrp[ai].u.t = s;
+ break;
+ case G_ATTRWINDOWID:
+ sprintf (&Gbufp[0], "0x%lx", XtWindow (widget->w));
+ attrp[ai].u.t = &Gbufp[0];
+ break;
+ case G_ATTRBUTTONCB:
+ attrp[ai].u.func = WBU->func;
+ break;
+ case G_ATTRUSERDATA:
+ attrp[ai].u.u = widget->udata;
+ break;
+ default:
+ Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
+ return -1;
+ }
}
return 0;
}
-int GBdestroywidget(Gwidget_t * widget)
-{
- XtDestroyWidget(widget->w);
+int GBdestroywidget (Gwidget_t *widget) {
+ XtDestroyWidget (widget->w);
return 0;
}
-static void bwcallback(Widget w, XtPointer clientdata, XtPointer calldata)
-{
+static void bwcallback (Widget w, XtPointer clientdata, XtPointer calldata) {
Gwidget_t *widget;
- widget = findwidget((unsigned long) w, G_BUTTONWIDGET);
+ widget = findwidget ((unsigned long) w, G_BUTTONWIDGET);
if (WBU->func)
- (*WBU->func) (widget - &Gwidgets[0], clientdata);
+ (*WBU->func) (widget - &Gwidgets[0], clientdata);
}