Ejemplo n.º 1
0
// ============================================================================
void AngleControl::SetPoint(int x, int y, BOOL bNegative/*=FALSE*/)
{
   float rad = m_diameter * 0.5f;

   Point2 point;
   point.x = x - rad;
   point.y = y - rad;
   point = Normalize(point);
   if (!m_dirCCW) point.y = -point.y;

   float m_newDegrees;
   m_newDegrees = RadToDeg(acos(point.x));
   if (point.y > 0.f) m_newDegrees = 360.f-m_newDegrees;

   m_newDegrees -= m_startDegrees;
   if (m_newDegrees < 0.f) m_newDegrees += 360.f;

   if (m_min >= 0.f && m_max >= 0.f) bNegative=FALSE;
   if (m_min <= 0.f && m_max <= 0.f) bNegative=TRUE;
   if(bNegative) m_newDegrees -= 360.f;

   BOOL newVal = FALSE;
   if (m_newDegrees >= m_min && m_newDegrees <= m_max)
   {  newVal = TRUE;
   }
   else // if (m_degrees != m_min && m_degrees != m_max)
   {  // figure out if m_degrees should be m_min, m_max, or 0
      float lo_min=m_min;
      float lo_max=m_max;
      if (!bNegative && lo_min < 0.0f && lo_max > 0.0f) lo_min=0.0f;
      else if (bNegative && lo_min < 0.0f && lo_max > 0.0f) lo_max=0.0f;
      Point2 pnt_min;
      pnt_min.x = rad + cos(DegToRad(lo_min+m_startDegrees))*rad;
      pnt_min.y = sin(DegToRad(lo_min+m_startDegrees))*rad;
      if (m_dirCCW)
         pnt_min.y = rad - pnt_min.y;
      else
         pnt_min.y += rad;
      Point2 pnt_max;
      pnt_max.x = rad + cos(DegToRad(lo_max+m_startDegrees))*rad;
      pnt_max.y = sin(DegToRad(lo_max+m_startDegrees))*rad;
      if (m_dirCCW)
         pnt_max.y = rad - pnt_max.y;
      else
         pnt_max.y += rad;
      Point2 origPoint = Point2((float)x,(float)y);
      if (Length(origPoint-pnt_min) < Length(origPoint-pnt_max))
         m_newDegrees=lo_min;
      else
         m_newDegrees=lo_max;
      newVal = TRUE;
   }

   if (newVal && m_newDegrees != m_degrees)
   {  m_degrees = m_newDegrees;
      CallChangedHandler();
      SendMessage(m_hToolTip, TTM_UPDATETIPTEXT, 0, (LPARAM)GetToolInfo());
      Invalidate();
   }
}
Ejemplo n.º 2
0
// ============================================================================
void AngleControl::SetDiameter(int dia)
{
   POINT pnt = {0,0};
   m_diameter = dia;

   MapWindowPoints(m_hWnd, parent_rollout->page, &pnt, 1);
   MoveWindow(m_hWnd, pnt.x, pnt.y, m_diameter, m_diameter, TRUE);
   SendMessage(m_hToolTip, TTM_SETTOOLINFO, 0, (LPARAM)GetToolInfo());
}
Ejemplo n.º 3
0
// ============================================================================
void AngleControl::SetDegrees(float deg)
{
   m_degrees = deg;
   if (m_degrees < m_min)
      m_degrees = m_min;
   else if (m_degrees > m_max)
      m_degrees = m_max;

   SendMessage(m_hToolTip, TTM_UPDATETIPTEXT, 0, (LPARAM)GetToolInfo());
   Invalidate();
   CallChangedHandler();
}
Ejemplo n.º 4
0
void wxDynamicToolBar::EnableTool(int toolIndex, bool enable )
{
    wxDynToolInfo* pInfo = GetToolInfo( toolIndex );

    if ( !pInfo )
        return;

    if ( pInfo->mIsSeparator || !pInfo->mpToolWnd )
        return;

    pInfo->mpToolWnd->Enable( enable );
}
Ejemplo n.º 5
0
void AngleControl::add_control(Rollout *ro, HWND parent, HINSTANCE hInstance, int& current_y)
{
   caption = caption->eval();

   HWND  label;
   int      left, top, width, height;
   SIZE  size;
   const TCHAR *label_text = caption->eval()->to_string();

   parent_rollout = ro;
   control_ID = next_id();
   WORD label_id = next_id();

   Value *val;
   if((val = control_param(diameter)) != &unsupplied)
      m_diameter = val->to_int();
   else if((val = control_param(width)) != &unsupplied)
      m_diameter = val->to_int();
   else if((val = control_param(height)) != &unsupplied)
      m_diameter = val->to_int();
   else
      m_diameter = 64;

   val = control_param(degrees);
   if(val != &unsupplied)
      m_degrees = val->to_float();
   else
      m_degrees = 0.f;

   val = control_param(radians);
   if(val != &unsupplied)
      m_degrees = RadToDeg(val->to_float());

   val = control_param(range);
   if (val == &unsupplied)
   {
      m_min = -360.0f; m_max = 360.0f;
   }
   else if (is_point3(val))
   {
      Point3 p = val->to_point3();
      m_min = p.x; m_max = p.y; m_degrees = p.z;
   }
   else
      throw TypeError (MaxSDK::GetResourceStringAsMSTR(IDS_ANGLE_RANGE_MUST_BE_A_VECTOR), val);

   val = control_param(startDegrees);
   if(val != &unsupplied)
      SetStartDegrees(val->to_float());
   else
      SetStartDegrees(0.f);

   val = control_param(startRadians);
   if(val != &unsupplied)
      SetStartDegrees(RadToDeg(val->to_float()));

   val = control_param(dir);
   if(val != &unsupplied)
   {
      if (val != n_CW && val != n_CCW)
         throw RuntimeError (MaxSDK::GetResourceStringAsMSTR(IDS_ANGLE_DIR_BAD_VALUE), val);
      m_dirCCW = val != n_CW;
   }

   val = control_param(bitmap);
   if(val != &unsupplied)
      SetBitmap(val);
   else
      SetColor(control_param(color));

   m_lButtonDown = FALSE;

   layout_data pos;
   compute_layout(ro, &pos, current_y);
   left = pos.left; top = pos.top;

   // place optional label
   int label_height = (_tcslen(label_text) != 0) ? ro->text_height + SPACING_BEFORE - 2 : 0;
   // LAM - defect 298613 - not creating the caption HWND was causing problems (whole screen redrawn
   // when control moved, setting caption text set wrong HWND). Now always create.
// if (label_height != 0)
// {
      DLGetTextExtent(ro->rollout_dc, label_text, &size);   
      width = min(size.cx, pos.width); height = ro->text_height;
      label = CreateWindow(_T("STATIC"),
                        label_text,
                        WS_VISIBLE | WS_CHILD | WS_GROUP,
                        left, top, width, height,    
                        parent, (HMENU)label_id, hInstance, NULL);
// }

   // place angle box
   top = pos.top + label_height;
   width = pos.width;

   m_hWnd = CreateWindow(
      ANGLECTRL_WINDOWCLASS,
      TEXT(""),
      WS_VISIBLE | WS_CHILD | WS_GROUP,
      pos.left, top, width, m_diameter,    
      parent, (HMENU)control_ID, g_hInst, this);

   m_hToolTip = CreateWindow(
      TOOLTIPS_CLASS,
      TEXT(""), WS_POPUP,
      CW_USEDEFAULT, CW_USEDEFAULT,
      CW_USEDEFAULT, CW_USEDEFAULT,
      m_hWnd, (HMENU)NULL, g_hInst, NULL);

   SendMessage(label, WM_SETFONT, (WPARAM)ro->font, 0L);
   SendMessage(m_hToolTip, TTM_ADDTOOL, 0, (LPARAM)GetToolInfo());
}