comparison dynamin/gui/control.d @ 23:d55b5b998412

Implement built-in mouse cursors with X.
author Jordan Miner <jminer7@gmail.com>
date Sat, 25 Jul 2009 14:58:43 -0500
parents 96b29f2efa4d
children 41b76c218851
comparison
equal deleted inserted replaced
22:9a50d6d96815 23:d55b5b998412
72 Cursor _cursor; 72 Cursor _cursor;
73 Container _parent; 73 Container _parent;
74 bool _elasticX, _elasticY; 74 bool _elasticX, _elasticY;
75 public: 75 public:
76 protected void dispatchMouseEntered(EventArgs e) { 76 protected void dispatchMouseEntered(EventArgs e) {
77 Cursor.setCurrent(this, _cursor); 77 setCurrentCursor(_cursor);
78 mouseEntered.callHandlers(e); 78 mouseEntered.callHandlers(e);
79 mouseEntered.callMainHandler(e); 79 mouseEntered.callMainHandler(e);
80 } 80 }
81 protected void dispatchMouseDown(MouseEventArgs e) { 81 protected void dispatchMouseDown(MouseEventArgs e) {
82 setCaptorControl(this); 82 setCaptorControl(this);
501 void font(Font f) { 501 void font(Font f) {
502 _font = f; 502 _font = f;
503 repaint(); 503 repaint();
504 } 504 }
505 505
506 void setCurrentCursor(Cursor cur) {
507 if(parent)
508 parent.setCurrentCursor(cur);
509 }
510 /**
511 * Gets or sets the mouse cursor that will be shown when the mouse
512 * is over this control.
513 */
506 Cursor cursor() { 514 Cursor cursor() {
507 return _cursor; 515 return _cursor;
508 } 516 }
517 /// ditto
509 void cursor(Cursor cur) { 518 void cursor(Cursor cur) {
510 if(_cursor is cur) 519 if(_cursor is cur)
511 return; 520 return;
512 _cursor = cur; 521 _cursor = cur;
513 if(getHotControl() is this) 522 if(getHotControl() is this)
514 Cursor.setCurrent(this, _cursor); 523 setCurrentCursor(_cursor);
515 } 524 }
516 525
517 /** 526 /**
518 * Causes the part of the control inside the specified 527 * Causes the part of the control inside the specified
519 * rectangle to be repainted. The rectangle is in content coordinates. 528 * rectangle to be repainted. The rectangle is in content coordinates.