25 #ifndef _ginteractor_h 26 #define _ginteractor_h 29 #include <QReadWriteLock> 33 #include "gobservable.h" 41 class _Internal_QWidget;
174 virtual
int getID() const;
189 virtual _Internal_QWidget* getInternalWidget() const = 0;
222 virtual
char getMnemonic() const
(deprecated);
271 virtual QWidget* getWidget() const = 0;
282 virtual
double getX() const;
288 virtual
double getY() const;
293 virtual
bool inBounds(
double x,
double y) const;
298 virtual
bool inBounds(
int x,
int y) const;
404 virtual
void setBounds(
double x,
double y,
double width,
double height);
469 virtual
void setFont(const QFont& font);
476 virtual
void setFont(const
std::
string& font);
505 virtual
void setIcon(const QIcon& icon);
512 virtual
void setIcon(const QPixmap& icon);
522 virtual
void setIcon(const
std::
string& filename,
bool retainIconSize = true);
567 virtual
void setMnemonic(
char mnemonic)
(deprecated);
589 virtual
void setName(const
std::
string& name);
631 virtual
void setSize(
double width,
double height);
659 virtual
void setWidth(
double width);
667 virtual
void setX(
double x);
675 virtual
void setY(
double y);
681 std::
string _actionCommand;
686 std::
string _actionEventType;
711 QReadWriteLock _lock;
716 static QWidget* getInternalParent(QWidget* parent);
721 virtual
std::
string getActionEventType() const;
726 virtual
std::
string getDefaultInteractorName() const;
731 virtual
void lockForRead();
736 virtual
void lockForReadConst() const;
741 virtual
void lockForWrite();
746 virtual
void lockForWriteConst() const;
751 static
std::
string normalizeAccelerator(const
std::
string& accelerator);
756 virtual
void setContainer(
GContainer* container);
761 virtual
void unlock();
766 virtual
void unlockConst() const;
771 friend class _Internal_QWidget;
774 static
int _interactorCount;
785 class _Internal_QWidget {
788 virtual ~_Internal_QWidget();
789 virtual void detach();
791 virtual bool hasMinimumSize()
const;
793 virtual bool hasPreferredSize()
const;
812 template <
typename T>
815 GGenericInteractor(T* widget)
817 _iqwidget =
new _Internal_QWidget();
820 _Internal_QWidget* getInternalWidget()
const override {
824 string
getType()
const override {
825 string typeName =
typeid(T).name();
826 return string(
"GGenericInteractor<") + typeName +
">";
829 QWidget* getWidget()
const override {
834 _Internal_QWidget* _iqwidget;
838 #endif // _ginteractor_h virtual GRectangle getBounds() const
Returns a rectangle representing the x/y position and size of this interactor.
Definition: ginteractor.cpp:85
This struct contains real-valued width and height fields.
Definition: gtypes.h:39
Definition: ginteractor.h:54
virtual void removeClickListener()
Removes the click listener from this interactor so that it will no longer call it when events occur...
Definition: ginteractor.cpp:248
virtual void setPreferredSize(double width, double height)
Sets the width and height in pixels that this interactor would prefer to be.
Definition: ginteractor.cpp:521
virtual double getX() const
Returns the x-coordinate of the top-left pixel of this interactor within its onscreen window...
Definition: ginteractor.cpp:193
virtual void setPreferredWidth(double width)
Sets the width in pixels that this interactor would prefer to be.
Definition: ginteractor.cpp:535
virtual double getHeight() const
Returns the current onscreen height of this interactor in pixels.
Definition: ginteractor.cpp:121
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:67
Definition: ginteractor.h:55
virtual GDimension getMinimumSize() const
Returns a GDimension structure representing the minimum size in pixels that this interactor will perm...
Definition: ginteractor.cpp:145
virtual double getY() const
Returns the y-coordinate of the top-left pixel of this interactor within its onscreen window...
Definition: ginteractor.cpp:197
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:472
virtual void setTooltip(string tooltipText)
Sets a "tooltip" that will appear if the user hovers their mouse over the interactor.
Definition: ginteractor.cpp:554
virtual void removeDoubleClickListener()
Removes the double-click listener from this interactor so that it will no longer call it when events ...
Definition: ginteractor.cpp:252
virtual void addActionListener() (deprecated)
Adds an event listener to be notified when this interactor is clicked or generally interacted with...
Definition: ginteractor.cpp:54
virtual GDimension getPreferredSize() const
Returns a GDimension structure storing the width and height in pixels that this interactor would pref...
Definition: ginteractor.cpp:171
A GObservable object is one that is able to send out events.
Definition: gobservable.h:36
virtual GDimension getSize() const
Returns a GDimension structure storing the current onscreen width and height of this interactor in pi...
Definition: ginteractor.cpp:185
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:399
virtual void setEnabled(bool value)
Sets whether this interactor is currently enabled.
Definition: ginteractor.cpp:393
virtual string getFont() const
Returns the font of this interactor's text as a font string such as "Helvetica-12-Bold".
Definition: ginteractor.cpp:107
virtual ~GInteractor()
Frees memory allocated internally by the interactor.
Definition: ginteractor.cpp:50
virtual void setName(string name)
Sets a string representing a unique name for this interactor.
Definition: ginteractor.cpp:512
GInteractor()
Initializes a newly created interactor.
Definition: ginteractor.cpp:38
virtual GContainer * getContainer() const
Returns a pointer to the onscreen container holding this interactor.
Definition: ginteractor.cpp:99
virtual void setAccelerator(string accelerator)
Sets an accelerator hotkey for this interactor, such as "Ctrl-S".
Definition: ginteractor.cpp:284
virtual bool isEnabled() const
Returns true if this interactor is currently enabled.
Definition: ginteractor.cpp:209
virtual int getBackgroundInt() const
Returns the background color of the interactor as an RGB integer.
Definition: ginteractor.cpp:80
virtual int getColorInt() const
Returns the foreground/text color of the interactor as an RGB integer.
Definition: ginteractor.cpp:94
virtual double getMinimumHeight() const
Returns the minimum height in pixels that this interactor will permit itself to be resized to...
Definition: ginteractor.cpp:141
virtual void setSize(double width, double height)
Sets the onscreen width and height of the interactor in pixels.
Definition: ginteractor.cpp:539
virtual bool isVisible() const
Returns true if the interactor is visible on the screen.
Definition: ginteractor.cpp:213
virtual int getID() const
Returns a globally unique identifier for this interactor, which is set when the interactor is constru...
Definition: ginteractor.cpp:125
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:579
bool eventsEnabled() const override
Returns true if this interactor is currently accepting events.
Definition: ginteractor.cpp:58
virtual void setBounds(double x, double y, double width, double height)
Sets the size and location of the widget.
Definition: ginteractor.cpp:345
This abstract class is the superclass for all graphical interactors.
Definition: ginteractor.h:48
virtual void setHeight(double height)
Sets the onscreen height of the interactor in pixels.
Definition: ginteractor.cpp:433
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:288
virtual void removeMouseListener()
Removes the mouse listener from this interactor so that it will no longer call it when events occur...
Definition: ginteractor.cpp:262
string getType() const override=0
Returns a string representing the class name of this interactor, such as "GButton" or "GCheckBox"...
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:466
virtual double getWidth() const
Returns the current onscreen width of this interactor in pixels.
Definition: ginteractor.cpp:189
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:385
virtual string getColor() const
Returns the foreground/text color of the interactor as a string.
Definition: ginteractor.cpp:89
virtual void setIcon(const QIcon &icon)
Sets the icon associated with this interactor.
Definition: ginteractor.cpp:440
virtual void setWidth(double width)
Sets the onscreen width of the interactor in pixels.
Definition: ginteractor.cpp:569
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:356
virtual string getAccelerator() const
Returns a string representing a hotkey for this interactor, or an empty string if no accelerator has ...
Definition: ginteractor.cpp:62
virtual void setActionCommand(string actionCommand)
Sets the action command for 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:150
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:167
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:488
This class represents a graphics window that supports simple graphics.
Definition: gwindow.h:98
virtual int getForegroundInt() const
Returns the foreground/text color of the interactor as an RGB integer.
Definition: ginteractor.cpp:116
virtual void setVisible(bool visible)
Returns true if the interactor is visible on the screen.
Definition: ginteractor.cpp:560
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:129
virtual string getForeground() const
Returns the foreground/text color of the interactor as a string.
Definition: ginteractor.cpp:111
virtual void setPreferredHeight(double height)
Sets the height in pixels that this interactor would prefer to be.
Definition: ginteractor.cpp:517
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:256
virtual void setFont(const QFont &font)
Sets the font used by this widget to the given Qt font.
Definition: ginteractor.cpp:423
virtual void requestFocus()
Transfers keyboard focus to this interactor.
Definition: ginteractor.cpp:274
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:454
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:364
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:181
friend class GDiffGui
Definition: ginteractor.h:769
virtual string getBackground() const
Returns the background color of the interactor as a string.
Definition: ginteractor.cpp:75
This struct contains real-valued x, y, width, and height fields.
Definition: gtypes.h:289
virtual string getName() const
Returns a string representing a unique name for this interactor.
Definition: ginteractor.cpp:159
TextPosition
The places where an interactor can place its text relative to its icon.
Definition: ginteractor.h:53
Definition: ginteractor.h:56
virtual GPoint getLocation() const
Returns an (x, y) point representing the onscreen location of the top-left corner of this interactor ...
Definition: ginteractor.cpp:133
This struct contains real-valued x and y fields.
Definition: gtypes.h: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:244
A GContainer is a logical grouping for interactors.
Definition: gcontainer.h:69
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:201
virtual void setBackground(int rgb)
Sets the background color of the interactor to the color represented by the given RGB integer...
Definition: ginteractor.cpp:296
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:575