void Abrowser::set(AfileList *files) { lastItem=null; th_running=false; while(!th_stopped) sleep(1); stop(); while(panel->fchild) delete(panel->fchild); panel->pos.y=0; panel->size(panel->pos.w, pos.h); adjustScroll(); repaint(); { int n=0; while(files) { AbrowserItem *bi=new AbrowserItem(files->name, panel, 0, 0, 40, 30, files->filename); bi->setTooltips(files->name); files=files->next; n++; } panel->sort(sortINC); { AbrowserItem *bi=(AbrowserItem *)panel->fchild; n=0; while(bi) { int x=(n%5)*44+4; int y=(n/5)*34+4; bi->pos.x=x; bi->pos.y=y; bi->show(true); bi=(AbrowserItem *)bi->next; n++; } } panel->size(panel->pos.w, maxi(pos.h, (((n-1)/5)+1)*34+4)); adjustScroll(); } repaint(); start(); }
bool Abrowser::size(int w, int h) { if(Aobject::size(w, h)) { panel->size(panel->pos.w, maxi(panel->pos.h, pos.h)); { int y=panel->pos.y; y=maxi(y, pos.h-panel->pos.h); y=mini(y, 0); panel->pos.y=y; } scroll->size(scroll->pos.w, pos.h); adjustScroll(); return true; } return false; }
bool Abrowser::mouse(int x, int y, int state, int event) { switch(event) { case mouseWHEEL: { float dy=(float)getWindow()->mouseW/8.f; int y=panel->pos.y+(int)dy; y=maxi(y, pos.h-panel->pos.h); y=mini(y, 0); panel->pos.y=y; adjustScroll(); repaint(); } return true; } return false; }
INT_PTR CALLBACK NavDialog::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) { switch (Message) { case WM_INITDIALOG: break; case WM_PAINT: onPaint(); break; case WM_LBUTTONDOWN: ::SetCapture(_hSelf); setPos(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break; case WM_LBUTTONUP: ::ReleaseCapture(); break; case WM_MOUSEMOVE: if (::GetCapture() == _hSelf) setPos(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); else if (!m_mouseOver) m_mouseOver = true; break; case WM_MOUSELEAVE: if (m_mouseOver) m_mouseOver = false; break; case WM_MOUSEWHEEL: if (m_mouseOver) onMouseWheel(GET_WHEEL_DELTA_WPARAM(wParam) / 120); break; case WM_VSCROLL: { switch (LOWORD(wParam)) { case SB_THUMBPOSITION: case SB_THUMBTRACK: { const int currentScroll = HIWORD(wParam); ::SetFocus(_hSelf); ::SetScrollPos(m_hScroll, SB_CTL, currentScroll, TRUE); ::InvalidateRect(_hSelf, NULL, FALSE); } break; case SB_PAGEDOWN: adjustScroll(m_navHeight); break; case SB_PAGEUP: adjustScroll(-m_navHeight); break; case SB_LINEDOWN: adjustScroll(1); break; case SB_LINEUP: adjustScroll(-1); break; } } break; case WM_SIZE: case WM_MOVE: if (isVisible()) SetScalingFactor(); break; case WM_NOTIFY: { LPNMHDR pnmh = (LPNMHDR)lParam; if (pnmh->hwndFrom == _hParent && LOWORD(pnmh->code) == DMN_CLOSE) { ViewNavigationBar(); } else if ((pnmh->hwndFrom == _hParent && LOWORD(pnmh->code) == DMN_FLOAT) || (pnmh->hwndFrom == _hParent && LOWORD(pnmh->code) == DMN_DOCK)) { SetScalingFactor(); ::SetFocus(m_syncView->m_hView); } } break; default: return DockingDlgInterface::run_dlgProc(Message, wParam, lParam); } return FALSE; }