void hListBox::addItems(int numItems, string label) { hGui * gui = hGui::getInstance(); string name = data->name; string itemName; int offset, index; int xx = 0, yy = 0; if(numItems > 0) { for(int i = 0; i < numItems; ++i) { offset = data_buffer.size(); index = offset + startIndex; itemName = name + "_" + ofToString(index); // cout << itemName << endl; hListItem *item = new hListItem(itemName, this, HGUI_ABSOLUTE_POSITION, x+xx, y+yy, w, label); item->getData()->index = index; item->getData()->offset = offset; item->setSelectColor(defSelectColor); item->displayIndex(indexDisplayFlag); item->setIndexShift(indexShift1, indexShift10, indexShift100); item->sendWhenReleased(sendWhenReleasedFlag); yy += gui->buttonHeight-1; } // Adapt the size of the panel to the size of all items inside int heightOfWidgets = yy+1; if(heightOfWidgets > h) h = heightOfWidgets; // Remove the last values of maxX and maxY #if defined( __WIN32__ ) || defined( _WIN32 ) addMaxXY(-(gui->scrollBarSize+1), - (gui->buttonHeight-6)); #else addMaxXY(-(gui->scrollBarSize+1), - (gui->buttonHeight-5)); #endif // Set the new values of maxX and maxY addMaxXY((w+gui->scrollBarSize), (h)); } }
hWidget::hWidget(std::string name, hPanel * parent, int dispMode, int xx, int yy, int width, int height) { parentPanel = parent; data = new hGuiData; // data had to be created before addWidgetToPanel is used if(parentPanel != NULL) { displayMode = dispMode; calcWidgetPosition(); // Remember the position after the last widget of the parent panel // Add the widget (and its data) to the panel parentPanel->addWidgetToPanel(this); } else displayMode = HGUI_ABSOLUTE_POSITION; w = width; h = height; // determine the position of the widget if(displayMode == HGUI_ABSOLUTE_POSITION) { x = xx; y = yy; } else if(displayMode == HGUI_TOP_LEFT) { x = parent->x + xx; y = parent->y + yy; } else { x = parentPanel->maxX + xx; y = parentPanel->maxY + yy; } addMaxXY(xx, yy); // Store the adress of the widget in the object map, for quickly search by hEvents if(name.size() > 0) { data->name = name; hEvents::getInstance()->addObject(name, this); } // Set default values visibleBorder = true; visibleBackground = false; backgroundColor = -1; data->type = "widget"; data->index = 0; data->offset = 0; data->value = 0.0; data->value2 = 0.0; data->selectable = false; data->selected = false; data->radioEnabled = false; data->disabled = false; data->selectColor = -1; data->indexDisplayFlag = false; data->indexShift1 = 0; data->indexShift10 = 0, data->indexShift100 = 0; editable = false; focusSendFlag = false; // focusSendFlag is actualy only used by number boxes x_extension = 0; // x_extension is actualy only used by check boxes varType = HGUI_NO_VAR; intVar = NULL; floatVar = NULL; doubleVar = NULL; boolVar = NULL; /* now done in hGui.cpp // Store the adress of the widget in the main widget list hGui * gui = hGui::getInstance(); gui->addWidget(this); */ }