27 #ifndef _ginteractor_h 28 #define _ginteractor_h 31 #include <QReadWriteLock> 35 #include "gobservable.h" 45 class _Internal_QWidget;
178 virtual
int getID() const;
193 virtual _Internal_QWidget* getInternalWidget() const = 0;
226 virtual
char getMnemonic() const
(deprecated);
275 virtual QWidget* getWidget() const = 0;
286 virtual
double getX() const;
292 virtual
double getY() const;
297 virtual
bool inBounds(
double x,
double y) const;
302 virtual
bool inBounds(
int x,
int y) const;
408 virtual
void setBounds(
double x,
double y,
double width,
double height);
473 virtual
void setFont(const QFont& font);
480 virtual
void setFont(const
std::
string& font);
509 virtual
void setIcon(const QIcon& icon);
516 virtual
void setIcon(const QPixmap& icon);
526 virtual
void setIcon(const
std::
string& filename,
bool retainIconSize = true);
571 virtual
void setMnemonic(
char mnemonic)
(deprecated);
593 virtual
void setName(const
std::
string& name);
635 virtual
void setSize(
double width,
double height);
663 virtual
void setWidth(
double width);
671 virtual
void setX(
double x);
679 virtual
void setY(
double y);
685 std::
string _actionCommand;
690 std::
string _actionEventType;
715 QReadWriteLock _lock;
720 static QWidget* getInternalParent(QWidget* parent);
725 virtual
std::
string getActionEventType() const;
730 virtual
std::
string getDefaultInteractorName() const;
735 virtual
void lockForRead();
740 virtual
void lockForReadConst() const;
745 virtual
void lockForWrite();
750 virtual
void lockForWriteConst() const;
755 static
std::
string normalizeAccelerator(const
std::
string& accelerator);
760 virtual
void setContainer(
GContainer* container);
765 virtual
void unlock();
770 virtual
void unlockConst() const;
775 friend class _Internal_QWidget;
778 static
int _interactorCount;
789 class _Internal_QWidget {
792 virtual ~_Internal_QWidget();
793 virtual void detach();
795 virtual bool hasMinimumSize()
const;
797 virtual bool hasPreferredSize()
const;
816 template <
typename T>
819 GGenericInteractor(T* widget)
821 _iqwidget =
new _Internal_QWidget();
824 _Internal_QWidget* getInternalWidget()
const override {
828 string
getType()
const override {
829 string typeName =
typeid(T).name();
830 return string(
"GGenericInteractor<") + typeName +
">";
833 QWidget* getWidget()
const override {
838 _Internal_QWidget* _iqwidget;
844 #endif // _ginteractor_h A GContainer is a logical grouping for interactors.
Definition: gcontainer.h:73
This class represents a graphics window that supports simple graphics.
Definition: gwindow.h:102
bool eventsEnabled() const override
Returns true if this interactor is currently accepting events.
Definition: ginteractor.cpp:63
This struct contains real-valued x, y, width, and height fields.
Definition: gtypes.h:293
virtual string getFont() const
Returns the font of this interactor's text as a font string such as "Helvetica-12-Bold".
Definition: ginteractor.cpp:112
TextPosition
The places where an interactor can place its text relative to its icon.
Definition: ginteractor.h:57
virtual void requestFocus()
Transfers keyboard focus to this interactor.
Definition: ginteractor.cpp:280
virtual double getMinimumWidth() const
Returns the minimum width in pixels that this interactor will permit itself to be resized to...
Definition: ginteractor.cpp:155
virtual GDimension getMinimumSize() const
Returns a GDimension structure representing the minimum size in pixels that this interactor will perm...
Definition: ginteractor.cpp:150
virtual void setY(double y)
Sets the onscreen y-coordinate of the top-left corner of the interactor relative to its window...
Definition: ginteractor.cpp:585
virtual void setSize(double width, double height)
Sets the onscreen width and height of the interactor in pixels.
Definition: ginteractor.cpp:545
virtual int getBackgroundInt() const
Returns the background color of the interactor as an RGB integer.
Definition: ginteractor.cpp:85
GInteractor()
Initializes a newly created interactor.
Definition: ginteractor.cpp:43
virtual void setTooltip(string tooltipText)
Sets a "tooltip" that will appear if the user hovers their mouse over the interactor.
Definition: ginteractor.cpp:560
virtual void setForeground(int rgb)
Sets the foreground/text color of the interactor to the color represented by the given RGB integer...
Definition: ginteractor.cpp:405
friend class GDiffGui
Definition: ginteractor.h:773
virtual void setFont(const QFont &font)
Sets the font used by this widget to the given Qt font.
Definition: ginteractor.cpp:429
virtual void removeDoubleClickListener()
Removes the double-click listener from this interactor so that it will no longer call it when events ...
Definition: ginteractor.cpp:258
virtual void setPreferredHeight(double height)
Sets the height in pixels that this interactor would prefer to be.
Definition: ginteractor.cpp:523
virtual void setKeyListener(GEventListener func)
Sets a key listener on this interactor so that it will be called when the user presses any key...
Definition: ginteractor.cpp:460
virtual void addActionListener() (deprecated)
Adds an event listener to be notified when this interactor is clicked or generally interacted with...
Definition: ginteractor.cpp:59
virtual int getForegroundInt() const
Returns the foreground/text color of the interactor as an RGB integer.
Definition: ginteractor.cpp:121
virtual void setIcon(const QIcon &icon)
Sets the icon associated with this interactor.
Definition: ginteractor.cpp:446
virtual double getHeight() const
Returns the current onscreen height of this interactor in pixels.
Definition: ginteractor.cpp:126
virtual bool isEnabled() const
Returns true if this interactor is currently enabled.
Definition: ginteractor.cpp:214
virtual string getForeground() const
Returns the foreground/text color of the interactor as a string.
Definition: ginteractor.cpp:116
virtual double getPreferredWidth() const
Returns the height in pixels that this interactor would prefer to be, which would exactly fit its con...
Definition: ginteractor.cpp:186
virtual string getActionCommand() const
Returns an action command for this interactor, which is a semi-unique string you can use to identify ...
Definition: ginteractor.cpp:72
virtual void setClickListener(GEventListener func)
Sets a mouse listener on this interactor so that it will be called when the mouse is clicked on it...
Definition: ginteractor.cpp:362
virtual GDimension getSize() const
Returns a GDimension structure storing the current onscreen width and height of this interactor in pi...
Definition: ginteractor.cpp:190
virtual void removeMouseListener()
Removes the mouse listener from this interactor so that it will no longer call it when events occur...
Definition: ginteractor.cpp:268
virtual double getMinimumHeight() const
Returns the minimum height in pixels that this interactor will permit itself to be resized to...
Definition: ginteractor.cpp:146
virtual double getWidth() const
Returns the current onscreen width of this interactor in pixels.
Definition: ginteractor.cpp:194
virtual void setHeight(double height)
Sets the onscreen height of the interactor in pixels.
Definition: ginteractor.cpp:439
virtual GDimension getPreferredSize() const
Returns a GDimension structure storing the width and height in pixels that this interactor would pref...
Definition: ginteractor.cpp:176
std::function< void(GEvent)> GEventListener
Types for the event listener functions to be passed to various interactors.
Definition: gevent.h:38
This abstract class is the superclass for all graphical interactors.
Definition: ginteractor.h:52
virtual void setPreferredWidth(double width)
Sets the width in pixels that this interactor would prefer to be.
Definition: ginteractor.cpp:541
virtual string getIcon() const
Returns the file name of the icon associated with this interactor, or an empty string if no icon has ...
Definition: ginteractor.cpp:134
virtual void setName(string name)
Sets a string representing a unique name for this interactor.
Definition: ginteractor.cpp:518
virtual ~GInteractor()
Frees memory allocated internally by the interactor.
Definition: ginteractor.cpp:55
virtual int getColorInt() const
Returns the foreground/text color of the interactor as an RGB integer.
Definition: ginteractor.cpp:99
virtual string getName() const
Returns a string representing a unique name for this interactor.
Definition: ginteractor.cpp:164
string getType() const override=0
Returns a string representing the class name of this interactor, such as "GButton" or "GCheckBox"...
virtual double getPreferredHeight() const
Returns the height in pixels that this interactor would prefer to be, which would exactly fit its con...
Definition: ginteractor.cpp:172
virtual void setBackground(int rgb)
Sets the background color of the interactor to the color represented by the given RGB integer...
Definition: ginteractor.cpp:302
virtual void setMouseListener(GEventListener func)
Sets a mouse listener on this interactor so that it will be called when the mouse is moved or clicked...
Definition: ginteractor.cpp:494
virtual void setX(double x)
Sets the onscreen x-coordinate of the top-left corner of the interactor relative to its window...
Definition: ginteractor.cpp:581
virtual void setEnabled(bool value)
Sets whether this interactor is currently enabled.
Definition: ginteractor.cpp:399
virtual GPoint getLocation() const
Returns an (x, y) point representing the onscreen location of the top-left corner of this interactor ...
Definition: ginteractor.cpp:138
std::function< void()> GEventListenerVoid
Types for the event listener functions to be passed to various interactors.
Definition: gevent.h:44
virtual GRectangle getBounds() const
Returns a rectangle representing the x/y position and size of this interactor.
Definition: ginteractor.cpp:90
virtual bool isVisible() const
Returns true if the interactor is visible on the screen.
Definition: ginteractor.cpp:218
virtual GContainer * getContainer() const
Returns a pointer to the onscreen container holding this interactor.
Definition: ginteractor.cpp:104
A GObservable object is one that is able to send out events.
Definition: gobservable.h:40
virtual void removeKeyListener()
Removes the key listener from this interactor so that it will no longer call it when key events occur...
Definition: ginteractor.cpp:262
virtual string getBackground() const
Returns the background color of the interactor as a string.
Definition: ginteractor.cpp:80
This struct contains real-valued width and height fields.
Definition: gtypes.h:43
virtual void setDoubleClickListener(GEventListener func)
Sets a mouse listener on this interactor so that it will be called when the mouse is double-clicked o...
Definition: ginteractor.cpp:391
virtual bool inBounds(double x, double y) const
Returns true if the given x/y pixel is within the bounds of this interactor.
Definition: ginteractor.cpp:206
Definition: ginteractor.h:59
virtual double getY() const
Returns the y-coordinate of the top-left pixel of this interactor within its onscreen window...
Definition: ginteractor.cpp:202
virtual int getID() const
Returns a globally unique identifier for this interactor, which is set when the interactor is constru...
Definition: ginteractor.cpp:130
virtual void setPreferredSize(double width, double height)
Sets the width and height in pixels that this interactor would prefer to be.
Definition: ginteractor.cpp:527
virtual void setAccelerator(string accelerator)
Sets an accelerator hotkey for this interactor, such as "Ctrl-S".
Definition: ginteractor.cpp:290
Definition: ginteractor.h:60
virtual void setBounds(double x, double y, double width, double height)
Sets the size and location of the widget.
Definition: ginteractor.cpp:351
virtual void setActionListener(GEventListener func)
Sets an action listener on this interactor so that it will be called when it is interacted with in it...
Definition: ginteractor.cpp:294
virtual void setActionCommand(string actionCommand)
Sets the action command for this interactor.
Definition: ginteractor.cpp:286
virtual double getX() const
Returns the x-coordinate of the top-left pixel of this interactor within its onscreen window...
Definition: ginteractor.cpp:198
virtual void removeActionListener()
Removes the action listener from this interactor so that it will no longer call it when events occur...
Definition: ginteractor.cpp:250
This struct contains real-valued x and y fields.
Definition: gtypes.h:202
virtual string getAccelerator() const
Returns a string representing a hotkey for this interactor, or an empty string if no accelerator has ...
Definition: ginteractor.cpp:67
Definition: ginteractor.h:58
virtual void setColor(int rgb)
Sets the foreground/text color of the interactor to the color represented by the given RGB integer...
Definition: ginteractor.cpp:370
virtual void setMinimumSize(double width, double height)
Sets the minimum size in pixels that this interactor will permit itself to be resized to...
Definition: ginteractor.cpp:478
virtual void setLocation(double x, double y)
Sets the onscreen x/y-coordinate of the top-left corner of the interactor relative to its window...
Definition: ginteractor.cpp:472
virtual void setVisible(bool visible)
Returns true if the interactor is visible on the screen.
Definition: ginteractor.cpp:566
virtual void setWidth(double width)
Sets the onscreen width of the interactor in pixels.
Definition: ginteractor.cpp:575
virtual void removeClickListener()
Removes the click listener from this interactor so that it will no longer call it when events occur...
Definition: ginteractor.cpp:254
virtual string getColor() const
Returns the foreground/text color of the interactor as a string.
Definition: ginteractor.cpp:94