/usr/share/doc/xviewg/examples/color/color_panel.c is in xview-examples 3.2p1.4-28.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | /* color_panel.c --
* This program demonstrates how to set panel items to different
* colors using the XView API for color.
*/
#include <xview/xview.h>
#include <xview/panel.h>
#include <xview/cms.h>
/* Color indices */
#define WHITE 0
#define RED 1
#define GREEN 2
#define BLUE 3
#define NUM_COLORS 4
/* Create a frame, panel, and a colormap segment and assign the
* cms to the panel.
*/
main(argc,argv)
int argc;
char *argv[];
{
Frame frame;
Panel panel;
Cms cms;
extern void exit(), pressed();
static Xv_singlecolor colors[] = {
{ 255, 255, 255 }, /* white */
{ 255, 0, 0 }, /* red */
{ 0, 255, 0 }, /* green */
{ 0, 0, 255 }, /* blue */
};
xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);
cms = (Cms) xv_create(NULL, CMS,
CMS_CONTROL_CMS, TRUE,
CMS_SIZE, CMS_CONTROL_COLORS + 4,
CMS_COLORS, colors,
NULL);
frame = (Frame)xv_create(XV_NULL, FRAME,
FRAME_LABEL, argv[0],
FRAME_SHOW_FOOTER, TRUE,
NULL);
panel = xv_create(frame, PANEL,
WIN_CMS, cms,
NULL);
xv_create(panel, PANEL_BUTTON,
PANEL_LABEL_STRING, "Red",
PANEL_ITEM_COLOR, CMS_CONTROL_COLORS + RED,
PANEL_NOTIFY_PROC, pressed,
NULL);
xv_create(panel, PANEL_BUTTON,
PANEL_LABEL_STRING, "Green",
PANEL_ITEM_COLOR, CMS_CONTROL_COLORS + GREEN,
PANEL_NOTIFY_PROC, pressed,
NULL);
xv_create(panel, PANEL_BUTTON,
PANEL_LABEL_STRING, "Blue",
PANEL_ITEM_COLOR, CMS_CONTROL_COLORS + BLUE,
PANEL_NOTIFY_PROC, pressed,
NULL);
xv_create(panel, PANEL_BUTTON,
PANEL_LABEL_STRING, "Quit",
PANEL_ITEM_COLOR, CMS_CONTROL_COLORS + WHITE,
PANEL_NOTIFY_PROC, exit,
NULL);
window_fit(panel);
window_fit(frame);
xv_main_loop(frame);
}
void
pressed(item, event)
Panel_item item;
Event *event;
{
char *name = (char *)xv_get(item, PANEL_LABEL_STRING);
Frame frame = xv_get(xv_get(item, PANEL_PARENT_PANEL), XV_OWNER);
xv_set(frame, FRAME_LEFT_FOOTER, name, NULL);
}
|