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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
#include <testlib.h>
static char *Strings = {
"We few, we happy few, we band of brothers;\n"
"For he to-day that sheds his blood with me\n"
"Shall be my brother; be he ne'er so vile,\n"
"This day shall gentle his condition:\n"
"And gentlemen in England now a-bed\n"
"Shall think themselves accursed they were not here,\n"
"And hold their manhoods cheap whiles any speaks\n"
"That fought with us upon Saint Crispin's day.\n"
"\tHenry V, Act IV Scene 3, William Shakespeare." };
#define WINDOW_PIXMAP "window.bmp"
#define TEXT_PIXMAP "text.bmp"
static void
SetWidgetColor( Widget w, char *color )
{
Display *display;
Colormap colormap;
XColor newcolor;
XColor unused;
Arg Args[MAX_ARGS];
int n;
display = XtDisplay(w);
colormap = DefaultColormapOfScreen(XtScreen(w));
XAllocNamedColor( display, colormap, color, &newcolor, &unused );
n = 0;
XtSetArg(Args[n], XmNbackground, newcolor.pixel ); n++;
XtSetValues( w, Args, n );
return;
}
static void
PrintValues( Widget window, char *label )
{
int n;
Arg Args[MAX_ARGS];
Widget VerticalSB;
Widget HorizontalSB;
Pixel SBbackground, SWbackground;
Pixel SBbottomShadowColor, SWbottomShadowColor;
Pixel SBtopShadowColor, SWtopShadowColor;
Pixmap SBbackgroundPixmap, SWbackgroundPixmap;
Pixmap SBbottomShadowPixmap, SWbottomShadowPixmap;
Pixmap SBtopShadowPixmap, SWtopShadowPixmap;
(void)printf( "%s\n", label );
VerticalSB = XtNameToWidget( window, "VertScrollBar" );
HorizontalSB = XtNameToWidget( window, "VertScrollBar" );
n = 0;
XtSetArg( Args[n], XmNbackground, &SBbackground ); n++;
XtSetArg( Args[n], XmNbottomShadowColor, &SBbottomShadowColor ); n++;
XtSetArg( Args[n], XmNtopShadowColor, &SBtopShadowColor ); n++;
XtSetArg( Args[n], XmNbackgroundPixmap, &SBbackgroundPixmap ); n++;
XtSetArg( Args[n], XmNbottomShadowPixmap, &SBbottomShadowPixmap ); n++;
XtSetArg( Args[n], XmNtopShadowPixmap, &SBtopShadowPixmap ); n++;
XtGetValues( VerticalSB, Args, n );
n = 0;
XtSetArg( Args[n], XmNbackground, &SWbackground ); n++;
XtSetArg( Args[n], XmNbottomShadowColor, &SWbottomShadowColor ); n++;
XtSetArg( Args[n], XmNtopShadowColor, &SWtopShadowColor ); n++;
XtSetArg( Args[n], XmNbackgroundPixmap, &SWbackgroundPixmap ); n++;
XtSetArg( Args[n], XmNbottomShadowPixmap, &SWbottomShadowPixmap ); n++;
XtSetArg( Args[n], XmNtopShadowPixmap, &SWtopShadowPixmap ); n++;
XtGetValues( window, Args, n );
#define CompareValue(desc) \
(void)printf( "\tVertical ScrollBar " #desc " is %s\n", \
(SW ## desc == SB ## desc) ? "identical" : "different" )
CompareValue(background);
CompareValue(bottomShadowColor);
CompareValue(topShadowColor);
CompareValue(backgroundPixmap);
CompareValue(bottomShadowPixmap);
CompareValue(topShadowPixmap);
#undef CompareValue
n = 0;
XtSetArg( Args[n], XmNbackground, &SBbackground ); n++;
XtSetArg( Args[n], XmNbottomShadowColor, &SBbottomShadowColor ); n++;
XtSetArg( Args[n], XmNtopShadowColor, &SBtopShadowColor ); n++;
XtSetArg( Args[n], XmNbackgroundPixmap, &SBbackgroundPixmap ); n++;
XtSetArg( Args[n], XmNbottomShadowPixmap, &SBbottomShadowPixmap ); n++;
XtSetArg( Args[n], XmNtopShadowPixmap, &SBtopShadowPixmap ); n++;
XtGetValues( HorizontalSB, Args, n );
(void)printf( "\n" );
#define CompareValue(desc) \
(void)printf( "\tHorizontal ScrollBar " #desc " is %s\n", \
(SW ## desc == SB ## desc) ? "identical" : "different" )
CompareValue(background);
CompareValue(bottomShadowColor);
CompareValue(topShadowColor);
CompareValue(backgroundPixmap);
CompareValue(bottomShadowPixmap);
CompareValue(topShadowPixmap);
#undef CompareValue
(void)printf( "\n" );
return;
}
int
main( int argc, char *argv[] )
{
int n;
Arg Args[MAX_ARGS];
int i;
Widget Text;
Widget Window;
Pixmap WindPixmap;
Pixmap TextPixmap;
CommonTestInit(argc, argv);
/* Get the pixmaps for the backgrounds */
WindPixmap = XmGetPixmap(screen, WINDOW_PIXMAP, BlackPixelOfScreen(screen),
WhitePixelOfScreen(screen));
TextPixmap = XmGetPixmap(screen, TEXT_PIXMAP, BlackPixelOfScreen(screen),
WhitePixelOfScreen(screen));
if (!WindPixmap)
{
(void)printf("Can't make pixmap for file %s!\n", WINDOW_PIXMAP );
exit(1);
}
if (!TextPixmap)
{
(void)printf("Can't make pixmap for file %s!\n", TEXT_PIXMAP );
exit(1);
}
/* Make the ScrolledWindow and Text */
n = 0;
XtSetArg( Args[n], XmNvalue, Strings ); n++;
XtSetArg( Args[n], XmNeditable, False ); n++;
XtSetArg( Args[n], XmNeditMode, XmMULTI_LINE_EDIT ); n++;
Text = XmCreateScrolledText(Shell1, "Text", Args, n );
/* Get the Widget for the parent Scrolled Window */
Window = XtParent(Text);
/* Set the Text Pixmap and color */
n = 0;
XtSetArg(Args[n], XmNbackgroundPixmap, TextPixmap ); n++;
XtSetValues( Text, Args, n );
SetWidgetColor( Text, "white" );
/* Set the Window Pixmap and color */
n = 0;
XtSetArg(Args[n], XmNbackgroundPixmap, WindPixmap ); n++;
XtSetValues( Window, Args, n );
SetWidgetColor( Window, "pink" );
XtManageChild(Text);
XtManageChild(Window);
/*************
* Assertion 1. Now that the text and window have differing pixmaps,
* lets dump the values for the child scrollbar values.
*/
PrintValues( Window, "Assertion 1" );
CommonPause();
/*************
* Assertion 2. Now that the text and window have differing pixmaps,
* lets dump the values for the child scrollbar values.
*/
SetWidgetColor( Text, "green" );
PrintValues( Window, "Assertion 2" );
CommonPause();
/* Cleanup Time */
XmDestroyPixmap( screen, WindPixmap );
XmDestroyPixmap( screen, TextPixmap );
XtDestroyWidget( XtParent(Text) );
CommonPause();
XtAppMainLoop(app_context);
return 0;
}
|