//----------------------------------------------------------------------------- void MadShiftaVerticalFillSlider::draw(DGGraphicsContext * inContext) { // draw background inContext->setFillColor(kControlBackgroundColor); inContext->fillRect( getBounds() ); // calculate coordinates of "on" portion inContext->setFillColor(kControlFillColor); SInt32 min = GetControl32BitMinimum(carbonControl); SInt32 max = GetControl32BitMaximum(carbonControl); SInt32 val = GetControl32BitValue(carbonControl); float valNorm = ((max-min) == 0) ? 0.0f : (float)(val-min) / (float)(max-min); DGRect onRect( getBounds() ); long onBottom; if (valNorm > axis) { onRect.y = (long) (getBounds()->h * valNorm); onBottom = (long) (getBounds()->h * axis); } else { onRect.y = (long) (getBounds()->h * axis); onBottom = (long) (getBounds()->h * valNorm); } onRect.y = getBounds()->h - onRect.y; onBottom = getBounds()->h - onBottom; onRect.h = onBottom - onRect.y; if (onRect.h < 1) { onRect.h = 1; inContext->setFillColor(kControlFillColor_alt); } onRect.y += getBounds()->y; // draw "on" portion inContext->fillRect(&onRect); // draw the text display if (textProc != NULL) { char text[kDGTextDisplay_stringSize]; text[0] = 0; textProc(getAUVP().GetValue(), text, NULL); DGRect textBounds( getBounds() ); textBounds.y += textY; textBounds.h = textHeight; inContext->setFont(kValueDisplayTextFont, kSliderTextSize); inContext->setColor(kValueDisplayTextColor); inContext->drawText(&textBounds, text, kDGTextAlign_center); } }
/* * This method checks to see if the mouse was clicked on any of the rectangles in the linked list. * @param mouseX: The x-coordinate of the mouse when it was clicked. * @param mouseY: The y-coordinate of the mouse when it was clicked. * @return: Returns the address of the node that was clicked on if there was one. If not, 0 is returned. */ Node* List::onThisRect(int mouseX, int mouseY) { Node* currentNode = (*sentinel).nextNode; while (currentNode != sentinel) { if (onRect(mouseX, mouseY, currentNode)) { return currentNode; } currentNode = (*currentNode).nextNode; } return 0; }