void _HYSequencePane::SetHeaders (_List* newH, bool update) { if (newH) { rowHeaders.Clear(); rowHeaders.Duplicate (newH); speciesIndex.Clear(); } headerWidth = 0; shortHeaderWidth = 0; StartDraw(); for (long k=0; k<rowHeaders.lLength; k++) { _String * thisString = (_String*)rowHeaders(k); #ifdef __MAC__ long lW = GetVisibleStringWidth(*thisString); #else long lW = GetVisibleStringWidth(*thisString, font); #endif if (lW>headerWidth) headerWidth = lW; if (thisString->sLength<=HY_SEQUENCE_PANE_SHORT_WIDTH) { if (lW>shortHeaderWidth) shortHeaderWidth = lW; } else { _String chopped (*thisString); chopped.Trim(0,HY_SEQUENCE_PANE_SHORT_WIDTH-1); #ifdef __MAC__ long sW = GetVisibleStringWidth (chopped); #else long sW = GetVisibleStringWidth (chopped, font); #endif if (sW>shortHeaderWidth) shortHeaderWidth = sW; } if (newH) speciesIndex << k; } headerWidth += HY_SEQUENCE_PANE_CHAR_SPACING; shortHeaderWidth += HY_SEQUENCE_PANE_CHAR_SPACING; EndDraw(); fullHeaderWidth = headerWidth; if (update) BuildPane(); }
void ProxyAction::handleKeyChange(const QKeySequence &old) { QString oldTooltip(QString("<span style=\"color: gray; font-size: small\">%1</span>").arg(old.toString(QKeySequence::NativeText))); QList<QPointer<QAction> > actions(m_contextActions.values()); QAction *backendAction = 0; for (int n = 0; n < actions.count(); n++) { backendAction = actions.at(n); if (backendAction) { if (backendAction->toolTip().endsWith(oldTooltip)) { QString chopped(backendAction->toolTip()); chopped.chop(oldTooltip.length()); backendAction->setToolTip(chopped); } } } if (m_currentKey.isEmpty() && !m_defaultKey.isEmpty()) { m_currentKey = m_defaultKey; } m_action->setShortcut(m_currentKey); QString newTooltip(QString("<span style=\"color: gray; font-size: small\">%1</span>").arg(key().toString(QKeySequence::NativeText).toHtmlEscaped())); QString activeTooltip(m_activeAction ? m_activeAction->toolTip() : m_backup->toolTip()); if (m_action->shortcut().isEmpty()) { m_action->setToolTip(activeTooltip); } else { m_action->setToolTip(activeTooltip.trimmed() + " " + newTooltip); for (int n = 0; n < actions.count(); n++) { backendAction = actions.at(n); if (backendAction) { backendAction->setToolTip(backendAction->toolTip().trimmed() + " " + newTooltip); } } } }
//__________________________________________________________________ void _HYSequencePane::BuildHeaders (void) { long h,v,slotHeight = GetSlotHeight(),k; long visWidth = _HYCanvas::GetMaxW()-headerWidth-5, visHeight = _HYCanvas::GetMaxH()-5, selectionIndex = 0; if (settings.width&HY_COMPONENT_V_SCROLL) visWidth-=HY_SCROLLER_WIDTH; if (settings.width&HY_COMPONENT_H_SCROLL) visHeight-=HY_SCROLLER_WIDTH; if (headerWidth) { _HYRect r = {0,0,0,0,1}; _HYColor blackC = {0,0,0}, selectColor = highlightColor; SetColor(headerColor); r.right = headerWidth; if (numbers) { r.bottom = (GetSlotHeight()+1)-1; FillRect(r); r.top = r.bottom+2; } else r.top = 0; r.bottom = visHeight; FillRect(r); if (numbers) v = slotHeight+(GetSlotHeight()+1); else v = slotHeight; if (vselection.lLength) { SetColor (selectColor); for (h=startRow; h<endRow; h++) { if (selectionIndex<vselection.lLength) { k = vselection.lData[selectionIndex]; while ((k<h)&&(selectionIndex<vselection.lLength)) { selectionIndex++; k = vselection.lData[selectionIndex]; } if (h==k) { _HYRect invR; invR.left = 0; invR.right = headerWidth; invR.top = (h-startRow)*slotHeight+(GetSlotHeight()+1)+2; invR.bottom = invR.top+slotHeight; FillRect (invR); selectionIndex++; } } else break; } } SetColor (blackC); for (h=startRow; h<endRow; h++) if (nameDisplayFlags&HY_SEQUENCE_PANE_NAMES_SHORT) { for (h=startRow; h<endRow; h++,v+=slotHeight) { _String *thisString = (_String*)rowHeaders(speciesIndex.lData[h]); if (thisString->sLength<=HY_SEQUENCE_PANE_SHORT_WIDTH) DisplayText (*thisString,v,HY_SEQUENCE_PANE_CHAR_SPACING/2,true); else { _String chopped (*thisString); chopped.Trim(0,HY_SEQUENCE_PANE_SHORT_WIDTH-1); chopped.sData[HY_SEQUENCE_PANE_SHORT_WIDTH-1]='-'; DisplayText (chopped,v,HY_SEQUENCE_PANE_CHAR_SPACING/2,true); } } } else for (h=startRow; h<endRow; h++,v+=slotHeight) { DisplayText (*(_String*)rowHeaders(speciesIndex.lData[h]),v,HY_SEQUENCE_PANE_CHAR_SPACING/2,true); } } }