⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qmag-qmag-cpp.html

📁 qtopiaphone英文帮助,用于初学者和开发人员,初学者可以用来学习,开发人员可以用来资料查询.
💻 HTML
📖 第 1 页 / 共 2 页
字号:
        z = 16;    else        z = index+1;    <a name="grab"></a><a href="#303">grab</a>();}void <a name="300"></a>MagWidget::setRefresh( int index ){    r = index;    <a name="killTimers"></a><a href="qobject.html#0ef111">killTimers</a>();    if (index &amp;&amp; !grabbing)        <a name="startTimer"></a><a href="qobject.html#4c6b67">startTimer</a>( timer[r] );}void <a name="301"></a>MagWidget::save(){    if ( !p.<a name="isNull"></a><a href="qpixmap.html#7803c4">isNull</a>() ) {        <a href="qobject.html#0ef111">killTimers</a>();        <a href="qstring.html">QString</a> fn = QFileDialog::getSaveFileName();        if ( !fn.<a name="isEmpty"></a><a href="qstring.html#c62623">isEmpty</a>() )            p.<a name="save"></a><a href="qpixmap.html#a38b1c">save</a>( fn, "BMP" );        if ( r )            <a href="qobject.html#4c6b67">startTimer</a>( timer[r] );    }}void <a name="302"></a>MagWidget::multiSave(){    if ( !p.<a href="qpixmap.html#7803c4">isNull</a>() ) {        multifn = ""; // stops saving        multifn = QFileDialog::getSaveFileName();        if ( multifn.<a href="qstring.html#c62623">isEmpty</a>() )            multiSaveButton-&gt;<a name="setOn"></a><a href="qpushbutton.html#15502f">setOn</a>(FALSE);        if ( !r )            p.<a href="qpixmap.html#a38b1c">save</a>( multifn, "BMP" );    } else {        multiSaveButton-&gt;<a href="qpushbutton.html#15502f">setOn</a>(FALSE);    }}void <a name="303"></a>MagWidget::grab(){    if ( !isVisible() )         return;                 // don't eat resources when iconified    if ( grabx &lt; 0 || graby &lt; 0 )        return;                 // don't grab until the user has said to    int x,y, w,h;    w = (<a href="qwidget.html#2edab1">width</a>()+z-1)/z;    h = (<a href="qwidget.html#e3c588">height</a>()+z-1-yoffset)/z;    if ( w&lt;1 || h&lt;1 )        return;                 // don't ask too much from the window system :)    x = grabx-w/2;              // find a suitable position to grab from    y = graby-h/2;    if ( x + w &gt; <a name="QApplication::desktop"></a><a href="qapplication.html#d8ed8c">QApplication::desktop</a>()-&gt;width() )        x = QApplication::desktop()-&gt;width()-w;    else if ( x &lt; 0 )        x = 0;    if ( y + h &gt; <a href="qapplication.html#d8ed8c">QApplication::desktop</a>()-&gt;height() )         y = QApplication::desktop()-&gt;height()-h;    else if ( y &lt; 0 )        y = 0;    p = QPixmap::grabWindow( <a href="qapplication.html#d8ed8c">QApplication::desktop</a>()-&gt;winId(),  x, y, w, h );    image = p.<a name="convertToImage"></a><a href="qpixmap.html#8c5f15">convertToImage</a>();    <a name="QWMatrix"></a><a href="qwmatrix.html">QWMatrix</a> m;                 // after getting it, scale it    m.scale( (double)z, (double)z );    pm = p.<a name="xForm"></a><a href="qpixmap.html#ff5fcf">xForm</a>( m );    if ( !multiSaveButton || !multiSaveButton-&gt;<a name="isOn"></a><a href="qbutton.html#12ce08">isOn</a>() )        <a name="repaint"></a><a href="qwidget.html#7569b1">repaint</a>( FALSE );               // and finally repaint, flicker-free}void <a name="304"></a>MagWidget::paintEvent( <a href="qpaintevent.html">QPaintEvent</a> * ){    if ( !pm.<a href="qpixmap.html#7803c4">isNull</a>() ) {        <a name="QPainter"></a><a href="qpainter.html">QPainter</a> paint( this );        paint.<a name="drawPixmap"></a><a href="qpainter.html#c64b89">drawPixmap</a>( 0, zoom ? zoom-&gt;<a href="qwidget.html#e3c588">height</a>()+4 : 0, pm,                               0,0, <a href="qwidget.html#2edab1">width</a>(), <a href="qwidget.html#e3c588">height</a>()-yoffset );    }}void <a name="305"></a>MagWidget::mousePressEvent( <a href="qmouseevent.html">QMouseEvent</a> *e ){    if ( !grabbing ) {          // prepare to grab...        grabbing = TRUE;        <a href="qobject.html#0ef111">killTimers</a>();        <a name="grabMouse"></a><a href="qwidget.html#5bdd5f">grabMouse</a>( crossCursor );        grabx = -1;        graby = -1;    } else {                    // REALLY prepare to grab        grabx = mapToGlobal(e-&gt;<a name="pos"></a><a href="qmouseevent.html#ac6f25">pos</a>()).x();        graby = mapToGlobal(e-&gt;<a href="qmouseevent.html#ac6f25">pos</a>()).y();    }}void <a name="306"></a>MagWidget::mouseReleaseEvent( <a href="qmouseevent.html">QMouseEvent</a> * e ){    if ( grabbing &amp;&amp; grabx &gt;= 0 &amp;&amp; graby &gt;= 0 ) {        grabbing = FALSE;        <a href=#307>grabAround</a>(e-&gt;<a href="qmouseevent.html#ac6f25">pos</a>());        <a name="releaseMouse"></a><a href="qwidget.html#369707">releaseMouse</a>();    }}void <a name="307"></a>MagWidget::grabAround(<a href="qpoint.html">QPoint</a> pos){    int rx, ry;    rx = mapToGlobal(pos).x();    ry = mapToGlobal(pos).y();    int w = QABS(rx-grabx);    int h = QABS(ry-graby);    if ( w &gt; 10 &amp;&amp; h &gt; 10 ) {        int pz;        pz = 1;        while ( w*pz*h*pz &lt; width()*(<a href="qwidget.html#e3c588">height</a>()-yoffset) &amp;&amp;                w*pz &lt; <a href="qapplication.html#d8ed8c">QApplication::desktop</a>()-&gt;width() &amp;&amp;                h*pz &lt; <a href="qapplication.html#d8ed8c">QApplication::desktop</a>()-&gt;height() )            pz++;        if ( (w*pz*h*pz - width()*(<a href="qwidget.html#e3c588">height</a>()-yoffset)) &gt;              (<a href="qwidget.html#2edab1">width</a>()*(<a href="qwidget.html#e3c588">height</a>()-yoffset) - w*(pz-1)*h*(pz-1)) )            pz--;        if ( pz &lt; 1 )            pz = 1;        if ( pz &gt; 8 )            pz = 8;        if ( zoom )            zoom-&gt;<a name="setCurrentItem"></a><a href="qcombobox.html#8a94f7">setCurrentItem</a>( pz-1 );        z = pz;        grabx = QMIN(rx, grabx) + w/2;        graby = QMIN(ry, graby) + h/2;        <a href="qwidget.html#8fcbbe">resize</a>( w*z, h*z+yoffset );    }    <a href=#303>grab</a>();    if ( r )        <a href="qobject.html#4c6b67">startTimer</a>( timer[r] );}void <a name="308"></a>MagWidget::mouseMoveEvent( <a href="qmouseevent.html">QMouseEvent</a> *e ){    if ( grabbing || pm.<a href="qpixmap.html#7803c4">isNull</a>() ||         e-&gt;<a href="qmouseevent.html#ac6f25">pos</a>().y() &gt; height() - (zoom ? zoom-&gt;<a href="qwidget.html#386569">fontMetrics</a>().height() - 4 : 0) ||         e-&gt;<a href="qmouseevent.html#ac6f25">pos</a>().y() &lt; (zoom ? zoom-&gt;<a href="qwidget.html#e3c588">height</a>()+4 : 4) ) {        rgb-&gt;<a href="qlabel.html#bc5ea6">setText</a>( "" );    } else {        int x,y;        x = e-&gt;<a href="qmouseevent.html#ac6f25">pos</a>().x() / z;        y = (e-&gt;<a href="qmouseevent.html#ac6f25">pos</a>().y() - ( zoom ? zoom-&gt;<a href="qwidget.html#e3c588">height</a>() : 0 ) - 4) / z;        <a href="qstring.html">QString</a> pixelinfo;        if ( image.<a name="valid"></a><a href="qimage.html#81538b">valid</a>(x,y) )        {            QRgb px = image.<a name="pixel"></a><a href="qimage.html#ecfb25">pixel</a>(x,y);            pixelinfo.<a name="sprintf"></a><a href="qstring.html#926f67">sprintf</a>(" %3d,%3d,%3d  #%02x%02x%02x",                <a name="qRed"></a><a href="qcolor.html#2f7325">qRed</a>(px), <a name="qGreen"></a><a href="qcolor.html#1cf303">qGreen</a>(px), <a name="qBlue"></a><a href="qcolor.html#c84970">qBlue</a>(px),                <a href="qcolor.html#2f7325">qRed</a>(px), <a href="qcolor.html#1cf303">qGreen</a>(px), <a href="qcolor.html#c84970">qBlue</a>(px));        }        <a href="qstring.html">QString</a> label;        label.<a href="qstring.html#926f67">sprintf</a>( "x=%d, y=%d %s",             x+grabx, y+graby, (const char*)pixelinfo );        rgb-&gt;<a href="qlabel.html#bc5ea6">setText</a>( label );    }}void <a name="309"></a>MagWidget::focusOutEvent( <a href="qfocusevent.html">QFocusEvent</a> * ){    rgb-&gt;<a href="qlabel.html#bc5ea6">setText</a>( "" );}void <a name="310"></a>MagWidget::timerEvent( <a href="qtimerevent.html">QTimerEvent</a> * ){    <a href=#303>grab</a>();/*    if ( multiSaveButton-&gt;<a href="qbutton.html#12ce08">isOn</a>() &amp;&amp; !multifn.<a href="qstring.html#c62623">isEmpty</a>() ) {        <a name="QRegExp"></a><a href="qregexp.html">QRegExp</a> num("[0-9][0-9]*");        int start;        int len;        if ((start=num.<a name="match"></a><a href="qregexp.html#f6e804">match</a>(multifn,0,&amp;len))&gt;=0)            multifn.<a name="replace"></a><a href="qstring.html#034e6e">replace</a>(num,                <a href="qstring.html">QString</a>().setNum(multifn.<a name="mid"></a><a href="qstring.html#3b1493">mid</a>(start,len).toInt()+1)            );        p.<a href="qpixmap.html#a38b1c">save</a>( multifn, "BMP" );    }*/}void <a name="311"></a>MagWidget::resizeEvent( <a href="qresizeevent.html">QResizeEvent</a> * ){    rgb-&gt;<a href="qwidget.html#9ede68">setGeometry</a>( 0, <a href="qwidget.html#e3c588">height</a>() - rgb-&gt;<a href="qwidget.html#e3c588">height</a>(), <a href="qwidget.html#2edab1">width</a>(), rgb-&gt;<a href="qwidget.html#e3c588">height</a>() );    <a href=#303>grab</a>();}#include "qmag.moc"int main( int argc, char **argv ){    <a name="QApplication"></a><a href="qapplication.html">QApplication</a> a( argc, argv );    MagWidget m;    a.<a name="setMainWidget"></a><a href="qapplication.html#7ad759">setMainWidget</a>( &amp;m );    m.<a name="show"></a><a href="qwidget.html#200ee5">show</a>();    return a.<a name="exec"></a><a href="qapplication.html#84c7bf">exec</a>();}</pre><p><address><hr><div align="center"><table width="100%" cellspacing="0" border="0"><tr><td>Copyright 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -