00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "ArrowButton.hh"
00025
00026 ArrowButton::ArrowButton(ArrowButton::Type arrow_type,
00027 const FbTk::FbWindow &parent,
00028 int x, int y,
00029 unsigned int width, unsigned int height):
00030 FbTk::Button(parent, x, y, width, height),
00031 m_arrow_type(arrow_type),
00032 m_mouse_handler(0) {
00033
00034 setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask |
00035 EnterWindowMask | LeaveWindowMask);
00036 }
00037
00038 ArrowButton::ArrowButton(ArrowButton::Type arrow_type,
00039 int screen_num,
00040 int x, int y,
00041 unsigned int width, unsigned int height):
00042 FbTk::Button(screen_num, x, y, width, height),
00043 m_arrow_type(arrow_type),
00044 m_mouse_handler(0) {
00045
00046 setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask |
00047 EnterWindowMask | LeaveWindowMask);
00048 }
00049
00050 void ArrowButton::clear() {
00051 FbTk::Button::clear();
00052 drawArrow();
00053 }
00054
00055 void ArrowButton::exposeEvent(XExposeEvent &event) {
00056 FbTk::Button::exposeEvent(event);
00057 drawArrow();
00058 }
00059
00060 void ArrowButton::buttonPressEvent(XButtonEvent &event) {
00061 FbTk::Button::buttonPressEvent(event);
00062 drawArrow();
00063 }
00064
00065 void ArrowButton::buttonReleaseEvent(XButtonEvent &event) {
00066 FbTk::Button::buttonReleaseEvent(event);
00067 drawArrow();
00068 }
00069
00070 void ArrowButton::enterNotifyEvent(XCrossingEvent &ce) {
00071 if (m_mouse_handler)
00072 m_mouse_handler->enterNotifyEvent(ce);
00073 }
00074
00075 void ArrowButton::leaveNotifyEvent(XCrossingEvent &ce) {
00076 if (m_mouse_handler)
00077 m_mouse_handler->leaveNotifyEvent(ce);
00078 }
00079
00083 void ArrowButton::drawArrow() {
00084 XPoint pts[3];
00085 unsigned int w = width() / 2;
00086 unsigned int h = height() / 2;
00087 switch (m_arrow_type) {
00088 case LEFT:
00089 pts[0].x = w - 2; pts[0].y = h;
00090 pts[1].x = 4; pts[1].y = 2;
00091 pts[2].x = 0; pts[2].y = -4;
00092 break;
00093 case RIGHT:
00094 pts[0].x = w - 2; pts[0].y = h - 2;
00095 pts[1].x = 4; pts[1].y = 2;
00096 pts[2].x = -4; pts[2].y = 2;
00097 break;
00098 case UP:
00099 break;
00100 case DOWN:
00101 break;
00102 }
00103
00104 if (gc() != 0) {
00105 fillPolygon(gc(),
00106 pts, 3,
00107 Convex, CoordModePrevious);
00108 }
00109 }
00110