void Console::notifyButtonPressed(MyGUI::Widget* _sender, MyGUI::KeyCode _key, MyGUI::Char _char) { size_t len = _sender->getCaption().length(); MyGUI::Edit* edit = _sender->castType<MyGUI::Edit>(); if ((_key == MyGUI::KeyCode::Backspace) && (len > 0) && (mAutocomleted)) { edit->deleteTextSelection(); len = _sender->getCaption().length(); edit->eraseText(len-1); } MyGUI::UString command = _sender->getCaption(); if (command.length() == 0) return; for (MapDelegate::iterator iter = mDelegates.begin(); iter != mDelegates.end(); ++iter) { if (iter->first.find(command) == 0) { if (command == iter->first) break; edit->setCaption(iter->first); edit->setTextSelection(command.length(), iter->first.length()); mAutocomleted = true; return; } } mAutocomleted = false; }
void View::addIndex(MyGUI::ResourceImageSetPtr _image, const MyGUI::GroupImage & _group, const MyGUI::IndexImage & _index, MyGUI::IntSize & _size) { const int left = 10; const int offset_height = 10; const int text_height = 26; MyGUI::StaticImage* image = mImageView->createWidget<MyGUI::StaticImage>("StaticImage", MyGUI::IntCoord(left, _size.height, _group.size.width, _group.size.height), MyGUI::Align::Default); image->setItemResourcePtr(_image); image->setItemGroup(_group.name); image->setItemName(_index.name); MyGUI::Edit* text = mImageView->createWidget<MyGUI::Edit>("Edit", MyGUI::IntCoord(image->getRight() + left, _size.height, 200, text_height), MyGUI::Align::Default); text->setEditReadOnly(true); text->setCaption(_index.name); MyGUI::IntSize size = text->getSubWidgetText()->getTextSize(); //text->setSize(size.width, text->getHeight()); if (_size.width < text->getRight()) _size.width = text->getRight(); _size.height = std::max(text->getBottom(), image->getBottom()) + offset_height; }
void View::addGroup(MyGUI::ResourceImageSetPtr _image, const MyGUI::GroupImage & _group, MyGUI::IntSize & _size) { const int left = 10; const int text_height = 26; MyGUI::Edit* text = mImageView->createWidget<MyGUI::Edit>("Edit", MyGUI::IntCoord(left, _size.height, 100, text_height), MyGUI::Align::Default); text->setEditReadOnly(true); text->setTextAlign(MyGUI::Align::Center); text->setCaption(MyGUI::utility::toString("group name : '", _group.name, "' , texture : '", _group.texture, "' , size : ", _group.size.print())); MyGUI::IntSize size = text->getSubWidgetText()->getTextSize(); text->setSize(size.width + 20, text->getHeight()); _size.height += text_height + 20; if (_size.width < text->getRight()) _size.width = text->getRight(); addAnimGroup(_image, _group, _size); for (size_t pos=0; pos<_group.indexes.size(); ++pos) { addIndex(_image, _group, _group.indexes[pos], _size); } }