Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header #64

Merged
merged 2 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* Continue rebasing from bf3ece4152614d0e2686ccb17c168bf58d7d9548
* Continue rebasing from 5e37d507e8345c425131c2ade8e6823cacb74035
* Add a focus listener interface.
* Make focus apply synchronously.
* Graphics and input objects for DirectX.
Expand Down
2 changes: 2 additions & 0 deletions include/guisan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#include <guisan/actionlistener.hpp>
#include <guisan/cliprectangle.hpp>
#include <guisan/color.hpp>
#include <guisan/containerevent.hpp>
#include <guisan/containerlistener.hpp>
#include <guisan/deathlistener.hpp>
#include <guisan/event.hpp>
#include <guisan/exception.hpp>
Expand Down
69 changes: 45 additions & 24 deletions include/guisan/widgets/dropdown.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,20 @@
namespace gcn
{
/**
* An implementation of a drop downable list from which an item can be selected.
* The drop down consists of an internal ScrollArea and an internal ListBox.
* The drop down also uses an internal FocusHandler to handle the focus of the
* internal ScollArea and the internal ListBox. The scroll area and the list box
* can be passed to the drop down if a custom scroll area and or a custom list box
* is preferable.
* An implementation of a drop downable list from which an item can be
* selected. The drop down consists of an internal ScrollArea and an
* internal ListBox. The drop down also uses an internal FocusHandler to
* handle the focus of the internal ScollArea and the internal ListBox.
* The scroll area and the list box can be passed to the drop down
* if a custom scroll area and/or a custom list box is preferable.
*
* To be able display a list the drop down uses a user provided list model.
* A list model can be any class that implements the ListModel interface.
* To be able display a list the drop down uses a user provided list model.
* A list model can be any class that implements the ListModel interface.
*
* If an item is selected in the drop down a select event will be sent to all selection
* listeners of the drop down. If an item is selected by using a mouse click or by using
* the enter or space key an action event will be sent to all action listeners of the
* drop down.
* If an item is selected in the drop down a select event will be sent to
* all selection listeners of the drop down. If an item is selected by
* using a mouse click or by using the enter or space key an action event
* will be sent to all action listeners of the drop down.
*/
class GCN_CORE_DECLSPEC DropDown :
public ActionListener,
Expand Down Expand Up @@ -159,6 +159,9 @@ namespace gcn
* changes an event will be sent to all selection listeners of the
* drop down.
*
* If you delete your selection listener, be sure to also remove it
* using removeSelectionListener().
*
* @param selectionListener the selection listener to add.
* @since 0.8.0
*/
Expand Down Expand Up @@ -259,40 +262,58 @@ namespace gcn
*/
void distributeValueChangedEvent();

/**
* True if the drop down has been pushed with the mouse, false
* otherwise.
*/
bool mPushed;

/**
* Holds what the height is if the drop down is folded up. Used when
* checking if the list of the drop down was clicked or if the upper part
* of the drop down was clicked on a mouse click
* Holds what the height is if the drop down is folded up.
* Used when checking if the list of the drop down was clicked
* or if the upper part of the drop down was clicked on a mouse click.
*/
int mFoldedUpHeight;

/**
* The scroll area used.
*/
ScrollArea* mScrollArea;
ListBox* mListBox;

/**
* The internal focus handler used to keep track of focus for the
* internal list box.
*/
FocusHandler mInternalFocusHandler;

/**
* True if an internal scroll area is used, false if a scroll area
* has been passed to the drop down which the drop down should not
* deleted in it's destructor.
*/
bool mInternalScrollArea;

/**
* True if an internal list box is used, false if a list box
* has been passed to the drop down which the drop down should not
* deleted in it's destructor.
*/
bool mInternalListBox;
bool mIsDragged;

/**
* Typedef.
* True if the drop down is dragged.
*/
bool mIsDragged;

typedef std::list<SelectionListener*> SelectionListenerList;

/**
* The selection listener's of the drop down.
*/
SelectionListenerList mSelectionListeners;

/**
* Typedef.
*/
typedef SelectionListenerList::iterator SelectionListenerIterator;

typedef SelectionListenerList::iterator SelectionListenerIterator;
};
}

Expand Down
54 changes: 26 additions & 28 deletions include/guisan/widgets/listbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ namespace gcn
/**
* An implementation of a list box where an item can be selected.
*
* To be able display a list the list box uses a user provided list model.
* To be able to display a list the list box uses a user provided list model.
* A list model can be any class that implements the ListModel interface.
*
* If an item is selected in the list box a select event will be sent to all selection
* listeners of the list box. If an item is selected by using a mouse click or by using
* the enter or space key an action event will be sent to all action listeners of the
* list box.
*
* If an item is selected in the list box a select event will be sent to
* all selection listeners of the list box. If an item is selected by using
* a mouse click or by using the enter or space key an action event will be
* sent to all action listeners of the list box.
*/
class GCN_CORE_DECLSPEC ListBox :
public Widget,
Expand Down Expand Up @@ -142,26 +142,28 @@ namespace gcn
void adjustSize();

/**
* Checks whether the list box wraps when selecting items with a keyboard.
* Checks whether the list box wraps when selecting items
* with a keyboard.
*
* Wrapping means that the selection of items will be wrapped. That is, if
* the first item is selected and up is pressed, the last item will get
* selected. If the last item is selected and down is pressed, the first item
* will get selected.
* Wrapping means that the selection of items will be wrapped.
* That is, if the first item is selected and up is pressed,
* the last item will get selected. If the last item is selected
* and down is pressed, the first item will get selected.
*
* @return true if wrapping is enabled, fasle otherwise.
* @return true if wrapping is enabled, false otherwise.
* @see setWrappingEnabled
*/
bool isWrappingEnabled() const;

/**
* Sets the list box to wrap or not when selecting items with a keyboard.
* Sets the list box to wrap or not when selecting items
* with a keyboard.
*
* Wrapping means that the selection of items will be wrapped.
* That is, if the first item is selected and up is pressed,
* the last item will get selected. If the last item is selected
* and down is pressed, the first item will get selected.
*
* Wrapping means that the selection of items will be wrapped. That is, if
* the first item is selected and up is pressed, the last item will get
* selected. If the last item is selected and down is pressed, the first item
* will get selected.
*
* @see isWrappingEnabled
*/
void setWrappingEnabled(bool wrappingEnabled);
Expand All @@ -171,6 +173,9 @@ namespace gcn
* changes an event will be sent to all selection listeners of the
* list box.
*
* If you delete your selection listener, be sure to also remove it
* using removeSelectionListener().
*
* @param selectionListener The selection listener to add.
* @since 0.8.0
*/
Expand Down Expand Up @@ -212,15 +217,14 @@ namespace gcn
virtual void mouseWheelMovedUp(MouseEvent& mouseEvent);

virtual void mouseWheelMovedDown(MouseEvent& mouseEvent);

virtual void mouseDragged(MouseEvent& mouseEvent);


protected:
/**
* Distributes a value changed event to all selection listeners
* of the list box.
*
*
* @since 0.8.0
*/
void distributeValueChangedEvent();
Expand All @@ -240,19 +244,13 @@ namespace gcn
*/
bool mWrappingEnabled;

/**
* Typdef.
*/
typedef std::list<SelectionListener*> SelectionListenerList;

/**
* The selection listeners of the list box.
*/
SelectionListenerList mSelectionListeners;

/**
* Typedef.
*/
typedef SelectionListenerList::iterator SelectionListenerIterator;
};
}
Expand Down