news download themes documentation links










ArrowButton.cc

00001 // ArrowButton.cc for Fluxbox Window Manager
00002 // Copyright (c) 2002-2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
00003 //
00004 // Permission is hereby granted, free of charge, to any person obtaining a
00005 // copy of this software and associated documentation files (the "Software"),
00006 // to deal in the Software without restriction, including without limitation
00007 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008 // and/or sell copies of the Software, and to permit persons to whom the
00009 // Software is furnished to do so, subject to the following conditions:
00010 //
00011 // The above copyright notice and this permission notice shall be included in
00012 // all copies or substantial portions of the Software.
00013 //
00014 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00017 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00018 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00019 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00020 // DEALINGS IN THE SOFTWARE.
00021 
00022 // $Id: ArrowButton.cc,v 1.5 2003/10/13 23:51:04 fluxgen Exp $
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: // TODO
00099         break;
00100     case DOWN: // TODO
00101         break;
00102     }
00103 
00104     if (gc() != 0) {
00105         fillPolygon(gc(),
00106                     pts, 3, 
00107                     Convex, CoordModePrevious);
00108     }
00109 }
00110 

Fluxbox CVS-Jan-2003




      



Got comments about the page? Send them to webmaster.
If you have general Fluxbox related questions ask them on our irc channel or mailing lists.

Show Source








Designed by aLEczapKA