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

	switch (message)
	{
		case SP_PAINT:
			{
				Surface	*surface = GetDrawSurface();
				Rect	 frame	 = Rect(GetRealPosition(), GetRealSize());

				if (!(flags & BF_NOFRAME))
				{
					surface->Frame(frame, FRAME_DOWN);
					surface->Frame(Rect(GetRealPosition() + Point(1, 1), GetRealSize() - Size(2, 2)), FRAME_UP);
				}

				if (text != NIL)
				{
					Rect	 textRect;

					textRect.left	= frame.left + ((frame.GetWidth() - scaledTextSize.cx) / 2);

					if (bitmap != NIL) textRect.left = frame.left + ((frame.GetWidth() - scaledTextSize.cx - bitmap.GetSize().cx - 7) / 2) + bitmap.GetSize().cx + 7;

					textRect.top	= frame.top + Math::Ceil(Float(frame.GetHeight() - scaledTextSize.cy) / 2) - 1;
					textRect.right	= textRect.left + scaledTextSize.cx + 1;
					textRect.bottom	= textRect.top + Math::Round(scaledTextSize.cy * 1.2);

					Font	 nFont = font;

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

					surface->Box(textRect, GetBackgroundColor(), Rect::Filled);
					surface->SetText(text, textRect, nFont);
				}

				if (bitmap != NIL)
				{
					Size	 size	  = GetSize();
					Size	 bmpSize  = bitmap.GetSize();

					if	(Float(bmpSize.cx) / size.cx >= Float(bmpSize.cy) / size.cy && bmpSize.cx > size.cx - 12) bmpSize = bmpSize * (Float(size.cx - 12) / bmpSize.cx);
					else if (Float(bmpSize.cy) / size.cy >= Float(bmpSize.cx) / size.cx && bmpSize.cy > size.cy - 12) bmpSize = bmpSize * (Float(size.cy - 12) / bmpSize.cy);

					bmpSize = bmpSize * surface->GetSurfaceDPI() / 96.0;

					Rect	 bmpRect;

					bmpRect.left	= frame.left + (frame.GetWidth() - bmpSize.cx) / 2;

					if (text != NIL) bmpRect.left = frame.left + (frame.GetWidth() - bmpSize.cx - scaledTextSize.cx - 7) / 2;

					bmpRect.top	= frame.top + (frame.GetHeight() - bmpSize.cy) / 2;
					bmpRect.right	= bmpRect.left + bmpSize.cx;
					bmpRect.bottom	= bmpRect.top + bmpSize.cy;

					if (IsActive())
					{
						surface->BlitFromBitmap(bitmap, Rect(Point(0, 0), bitmap.GetSize()), bmpRect);
					}
					else
					{
						Bitmap	 graymap(bitmap);

						graymap.GrayscaleBitmap();

						surface->BlitFromBitmap(graymap, Rect(Point(0, 0), bitmap.GetSize()), bmpRect);
					}
				}
			}

			break;
	}

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %esi, %ebx
movq %rdi, %r14
movq (%rdi), %rax
callq *0x88(%rax)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %al, %al
je 0x73d68
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
xorl %ebp, %ebp
testl %ebx, %ebx
jne 0x73d68
testb %al, %al
je 0x73d68
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, %r13
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %r15
movq %rax, %rbx
shrq $0x20, %rbx
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
leal (%rax,%r15), %ecx
shrq $0x20, %rax
movl %r15d, (%rsp)
movl %ebx, 0x4(%rsp)
movl %ecx, 0x8(%rsp)
addl %ebx, %eax
movl %eax, 0xc(%rsp)
testb $0x1, 0x30(%r14)
jne 0x73891
movq %rsp, %rsi
movq %r13, %rdi
movl $0x1, %edx
callq 0x57890
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %r15
movq %rax, %rbx
shrq $0x20, %rbx
leal 0x1(%rbx), %ebp
leal 0x1(%rax), %r12d
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
leal (%r15,%rax), %ecx
decl %ecx
shrq $0x20, %rax
leaq 0x40(%rsp), %rsi
movl %r12d, (%rsi)
movl %ebp, 0x4(%rsi)
movl %ecx, 0x8(%rsi)
addl %ebx, %eax
decl %eax
movl %eax, 0xc(%rsi)
movq %r13, %rdi
xorl %edx, %edx
callq 0x57890
leaq 0xf0(%r14), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x56bd0
testb %al, %al
je 0x73a4d
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movl (%rsp), %eax
movl 0x8(%rsp), %ecx
movl 0x188(%r14), %edx
addl %eax, %edx
subl %edx, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
addl %eax, %edx
movl %edx, 0x10(%rsp)
leaq 0x5b8(%r14), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x563f0
testb %al, %al
je 0x73948
movl (%rsp), %ebx
movq %r15, 0x30(%rsp)
movl 0x8(%rsp), %r15d
movq %r13, %rbp
movl 0x188(%r14), %r13d
addl %ebx, %r13d
movq %r12, %rdi
callq 0x58410
addl (%rax), %r13d
movl %r15d, %eax
subl %r13d, %eax
negl %r13d
leal (%r15,%r13), %ecx
addl $-0x7, %ecx
movq %rbp, %r13
shrl $0x1f, %ecx
leal (%rcx,%rax), %r15d
addl $-0x7, %r15d
sarl %r15d
movq %r12, %rdi
callq 0x58410
addl (%rax), %ebx
leal (%r15,%rbx), %eax
addl $0x7, %eax
movq 0x30(%rsp), %r15
movl %eax, 0x10(%rsp)
movl 0x4(%rsp), %ebx
movl 0xc(%rsp), %eax
movl 0x18c(%r14), %ecx
addl %ebx, %ecx
subl %ecx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x80a2e(%rip), %xmm0    # 0xf4398
callq 0x56cb0
movl %ebx, %ecx
addl %eax, %ecx
addl %ebx, %eax
decl %eax
movl %eax, 0x14(%rsp)
movl 0x10(%rsp), %eax
movl 0x188(%r14), %edx
leal 0x1(%rax,%rdx), %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x18c(%r14), %xmm0
mulsd 0x831be(%rip), %xmm0    # 0xf6b60
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x80dda(%rip), %rdx     # 0xf4790
addsd (%rdx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
leal -0x1(%rax,%rcx), %eax
movl %eax, 0x1c(%rsp)
leaq 0x140(%r14), %rsi
leaq 0x40(%rsp), %rdi
callq 0x55b70
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
testb %al, %al
jne 0x739fa
movq 0xf8f60(%rip), %rsi     # 0x16c950
leaq 0x40(%rsp), %rdi
callq 0x58650
movq (%r14), %rax
movq %r14, %rdi
callq *0x140(%rax)
movq 0xf959b(%rip), %rcx     # 0x16cfa8
movl (%rcx), %ecx
leaq 0x20(%rsp), %r8
movq $0x0, (%r8)
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
movq %rax, %rdx
callq 0x57930
leaq 0x10(%rsp), %rdx
leaq 0x40(%rsp), %rcx
movq %r13, %rdi
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x57b80
leaq 0x40(%rsp), %rdi
callq 0x56720
leaq 0x5b8(%r14), %rbx
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %esi, %esi
callq 0x563f0
testb %al, %al
je 0x73d68
movq %r15, 0x30(%rsp)
movq %r13, 0x28(%rsp)
movl 0xb0(%r14), %r12d
movl 0xb4(%r14), %r15d
movq %rbx, 0x38(%rsp)
movq %rbx, %rdi
callq 0x58410
movq (%rax), %r13
movq %r13, %rbx
shrq $0x20, %rbx
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movapd %xmm1, %xmm2
divsd %xmm0, %xmm2
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
cvtsi2sd %r15d, %xmm4
movapd %xmm0, %xmm3
divsd %xmm4, %xmm3
ucomisd %xmm3, %xmm2
jb 0x73ae0
addl $-0xc, %r12d
cmpl %r13d, %r12d
jge 0x73ae0
xorps %xmm2, %xmm2
cvtsi2sd %r12d, %xmm2
divsd %xmm1, %xmm2
jmp 0x73afb
ucomisd %xmm2, %xmm3
jb 0x73b57
addl $-0xc, %r15d
cmpl %ebx, %r15d
jge 0x73b57
xorps %xmm2, %xmm2
cvtsi2sd %r15d, %xmm2
divsd %xmm0, %xmm2
mulsd %xmm2, %xmm1
xorpd %xmm3, %xmm3
movapd %xmm1, %xmm4
cmpltsd %xmm3, %xmm4
movsd 0x8087c(%rip), %xmm5    # 0xf4390
movapd %xmm4, %xmm6
andpd %xmm5, %xmm6
movsd 0x80874(%rip), %xmm7    # 0xf4398
andnpd %xmm7, %xmm4
orpd %xmm6, %xmm4
addsd %xmm1, %xmm4
cvttsd2si %xmm4, %r13
mulsd %xmm0, %xmm2
movapd %xmm2, %xmm0
cmpltsd %xmm3, %xmm0
andpd %xmm0, %xmm5
andnpd %xmm7, %xmm0
orpd %xmm5, %xmm0
addsd %xmm2, %xmm0
cvttsd2si %xmm0, %rbx
movq 0x28(%rsp), %rdi
callq 0x58930
cwtl
xorps %xmm3, %xmm3
cvtsi2sd %eax, %xmm3
xorps %xmm4, %xmm4
cvtsi2sd %r13d, %xmm4
mulsd %xmm3, %xmm4
xorpd %xmm1, %xmm1
movapd %xmm4, %xmm5
cmpltsd %xmm1, %xmm5
movsd 0x80806(%rip), %xmm0    # 0xf4390
movapd %xmm5, %xmm6
andpd %xmm0, %xmm6
movsd 0x807fe(%rip), %xmm2    # 0xf4398
andnpd %xmm2, %xmm5
orpd %xmm6, %xmm5
addsd %xmm4, %xmm5
cvttsd2si %xmm5, %rax
xorps %xmm4, %xmm4
cvtsi2sd %ebx, %xmm4
mulsd %xmm3, %xmm4
movapd %xmm4, %xmm3
cmpltsd %xmm1, %xmm3
movapd %xmm3, %xmm5
andpd %xmm0, %xmm5
andnpd %xmm2, %xmm3
orpd %xmm5, %xmm3
addsd %xmm4, %xmm3
cvttsd2si %xmm3, %rcx
xorps %xmm3, %xmm3
cvtsi2sd %eax, %xmm3
movsd 0x80909(%rip), %xmm4    # 0xf44f0
divsd %xmm4, %xmm3
movapd %xmm3, %xmm5
cmpltsd %xmm1, %xmm5
movapd %xmm5, %xmm6
andpd %xmm0, %xmm6
andnpd %xmm2, %xmm5
orpd %xmm6, %xmm5
addsd %xmm3, %xmm5
cvttsd2si %xmm5, %r13
xorps %xmm3, %xmm3
cvtsi2sd %ecx, %xmm3
divsd %xmm4, %xmm3
movapd %xmm3, %xmm4
cmpltsd %xmm1, %xmm4
andpd %xmm4, %xmm0
andnpd %xmm2, %xmm4
orpd %xmm0, %xmm4
addsd %xmm3, %xmm4
cvttsd2si %xmm4, %rbx
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
movl (%rsp), %eax
movl 0x8(%rsp), %ecx
subl %eax, %ecx
subl %r13d, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
addl %eax, %edx
movl %edx, 0x40(%rsp)
movq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x56bd0
testb %al, %al
je 0x73c98
movl (%rsp), %eax
movl 0x8(%rsp), %ecx
leal (%rax,%r13), %edx
addl 0x188(%r14), %edx
movl %ecx, %esi
subl %edx, %esi
negl %edx
addl %edx, %ecx
addl $-0x7, %ecx
shrl $0x1f, %ecx
addl %esi, %ecx
addl $-0x7, %ecx
sarl %ecx
addl %eax, %ecx
movl %ecx, 0x40(%rsp)
movl 0x4(%rsp), %eax
movl 0xc(%rsp), %ecx
subl %eax, %ecx
subl %ebx, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
addl %eax, %edx
movl %edx, 0x44(%rsp)
addl 0x40(%rsp), %r13d
movl %r13d, 0x48(%rsp)
addl %ebx, %edx
movl %edx, 0x4c(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
testb %al, %al
je 0x73d0b
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x58410
leaq 0x10(%rsp), %rdx
movq $0x0, (%rdx)
movl (%rax), %ecx
movl %ecx, 0x8(%rdx)
movl 0x4(%rax), %eax
movl %eax, 0xc(%rdx)
leaq 0x40(%rsp), %rcx
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x55ba0
jmp 0x73d68
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq 0x38(%rsp), %r15
movq %r15, %rsi
callq 0x57160
movq %r14, %rdi
callq 0x56db0
movq 0x28(%rsp), %rbx
movq %r15, %rdi
callq 0x58410
leaq 0x10(%rsp), %rdx
movq $0x0, (%rdx)
movl (%rax), %ecx
movl %ecx, 0x8(%rdx)
movl 0x4(%rax), %eax
movl %eax, 0xc(%rdx)
leaq 0x20(%rsp), %rsi
leaq 0x40(%rsp), %rcx
movq %rbx, %rdi
callq 0x55ba0
leaq 0x20(%rsp), %rdi
callq 0x59148
movl %ebp, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x73d7e
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x59148
jmp 0x73d9c
jmp 0x73d8f
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x56720
movq %rbx, %rdi
callq 0x57090