Exemple #1
0
void ScrollBar::SetValue(int32_t value)
{
    if (value < GetMinValue())
    {
        value = GetMinValue();
    }
    else if (value > GetMaxValue())
    {
        value = GetMaxValue();
    }

    _value = value;

    (onValueChanged != 0) ? onValueChanged(this) : OnValueChanged();

    if (GetOrientation() == ORIENTATION_HORIZONTAL)
    {
        GetMarker()->SetX(static_cast<PosType>(GetMarkerOffsetX() + (Slider::GetWidth() -
                                               GetMarker()->GetWidth()) / ((GetMaxValue() - GetMinValue()) / static_cast<float>(GetValue()))));
        GetMarker()->SetY(GetMarkerOffsetY());
    }
    else
    {
        GetMarker()->SetX(GetMarkerOffsetX());
        GetMarker()->SetY(static_cast<PosType>(GetMarkerOffsetY() + (Slider::GetHeight() -
                                               GetMarker()->GetHeight()) / ((GetMaxValue() - GetMinValue()) /
                                                       static_cast<float>(GetValue()))));
    }
}
Exemple #2
0
void Slider::SetValue(int value) 
{ 
	if (value < GetMinValue())
	{
		value = GetMinValue();
	}
	else if (value > GetMaxValue())
	{
		value = GetMaxValue();
	}

	_value = value;

	(onValueChanged != 0) ? onValueChanged(this) : OnValueChangedEvent();

	if (GetOrientation() == ORIENTATION_VERTICAL)
	{
		GetMarker()->SetX(GetMarkerOffsetX());
		GetMarker()->SetY(static_cast<sint>(GetMarkerOffsetY() + GetHeight() / 
			((GetMaxValue() - GetMinValue()) / static_cast<float>(GetValue())) - GetMarker()->GetHeight() 
			/ 2.0f));
	}
	else
	{
		GetMarker()->SetX(static_cast<sint>(GetMarkerOffsetX() + GetWidth() / 
			((GetMaxValue() - GetMinValue()) / static_cast<float>(GetValue())) - GetMarker()->GetWidth() 
			/ 2.0f));
		GetMarker()->SetY(GetMarkerOffsetY());
	}
}
Exemple #3
0
void DMA1_Channel1_IRQHandler(void)
{
	uint8_t i;
	if(DMA_GetITStatus(DMA1_IT_TC1)) //
	{
		DMA_ClearITPendingBit(DMA1_IT_GL1);    //clear flag
		for(i=0;i<ADC_CHANNELS;i++)
		{
			adc_param.tim_adc_buf[i][adc_param.index] = adc_buf[i];
		}
		adc_param.index++;	
		
		if(adc_param.index >= ADC_TIM_BUF)
		{
			
			for(i=0;i<ADC_CHANNELS;i++)
			{
				//获取40次采样中的第二大的值
				adc_param.tim_200ms_buf[i][adc_param.tim_200ms_index]= GetMaxValue(1,adc_param.tim_adc_buf[i],ADC_TIM_BUF);
			}
			adc_param.tim_200ms_index++;
			if(adc_param.tim_200ms_index >= ADC_200MS_BUF)
			{
				for(i=0;i<ADC_CHANNELS;i++)
				{
					//获取10次最大值的平均值
					adc_param.adc_use_buf[i]= GetMaxValue(ADC_200MS_BUF/2,adc_param.tim_200ms_buf[i],ADC_200MS_BUF);
				}
				adc_param.tim_200ms_index = 0;
			}
			adc_param.index = 0;
			
		}
	}
}
Exemple #4
0
void Slider::MarkerOnMouseButtonDown(Control* control, int x, int y, uchar button)
{
	if (GetOrientation() == ORIENTATION_VERTICAL)
	{
		SetValue(static_cast<int>((GetMaxValue() - GetMinValue()) / static_cast<float>(GetHeight() / 
			static_cast<float>(y - GetAbsY()))));
	}
	else
	{
		SetValue(static_cast<int>((GetMaxValue() - GetMinValue()) / static_cast<float>(GetWidth() / 
			static_cast<float>(x - GetAbsX()))));
	}
}
void LogarithmicNumberAxis::UpdateBounds()
{
	if (m_fixedBounds) {
		return ; // bounds are fixed, so don't update
	}

	m_hasLabels = false;

	for (size_t n = 0; n < m_datasets.Count(); n++) {
		double minValue = GetMinValue(m_datasets[n]);
		double maxValue = GetMaxValue(m_datasets[n]);

		if (n == 0) {
			m_minValue = minValue;
			m_maxValue = maxValue;
		}
		else {
			m_minValue = wxMin(m_minValue, minValue);
			m_maxValue = wxMax(m_maxValue, maxValue);
		}
	}

	if (m_minValue == m_maxValue) {
		if (m_maxValue > 0) {
			m_minValue = 0;
		}
		else {
			m_maxValue = 0;
		}
	}

	UpdateTickValues();
	FireBoundsChanged();
}
Exemple #6
0
wxString pgSequence::GetSql(ctlTree *browser)
{
	if (sql.IsNull())
	{
		UpdateValues();
		sql = wxT("-- Sequence: ") + GetQuotedFullIdentifier() + wxT("\n\n")
		      + wxT("-- DROP SEQUENCE ") + GetQuotedFullIdentifier() + wxT(";")
		      + wxT("\n\nCREATE SEQUENCE ") + GetQuotedFullIdentifier()
		      + wxT("\n  INCREMENT ") + GetIncrement().ToString()
		      + wxT("\n  MINVALUE ") + GetMinValue().ToString()
		      + wxT("\n  MAXVALUE ") + GetMaxValue().ToString()
		      + wxT("\n  START ") + GetLastValue().ToString()
		      + wxT("\n  CACHE ") + GetCacheValue().ToString();
		if (GetCycled())
			sql += wxT("\n  CYCLE");
		sql += wxT(";\n")
		       + GetOwnerSql(7, 3, wxT("TABLE ") + GetQuotedFullIdentifier());

		if (!GetConnection()->BackendMinimumVersion(8, 2))
			sql += GetGrant(wxT("arwdRxt"), wxT("TABLE ") + GetQuotedFullIdentifier());
		else
			sql += GetGrant(wxT("rwU"), wxT("TABLE ") + GetQuotedFullIdentifier());

		sql += GetCommentSql();

		if (GetConnection()->BackendMinimumVersion(9, 1))
			sql += GetSeqLabelsSql();
	}

	return sql;
}
Exemple #7
0
void pgSequence::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	UpdateValues();
	if (properties)
	{
		CreateListColumns(properties);

		properties->AppendItem(_("Name"), GetName());
		properties->AppendItem(_("OID"), GetOid());
		properties->AppendItem(_("Owner"), GetOwner());
		properties->AppendItem(_("ACL"), GetAcl());
		properties->AppendItem(_("Current value"), GetLastValue());
		properties->AppendItem(_("Next value"), GetNextValue());
		properties->AppendItem(_("Minimum"), GetMinValue());
		properties->AppendItem(_("Maximum"), GetMaxValue());
		properties->AppendItem(_("Increment"), GetIncrement());
		properties->AppendItem(_("Cache"), GetCacheValue());
		properties->AppendYesNoItem(_("Cycled?"), GetCycled());
		properties->AppendYesNoItem(_("Called?"), GetCalled());
		properties->AppendYesNoItem(_("System sequence?"), GetSystemObject());
		properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));

		if (!GetLabels().IsEmpty())
		{
			wxArrayString seclabels = GetProviderLabelArray();
			if (seclabels.GetCount() > 0)
			{
				for (unsigned int index = 0 ; index < seclabels.GetCount() - 1 ; index += 2)
				{
					properties->AppendItem(seclabels.Item(index), seclabels.Item(index + 1));
				}
			}
		}
	}
}
Exemple #8
0
void Slider::MarkerOnMouseMove(Control* control, int x, int y)
{
	if (GetMarker()->IsPressed())
	{
		if (GetOrientation() == ORIENTATION_VERTICAL)
		{
			SetValue(static_cast<int>((GetMaxValue() - GetMinValue()) / 
				static_cast<float>(GetHeight() / static_cast<float>(y - GetAbsY()))));
		}
		else
		{
			SetValue(static_cast<int>((GetMaxValue() - GetMinValue()) / 
				static_cast<float>(GetWidth() / static_cast<float>(x - GetAbsX()))));
		}
	}
}
Exemple #9
0
Control* Slider::MouseButtonDownEvent(int x, int y, uchar button)
{
	Control* control = Control::MouseButtonDownEvent(x, y, button);
	if (control == this)
	{
		if (GetOrientation() == ORIENTATION_VERTICAL)
		{
			SetValue(static_cast<int>((GetMaxValue() - GetMinValue()) / 
				static_cast<float>(GetHeight() / static_cast<float>(y - GetAbsY()))));
		}
		else
		{
			SetValue(static_cast<int>((GetMaxValue() - GetMinValue()) / 
				static_cast<float>(GetWidth() / static_cast<float>(x - GetAbsX()))));
		}
	}
	return control;
}
Exemple #10
0
Control* Slider::MouseMoveEvent(int x, int y)
{
	Control* control = Control::MouseMoveEvent(x, y);
	if (control == this && IsPressed())
	{
		if (GetOrientation() == ORIENTATION_VERTICAL)
		{
			SetValue(static_cast<int>((GetMaxValue() - GetMinValue()) / 
				static_cast<float>(GetHeight() / static_cast<float>(y - GetAbsY()))));
		}
		else
		{
			SetValue(static_cast<int>((GetMaxValue() - GetMinValue()) / 
				static_cast<float>(GetWidth() / static_cast<float>(x - GetAbsX()))));
		}
	}
	return control;
}
Exemple #11
0
wxPolarAreaChart::wxPolarAreaChart(const wxPolarAreaChartData &data,
                                   const wxSize &size)
    : m_grid(size, GetMinValue(data.GetSlices()), GetMaxValue(data.GetSlices()),
        m_options.GetGridOptions())
{
    const wxVector<wxChartSliceData>& slices = data.GetSlices();
    for (size_t i = 0; i < slices.size(); ++i)
    {
        Add(slices[i], size);
    }
}
    uint32 GetSpace( SUser *user, uint8 building_type )
    {
        MacroCheckBuildingTypeReturn( building_type )

        uint32 max_value = GetMaxValue( user, building_type );

        //正常情况不会出现,只有在静态资源出错的情况下
        if ( max_value == 0 )
            return 0;

        return max_value - iter->ext.production;
    }
Exemple #13
0
void SpinButton::Pack()
{
  std::ostringstream max_value_s;
  max_value_s << GetMaxValue();
  uint max_value_w = (*Font::GetInstance(txtValue->GetFontSize())).GetWidth(max_value_s.str());

  m_plus->SetPosition(position.x + size.x - m_plus->GetSizeX(),
                      position.y + (size.y / 2) - (m_plus->GetSizeY() / 2));
  m_minus->SetPosition(position.x + size.x - (m_plus->GetSizeX() + max_value_w + m_plus->GetSizeX()),
                       position.y + (size.y / 2) - (m_minus->GetSizeY() / 2));

  txtLabel->SetMaxWidth(size.x - 30);
  size.y = txtLabel->GetHeight();
}
Exemple #14
0
void SpinButton::Draw(const Point2i & mousePosition)
{
  txtLabel->DrawCenterTop(position + Point2i(0, 6));

  uint center = m_plus->GetPositionX() - (m_plus->GetPositionX() - (m_minus->GetPositionX() + m_minus->GetSizeX())) / 2;
  txtValue->DrawCenterTop(Point2i(center, position.y)); //CenterTop

  if (GetValue() != GetMinValue()) {
    m_minus->Draw(mousePosition);
  }
  if (GetValue() != GetMaxValue()) {
    m_plus->Draw(mousePosition);
  }
}
    uint32 AddValue( SUser *user, uint8 building_type, uint32 value, uint32 path )
    {
        MacroCheckBuildingTypeReturn( building_type )

        uint32 old_count = iter->ext.production;
        uint32 now_count = iter->ext.production;
        uint32 max_value = GetMaxValue( user, building_type );


        if ( old_count + value > max_value )
            now_count = max_value;
        else
            now_count += value;

        iter->ext.production = now_count;

        return max_value - now_count;
    }
Exemple #16
0
SpinButton::SpinButton (const std::string & _label,
                        int width,
                        int value,
                        int step,
                        int min_value,
                        int max_value,
                        const Color & color,
                        bool _shadowed) :
  AbstractSpinButton(value,
                     step,
                     min_value,
                     max_value),
  shadowed(false),
  txtLabel(NULL),
  txtValue(NULL),
  m_plus(NULL),
  m_minus(NULL)
{
  position = Point2i(-1, -1);
  size.x = width;
  size.y = (*Font::GetInstance(Font::FONT_SMALL)).GetHeight();
  shadowed = _shadowed;

  Profile *res = GetResourceManager().LoadXMLProfile("graphism.xml", false);

  txtLabel = new Label(_label, 100, Font::FONT_SMALL, Font::FONT_NORMAL,
                       color, Text::ALIGN_LEFT_TOP, shadowed);
  txtLabel->SetMaxWidth(size.x - 30);

  txtValue = new Label(" ", 100, Font::FONT_SMALL, Font::FONT_NORMAL,
                       color, Text::ALIGN_LEFT_TOP, shadowed);
  std::ostringstream max_value_s;
  max_value_s << GetMaxValue();
  uint max_value_w = (*Font::GetInstance(Font::FONT_SMALL)).GetWidth(max_value_s.str());

  uint margin = 5;

  m_plus = new Button(res, "menu/plus");
  m_plus->SetPosition(position.x + size.x - 5, position.y);
  m_minus = new Button(res, "menu/minus");
  m_minus->SetPosition(position.x + size.x - max_value_w - 5 - 2 * margin, position.y);

  ValueHasChanged();
}
void pgSequence::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
    UpdateValues();
    if (properties)
    {
        CreateListColumns(properties);

        properties->AppendItem(_("Name"), GetName());
        properties->AppendItem(_("OID"), GetOid());
        properties->AppendItem(_("Owner"), GetOwner());
        properties->AppendItem(_("ACL"), GetAcl());
        properties->AppendItem(_("Current value"), GetLastValue());
        properties->AppendItem(_("Minimum"), GetMinValue());
        properties->AppendItem(_("Maximum"), GetMaxValue());
        properties->AppendItem(_("Increment"), GetIncrement());
        properties->AppendItem(_("Cache"), GetCacheValue());
        properties->AppendItem(_("Cycled?"), GetCycled());
        properties->AppendItem(_("Called?"), GetCalled());
        properties->AppendItem(_("System sequence?"), GetSystemObject());
        properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));
    }
}
void
LGAMiniArrowPopup::SetPopupMenuResID (	ResIDT	inResID )
{

	// е Only make the change if we have to
	if ( mPopupMenuResID != inResID )
	{
		mPopupMenuResID = inResID;
		
		// е Now we need to load the new menu and get it
		// saved into the cache
		SetMacMenuH ( LoadPopupMenuH () );
		
		// е Because the new menu might be shorter than the old one
		// we need to make sure the the current item is not off the
		// end of the menu, if it is we simply set the first item
		if ( GetValue () > GetMaxValue () )
			SetValue ( 1 );
			
		// е Get things redrawn so the changes can be seen
		Draw ( nil);
	}

}	//	LGAMiniArrowPopup::SetPopupMenuResID
void PluginPreference::SetValue(const wxString& value) {
  hasBeenSet_ = true;

  if (value_ == value) return;

  if (GetType() == PluginPreferenceType::Spinner) {

    double dValue;
    bool converted = value.ToDouble(&dValue);
    if (!converted) {
      ELOG(_T("PluginPreference: value is not a number"));
      return;
    }

    double fValue = (double)dValue;

    if (minValue_ != maxValue_) {
      if (fValue < minValue_ || fValue > maxValue_) {
        ELOG(wxString::Format(_T("PluginPreference: value of '%s' is not within correct range (%d, %d)."), GetName(), GetMinValue(), GetMaxValue()));
        return;
      }
    }

  }
    
  value_ = value;
  
  Invalidate();
}
                max_value = pData->speed6 * 8 * 60;
            }
            break;
        }

        return max_value;
    }

    uint32 SetMaxValue( SUser *user, uint8 building_type )
    {
        MacroCheckBuildingTypeReturn( building_type )

        if( building_type != kBuildingTypeGoldField && building_type != kBuildingTypeWaterFactory )
            return 0;

        iter->ext.production     = GetMaxValue( user,building_type );
        return iter->ext.production;
    }

    /********************针对性接口************************************/
    void CalculateOutput( SUser *user, uint8 building_type )
    {
        MacroCheckBuildingType( building_type )

        uint32 time_now  = (uint32)server::local_time();
        uint32 old_count = iter->ext.production;
        uint32 speed     = 1;

        CBuildingSpeedData::SData *pData = theBuildingSpeedExt.Find( iter->data.info_level );

        if( NULL == pData )