home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 June
/
Chip_2002-06_cd1.bin
/
ctenari
/
Krutak
/
univiewi_pdk.exe
/
generic
/
generic.cpp
next >
Wrap
C/C++ Source or Header
|
2001-12-30
|
3KB
|
127 lines
#include "generic.h"
HWND uv_hwnd;
int lang, active;
HINSTANCE hI;
int uvplugin_init(up_initdata* updata)
{
updata->items_count=1;
strcpy(updata->plugin_name, "UniView generic plugin (us|sk)");
updata->up_menuitems[0].place=MENU_PLUGINS;
if (lang!=1)
strcpy(updata->up_menuitems[0].name, "Generic plugin");
else
strcpy(updata->up_menuitems[0].name, "Generick² plugin");
updata->version_1=1;
updata->version_2=8;
return 0;
}
int imageeffect(void)
{
int xs, ys;
int i, j;
BYTE r, g, b;
BYTE r1, g1, b1;
CImage *img=(CImage *)UniView_doservice(PLGMSG_GETIMGCLASS, 0, 0);
if (img==NULL)
return 1;
UniView_doservice(PLGMSG_IMAGEMAKEUNDO, 0, 0);
UVImage_quantize(img, 300, 0);
xs=UVImage_getXSize(img);
ys=UVImage_getYSize(img);
for (i=0; i<xs; i++) {
for (j=0; j<ys; j++) {
UVImage_getRGB(img, i, j, r, g, b);
UVImage_getRGB(img, xs-i-1, ys-j-1, r1, g1, b1);
UVImage_setRGB(img, i, j, (r+r1)/2, abs(g+g1)/2, (b+b1)/2);
}
}
UniView_doservice(PLGMSG_DOCUMENTCHANGED, 0, 0);
return 0;
}
BOOL CALLBACK generic_dlgproc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
char buf[128];
switch (uMsg) {
case WM_INITDIALOG:
if (lang==1) {
SetWindowText(hDlg, "Ahoj svet!");
sprintf(buf, "Testova¥ typ %d", (int)UniView_doservice(PLGMSG_GETDOCTYPE, 0, 0));
SetDlgItemText(hDlg, IDC_BUTTON1, buf);
} else {
sprintf(buf, "Test type %d", (int)UniView_doservice(PLGMSG_GETDOCTYPE, 0, 0));
SetDlgItemText(hDlg, IDC_BUTTON1, buf);
}
active=1;
return TRUE;
case WM_DESTROY:
active=0;
return 0;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
EndDialog(hDlg, 0);
return 0;
case IDC_BUTTON1:
switch ((int)UniView_doservice(PLGMSG_GETDOCTYPE, 0, 0)) {
case 1:
if (imageeffect())
MessageBox(hDlg, (lang==1)?"Nesprßvny typ s·boru":"Bad file type", "Generic", MB_OK);
return 0;
default:
MessageBox(hDlg, (lang==1)?"OstatnΘ funkcie zatia╛ neboli implementovanΘ":"Other functions weren't implemented yet", "Generic", MB_OK);
return 0;
}
return 0;
}
}
return 0;
}
int uvplugin_command(int command)
{
switch (command) {
case 0:
DialogBox(hI, "TESTDLG", uv_hwnd, (DLGPROC)generic_dlgproc);
return 0;
}
return 0;
}
int uvplugin_getsettings(void)
{
uv_hwnd=(HWND)UniView_doservice(PLGMSG_GETUVHWND, 0, 0);
lang=(int)UniView_doservice(PLGMSG_GETLANG, 0, 0);
return 0;
}
int __stdcall uvplugin_main(HINSTANCE plgI, DWORD message, DWORD wParam, DWORD lParam)
{
switch (message) {
case UVMSG_INITPLUGIN:
hI=plgI;
active=0;
lang=(int)UniView_doservice(PLGMSG_GETLANG, 0, 0);
return uvplugin_init((up_initdata*)wParam);
case UVMSG_EXIT:
return 0;
case UVMSG_STOPEXIT:
return (active==0)?0:1;
case UVMSG_DOCUMENT_SAVED:
case UVMSG_DOCUMENT_NEWOPENED:
case UVMSG_SETTINGS_CHANGED:
uvplugin_getsettings();
return 0;
case UVMSG_COMMAND:
return uvplugin_command((int)wParam);
}
return 0;
}