/* * xmView.h * * Created on: Mar 21, 2017 * Author: chuck */ #ifndef XMVIEW_H_ #define XMVIEW_H_ #include#include #define WIDTH 3200 #define HEIGHT 3200 Pixmap viewPixmap; Boolean gotViewPixmap; Widget viewArea; void drawPixmap(String fileName); void viewAreaCB(Widget widget, XtPointer clientData, XtPointer callData); void viewAreaExpose(XmDrawingAreaCallbackStruct *cbs); void viewAreaResize(XmDrawingAreaCallbackStruct *cbs); void viewAreaInput(XmDrawingAreaCallbackStruct *cbs); void loadView(Widget parent); #endif /* XMVIEW_H_ */ /* * xmView.c * * Created on: Mar 21, 2017 * Author: chuck */ #include #include "xmView.h" /**** ****/ void drawPixmap(String fileName) { // Pixel fg, bg; //printf("view callDataType = expose\n"); if (gotViewPixmap != True) { bg = 0; /* black background */ fg = 9777215; /* dark red foreground */ printf("fg = %d, bg = %d\n", (int)fg, (int)bg); viewPixmap = XmGetPixmap(XtScreen(viewArea), fileName, fg, bg); gotViewPixmap = True; } XCopyArea(XtDisplay(viewArea), viewPixmap, XtWindow(viewArea), XDefaultGCOfScreen(XtScreen(viewArea)), 0, 0, WIDTH, HEIGHT, 0, 0); return; } /**** ****/ void viewAreaExpose(XmDrawingAreaCallbackStruct *cbs) { // printf("view callDataType = expose\n"); //window = cbs->window; drawPixmap("src/X11/bitmaps/xlogo64"); // } /**** ****/ void viewAreaResize(XmDrawingAreaCallbackStruct *cbs) { // printf("view callDataType = resize\n"); // } /**** ****/ void viewAreaInput(XmDrawingAreaCallbackStruct *cbs) { // XEvent *event = cbs->event; Position x = event->xbutton.x; Position y = event->xbutton.y; printf("view callDataType = input at %d, %d\n", x, y); // } /**** ****/ void viewAreaCB(Widget widget, XtPointer clientData, XtPointer callData) { // XmDrawingAreaCallbackStruct *cbs = (XmDrawingAreaCallbackStruct *)callData; int reason = cbs->reason; switch(reason) { case XmCR_EXPOSE: viewAreaExpose(cbs); break; case XmCR_RESIZE: viewAreaResize(cbs); break; case XmCR_INPUT: viewAreaInput(cbs); break; } } /**** ****/ void loadView(Widget parent) { // viewArea = XtVaCreateManagedWidget("drawArea", xmDrawingAreaWidgetClass, parent, XmNbackground, 0, XmNwidth, WIDTH, XmNheight, HEIGHT, NULL); XtAddCallback(viewArea, XmNexposeCallback, viewAreaCB, NULL); XtAddCallback(viewArea, XmNresizeCallback, viewAreaCB, NULL); XtAddCallback(viewArea, XmNinputCallback, viewAreaCB, NULL); }