home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
contro.zip
/
SHADEXT.C
< prev
next >
Wrap
Text File
|
1994-12-29
|
7KB
|
321 lines
#define INCL_DOS
#define INCL_WIN
#define INCL_GPI
/* Presentation Manager include file */
#include <os2.h>
/*
* Include C library routine header files
*/
#include <stdlib.h> /* Miscellaneous function declarations */
#include <stdio.h> /* Declarations for standard I/O routines */
#include <string.h> /* String function declarations */
#include <memory.h> /* Declarations for memory manipulation */
/*
* Include C GPF API User Control header files
*/
#include "GpfUC.h"
#include "shadext.h"
#include "shadowx.h"
/* prototypes */
MRESULT EXPENTRY fnwpExtShadowx(HWND, ULONG, MPARAM, MPARAM);
struct{
ULONG Color;
PSZ Text;
} Colors[]={
CLR_WHITE, "WHITE",
CLR_BLACK, "BLACK",
CLR_RED, "RED",
CLR_BLUE, "BLUE",
CLR_GREEN, "GREEN",
CLR_CYAN, "CYAN",
CLR_YELLOW, "YELLOW",
CLR_PALEGRAY, "PALEGRAY",
CLR_PINK, "PINK",
CLR_DARKGRAY, "DARK GRAY",
CLR_DARKRED, "DARK RED",
CLR_DARKBLUE, "DARK BLUE",
CLR_DARKGREEN, "DARK GREEN",
CLR_DARKCYAN, "DARK CYAN",
CLR_BROWN, "BROWN",
CLR_DARKPINK, "DARK PINK",
0xffff, ""};
static USHORT ComboID[]=
{ID_CBX_LEFT,ID_CBX_RIGHT,ID_CBX_FORE,ID_CBX_BACK,0};
/************************************************************/
LONG APIENTRY ExtendedShadowx(LONG WsStyle, PVOID pCtlData)
{
HWND hwndActive, hwndDlg;
HMODULE hmod;
UCHAR tmp[256];
APIRET rc;
hwndActive= WinQueryActiveWindow(HWND_DESKTOP);
rc= DosLoadModule(tmp, sizeof(tmp), "SHADOWX", (HMODULE *)&hmod);
hwndDlg= WinDlgBox(
HWND_DESKTOP, /* Parent */
hwndActive, /* Owner */
fnwpExtShadowx, /* Address of dialog proc */
hmod, /* Module handle */
ID_SHADEXT, /* ID of dialog in resource */
pCtlData); /* Initialization data */
return WsStyle;
}
/************************************************************/
MRESULT EXPENTRY fnwpExtShadowx(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
LONG lSpinVal;
SHORT i, j;
USHORT Notify,Index,fAngle;
static BOOL fCreate;
static PUCPARAMS pUC;
static HWND hwndSample;
HPS hps;
CHAR chSave;
switch (msg){
case WM_INITDLG:
fCreate= TRUE;
hwndSample= WinWindowFromID(hwnd,ID_SAMPLE);
pUC= (PUCPARAMS) mp2;
if(pUC->cBytes != sizeof(UCPARAMS)){ /* has it been initialized? */
pUC->cBytes= sizeof(UCPARAMS);
pUC->BgIndex= 7; /* CLR_PALEGRAY offset into struct "Colors" */
pUC->FgIndex= 7;
pUC->LeftIndex= 0;
pUC->LeftColor= CLR_WHITE;
pUC->RightIndex= 1;
pUC->RightColor= CLR_BLACK;
pUC->sAngle= 0;
pUC->fOverride= FALSE;
DosBeep(3000,500);
DosBeep(1500,500);
}
if(!*pUC->chText)
strcpy(pUC->chText,"t");
WinCheckButton(hwnd,ID_CB_OVERRIDE,pUC->fOverride);
/* INIT SPIN BUTTONS */
WinSendDlgItemMsg(
hwnd,
ID_SB_ANGLE,
SPBM_SETLIMITS,
MPFROMLONG(30L),
MPFROMLONG(-30L));
WinSendDlgItemMsg(
hwnd,
ID_SB_ANGLE,
SPBM_SETCURRENTVALUE,
MPFROMLONG((LONG)pUC->sAngle),
0L);
/* INIT COMBO BOXES */
for(i=0; i<4; i++)
WinSendDlgItemMsg(
hwnd,
ComboID[i],
LM_DELETEALL,
0L,0L);
for(i=0; Colors[i].Color != 0xffff; i++)
for(j=0; j<4; j++)
WinSendDlgItemMsg(
hwnd,
ComboID[j],
LM_INSERTITEM,
MPFROMSHORT(LIT_END),
MPFROMP(Colors[i].Text));
WinSendDlgItemMsg(
hwnd,
ID_CBX_LEFT,
LM_SELECTITEM,
MPFROMSHORT(pUC->LeftIndex),
MPFROMSHORT(TRUE));
WinSendDlgItemMsg(
hwnd,
ID_CBX_RIGHT,
LM_SELECTITEM,
MPFROMSHORT(pUC->RightIndex),
MPFROMSHORT(TRUE));
WinSendDlgItemMsg(
hwnd,
ID_CBX_FORE,
LM_SELECTITEM,
MPFROMSHORT(pUC->FgIndex),
MPFROMSHORT(TRUE));
WinSendDlgItemMsg(
hwnd,
ID_CBX_BACK,
LM_SELECTITEM,
MPFROMSHORT(pUC->BgIndex),
MPFROMSHORT(TRUE));
WinEnableWindow(WinWindowFromID(hwnd,ID_CBX_FORE),pUC->fOverride);
WinEnableWindow(WinWindowFromID(hwnd,ID_CBX_BACK),pUC->fOverride);
fCreate= FALSE;
break;
case WM_CONTROL:
case WM_COMMAND:
Notify= SHORT2FROMMP( mp1 );
switch( SHORT1FROMMP( mp1 ) ){
case ID_SB_ANGLE:
if(Notify == SPBN_ENDSPIN){
WinSendDlgItemMsg(
hwnd,
ID_SB_ANGLE,
SPBM_QUERYVALUE,
MPFROMP(&lSpinVal),
MPFROM2SHORT(0,SPBQ_ALWAYSUPDATE));
pUC->sAngle= (SHORT)lSpinVal;
}
else
return FALSE;
break;
case ID_CB_OVERRIDE:
pUC->fOverride=
(BOOL)WinSendDlgItemMsg(
hwnd,
SHORT1FROMMP(mp1),
BM_QUERYCHECK,
0L,0L);
WinEnableWindow(
WinWindowFromID(hwnd,ID_CBX_FORE),
pUC->fOverride);
WinEnableWindow(
WinWindowFromID(hwnd,ID_CBX_BACK),
pUC->fOverride);
break;
case ID_CBX_LEFT:
switch(Notify){
case CBN_ENTER:
case CBN_LBSELECT:
Index=
(SHORT)WinSendDlgItemMsg(
hwnd,
ID_CBX_LEFT,
LM_QUERYSELECTION,
MPFROMSHORT(0),
0L);
if(Index == LIT_NONE)
return WinDefDlgProc( hwnd, msg, mp1, mp2 );
pUC->LeftIndex= Index;
pUC->LeftColor= Colors[Index].Color;
break;
default:
return FALSE;
}
break;
case ID_CBX_RIGHT:
switch(Notify){
case CBN_ENTER:
case CBN_LBSELECT:
Index=
(SHORT)WinSendDlgItemMsg(
hwnd,
ID_CBX_RIGHT,
LM_QUERYSELECTION,
MPFROMSHORT(0),
0L);
if(Index == LIT_NONE)
return WinDefDlgProc( hwnd, msg, mp1, mp2 );
pUC->RightIndex= Index;
pUC->RightColor= Colors[Index].Color;
break;
default:
return FALSE;
}
break;
case ID_CBX_FORE:
switch(Notify){
case CBN_ENTER:
case CBN_LBSELECT:
Index=
(SHORT)WinSendDlgItemMsg(
hwnd,
ID_CBX_FORE,
LM_QUERYSELECTION,
MPFROMSHORT(0),
0L);
if(Index == LIT_NONE)
return WinDefDlgProc( hwnd, msg, mp1, mp2 );
pUC->FgIndex= Index;
pUC->FgColor= Colors[Index].Color;
break;
default:
return FALSE;
}
break;
case ID_CBX_BACK:
switch(Notify){
case CBN_ENTER:
case CBN_LBSELECT:
Index=
(SHORT)WinSendDlgItemMsg(
hwnd,
ID_CBX_BACK,
LM_QUERYSELECTION,
MPFROMSHORT(0),
0L);
if(Index == LIT_NONE)
return WinDefDlgProc( hwnd, msg, mp1, mp2 );
pUC->BgIndex= Index;
pUC->BgColor= Colors[Index].Color;
break;
default:
return FALSE;
}
break;
case ID_PB_OK:
case DID_OK:
WinDismissDlg( hwnd, TRUE );
return FALSE;
default:
return WinDefDlgProc( hwnd, msg, mp1, mp2 );
}
break;
default:
return WinDefDlgProc( hwnd, msg, mp1, mp2 );
}
/* draw a local sample of the text style and color(s) */
if(!fCreate){
hps= WinGetPS(hwndSample);
/* temporarily NULL-terminate after 1st character */
chSave=*(pUC->chText +1);
*(pUC->chText +1)= 0;
Paint(hwndSample, hps, pUC);
*(pUC->chText +1)= chSave;
WinReleasePS(hps);
}
return FALSE;
}