void TNameControl::MessageReceived(BMessage *msg) { switch (msg->what) { case M_SELECT: TextView()->Select(0, TextView()->TextLength()); break; default: BTextControl::MessageReceived(msg); } }
void BDecimalSpinner::SetValue(double value) { // clip to range if (value < fMinValue) value = fMinValue; else if (value > fMaxValue) value = fMaxValue; // update the text view char* format; asprintf(&format, "%%.%" B_PRId32 "f", fPrecision); char* valueString; asprintf(&valueString, format, value); TextView()->SetText(valueString); free(format); free(valueString); // update the up and down arrows SetIncrementEnabled(IsEnabled() && value < fMaxValue); SetDecrementEnabled(IsEnabled() && value > fMinValue); if (value == fValue) return; fValue = value; ValueChanged(); Invoke(); Invalidate(); }
void GameWaitView::draw(sf::RenderTarget& target, sf::RenderStates states) const { MenuView::draw(target, states); sf::View currentView = target.getView(); // TextView::setAbs(false); // // // Draw left time target.setView(m_centerSfView); target.draw(TextView(m_leftTimeText, 60, Center), states); sf::Vector2f sizeW = static_cast<sf::Vector2f> (target.getSize()); target.setView(sf::View({0.0f, 0.0f, sizeW.x, sizeW.y})); sf::Vector2f shipPos; shipPos.x = sizeW.x / 2; shipPos.y = 410.0f; // // target.setView(m_shipSfView); // std::string size = "widh(" + std::to_string(m_shipTexture.getSize().x) + "), height(" + std::to_string(m_shipTexture.getSize().y) + ")"; // target.draw(TextView(size, 60, Center), states); states.transform.translate(shipPos); states.texture = &m_shipTexture; target.draw(m_shapeShip, states); target.setView(currentView); }
void TNameControl::AttachedToWindow() { BTextControl::AttachedToWindow(); SetDivider(StringWidth(fLabel) + 6); TextView()->SetMaxBytes(B_FILE_NAME_LENGTH - 1); }
void BDecimalSpinner::_InitObject() { fMaxValue = 100.0; fMinValue = 0.0; fPrecision = 2; fStep = 1.0; fValue = 0.0; TextView()->SetAlignment(B_ALIGN_RIGHT); for (uint32 c = 0; c <= 42; c++) TextView()->DisallowChar(c); TextView()->DisallowChar('/'); for (uint32 c = 58; c <= 127; c++) TextView()->DisallowChar(c); }
void TimedAlert::MessageReceived(BMessage *msg) { if (msg->what == TIMEDALERT_UPDATE) { BString string; GetLabel(string); TextView()->SetText(string.String()); } else BAlert::MessageReceived(msg); }
LoginAlert::LoginAlert(nserror (*callback)(const char *username, const char *password, void *pw), void *callbackpw, nsurl *url, const char *host, const char *realm, const char *text) : BAlert("Login", text, "Cancel", "Ok", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT) { fCallback = callback; fCallbackPw = callbackpw; fUrl = url; fHost = host; fRealm = realm; SetFeel(B_MODAL_SUBSET_WINDOW_FEEL); /* // XXX: can't do that anymore nsbeos_scaffolding *s = nsbeos_get_scaffold(bw->window); if (s) { NSBrowserWindow *w = nsbeos_get_bwindow_for_scaffolding(s); if (w) AddToSubset(w); }*/ // make space for controls ResizeBy(0, 2 * TC_H); MoveTo(AlertPosition(Frame().Width() + 1, Frame().Height() + 1)); BTextView *tv = TextView(); BRect r(TC_MARGIN, tv->Bounds().bottom - 2 * TC_H, tv->Bounds().right - TC_MARGIN, tv->Bounds().bottom - TC_H); fUserControl = new BTextControl(r, "user", "Username", "", new BMessage(), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT); fUserControl->SetDivider(60); tv->AddChild(fUserControl); r.OffsetBySelf(0, TC_H); fPassControl = new BTextControl(r, "pass", "Password", "", new BMessage(), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT); fPassControl->TextView()->HideTyping(true); fPassControl->SetDivider(60); tv->AddChild(fPassControl); SetShortcut(0, B_ESCAPE); }
CurrencyBox::CurrencyBox(const char *name, const char *label, const char *text, BMessage *msg, uint32 flags) : NavTextBox(name,label,text,msg,flags) { SetFilter(new CurrencyBoxFilter(this)); const char amount_disallowed[]=" `~!@#%^&*()_-+=QWERTYUIOP{[}]|\\ASDFGHJKL;:'\"" "ZXCVBNM<>?/qwertyuiopasdfghjklzxcvbnm"; int32 i=0; while(amount_disallowed[i]) { TextView()->DisallowChar(amount_disallowed[i]); i++; } SetCharacterLimit(20); }
void AutoTextControl::OnlyAllowDigits(bool turnOn) { if (fOnlyDigits == turnOn) return; fOnlyDigits = turnOn; BTextView* view = TextView(); void (BTextView::*f)(uint32 byte) = turnOn ? &BTextView::DisallowChar : &BTextView::AllowChar; for (uint32 i = 0; i < '0'; i++) (view->*f)(i); for (uint32 i = '9' + 1; i < 256; i++) (view->*f)(i); }
void NumberControl::_InitControl(int32 maxBytes, bool allowNegative, bool continuos) { for (uint32 i = 0; i < 256; ++i) TextView()->DisallowChar(i); TextView()->AllowChar('0'); TextView()->AllowChar('1'); TextView()->AllowChar('2'); TextView()->AllowChar('3'); TextView()->AllowChar('4'); TextView()->AllowChar('5'); TextView()->AllowChar('6'); TextView()->AllowChar('7'); TextView()->AllowChar('8'); TextView()->AllowChar('9'); if (allowNegative) TextView()->AllowChar('-'); TextView()->SetMaxBytes(maxBytes); SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); }
void HTextControl::SetText(const char *text) { BTextControl::SetText(text); if (IsFocus()) TextView()->SelectAll(); } /* HTextControl::SetText */
/*------------------------------------------------------------------------------*\ ( ) - \*------------------------------------------------------------------------------*/ void BmTextControl::FrameResized( float new_width, float new_height) { BRect curr = Bounds(); Invalidate( BRect( Divider(), 0, new_width-1, curr.Height())); inherited::FrameResized( new_width, new_height); TextView()->ScrollToSelection(); }
/*------------------------------------------------------------------------------*\ ( ) - \*------------------------------------------------------------------------------*/ void BmTextControl::SetText( const char* text) { inherited::SetText( text); TextView()->ScrollToSelection(); }
void BAlert::SetText(const char* text) { TextView()->SetText(text); }
void BDecimalSpinner::SetValueFromText() { SetValue(roundTo(atof(TextView()->Text()), Precision())); }
void ClientStateGameEnd::render(sf::RenderWindow& window) const { ClientStateGameStarted::render(window); window.setView(window.getDefaultView()); window.draw(TextView("Someone has win the game", 40, TypeAlign::Center)); }
void CMsgBodyControlEditor::HandlePointerEventL( const TPointerEvent& aPointerEvent ) { TBool forwardRequest( ETrue ); if ( IsActivated() && IsReadOnly() && ( aPointerEvent.iType == TPointerEvent::EButton1Down || aPointerEvent.iType == TPointerEvent::EButton1Up ) ) { TPoint tapPoint( aPointerEvent.iPosition ); TInt docPos( TextView()->XyPosToDocPosL( tapPoint ) ); TInt start( 0 ); TInt length( 0 ); MParser* parser = iItemFinder; TBool tappedOverTag( RichText()->CursorOverTag( docPos, parser, start, length ) ); if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) { iPreviousItemStart = -1; iPreviousItemLength = -1; if ( tappedOverTag ) { TPoint relativeTapPoint( aPointerEvent.iPosition - iPosition ); if ( iItemFinder->ItemWasTappedL( relativeTapPoint ) ) { iPreviousItemStart = start; iPreviousItemLength = length; forwardRequest = EFalse; } } else { iItemFinder->ResetCurrentItem(); } } else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) { if ( tappedOverTag && start >= iPreviousItemStart && length <= iPreviousItemLength ) { TKeyEvent event; event.iCode = EKeyDevice3; event.iScanCode = EStdKeyDevice3; event.iModifiers = 0; event.iRepeats = 0; iCoeEnv->WsSession().SimulateKeyEvent( event ); forwardRequest = EFalse; } } } if ( forwardRequest ) { CMsgExpandableControlEditor::HandlePointerEventL( aPointerEvent ); } #ifdef RD_TACTILE_FEEDBACK else if(aPointerEvent.iType == TPointerEvent::EButton1Down) { MTouchFeedback* feedback = MTouchFeedback::Instance(); if ( feedback ) { feedback->InstantFeedback( this, ETouchFeedbackBasic ); } } #endif // RD_TACTILE_FEEDBACK }