#include <CSListbox.h>
Inheritance diagram for CSListbox:
Public Member Functions | |
CSListbox (int numberOfElementsDisplayed, int width) | |
virtual | ~CSListbox () |
virtual std::string | getType () |
void | initListbox () |
virtual void | paint (SDL_Surface *destination, SDL_Rect *parentViewport) |
void | reactOnMessageListbox (CSMessage *message) |
virtual void | reactOnMessage (CSMessage *message) |
to be overloaded | |
virtual void | setGrafikCursor (int x, int y) |
virtual void | setItems (const CSStringlist &list) |
virtual CSStringlist | getItems () |
virtual int | getSelected () |
virtual void | setSelected (int i) |
virtual void | setHoverSelection (bool b) |
virtual void | setItemsShown (int numberOfElementsDisplayed) |
virtual void | layoutSetup () |
Static Public Attributes | |
const char * | CLASS = "CSListbox" |
static element, name of this class (introsepection) | |
Protected Member Functions | |
void | layoutSetupListbox () |
virtual void | rebuildElement () |
Protected Attributes | |
GuiMessage | MESSAGE_LIST_ITEM_SELECTED |
|
Definition at line 15 of file CSListbox.cpp. References initListbox(), LOG_ENTER, and LOG_EXIT.
00015 : CSGrafikElement(numberOfElementsDisplayed*16, width) // * 16 is dummy, size is calculated in changeDisplayLayout() 00016 { 00017 static char *functionName="CSListbox"; 00018 LOG_ENTER 00019 mNumberOfElementsDisplayed = numberOfElementsDisplayed; 00020 initListbox(); 00021 LOG_EXIT 00022 } |
Here is the call graph for this function:
|
Definition at line 24 of file CSListbox.cpp. References LOG_ENTER, LOG_EXIT, and CSGrafikElement::removeElement().
00025 { 00026 static char *functionName="~CSListbox"; 00027 LOG_ENTER 00028 if (mScrollbar != 0) 00029 { 00030 removeElement(mScrollbar); 00031 delete(mScrollbar); 00032 mScrollbar = 0; 00033 } 00034 LOG_EXIT 00035 } |
Here is the call graph for this function:
|
Definition at line 248 of file CSListbox.cpp. References CSGrafikElement::getBorder(), CSLAF::getCurrentLAF(), CSGrafikElement::getFont(), CSFont::getHeight(), CSGrafikElement::getInset(), CSStringlist::getSize(), CSInset::getTotalHeight(), CSBorder::getTotalHeight(), CSInset::getTotalWidth(), CSBorder::getTotalWidth(), CSGrafikElement::getVerticalElementSpacing(), LOG_ENTER, LOG_EXIT, CSScrollbar::setDisplayEnd(), CSScrollbar::setDisplayLength(), CSScrollbar::setDisplayStart(), CSScrollbar::setEnd(), CSScrollbar::setStart(), and CSGrafikElement::setVisible(). Referenced by layoutSetup().
00249 { 00250 static char *functionName="layoutSetupListbox"; 00251 LOG_ENTER 00252 CSLAF *laf = CSLAF::getCurrentLAF(); 00253 mListInset = CSInset(2); 00254 00255 00256 00257 00258 mHeight = mNumberOfElementsDisplayed * (getFont()->getHeight()) 00259 + (mNumberOfElementsDisplayed-1) * (getVerticalElementSpacing()) 00260 + getBorder()->getTotalHeight() 00261 + getInset().getTotalHeight() 00262 + mListInset.getTotalHeight(); 00263 mMinHeight = mHeight - getBorder()->getTotalHeight() - getInset().getTotalHeight(); 00264 mMinWidth = mWidth - getBorder()->getTotalWidth() - getInset().getTotalWidth(); 00265 00266 int yAdd = getFont()->getHeight() + getVerticalElementSpacing(); 00267 00268 // getLayoutManager()->buildArea(this); 00269 // getLayoutManager()->layout(); 00270 00271 // mDisplayLength = (getViewportHeight()) / yAdd; 00272 mDisplayLength = (mMinHeight) / yAdd; 00273 00274 00275 //printf("\n---\nDisplayLength: %i, yAdd: %i, ViewportHeight: %i\n\n",mDisplayLength, yAdd, getViewportHeight()); 00276 mEnd = mStart + mDisplayLength; 00277 mScrollbar->setDisplayStart(mStart); 00278 mScrollbar->setDisplayEnd(mEnd); 00279 mScrollbar->setDisplayLength(mDisplayLength); 00280 mScrollbar->setStart(0); 00281 mScrollbar->setEnd(mItems.getSize()); 00282 00283 if (mDisplayLength < mItems.getSize()) 00284 { 00285 mScrollbar->setVisible(true); 00286 } 00287 else 00288 { 00289 mScrollbar->setVisible(false); 00290 } 00291 LOG_EXIT 00292 } |
Here is the call graph for this function:
|
Reimplemented from CSGrafikElement. Definition at line 220 of file CSListbox.cpp. References CSGrafikElement::addElement(), CSMessageDispatchable::addMessageListener(), BORDER_TYPE_SELECTED, CSBorder::getBorder(), CSLAF::getCurrentLAF(), CSGrafikElement::getFocusable(), GUI_MESSAGE, LOG_ENTER, LOG_EXIT, POSITION_EAST, CSGrafikElement::removeElement(), CSMessageDispatchable::removeMessageListener(), CSGrafikElement::setFocusable(), and TYPE_VERTICAL. Referenced by initListbox().
00221 { 00222 static char *functionName="rebuildElement"; 00223 LOG_ENTER 00224 CSLAF *laf = CSLAF::getCurrentLAF(); 00225 if (mSelectionBorder != 0) 00226 { 00227 delete mSelectionBorder; 00228 mSelectionBorder = 0; 00229 } 00230 mSelectionBorder = CSBorder::getBorder(BORDER_TYPE_SELECTED); 00231 00232 if (mScrollbar != 0) 00233 { 00234 mScrollbar->removeMessageListener(this); 00235 removeElement(mScrollbar); 00236 delete (mScrollbar); 00237 mScrollbar = 0; 00238 } 00239 00240 mScrollbar = new CSScrollbar(TYPE_VERTICAL); 00241 mScrollbar->addMessageListener(this, GUI_MESSAGE); 00242 00243 mScrollbar->setFocusable(getFocusable()); 00244 addElement(mScrollbar, POSITION_EAST); 00245 LOG_EXIT 00246 } |
Here is the call graph for this function:
|
Reimplemented from CSGrafikElement. Definition at line 50 of file CSListbox.h. References CLASS.
00050 {return (std::string) CLASS;} |
|
Definition at line 37 of file CSListbox.cpp. References layoutSetup(), LIST_ITEM_SELECTED_MESSAGE, LOG_ENTER, LOG_EXIT, MESSAGE_LIST_ITEM_SELECTED, rebuildElement(), CSGrafikElement::setLayoutManager(), and CSMessage::setSubtype(). Referenced by CSListbox().
00038 { 00039 static char *functionName="initListbox"; 00040 LOG_ENTER 00041 MESSAGE_LIST_ITEM_SELECTED.setSubtype(LIST_ITEM_SELECTED_MESSAGE); 00042 setLayoutManager(new CSLayoutManagerStackHorizontal()); 00043 mSelectedItem = -1; // not item selected 00044 mStart = 0; // first item to be displayed 00045 mEnd = 0; 00046 mDisplayLength = 0; 00047 mScrollbar = 0; 00048 mHoverSelection = false; 00049 mSelectionBorder = 0; 00050 00051 rebuildElement(); 00052 layoutSetup(); 00053 LOG_EXIT 00054 } |
Here is the call graph for this function:
|
Reimplemented from CSGrafikElement. Definition at line 161 of file CSListbox.cpp. References SDLMain::adjustClipping(), BORDER_STATE_VISIBLE, CSGrafikElement::getElementArea(), CSGrafikElement::getFont(), CSFont::getHeight(), CSStringlist::getSize(), CSInset::getSizeNorth(), CSInset::getSizeWest(), CSStringlist::getString(), CSGrafikElement::getVerticalElementSpacing(), CSGrafikElement::getViewportArea(), CSGrafikElement::getVisible(), CSGrafikElement::getWidth(), CSGrafikElement::getX(), CSGrafikElement::getY(), CSBorder::paint(), CSGrafikElement::paintChildren(), CSGrafikElement::putString(), and CSBorder::setState().
00162 { 00163 static char *functionName="paint"; 00164 SDL_Rect rectSave; 00165 SDL_GetClipRect(destination, &rectSave); 00166 00167 SDL_Rect rectClip = getViewportArea(); 00168 rectClip.x += parentViewport->x + getX(); 00169 rectClip.y += parentViewport->y + getY(); 00170 00171 SDLMain::adjustClipping(rectClip, rectSave); 00172 00173 SDL_SetClipRect(destination, &rectClip); 00174 00175 SDL_Rect viewArea = getViewportArea(); 00176 SDL_Rect elementArea = getElementArea(); 00177 SDL_Rect printArea = viewArea; 00178 printArea.x += parentViewport->x + elementArea.x; 00179 printArea.y += parentViewport->y + elementArea.y; 00180 00181 int x = mListInset.getSizeWest(); 00182 int y = mListInset.getSizeNorth(); 00183 00184 int yAdd = getFont()->getHeight() + getVerticalElementSpacing(); 00185 00186 for (int i = mStart; ((i<mEnd) && (i<mItems.getSize())); i++) 00187 { 00188 if (mItems.getString(i).size()) 00189 { 00190 std::string t = mItems.getString(i); 00191 putString(destination, &printArea, x, y, t); 00192 00193 if (i == mSelectedItem) 00194 { 00195 SDL_Rect selectedItemArea = printArea; 00196 selectedItemArea.x; 00197 selectedItemArea.y += y - mListInset.getSizeNorth(); 00198 00199 selectedItemArea.h = getFont()->getHeight() + getVerticalElementSpacing(); 00200 if (mScrollbar->getVisible()) 00201 { 00202 selectedItemArea.w -= mScrollbar->getWidth(); 00203 } 00204 mSelectionBorder->paint(destination, &selectedItemArea); 00205 mSelectionBorder->setState(BORDER_STATE_VISIBLE); 00206 } 00207 } 00208 y += yAdd; 00209 } 00210 00211 SDL_SetClipRect(destination, &rectSave); 00212 paintChildren(destination, parentViewport); 00213 } |
Here is the call graph for this function:
|
Definition at line 70 of file CSListbox.cpp. References GuiMessage::end, CSMessage::getSubtype(), CSMessage::getType(), GUI_MESSAGE, MESSAGE_LIST_ITEM_SELECTED, CSMessage::mIsHandled, MOUSE_BUTTON_PRESSED_MESSAGE, MOUSE_BUTTON_RELEASED_MESSAGE, MOUSE_MOTION_MESSAGE, CSGrafikElement::reactOnMessageGrafikElement(), GuiMessage::receiver, GuiMessage::receiverX, GuiMessage::receiverY, SCROLLBAR_POSITION_CHANGED_MESSAGE, GuiMessage::selected, CSMessageDispatchable::sendMessage(), setGrafikCursor(), and GuiMessage::start. Referenced by reactOnMessage().
00071 { 00072 static char *functionName="reactOnMessage"; 00073 if (message->mIsHandled) 00074 { 00075 reactOnMessageGrafikElement(message); 00076 return; 00077 } 00078 switch (message->getType()) 00079 { 00080 case GUI_MESSAGE: 00081 { 00082 GuiMessage *gm = (GuiMessage *) message; 00083 if (gm->receiver == this) 00084 { 00085 if (gm->getSubtype() == MOUSE_BUTTON_RELEASED_MESSAGE) 00086 { 00087 if (mHoverSelection) 00088 { 00089 MESSAGE_LIST_ITEM_SELECTED.selected = mSelectedItem; 00090 MESSAGE_LIST_ITEM_SELECTED.mIsHandled = false; 00091 sendMessage(MESSAGE_LIST_ITEM_SELECTED); 00092 } 00093 gm->mIsHandled = true; 00094 } 00095 } 00096 if (gm->receiver != this) 00097 { 00098 if (gm->getSubtype() == SCROLLBAR_POSITION_CHANGED_MESSAGE) 00099 { 00100 mStart = gm->start; 00101 mEnd = gm->end; 00102 gm->mIsHandled = true; 00103 } 00104 } 00105 else // receiver == this 00106 { 00107 switch (message->getSubtype()) 00108 { 00109 case MOUSE_MOTION_MESSAGE: 00110 { 00111 if (mHoverSelection) 00112 { 00113 int x,y; 00114 x = gm->receiverX; 00115 y = gm->receiverY; 00116 setGrafikCursor(x,y); 00117 } 00118 gm->mIsHandled = true; 00119 break; 00120 } 00121 00122 case MOUSE_BUTTON_PRESSED_MESSAGE: 00123 { 00124 if (!mHoverSelection) 00125 { 00126 int x,y; 00127 x = gm->receiverX; 00128 y = gm->receiverY; 00129 setGrafikCursor(x,y); 00130 } 00131 gm->mIsHandled = true; 00132 break; 00133 } 00134 } 00135 } 00136 } 00137 } 00138 reactOnMessageGrafikElement(message); 00139 } |
Here is the call graph for this function:
|
to be overloaded
Reimplemented from CSGrafikElement. Definition at line 65 of file CSListbox.cpp. References reactOnMessageListbox().
00066 { 00067 reactOnMessageListbox(message); 00068 } |
Here is the call graph for this function:
|
Here is the call graph for this function:
|
Definition at line 57 of file CSListbox.h. References CSGrafikElement::layoutChanged(). Referenced by CSCombobox::setItems().
00058 { 00059 mItems = list; 00060 layoutChanged(); 00061 } |
Here is the call graph for this function:
|
Definition at line 62 of file CSListbox.h. Referenced by CSCombobox::getItems(), CSCombobox::getSelectedObject(), and CSCombobox::getSelectedString().
00062 {return mItems;}
|
|
Definition at line 63 of file CSListbox.h. Referenced by CSCombobox::getSelectedObject(), and CSCombobox::getSelectedString().
00063 {return mSelectedItem;}
|
|
Definition at line 215 of file CSListbox.cpp. Referenced by CSCombobox::setSelected().
00216 { 00217 mSelectedItem = i; 00218 } |
|
Definition at line 65 of file CSListbox.h. Referenced by CSCombobox::rebuildElement().
00065 {mHoverSelection = b;} |
|
Definition at line 56 of file CSListbox.cpp. References CSGrafikElement::layoutChanged(), LOG_ENTER, and LOG_EXIT. Referenced by CSCombobox::rebuildElement().
00057 { 00058 static char *functionName="setItemsShown"; 00059 LOG_ENTER 00060 mNumberOfElementsDisplayed = numberOfElementsDisplayed; 00061 layoutChanged(); 00062 LOG_EXIT 00063 } |
Here is the call graph for this function:
|
Reimplemented from CSGrafikElement. Definition at line 67 of file CSListbox.h. References layoutSetupListbox(). Referenced by initListbox().
00067 {layoutSetupListbox();} |
Here is the call graph for this function:
|
Definition at line 42 of file CSListbox.h. Referenced by initListbox(), reactOnMessageListbox(), and setGrafikCursor(). |
|
static element, name of this class (introsepection)
Reimplemented from CSGrafikElement. Definition at line 13 of file CSListbox.cpp. Referenced by CSLAF::getBackgroundColorDisabledInternal(), CSLAF::getBackgroundColorEnabledInternal(), CSLAF::getBorderInternal(), CSLAF::getHorizontalElementSpacingInternal(), CSLAF::getTextColorDisabledInternal(), CSLAF::getTextColorEnabledInternal(), getType(), and CSLAF::getVerticalElementSpacingInternal(). |