home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2002 December
/
PCWorld_2002-12_cd.bin
/
Software
/
Komercni
/
Baltik
/
katB.exe
/
katB
/
DESIGN
/
DESIGN_C.UI
< prev
next >
Wrap
Text File
|
2002-09-24
|
16KB
|
473 lines
////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------//
//-----project DESINGER, copyright 2002 Libor Bareτ-------------------------//
//----------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////////
// DEBUG!
// hlavni promene pro funkci celeho systemu oken :
int m_modalshow=0;
unsigned m_ObjectWithFocus=0 /* DESKTOP */;
DIAGRAMCELL m_MEMORY_CELL;
unsigned m_pWndLastOver=-1;
unsigned m_hWndCapturedObject = -1;
char m_PopUpMenuFilter = 0;
char m_bMouseMenuFirstTime = 0;
char m_POPUPMENU_TOMENU = 0;
char m_POPUPMENU_FROMMENU = 0;
char m_DIAGRAM_DOCKING_DEPENDENT = 0;
RECT m_LAST_POINTS;
int m_ProtectedTimer[1/*IDTSIZE_TIMER*/];
long m_ProtectedTimerTime[1/*IDTSIZE_TIMER*/];
long m_ProtectedTimerCount[1/*IDTSIZE_TIMER*/];
char m_DIAGRAM_ADDINGDEPENDENT;
POINT m_DIAGRAM_DEPENDENT_FROM;
char m_DIAGRAM_ADDINGDEPENDENT_USEMOVING=0;
void CopyRect(RECT* lprcDst,/* const */ RECT* lprcSrc){
memcpy(lprcDst,lprcSrc,sizeof(RECT));
}
void LoadFont(string File,void& pArray){
long src=SouborOtev²i(File,0x01|0x200/*SouborP²ístupBinární*/);
Soubor¼tiBlok(src,&pArray,sizeof(char)*255);SouborZav²i(src);if(DOSChyba())m_LastedMessage=1;
}
//# define ShowMouse() ShowMouse()
//# define HideMouse() HideMouse()
void HideMouse(){
AnimP²edm╪tSchovej(MouseObject);
}
//void ShowCursor(char bShow){
// if(bShow == 0)
// AnimP²edm╪tSchovej(MouseObject);
// else
// AnimP²edm╪tAnimuj(MouseObject,MouseEvent.X-10/*-MOUSEOFFSET.left*/,MouseEvent.Y/*-MOUSEOFFSET.top*/-10,-1);
//
//}
void SetZOrderControl(int nID){
// move array ...
if(m_ZOrderControlSize != 0 && m_ControlzOrderArray[0] == nID )return; // this control is jet topmost !
if(m_ZOrderControlSize != 0 ){
// is nID control in array ?
int i;
int movefrom = -1;
for(i=0;i<m_ZOrderControlSize;i++){
if(m_ControlzOrderArray[i] == nID){ // yes, it is
movefrom =i;break;
}
}
if(movefrom == -1)movefrom = m_ZOrderControlSize;
memcpy(&m_ControlzOrderArray[1],&m_ControlzOrderArray[0],sizeof(char)*movefrom);
}
m_ControlzOrderArray[0]=nID;
}
void MyWndProc(unsigned hWnd,unsigned nMessage, long lParam, long wParam);
void Diagram__WndProc( unsigned nMessage, long lParam, long wParam );
void SendMessage(unsigned dest, unsigned nMessage,long lParam, long wParam){
// UPOZORNENI : Tato fuknce ma cetnost volani cca 1000x / 10 s !!!
if(dest == 2 /* IDC_DIAGRAM */){Diagram__WndProc(nMessage,lParam,wParam);return;}
MyWndProc(dest,nMessage,lParam,wParam);
}
void STYLEMINUS(long &nStyle,long style){
if(nStyle & style)
nStyle^=style;
}
void Invalidate(unsigned nID){
WND* pWnd = GetWindow(nID);
if(pWnd->dwStyle & 0x00020000L/*WS_VISIBLE*/){ // send 8/*WM_PAINT*/ only if control is visible in else case will be BUG !
SendMessage(nID,8/*WM_PAINT*/ ,-1,-1);
if(pWnd->nChildSize > 0){
int i=0;
for(;i < pWnd->nChildSize; i++)
Invalidate(pWnd->pChild[i]->hWnd);
}
}
}
unsigned SetFocus(unsigned hWndToSetFocus){
if(hWndToSetFocus==m_ObjectWithFocus)return m_ObjectWithFocus;
if(hWndToSetFocus == 3/*IDC_POPUPMENU*/)return 3/*IDC_POPUPMENU*/;
int tmp=m_ObjectWithFocus;
if(m_ObjectWithFocus != -1 && m_ObjectWithFocus != hWndToSetFocus){
STYLEMINUS(GetWindow(m_ObjectWithFocus)->dwStyle,0x00400000L);
if(GetWindow(tmp)->nType == 4/*DFC_BUTTON*/){
Invalidate(tmp);
}
SendMessage(m_ObjectWithFocus,12/*WM_KILLFOCUS*/,hWndToSetFocus,-1);
}
if(m_ObjectWithFocus != hWndToSetFocus){
GetWindow(hWndToSetFocus)->dwStyle|= 0x00400000L;
SendMessage(hWndToSetFocus,11/*WM_SETFOCUS*/,tmp,-1);
}
m_ObjectWithFocus = hWndToSetFocus;
return tmp;
}
RECT* GetWindowRect(unsigned nID){
return &m_ControlArray[nID].Rect;
}
int GetWindowWidth(unsigned hWnd){
return (GetWindowRect(hWnd)->right - GetWindowRect(hWnd)->left);
}
int GetWindowHeight(unsigned hWnd){
return (GetWindowRect(hWnd)->bottom - GetWindowRect(hWnd)->top);
}
void MoveRect(RECT* rect,int x,int y, int x2, int y2){
// InflateRect(rect,-x,-y,x2,y2);
rect->left+=x;
rect->top+=y;
rect->right+=x2;
rect->bottom+=y2;
}
void SetParent(unsigned nParent, unsigned nControl){
WND * pWnd=GetWindow(nParent),*pControl=GetWindow(nControl);
pWnd->pChild = AddChildWindow(pWnd->pChild,pWnd->nChildSize,pWnd->nChildSize+1);
pWnd->pChild[pWnd->nChildSize-1] = pControl;
pControl->pParent = pWnd;
MoveRect(&pControl->Rect,4,23,4,23);
}
char PtInRect(int x, int y, RECT* rect){
if(rect->left <= x && rect->top <= y && rect->right >= x && rect->bottom >= y){
return 1;
}
return 0;
}
void ShowMouse(){
AnimP²edm╪tAnimuj(MouseObject,MouseEvent.X-10/*-MOUSEOFFSET.left*/,MouseEvent.Y-10/*-MOUSEOFFSET.top*/,-1);
}
void AnimMouse(){
Myτ¼tiUdálost(MouseEvent);
if(UnderXP && NoXP){ // mouse error cathing ....
MouseEvent.X=(GrMaxX()/639.)*MouseEvent.X;
MouseEvent.Y=(GrMaxY()/199.)*MouseEvent.Y;
}
ShowMouse();
}
WND* GetWindow(unsigned nID){
return &m_ControlArray[nID];
}
void _CheckNewOverControl(){
if(m_pWndLastOver != -1){
STYLEMINUS(GetWindow(m_pWndLastOver)->dwStyle,0x00100000L/*WS_MOUSEOVER*/);
SendMessage(m_pWndLastOver,4/*WM_MOUSELEAVE*/,MouseEvent.X,MouseEvent.Y);
m_pWndLastOver = -1;
}
}
// KERNEL !!!!!!!!!!!!!
// vnitrni API programu pro poslani zpravy programu ...
void _SendMouseEventFor(unsigned i){
int MSG=0;
if(MouseEvent.Typ == 4/*MyτUdálostLevéTlNahoru*/){
MSG=7;
}
else if(MouseEvent.Typ == 2/*MyτUdálostLevéTlDolà*/){
MSG=1;
}
else if(MouseEvent.Typ == 8/*MyτUdálostPravéTlDolà*/){
MSG=2;
}
else if(MouseEvent.Typ == 16/*MyτUdálostPravéTlNahoru*/){
MSG=6;
}
else if (MouseEvent.Typ ==1/*MyτUdálostPohyb*/){
MSG=3;
}
if(MSG != 0 && MSG != 3)
SetFocus(i);
if(MSG !=0)
SendMessage(i,MSG,MouseEvent.X,MouseEvent.Y);
return;
}
void StopTrackingPopUpMenu();
void KERNEL(){
m_keyIDKey = ¼tiKlávesuZFronty();
if(m_keyIDKey & 0x3b00){SendMessage(0 /* DESKTOP */,9/* WM_COMMAND*/,205/*IDC_HELP_CONTENT*/,-1);}
// timers ...
int tim;
for(tim = 0; tim < 1/*IDTSIZE_TIMER*/; tim++){
if(m_ProtectedTimer[tim] > 0){
if(m_ProtectedTimerTime[tim] < Systémov∞Tikot() ){
m_ProtectedTimerTime[tim] = Systémov∞Tikot()+m_ProtectedTimer[tim];
m_ProtectedTimerCount[tim]++;
SendMessage(0 /* DESKTOP */,13/* WM_TIMER */,tim,m_ProtectedTimerCount[tim]);
}
}
}
#ifdef _DEBUG
#ifdef _MEMORY_PREVIEW
GrNastavPozici(0,GrMaxY()-10);
GrNastavBarvuPozadí(5);
GrNastavBarvuPop²edí(6);
GrPiτⁿet╪zec("MEMORY_FREE="+StrD¼íslo(HromadaVolnáPam╪£(),-1,0));
#endif
#ifdef _MOUSE_DEBUG
GrNastavPozici(GrMaxX()-200,GrMaxY()-10);
GrNastavBarvuPozadí(5);
GrNastavBarvuPop²edí(6);
GrPiτⁿet╪zec("MousePosition("+StrD¼íslo(MouseEvent.X,-1,0)+","+StrD¼íslo(MouseEvent.Y,-1,0)+");");
#endif
#endif
AnimMouse();
if(MouseEvent.X == 0 && MouseEvent.Y == 0 && MouseEvent.TlaĒtka == 1){
HideMouse();
GrUloºBMP(0,0,-1,-1,"*\\designer.dir\\common\\prev.bmp");
ShowMouse();
}
if(m_hWndCapturedObject == -1){
// pomoci [void] SetCapture se muze upravit smycka posilani zprav tak,
// ze veskere zpravy poputuji oknu, ktery tuto udalost nastavil.
STARTPROCES :
int i,OA;
for(i=0;i<m_nm_ControlArraySize;i++){
OA = m_ControlzOrderArray[i];
if(!(GetWindow(OA)->dwStyle & 0x00080000L/* WS_DISABLE*/) && GetWindow(OA)->dwStyle & 0x00020000L/* WS_VISIBLE */ && PtInRect(MouseEvent.X,MouseEvent.Y,GetWindowRect(OA))){
if(m_modalshow != 0 && GetWindow(OA)->pParent->hWnd == m_modalshow || m_modalshow == 0){
if(m_pWndLastOver != OA){
_CheckNewOverControl();
m_pWndLastOver = OA;
GetWindow(OA)->dwStyle |= 0x00100000L/*WS_MOUSEOVER*/;
SendMessage(OA,5/* WM_MOUSEENTER*/,MouseEvent.X,MouseEvent.Y);
}
_SendMouseEventFor(OA);
goto keyboards;
}
}
}
if(MouseEvent.TlaĒtka == 1 || MouseEvent.TlaĒtka == 2){
SetFocus(0);
}
_CheckNewOverControl();
}
else {
if(m_pWndLastOver != m_hWndCapturedObject){
_CheckNewOverControl();
m_pWndLastOver = m_hWndCapturedObject;
}
if(PtInRect(MouseEvent.X,MouseEvent.Y,GetWindowRect(m_hWndCapturedObject))){
if(!(GetWindow(m_hWndCapturedObject)->dwStyle & 0x00100000L/*WS_MOUSEOVER*/)){
GetWindow(m_pWndLastOver)->dwStyle |= 0x00100000L/*WS_MOUSEOVER*/;
SendMessage(m_hWndCapturedObject,5/* WM_MOUSEENTER*/,MouseEvent.X,MouseEvent.Y);
}
}
else {
if(GetWindow(m_hWndCapturedObject)->dwStyle & 0x00100000L/*WS_MOUSEOVER*/){
STYLEMINUS(GetWindow(m_pWndLastOver)->dwStyle,0x00100000L/*WS_MOUSEOVER*/);
SendMessage(m_hWndCapturedObject,4/*WM_MOUSELEAVE*/,MouseEvent.X,MouseEvent.Y);
}
if(m_hWndCapturedObject == 1 /* IDC_MENU */ || m_hWndCapturedObject == 3/*IDC_POPUPMENU*/){
int gg = 0;
if(m_PopUpMenuFilter == 1){
if(m_POPUPMENU_TOMENU==1 ){ gg=PtInRect(MouseEvent.X,MouseEvent.Y,GetWindowRect(1 /* IDC_MENU */));if(gg){
SendMessage(1 /* IDC_MENU */,3/* WM_MOUSEMOVE*/,MouseEvent.X,MouseEvent.Y);
}
}
}
if((m_bMouseMenuFirstTime == 0 && (MouseEvent.TlaĒtka & 1 || MouseEvent.TlaĒtka & 2) && !gg)){
StopTrackingPopUpMenu();
m_pWndLastOver = -1;
goto STARTPROCES;
}
}
}
_SendMouseEventFor(m_hWndCapturedObject);
}
keyboards:
if(m_keyIDKey != 0){
// note : KlUp and so on is contained in 0x??00 !!
if((char)m_keyIDKey != 0){ // only for some keys
char id = m_keyIDKey;
SgpAsciiToWinChar(id); // decode charset to oficial WindowsCharset
m_keyIDKey = id;
}
SendMessage(m_ObjectWithFocus,14 /* WM_CHAR*/,m_keyIDKey,-1);
}
}
void ShowWindow(unsigned hWnd,int nCmdShow){
if(nCmdShow ){ GetWindow(hWnd)->dwStyle |= 0x00020000L/* WS_VISIBLE */;
SendMessage(hWnd,16 /* WM_SHOWWINDOW */,1,-1);
}
else {
STYLEMINUS(GetWindow(hWnd)->dwStyle,0x00020000L/* WS_VISIBLE */);
SendMessage(hWnd,16 /* WM_SHOWWINDOW */,0,-1);
}
}
#define GetWindowText(x) m_ControlArray[x].szText
//string GetWindowText(unsigned nID){
// return m_ControlArray[nID].szText;
//
//}
// nastavuje ctverec pro okno
void SetRect(RECT* dest,int x, int y, int x2, int y2){
dest->left = x;
dest->top=y;
dest->right=x2;
dest->bottom=y2;
}
// nastavuje ctverec pro okno
void SetWindowRect2(unsigned nID,int x, int y, int x2, int y2){
SetRect(&m_ControlArray[nID].Rect,x,y,x2,y2);
}
void MoveWindow(unsigned hWnd, int x, int y){
WND* pWnd = GetWindow(hWnd);
WND* pChild;
RECT Rect;CopyRect(&Rect,&pWnd->Rect);
if(pWnd->nChildSize > 0){
int i=0;
for(;i < pWnd->nChildSize; i++){pChild=GetWindow(hWnd)->pChild[i];
MoveWindow(pChild->hWnd,pChild->Rect.left+(x-Rect.left),
pChild->Rect.top+(y-Rect.top)
);
}
}
SetWindowRect2(hWnd,x,y,x+Rect.right - Rect.left ,Rect.bottom-Rect.top+y);
}
void InflateRect(RECT* dest, int x,int y, int x2, int y2){
dest->left-=x;
dest->top-=y;
dest->right+=x2;
dest->bottom+=y2;
}
// nastavuje text okna
void SetWindowText(unsigned nID,string szText){
m_ControlArray[nID].szText = szText;
SendMessage(nID,17 /* WM_SETTEXT */,-1,-1);
}
void ResetControl(unsigned hParent){
int i=0;
WND* pChild;
for(;i < GetWindow(hParent)->nChildSize; i++){
pChild = GetWindow(hParent)->pChild[i];
if(pChild->nType != 13)STYLEMINUS(pChild->dwStyle,0x00080000L/*DFCS_PUSHED*/);
STYLEMINUS(pChild->dwStyle,0x0000200L/*DFCS_PUSHED*/);
if(pChild->nType == 7 /*EDIT*/)SetWindowText(pChild->hWnd,"");
}
}
void DestroyDialog(){
if(m_modalshow ==0 )return;
ShowWindow(m_modalshow,0);
m_modalshow =0;
}
void ShowDialog(unsigned hWnd){
if(m_modalshow > 0)DestroyDialog();
int x =(GrMaxX()-GetWindowWidth(hWnd))/2;
int y = (GrMaxY()-GetWindowHeight(hWnd))/2;
MoveWindow(hWnd,x,y);
m_modalshow = hWnd;
ShowWindow(hWnd,1);
}
// pripoji mysi udalosti k oknu
#define SetCapture(x) m_hWndCapturedObject = x;
// uvolnit mys
#define ReleaseCapture() m_hWndCapturedObject = -1
int MenuHitTest(unsigned nID){
switch(nID){
case 1 /* IDC_MENU */:
RECT rect,*rc=GetWindowRect(nID);
CopyRect(&rect,rc);
rect.right = rect.left;
int i;
for(i = 0; i < 5;i++){
rect.right=rc->left+IDC_MENU_RECT[i];
if(PtInRect(MouseEvent.X,MouseEvent.Y,&rect))
return i;
rect.left=rc->left+IDC_MENU_RECT[i];
}
return -1;
}
return -1;
}
void EnableWindow(unsigned hWnd, char bEnable){
WND* pWnd = GetWindow(hWnd);
long s = (pWnd->dwStyle & 0x00080000L/* WS_DISABLE*/);
if((!s && bEnable)||(s && !bEnable))return;
if(bEnable==1){
STYLEMINUS(pWnd->dwStyle,0x00080000L);
}
else{
pWnd->dwStyle|= 0x00080000L;
}
Invalidate(hWnd);
}
// KONEC SOUB
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////