#include "..\\include\Lib_Clara.h"
#include "..\\include\Dir.h"
#include "..\\include\cfg_items.h"
#include "conf_loader.h"
#include "config_data.h"
typedef struct
{
BOOK book;
}MyBOOK;
MyBOOK * myBook;
GUI_LIST * list;
GUI* maingui;
bool visible;
BOOK* daemon;
//bool test=0;
#pragma segment="ELFBEGIN"
void elf_exit(void){
kill_data(__segment_begin("ELFBEGIN"), (void(*)(void*))mfree_adr()); //\u041e\u041d\u041a\u0421\u0412\u042e\u0415\u0420\u042f\u042a \u0412\u0420\u041d \u0414\u042e\u041c\u041c\u0428\u0415 \u0411\u0428\u042c\u0415 \u0414\u0415\u041f\u0415\u0419\u0420\u0425\u0411\u0428
} //"pragma" \u041c\u0415 \u0421\u0414\u042e\u041a\u042a\u0427\u0420\u042f\u042a?
int NewKey(int key, int r1 , int mode);
static int ReconfigElf(void *mess ,BOOK *book);
static void onMyBookClose(BOOK * book);
int isPaR(BOOK * struc)
{
if (struc->onClose=
void*)onMyBookClose)
{
return(1);
}
else
{
return(0);
}
}
static int TerminateElf(void * ,BOOK *book)
{
FreeBook(book);
return(1);
}
typedef struct
{
BOOK * book;
}MSG;
static int ShowAuthorInfo(void *mess ,BOOK *book)
{
MSG * msg = (MSG *)mess;
int iconID;
iconidname2id(_T("SMI_WINK_ICN"),-1,&iconID); //
MessageBox(0x6fffffff,STR("Supaelf (c) xzkto"),iconID, 1 ,5000,msg->book);
return(1);
}
void PaRBack(BOOK *bk, void *lt)
{
//GUIObject_SoftKey_RemoveItem(mazaGui,ACTION_BACK);
//GUIObject_SoftKey_RemoveItem(mazaGui,ACTION_SELECT1);
GUI_Free(maingui);
// exitproc();
}
void PaROnEnterPressed(BOOK *bk, void *lt)
{
int item = ListMenu_GetSelectedItem((GUI_LIST*)bk->gui);
if(item==0)
MessageBox (0x6fFFFFFF,STR("Yo!"),0,1,5000,0);
if(item==1)
MessageBox (0x6fFFFFFF,STR("2xYo!"),0,1,5000,0);
}
int PaROnLBMessage(GUI_MESSAGE * msg)
{
int item;
//OBJECT * obj;
int text[2];
switch(msg->msg)
{
case 1:
item=GUIonMessage_GetCreatedItemIndex(msg);
text[0]=Str2ID (L"Line 1",0,100);
text[1]=Str2ID (L"Line 2",0,100);
SetMenuItemText0(msg,TextCopyId(text[item]));
}
return(1);
}
GUI_LIST * PaRCreateGuiList(void * r0, BOOK * bk)
{
bk->gui
GUI*)CreateListObject(bk,0);
GuiObject_SetTitleText(bk->gui,Str2ID(L"Just guilist",0,SID_ANY_LEN));
SetNumOfMenuItem(bk->gui,2);
OneOfMany_SetonMessage((GUI_ONEOFMANY*)bk->gui,PaROnLBMessage);
SetCursorToItem(bk->gui,0);
SetMenuItemStyle(bk->gui,3);
GUIObject_Softkey_SetAction(bk->gui,ACTION_BACK, PaRBack);
GUIObject_Softkey_SetAction(bk->gui,ACTION_SELECT1,PaROnEnterPressed);
return((GUI_LIST*)bk->gui);
}
void CloseMyBook(BOOK* booka,void* X3)
{
//GUI_Free(booka->gui);
FreeBook(booka);
//myBook=0;
}
static void onMyBookClose(BOOK * book)
{
ModifyKeyHook(NewKey,0);
GUI_Free((GUI*)book->gui);
FreeBook(book);
delete myBook;
SUBPROC(elf_exit);
}
const PAGE_MSG bk_msglst_base[] @ "DYN_PAGE" =
{
ELF_TERMINATE_EVENT, TerminateElf,
ELF_SHOW_INFO_EVENT, ShowAuthorInfo,
ELF_RECONFIG_EVENT, ReconfigElf,
NIL_EVENT_TAG, NULL
};
const PAGE_DESC bk_base = {"MegaElf_Base_Page",0,bk_msglst_base};
void CreatePnRBook()
{
myBook=new MyBOOK;
memset(myBook,0,sizeof(MyBOOK));
if (!CreateBook(myBook,onMyBookClose,&bk_base,"MegaElf",-1,0))
{
delete myBook;
SUBPROC(elf_exit);
// return (0);
}
}
int NewKey(int key, int r1 , int mode)
{
if(key==KEY_SHOW)
{
if(mode==KEYMODE_SHOW)
{
BOOK * bk;
if (!(bk=FindBook(isPaR)))
{
CreatePnRBook();maingui
GUI*)PaRCreateGuiList(0,(BOOK*)myBook); ShowWindow(maingui);
return(-1);
}
else
{
CloseMyBook(bk,0);
return(0);
}
}
}
return(0);
}
void startproc()
{
/*
maingui
GUI*)PaRCreateGuiList(0,myBook->book);
ShowWindow(mazaGui);
*/
ModifyKeyHook(NewKey,1);
}
static int ReconfigElf(void *mess ,BOOK *book)
{
RECONFIG_EVENT_DATA *reconf
RECONFIG_EVENT_DATA *)mess;
int result=0;
if (wstrcmpi(reconf->path,successed_config_path)==0 && wstrcmpi(reconf->name,successed_config_name)==0)
{
//exitproc();
InitConfig();
//Timer_ReSet(&timer,REFRESH_TIME,onTimer,0);
//exitproc();
startproc();
result=1;
}
return(result);
}
//daemon
void Daemon_onClose(BOOK * book)
{
}
const PAGE_MSG Daemon_Base_PageEvents[] @ "DYN_PAGE" =
{
ELF_RECONFIG_EVENT,ReconfigElf,
NIL_EVENT_TAG,0
};
const PAGE_DESC Daemon_Base_Page = {"MegaDaemon_Base_Page",0,Daemon_Base_PageEvents};
int isBookmanDaemonBook(BOOK * book)
{
if(!strcmp(book->xbook->name,"MegaDaemon")) return(1);
return(0);
}
void DestroyDaemon(void)
{
BOOK * Daemon_Book;
if (Daemon_Book=FindBook(isBookmanDaemonBook)) FreeBook(Daemon_Book);
}
void CreateDaemon(void)
{
BOOK * Daemon_Book;
if (Daemon_Book=FindBook(isBookmanDaemonBook)) FreeBook(Daemon_Book);
Daemon_Book=new BOOK;
CreateBook(Daemon_Book,Daemon_onClose,&Daemon_Base_Page,"MegaDaemon",-1,0);
}
//end of daemon
int main()
{
CreatePnRBook();
//CreateDaemon();
myBook=0;
InitConfig();
startproc();
//MMIPROC((void (*)(void))onTimer);
return 0;
}
от UltraShot'а: поправил тэг "code", а то страницу листать неудобно. легче в блокнот скопировать и посмотреть