// File: /workspace/github_c_makefile_star2_O2/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 $0x98, %rsp
movl %esi, %ebx
movq %rdi, %r14
movq (%rdi), %rax
callq *0x88(%rax)
testb %al, %al
je 0x7311c
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
xorl %ebp, %ebp
testl %ebx, %ebx
jne 0x7311f
testb %al, %al
je 0x7311f
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, %r13
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %rbx
movq %rax, %r15
shrq $0x20, %r15
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
leal (%rax,%rbx), %ecx
shrq $0x20, %rax
movl %ebx, 0x8(%rsp)
movl %r15d, 0xc(%rsp)
movl %ecx, 0x10(%rsp)
addl %r15d, %eax
movl %eax, 0x14(%rsp)
testb $0x1, 0x30(%r14)
jne 0x72f04
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
movq %r13, %rdi
callq 0x58ad0
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %rbx
movq %rax, %r15
shrq $0x20, %r15
leal 0x1(%r15), %ebp
leal 0x1(%rax), %r12d
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
leal (%rbx,%rax), %ecx
decl %ecx
shrq $0x20, %rax
leaq 0x58(%rsp), %rsi
movl %r12d, (%rsi)
movl %ebp, 0x4(%rsi)
movl %ecx, 0x8(%rsi)
addl %r15d, %eax
decl %eax
movl %eax, 0xc(%rsi)
movq %r13, %rdi
xorl %edx, %edx
callq 0x58ad0
leaq 0xf0(%r14), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x57d40
pushq $0x2
popq %rsi
testb %al, %al
je 0x730a8
movl 0x8(%rsp), %ecx
movl 0x10(%rsp), %eax
movl 0x188(%r14), %edx
addl %ecx, %edx
subl %edx, %eax
cltd
idivl %esi
movl %eax, %r12d
addl %ecx, %r12d
movl %r12d, 0x20(%rsp)
leaq 0x5b8(%r14), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x574f0
testb %al, %al
je 0x72faf
movq %r15, 0x30(%rsp)
movl 0x8(%rsp), %r15d
movl 0x10(%rsp), %r12d
movq %r13, %rbp
movl 0x188(%r14), %r13d
addl %r15d, %r13d
movq %rbx, %rdi
callq 0x596e0
addl (%rax), %r13d
negl %r13d
leal (%r12,%r13), %eax
addl $-0x7, %eax
movq %rbp, %r13
cltd
pushq $0x2
popq %rcx
idivl %ecx
movl %eax, %r12d
movq %rbx, %rdi
callq 0x596e0
addl (%rax), %r15d
addl %r15d, %r12d
addl $0x7, %r12d
movq 0x30(%rsp), %r15
movl %r12d, 0x20(%rsp)
movl 0xc(%rsp), %ebx
movl 0x14(%rsp), %eax
movl 0x18c(%r14), %ecx
addl %ebx, %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
mulsd 0x703b2(%rip), %xmm0    # 0xe3380
callq 0x57e30
movl %ebx, %ecx
addl %eax, %ecx
addl %ebx, %eax
decl %eax
movl %eax, 0x24(%rsp)
movl 0x188(%r14), %eax
leal 0x1(%r12,%rax), %eax
movl %eax, 0x28(%rsp)
cvtsi2sdl 0x18c(%r14), %xmm0
mulsd 0x72bb0(%rip), %xmm0    # 0xe5bb0
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x7095c(%rip), %rdx     # 0xe3970
addsd (%rdx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
leal -0x1(%rax,%rcx), %eax
movl %eax, 0x2c(%rsp)
leaq 0x140(%r14), %rsi
leaq 0x58(%rsp), %rdi
callq 0x56bf0
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
testb %al, %al
jne 0x73058
movq 0xee902(%rip), %rsi     # 0x161950
leaq 0x58(%rsp), %rdi
callq 0x59940
movq (%r14), %rax
movq %r14, %rdi
callq *0x140(%rax)
movq 0xeef3d(%rip), %rcx     # 0x161fa8
movl (%rcx), %ecx
leaq 0x18(%rsp), %r8
andq $0x0, (%r8)
leaq 0x20(%rsp), %rsi
movq %r13, %rdi
movq %rax, %rdx
callq 0x58b80
leaq 0x20(%rsp), %rdx
leaq 0x58(%rsp), %rcx
movq %r13, %rdi
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x58df0
leaq 0x58(%rsp), %rdi
callq 0x57860
leaq 0x5b8(%r14), %r12
xorl %ebp, %ebp
movq %r12, %rdi
xorl %esi, %esi
callq 0x574f0
testb %al, %al
je 0x7311f
movsd 0xb0(%r14), %xmm0
movaps %xmm0, 0x40(%rsp)
movq %r12, %rdi
callq 0x596e0
movdqa 0x40(%rsp), %xmm4
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq %rax, %xmm0
cvtdq2pd %xmm0, %xmm1
cvtdq2pd %xmm4, %xmm3
movapd %xmm1, %xmm2
divpd %xmm3, %xmm2
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
ucomisd %xmm3, %xmm2
movq %r15, 0x30(%rsp)
jb 0x73133
movd %xmm4, %ecx
addl $-0xc, %ecx
cmpl %eax, %ecx
jge 0x73133
cvtsi2sd %ecx, %xmm0
jmp 0x7315a
pushq $-0x1
popq %rbp
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
ucomisd %xmm2, %xmm3
jb 0x7316e
pshufd $0x55, %xmm4, %xmm2     # xmm2 = xmm4[1,1,1,1]
movd %xmm2, %eax
addl $-0xc, %eax
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %ecx
cmpl %ecx, %eax
jge 0x7316e
cvtsi2sd %eax, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
divsd %xmm1, %xmm0
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x57480
movq %rax, (%rbx)
movq %r13, 0x40(%rsp)
movq %r13, %rdi
callq 0x59c60
cwtl
cvtsi2sd %eax, %xmm0
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x57480
leaq 0x58(%rsp), %r15
movq %rax, (%r15)
movsd 0x70373(%rip), %xmm0    # 0xe3510
movq %r15, %rdi
callq 0x59050
movq %rax, (%rbx)
movl 0x8(%rsp), %esi
movl 0x10(%rsp), %ecx
addl %esi, %eax
subl %eax, %ecx
movl %ecx, %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movl %eax, %r13d
addl %esi, %r13d
movl %r13d, (%r15)
movl %ecx, %r15d
movq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x57d40
movl (%rbx), %ecx
testb %al, %al
je 0x73202
movl 0x8(%rsp), %esi
movl 0x10(%rsp), %eax
leal (%rsi,%rcx), %edx
addl 0x188(%r14), %edx
negl %edx
addl %edx, %eax
addl $-0x7, %eax
cltd
idivl %r15d
movl %eax, %r13d
addl %esi, %r13d
movl %r13d, 0x58(%rsp)
movl 0xc(%rsp), %esi
movl 0x14(%rsp), %eax
movl 0x1c(%rsp), %edi
subl %esi, %eax
subl %edi, %eax
cltd
idivl %r15d
addl %esi, %eax
movl %eax, 0x5c(%rsp)
addl %r13d, %ecx
movl %ecx, 0x60(%rsp)
addl %edi, %eax
movl %eax, 0x64(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
testb %al, %al
je 0x73268
movq %r12, %rdi
callq 0x596e0
leaq 0x20(%rsp), %rdx
andq $0x0, (%rdx)
movq (%rax), %rax
movq %rax, 0x8(%rdx)
leaq 0x58(%rsp), %rcx
movq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x56c20
jmp 0x7311f
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x58350
movq %rbx, %rdi
callq 0x57f60
movq 0x40(%rsp), %rbx
movq %r12, %rdi
callq 0x596e0
leaq 0x20(%rsp), %rdx
andq $0x0, (%rdx)
movq (%rax), %rax
movq %rax, 0x8(%rdx)
leaq 0x38(%rsp), %rsi
leaq 0x58(%rsp), %rcx
movq %rbx, %rdi
callq 0x56c20
leaq 0x38(%rsp), %rdi
callq 0x5a4c8
jmp 0x7311f
jmp 0x732c0
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x5a4c8
jmp 0x732de
jmp 0x732d1
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x57860
movq %rbx, %rdi
callq 0x58260