void TabMenuControl::SetCurrentPage(TabMenuControl::MenuTabIndex menuIndex) { assert(!menuIndex.IsNone()); SetCurrentPage(GetPageNum(menuIndex)); }
bool TabMenuDisplay::OnMouseUp(PixelScalar x, PixelScalar y) { RasterPoint Pos; Pos.x = x; Pos.y = y; if (dragging) { DragEnd(); const MenuTabIndex di = IsPointOverButton(Pos, GetPageMainIndex(cursor)); if (di == down_index) { // sub menu click if (di.IsSub()) pager.ClickPage(PAGE_OFFSET + GetPageNum(di)); // main menu click else if (di.IsMain()) { /* move cursor to first item in this menu */ cursor = main_menu_buttons[di.main_index].first_page_index; Invalidate(); } else { InvalidateButton(down_index); } } down_index = MenuTabIndex::None(); return true; } else { return PaintWindow::OnMouseUp(x, y); } }
void TabMenuControl::HighlightPreviousMenuItem() { const unsigned page = GetPageNum(GetTabMenuDisplay()->GetSelectedIndex()); if (page > 0) { SetLastContentPage(page - 1); } }
/** \brief Returns the whole size ("scrollable") of the music score, in pixels. It can be much bigger than the current visible portion of the score in the control. */ void GuidoCarbonControl::GetFullScoreSize( float * outWidth, float * outHeight ) const { GuidoPageFormat format = { 100, 100, 10, 10, 10, 10 }; GuidoGetPageFormat( GetGuidoGR(), GetPageNum(), &format ); *outWidth = format.width * GetZoom() * 0.1f; *outHeight = format.height * GetZoom() * 0.1f; }
inline const PixelRect & TabMenuDisplay::GetButtonPosition(MenuTabIndex i) const { assert(!i.IsNone()); return i.IsMain() ? GetMainMenuButtonSize(i.main_index) : GetSubMenuButtonSize(GetPageNum(i)); }
void TabMenuControl::HighlightNextMenuItem() { const unsigned page = GetPageNum(GetTabMenuDisplay()->GetSelectedIndex()); if (page + 1 < GetNumPages()) // don't wrap SetLastContentPage(page + 1); else if (page >= GetNumPages()) // initial state is menu (page == NunPages) SetLastContentPage(0); }
int DviDoc::FindPage (/*[in]*/ int pageNum) const { for (int pageIdx = 0; pageIdx < GetPageCount(); ++ pageIdx) { if (GetPageNum(pageIdx) == pageNum) { return (pageIdx); } } return (-1); }
// ---------------------------------------------------------------------------- // * DoDraw // ---------------------------------------------------------------------------- void GuidoCarbonControl::DoDraw() { const GRHandler guidoRef = GetGuidoGR(); if( guidoRef == 0 ) return; ControlRef theControl = GetControlRef(); if( theControl == 0 ) return; // - Get our local size int localWidth; int localHeight; GetSize( &localWidth, &localHeight ); CGRect deviceRect = ::CGRectMake( 0, 0, localWidth, localHeight ); // VGDevice * device = GetGDevice(); // <- was const int kScrollBarHeight = 15; // - Create the graphic context. It must be initialized with the actual size of the window, // otherwise the y-origin is not calculated properly. WindowRef winRef = ::GetControlOwner( theControl ); GrafPtr port = ::GetWindowPort( winRef ); CGContextRef contextRef = 0; OSStatus status = ::CreateCGContextForPort( port, &contextRef ); if( status != noErr ) return; GSystemOSX system(contextRef, NULL); VGDevice* device = system.CreateDisplayDevice(); device->NotifySize(localWidth, localHeight + kScrollBarHeight ); ::CGContextRelease(contextRef); // because the device now owns the context. // - Draw the background device->BeginDraw(); device->PushPen( VGColor( 0, 0, 0, ALPHA_OPAQUE ), 1 ); device->PushFillColor( VGColor( 255, 255, 255, ALPHA_TRANSPARENT )); device->Rectangle( 0, 0, localWidth, localHeight ); device->PopFillColor(); device->PopPen(); // - Setup the clipping rectangle, to avoid drawing on scrollbars. ::CGContextClipToRect( contextRef, deviceRect ); // - Draw the music score int virtualScrollX = (int)((float)mScrollX * 10 / GetZoom()); int virtualScrollY = (int)((float)mScrollY * 10 / GetZoom()); float virtualVisibleWidth = localWidth * 10 / GetZoom(); float virtualVisibleHeight = localHeight * 10 / GetZoom(); float fullScoreWidth; float fullScoreHeight; GetFullScoreSize( &fullScoreWidth, &fullScoreHeight ); GuidoOnDrawDesc desc; desc.handle = guidoRef; desc.hdc = device; desc.updateRegion.erase = false; desc.updateRegion.left = virtualScrollX; // absolute virtual coordinates clip rect desc.updateRegion.top = virtualScrollY; desc.updateRegion.right = (int)(virtualScrollX + virtualVisibleWidth); desc.updateRegion.bottom = (int)(virtualScrollY + virtualVisibleHeight); desc.scrollx = (int)virtualScrollX; desc.scrolly = (int)virtualScrollY; desc.page = GetPageNum(); desc.sizex = (int)fullScoreWidth; desc.sizey = (int)fullScoreHeight; MClock clock; GuidoOnDraw( &desc ); // debug #if 0 std::cout << "Score : sizex = " << desc.sizex << " ; sizey = " << desc.sizey << std::endl; std::cout << "Guido: time do draw the score: " << clock.Milliseconds() << " ms" << std::endl; // std::cout << "Guido: graphical objects: " << GuidoGRObjectCount() << std::endl; #endif if( GetParam( kDrawSymbolMap ) == 1 ) DrawSymbolMap(); // drawMap (guidoRef, device, GetPageNum()); device->EndDraw(); delete device; }