File indexing completed on 2024-05-05 05:46:08

0001 /***************************************************************************
0002  *   Copyright (C) 2005 by David Saxton                                    *
0003  *   david@bluehaze.org                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  ***************************************************************************/
0010 
0011 #ifndef PUSHSWITCH_H
0012 #define PUSHSWITCH_H
0013 
0014 #include "component.h"
0015 
0016 /**
0017 @short Push-to-Break switch component
0018 @author David Saxton
0019 */
0020 class ECPTBSwitch : public Component
0021 {
0022 public:
0023     ECPTBSwitch(ICNDocument *icnDocument, bool newItem, const char *id = nullptr);
0024     ~ECPTBSwitch() override;
0025 
0026     static Item *construct(ItemDocument *itemDocument, bool newItem, const char *id);
0027     static LibraryItem *libraryItem();
0028 
0029     void buttonStateChanged(const QString &id, bool state) override;
0030     void dataChanged() override;
0031 
0032 private:
0033     void drawShape(QPainter &p) override;
0034     Switch *m_switch;
0035     bool pressed;
0036 };
0037 
0038 /**
0039 @short Push-to-make switch
0040 @author David Saxton
0041 */
0042 class ECPTMSwitch : public Component
0043 {
0044 public:
0045     ECPTMSwitch(ICNDocument *icnDocument, bool newItem, const char *id = nullptr);
0046     ~ECPTMSwitch() override;
0047 
0048     static Item *construct(ItemDocument *itemDocument, bool newItem, const char *id);
0049     static LibraryItem *libraryItem();
0050 
0051     void buttonStateChanged(const QString &id, bool state) override;
0052     void dataChanged() override;
0053 
0054 private:
0055     void drawShape(QPainter &p) override;
0056 
0057     Switch *m_switch;
0058     bool pressed;
0059 };
0060 
0061 #endif