📄 abstractx11control.cpp
字号:
eventHandled = true; } } break; case ButtonRelease : { currentKeyState_ = x11Event->xbutton.state; currentButtonState_ = x11Event->xbutton.button; if ( false == enabled_ ) { //skip the event handling eventHandled = true; } } break; case MotionNotify : { currentKeyState_ = x11Event->xmotion.state; if ( false == enabled_ ) { //skip the event handling eventHandled = true; } } break; case EnterNotify : case LeaveNotify : { MouseEvent* mouseEvent = reinterpret_cast<MouseEvent*>( event ); MouseEvent* newEvent = new MouseEvent( event->getSource(), event->getType(), toolkit->translateButtonMask( currentButtonState_ ), toolkit->translateKeyMask( currentKeyState_ ), mouseEvent->getPoint() ); delete event; event = newEvent; if ( false == enabled_ ) { //skip the event handling eventHandled = true; } } break; case FocusIn : { if ( false == enabled_ ) { //skip the event handling eventHandled = true; } } break; case FocusOut : { if ( false == enabled_ ) { //skip the event handling eventHandled = true; } } break; case NoExpose : { } break; /* case VisibiltyNotify : { printf( "event VisibiltyNotify...\n" ); }control_->handleEvent( event ); break; */ case CreateNotify : { } break; case DestroyNotify : { control_->handleEvent( event ); AbstractX11Control::unRegisterX11Control( this ); //printf( "Destroy of %p in progress, notified Control: %s @ %p, and removed from event map...\n", // this, typeid(*control_).name(), control_ ); eventHandled = true; wndHandle_ = NULL; } break; case UnmapNotify : { } break; case MapNotify : { } break; case MapRequest : { } break; case ReparentNotify : { } break; case ConfigureNotify : { if ( false == enabled_ ) { //skip the event handling eventHandled = true; } else { int x = (int)bounds_.left_; int y = (int)bounds_.top_; int w = (int)bounds_.getWidth(); int h = (int)bounds_.getHeight(); bounds_.left_ = x11Event->xconfigure.x; bounds_.top_ = x11Event->xconfigure.y; bounds_.right_ = bounds_.left_ + (double)x11Event->xconfigure.width; bounds_.bottom_ = bounds_.top_ + (double)x11Event->xconfigure.height; /* printf( "ConfigureNotify: %p, %s\n\tx: %d, y: %d, w: %d, h: %d\n", wndHandle_, typeid(*control_).name(), x11Event->xconfigure.x , x11Event->xconfigure.y,x11Event->xconfigure.width, x11Event->xconfigure.height); printf( "\tbounds: %d, %d, %d, %d\n", x,y,w,h ); */ //if ( (x != x11Event->xconfigure.x) || (y != x11Event->xconfigure.y) ) { VCF::Point pt( x11Event->xconfigure.x , x11Event->xconfigure.y ); ControlEvent moveEvent( control_, pt ); control_->handleEvent( &moveEvent ); eventHandled = true; //} //if ( (w != x11Event->xconfigure.width) || (h != x11Event->xconfigure.height) ) { VCF::Size sz( x11Event->xconfigure.width, x11Event->xconfigure.height ); ControlEvent sizeEvent( control_, sz ); control_->handleEvent( &sizeEvent ); eventHandled = true; //} } } break; case GravityNotify : { } break; case ResizeRequest : { } break; case ConfigureRequest : { } break; case CirculateNotify : { } break; case CirculateRequest : { } break; case PropertyNotify : { } break; case SelectionClear : { } break; case SelectionRequest : { } break; case SelectionNotify : { } break; case ColormapNotify : { } break; case ClientMessage : { X11UIToolkit* toolkit = reinterpret_cast<X11UIToolkit*>( UIToolkit::getDefaultUIToolkit() ); if ( false == enabled_ ) { //skip the event handling eventHandled = true; } else { } } break; case MappingNotify : { } break; case KeymapNotify : { } break; } if ( (!eventHandled) && (NULL != event) ) { control_->handleEvent( event ); } if ( NULL != event ) { delete event; event = NULL; }}void AbstractX11Control::handlePaintEvent(){ GraphicsContext* gc = control_->getContext(); if ( updateRects_.empty() ) { return; } std::vector<Rect>::iterator it = updateRects_.begin(); Rect clipBounds = updateRects_.front(); while ( it != updateRects_.end() ) { Rect& r = *it; clipBounds.left_ = minVal<double>( clipBounds.left_, r.left_ ); clipBounds.top_ = minVal<double>( clipBounds.top_, r.top_ ); clipBounds.right_ = maxVal<double>( clipBounds.right_, r.right_ ); clipBounds.bottom_ = maxVal<double>( clipBounds.bottom_, r.bottom_ ); it ++; } clipBounds.normalize(); if ( (clipBounds.getHeight() <= 0.0) || (clipBounds.getWidth() <= 0.0) ) { return; } //printf( "%s clipBounds: %s\n", typeid(*control_).name(), clipBounds.toString().c_str() ); //GraphicsContext gc2(clipBounds.getWidth(), clipBounds.getHeight() ); //gc2.setOrigin( -clipBounds.left_, -clipBounds.top_ ); //gc->setClippingRect( &clipBounds ); gc->getPeer()->setContextID(wndHandle_); control_->paint( gc ); //gc->setClippingRect( &Rect(0,0,0,0) ); //gc2.setOrigin( 0, 0 ); //gc->copyContext( clipBounds.left_, clipBounds.top_, &gc2 ); updateRects_.clear();}void AbstractX11Control::addUpdateRect( const Rect& updateRect ){ updateRects_.push_back( updateRect );}/***CVS Log info*$Log$*Revision 1.2 2004/08/07 02:49:05 ddiego*merged in the devmain-0-6-5 branch to stable**Revision 1.1.2.2 2004/04/29 03:43:12 marcelloptr*reformatting of source files: macros and csvlog and copyright sections**Revision 1.1.2.1 2004/04/28 00:28:13 ddiego*migration towards new directory structure**Revision 1.4 2003/12/18 05:16:01 ddiego*merge from devmain-0-6-2 branch into the stable branch**Revision 1.3.4.2 2003/10/28 20:23:26 ddiego*minor header changes**Revision 1.3.4.1 2003/08/18 19:52:38 ddiego*changed the Container from being a class you derive from to a separate*intance that is created and assigned dynamically to any Control.**Revision 1.3 2003/05/17 20:37:31 ddiego*this is the checkin for the 0.6.1 release - represents the merge over from*the devmain-0-6-0 branch plus a few minor bug fixes**Revision 1.2.2.2 2003/03/23 03:23:56 marcelloptr*3 empty lines at the end of the files**Revision 1.2.2.1 2003/03/12 03:12:17 ddiego*switched all member variable that used the "m_"<name> prefix to* <name>"_" suffix nameing standard.*Also changed all vcf builder files to accomadate this.*Changes were made to the Stream classes to NOT multiple inheritance and to*be a little more correct. Changes include breaking the FileStream into two*distinct classes, one for input and one for output.**Revision 1.2 2003/02/26 04:30:47 ddiego*merge of code in the devmain-0-5-9 branch into the current tree.*most additions are in the area of the current linux port, but the major*addition to this release is the addition of a Condition class (currently*still under development) and the change over to using the Delegate class*exclusively from the older event handler macros.**Revision 1.1.2.15 2003/02/03 05:22:54 ddiego*added support for command types to the PuchButton class*added support for clicks in the PuchButton class to auto close a dialog*if it is parented to one, similar to the CommandButton. This is part of the*gradual phase out of the CommandButton class*Add supprt for drawing a focus rect in the PushButton class*plugged in tabbing bahaviour to the X11UIToolkit. It seems as though*"Shift" + "Tab" is not being picked up properly*Finished implementing the X11Dialog::showMessage(String,String) method*and also add some finishing touches to teh X11Dialog so it displays correctly*Add some finishing touches to the X11UIToolkit::runModalEventLoop() as well**Revision 1.1.2.14 2003/02/02 04:56:40 ddiego*fixed a bug in AbstractX11Control::getBounds() that was incorrectly setting the bounds reported*by XGetGeometry - the error was due to adding a negative int and an unsigned int together! Ooops*The problem was manifewsting itself in the TabbedPages control with it's scroll buttons.*Changed PushButton to be a heavyweight control**Revision 1.1.2.13 2003/01/27 05:04:02 ddiego*more X11 work fixed up some stuff for modal event loop and added X11Dialog*class. not ready to work yet**Revision 1.1.2.12 2003/01/19 20:18:21 ddiego*changes to try and optimize painting. didn't work for this go around :(**Revision 1.1.2.11 2003/01/19 03:11:59 ddiego*misc coding fixes, added x11 error handler**Revision 1.1.2.10 2003/01/16 04:46:53 ddiego*added support for default X11 cursors*added support for translating coordinates from screen to client*and client to screen, where the screen is the RootWindow**Revision 1.1.2.9 2003/01/13 04:57:03 ddiego*added a fix for the X11COntext::gettextWidth and Height, now returns correct values*static makefile for the various kits is now ready to use for all*AbstractX11Controll::keepMouseEvents is now working correctly**Revision 1.1.2.8 2003/01/11 23:17:25 ddiego*added extra functionality to the static makefile in vcf/build/make*added some bug fixes to X11**Revision 1.1.2.7 2003/01/08 03:49:18 ddiego*fixes to ensure that move and size events get sent properly. Not sure*I am happy with how it is currently working. Fix to X11Cursor so that the cursorID*has a valid initial value.**Revision 1.1.2.6 2003/01/04 06:12:24 ddiego*fixed a crash in X11GraphicsToolkit - an error in how colors were being freed*added support for titles, getting the focus control, and grabbing the mouse !**Revision 1.1.2.5 2003/01/03 05:43:02 ddiego*added some tune ups to the event loop method in the X11UIToolkit*added code for closing a window and destroying child peers*trying to track down why a core dump happens in the ApplicationKit::terminate*method - seems to be due to bad pointers? Very very annoying....**Revision 1.1.2.4 2003/01/02 04:07:46 ddiego*adding more event support, plus added further Font implementation**Revision 1.1.2.3 2003/01/01 05:06:29 ddiego*changes start propagating VCF::Event instances back into the main Control*event loop from native X11 events.**Revision 1.1.2.2 2002/12/31 07:02:19 ddiego*trying to track issues with parenting in X. Made some fixes in the Color class*and the ContextPeer class to work in gcc/X**Revision 1.1.2.1 2002/12/30 03:59:25 ddiego*more X11 porting code. Now have X11UIToolkit::runEventLoop partially implemented*Can create and paint in a Window object! Woo hoo!*Color class is crurently broken on linux, will fix pronto*Auto generated C++ implementation for class AbstractX11Control*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -