// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/classes/gui/widgets/basic/text.cpp
// Function: smooth::GUI::Text::Paint(int)
S::Int S::GUI::Text::Paint(Int message)
{
	if (!IsRegistered()) return Error();
	if (!IsVisible())    return Success();

	switch (message)
	{
		case SP_PAINT:
			if (text != NIL)
			{
				Font	 nFont	    = font;

				if (!IsActive()) nFont.SetColor(Setup::InactiveTextColor);

				Rect	 rect	    = Rect(GetRealPosition(), GetRealSize());
				Surface	*surface    = GetDrawSurface();

				Size	 alignToUse = Size(align.cx, (font.GetSize() == Font::DefaultSize && align.cy == 0) ? 13 : align.cy);
				Point	 alignment  = Point(alignToUse.cx == 0 ? 0 : Math::Ceil(Float(Float(alignToUse.cx) * surface->GetSurfaceDPI() / 96.0 - font.GetScaledTextSizeX(text)) / 2) - 1,
							    alignToUse.cy == 0 ? 0 : Math::Ceil(Float(Float(alignToUse.cy) * surface->GetSurfaceDPI() / 96.0 - font.GetScaledTextSizeY())     / 2) - 1);

				surface->Box(rect + alignment, GetBackgroundColor(), Rect::Filled);
				surface->SetText(text, Rect::OverlapRect(Rect(rect.GetPosition() + alignment, Size(scaledTextSize.cx, Math::Round(scaledTextSize.cy * 1.2))), GetVisibleArea() + alignment), nFont);
			}

			break;
	}

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %esi, %ebp
movq %rdi, %r14
movq (%rdi), %rax
callq *0x88(%rax)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb %al, %al
je 0x7f93e
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
xorl %ebx, %ebx
testl %ebp, %ebp
jne 0x7f93e
testb %al, %al
je 0x7f93e
leaq 0xf0(%r14), %r12
xorl %ebx, %ebx
movq %r12, %rdi
xorl %esi, %esi
callq 0x56bd0
testb %al, %al
je 0x7f93e
leaq 0x140(%r14), %r15
leaq 0x48(%rsp), %rdi
movq %r15, %rsi
callq 0x55b70
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
testb %al, %al
jne 0x7f6de
movq 0xed27c(%rip), %rsi     # 0x16c950
leaq 0x48(%rsp), %rdi
callq 0x58650
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, 0x18(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
movq %rax, %rbx
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, 0x8(%rsp)
movq %rbx, 0x30(%rsp)
movq %r12, 0x10(%rsp)
movl 0x5b8(%r14), %r12d
movq %r15, %rdi
callq 0x58d40
movq 0xed772(%rip), %rcx     # 0x16ce98
movl 0x5bc(%r14), %edx
testl %edx, %edx
movl $0xd, %ebx
cmovnel %edx, %ebx
cmpw (%rcx), %ax
cmovnel %edx, %ebx
xorl %r13d, %r13d
movl $0x0, %ebp
testl %r12d, %r12d
je 0x7f798
movq 0x8(%rsp), %rdi
callq 0x58930
movl %eax, %ebp
movq %r15, %rdi
movq 0x10(%rsp), %rsi
callq 0x56730
cvtsi2sd %r12d, %xmm1
movswl %bp, %ecx
cvtsi2sd %ecx, %xmm0
mulsd %xmm1, %xmm0
divsd 0x74d75(%rip), %xmm0    # 0xf44f0
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
subsd %xmm1, %xmm0
mulsd 0x74c0a(%rip), %xmm0    # 0xf4398
callq 0x56cb0
movq %rax, %rbp
decl %ebp
testl %ebx, %ebx
je 0x7f7f4
movq 0x8(%rsp), %rdi
callq 0x58930
movl %eax, %r13d
movq 0xed608(%rip), %rsi     # 0x16cdb8
movq %r15, %rdi
callq 0x57680
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
movswl %r13w, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
mulsd %xmm1, %xmm0
divsd 0x74d1a(%rip), %xmm0    # 0xf44f0
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
subsd %xmm1, %xmm0
mulsd 0x74baf(%rip), %xmm0    # 0xf4398
callq 0x56cb0
movq %rax, %r13
decl %r13d
movq 0x18(%rsp), %rdx
movq %rdx, %r15
shrq $0x20, %r15
movq 0x30(%rsp), %rcx
movq %rcx, %rax
shrq $0x20, %rax
addl %edx, %ecx
addl %r15d, %eax
addl %ebp, %edx
addl %r13d, %r15d
movq %r15, %rsi
shlq $0x20, %rsi
addl %ebp, %ecx
addl %r13d, %eax
orq %rsi, %rdx
shlq $0x20, %rax
orq %rax, %rcx
movq %rdx, 0x38(%rsp)
movq %rcx, 0x40(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x140(%rax)
movq 0xed75f(%rip), %rcx     # 0x16cfa8
movl (%rcx), %ecx
leaq 0x20(%rsp), %r8
movq $0x0, (%r8)
leaq 0x38(%rsp), %rsi
movq 0x8(%rsp), %rdi
movq %rax, %rdx
callq 0x57930
xorps %xmm0, %xmm0
cvtsi2sdl 0x18c(%r14), %xmm0
mulsd 0x772e3(%rip), %xmm0    # 0xf6b60
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
movq 0x18(%rsp), %rcx
leal (%rbp,%rcx), %ecx
seta %al
leaq 0x74ef6(%rip), %rdx     # 0xf4790
addsd (%rdx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
movl 0x188(%r14), %edx
addl %ecx, %edx
movl %ecx, 0x20(%rsp)
movl %r15d, 0x24(%rsp)
movl %edx, 0x28(%rsp)
addl %r15d, %eax
movl %eax, 0x2c(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x130(%rax)
movq %rax, %rcx
shrq $0x20, %rcx
addl %ebp, %eax
addl %r13d, %ecx
shlq $0x20, %rcx
movq %rdx, %rsi
shrq $0x20, %rsi
addl %ebp, %edx
addl %r13d, %esi
orq %rcx, %rax
shlq $0x20, %rsi
orq %rsi, %rdx
leaq 0x88(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
leaq 0x20(%rsp), %rdi
callq 0x58af0
leaq 0x38(%rsp), %r8
movq %rax, (%r8)
movq %rdx, 0x8(%r8)
leaq 0x48(%rsp), %rcx
xorl %ebx, %ebx
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r8, %rdx
xorl %r8d, %r8d
callq 0x57b80
leaq 0x48(%rsp), %rdi
callq 0x56720
movl %ebx, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7f962
jmp 0x7f962
jmp 0x7f962
jmp 0x7f962
jmp 0x7f962
jmp 0x7f962
jmp 0x7f962
jmp 0x7f962
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x56720
movq %rbx, %rdi
callq 0x57090
nop