Blob Blame History Raw
/* 
 * Motif
 *
 * Copyright (c) 1987-2012, The Open Group. All rights reserved.
 *
 * These libraries and programs are free software; you can
 * redistribute them and/or modify them under the terms of the GNU
 * Lesser General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * These libraries and programs are distributed in the hope that
 * they will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE. See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with these librararies and programs; if not, write
 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
 * Floor, Boston, MA 02110-1301 USA
*/ 
/* 
 * HISTORY
*/ 
#ifdef REV_INFO
#ifndef lint
static char rcsid[] = "$XConsortium: ToggleBGad2.c /main/8 1995/07/13 17:31:11 drk $"
#endif
#endif
/*
*  (c) Copyright 1989, HEWLETT-PACKARD COMPANY */
/****************************************************************************
 *
 * This program tests  a toggle pixmap, and the XmNindicatorOn resource.\
 *
 ****************************************************************************/
#include <X11/Xlib.h>
#include <X11/StringDefs.h>
#include <X11/IntrinsicP.h>
#include <X11/Xatom.h>

#include <testlib.h>

char smileRaster[] =
{
   0xff, 0xff, 0xff, 0x01, 0x00, 0xfe, 0xff, 0xff,
   0xff, 0xff, 0x3f, 0x00, 0x00, 0xe0, 0xff, 0xff,
   0xff, 0xff, 0x0f, 0xfc, 0xff, 0xc1, 0xff, 0xff,
   0xff, 0xff, 0x83, 0xff, 0xff, 0x0f, 0xff, 0xff,
   0xff, 0xff, 0xf0, 0xff, 0xff, 0x3f, 0xfc, 0xff,
   0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xf8, 0xff,
   0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff,
   0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff,
   0xff, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff,
   0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff,
   0xff, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff,
   0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff,
   0x7f, 0xfc, 0x1f, 0xfe, 0x7f, 0xf8, 0x3f, 0xff,
   0x7f, 0xfe, 0xe7, 0xf9, 0x9f, 0xe7, 0x3f, 0xff,
   0x3f, 0xff, 0xfb, 0xf7, 0xef, 0xdf, 0x7f, 0xfe,
   0x3f, 0xff, 0xfd, 0xef, 0xf7, 0xbf, 0x7f, 0xfe,
   0x3f, 0xff, 0xfd, 0xef, 0xf7, 0xbf, 0xff, 0xfc,
   0x9f, 0xff, 0xfe, 0xdf, 0xfb, 0x7f, 0xff, 0xfc,
   0x9f, 0xff, 0xfe, 0xdf, 0xfb, 0x7f, 0xff, 0xf9,
   0x9f, 0xff, 0xfe, 0xc1, 0xfb, 0x07, 0xff, 0xf9,
   0xcf, 0xff, 0xfe, 0xc0, 0xfb, 0x03, 0xff, 0xf9,
   0xcf, 0xff, 0x7d, 0xe0, 0xf7, 0x81, 0xff, 0xf3,
   0xcf, 0xff, 0x3d, 0xe0, 0xf7, 0x80, 0xff, 0xf3,
   0xcf, 0xff, 0x3b, 0xf0, 0xef, 0xc0, 0xff, 0xf3,
   0xcf, 0xff, 0x27, 0xf8, 0x9f, 0xe0, 0xff, 0xf3,
   0xcf, 0xff, 0x1f, 0xfe, 0x7f, 0xf8, 0xff, 0xf3,
   0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3,
   0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3,
   0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3,
   0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3,
   0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3,
   0xcf, 0xef, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xf3,
   0xcf, 0xef, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xf3,
   0xcf, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xf3,
   0xcf, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xf3,
   0xcf, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfb,
   0xdf, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xfb,
   0x9f, 0xff, 0xfc, 0xff, 0xff, 0x9f, 0xff, 0xf9,
   0x9f, 0xff, 0xfb, 0xff, 0xff, 0xcf, 0xff, 0xf9,
   0x3f, 0xff, 0xef, 0xff, 0xff, 0xf3, 0xff, 0xfc,
   0x3f, 0xff, 0x1f, 0xff, 0x7f, 0xf8, 0xff, 0xfc,
   0x3f, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xfe,
   0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff,
   0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff,
   0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff,
   0xff, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x9f, 0xff,
   0xff, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff,
   0xff, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff,
   0xff, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xff,
   0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff,
   0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff,
   0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff,
   0xff, 0x3f, 0xfe, 0xff, 0xff, 0x3f, 0xfe, 0xff,
   0xff, 0x7f, 0xfc, 0xff, 0xff, 0x1f, 0xff, 0xff,
   0xff, 0xff, 0xf0, 0xff, 0xff, 0xc3, 0xff, 0xff,
   0xff, 0xff, 0xe1, 0xff, 0xff, 0xe0, 0xff, 0xff,
   0xff, 0xff, 0x03, 0xff, 0x3f, 0xf8, 0xff, 0xff,
   0xff, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0xc0, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};

#include "smiley.bmp"
#define XBMs_BITS        smiley_bits
#define XBMs_WIDTH       smiley_width
#define XBMs_HEIGHT      smiley_height
Pixmap select_pixmap;

void main (argc, argv)
unsigned int argc;
char **argv;

{
  int n;
  XImage *pic;
  Widget toggle, bb ;
  Arg args[10];
  Screen *screen;
  Pixmap pixOn, pixOff;
  GC gc;
  XGCValues values;
  XtGCMask valueMask; 
  Drawable drawable;
  Window win;

  CommonTestInit(argc, argv);
  
  n = 0;
  bb = XmCreateBulletinBoard(Shell1, "bb", args, n);
 
  screen=XtScreen(Shell1);
  pic = XCreateImage(display, (Visual *) screen, 1, XYBitmap, 0, smileRaster, 64, 64,
		     BitmapPad(display), 8);

  pic->byte_order = MSBFirst;
  pic->bitmap_bit_order = LSBFirst;
  pic->bitmap_unit = 8;

  drawable = RootWindowOfScreen(XtScreen(Shell1));
  pixOn = XCreatePixmap(display, drawable, 64, 64, 
			DefaultDepthOfScreen(screen));    
  pixOff = XCreatePixmap(display, drawable, 64, 64, 
			 DefaultDepthOfScreen(screen));    
  values.foreground = XBlackPixel(display, 0);
  values.background = XWhitePixel(display, 0);
  valueMask = GCForeground | GCBackground;
  gc = XCreateGC(display, drawable, valueMask, &values);
    
  XPutImage(display, pixOn, gc, pic, 0, 0, 0, 0, 64, 64);
  values.foreground = XWhitePixel(display, 0);
  values.background = XBlackPixel(display, 0);
  valueMask = GCForeground | GCBackground;
  XChangeGC(display, gc, valueMask, &values);
  XPutImage(display, pixOff, gc, pic, 0, 0, 0, 0, 64, 64);
  
  n = 0;
  XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++;
  XtSetArg(args[n], XmNlabelPixmap, pixOff); n++;  
  XtSetArg(args[n], XmNlabelInsensitivePixmap, pixOn); n++; 
  XtSetArg(args[n], XmNset, True); n++;
  XtSetArg(args[n], XmNsensitive, False); n++;
  toggle = XmCreateToggleButtonGadget(bb, "label1", args, n); 

  XtManageChild (bb);
  XtManageChild (toggle);
  XtRealizeWidget (Shell1);

  CommonPause();
  CommonPause();

  XtAppMainLoop(app_context);
  XtDestroyWidget(bb);
  XtDestroyWidget(toggle);
}