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.MEN
< prev
next >
Wrap
Text File
|
2002-09-24
|
6KB
|
193 lines
////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------//
//-----project DESINGER, copyright 2002 Libor Bareτ-------------------------//
//----------------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////////////
POINT m_POPUPMENU_PLACEMENT_SIZE;
int m_POPUPMENU_ROWS=0;
unsigned PopUpMenuHitTest(int x,int y);
string m_POPUPMENU_STRINGS[20];
int m_POPUPMENU_HEIGHTS[20];
int m_POPUPMENU_selitem=-1;
int m_POPUPMENU_IDS[20];
int m_POPUPMENU_IMAGES[20];
char m_POPUPMENU_ENABLE[20];
#define SetMenuCount(x) m_POPUPMENU_ROWS=x
void MENUITEM(unsigned nMenuItem,nID,string szText,hBitmap,char bEnable){
m_POPUPMENU_IDS[nMenuItem] = nID;
if(szText == "-")m_POPUPMENU_IDS[nMenuItem] = -1;
m_POPUPMENU_STRINGS[nMenuItem] = szText;
m_POPUPMENU_IMAGES[nMenuItem] = hBitmap;
m_POPUPMENU_ENABLE[nMenuItem] = bEnable;
}
void GetTextExtent(string szText,SIZE &returnsize, char FontType);
void SetPoint(POINT * pt, int x, int y){
pt->left = x;
pt->top = y;
}
void RecallPopUpMenuSize(){
int i,ac=0;
int nMaxWidth=0;
SIZE tmpW;
for(i = 0;i < m_POPUPMENU_ROWS;i++){
GetTextExtent(m_POPUPMENU_STRINGS[i],tmpW,FONT_TAHOMA_8);
if(nMaxWidth < tmpW.x)nMaxWidth=tmpW.x;
#ifdef _XP_THEME
if(m_POPUPMENU_STRINGS[i] == "-")ac+=4;
else ac+=22;
#else
if(m_POPUPMENU_STRINGS[i] == "-")ac+=8;
else ac+=19;
#endif
m_POPUPMENU_HEIGHTS[i] = ac;
}
if(nMaxWidth < 140)nMaxWidth = 100;
#ifdef _XP_THEME
SetPoint(&m_POPUPMENU_PLACEMENT_SIZE,nMaxWidth+64,ac+4);
#else
SetPoint(&m_POPUPMENU_PLACEMENT_SIZE,nMaxWidth+54,ac+5);
#endif
}
void StopTrackingPopUpMenu(){
RecallPopUpMenuSize();
RECT rect;CopyRect(&rect,GetWindowRect(3 /* IDC_POPUPMENU */));
STYLEMINUS(GetWindow(3 /* IDC_POPUPMENU */)->dwStyle,0x00020000L/*WS_VISIBLE*/);
m_PopUpMenuFilter = 0;
int x =m_POPUPMENU_TOMENU;
m_POPUPMENU_TOMENU =0;
m_POPUPMENU_selitem=-1;
if(x){
SendMessage(1 /* IDC_MENU */,8/*WM_PAINT */ ,IDC_MENU_OVER,0);
}
ReleaseCapture();
int mx=rect.right-rect.left,my=rect.bottom-rect.top;
if(m_ObjectWithFocus != 2){
GrKresliP²edm╪ty(16001,1,rect.left,rect.top,mx/39+1,my/29+1);
}
else {
Diagram__ScreenToClient2(rect);
Diagram__OnDrawClipRect(rect.left,rect.top,rect.right,rect.bottom);
}
}
void TrackPopUpMenu(int x, int y){
if(m_POPUPMENU_ROWS == 0)return;
RecallPopUpMenuSize();
int mx = m_POPUPMENU_PLACEMENT_SIZE.left;
int my = m_POPUPMENU_PLACEMENT_SIZE.top;
GetWindow(3 /* IDC_POPUPMENU */)->dwStyle|=0x00020000L/*WS_VISIBLE*/;
SetCapture(3 /* IDC_POPUPMENU */);
m_PopUpMenuFilter = 1;
if(mx+x > GrMaxX())x=GrMaxX()-mx;
if(my+y > GrMaxY() && y-my > 33)y-=my;
if(m_ObjectWithFocus != 2){
if(my > 290){GrNastavObrazP²edm╪tà(17001,x,y+290,mx/39+1,(my-290)/29+1,1);}
GrNastavObrazP²edm╪tà(16001,x,y,mx/39+1,((((my)/29+1)>=10)?10:((my)/29+1)),1);
}
SetWindowRect2(3 /* IDC_POPUPMENU */,x,y,x+mx,y+my);
Invalidate(3 /* IDC_POPUPMENU */);
m_POPUPMENU_selitem=-1;
while(MouseEvent.TlaĒtka & 2){
AnimMouse();
}
}
unsigned PopUpMenuHitTest(int x,int y){
int e;
RECT rc,*r=GetWindowRect(3 /* IDC_POPUPMENU */);
CopyRect(&rc,r);
InflateRect(&rc,-4,-3,-4,0);
rc.bottom=rc.top;
for(e=0;e < m_POPUPMENU_ROWS; e++){
rc.bottom = r->top+3+ m_POPUPMENU_HEIGHTS[e]-1;
if(PtInRect(x,y,&rc))return e;
rc.top = r->top+3+ m_POPUPMENU_HEIGHTS[e];
}
return -1;
}
void LoadMenu(int nStartPos,int nSize){
// We must put code for all menu thread (not only for this function to binary file)
// similar as in all function ...
int nPos;
MENU* pMenu;
m_POPUPMENU_ROWS=nSize;
for(nPos=0;nPos < nSize;nPos++){
pMenu = &m_MenuArray[nPos+nStartPos];
MENUITEM(nPos,pMenu->nID,pMenu->strItem,pMenu->hBitmap,1);
}
}
void SetMainMenu(unsigned idThread){
long bCellFocus = m_nInterCellFocus > -1;
long nType = 0;
if(bCellFocus)nType = Diagram__GetFocusCell()->nType;
switch(idThread){
case 0 /*IDM_FILE*/:
LoadMenu(0,9);
break;
case 1 /*IDM_EDIT*/:
LoadMenu(9,5);
m_POPUPMENU_ENABLE[0]=bCellFocus && nType != 4;
m_POPUPMENU_ENABLE[1]=bCellFocus && nType != 4;
m_POPUPMENU_ENABLE[2]=m_MEMORY_CELL.nType != 0; // null memory
m_POPUPMENU_ENABLE[3]=bCellFocus;
m_POPUPMENU_ENABLE[4]=m_nm_DiagramCellsSize > 0;
break;
case 4/*IDM_HELP*/:
LoadMenu(14,4);
if(NoXP && UnderXP){
m_POPUPMENU_ENABLE[0] = 0;m_POPUPMENU_ENABLE[1] = 0;
}
break;
case 2/*IDM_INSERT*/ :
LoadMenu(18,5);
m_POPUPMENU_ENABLE[1]=(bCellFocus)&&(m_nm_DiagramCellsSize > 0)&&nType != 4;
m_POPUPMENU_ENABLE[3]=bCellFocus&&nType < 3;
m_POPUPMENU_ENABLE[4]=bCellFocus&&nType < 3;
break;
case 3/*IDM_VIEW*/:
if( _UNDER_WINDOWS_2k){
LoadMenu(34,1);
m_POPUPMENU_IMAGES[0] = 147;
}
else
LoadMenu(23,3);
m_POPUPMENU_IMAGES[GrMód()-3] = 147/*IDB_CHECKED*/;
break;
default: // ERROR !!!! Nothing to set
return;
}
}
// KONEC SOUBORU
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////