Exemplo n.º 1
0
// -----------------------------------------------------------------------------
//	StillTracking
// -----------------------------------------------------------------------------
//	Called during tracking.
//
OSStatus TValuePictControl::StillTracking(TCarbonEvent&inEvent, HIPoint& from)
{
    HIPoint mouse;
    float deltaX, deltaY;
    SInt32 mini, maxi;

    mini = GetMinimum();
    maxi = GetMaximum();

    inEvent.GetParameter<HIPoint>( kEventParamWindowMouseLocation, typeHIPoint, &mouse );
    ConvertToLocal(mouse);

    SInt32 curVal = GetValue();
    deltaX = mouse.x-from.x;
    deltaY = mouse.y-from.y;

    SInt32 val = SInt32(rint(curVal + (deltaX - deltaY) * (maxi - mini) / 300.));
    if ( val > maxi) val = maxi;
    if ( val < mini) val = mini;
    if (val != curVal) {
		SetValue ( val );
		from = mouse;
    }
    return noErr;
}
Exemplo n.º 2
0
void TextShape::DrawSubString(ref_ptr<dp::GraphicsContext> context, StraightTextLayout & layout,
                              dp::FontDecl const & font, glm::vec2 const & baseOffset,
                              ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures,
                              bool isPrimary, bool isOptional) const
{
  glsl::vec2 const pt = glsl::ToVec2(ConvertToLocal(m_basePoint, m_params.m_tileCenter, kShapeCoordScalar));
  layout.SetBasePosition(glsl::vec4(pt, m_params.m_depth, -m_params.m_posZ), baseOffset);

  dp::Color outlineColor = isPrimary ? m_params.m_titleDecl.m_primaryTextFont.m_outlineColor
                                     : m_params.m_titleDecl.m_secondaryTextFont.m_outlineColor;

  if (outlineColor == dp::Color::Transparent())
    DrawSubStringPlain(context, layout, font, baseOffset, batcher, textures, isPrimary, isOptional);
  else
    DrawSubStringOutlined(context, layout, font, baseOffset, batcher, textures, isPrimary, isOptional);
}
Exemplo n.º 3
0
NervHitTestValue NervStandardPanel::OnHitTest(NervPoint in_pt){
	auto pt = ConvertToLocal(in_pt);
	if (caption.ContainsPoint(pt)){
		if (caption_elements.close_button.rect.ContainsPoint(pt))
			return NervHitTestValue::Close;
				
		return NervHitTestValue::Caption;
	}
	static const int drag_border = 6;
	if (resize_manipulator[NervResizeManipulator::Side::TopLeft]){
		if ((pt.x < drag_border) && (pt.y < drag_border))
			return NervHitTestValue::TopLeft;
	}
	if (resize_manipulator[NervResizeManipulator::Side::BottomLeft]){
		if ((pt.x < drag_border) && (pt.y>size.y - drag_border))
			return NervHitTestValue::BottomLeft;
	}
	if (resize_manipulator[NervResizeManipulator::Side::Left]){
		if (pt.x < drag_border)
			return NervHitTestValue::Left;
	}

	if (resize_manipulator[NervResizeManipulator::Side::TopRight]){
		if ((pt.x > (size.x - drag_border)) && (pt.y < drag_border))
			return NervHitTestValue::TopRight;
	}
	if (resize_manipulator[NervResizeManipulator::Side::BottomRight]){
		if ((pt.x > (size.x - drag_border)) && (pt.y>size.y - drag_border))
			return NervHitTestValue::BottomRight;
	}
	if (resize_manipulator[NervResizeManipulator::Side::Right]){
		if (pt.x > (size.x - drag_border))
			return NervHitTestValue::Right;
	}

	if (resize_manipulator[NervResizeManipulator::Side::Top]){
		if (pt.y < 5)
			return NervHitTestValue::Top;
	}
	if (resize_manipulator[NervResizeManipulator::Side::Bottom]){
		if (pt.y > (size.y - 5))
			return NervHitTestValue::Bottom;
	}
	return NervHitTestValue::Client;
}
Exemplo n.º 4
0
void NervStandardPanel::OnNonclientMouseMove(const NervMouseNonclientEvent* in_event){
	auto pt = ConvertToLocal(in_event->pt);
	bool needs_redraw = false;
	if (caption_elements.close_button.rect.ContainsPoint(pt)){
		if (highlighted_control == HighlightedControl::CloseButton)
			return;
		highlighted_control = HighlightedControl::CloseButton;
		needs_redraw = true;
		NervLog()("CloseButtonHover\n");
	}
	else if (caption_elements.bullet_button.rect.ContainsPoint(pt)){
		if (highlighted_control == HighlightedControl::BulletButton)
			return;
		highlighted_control = HighlightedControl::BulletButton;
		needs_redraw = true;
		NervLog()("BulletButtonHover\n");
	}
	else if (caption_elements.stack_button.rect.ContainsPoint(pt)){
		if (highlighted_control == HighlightedControl::StackButton)
			return;
		highlighted_control = HighlightedControl::StackButton;
		needs_redraw = true;
		NervLog()("StackButtonHover\n");
	}
	else{
		if (highlighted_control == HighlightedControl::None){
			return;
		}
		NervLog()("Nowhere\n");
		highlighted_control = HighlightedControl::None;
		needs_redraw = true;
	}
	if (needs_redraw){
		NervWindowDC dc{ hwnd };
		OnNcPaint(dc);
		needs_redraw = false;
	}
}
Exemplo n.º 5
0
// ---------------------------------------------------------------------------
// TPresCondValidity::GetValidity()
// ---------------------------------------------------------------------------
//	
EXPORT_C TInt TPresCondValidity::GetValidityL(const TDesC& aRuleID, 
                                        RArray<TTimePeriod>& aValidTimes)
	{
    OPENG_DP(D_OPENG_LIT( "TPresCondValidity::GetValidity()" ) );
    OPENG_DP(D_OPENG_LIT( "     aRuleID = %S"),&aRuleID);

	CXdmDocumentNode* validityNode = GetValidityNodeL(aRuleID, EFalse);
	if(validityNode==NULL)
	    return KErrNotFound;
	
	TInt nodeCount = validityNode->NodeCount();
    OPENG_DP(D_OPENG_LIT( "     validityNode->NodeCount() = %d"),nodeCount);
	if(!nodeCount)
	    return KErrNotFound;
	
	RPointerArray<CXdmDocumentNode> fromNodes;
	RPointerArray<CXdmDocumentNode> untilNodes;
	
	HBufC* fromPtr(NULL);
	HBufC* untilPtr(NULL); 
	
	TTime fromTime(0);
	TTime untilTime(0);
	
	
	TTimePeriod myTimePeriod;
	
    // Get all the <from> nodes
  	validityNode->Find(KXdmFrom, fromNodes);
    validityNode->Find(KXdmUntil, untilNodes);
    
    if((fromNodes.Count()) != (untilNodes.Count()))
        {
        fromNodes.Close();
        untilNodes.Close();
        return KErrGeneral;
        }
        
    
    nodeCount = fromNodes.Count();
    OPENG_DP(D_OPENG_LIT( "     nodesCount = %d" ),nodeCount);

	for(TInt i=0; i<nodeCount; i++)
	    {
        aValidTimes.Append(myTimePeriod);

	    // processing from
	    (fromNodes[i])->SetLeafNode(ETrue);
	    fromPtr = CnvUtfConverter::ConvertToUnicodeFromUtf8L((fromNodes[i])->LeafNodeContent());
	    CleanupStack::PushL(fromPtr);
	    OPENG_DP(D_OPENG_LIT( "     from string at i(%d): %S" ),i,&(*fromPtr));
	    ParseFromXMLTimeString(fromPtr->Des(), fromTime);
	    CleanupStack::PopAndDestroy(fromPtr);
	    ConvertToLocal(fromTime);
	    ((aValidTimes[i]).from).Set(fromTime.DateTime().Year(),fromTime.DateTime().Month(),
	        fromTime.DateTime().Day(),fromTime.DateTime().Hour(),fromTime.DateTime().Minute(),
	        fromTime.DateTime().Second(), fromTime.DateTime().MicroSecond());
	    OPENG_DP(D_OPENG_LIT( "     from at i = %d" ),i);
	    LogDateTime((aValidTimes[i]).from);
	    
	    
	    // processing until
	    (untilNodes[i])->SetLeafNode(ETrue);
	    untilPtr = CnvUtfConverter::ConvertToUnicodeFromUtf8L((untilNodes[i])->LeafNodeContent());
	    CleanupStack::PushL(untilPtr);
	    OPENG_DP(D_OPENG_LIT( "     until string at i(%d): %S" ),i,&(*untilPtr));
	    ParseFromXMLTimeString(untilPtr->Des(), untilTime);
	    CleanupStack::PopAndDestroy(untilPtr);
	    ConvertToLocal(untilTime);
	    (aValidTimes[i]).until.Set(untilTime.DateTime().Year(),untilTime.DateTime().Month(),
	        untilTime.DateTime().Day(),untilTime.DateTime().Hour(),untilTime.DateTime().Minute(),
	        untilTime.DateTime().Second(),untilTime.DateTime().MicroSecond());
	    OPENG_DP(D_OPENG_LIT( "     until at i = %d" ),i);
	    LogDateTime((aValidTimes[i]).until);

	    }
	    
    fromNodes.Close();
    untilNodes.Close();
	return KErrNone;
	}