summaryrefslogtreecommitdiff
authorleseb <leseb>2002-07-13 12:37:36 (UTC)
committer leseb <leseb>2002-07-13 12:37:36 (UTC)
commit6337e3836497ede8bb47aea5c7b65f4f8c08c4cd (patch) (unidiff)
tree3a2b4d0d2ee302b1c01fbe8c0f3fbf40f8a30b3b
parent804c1ce9554548d1c0f46d28eb1b8f63b4341fdb (diff)
downloadopie-6337e3836497ede8bb47aea5c7b65f4f8c08c4cd.zip
opie-6337e3836497ede8bb47aea5c7b65f4f8c08c4cd.tar.gz
opie-6337e3836497ede8bb47aea5c7b65f4f8c08c4cd.tar.bz2
Small fix in drawing menubar
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index fc925b8..87b5488 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1739,521 +1739,521 @@ void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g,
1739{ 1739{
1740 if(horiz){ 1740 if(horiz){
1741 if(r.width() >= 15){ 1741 if(r.width() >= 15){
1742 int y = r.y()+3; 1742 int y = r.y()+3;
1743 int x = r.x() + (r.width()-7)/2; 1743 int x = r.x() + (r.width()-7)/2;
1744 int y2 = r.bottom()-3; 1744 int y2 = r.bottom()-3;
1745 p->setPen(g.light()); 1745 p->setPen(g.light());
1746 p->drawLine(x, y, x, y2); 1746 p->drawLine(x, y, x, y2);
1747 p->drawLine(x+3, y, x+3, y2); 1747 p->drawLine(x+3, y, x+3, y2);
1748 p->drawLine(x+6, y, x+6, y2); 1748 p->drawLine(x+6, y, x+6, y2);
1749 1749
1750 p->setPen(g.mid()); 1750 p->setPen(g.mid());
1751 p->drawLine(x+1, y, x+1, y2); 1751 p->drawLine(x+1, y, x+1, y2);
1752 p->drawLine(x+4, y, x+4, y2); 1752 p->drawLine(x+4, y, x+4, y2);
1753 p->drawLine(x+7, y, x+7, y2); 1753 p->drawLine(x+7, y, x+7, y2);
1754 } 1754 }
1755 } 1755 }
1756 else{ 1756 else{
1757 if(r.height() >= 15){ 1757 if(r.height() >= 15){
1758 int x = r.x()+3; 1758 int x = r.x()+3;
1759 int y = r.y() + (r.height()-7)/2; 1759 int y = r.y() + (r.height()-7)/2;
1760 int x2 = r.right()-3; 1760 int x2 = r.right()-3;
1761 p->setPen(g.light()); 1761 p->setPen(g.light());
1762 p->drawLine(x, y, x2, y); 1762 p->drawLine(x, y, x2, y);
1763 p->drawLine(x, y+3, x2, y+3); 1763 p->drawLine(x, y+3, x2, y+3);
1764 p->drawLine(x, y+6, x2, y+6); 1764 p->drawLine(x, y+6, x2, y+6);
1765 1765
1766 p->setPen(g.mid()); 1766 p->setPen(g.mid());
1767 p->drawLine(x, y+1, x2, y+1); 1767 p->drawLine(x, y+1, x2, y+1);
1768 p->drawLine(x, y+4, x2, y+4); 1768 p->drawLine(x, y+4, x2, y+4);
1769 p->drawLine(x, y+7, x2, y+7); 1769 p->drawLine(x, y+7, x2, y+7);
1770 } 1770 }
1771 } 1771 }
1772 1772
1773} 1773}
1774 1774
1775 1775
1776void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin, 1776void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin,
1777 int &sliderMax, int &sliderLength, 1777 int &sliderMax, int &sliderLength,
1778 int &buttonDim) 1778 int &buttonDim)
1779{ 1779{
1780 1780
1781 int maxLength; 1781 int maxLength;
1782 int b = 0; 1782 int b = 0;
1783 bool horiz = sb->orientation() == QScrollBar::Horizontal; 1783 bool horiz = sb->orientation() == QScrollBar::Horizontal;
1784 int length = horiz ? sb->width() : sb->height(); 1784 int length = horiz ? sb->width() : sb->height();
1785 int extent = horiz ? sb->height() : sb->width(); 1785 int extent = horiz ? sb->height() : sb->width();
1786 1786
1787 if ( length > ( extent - b*2 - 1 )*2 + b*2 ) 1787 if ( length > ( extent - b*2 - 1 )*2 + b*2 )
1788 buttonDim = extent - b*2; 1788 buttonDim = extent - b*2;
1789 else 1789 else
1790 buttonDim = ( length - b*2 )/2 - 1; 1790 buttonDim = ( length - b*2 )/2 - 1;
1791 1791
1792 sliderMin = b + 0; // buttonDim; 1792 sliderMin = b + 0; // buttonDim;
1793 maxLength = length - b*2 - buttonDim*2; // 3; 1793 maxLength = length - b*2 - buttonDim*2; // 3;
1794 1794
1795 if ( sb->maxValue() == sb->minValue() ) { 1795 if ( sb->maxValue() == sb->minValue() ) {
1796 sliderLength = maxLength; 1796 sliderLength = maxLength;
1797 } else { 1797 } else {
1798 sliderLength = (sb->pageStep()*maxLength)/ 1798 sliderLength = (sb->pageStep()*maxLength)/
1799 (sb->maxValue()-sb->minValue()+sb->pageStep()); 1799 (sb->maxValue()-sb->minValue()+sb->pageStep());
1800 uint range = sb->maxValue()-sb->minValue(); 1800 uint range = sb->maxValue()-sb->minValue();
1801 if ( sliderLength < 9 || range > INT_MAX/2 ) 1801 if ( sliderLength < 9 || range > INT_MAX/2 )
1802 sliderLength = 9; 1802 sliderLength = 9;
1803 if ( sliderLength > maxLength ) 1803 if ( sliderLength > maxLength )
1804 sliderLength = maxLength; 1804 sliderLength = maxLength;
1805 } 1805 }
1806 sliderMax = sliderMin + maxLength - sliderLength; 1806 sliderMax = sliderMin + maxLength - sliderLength;
1807 1807
1808} 1808}
1809 1809
1810QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb, 1810QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb,
1811 int sliderStart, 1811 int sliderStart,
1812 const QPoint &p) 1812 const QPoint &p)
1813{ 1813{
1814 if ( !sb->rect().contains( p ) ) 1814 if ( !sb->rect().contains( p ) )
1815 return NoScroll; 1815 return NoScroll;
1816 int sliderMin, sliderMax, sliderLength, buttonDim, pos; 1816 int sliderMin, sliderMax, sliderLength, buttonDim, pos;
1817 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); 1817 scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
1818 pos = (sb->orientation() == QScrollBar::Horizontal)? p.x() : p.y(); 1818 pos = (sb->orientation() == QScrollBar::Horizontal)? p.x() : p.y();
1819 if ( pos < sliderMin ) 1819 if ( pos < sliderMin )
1820 return SubLine; 1820 return SubLine;
1821 if ( pos < sliderStart ) 1821 if ( pos < sliderStart )
1822 return SubPage; 1822 return SubPage;
1823 if ( pos < sliderStart + sliderLength ) 1823 if ( pos < sliderStart + sliderLength )
1824 return Slider; 1824 return Slider;
1825 if ( pos < sliderMax + sliderLength) 1825 if ( pos < sliderMax + sliderLength)
1826 return AddPage; 1826 return AddPage;
1827 if(pos > sliderMax + sliderLength + 16) 1827 if(pos > sliderMax + sliderLength + 16)
1828 return AddLine; 1828 return AddLine;
1829 1829
1830 return SubLine; 1830 return SubLine;
1831} 1831}
1832 1832
1833#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) 1833#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
1834 1834
1835 1835
1836QSize LiquidStyle::exclusiveIndicatorSize() const 1836QSize LiquidStyle::exclusiveIndicatorSize() const
1837{ 1837{
1838 return(QSize(16, 16)); 1838 return(QSize(16, 16));
1839} 1839}
1840 1840
1841void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/, 1841void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/,
1842 int /*h*/, const QColorGroup &/*g*/, bool on, 1842 int /*h*/, const QColorGroup &/*g*/, bool on,
1843 bool down, bool) 1843 bool down, bool)
1844{ 1844{
1845 bool isHover = highlightWidget == p->device(); 1845 bool isHover = highlightWidget == p->device();
1846 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget 1846 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget
1847 && ((QWidget*)p->device())->autoMask(); 1847 && ((QWidget*)p->device())->autoMask();
1848 1848
1849 if(isMasked){ 1849 if(isMasked){
1850 if(on || down){ 1850 if(on || down){
1851 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioDownHover) : 1851 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioDownHover) :
1852 *getPixmap(HTMLRadioDown)); 1852 *getPixmap(HTMLRadioDown));
1853 } 1853 }
1854 else 1854 else
1855 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioHover) : 1855 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLRadioHover) :
1856 *getPixmap(HTMLRadio)); 1856 *getPixmap(HTMLRadio));
1857 1857
1858 } 1858 }
1859 else{ 1859 else{
1860 if(on || down){ 1860 if(on || down){
1861 p->drawPixmap(x, y, isHover ? *getPixmap(RadioOnHover) : 1861 p->drawPixmap(x, y, isHover ? *getPixmap(RadioOnHover) :
1862 *getPixmap(RadioOn)); 1862 *getPixmap(RadioOn));
1863 } 1863 }
1864 else 1864 else
1865 p->drawPixmap(x, y, isHover ? *getPixmap(RadioOffHover) : 1865 p->drawPixmap(x, y, isHover ? *getPixmap(RadioOffHover) :
1866 *getPixmap(RadioOff)); 1866 *getPixmap(RadioOff));
1867 } 1867 }
1868} 1868}
1869 1869
1870void LiquidStyle::drawExclusiveIndicatorMask(QPainter *p, int x, int y, int w, 1870void LiquidStyle::drawExclusiveIndicatorMask(QPainter *p, int x, int y, int w,
1871 int h, bool) 1871 int h, bool)
1872{ 1872{
1873 p->fillRect(x, y, w, h, Qt::color0); 1873 p->fillRect(x, y, w, h, Qt::color0);
1874 p->setPen(Qt::color1); 1874 p->setPen(Qt::color1);
1875 p->drawPixmap(x, y, *getPixmap(RadioOn)->mask()); 1875 p->drawPixmap(x, y, *getPixmap(RadioOn)->mask());
1876} 1876}
1877 1877
1878 1878
1879QSize LiquidStyle::indicatorSize() const 1879QSize LiquidStyle::indicatorSize() const
1880{ 1880{
1881 return(QSize(20, 22)); 1881 return(QSize(20, 22));
1882} 1882}
1883 1883
1884void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/, 1884void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/,
1885 const QColorGroup &/*g*/, int state, bool /*down*/, bool) 1885 const QColorGroup &/*g*/, int state, bool /*down*/, bool)
1886{ 1886{
1887 bool isHover = highlightWidget == p->device(); 1887 bool isHover = highlightWidget == p->device();
1888 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget 1888 bool isMasked = p->device() && p->device()->devType() == QInternal::Widget
1889 && ((QWidget*)p->device())->autoMask(); 1889 && ((QWidget*)p->device())->autoMask();
1890 if(isMasked){ 1890 if(isMasked){
1891 if(state != QButton::Off){ 1891 if(state != QButton::Off){
1892 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBDownHover) : 1892 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBDownHover) :
1893 *getPixmap(HTMLCBDown)); 1893 *getPixmap(HTMLCBDown));
1894 } 1894 }
1895 else 1895 else
1896 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBHover) : 1896 p->drawPixmap(x, y, isHover ? *getPixmap(HTMLCBHover) :
1897 *getPixmap(HTMLCB)); 1897 *getPixmap(HTMLCB));
1898 1898
1899 } 1899 }
1900 else{ 1900 else{
1901 if(state != QButton::Off){ 1901 if(state != QButton::Off){
1902 p->drawPixmap(x, y, isHover ? *getPixmap(CBDownHover) : 1902 p->drawPixmap(x, y, isHover ? *getPixmap(CBDownHover) :
1903 *getPixmap(CBDown)); 1903 *getPixmap(CBDown));
1904 /* Todo - tristate 1904 /* Todo - tristate
1905 if(state == QButton::On){ 1905 if(state == QButton::On){
1906 p->setPen(Qt::black); 1906 p->setPen(Qt::black);
1907 p->drawPixmap(3, 3, xBmp); 1907 p->drawPixmap(3, 3, xBmp);
1908 } 1908 }
1909 else{ 1909 else{
1910 p->setPen(g.dark()); 1910 p->setPen(g.dark());
1911 p->drawRect(x+2, y+2, w-4, h-4); 1911 p->drawRect(x+2, y+2, w-4, h-4);
1912 p->setPen(Qt::black); 1912 p->setPen(Qt::black);
1913 p->drawLine(x+3, (y+h)/2-2, x+w-4, (y+h)/2-2); 1913 p->drawLine(x+3, (y+h)/2-2, x+w-4, (y+h)/2-2);
1914 p->drawLine(x+3, (y+h)/2, x+w-4, (y+h)/2); 1914 p->drawLine(x+3, (y+h)/2, x+w-4, (y+h)/2);
1915 p->drawLine(x+3, (y+h)/2+2, x+w-4, (y+h)/2+2); 1915 p->drawLine(x+3, (y+h)/2+2, x+w-4, (y+h)/2+2);
1916 }*/ 1916 }*/
1917 } 1917 }
1918 else 1918 else
1919 p->drawPixmap(x, y, isHover ? *getPixmap(CBHover) : *getPixmap(CB)); 1919 p->drawPixmap(x, y, isHover ? *getPixmap(CBHover) : *getPixmap(CB));
1920 } 1920 }
1921} 1921}
1922 1922
1923void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, 1923void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/,
1924 int /*state*/) 1924 int /*state*/)
1925{ 1925{
1926 // needed for some reason by KHtml, even tho it's all filled ;P 1926 // needed for some reason by KHtml, even tho it's all filled ;P
1927 p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask()); 1927 p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask());
1928 1928
1929} 1929}
1930 1930
1931void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h, 1931void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h,
1932 const QColorGroup &/*g*/, Orientation orient, 1932 const QColorGroup &/*g*/, Orientation orient,
1933 bool, bool) 1933 bool, bool)
1934{ 1934{
1935 QWidget *parent = (QWidget *)p->device(); 1935 QWidget *parent = (QWidget *)p->device();
1936 p->setBrushOrigin(parent->pos()); 1936 p->setBrushOrigin(parent->pos());
1937 parent->erase(x, y, w, h); 1937 parent->erase(x, y, w, h);
1938 p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider) : 1938 p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider) :
1939 *getPixmap(VSlider)); 1939 *getPixmap(VSlider));
1940} 1940}
1941 1941
1942void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int /*w*/, int /*h*/, 1942void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int /*w*/, int /*h*/,
1943 Orientation orient, bool, bool) 1943 Orientation orient, bool, bool)
1944{ 1944{
1945 p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider)->mask() : 1945 p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider)->mask() :
1946 *getPixmap(VSlider)->mask()); 1946 *getPixmap(VSlider)->mask());
1947} 1947}
1948 1948
1949int LiquidStyle::sliderLength() const 1949int LiquidStyle::sliderLength() const
1950{ 1950{
1951 return(10); 1951 return(10);
1952} 1952}
1953 1953
1954#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) 1954#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
1955 1955
1956void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x, 1956void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x,
1957 int y, int w, int h, const QColorGroup &g, 1957 int y, int w, int h, const QColorGroup &g,
1958 bool enabled, const QBrush *) 1958 bool enabled, const QBrush *)
1959{ 1959{
1960 static const QCOORD u_arrow[]={3,1, 4,1, 2,2, 5,2, 1,3, 6,3, 0,4, 7,4, 0,5, 7,5}; 1960 static const QCOORD u_arrow[]={3,1, 4,1, 2,2, 5,2, 1,3, 6,3, 0,4, 7,4, 0,5, 7,5};
1961 static const QCOORD d_arrow[]={0,2, 7,2, 0,3, 7,3, 1,4, 6,4, 2,5, 5,5, 3,6, 4,6}; 1961 static const QCOORD d_arrow[]={0,2, 7,2, 0,3, 7,3, 1,4, 6,4, 2,5, 5,5, 3,6, 4,6};
1962 static const QCOORD l_arrow[]={1,3, 1,4, 2,2, 2,5, 3,1, 3,6, 4,0, 4,7, 5,0, 5,7}; 1962 static const QCOORD l_arrow[]={1,3, 1,4, 2,2, 2,5, 3,1, 3,6, 4,0, 4,7, 5,0, 5,7};
1963 static const QCOORD r_arrow[]={2,0, 2,7, 3,0, 3,7, 4,1, 4,6, 5,2, 5,5, 6,3, 6,4}; 1963 static const QCOORD r_arrow[]={2,0, 2,7, 3,0, 3,7, 4,1, 4,6, 5,2, 5,5, 6,3, 6,4};
1964 1964
1965 p->setPen(enabled ? on ? g.light() : g.buttonText() : g.mid()); 1965 p->setPen(enabled ? on ? g.light() : g.buttonText() : g.mid());
1966 if(w > 8){ 1966 if(w > 8){
1967 x = x + (w-8)/2; 1967 x = x + (w-8)/2;
1968 y = y + (h-8)/2; 1968 y = y + (h-8)/2;
1969 } 1969 }
1970 1970
1971 QPointArray a; 1971 QPointArray a;
1972 switch(type){ 1972 switch(type){
1973 case Qt::UpArrow: 1973 case Qt::UpArrow:
1974 a.setPoints(QCOORDARRLEN(u_arrow), u_arrow); 1974 a.setPoints(QCOORDARRLEN(u_arrow), u_arrow);
1975 break; 1975 break;
1976 case Qt::DownArrow: 1976 case Qt::DownArrow:
1977 a.setPoints(QCOORDARRLEN(d_arrow), d_arrow); 1977 a.setPoints(QCOORDARRLEN(d_arrow), d_arrow);
1978 break; 1978 break;
1979 case Qt::LeftArrow: 1979 case Qt::LeftArrow:
1980 a.setPoints(QCOORDARRLEN(l_arrow), l_arrow); 1980 a.setPoints(QCOORDARRLEN(l_arrow), l_arrow);
1981 break; 1981 break;
1982 default: 1982 default:
1983 a.setPoints(QCOORDARRLEN(r_arrow), r_arrow); 1983 a.setPoints(QCOORDARRLEN(r_arrow), r_arrow);
1984 break; 1984 break;
1985 } 1985 }
1986 1986
1987 a.translate(x, y); 1987 a.translate(x, y);
1988 p->drawLineSegments(a); 1988 p->drawLineSegments(a);
1989} 1989}
1990 1990
1991 1991
1992void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h, 1992void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h,
1993 QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active ) 1993 QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active )
1994 { 1994 {
1995 x -= 2; // Bug in Qt/E 1995 if(active){
1996 y -= 2; 1996 x -= 2; // Bug in Qt/E
1997 w += 2; 1997 y -= 2;
1998 h += 2; 1998 w += 2;
1999 h += 2;
2000 }
1999 2001
2000 p-> fillRect ( x, y, w, h, g.brush(QColorGroup::Background)); 2002 p-> fillRect ( x, y, w, h, g.brush(QColorGroup::Background));
2001 2003
2002 w -= 2;
2003
2004 if(menuHandler->useShadowText()){ 2004 if(menuHandler->useShadowText()){
2005 QColor shadow; 2005 QColor shadow;
2006 if(p->device() && p->device()->devType() == QInternal::Widget && 2006 if(p->device() && p->device()->devType() == QInternal::Widget &&
2007 ((QWidget *)p->device())->inherits("QMenuBar")){ 2007 ((QWidget *)p->device())->inherits("QMenuBar")){
2008 shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) : 2008 shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) :
2009 g.background().dark(130); 2009 g.background().dark(130);
2010 } 2010 }
2011 else 2011 else
2012 shadow = g.background().dark(130); 2012 shadow = g.background().dark(130);
2013 2013
2014 if(active){ 2014 if(active){
2015 drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); 2015 drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background());
2016 QApplication::style().drawItem(p, x+1, y+1, w, h, 2016 QApplication::style().drawItem(p, x+1, y+1, w, h,
2017 AlignCenter|ShowPrefix|DontClip|SingleLine, 2017 AlignCenter|ShowPrefix|DontClip|SingleLine,
2018 g, mi->isEnabled(), NULL, mi->text(), 2018 g, mi->isEnabled(), NULL, mi->text(),
2019 -1, &shadow); 2019 -1, &shadow);
2020 QApplication::style().drawItem(p, x, y, w, h, 2020 QApplication::style().drawItem(p, x, y, w, h,
2021 AlignCenter|ShowPrefix|DontClip|SingleLine, 2021 AlignCenter|ShowPrefix|DontClip|SingleLine,
2022 g, mi->isEnabled(), NULL, mi->text(), 2022 g, mi->isEnabled(), NULL, mi->text(),
2023 -1, &g.text()); 2023 -1, &g.text());
2024 } 2024 }
2025 else{ 2025 else{
2026 QApplication::style().drawItem(p, x+1, y+1, w, h, 2026 QApplication::style().drawItem(p, x+1, y+1, w, h,
2027 AlignCenter|ShowPrefix|DontClip|SingleLine, 2027 AlignCenter|ShowPrefix|DontClip|SingleLine,
2028 g, mi->isEnabled(), NULL, mi->text(), 2028 g, mi->isEnabled(), NULL, mi->text(),
2029 -1, &shadow); 2029 -1, &shadow);
2030 QApplication::style().drawItem(p, x, y, w, h, 2030 QApplication::style().drawItem(p, x, y, w, h,
2031 AlignCenter|ShowPrefix|DontClip|SingleLine, 2031 AlignCenter|ShowPrefix|DontClip|SingleLine,
2032 g, mi->isEnabled(), NULL, mi->text(), 2032 g, mi->isEnabled(), NULL, mi->text(),
2033 -1, &g.text()); 2033 -1, &g.text());
2034 } 2034 }
2035 } 2035 }
2036 else{ 2036 else{
2037 if(active) 2037 if(active)
2038 drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background()); 2038 drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background());
2039 QApplication::style().drawItem(p, x, y, w, h, 2039 QApplication::style().drawItem(p, x, y, w, h,
2040 AlignCenter|ShowPrefix|DontClip|SingleLine, 2040 AlignCenter|ShowPrefix|DontClip|SingleLine,
2041 g, mi->isEnabled(), NULL, mi->text(), 2041 g, mi->isEnabled(), NULL, mi->text(),
2042 -1, &g.text()); 2042 -1, &g.text());
2043 } 2043 }
2044} 2044}
2045 2045
2046void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h, 2046void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h,
2047 const QColorGroup &g, int /*lineWidth*/, 2047 const QColorGroup &g, int /*lineWidth*/,
2048 const QBrush * /*fill*/) 2048 const QBrush * /*fill*/)
2049{ 2049{
2050 QColor c; 2050 QColor c;
2051 switch(menuHandler->transType()){ 2051 switch(menuHandler->transType()){
2052 case None: 2052 case None:
2053 case StippledBg: 2053 case StippledBg:
2054 case TransStippleBg: 2054 case TransStippleBg:
2055 c = g.background(); 2055 c = g.background();
2056 break; 2056 break;
2057 case StippledBtn: 2057 case StippledBtn:
2058 case TransStippleBtn: 2058 case TransStippleBtn:
2059 c = g.button(); 2059 c = g.button();
2060 break; 2060 break;
2061 default: 2061 default:
2062 c = menuHandler->bgColor(); 2062 c = menuHandler->bgColor();
2063 } 2063 }
2064 p->setPen(c.dark(140)); 2064 p->setPen(c.dark(140));
2065 p->drawRect(x, y, w, h); 2065 p->drawRect(x, y, w, h);
2066 p->setPen(c.light(120)); 2066 p->setPen(c.light(120));
2067 p->drawRect(x+1, y+1, w-2, h-2); 2067 p->drawRect(x+1, y+1, w-2, h-2);
2068} 2068}
2069 2069
2070void LiquidStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, 2070void LiquidStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw,
2071 int tab, QMenuItem* mi, 2071 int tab, QMenuItem* mi,
2072 const QPalette& pal, bool act, 2072 const QPalette& pal, bool act,
2073 bool enabled, int x, int y, int w, int h) 2073 bool enabled, int x, int y, int w, int h)
2074{ 2074{
2075static const int motifItemFrame = 2; 2075static const int motifItemFrame = 2;
2076static const int motifItemHMargin = 3; 2076static const int motifItemHMargin = 3;
2077static const int motifItemVMargin = 2; 2077static const int motifItemVMargin = 2;
2078static const int motifArrowHMargin = 6; 2078static const int motifArrowHMargin = 6;
2079static const int windowsRightBorder = 12; 2079static const int windowsRightBorder = 12;
2080 2080
2081 maxpmw = QMAX( maxpmw, 20 ); 2081 maxpmw = QMAX( maxpmw, 20 );
2082 2082
2083 2083
2084 bool dis = !enabled; 2084 bool dis = !enabled;
2085 QColorGroup itemg = dis ? pal.disabled() : pal.active(); 2085 QColorGroup itemg = dis ? pal.disabled() : pal.active();
2086 2086
2087 int checkcol = maxpmw; 2087 int checkcol = maxpmw;
2088 if(act){ 2088 if(act){
2089 2089
2090 // FIXME 2090 // FIXME
2091 drawClearBevel(p, x, y, w, h, itemg.button(), itemg.background()); 2091 drawClearBevel(p, x, y, w, h, itemg.button(), itemg.background());
2092 } 2092 }
2093 //else if(((QWidget*)p->device())->backgroundPixmap()){ 2093 //else if(((QWidget*)p->device())->backgroundPixmap()){
2094 // p->drawPixmap(x, y, *((QWidget*)p->device())->backgroundPixmap(), 2094 // p->drawPixmap(x, y, *((QWidget*)p->device())->backgroundPixmap(),
2095 // x, y, w, h); 2095 // x, y, w, h);
2096 //} 2096 //}
2097 else{ 2097 else{
2098 if(menuHandler->transType() == None){ 2098 if(menuHandler->transType() == None){
2099 p->fillRect(x, y, w, h, pal.active().background()); 2099 p->fillRect(x, y, w, h, pal.active().background());
2100 } 2100 }
2101 else if(menuHandler->transType() == StippledBg){ 2101 else if(menuHandler->transType() == StippledBg){
2102 p->fillRect(x, y, w, h, bgBrush); 2102 p->fillRect(x, y, w, h, bgBrush);
2103 } 2103 }
2104 else if(menuHandler->transType() == StippledBtn){ 2104 else if(menuHandler->transType() == StippledBtn){
2105 p->fillRect(x, y, w, h, menuBrush); 2105 p->fillRect(x, y, w, h, menuBrush);
2106 } 2106 }
2107 else{ 2107 else{
2108 QPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId()); 2108 QPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId());
2109 if(pix) 2109 if(pix)
2110 p->drawPixmap(x, y, *pix, x, y, w, h); 2110 p->drawPixmap(x, y, *pix, x, y, w, h);
2111 } 2111 }
2112 } 2112 }
2113 2113
2114 if(!mi) 2114 if(!mi)
2115 return; 2115 return;
2116 2116
2117 QColor discol; 2117 QColor discol;
2118 if (dis) { 2118 if (dis) {
2119 discol = itemg.mid(); 2119 discol = itemg.mid();
2120 p->setPen(discol); 2120 p->setPen(discol);
2121 } 2121 }
2122 2122
2123 QColorGroup cg2(itemg); 2123 QColorGroup cg2(itemg);
2124 2124
2125 if(menuHandler->transType() == Custom){ 2125 if(menuHandler->transType() == Custom){
2126 cg2.setColor(QColorGroup::Foreground, menuHandler->textColor()); 2126 cg2.setColor(QColorGroup::Foreground, menuHandler->textColor());
2127 cg2.setColor(QColorGroup::Text, menuHandler->textColor()); 2127 cg2.setColor(QColorGroup::Text, menuHandler->textColor());
2128 cg2.setColor(QColorGroup::Light, menuHandler->textColor().light(120)); 2128 cg2.setColor(QColorGroup::Light, menuHandler->textColor().light(120));
2129 cg2.setColor(QColorGroup::Mid, menuHandler->textColor().dark(120)); 2129 cg2.setColor(QColorGroup::Mid, menuHandler->textColor().dark(120));
2130 } 2130 }
2131 else{ 2131 else{
2132 cg2 = QColorGroup(discol, itemg.highlight(), black, black, 2132 cg2 = QColorGroup(discol, itemg.highlight(), black, black,
2133 dis ? discol : black, discol, black); 2133 dis ? discol : black, discol, black);
2134 } 2134 }
2135 2135
2136 if(mi->isSeparator()){ 2136 if(mi->isSeparator()){
2137 QColor c; 2137 QColor c;
2138 switch(menuHandler->transType()){ 2138 switch(menuHandler->transType()){
2139 case None: 2139 case None:
2140 case StippledBg: 2140 case StippledBg:
2141 case TransStippleBg: 2141 case TransStippleBg:
2142 c = QApplication::palette().active().background(); 2142 c = QApplication::palette().active().background();
2143 break; 2143 break;
2144 case StippledBtn: 2144 case StippledBtn:
2145 case TransStippleBtn: 2145 case TransStippleBtn:
2146 c = QApplication::palette().active().button(); 2146 c = QApplication::palette().active().button();
2147 break; 2147 break;
2148 default: 2148 default:
2149 c = menuHandler->bgColor(); 2149 c = menuHandler->bgColor();
2150 } 2150 }
2151 p->setPen(c.dark(140)); 2151 p->setPen(c.dark(140));
2152 p->drawLine(x, y, x+w, y ); 2152 p->drawLine(x, y, x+w, y );
2153 p->setPen(c.light(115)); 2153 p->setPen(c.light(115));
2154 p->drawLine(x, y+1, x+w, y+1 ); 2154 p->drawLine(x, y+1, x+w, y+1 );
2155 return; 2155 return;
2156 } 2156 }
2157 if(mi->iconSet()) { 2157 if(mi->iconSet()) {
2158 QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal; 2158 QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal;
2159 if (!dis) 2159 if (!dis)
2160 mode = QIconSet::Active; 2160 mode = QIconSet::Active;
2161 QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode); 2161 QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode);
2162 int pixw = pixmap.width(); 2162 int pixw = pixmap.width();
2163 int pixh = pixmap.height(); 2163 int pixh = pixmap.height();
2164 QRect cr(x, y, checkcol, h); 2164 QRect cr(x, y, checkcol, h);
2165 QRect pmr(0, 0, pixw, pixh); 2165 QRect pmr(0, 0, pixw, pixh);
2166 pmr.moveCenter( cr.center() ); 2166 pmr.moveCenter( cr.center() );
2167 p->setPen(itemg.highlightedText()); 2167 p->setPen(itemg.highlightedText());
2168 p->drawPixmap(pmr.topLeft(), pixmap ); 2168 p->drawPixmap(pmr.topLeft(), pixmap );
2169 2169
2170 } 2170 }
2171 else if(checkable) { 2171 else if(checkable) {
2172 int mw = checkcol + motifItemFrame; 2172 int mw = checkcol + motifItemFrame;
2173 int mh = h - 2*motifItemFrame; 2173 int mh = h - 2*motifItemFrame;
2174 if (mi->isChecked()){ 2174 if (mi->isChecked()){
2175 drawCheckMark( p, x + motifItemFrame, 2175 drawCheckMark( p, x + motifItemFrame,
2176 y+motifItemFrame, mw, mh, cg2, act, dis ); 2176 y+motifItemFrame, mw, mh, cg2, act, dis );
2177 } 2177 }
2178 } 2178 }
2179 if(menuHandler->transType() == Custom) 2179 if(menuHandler->transType() == Custom)
2180 p->setPen(menuHandler->textColor()); 2180 p->setPen(menuHandler->textColor());
2181 else 2181 else
2182 p->setPen(itemg.text()); 2182 p->setPen(itemg.text());
2183 2183
2184 2184
2185 int xm = motifItemFrame + checkcol + motifItemHMargin; 2185 int xm = motifItemFrame + checkcol + motifItemHMargin;
2186 QString s = mi->text(); 2186 QString s = mi->text();
2187 if (!s.isNull()) { 2187 if (!s.isNull()) {
2188 int t = s.find( '\t' ); 2188 int t = s.find( '\t' );
2189 int m = motifItemVMargin; 2189 int m = motifItemVMargin;
2190 const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; 2190 const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
2191 QPen oldPen = p->pen(); 2191 QPen oldPen = p->pen();
2192 if(menuHandler->useShadowText()){ 2192 if(menuHandler->useShadowText()){
2193 if(menuHandler->transType() == Custom) 2193 if(menuHandler->transType() == Custom)
2194 p->setPen(menuHandler->bgColor().dark(130)); 2194 p->setPen(menuHandler->bgColor().dark(130));
2195 else if(menuHandler->transType() == StippledBtn || 2195 else if(menuHandler->transType() == StippledBtn ||
2196 menuHandler->transType() == TransStippleBtn) 2196 menuHandler->transType() == TransStippleBtn)
2197 p->setPen(itemg.button().dark(130)); 2197 p->setPen(itemg.button().dark(130));
2198 else 2198 else
2199 p->setPen(bgBrush.color().dark(130)); 2199 p->setPen(bgBrush.color().dark(130));
2200 2200
2201 if (t >= 0) { 2201 if (t >= 0) {
2202 p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+2, 2202 p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+2,
2203 y+m+2, tab-1, h-2*m-1, text_flags, s.mid( t+1 )); 2203 y+m+2, tab-1, h-2*m-1, text_flags, s.mid( t+1 ));
2204 } 2204 }
2205 p->drawText(x+xm+1, y+m+1, w-xm-tab, h-2*m-1, text_flags, s, t); 2205 p->drawText(x+xm+1, y+m+1, w-xm-tab, h-2*m-1, text_flags, s, t);
2206 } 2206 }
2207 p->setPen(oldPen); 2207 p->setPen(oldPen);
2208 if (t >= 0) { 2208 if (t >= 0) {
2209 p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, 2209 p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1,
2210 y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); 2210 y+m+1, tab, h-2*m, text_flags, s.mid( t+1 ));
2211 } 2211 }
2212 p->drawText(x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t); 2212 p->drawText(x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t);
2213 2213
2214 } 2214 }
2215 else if (mi->pixmap()) { 2215 else if (mi->pixmap()) {
2216 QPixmap *pixmap = mi->pixmap(); 2216 QPixmap *pixmap = mi->pixmap();
2217 if (pixmap->depth() == 1) 2217 if (pixmap->depth() == 1)
2218 p->setBackgroundMode(OpaqueMode); 2218 p->setBackgroundMode(OpaqueMode);
2219 p->drawPixmap( x+xm, y+motifItemFrame, *pixmap); 2219 p->drawPixmap( x+xm, y+motifItemFrame, *pixmap);
2220 if (pixmap->depth() == 1) 2220 if (pixmap->depth() == 1)
2221 p->setBackgroundMode(TransparentMode); 2221 p->setBackgroundMode(TransparentMode);
2222 } 2222 }
2223 if (mi->popup()) { 2223 if (mi->popup()) {
2224 int dim = (h-2*motifItemFrame) / 2; 2224 int dim = (h-2*motifItemFrame) / 2;
2225 drawArrow(p, RightArrow, true, 2225 drawArrow(p, RightArrow, true,
2226 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, 2226 x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
2227 dim, dim, cg2, TRUE); 2227 dim, dim, cg2, TRUE);
2228 } 2228 }
2229} 2229}
2230 2230
2231int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi, 2231int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi,
2232 const QFontMetrics &fm) 2232 const QFontMetrics &fm)
2233{ 2233{
2234 if (mi->isSeparator()) 2234 if (mi->isSeparator())
2235 return 2; 2235 return 2;
2236 2236
2237 int h = 0; 2237 int h = 0;
2238 if (mi->pixmap()) 2238 if (mi->pixmap())
2239 h = mi->pixmap()->height(); 2239 h = mi->pixmap()->height();
2240 2240
2241 if (mi->iconSet()) 2241 if (mi->iconSet())
2242 h = QMAX(mi->iconSet()-> 2242 h = QMAX(mi->iconSet()->
2243 pixmap(QIconSet::Small, QIconSet::Normal).height(), h); 2243 pixmap(QIconSet::Small, QIconSet::Normal).height(), h);
2244 2244
2245 h = QMAX(fm.height() + 4, h); 2245 h = QMAX(fm.height() + 4, h);
2246 2246
2247 // we want a minimum size of 18 2247 // we want a minimum size of 18
2248 h = QMAX(h, 18); 2248 h = QMAX(h, 18);
2249 2249
2250 return h; 2250 return h;
2251} 2251}
2252 2252
2253 2253
2254void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r, 2254void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r,
2255 const QColorGroup &g, const QColor *c, 2255 const QColorGroup &g, const QColor *c,
2256 bool atBorder) 2256 bool atBorder)
2257{ 2257{
2258 // are we painting a widget? 2258 // are we painting a widget?
2259 if(p->device()->devType() == QInternal::Widget){ 2259 if(p->device()->devType() == QInternal::Widget){