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

📄 kmenubar.cpp

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  {    //bool aha = isVisible(); // did app enable show?      setMenuBarPos(FloatingSystem);      Parent->removeEventFilter(this); //One time only      return false;  }  if (mgr)    return true;  if (ob == handle){    if (ev->type() == Event_MouseButtonPress)    {      if (standalone_menubar)      {        //Dunno but krootwm does this; without it menu stays...        XUngrabPointer(qt_xdisplay(), CurrentTime);        XSync(qt_xdisplay(), False);        QString x,y;        x.setNum(pos().x());        y.setNum(pos().y()+height());        while (x.length()<4)          x.prepend("0");        while (y.length()<4)          y.prepend("0");        //if (((QMouseEvent*)ev)->button() == LeftButton)          KWM::sendKWMCommand(QString("kpanel:go")+x+y);        //else        //  KWM::sendKWMCommand(QString("krootwm:go")+x+y);        return false; //or true? Bah...      }      if ( moving && ((QMouseEvent*)ev)->button() == RightButton)	{	  context->popup( handle->mapToGlobal(((QMouseEvent*)ev)->pos()), 0 );	  ContextCallback(0);	}      else if (((QMouseEvent*)ev)->button() == MidButton &&               position != Floating)        setFlat (position != Flat);      else if (((QMouseEvent*)ev)->button() == LeftButton)        toggleFlatOnRelease=true;      return TRUE;    }    if (ev->type() == Event_MouseMove &&        ((QMouseEvent*) ev)->state() == LeftButton &&        toggleFlatOnRelease)      {        toggleFlatOnRelease = false;        //Move now        QRect rr(Parent->geometry());        int ox = rr.x();        int oy = rr.y();        int ow = rr.width();        int oh = rr.height();        int  fat = 25; //ness        mgr = new KToolBoxManager(this, transparent);        mgr->addHotSpot(ox, oy, ow, fat);           // top        mgr->addHotSpot(ox, oy+oh-fat, ow, fat);    // bottom        movePosition = position;        connect (mgr, SIGNAL(onHotSpot(int)), SLOT(slotHotSpot(int)));        if (transparent)          mgr->doMove(true, false, true);        else        {          mgr->doMove(true, false, false);        }        if (transparent)        {          setMenuBarPos (movePosition);          if (movePosition == Floating)            move (mgr->x(), mgr->y());          if (!isVisible())            show();        }        delete mgr;        mgr=0;        handle->repaint(false);        //debug ("KMenuBar: moving done");        return true; // Or false? Never knew what evFilter returns...      }    if (ev->type() == Event_MouseButtonRelease)      {	if (mgr)          mgr->stop();        if (toggleFlatOnRelease && position != Floating)          setFlat (position != Flat);        toggleFlatOnRelease = false;        return TRUE;      }    if ((ev->type() == Event_Paint)||(ev->type() == Event_Enter)||(ev->type() == Event_Leave) ){      QColorGroup g = QWidget::colorGroup();      QPainter paint(handle);      QBrush b = QWidget::backgroundColor();      if (standalone_menubar)      {        if ( style() == WindowsStyle )          qDrawWinButton( &paint, 0, 0, handle->width(), handle->height(),                          g, false );        else          qDrawShadePanel( &paint, 0, 0, handle->width(), handle->height(),                           g, false, 1, 0L );        if (miniGo)        {          int dx = ( handle->width() - miniGo->width() ) / 2;          int dy = ( handle->height() - miniGo->height() ) / 2;          paint.drawPixmap( dx, dy, *miniGo);        }        return true;      }      int stipple_height;      if (ev->type() == Event_Enter && highlight) // highlight? - sven        b = kapp->selectColor; // this is much more logical then                               // the hardwired value used before!!      //else      //  b = QWidget::backgroundColor();      int h = handle->height();      int w = handle->width();      if (style() == MotifStyle) //Motif style handle      {        if (position == Flat)        {          qDrawShadePanel( &paint, 0, 0, w, 9,			   g , FALSE, 1, &b );	  paint.setPen( g.light() );          stipple_height = 3;          while ( stipple_height < w-4 ) {            paint.drawPoint( stipple_height+1, 1);            paint.drawPoint( stipple_height, 4 );            stipple_height+=3;          }          paint.setPen( g.dark() );          stipple_height = 4;          while ( stipple_height < w-4 ) {            paint.drawPoint( stipple_height+1, 2 );            paint.drawPoint( stipple_height, 5);            stipple_height+=3;	  }	  paint.drawLine( 1, 9, w, 9);          return true;        }        qDrawShadePanel( &paint, 0, 0, 9, h,                           g , FALSE, 1, &b );        paint.setPen( g.light() );        stipple_height = 3;        while ( stipple_height < h-4 ) {          paint.drawPoint( 1, stipple_height+1);          paint.drawPoint( 4, stipple_height);          stipple_height+=3;        }        paint.setPen( g.dark() );        stipple_height = 4;        while ( stipple_height < h-4 ) {          paint.drawPoint( 2, stipple_height+1);          paint.drawPoint( 5, stipple_height);          stipple_height+=3;        }        return TRUE;      }      else //windows style handle      {        if (position == Flat)        {          qDrawPlainRect ( &paint, 0, 0, handle->width(), 9,                           g.mid(), 0, &b);          h = 16;          paint.setClipRect(2, 0, w-4, 6);          paint.setPen( g.light() );          int a = 0-h;          while (a <= w+h)          {            paint.drawLine(w-a, h, w-a+h, 0);            paint.drawLine(w-a+1, h, w-a+1+h, 0);            a +=6;          }          a = 0-h;          paint.setPen( g.dark() );          while (a <= w+h)          {            paint.drawLine(w-a+2, h, w-a+2+h, 0);            paint.drawLine(w-a+3, h, w-a+3+h, 0);            a +=6;          }         return true;        }        qDrawPlainRect ( &paint, 0, 0, 6, handle->height(),                         g.mid(), 0, &b);        w=6;        paint.setClipRect(0, 2, w, h-4);        paint.setPen( g.light() );        int a=0-w;        while (a <= h+5)        {          paint.drawLine(0, h-a, h, 0-a);          paint.drawLine(0, h-a+1, h, 0-a+1);          a +=6;        }        a=0-w;        paint.setPen( g.dark() );        while (a <= h+5)        {          paint.drawLine(0, h-a+2, h, 0-a+2);          paint.drawLine(0, h-a+3, h, 0-a+3);          a +=6;        }        return TRUE;      }    }  }  return FALSE;}void KMenuBar::enableMoving(bool flag){  moving = flag;}void KMenuBar::setMenuBarPos(menuPosition mpos){    if (position == FloatingSystem && standalone_menubar == true) {	return; // Ignore positioning of Mac menubar    }  if (position != mpos)   {     if (mpos == Floating || mpos == FloatingSystem)      {	  lastPosition = position;	  position = mpos;	  oldX = x();	  oldY = y();	  if ( mpos == FloatingSystem && position == Floating)	      lastPosition = Top;	  else	      oldWFlags = getWFlags();	  QPoint p = mapToGlobal(QPoint(0,0));	  parentOffset = pos();	  hide();	  recreate(0, 0,		   p, FALSE);	  XSetTransientForHint( qt_xdisplay(), winId(), Parent->topLevelWidget()->winId());	  if (mpos == FloatingSystem)	      KWM::setDecoration(winId(), KWM::noDecoration | KWM::standaloneMenuBar | KWM::noFocus);	  else	      KWM::setDecoration(winId(), KWM::tinyDecoration | KWM::noFocus);	  KWM::moveToDesktop(winId(), KWM::desktop(Parent->winId()));	  setCaption(""); // this triggers a qt bug	  if (title){	      setCaption(title);	  }	  else {	      QString s = Parent->caption();	      s.append(" [menu]");	      setCaption(s);	  }	  setFrameStyle( NoFrame);	  if (mpos == FloatingSystem)	      {		  if (style() == MotifStyle)		      menu->setFrameStyle(Panel | Raised);		  else		      menu->setFrameStyle(WinPanel | Raised) ;	      }	  else	      menu->setFrameStyle( NoFrame) ;	  context->changeItem (klocale->translate("UnFloat"), CONTEXT_FLOAT);			if (mpos == FloatingSystem) {	    QRect r =  KWM::getWindowRegion(KWM::currentDesktop());	    setGeometry(r.x(),(r.y()-1)<=0?-2:r.y()-1, r.width(), // check panel top			heightForWidth(r.width()));	    int dim = fontMetrics().height();	    if (!miniGo)		miniGo = new QPixmap(kapp->kde_datadir() + "/kpanel/pics/mini/go.xpm");		    QPixmap px(KWM::miniIcon(Parent->winId(), dim, dim));	    if (!px.isNull())		*miniGo = px;	    show();	}        emit moved (mpos);//        if (style() == MotifStyle)//          menu->setMouseTracking(false);//        else//          menu->setMouseTracking(true);//----------------------------------------------------------------------------        // Repair repaired Accelerators (Eh, those Trolls...)        QObjectList	*accelerators = queryList( "QAccel" );        QObjectListIt it( *accelerators );        QObject *obj;        while ( (obj=it.current()) != 0 )        {          ++it;          this->removeEventFilter(obj); //Man...          disconnect( this, SIGNAL(destroyed()), obj, SLOT(tlwDestroyed()));          Parent->installEventFilter(obj);          connect( Parent, SIGNAL(destroyed()), obj, SLOT(tlwDestroyed()));        }//----------------------------------------------------------------------------        return;      }     else if (position == Floating || position == FloatingSystem) // was floating      {        position = mpos;        hide();	setFrameStyle(NoFrame);	menu->setFrameStyle(oldMenuFrameStyle);        recreate(Parent, oldWFlags, QPoint(oldX, oldY), TRUE);        context->changeItem (klocale->translate("Float"), CONTEXT_FLOAT);        emit moved (mpos);        if (style() == MotifStyle)        {//          menu->setMouseTracking(false);          menu->setFrameStyle(Panel | Raised);        }        else        {//          menu->setMouseTracking(true);          menu->setFrameStyle(NoFrame);        }        return;      }     else      {        if (mpos == Flat)        {          setFlat (true);          return;        }        enableFloating (true);        position = mpos;        emit moved ( mpos );        return;      }   }}void KMenuBar::enableFloating (bool arrrrrrgh){  context->setItemEnabled (CONTEXT_FLOAT, arrrrrrgh);}/*******************************************************/uint KMenuBar::count(){  return menu->count();}int KMenuBar::insertItem(const char *text,               const QObject *receiver, const char *member,               int accel){  return menu->insertItem(text, receiver, member, accel);}int KMenuBar::insertItem( const char *text, int id, int index){  return menu->insertItem(text, id, index);}int KMenuBar::insertItem( const char *text, QPopupMenu *popup,                          int id, int index){  return menu->insertItem(text, popup, id, index);}/* Later - should be virtual and I can't do it right now - svenint KMenuBar::insertItem (const QPixmap &pixmap, const QObject *receiver,                          const char *member, int accel){  return->menu->insertItem (pixmap, receiver, member, accel);}*/void KMenuBar::insertSeparator(int index){  menu->insertSeparator(index);}void KMenuBar::removeItem( int id ){  menu->removeItem(id);}void KMenuBar::removeItemAt( int index ){  menu->removeItemAt(index);}void KMenuBar::clear(){  menu->clear();}int KMenuBar::accel( int id ){  return menu->accel(id);}void KMenuBar::setAccel( int key, int id ){  menu->setAccel(key, id);}const char *KMenuBar::text( int id ){  return menu->text(id);}void KMenuBar::changeItem( const char *text, int id ){  menu->changeItem(text, id);}void KMenuBar::setItemChecked(int id , bool flag){  menu->setItemChecked(id , flag);}void KMenuBar::setItemEnabled(int id, bool flag){  menu->setItemEnabled(id, flag);}void KMenuBar::slotActivated (int id){  emit activated(id);}void KMenuBar::slotHighlighted (int id){  emit highlighted (id);}void KMenuBar::setFlat (bool flag){#define also  if (flag && ((position == Floating  || position == FloatingSystem) && position == Flat))    return;  if (!flag && (position != Flat))    also return;  if (flag) //flat  {    lastPosition = position; // test float. I did and it works by miracle!?    //debug ("Flat");    position = Flat;    resize(30, 10);    handle->resize(30, 10);    frame->move(100, 100); // move menubar out of sight    enableFloating(false);    emit moved(Flat); // KTM will block this->updateRects  }  else //unflat  {    //debug ("Unflat");    setMenuBarPos(lastPosition);    enableFloating(true);    emit moved (position); // KTM will call this->updateRects  }}#include "kmenubar.moc"

⌨️ 快捷键说明

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