|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T x
Length: 2896 (0xb50) Types: TextFile Names: »xselectbit.c«
└─⟦8648bda34⟧ Bits:30007244 EUUGD5_II: X11R5 └─⟦2ca9b63e1⟧ »./contrib-1/contrib-1.00« └─⟦a8392fb20⟧ └─⟦this⟧ »contrib/examples/OReilly/Vol4/ch10/xselectbit.c«
/* * Copyright 1989 O'Reilly and Associates, Inc. * See ../Copyright for complete rights and liability information. */ /* * xselectbit.c */ #include <stdio.h> #include <X11/Intrinsic.h> #include <X11/StringDefs.h> #include <X11/Xaw/Form.h> #include <X11/Xaw/Box.h> #include <X11/Xaw/Command.h> #include "BitmapEdit.h" Dimension pixmap_width_in_cells, pixmap_height_in_cells; /* * The Printout routine prints an array of 1s and 0s representing the * contents of the bitmap. This data can be processed into any * desired form, including standard X11 bitmap file format. */ /* ARGSUSED */ static void Printout(widget, client_data, call_data) Widget widget; XtPointer client_data; /* cast to bigBitmap */ XtPointer call_data; /* unused */ { Widget bigBitmap = (Widget) client_data; int x, y; char *cell; cell = BitmapEditGetArrayString(bigBitmap); (void) putchar('\n'); for (y = 0; y < pixmap_height_in_cells; y++) { for (x = 0; x < pixmap_width_in_cells; x++) (void) putchar(cell[x + y * pixmap_width_in_cells] ? '1' : '0'); (void) putchar('\n'); } (void) putchar('\n'); } main(argc, argv) int argc; char *argv[]; { XtAppContext app_context; Widget topLevel, form, buttonbox, quit, output, bigBitmap; extern exit(); static XrmOptionDescRec table[] = { {"-pw", "*pixmapWidthInCells", XrmoptionSepArg, NULL}, {"-pixmapwidth", "*pixmapWidthInCells", XrmoptionSepArg, NULL}, {"-ph", "*pixmapHeightInCells", XrmoptionSepArg, NULL}, {"-pixmapheight", "*pixmapHeightInCells", XrmoptionSepArg, NULL}, {"-cellsize", "*cellSizeInPixels", XrmoptionSepArg, NULL}, }; topLevel = XtVaAppInitialize( &app_context, /* Application context */ "XSelectbit", /* Application class */ table, XtNumber(table), /* command line option list */ &argc, argv, /* command line args */ NULL, /* for missing app-defaults file */ NULL); /* terminate varargs list */ form = XtCreateManagedWidget("form", formWidgetClass, topLevel, NULL, 0); buttonbox = XtCreateManagedWidget("buttonbox", boxWidgetClass, form, NULL, 0); output = XtCreateManagedWidget("output", commandWidgetClass, buttonbox, NULL, 0); /* output callback added below, after bitmap widget created */ quit = XtCreateManagedWidget("quit", commandWidgetClass, buttonbox, NULL, 0); XtAddCallback(quit, XtNcallback, exit, NULL); bigBitmap = XtCreateManagedWidget("bigBitmap", bitmapEditWidgetClass, form, NULL, 0); XtAddCallback(output, XtNcallback, Printout, bigBitmap); /* need the following values for the Printout routine. */ XtVaGetValues(bigBitmap, XtNpixmapWidthInCells, &pixmap_width_in_cells, XtNpixmapHeightInCells, &pixmap_height_in_cells, NULL); XtRealizeWidget(topLevel); XtAppMainLoop(app_context); }