home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1999 February
/
VPR9902A.BIN
/
FFILLY
/
UG
/
winbut.tfy
< prev
Wrap
Text File
|
1998-04-29
|
7KB
|
202 lines
str GB_Cap[]; // CAPTION
int GB_X[];
int GB_Y[];
int GB_W[];
int GB_H[];
int GB_Col[];
int GB_Typ[]; // type
// 1 == disable clicked button
// 2 == disable not clicked button
// 3 == able not clicked button
// 4 == frameless button
int WinFocus; // FOCUS
// PAINT BUTTON ----IF col < 0 NOT PAINT ------------------------------
int paintButton( int pic, int x, int y, int w, int h,
int col1, int col2, int col3 ) {
SetLineSize(1);
if ( col1 >= 0 ) { // FILL RECT
SetPaintColor( col1 );
DrawRect( pic, x, y, x+w, y+h, 0,0 );
}
if ( col2 >= 0 ) {
SetPaintColor( col2 );
DrawLine( pic, x, y, x+w-1, y ); // NORTH
DrawLine( pic, x, y, x, y+h ); // WEST
}
if ( col3 >= 0 ) {
SetPaintColor( col3 );
DrawLine( pic, x+1, y+h-1, x+w-1, y+h-1 ); // SOUTH
DrawLine( pic, x+w-1, y, x+w-1, y+h ); // EAST
}
} // method end
// WINDOW WITH BUTTON -------------------------------------------------
int makeWindow( int winnum, int pic, int x, int y, int w, int h,
int allbut, int save_on, int frmcol ) {
int wpic, spic;
int i, j;
int b_x[], b_y[], b_w[], b_h[], b_typ[]; // FOR CLICK POS
int c1, c2; // FOR BUTTON COLOR
int click_on; // CLICK FRAG
int n; // FOR USER MES
WinFocus = winnum;
click_on = 0;
wpic = CreatePic( pic, w, h );
// SAVE BACK
if ( save_on>=1 ) {
spic = CreatePic( pic, w, h ); MovePic( pic, x,y, w,h, spic, 0,0 );
}
// FORM
if ( GB_Cap[0] == "3D" ) {
paintButton( wpic, 0,0, w,h, -2, frmcol, 0x000000 );
paintButton( wpic, 1,1, w-2,h-2, frmcol, 0xffffff, 0x808080 );
}
else { paintButton( wpic, 0,0, w,h, frmcol, 0xffffff, 0x808080 ); }
// PAINT BUTTON
for ( i = 1; i <= allbut; i = i + 1 ) {
if ( GB_Typ[i]==1 ) { c1 = 0x808080; c2 = 0xffffff; }
else if ( 2<=GB_Typ[i] && GB_Typ[i]<=3 ) { c1 = 0xffffff; c2 = 0x808080; }
else if ( GB_Typ[i]==4 ) { c1 = -2; c2 = -2; }
paintButton( wpic, GB_X[i], GB_Y[i], GB_W[i], GB_H[i], GB_Col[i], c1, c2 );
// CAPTION
SetFont( GB_H[i]-5, "MS ゴシック", 128,0,0,0,600 );
TextWrite( GB_Cap[i], wpic, GB_X[i] + 5, GB_Y[i] + 2 );
// LOCALIZE
b_x[i] = x + GB_X[i]; b_y[i] = y + GB_Y[i];
b_w[i] = GB_W[i]; b_h[i] = GB_H[i];
b_typ[i] = GB_Typ[i];
} // for end
// CLEAR ARRAY
DelArrayAll( GB_Cap[] );
DelArrayAll( GB_X[] ); DelArrayAll( GB_Y[] );
DelArrayAll( GB_W[] ); DelArrayAll( GB_H[] );
DelArrayAll( GB_Col[] ); DelArrayAll( GB_Typ[] );
// PAINT FORM
MovePic( wpic, 0,0, w,h, pic, x,y );
PostMes( USER, 8000, wpic ); // NOTIFY PICTURE NUM
mes( LBDOWN ) {
if ( WinFocus == winnum ) {
for ( i = 1; i <= allbut; i = i + 1 ) {
if ( b_x[i] <= MesP2 && MesP2 < b_x[i]+b_w[i] &&
b_y[i] <= MesP3 && MesP3 < b_y[i]+b_h[i] && b_typ[i] >= 3 ) {
click_on = 1;
if ( b_typ[i] == 3 ) {
paintButton( pic, b_x[i],b_y[i], b_w[i],b_h[i],
-2, 0x808080, 0xffffff );
}
else if ( b_typ[i] == 4 ) {
paintButton( pic, b_x[i] + 1,b_y[i]+1, b_w[i] - 2,b_h[i] - 2,
0x000000, -2, -2 );
}
PostMes( USER, MakeLong( i, winnum ) ); // NOTIFY BUTTON NUM
j = i; break; // SAVE BUTTON NUM
} // if end
} // for end
} // if WinFocus end
} // mes LB end
mes( LBUP ) { // AFTER BUTTON CLICKED
if ( click_on == 1 ) {
if ( b_typ[i]==3) {
paintButton( pic, b_x[j],b_y[j], b_w[j],b_h[j], -2, 0xffffff, 0x808080 );
}
else if( b_typ[i]==4 ){
MovePic( wpic, b_x[j] - x, b_y[j] - y, b_w[j], b_h[j], pic, b_x[j], b_y[j] );
}
click_on = 0;
}
} // mes LBUP end
mes( USER ) {
if ( GetHiWord( MesP1 ) == winnum ) { // GET WIN NUM
n = GetLowWord( MesP1 ); // GET MES NUM
if ( n == 1000 ) { // QUIT
del_us;
DelPic( wpic );
if ( save_on >= 1 ) { // REPAIR BACK
MovePic( spic, 0,0, w,h, pic, x,y ); DelPic( spic );
}
del_me;
}
}
} // mes USER end
} // method end
// INPUT BUTTON ARRAY----- IF -1 NOT INP ------------------------------
int inputButArr( str cap, int x, int y, int w, int h,
int col, int typ, int from, int to ) {
int i;
for ( i = from; i <= to; i = i + 1 ) {
if ( cap != "-1" ) { GB_Cap[i] = cap; }
if ( x != -1 ) { GB_X[i] = x; }
if ( y != -1 ) { GB_Y[i] = y; }
if ( w != -1 ) { GB_W[i] = w; }
if ( h != -1 ) { GB_H[i] = h; }
if ( col != -1 ) { GB_Col[i] = col; }
if ( typ != -1 ) { GB_Typ[i] = typ; }
}
} // method end
// PAINT TEXT ---------------------------------------------------------
int paintText( int pic, int x, int y, int fsize,
int r, int g, int b, str ser ) {
SetFont( fsize, "MS ゴシック", 128,0,0,0,600 );
TextColor( r, g, b ); BackMode(1);
TextWrite( ser, pic, x, y );
} // method end
// PAINT TEXT ---------------------------------------------------------
int paintBText( int pic, int x, int y, int fsize,
int r, int g, int b, str ser ) {
SetFont( fsize, "MS ゴシック", 128,0,0,0,600 );
BackMode( 1 );
TextColor( 0, 0, 0 ); TextWrite( ser, pic, x + 2, y + 2 );
TextColor( r, g, b ); TextWrite( ser, pic, x, y );
} // method end
// PAINT LABEL --------------------------------------------------------
int paintLabel( int pic, int x, int y, int w, int h, int col, str ser ) {
SetFont( h - 5, "MS ゴシック", 128,0,0,0,600 );
TextColor( 255,255,255 ); BackMode(1);
paintButton( pic, x, y, w,h, col, 0x808080, 0xffffff );
TextWrite( ser, pic, x + 5, y + 2 );
} // method end
// DIR ----------------------------------------------------------------
str getDir( str fname ) {
int i;
int len;
str s;
len = StrLen( fname );
i = len; if ( i == 0 ) { return( "" ); }
getDirL1:;
s = SubStr( fname, i-1, 1 );
if ( s == "\" ) { return( SubStr( fname, 0, i ) ); }
else { i = i - 1; goto getDirL1; }
} // method end
// CUT DIR ------------------------------------------------------------
str cutDir( str fname ) {
int i, len;
len = StrLen( fname );
i = len; if ( i == 0 ) { return( "" ); }
cutDirL1:;
if ( i == 0 ) { return(""); }
if ( SubStr( fname, i-1, 1) == "\" ) {
return( SubStr( fname, i, len - i ) );
}
else { i=i-1; goto cutDirL1; }
} // method end