void KCommonDecoration::maximizeChange() { if( m_button[MaxButton] ) { m_button[MaxButton]->setOn( maximizeMode()==MaximizeFull); m_button[MaxButton]->setTipText( (maximizeMode()!=MaximizeFull) ? i18n("Maximize") : i18n("Restore")); m_button[MaxButton]->reset(KCommonDecorationButton::StateChange); } updateWindowShape(); widget()->update(); }
QString KWM::getProperties(Window w){ QString result; QRect rect; int data[13]; int i = 0; int n = 0; data[n++]=desktop(w); rect = geometry(w); data[n++]=rect.x(); data[n++]=rect.y(); data[n++]=rect.width(); data[n++]=rect.height(); rect = geometryRestore(w); data[n++]=rect.x(); data[n++]=rect.y(); data[n++]=rect.width(); data[n++]=rect.height(); data[n++]=isIconified(w)?1:0; data[n++]=isMaximized(w)?maximizeMode(w):0; data[n++]=isSticky(w)?1:0; data[n++]=getDecoration(w); QString s; for (i=0;i<n;i++){ s.setNum(data[i]); result.append(s); if (i<n-1) result.append("+"); } return result; }
void KWMThemeClient::maximizeChange() { if (maxBtn) { bool m = maximizeMode() == MaximizeFull; maxBtn->setPixmap(m ? *minmaxPix : *maxPix); QToolTip::remove( maxBtn ); QToolTip::add( maxBtn, m ? i18n("Restore") : i18n("Maximize")); } }
bool NextClient::mustDrawHandle() const { bool drawSmallBorders = !options()->moveResizeMaximizedWindows(); if (drawSmallBorders && (maximizeMode() & MaximizeVertical)) { return false; } else { return isResizable(); } }
void Decoration::borders( int& left, int& right, int& top, int& bottom ) const { if( options()->preferredBorderSize( factory()) == BorderTiny ) { left = right = bottom = 1; top = 5; } else { left = right = options()->preferredBorderSize( factory()) * 5; top = options()->preferredBorderSize( factory()) * 10; bottom = options()->preferredBorderSize( factory()) * 2; } if( isShade()) bottom = 0; if( ( maximizeMode() & MaximizeHorizontal ) && !options()->moveResizeMaximizedWindows()) left = right = 0; if( ( maximizeMode() & MaximizeVertical ) && !options()->moveResizeMaximizedWindows()) bottom = 0; }
void NextClient::maximizeChange() { if (button[MAXIMIZE_IDX]) { bool m = maximizeMode() == MaximizeFull; //button[MAXIMIZE_IDX]->setBitmap(m ? minmax_bits : maximize_bits); QToolTip::remove(button[MAXIMIZE_IDX]); QToolTip::add(button[MAXIMIZE_IDX], m ? i18n("Restore") : i18n("Maximize")); } //spacer->changeSize(10, mustDrawHandle() ? handleSize : 1, // QSizePolicy::Expanding, QSizePolicy::Minimum); //mainLayout->activate(); }
int QuartzClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const { bool maximized = maximizeMode() == MaximizeFull && !options()->moveResizeMaximizedWindows(); switch(lm) { case LM_BorderLeft: case LM_BorderRight: case LM_BorderBottom: case LM_TitleEdgeLeft: case LM_TitleEdgeRight: { if(respectWindowState && maximized) { return 0; } else { return borderSize; } } case LM_TitleEdgeTop: return borderSize - 1; case LM_TitleEdgeBottom: return 1; case LM_TitleBorderLeft: case LM_TitleBorderRight: return 5; case LM_TitleHeight: return titleHeight; case LM_ButtonWidth: case LM_ButtonHeight: return titleHeight - 2; case LM_ButtonSpacing: return 1; case LM_ExplicitButtonSpacer: return 3; default: return KCommonDecoration::layoutMetric(lm, respectWindowState, btn); } }
void Manager::slotMaximizeClicked(ButtonState state) { #if KDE_IS_VERSION(3, 3, 0) maximize(state); #else switch (state) { case RightButton: maximize(maximizeMode() ^ MaximizeHorizontal); break; case MidButton: maximize(maximizeMode() ^ MaximizeVertical); break; case LeftButton: default: maximize(maximizeMode() == MaximizeFull ? MaximizeRestore : MaximizeFull); break; } #endif emit(maximizeChanged(maximizeMode() == MaximizeFull)); }
KDecorationDefines::Position AuroraeClient::mousePosition(const QPoint &point) const { // based on the code from deKorator int pos = PositionCenter; if (isShade()) { return Position(pos); } int borderLeft, borderTop, borderRight, borderBottom; borders(borderLeft, borderRight, borderTop, borderBottom); int paddingLeft, paddingTop, paddingRight, paddingBottom; padding(paddingLeft, paddingRight, paddingTop, paddingBottom); const bool maximized = maximizeMode() == MaximizeFull && !options()->moveResizeMaximizedWindows(); int titleEdgeLeft, titleEdgeRight, titleEdgeTop, titleEdgeBottom; AuroraeFactory::instance()->theme()->titleEdges(titleEdgeLeft, titleEdgeTop, titleEdgeRight, titleEdgeBottom, maximized); switch (AuroraeFactory::instance()->theme()->decorationPosition()) { case DecorationTop: borderTop = titleEdgeTop; break; case DecorationLeft: borderLeft = titleEdgeLeft; break; case DecorationRight: borderRight = titleEdgeRight; break; case DecorationBottom: borderBottom = titleEdgeBottom; break; default: break; // nothing } if (point.x() >= (m_view->width() - borderRight - paddingRight)) { pos |= PositionRight; } else if (point.x() <= borderLeft + paddingLeft) { pos |= PositionLeft; } if (point.y() >= m_view->height() - borderBottom - paddingBottom) { pos |= PositionBottom; } else if (point.y() <= borderTop + paddingTop ) { pos |= PositionTop; } return Position(pos); }
void AuroraeClient::borders(int &left, int &right, int &top, int &bottom) const { if (!m_item) { left = right = top = bottom = 0; return; } const bool maximized = maximizeMode() == MaximizeFull && !options()->moveResizeMaximizedWindows(); if (maximized) { left = m_item->property("borderLeftMaximized").toInt(); right = m_item->property("borderRightMaximized").toInt(); top = m_item->property("borderTopMaximized").toInt(); bottom = m_item->property("borderBottomMaximized").toInt(); } else { left = m_item->property("borderLeft").toInt(); right = m_item->property("borderRight").toInt(); top = m_item->property("borderTop").toInt(); bottom = m_item->property("borderBottom").toInt(); } }
void KWMThemeClient::slotMaximize() { maximize( maximizeMode() == MaximizeFull ? MaximizeRestore : MaximizeFull ); }
int PlastikClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const { bool maximized = maximizeMode() == MaximizeFull && !options()->moveResizeMaximizedWindows(); switch(lm) { case LM_BorderLeft: case LM_BorderRight: case LM_BorderBottom: { if(respectWindowState && maximized) { return 0; } else { return Handler()->borderSize(); } } case LM_TitleEdgeTop: { if(respectWindowState && maximized) { return 0; } else { return 4; } } case LM_TitleEdgeBottom: { // if (respectWindowState && maximized) { // return 1; // } else { return 2; // } } case LM_TitleEdgeLeft: case LM_TitleEdgeRight: { if(respectWindowState && maximized) { return 0; } else { return 6; } } case LM_TitleBorderLeft: case LM_TitleBorderRight: return 5; case LM_ButtonWidth: case LM_ButtonHeight: case LM_TitleHeight: { if(respectWindowState && isToolWindow()) { return Handler()->titleHeightTool(); } else { return Handler()->titleHeight(); } } case LM_ButtonSpacing: return 1; case LM_ButtonMarginTop: return 0; case LM_ExplicitButtonSpacer: return 3; default: return KCommonDecoration::layoutMetric(lm, respectWindowState, btn); } }
void Manager::maximizeChange() { emit(maximizeChanged(maximizeMode() == MaximizeFull)); }
int OxygenClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const { bool maximized = maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows(); int frameWidth = OxygenFactory::borderSize(); switch (lm) { case LM_BorderLeft: case LM_BorderRight: case LM_BorderBottom: { if (respectWindowState && maximized) { return 0; } else { // Even for thin borders (2px wide) we want to preserve // the rounded corners having a minimum height of 7px if (lm == LM_BorderBottom) { return qMax(frameWidth, 7); } else { return frameWidth; } } } case LM_TitleEdgeTop: { if (respectWindowState && maximized) { return 0; } else { return TFRAMESIZE; } } case LM_TitleEdgeBottom: { return 0; } case LM_TitleEdgeLeft: case LM_TitleEdgeRight: { if (respectWindowState && maximized) { return 0; } else { return 6; } } case LM_TitleBorderLeft: case LM_TitleBorderRight: return 5; case LM_ButtonWidth: case LM_ButtonHeight: case LM_TitleHeight: { if (respectWindowState && isToolWindow()) { return OXYGEN_BUTTONSIZE; } else { return OXYGEN_BUTTONSIZE; } } case LM_ButtonSpacing: return 1; case LM_ButtonMarginTop: return 0; default: return KCommonDecoration::layoutMetric(lm, respectWindowState, btn); } }
bool AuroraeClient::isMaximized() const { return maximizeMode()==KDecorationDefines::MaximizeFull && !options()->moveResizeMaximizedWindows(); }
void Manager::createTitle() { leftButtonList_.clear(); rightButtonList_.clear(); TQString buttons; if (options()->customButtonPositions()) buttons = options()->titleButtonsLeft() + "|" + options()->titleButtonsRight(); else buttons = "XSH|IA"; TQPtrList<Button> *buttonList = &leftButtonList_; for (unsigned int i = 0; i < buttons.length(); ++i) { Button * tb = NULL; switch (buttons[i].latin1()) { case 'S': // Sticky tb = new StickyButton(widget()); connect(this, TQT_SIGNAL(stickyChanged(bool)), tb, TQT_SLOT(setOn(bool))); connect(tb, TQT_SIGNAL(toggleSticky()), this, TQT_SLOT(slotToggleSticky())); emit(stickyChanged(isOnAllDesktops())); break; case 'H': // Help if (providesContextHelp()) { tb = new HelpButton(widget()); connect(tb, TQT_SIGNAL(help()), this, TQT_SLOT(showContextHelp())); } break; case 'I': // Minimize if (isMinimizable()) { tb = new IconifyButton(widget()); connect(tb, TQT_SIGNAL(iconify()), this, TQT_SLOT(minimize())); } break; case 'A': // Maximize if (isMaximizable()) { tb = new MaximiseButton(widget()); connect(tb, TQT_SIGNAL(maximizeClicked(ButtonState)), this, TQT_SLOT(slotMaximizeClicked(ButtonState))); connect(this, TQT_SIGNAL(maximizeChanged(bool)), tb, TQT_SLOT(setOn(bool))); emit(maximizeChanged(maximizeMode() == MaximizeFull)); } break; case 'F': // Above tb = new AboveButton(widget()); connect(tb, TQT_SIGNAL(above()), this, TQT_SLOT(slotAbove())); break; case 'B': // Lower tb = new LowerButton(widget()); connect(tb, TQT_SIGNAL(lower()), this, TQT_SLOT(slotLower())); break; case 'X': // Close if (isCloseable()) { tb = new CloseButton(widget()); connect(tb, TQT_SIGNAL(closeWindow()), this, TQT_SLOT(closeWindow())); } break; case '|': buttonList = &rightButtonList_; break; } if (tb != NULL) { connect(this, TQT_SIGNAL(activeChanged(bool)), tb, TQT_SLOT(setActive(bool))); buttonList->append(tb); } }
// Quartz Paint magic goes here. void QuartzClient::paintEvent(QPaintEvent *) { // Never paint if the pixmaps have not been created if(!quartz_initialized) return; const bool maxFull = (maximizeMode() == MaximizeFull) && !options()->moveResizeMaximizedWindows(); QColorGroup g; QPainter p(widget()); // Obtain widget bounds. QRect r(widget()->rect()); int x = r.x(); int y = r.y(); int x2 = r.width() - 1; int y2 = r.height() - 1; int w = r.width(); int h = r.height(); // Draw part of the frame that is the title color if(coloredFrame) g = options()->colorGroup(ColorTitleBar, isActive()); else g = options()->colorGroup(ColorFrame, isActive()); // Draw outer highlights and lowlights p.setPen(g.light().light(120)); p.drawLine(x, y, x2 - 1, y); p.drawLine(x, y + 1, x, y2 - 1); p.setPen(g.dark().light(120)); p.drawLine(x2, y, x2, y2); p.drawLine(x, y2, x2, y2); // Fill out the border edges QColor frameColor; if(coloredFrame) frameColor = g.background().light(130); else frameColor = g.background(); if(borderSize > 2) { p.fillRect(x + 1, y + 1, w - 2, borderSize - 2, frameColor); // top if(!maxFull) { p.fillRect(x + 1, y + h - (borderSize - 1), w - 2, borderSize - 2, frameColor); // bottom p.fillRect(x + 1, y + borderSize - 1, borderSize - 1, h - 2 * (borderSize - 1), frameColor); // left p.fillRect(x + w - (borderSize), y + borderSize - 1, borderSize - 1, h - 2 * (borderSize - 1), frameColor); // right } } // Draw a frame around the wrapped widget. p.setPen(g.background()); if(maxFull) { p.drawLine(x + 1, y + titleHeight + (borderSize - 1), w - 2, y + titleHeight + (borderSize - 1)); } else { p.drawRect(x + (borderSize - 1), y + titleHeight + (borderSize - 1), w - 2 * (borderSize - 1), h - titleHeight - 2 * (borderSize - 1)); } // Drawing this extra line removes non-drawn areas when shaded p.drawLine(x + borderSize, y2 - borderSize, x2 - borderSize, y2 - borderSize); // Highlight top corner p.setPen(g.light().light(160)); p.drawPoint(x, y); p.setPen(g.light().light(140)); p.drawPoint(x + 1, y); p.drawPoint(x, y + 1); // Draw the title bar. // =================== int r_x, r_y, r_x2, r_y2; widget()->rect().coords(&r_x, &r_y, &r_x2, &r_y2); const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft); const int titleEdgeTop = layoutMetric(LM_TitleEdgeTop); const int titleEdgeRight = layoutMetric(LM_TitleEdgeRight); const int titleEdgeBottom = layoutMetric(LM_TitleEdgeBottom); const int ttlHeight = layoutMetric(LM_TitleHeight); const int titleEdgeBottomBottom = r_y + titleEdgeTop + ttlHeight + titleEdgeBottom - 1; r = QRect(r_x + titleEdgeLeft + buttonsLeftWidth(), r_y + titleEdgeTop, r_x2 - titleEdgeRight - buttonsRightWidth() - (r_x + titleEdgeLeft + buttonsLeftWidth()), titleEdgeBottomBottom - (r_y + titleEdgeTop)); // Obtain titlebar blend colours QColor c1 = options()->color(ColorTitleBar, isActive()).light(130); QColor c2 = options()->color(ColorTitleBlend, isActive()); // Create a disposable pixmap buffer for the titlebar KPixmap *titleBuffer = new KPixmap; titleBuffer->resize(maxFull ? w - 2 : (w - 2 * (borderSize - 1)), titleHeight); QPainter p2(titleBuffer, this); // subtract titleBlocks pixmap width and some int rightoffset = r.x() + r.width() - titleBlocks->width() - borderSize; p2.fillRect(0, 0, w, r.height(), c1); p2.fillRect(rightoffset, 0, maxFull ? w - rightoffset : w - rightoffset - 2 * (borderSize - 1), r.height(), c2); // 8 bit displays will be a bit dithered, but they still look ok. if(isActive()) p2.drawPixmap(rightoffset, 0, *titleBlocks); else p2.drawPixmap(rightoffset, 0, *ititleBlocks); // Draw the title text on the pixmap, and with a smaller font // for toolwindows than the default. QFont fnt; if(largeButtons) { fnt = options()->font(true, false); // font not small } else { fnt = options()->font(true, true); // font small fnt.setWeight(QFont::Normal); // and disable bold } p2.setFont(fnt); p2.setPen(options()->color(ColorFont, isActive())); p2.drawText(r.x() + 4 - borderSize, 0, r.width() - 3, r.height(), AlignLeft | AlignVCenter, caption()); p2.end(); p.drawPixmap(maxFull ? 1 : borderSize - 1, borderSize - 1, *titleBuffer); delete titleBuffer; }
void KCommonDecoration::addButtons(ButtonContainer &btnContainer, const QString& s, bool isLeft) { if (s.length() > 0) { for (unsigned n=0; n < s.length(); n++) { KCommonDecorationButton *btn = 0; switch (s[n]) { case 'M': // Menu button if (!m_button[MenuButton]){ btn = createButton(MenuButton); if (!btn) break; btn->setTipText(i18n("Menu") ); btn->setRealizeButtons(LeftButton|RightButton); connect(btn, SIGNAL(pressed()), SLOT(menuButtonPressed())); connect(btn, SIGNAL(released()), this, SLOT(menuButtonReleased())); m_button[MenuButton] = btn; } break; case 'S': // OnAllDesktops button if (!m_button[OnAllDesktopsButton]){ btn = createButton(OnAllDesktopsButton); if (!btn) break; const bool oad = isOnAllDesktops(); btn->setTipText(oad?i18n("Not on all desktops"):i18n("On all desktops") ); btn->setToggleButton(true); btn->setOn( oad ); connect(btn, SIGNAL(clicked()), SLOT(toggleOnAllDesktops())); m_button[OnAllDesktopsButton] = btn; } break; case 'H': // Help button if ((!m_button[HelpButton]) && providesContextHelp()){ btn = createButton(HelpButton); if (!btn) break; btn->setTipText(i18n("Help") ); connect(btn, SIGNAL(clicked()), SLOT(showContextHelp())); m_button[HelpButton] = btn; } break; case 'I': // Minimize button if ((!m_button[MinButton]) && isMinimizable()){ btn = createButton(MinButton); if (!btn) break; btn->setTipText(i18n("Minimize") ); connect(btn, SIGNAL(clicked()), SLOT(minimize())); m_button[MinButton] = btn; } break; case 'A': // Maximize button if ((!m_button[MaxButton]) && isMaximizable()){ btn = createButton(MaxButton); if (!btn) break; btn->setRealizeButtons(LeftButton|MidButton|RightButton); const bool max = maximizeMode()==MaximizeFull; btn->setTipText(max?i18n("Restore"):i18n("Maximize") ); btn->setToggleButton(true); btn->setOn( max ); connect(btn, SIGNAL(clicked()), SLOT(slotMaximize())); m_button[MaxButton] = btn; } break; case 'X': // Close button if ((!m_button[CloseButton]) && isCloseable()){ btn = createButton(CloseButton); if (!btn) break; btn->setTipText(i18n("Close") ); connect(btn, SIGNAL(clicked()), SLOT(closeWindow())); m_button[CloseButton] = btn; } break; case 'F': // AboveButton button if (!m_button[AboveButton]){ btn = createButton(AboveButton); if (!btn) break; bool above = keepAbove(); btn->setTipText(above?i18n("Do not keep above others"):i18n("Keep above others") ); btn->setToggleButton(true); btn->setOn( above ); connect(btn, SIGNAL(clicked()), SLOT(slotKeepAbove())); m_button[AboveButton] = btn; } break; case 'B': // BelowButton button if (!m_button[BelowButton]){ btn = createButton(BelowButton); if (!btn) break; bool below = keepBelow(); btn->setTipText(below?i18n("Do not keep below others"):i18n("Keep below others") ); btn->setToggleButton(true); btn->setOn( below ); connect(btn, SIGNAL(clicked()), SLOT(slotKeepBelow())); m_button[BelowButton] = btn; } break; case 'L': // Shade button if ((!m_button[ShadeButton]) && isShadeable()){ btn = createButton(ShadeButton); if (!btn) break; bool shaded = isSetShade(); btn->setTipText(shaded?i18n("Unshade"):i18n("Shade") ); btn->setToggleButton(true); btn->setOn( shaded ); connect(btn, SIGNAL(clicked()), SLOT(slotShade())); m_button[ShadeButton] = btn; } break; case '_': // Spacer item btnContainer.append(0); } if (btn) { btn->setLeft(isLeft); btn->setSize(QSize(layoutMetric(LM_ButtonWidth, true, btn),layoutMetric(LM_ButtonHeight, true, btn)) ); btn->show(); btnContainer.append(btn); } } } }