void CGUIFixedListContainer::ValidateOffset() { if (!m_layout) return; // ensure our fixed cursor position is valid if (m_fixedCursor >= m_itemsPerPage) m_fixedCursor = m_itemsPerPage - 1; if (m_fixedCursor < 0) m_fixedCursor = 0; // compute our minimum and maximum cursor positions int minCursor, maxCursor; GetCursorRange(minCursor, maxCursor); // assure our cursor is between these limits SetCursor(std::max(GetCursor(), minCursor)); SetCursor(std::min(GetCursor(), maxCursor)); int minOffset, maxOffset; GetOffsetRange(minOffset, maxOffset); // and finally ensure our offset is valid // don't validate offset if we are scrolling in case the tween image exceed <0, 1> range if (GetOffset() > maxOffset || (!m_scroller.IsScrolling() && m_scroller.GetValue() > maxOffset * m_layout->Size(m_orientation))) { SetOffset(std::max(-minCursor, maxOffset)); m_scroller.SetValue(GetOffset() * m_layout->Size(m_orientation)); } if (GetOffset() < minOffset || (!m_scroller.IsScrolling() && m_scroller.GetValue() < minOffset * m_layout->Size(m_orientation))) { SetOffset(minOffset); m_scroller.SetValue(GetOffset() * m_layout->Size(m_orientation)); } }
EVENT_RESULT CGUIBaseContainer::OnMouseEvent(const CPoint &point, const CMouseEvent &event) { if (event.m_id >= ACTION_MOUSE_LEFT_CLICK && event.m_id <= ACTION_MOUSE_DOUBLE_CLICK) { if (SelectItemFromPoint(point - CPoint(m_posX, m_posY))) { OnClick(event.m_id); return EVENT_RESULT_HANDLED; } } else if (event.m_id == ACTION_MOUSE_WHEEL_UP) { Scroll(-1); return EVENT_RESULT_HANDLED; } else if (event.m_id == ACTION_MOUSE_WHEEL_DOWN) { Scroll(1); return EVENT_RESULT_HANDLED; } else if (event.m_id == ACTION_GESTURE_NOTIFY) { return (m_orientation == HORIZONTAL) ? EVENT_RESULT_PAN_HORIZONTAL : EVENT_RESULT_PAN_VERTICAL; } else if (event.m_id == ACTION_GESTURE_BEGIN) { // grab exclusive access CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, GetID(), GetParentID()); SendWindowMessage(msg); return EVENT_RESULT_HANDLED; } else if (event.m_id == ACTION_GESTURE_PAN) { // do the drag and validate our offset (corrects for end of scroll) m_scroller.SetValue(m_scroller.GetValue() - ((m_orientation == HORIZONTAL) ? event.m_offsetX : event.m_offsetY)); float size = (m_layout) ? m_layout->Size(m_orientation) : 10.0f; int offset = (int)MathUtils::round_int(m_scroller.GetValue() / size); m_lastScrollStartTimer.Stop(); m_scrollTimer.Start(); SetOffset(offset); ValidateOffset(); return EVENT_RESULT_HANDLED; } else if (event.m_id == ACTION_GESTURE_END) { // release exclusive access CGUIMessage msg(GUI_MSG_EXCLUSIVE_MOUSE, 0, GetParentID()); SendWindowMessage(msg); m_scrollTimer.Stop(); // and compute the nearest offset from this and scroll there float size = (m_layout) ? m_layout->Size(m_orientation) : 10.0f; float offset = m_scroller.GetValue() / size; int toOffset = (int)MathUtils::round_int(offset); if (toOffset < offset) SetOffset(toOffset+1); else SetOffset(toOffset-1); ScrollToOffset(toOffset); return EVENT_RESULT_HANDLED; } return EVENT_RESULT_UNHANDLED; }
ReturnValue FileInputResource::ReadFrom(int offset, void* pBuffer, size_t count) { if(mInputStream.is_open()) { int oldOffset=GetOffset(); SetOffset(offset); Read(pBuffer,count); SetOffset(oldOffset); } }
//! peeks a character without advancing the file pointer char CacheFile::Peek() { char c; Read(&c, 1); SetOffset(-1); return c; }
// Updates the position of the document based on the style properties. void ElementDocument::UpdatePosition() { // We are only positioned relative to our parent, so if we're not parented we may as well bail now. if (GetParentNode() == NULL) return; Vector2f position; // Work out our containing block; relative offsets are calculated against it. Vector2f containing_block = GetParentNode()->GetBox().GetSize(Box::CONTENT); const Property *left = GetLocalProperty(LEFT); const Property *right = GetLocalProperty(RIGHT); if (left != NULL && left->unit != Property::KEYWORD) position.x = ResolveProperty(LEFT, containing_block.x); else if (right != NULL && right->unit != Property::KEYWORD) position.x = (containing_block.x - GetBox().GetSize(Box::MARGIN).x) - ResolveProperty(RIGHT, containing_block.x); else position.x = GetBox().GetEdge(Box::MARGIN, Box::LEFT); const Property *top = GetLocalProperty(TOP); const Property *bottom = GetLocalProperty(BOTTOM); if (top != NULL && top->unit != Property::KEYWORD) position.y = ResolveProperty(TOP, containing_block.y); else if (bottom != NULL && bottom->unit != Property::KEYWORD) position.y = (containing_block.y - GetBox().GetSize(Box::MARGIN).y) - ResolveProperty(BOTTOM, containing_block.y); else position.y = GetBox().GetEdge(Box::MARGIN, Box::TOP); SetOffset(position, NULL); }
CPLErr VRTRasterBand::CopyCommonInfoFrom( GDALRasterBand * poSrcBand ) { SetMetadata( poSrcBand->GetMetadata() ); const char* pszNBits = poSrcBand->GetMetadataItem("NBITS", "IMAGE_STRUCTURE"); SetMetadataItem( "NBITS", pszNBits, "IMAGE_STRUCTURE" ); const char* pszPixelType = poSrcBand->GetMetadataItem("PIXELTYPE", "IMAGE_STRUCTURE"); SetMetadataItem( "PIXELTYPE", pszPixelType, "IMAGE_STRUCTURE" ); SetColorTable( poSrcBand->GetColorTable() ); SetColorInterpretation(poSrcBand->GetColorInterpretation()); if( strlen(poSrcBand->GetDescription()) > 0 ) SetDescription( poSrcBand->GetDescription() ); int bSuccess; double dfNoData; dfNoData = poSrcBand->GetNoDataValue( &bSuccess ); if( bSuccess ) SetNoDataValue( dfNoData ); SetOffset( poSrcBand->GetOffset() ); SetScale( poSrcBand->GetScale() ); SetCategoryNames( poSrcBand->GetCategoryNames() ); if( !EQUAL(poSrcBand->GetUnitType(),"") ) SetUnitType( poSrcBand->GetUnitType() ); return CE_None; }
void CGUIBaseContainer::ScrollToOffset(int offset) { int minOffset, maxOffset; if(GetOffsetRange(minOffset, maxOffset)) offset = std::max(minOffset, std::min(offset, maxOffset)); float size = (m_layout) ? m_layout->Size(m_orientation) : 10.0f; int range = ScrollCorrectionRange(); if (offset * size < m_scroller.GetValue() && m_scroller.GetValue() - offset * size > size * range) { // scrolling up, and we're jumping more than 0.5 of a screen m_scroller.SetValue((offset + range) * size); } if (offset * size > m_scroller.GetValue() && offset * size - m_scroller.GetValue() > size * range) { // scrolling down, and we're jumping more than 0.5 of a screen m_scroller.SetValue((offset - range) * size); } m_scroller.ScrollTo(offset * size); m_lastScrollStartTimer.StartZero(); if (!m_wasReset) { SetContainerMoving(offset - GetOffset()); if (m_scroller.IsScrolling()) m_scrollTimer.Start(); else m_scrollTimer.Stop(); } SetOffset(offset); }
void CGUIPanelContainer::ValidateOffset() { if (!m_layout) return; // first thing is we check the range of our offset // don't validate offset if we are scrolling in case the tween image exceed <0, 1> range if (GetOffset() > (int)GetRows() - m_itemsPerPage || (!m_scroller.IsScrolling() && m_scroller.GetValue() > ((int)GetRows() - m_itemsPerPage) * m_layout->Size(m_orientation))) { SetOffset(std::max(0, (int)GetRows() - m_itemsPerPage)); m_scroller.SetValue(GetOffset() * m_layout->Size(m_orientation)); } if (GetOffset() < 0 || (!m_scroller.IsScrolling() && m_scroller.GetValue() < 0)) { SetOffset(0); m_scroller.SetValue(0); } }
void UIFont::CopyFrom(UIFont *Other) { if (!Other) return; SetFace(Other->GetFace()); SetColor(Other->GetColor()); SetBrush(Other->GetBrush()); QPoint offset; QColor color; int blur; quint16 size; Other->GetShadow(offset, color, blur); SetShadow(Other->HasShadow(), offset, color, blur); Other->GetOutline(color, size); SetOutline(Other->HasOutline(), color, size); SetOffset(Other->GetOffset()); SetRelativeSize(Other->GetRelativeSize()); SetSize(Other->GetFace().pixelSize()); SetStretch(Other->GetStretch()); SetImageFileName(Other->GetImageFileName()); SetImageReady(Other->GetImageReady()); UIImage* image = Other->GetImage(); if (image) { SetImage(image); m_image->UpRef(); } }
static void DoScroll( HWND wnd, int dx, int dy, BOOL lock ) /*********************************************************/ { /* scroll 'wnd' by 'dx' and 'dy'. 'lock' says to lock the scrolling on the */ /* bottom and right into the scrolling rectangle */ POINT offset; RECT srect; GetOffset( &offset ); GetScrollBounds( &srect, lock ); dx = AdjustScroll( offset.x, srect.left, srect.right, dx ); dy = AdjustScroll( offset.y, srect.top, srect.bottom, dy ); if( dx != 0 || dy != 0 ) { offset.x += dx; offset.y += dy; SetOffset( offset ); ScrollWindow( wnd, -dx, -dy, NULL, NULL ); if( GetScrollConfig() & SCROLL_HORZ ) { SetScrollPos( wnd, SB_HORZ, offset.x, TRUE ); } if( GetScrollConfig() & SCROLL_VERT ) { SetScrollPos( wnd, SB_VERT, offset.y, TRUE ); } } }
bool GetFeatureRequest::Create(rude::CGI& cgi, Map* pMap) { WebContext* pWebContext = augeGetWebContextInstance(); char parameter[AUGE_NAME_MAX]; SetVersion(cgi["version"]); //auge_web_parameter_encoding(, parameter, AUGE_NAME_MAX, pWebContext->IsIE()); SetTypeName(cgi["typeName"],true); auge_web_parameter_encoding(cgi["sourceName"], parameter, AUGE_NAME_MAX, pWebContext->IsIE()); SetSourceName(parameter); //auge_web_parameter_encoding(cgi["mapName"], parameter, AUGE_NAME_MAX, pWebContext->IsIE()); SetMapName(cgi["mapName"], true); SetOutputFormat(cgi["outputFormat"]); SetMaxFeatures(cgi["maxFeatures"]); SetOffset(cgi["offset"]); SetBBox(cgi["bbox"]); SetEncoding(cgi["encoding"]); m_filter = cgi["filter"]; m_fields = cgi["fields"]; //if(!m_extent.IsValid()) //{ // SetQuery(cgi["filter"],cgi["fields"], GetTypeName(), pMap); //} return true; }
bool WaveClip::HandleXMLTag(const wxChar *tag, const wxChar **attrs) { if (!wxStrcmp(tag, wxT("waveclip"))) { double dblValue; while (*attrs) { const wxChar *attr = *attrs++; const wxChar *value = *attrs++; if (!value) break; const wxString strValue = value; if (!wxStrcmp(attr, wxT("offset"))) { if (!XMLValueChecker::IsGoodString(strValue) || !Internat::CompatibleToDouble(strValue, &dblValue)) return false; SetOffset(dblValue); } } return true; } return false; }
void ClothoidPath::OptimiseLine( const CarModel& cm, int idx, int step, double hLimit, PathPt* l3, const PathPt* l2, const PathPt* l4 ) { LinearRegression l; const int NSEG = m_pTrack->GetSize(); int i = (idx + NSEG - step) % NSEG; while( m_pPath[i].h > hLimit ) { l.Sample( m_pPath[i].pt.GetXY() ); i = (i + NSEG - step) % NSEG; } l.Sample( m_pPath[i].pt.GetXY() ); i = idx; while( m_pPath[i].h > hLimit ) { l.Sample( m_pPath[i].pt.GetXY() ); i = (i + step) % NSEG; } l.Sample( m_pPath[i].pt.GetXY() ); GfOut( "%4d ", idx ); Vec2d p, v; l.CalcLine( p, v ); double t; Utils::LineCrossesLine( l3->Pt().GetXY(), l3->Norm().GetXY(), p, v, t ); SetOffset( cm, 0, t, l3, l2, l4 ); }
Hublot::Hublot ( double room_width, double room_height, double thickness ) { float rim_color[4] = { 0.8, 0.3, 0.3, 1.0 }; float parois_color[4] = { 0.8, 0.3, 0.3, 1.0 }; this->room_width = room_width; this->room_height = room_height; bulkhead = new Hole( 500.0, room_width, room_height * 5.0 ); bulkhead->SetColor( bulkhead_color ); AddComponent( bulkhead ); edge1 = new Cylinder( 500.0, 500.0, thickness ); edge1->SetColor( parois_color ); AddComponent( edge1 ); edge2 = new Cylinder( 500.0 + BORDER_THICKNESS, 500.0 + BORDER_THICKNESS, thickness ); edge2->SetColor( rim_color ); AddComponent( edge2 ); border = new Disk( 500.0 + BORDER_THICKNESS, 500.0 ); border->SetOffset( 0.0, 0.0, thickness ); border->SetColor( rim_color ); AddComponent( border ); SetOffset( 0.0, room_height / 2.0, 0.0 ); }
void CShadowUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) { if (lstrcmpi(pstrName, _T("offset")) == 0) { POINT pt = { 0 }; LPTSTR pstr = NULL; pt.x = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); pt.y = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetOffset(pt); } else if (lstrcmpi(pstrName, _T("drag")) == 0) { SetDrag(lstrcmpi(pstrValue, _T("true")) == 0); } else if (lstrcmpi(pstrName, _T("traversal")) == 0) { SetTraversal(lstrcmpi(pstrValue, _T("true")) == 0); } else if (lstrcmpi(pstrName, _T("activeimage")) == 0) { SetActiveImage(pstrValue); } else if (lstrcmpi(pstrName, _T("deactiveimage")) == 0) { SetDeactiveImage(pstrValue); } else { CControlUI::SetAttribute(pstrName, pstrValue); } }
void D_PAD::ImportSettingsFromMaster( const D_PAD& aMasterPad ) { SetShape( aMasterPad.GetShape() ); SetLayerSet( aMasterPad.GetLayerSet() ); SetAttribute( aMasterPad.GetAttribute() ); // The pad orientation, for historical reasons is the // pad rotation + parent rotation. // So we have to manage this parent rotation double pad_rot = aMasterPad.GetOrientation(); if( aMasterPad.GetParent() ) pad_rot -= aMasterPad.GetParent()->GetOrientation(); if( GetParent() ) pad_rot += GetParent()->GetOrientation(); SetOrientation( pad_rot ); SetSize( aMasterPad.GetSize() ); SetDelta( wxSize( 0, 0 ) ); SetOffset( aMasterPad.GetOffset() ); SetDrillSize( aMasterPad.GetDrillSize() ); SetDrillShape( aMasterPad.GetDrillShape() ); SetRoundRectRadiusRatio( aMasterPad.GetRoundRectRadiusRatio() ); switch( aMasterPad.GetShape() ) { case PAD_SHAPE_TRAPEZOID: SetDelta( aMasterPad.GetDelta() ); break; case PAD_SHAPE_CIRCLE: // ensure size.y == size.x SetSize( wxSize( GetSize().x, GetSize().x ) ); break; default: ; } switch( aMasterPad.GetAttribute() ) { case PAD_ATTRIB_SMD: case PAD_ATTRIB_CONN: // These pads do not have hole (they are expected to be only on one // external copper layer) SetDrillSize( wxSize( 0, 0 ) ); break; default: ; } // Add or remove custom pad shapes: SetPrimitives( aMasterPad.GetPrimitives() ); SetAnchorPadShape( aMasterPad.GetAnchorPadShape() ); MergePrimitivesAsPolygon(); }
TrLadGain::TrLadGain(int hwid, float* gain, float* offset, float* syserr, int* status) { Clear(); SetHwId(hwid); SetGain(gain); SetOffset(offset); SetSysErr(syserr); SetStatus(status); }
void FMEDITAPI NewOffset( POINT point ) /*************************************/ { // Set the offset to 'point' and reset the scrolling stuff SetOffset( point ); UpdateScroll(); InvalidateRect( GetAppWnd(), NULL, TRUE ); }
void FileInputResource::Skip(int bytes) { if(mInputStream.is_open()) { int offset=GetOffset(); SetOffset(offset+bytes); } }
void LIB_BEZIER::Move( const wxPoint& aPosition ) { if ( !m_PolyPoints.size() ) { m_PolyPoints.push_back( wxPoint(0, 0) ); } SetOffset( aPosition - m_PolyPoints[0] ); }
int GDALJP2Box::ReadFirstChild( GDALJP2Box *poSuperBox ) { szBoxType[0] = '\0'; if( !poSuperBox->IsSuperBox() ) return FALSE; return SetOffset( poSuperBox->nDataOffset ) && ReadBox(); }
bool TrLadGain::LinearToGainDB(float* offset) { if (!offset) return false; SetHwId((int)offset[0]); SetGain(offset+1); SetOffset(offset+1+16); SetSysErr(offset+1+16+16); SetStatus(offset+1+16+16+16); return true; }
Node::Node(int id) { this->id = id; SetOffset(50, 50); SetSize(10, 10); mApplication->AddRenderable(this); // Immediately add a node when it is initialized // Benefit: No need to separately add nodes later on }
void CGUIListContainer::ValidateOffset() { if (!m_layout) return; // first thing is we check the range of our offset // don't validate offset if we are scrolling in case the tween image exceed <0, 1> range int minOffset, maxOffset; GetOffsetRange(minOffset, maxOffset); if (GetOffset() > maxOffset || (!m_scroller.IsScrolling() && m_scroller.GetValue() > maxOffset * m_layout->Size(m_orientation))) { SetOffset(std::max(0, maxOffset)); m_scroller.SetValue(GetOffset() * m_layout->Size(m_orientation)); } if (GetOffset() < 0 || (!m_scroller.IsScrolling() && m_scroller.GetValue() < 0)) { SetOffset(0); m_scroller.SetValue(0); } }
// Offsets the view to make sure viewspace point viewp is over // projectspace point projp. void EditView::AlignView( Point const& viewp, Point const& projp ) { Point p = ViewToProj( viewp ); int dx = projp.x - p.x; int dy = projp.y - p.y; Point o = Offset(); o.x += dx; o.y += dy; SetOffset( o); }
//Trim trims within a clip, rather than trimming everything. //If a bound is outside a clip, it trims everything. bool WaveTrack::Trim (double t0, double t1) { bool inside0 = false; bool inside1 = false; //Keeps track of the offset of the first clip greater than // the left selection t0. double firstGreaterOffset = -1; WaveClipList::Node * it; for(it = GetClipIterator(); it; it = it->GetNext()) { WaveClip * clip = it->GetData(); //Find the first clip greater than the offset. //If we end up clipping the entire track, this is useful. if(firstGreaterOffset < 0 && clip->GetStartTime() >= t0) firstGreaterOffset = clip->GetStartTime(); if(t1 > clip->GetStartTime() && t1 < clip->GetEndTime()) { if (!clip->Clear(t1,clip->GetEndTime())) return false; inside1 = true; } if(t0 > clip->GetStartTime() && t0 < clip->GetEndTime()) { if (!clip->Clear(clip->GetStartTime(),t0)) return false; clip->SetOffset(t0); inside0 = true; } } //if inside0 is false, then the left selector was between //clips, so delete everything to its left. if(false == inside1) { if (!Clear(t1,GetEndTime())) return false; } if(false == inside0) { if (!Clear(0,t0)) return false; //Reset the track offset to be at the point of the first remaining clip. SetOffset(firstGreaterOffset ); } return true; }
void MovingEntity::Move(float delta){ m_Position += m_Heading * m_Speed; // * delta; //Debug purpose: int x = (int)m_Position.x % SCREEN_WIDTH; int y = (int)m_Position.y % SCREEN_HEIGHT; if (x > SCREEN_WIDTH) x -= SCREEN_WIDTH;//possible fix for negavtive x/y values if (x <= 0) x += SCREEN_WIDTH; SetOffset(x, y); }
bool NoteTrack::HandleXMLTag(const wxChar *tag, const wxChar **attrs) { if (!wxStrcmp(tag, wxT("notetrack"))) { while (*attrs) { const wxChar *attr = *attrs++; const wxChar *value = *attrs++; if (!value) break; const wxString strValue = value; long nValue; double dblValue; if (!wxStrcmp(attr, wxT("name")) && XMLValueChecker::IsGoodString(strValue)) mName = strValue; else if (!wxStrcmp(attr, wxT("offset")) && XMLValueChecker::IsGoodString(strValue) && Internat::CompatibleToDouble(strValue, &dblValue)) SetOffset(dblValue); else if (!wxStrcmp(attr, wxT("visiblechannels"))) { if (!XMLValueChecker::IsGoodInt(strValue) || !strValue.ToLong(&nValue) || !XMLValueChecker::IsValidVisibleChannels(nValue)) return false; mVisibleChannels = nValue; } else if (!wxStrcmp(attr, wxT("height")) && XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) mHeight = nValue; else if (!wxStrcmp(attr, wxT("minimized")) && XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) mMinimized = (nValue != 0); else if (!wxStrcmp(attr, wxT("isSelected")) && XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) this->SetSelected(nValue != 0); #ifdef EXPERIMENTAL_MIDI_OUT else if (!wxStrcmp(attr, wxT("velocity")) && XMLValueChecker::IsGoodString(strValue) && Internat::CompatibleToDouble(strValue, &dblValue)) mGain = (float) dblValue; #endif else if (!wxStrcmp(attr, wxT("bottomnote")) && XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) SetBottomNote(nValue); else if (!wxStrcmp(attr, wxT("data"))) { std::string s(strValue.mb_str(wxConvUTF8)); std::istringstream data(s); mSeq = new Alg_seq(data, false); } } // while return true; } return false; }
bool CGUIListContainer::OnMessage(CGUIMessage& message) { if (message.GetControlId() == GetID() ) { if (message.GetMessage() == GUI_MSG_LABEL_RESET) { SetCursor(0); SetOffset(0); m_scroller.SetValue(0); } } return CGUIBaseContainer::OnMessage(message); }
bool NoteTrack::Trim(double t0, double t1) { if (t1 <= t0) return false; mSeq->convert_to_seconds(); // delete way beyond duration just in case something is out there: mSeq->clear(t1 - GetOffset(), mSeq->get_dur() + 10000.0, false); // Now that stuff beyond selection is cleared, clear before selection: mSeq->clear(0.0, t0 - GetOffset(), false); // want starting time to be t0 SetOffset(t0); return true; }