| 294 | } |
| 295 | |
| 296 | void ListBox::updateLine(bool _reset) |
| 297 | { |
| 298 | // сбрасываем |
| 299 | if (_reset) |
| 300 | { |
| 301 | mOldSize.clear(); |
| 302 | mLastRedrawLine = 0; |
| 303 | _resetContainer(false); |
| 304 | } |
| 305 | |
| 306 | // позиция скролла |
| 307 | int position = mTopIndex * mHeightLine + mOffsetTop; |
| 308 | |
| 309 | // если высота увеличивалась то добавляем виджеты |
| 310 | if (mOldSize.height < mCoord.height) |
| 311 | { |
| 312 | int height = (int)mWidgetLines.size() * mHeightLine - mOffsetTop; |
| 313 | |
| 314 | // до тех пор, пока не достигнем максимального колличества, и всегда на одну больше |
| 315 | while ((height <= (_getClientWidget()->getHeight() + mHeightLine)) && |
| 316 | (mWidgetLines.size() < mItemsInfo.size())) |
| 317 | { |
| 318 | // создаем линию |
| 319 | Widget* widget = _getClientWidget()->createWidgetT( |
| 320 | "Button", |
| 321 | mSkinLine, |
| 322 | 0, |
| 323 | height, |
| 324 | _getClientWidget()->getWidth(), |
| 325 | mHeightLine, |
| 326 | Align::Top | Align::HStretch); |
| 327 | Button* line = widget->castType<Button>(); |
| 328 | // подписываемся на всякие там события |
| 329 | line->eventMouseButtonPressed += newDelegate(this, &ListBox::notifyMousePressed); |
| 330 | line->eventMouseButtonReleased += newDelegate(this, &ListBox::notifyMouseButtonReleased); |
| 331 | line->eventMouseButtonClick += newDelegate(this, &ListBox::notifyMouseClick); |
| 332 | line->eventMouseButtonDoubleClick += newDelegate(this, &ListBox::notifyMouseDoubleClick); |
| 333 | line->eventMouseWheel += newDelegate(this, &ListBox::notifyMouseWheel); |
| 334 | line->eventKeyButtonPressed += newDelegate(this, &ListBox::notifyKeyButtonPressed); |
| 335 | line->eventKeyButtonReleased += newDelegate(this, &ListBox::notifyKeyButtonReleased); |
| 336 | line->eventMouseSetFocus += newDelegate(this, &ListBox::notifyMouseSetFocus); |
| 337 | line->eventMouseLostFocus += newDelegate(this, &ListBox::notifyMouseLostFocus); |
| 338 | line->_setContainer(this); |
| 339 | // присваиваем порядковый номер, для простоты просчета |
| 340 | line->_setInternalData((size_t)mWidgetLines.size()); |
| 341 | // и сохраняем |
| 342 | mWidgetLines.push_back(line); |
| 343 | height += mHeightLine; |
| 344 | } |
| 345 | |
| 346 | // проверяем на возможность не менять положение списка |
| 347 | if (position >= mRangeIndex) |
| 348 | { |
| 349 | // размер всех помещается в клиент |
| 350 | if (mRangeIndex <= 0) |
| 351 | { |
| 352 | // обнуляем, если надо |
| 353 | if (position || mOffsetTop || mTopIndex) |
nothing calls this directly
no test coverage detected