void VScroll::initialiseOverride() { Base::initialiseOverride(); // при нуле, будет игнорировать кнопки mScrollPage = 1; mScrollViewPage = 1; mMinTrackSize = 0; mSkinRangeStart = 0; mSkinRangeEnd = 0; assignWidget(mWidgetStart, "Start"); if (mWidgetStart != nullptr) { mWidgetStart->eventMouseButtonPressed += newDelegate(this, &VScroll::notifyMousePressed); mWidgetStart->eventMouseWheel += newDelegate(this, &VScroll::notifyMouseWheel); } assignWidget(mWidgetEnd, "End"); if (mWidgetEnd != nullptr) { mWidgetEnd->eventMouseButtonPressed += newDelegate(this, &VScroll::notifyMousePressed); mWidgetEnd->eventMouseWheel += newDelegate(this, &VScroll::notifyMouseWheel); } assignWidget(mWidgetTrack, "Track"); if (mWidgetTrack) { mWidgetTrack->eventMouseDrag += newDelegate(this, &VScroll::notifyMouseDrag); mWidgetTrack->eventMouseButtonPressed += newDelegate(this, &VScroll::notifyMousePressed); mWidgetTrack->eventMouseButtonReleased += newDelegate(this, &VScroll::notifyMouseReleased); mWidgetTrack->eventMouseWheel += newDelegate(this, &VScroll::notifyMouseWheel); mWidgetTrack->setVisible(false); } assignWidget(mWidgetFirstPart, "FirstPart"); if (mWidgetFirstPart != nullptr) { mWidgetFirstPart->eventMouseButtonPressed += newDelegate(this, &VScroll::notifyMousePressed); mWidgetFirstPart->eventMouseWheel += newDelegate(this, &VScroll::notifyMouseWheel); } assignWidget(mWidgetSecondPart, "SecondPart"); if (mWidgetSecondPart != nullptr) { mWidgetSecondPart->eventMouseButtonPressed += newDelegate(this, &VScroll::notifyMousePressed); mWidgetSecondPart->eventMouseWheel += newDelegate(this, &VScroll::notifyMouseWheel); } if (isUserString("MinTrackSize")) mMinTrackSize = utility::parseValue<int>(getUserString("MinTrackSize")); if (isUserString("TrackRangeMargins")) utility::parseComplex<size_t>(getUserString("TrackRangeMargins"), mSkinRangeStart, mSkinRangeEnd); }
void ComboBox::initialiseOverride() { Base::initialiseOverride(); ///@wskin_child{ComboBox, Button, Button} Кнопка для выпадающего списка. assignWidget(mButton, "Button"); if (mButton != nullptr) { mButton->eventMouseButtonPressed += newDelegate(this, &ComboBox::notifyButtonPressed); } ///@wskin_child{ComboBox, ListBox, List} Выпадающий список. assignWidget(mList, "List"); if (mList == nullptr) { std::string list_skin = getUserString("ListSkin"); std::string list_layer = getUserString("ListLayer"); mList = static_cast<ListBox*>(_createSkinWidget(WidgetStyle::Popup, ListBox::getClassTypeName(), list_skin, IntCoord(), Align::Default, list_layer)); } if (mList != nullptr) { mList->setActivateOnClick(true); mList->setVisible(false); mList->eventKeyLostFocus += newDelegate(this, &ComboBox::notifyListLostFocus); mList->eventListSelectAccept += newDelegate(this, &ComboBox::notifyListSelectAccept); mList->eventListMouseItemActivate += newDelegate(this, &ComboBox::notifyListMouseItemActivate); mList->eventListChangePosition += newDelegate(this, &ComboBox::notifyListChangePosition); mList->setNeedToolTip(true); mList->eventToolTip += newDelegate(this, &ComboBox::notifyToolTip); } // подписываем дочерние классы на скролл if (mClient != nullptr) { mClient->eventMouseWheel += newDelegate(this, &ComboBox::notifyMouseWheel); mClient->eventMouseButtonPressed += newDelegate(this, &ComboBox::notifyMousePressed); mClient->setNeedToolTip(true); mClient->eventToolTip += newDelegate(this, &ComboBox::notifyToolTip); } // подписываемся на изменения текста eventEditTextChange += newDelegate(this, &ComboBox::notifyEditTextChange); }
//------------------------------------------------------------------------------// void InventoryReceiver::populateGeometryBuffer() { if (!isUserStringDefined("BlockImage")) return; const Image* img = PropertyHelper<Image*>::fromString(getUserString("BlockImage")); if (!img) return; const Sizef square_size(squarePixelSize()); for (int y = 0; y < d_content.height(); ++y) { for (int x = 0; x < d_content.width(); ++x) { argb_t colour = 0xFFFFFFFF; if (d_content.elementAtLocation(x, y)) colour = 0xFF0000FF; img->render(*d_geometry, Vector2f(x * square_size.d_width + 1, y * square_size.d_height + 1), Sizef(square_size.d_width - 2, square_size.d_height - 2), 0, ColourRect(colour)); } } }
//------------------------------------------------------------------------------// void InventoryItem::populateGeometryBuffer() { if (!isUserStringDefined("BlockImage")) return; const Image* img = PropertyHelper<Image*>::fromString(getUserString("BlockImage")); if (!img) return; const Sizef square_size(squarePixelSize()); argb_t colour = 0xFF00FF00; if (d_dragging && !currentDropTargetIsValid()) colour = 0xFFFF0000; for (int y = 0; y < d_content.height(); ++y) { for (int x = 0; x < d_content.width(); ++x) { if (d_content.elementAtLocation(x, y)) { img->render(d_geometryBuffers, glm::vec2(x * square_size.d_width + 1, y * square_size.d_height + 1), Sizef(square_size.d_width - 2, square_size.d_height - 2), 0, false, ColourRect(colour)); } } } }
void Profile::updateDomain(const QString& domain) { if (_lastDomain != domain) { _lastDomain = domain; // send the changed domain to the data-server DataServerClient::putValueForKeyAndUserString(DataServerKey::Domain, domain, getUserString()); } }
void MenuControl::initialiseOverride() { Base::initialiseOverride(); // инициализируем овнера Widget* parent = getParent(); if (parent) { mOwner = parent->castType<MenuItem>(false); if (!mOwner) { Widget* client = parent; parent = client->getParent(); if (parent && parent->getClientWidget()) { mOwner = parent->castType<MenuItem>(false); } } } // FIXME нам нужен фокус клавы setNeedKeyFocus(true); ///@wskin_child{MenuControl, Widget, Client} Клиентская зона. assignWidget(mClient, "Client"); if (mClient != nullptr) { setWidgetClient(mClient); } //OBSOLETE if (isUserString("SkinLine")) { mItemNormalSkin = getUserString("SkinLine"); mItemPopupSkin = mItemNormalSkin; } if (isUserString("SeparatorSkin")) mItemSeparatorSkin = getUserString("SeparatorSkin"); if (isUserString("NormalSkin")) mItemNormalSkin = getUserString("NormalSkin"); if (isUserString("PopupSkin")) mItemPopupSkin = getUserString("PopupSkin"); if (isUserString("DistanceButton")) mDistanceButton = utility::parseValue<int>(getUserString("DistanceButton")); if (isUserString("SubMenuSkin")) mSubMenuSkin = getUserString("SubMenuSkin"); if (isUserString("SubMenuLayer")) mSubMenuLayer = getUserString("SubMenuLayer"); // FIXME добавленно, так как шетдаун вызывается и при смене скина mShutdown = false; }
int main () { std::string inputString; // The initial word/phrase entered by the user std::string command; // The command string, entered by the user int stringLen=0; // Length of string, max int nextAction=0; // What command the user has chosen int cmdArgument=0; // Argument to that command, if any char inputChars[MAX_STRING_LEN]; // A c-string, easier to manipulate // Get a word or phrase from user input inputString = getUserString(MAX_STRING_LEN); if (inputString.compare("") == 0 ) return(-1); // Copy the c++ string into a c-string array. // Using strncpy and adding the null isn't necessary if the string // is shorter than MAX_LEN, but it isn't harmful either. std::strncpy(inputChars, inputString.c_str(), MAX_STRING_LEN - 1 ); inputChars[MAX_STRING_LEN-1] = '\0'; // Print the menu of options and enter a loop std::cout << "How do you want to tweak this phrase?" <<std::endl; do { std::cout << "R#, L#, or rev: "; getline(std::cin, command); nextAction = parseCommand(command, cmdArgument); switch(nextAction) { case REV: reverseString(inputChars); std::cout << "Reverse: " << inputChars << std::endl; break; case LSHIFT: shiftString(inputChars, cmdArgument); std::cout << "Left " << cmdArgument << ": " << inputChars << std::endl; break; case RSHIFT: shiftString(inputChars, -(cmdArgument)); std::cout << "Right "<< cmdArgument << ": " << inputChars << std::endl; break; case QUIT: break; default: std::cout << "Didn't recognize that command, try again. (Type \"quit\" to quit)" << std::endl; break; } } while ( nextAction != QUIT ); }
void ListBox::initialiseOverride() { Base::initialiseOverride(); // FIXME нам нужен фокус клавы setNeedKeyFocus(true); // парсим свойства if (isUserString("SkinLine")) mSkinLine = getUserString("SkinLine"); if (isUserString("HeightLine")) mHeightLine = utility::parseInt(getUserString("HeightLine")); if (mHeightLine < 1) mHeightLine = 1; assignWidget(mClient, "Client"); if (mClient != nullptr) { mClient->eventMouseButtonPressed += newDelegate(this, &ListBox::notifyMousePressed); setWidgetClient(mClient); } assignWidget(mWidgetScroll, "VScroll"); if (mWidgetScroll != nullptr) { mWidgetScroll->eventScrollChangePosition += newDelegate(this, &ListBox::notifyScrollChangePosition); mWidgetScroll->eventMouseButtonPressed += newDelegate(this, &ListBox::notifyMousePressed); mWidgetScroll->setScrollPage((size_t)mHeightLine); mWidgetScroll->setScrollViewPage((size_t)mHeightLine); } updateScroll(); updateLine(); }
Profile::Profile(const QString &username) : _username(), _uuid(), _lastDomain(), _lastPosition(0.0, 0.0, 0.0), _lastOrientationSend(0) { if (!username.isEmpty()) { setUsername(username); // we've been given a new username, ask the data-server for profile DataServerClient::getValueForKeyAndUserString(DataServerKey::UUID, getUserString(), this); // send our current domain server to the data-server updateDomain(NodeList::getInstance()->getDomainHostname()); } }
void ItemBox::initialiseOverride() { Base::initialiseOverride(); // FIXME нам нужен фокус клавы setNeedKeyFocus(true); mDragLayer = "DragAndDrop"; if (isUserString("DragLayer")) mDragLayer = getUserString("DragLayer"); ///@wskin_child{ItemBox, Widget, Client} Клиентская зона. assignWidget(mClient, "Client"); if (mClient != nullptr) { mClient->eventMouseWheel += newDelegate(this, &ItemBox::notifyMouseWheel); mClient->eventMouseButtonPressed += newDelegate(this, &ItemBox::notifyMouseButtonPressed); mClient->eventMouseButtonReleased += newDelegate(this, &ItemBox::notifyMouseButtonReleased); setWidgetClient(mClient); } ///@wskin_child{ItemBox, ScrollBar, VScroll} Вертикальная полоса прокрутки. assignWidget(mVScroll, "VScroll"); if (mVScroll != nullptr) { mVScroll->eventScrollChangePosition += newDelegate(this, &ItemBox::notifyScrollChangePosition); } ///@wskin_child{ItemBox, ScrollBar, HScroll} Горизонтальная полоса прокрутки. assignWidget(mHScroll, "HScroll"); if (mHScroll != nullptr) { mHScroll->eventScrollChangePosition += newDelegate(this, &ItemBox::notifyScrollChangePosition); } // подписываем клиент для драгэндропа if (mClient != nullptr) mClient->_setContainer(this); requestItemSize(); updateScrollSize(); updateScrollPosition(); }
void Profile::updateOrientation(const glm::quat& orientation) { glm::vec3 eulerAngles = safeEulerAngles(orientation); if (_lastOrientation == eulerAngles) { return; } const quint64 DATA_SERVER_ORIENTATION_UPDATE_INTERVAL_USECS = 5 * 1000 * 1000; const float DATA_SERVER_ORIENTATION_CHANGE_THRESHOLD_DEGREES = 5.0f; quint64 now = usecTimestampNow(); if (now - _lastOrientationSend >= DATA_SERVER_ORIENTATION_UPDATE_INTERVAL_USECS && glm::distance(_lastOrientation, eulerAngles) >= DATA_SERVER_ORIENTATION_CHANGE_THRESHOLD_DEGREES) { DataServerClient::putValueForKeyAndUserString(DataServerKey::Orientation, QString(createByteArray(eulerAngles)), getUserString()); _lastOrientation = eulerAngles; _lastOrientationSend = now; } }
void MultiListBox::initialiseOverride() { Base::initialiseOverride(); std::string skinButtonEmpty; if (isUserString("SkinButton")) mSkinButton = getUserString("SkinButton"); if (isUserString("SkinList")) mSkinList = getUserString("SkinList"); if (isUserString("SkinSeparator")) mSkinSeparator = getUserString("SkinSeparator"); if (isUserString("WidthSeparator")) mWidthSeparator = utility::parseValue<int>(getUserString("WidthSeparator")); // OBSOLETE if (isUserString("HeightButton")) mHeightButton = utility::parseValue<int>(getUserString("HeightButton")); if (mHeightButton < 0) mHeightButton = 0; ///@wskin_child{MultiListBox, Widget, HeaderPlace} Место для заголовков колонок. assignWidget(mHeaderPlace, "HeaderPlace"); ///@wskin_child{MultiListBox, Widget, Client} Клиентская зона. assignWidget(mClient, "Client"); if (mClient != nullptr) setWidgetClient(mClient); if (nullptr == mClient) mClient = this; ///@wskin_child{MultiListBox, Widget, Empty} Виджет для заголовка в месте где нет списков. assignWidget(mWidgetEmpty, "Empty"); if (mWidgetEmpty == nullptr) { if (isUserString("SkinButtonEmpty")) skinButtonEmpty = getUserString("SkinButtonEmpty"); if (!skinButtonEmpty.empty()) mWidgetEmpty = mClient->createWidget<Widget>(skinButtonEmpty, IntCoord(0, 0, mClient->getWidth(), getButtonHeight()), Align::Default); } if (getUpdateByResize()) updateColumns(); }
/* * The real main function. * Make all instead of us. * Gets equation string, prepare it, and solve. * * @param argc - the int number of parameters passed to the main function. * @param argv - the array of pointers to parameters strings. */ void makeAll(int argc, char** argv) { do { // in configuration.h // show input rules if (USAGE) showUsage(); //String of equation. string equation = ""; if (argc > 1) { equation = argsToString(argc, argv); } else { equation = getUserString(); } cout << equation << " = " << calculate(equation) << endl; } while (repeat()); closeProgramManually(); //system("pause"); }
void ListCtrl::initialiseOverride() { Base::initialiseOverride(); // FIXME нам нужен фокус клавы setNeedKeyFocus(true); mDragLayer = "DragAndDrop"; if (isUserString("DragLayer")) mDragLayer = getUserString("DragLayer"); assignWidget(mClient, "Client"); if (mClient != nullptr) { mClient->eventMouseWheel += newDelegate(this, &ListCtrl::notifyMouseWheel); mClient->eventMouseButtonPressed += newDelegate(this, &ListCtrl::notifyMouseButtonPressed); setWidgetClient(mClient); } assignWidget(mVScroll, "VScroll"); if (mVScroll != nullptr) { mVScroll->eventScrollChangePosition += newDelegate(this, &ListCtrl::notifyScrollChangePosition); } assignWidget(mHScroll, "HScroll"); if (mHScroll != nullptr) { mHScroll->eventScrollChangePosition += newDelegate(this, &ListCtrl::notifyScrollChangePosition); } // подписываем клиент для драгэндропа _getClientWidget()->_setContainer(this); updateFromResize(); }
void MultiListBox::initialiseOverride() { Base::initialiseOverride(); std::string skinButtonEmpty; if (isUserString("SkinButton")) mSkinButton = getUserString("SkinButton"); if (isUserString("SkinList")) mSkinList = getUserString("SkinList"); if (isUserString("SkinSeparator")) mSkinSeparator = getUserString("SkinSeparator"); if (isUserString("WidthSeparator")) mWidthSeparator = utility::parseValue<int>(getUserString("WidthSeparator")); // OBSOLETE if (isUserString("HeightButton")) mHeightButton = utility::parseValue<int>(getUserString("HeightButton")); if (mHeightButton < 0) mHeightButton = 0; assignWidget(mHeaderPlace, "HeaderPlace"); assignWidget(mClient, "Client"); if (mClient != nullptr) setWidgetClient(mClient); if (nullptr == mClient) mClient = this; assignWidget(mWidgetEmpty, "Empty"); if (mWidgetEmpty == nullptr) { if (isUserString("SkinButtonEmpty")) skinButtonEmpty = getUserString("SkinButtonEmpty"); if (!skinButtonEmpty.empty()) mWidgetEmpty = mClient->createWidget<Widget>(skinButtonEmpty, IntCoord(0, 0, mClient->getWidth(), getButtonHeight()), Align::Default); } if (getUpdateByResize()) updateColumns(); }
void TabControl::initialiseOverride() { Base::initialiseOverride(); if (isUserString("ButtonSkin")) mButtonSkinName = getUserString("ButtonSkin"); // OBSOLETE if (isUserString("OffsetBar")) mOffsetTab = utility::parseValue<int>(getUserString("OffsetBar")); // OBSOLETE if (isUserString("EmptyBarSkin")) mEmptySkinName = getUserString("EmptyBarSkin"); // OBSOLETE assignWidget(mWidgetBar, "Bar"); if (mWidgetBar != nullptr) { mWidgetBar->setSize(mWidgetBar->getWidth() - mOffsetTab, mWidgetBar->getHeight()); } assignWidget(mButtonLeft, "Left"); if (mButtonLeft != nullptr) { mButtonLeft->eventMouseButtonClick += newDelegate(this, &TabControl::notifyPressedButtonEvent); } assignWidget(mButtonRight, "Right"); if (mButtonRight != nullptr) { mButtonRight->eventMouseButtonClick += newDelegate(this, &TabControl::notifyPressedButtonEvent); } // OBSOLETE assignWidget(mButtonDecor, "ButtonDecor"); if (mButtonDecor != nullptr) { mButtonDecor->setVisible(false); } assignWidget(mItemTemplate, "TabItem"); if (mItemTemplate != nullptr) { mItemTemplate->setVisible(false); } #ifndef MYGUI_DONT_USE_OBSOLETE if (mItemTemplate == nullptr) { assignWidget(mItemTemplate, "Sheet"); if (mItemTemplate != nullptr) { mItemTemplate->setVisible(false); } } #endif // MYGUI_DONT_USE_OBSOLETE // OBSOLETE Widget* showPatch = nullptr; assignWidget(showPatch, "ShowPatch"); if (showPatch != nullptr) { mWidgetsPatch.push_back(showPatch); showPatch->setVisible(false); } assignWidget(mHeaderPlace, "HeaderPlace"); assignWidget(mControls, "Controls"); assignWidget(mEmpty, "Empty"); if (mEmpty == nullptr) { // создаем виджет, носитель скина пустоты бара // OBSOLETE mEmptyBarWidget = _getWidgetBar()->createWidget<Widget>(mEmptySkinName, IntCoord(), Align::Left | Align::Top); } updateBar(); // FIXME добавленно, так как шетдаун вызывается и при смене скина mShutdown = false; }
void Profile::updatePosition(const glm::vec3 position) { if (_lastPosition != position) { static timeval lastPositionSend = {}; const quint64 DATA_SERVER_POSITION_UPDATE_INTERVAL_USECS = 5 * 1000 * 1000; const float DATA_SERVER_POSITION_CHANGE_THRESHOLD_METERS = 1; if (usecTimestampNow() - usecTimestamp(&lastPositionSend) >= DATA_SERVER_POSITION_UPDATE_INTERVAL_USECS && (fabsf(_lastPosition.x - position.x) >= DATA_SERVER_POSITION_CHANGE_THRESHOLD_METERS || fabsf(_lastPosition.y - position.y) >= DATA_SERVER_POSITION_CHANGE_THRESHOLD_METERS || fabsf(_lastPosition.z - position.z) >= DATA_SERVER_POSITION_CHANGE_THRESHOLD_METERS)) { // if it has been 5 seconds since the last position change and the user has moved >= the threshold // in at least one of the axis then send the position update to the data-server _lastPosition = position; // update the lastPositionSend to now gettimeofday(&lastPositionSend, NULL); // send the changed position to the data-server DataServerClient::putValueForKeyAndUserString(DataServerKey::Position, QString(createByteArray(position)), getUserString()); } } }
void ScrollBar::initialiseOverride() { Base::initialiseOverride(); // при нуле, будет игнорировать кнопки mScrollPage = 1; mScrollViewPage = 1; mScrollWheelPage = 1; mMinTrackSize = 0; mSkinRangeStart = 0; mSkinRangeEnd = 0; mRepeatTriggerTime = 0.5f; mRepeatStepTime = 0.1f; ///@wskin_child{ScrollBar, Button, Start} Кнопка начала диапазона. assignWidget(mWidgetStart, "Start"); if (mWidgetStart != nullptr) { mWidgetStart->eventMouseButtonPressed += newDelegate(this, &ScrollBar::notifyMousePressed); mWidgetStart->eventMouseButtonReleased += newDelegate(this, &ScrollBar::notifyMouseReleased); mWidgetStart->eventMouseWheel += newDelegate(this, &ScrollBar::notifyMouseWheel); } ///@wskin_child{ScrollBar, Button, End} Кнопка конца диапазона. assignWidget(mWidgetEnd, "End"); if (mWidgetEnd != nullptr) { mWidgetEnd->eventMouseButtonPressed += newDelegate(this, &ScrollBar::notifyMousePressed); mWidgetEnd->eventMouseButtonReleased += newDelegate(this, &ScrollBar::notifyMouseReleased); mWidgetEnd->eventMouseWheel += newDelegate(this, &ScrollBar::notifyMouseWheel); } ///@wskin_child{ScrollBar, Button, Track} Кнопка трекера. assignWidget(mWidgetTrack, "Track"); if (mWidgetTrack) { mWidgetTrack->eventMouseDrag += newDelegate(this, &ScrollBar::notifyMouseDrag); mWidgetTrack->eventMouseButtonPressed += newDelegate(this, &ScrollBar::notifyMousePressed); mWidgetTrack->eventMouseButtonReleased += newDelegate(this, &ScrollBar::notifyMouseReleased); mWidgetTrack->eventMouseWheel += newDelegate(this, &ScrollBar::notifyMouseWheel); mWidgetTrack->setVisible(false); } ///@wskin_child{ScrollBar, Widget, FirstPart} Виджет первой половины прокрутки от начала до трекера, при нажатии восприницмается как прокрутка страницы. assignWidget(mWidgetFirstPart, "FirstPart"); if (mWidgetFirstPart != nullptr) { mWidgetFirstPart->eventMouseButtonPressed += newDelegate(this, &ScrollBar::notifyMousePressed); mWidgetFirstPart->eventMouseButtonReleased += newDelegate(this, &ScrollBar::notifyMouseReleased); mWidgetFirstPart->eventMouseWheel += newDelegate(this, &ScrollBar::notifyMouseWheel); } ///@wskin_child{ScrollBar, Widget, SecondPart} Виджет второй половины прокрутки от трекера до конца, при нажатии восприницмается как прокрутка страницы. assignWidget(mWidgetSecondPart, "SecondPart"); if (mWidgetSecondPart != nullptr) { mWidgetSecondPart->eventMouseButtonPressed += newDelegate(this, &ScrollBar::notifyMousePressed); mWidgetSecondPart->eventMouseButtonReleased += newDelegate(this, &ScrollBar::notifyMouseReleased); mWidgetSecondPart->eventMouseWheel += newDelegate(this, &ScrollBar::notifyMouseWheel); } if (isUserString("MinTrackSize")) mMinTrackSize = utility::parseValue<int>(getUserString("MinTrackSize")); if (isUserString("TrackRangeMargins")) utility::parseComplex<size_t>(getUserString("TrackRangeMargins"), mSkinRangeStart, mSkinRangeEnd); if (mWidgetTrack != nullptr) { if (mWidgetTrack->isUserString("MinTrackSize")) mMinTrackSize = utility::parseValue<int>(mWidgetTrack->getUserString("MinTrackSize")); } }