// SideBar.cpp: implementation of the CSideBar class. // ////////////////////////////////////////////////////////////////////// #include "SideBar.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CSideBar::CSideBar(int ix,int iy,int iwidth,int iheight,int iLayerWidth,int iLayerHeight,UINT uiBG):CPanel(ix,iy,iwidth,iheight,uiBG) { iLayerX=0; iLayerY=0; CSideBar::iLayerWidth=iLayerWidth; CSideBar::iLayerHeight=iLayerHeight; /*HANDLE hFile = CreateFile(TEXT("LessonMenu.txt"), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL); int iIndex=0; DWORD dwBytesRead; char chNext; int iMenus; char szMenuNumber[8]; for(int i=0;i<2;i++){ ReadFile(hFile,&chNext,1,&dwBytesRead,NULL); szMenuNumber[i]=chNext; } iMenus=atoi(szMenuNumber); while(true){ ReadFile(hFile,&chNext,1,&dwBytesRead,NULL); if(chNext==(char)179) break; if(chNext=='\n' || chNext=='\t' || chNext=='\r') continue; szTreeMenu[iIndex++]=chNext; } szTreeMenu[iIndex]='\0'; CloseHandle(hFile); /*strcpy(szTreeMenu, "Introduction:140:0:Intro:0:" "!Introduction:" "Alkane:90:4:Alkane:0:" "Preparation:140:0:Alkane:1:" "!Preparation:" "Reaction:140:3:Alkane:2:" "With Halogen:145:0:Alkane:3:" "!With Halogen:" "With Oxygen:145:0:Alkane:4:" "!With Oxygen:" "With Nitric acid:155:0:Alkane:5:" "!With Nitric acid:" "!Reaction:" "Exercises1:140:0:AlkaneExercise:0:" "!Exercises1:" "Exercises2:140:0:AlkaneExercise2:0:" "!Exercises2:" "!Alkane:" "Alkene:100:2:Alkene:0:" "Preparation:140:2:Alkene:1:" "Using Alcohol:145:0:Alkene:2:" "!Using Alcohol:" "Using Halides:145:0:Alkene:3:" "!Using Halides:" "!Preparation:" "Reaction:140:6:Alkene:4:" "With Hydrogen:145:0:Alkene:5:" "!With Hydrogen:" "With Halogen:145:0:Alkene:6:" "!With Halogen:" "With Halides:145:0:Alkene:7:" "!With Halides:" "Acidic Oxidization:155:0:Alkene:8:" "!Acidic Oxidization:" "Basic Oxidization:155:0:Alkene:9:" "!Basic Oxidization:" "Hydration:155:0:Alkene:10:" "!Hydration:" "!Reaction:" "!Alkene:" "Alkyne:145:0:Alkyne:0:" "!Alkyne:") ;*/ _pContent=new CContent(250,20,530,560,530,800,IDB_TREE_BG_LEFTTOP); //_pContent->ChangeTo("Alkene",0); pTreeMenu=new CTreeMenu(szTreeMenu,0,30,IDB_TREE_NORMAL1,10,50,32,_pContent); bmpBackGround=new Bitmap(GetDC(GameEngine::GetEngine()->GetWindow()),IDB_TREE_BG,GameEngine::GetEngine()->GetInstance()); } CSideBar::~CSideBar() { delete pTreeMenu; delete bmpBackGround; } void CSideBar::DrawScreen(HDC hDC){ if(!bShow) return; HDC _hLayerDC = CreateCompatibleDC(hDC); HBITMAP _hLayerBitmap = CreateCompatibleBitmap(hDC,iLayerWidth, iLayerHeight); SelectObject(_hLayerDC, _hLayerBitmap); //do painting for(int i=0;i<=iLayerWidth/90;i++){ for(int j=0;j<=iLayerHeight/90;j++){ bmpBackGround->Draw(_hLayerDC,i*90,j*90); } } pTreeMenu->DrawScreen(_hLayerDC); CPanel::DrawScreen(_hLayerDC); DeleteObject(_hLayerBitmap); DeleteDC(_hLayerDC); } void CSideBar::MouseButtonDown(int x,int y,BOOL bLeft){ _pContent->MouseButtonDown(x,y,bLeft); CPanel::MouseButtonDown(x,y,bLeft); if(WithinItem(x,y) && bShow) pTreeMenu->MouseButtonDown(x-GetX()+iLayerX,y-GetY()+iLayerY,bLeft); } void CSideBar::MouseButtonUp(int x,int y,BOOL bLeft){ _pContent->MouseButtonUp(x,y,bLeft); CPanel::MouseButtonUp(x,y,bLeft); if(bShow) pTreeMenu->MouseButtonUp(x-GetX()+iLayerX,y-GetY()+iLayerY,bLeft); } void CSideBar::MouseMove(int x,int y){ _pContent->MouseMove(x,y); CPanel::MouseMove(x,y); //if(WithinItem(x,y)&& bShow) if(bShow) pTreeMenu->MouseMove(x-GetX()+iLayerX,y-GetY()+iLayerY); } bool CSideBar::WithinItem(int x,int y){ if(x>GetX() && xGetY() && yRefresh(iMenus); //pTreeMenu=new CTreeMenu(szTreeMenu,iMenus,30,IDB_TREE_NORMAL1,10,50,32,_pContent); }