// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x198(%rbp)
movq (%rdi), %rax
callq *0x88(%rax)
testb $0x1, %al
jne 0x91b54
leaq -0x28(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x5a9c0
movq -0x1a8(%rbp), %rdi
callq 0x59680
movl %eax, -0x19c(%rbp)
jmp 0x91b23
movl -0x19c(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x5b5b0
jmp 0x923e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x5b5b0
jmp 0x923ec
movq -0x198(%rbp), %rdi
movq (%rdi), %rax
callq *0x90(%rax)
testb $0x1, %al
jne 0x91bbd
leaq -0x48(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x5ca80
movq -0x1b8(%rbp), %rdi
callq 0x59680
movl %eax, -0x1ac(%rbp)
jmp 0x91b8c
movl -0x1ac(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5a410
jmp 0x923e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5a410
jmp 0x923ec
movl -0x14(%rbp), %eax
testl %eax, %eax
jne 0x92388
jmp 0x91bca
movq -0x198(%rbp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq -0x198(%rbp), %rdi
movq %rax, -0x50(%rbp)
movq (%rdi), %rax
callq *0x48(%rax)
movq -0x198(%rbp), %rdi
movq %rax, -0x68(%rbp)
movq (%rdi), %rax
callq *0x50(%rax)
movq %rax, -0x70(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x59ff0
movq -0x198(%rbp), %rax
movl 0x30(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x91cec
movq -0x50(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x1, %edx
callq 0x5c050
movq -0x198(%rbp), %rdi
movq -0x50(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq (%rdi), %rax
callq *0x48(%rax)
movq %rax, -0x90(%rbp)
leaq -0x98(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0x5c2c0
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x5ca20
movq -0x198(%rbp), %rdi
movq %rax, -0x88(%rbp)
movq (%rdi), %rax
callq *0x50(%rax)
movq %rax, -0xa8(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x2, %edx
movl %edx, %esi
callq 0x59260
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x5db90
movq %rax, -0xa0(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0x59ff0
movq -0x1c0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
xorl %edx, %edx
callq 0x5c050
movq -0x198(%rbp), %rdi
addq $0xf0, %rdi
xorl %esi, %esi
callq 0x5b110
testb $0x1, %al
jne 0x91d0a
jmp 0x91fa1
leaq -0xc0(%rbp), %rdi
callq 0x5c030
movl -0x60(%rbp), %eax
movl %eax, -0x1c4(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x5a5a0
movq -0x198(%rbp), %rdi
subl 0x188(%rdi), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x1c4(%rbp), %eax
addl %ecx, %eax
movl %eax, -0xc0(%rbp)
addq $0x5b8, %rdi            # imm = 0x5B8
xorl %esi, %esi
callq 0x5a830
testb $0x1, %al
jne 0x91d61
jmp 0x91ddf
movl -0x60(%rbp), %eax
movl %eax, -0x1cc(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x5a5a0
movq -0x198(%rbp), %rdi
subl 0x188(%rdi), %eax
movl %eax, -0x1d0(%rbp)
addq $0x5b8, %rdi            # imm = 0x5B8
callq 0x5ce60
movq -0x198(%rbp), %rdi
movq %rax, %rcx
movl -0x1d0(%rbp), %eax
subl (%rcx), %eax
subl $0x7, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x1cc(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x1c8(%rbp)
addq $0x5b8, %rdi            # imm = 0x5B8
callq 0x5ce60
movq %rax, %rcx
movl -0x1c8(%rbp), %eax
addl (%rcx), %eax
addl $0x7, %eax
movl %eax, -0xc0(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x1dc(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x591a0
movq -0x198(%rbp), %rcx
movl 0x18c(%rcx), %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd 0xf557c(%rip), %xmm1    # 0x187388
mulsd %xmm1, %xmm0
callq 0x5b240
movl -0x1dc(%rbp), %edx
movq %rax, %rcx
movq -0x198(%rbp), %rax
movl %ecx, %esi
movl %edx, %ecx
movl %esi, %edx
leal -0x1(%rcx,%rdx), %ecx
movl %ecx, -0xbc(%rbp)
movl -0xc0(%rbp), %esi
movl 0x188(%rax), %ecx
movl %ecx, %edx
movl %esi, %ecx
leal 0x1(%rcx,%rdx), %ecx
movl %ecx, -0xb8(%rbp)
movl -0xbc(%rbp), %ecx
movl %ecx, -0x1d8(%rbp)
cvtsi2sdl 0x18c(%rax), %xmm0
movsd 0xf7c75(%rip), %xmm1    # 0x189ae0
mulsd %xmm1, %xmm0
callq 0x5a970
movq -0x198(%rbp), %rsi
movq %rax, %rcx
movl -0x1d8(%rbp), %eax
addl %ecx, %eax
movl %eax, -0xb4(%rbp)
addq $0x140, %rsi            # imm = 0x140
leaq -0x100(%rbp), %rdi
callq 0x59da0
movq -0x198(%rbp), %rdi
movq (%rdi), %rax
movq 0x98(%rax), %rax
callq *%rax
movb %al, -0x1d1(%rbp)
jmp 0x91eba
movb -0x1d1(%rbp), %al
testb $0x1, %al
jne 0x91efa
jmp 0x91ec6
movq 0x176a63(%rip), %rsi    # 0x208930
leaq -0x100(%rbp), %rdi
callq 0x5d110
jmp 0x91edb
jmp 0x91efa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x5abf0
jmp 0x923ec
movq -0x198(%rbp), %rdi
movq -0x50(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq (%rdi), %rax
movq 0x140(%rax), %rax
callq *%rax
movq %rax, -0x1e8(%rbp)
jmp 0x91f21
movq 0x177078(%rip), %rax    # 0x208fa0
movl (%rax), %eax
movl %eax, -0x1f4(%rbp)
leaq -0x108(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x59260
jmp 0x91f42
movl -0x1f4(%rbp), %ecx
movq -0x1e8(%rbp), %rdx
movq -0x1f0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
leaq -0x108(%rbp), %r8
callq 0x5c110
jmp 0x91f6b
movq -0x198(%rbp), %rsi
movq -0x50(%rbp), %rdi
addq $0xf0, %rsi
leaq -0xc0(%rbp), %rdx
leaq -0x100(%rbp), %rcx
xorl %r8d, %r8d
callq 0x5c3f0
jmp 0x91f95
leaq -0x100(%rbp), %rdi
callq 0x5abf0
movq -0x198(%rbp), %rdi
addq $0x5b8, %rdi            # imm = 0x5B8
xorl %esi, %esi
callq 0x5a830
testb $0x1, %al
jne 0x91fbf
jmp 0x92386
movq -0x198(%rbp), %rdi
callq 0x5bf70
movq -0x198(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x110(%rbp)
addq $0x5b8, %rdi            # imm = 0x5B8
callq 0x5ce60
movq (%rax), %rax
movq %rax, -0x118(%rbp)
cvtsi2sdl -0x118(%rbp), %xmm0
cvtsi2sdl -0x110(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x114(%rbp), %xmm1
cvtsi2sdl -0x10c(%rbp), %xmm2
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x9206f
movl -0x118(%rbp), %eax
movl -0x110(%rbp), %ecx
subl $0xc, %ecx
cmpl %ecx, %eax
jle 0x9206f
movl -0x110(%rbp), %eax
subl $0xc, %eax
cvtsi2sd %eax, %xmm0
cvtsi2sdl -0x118(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq -0x118(%rbp), %rdi
callq 0x5a7b0
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rax
movq %rax, -0x118(%rbp)
jmp 0x920ec
cvtsi2sdl -0x114(%rbp), %xmm0
cvtsi2sdl -0x10c(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x118(%rbp), %xmm1
cvtsi2sdl -0x110(%rbp), %xmm2
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0x920ea
movl -0x114(%rbp), %eax
movl -0x10c(%rbp), %ecx
subl $0xc, %ecx
cmpl %ecx, %eax
jle 0x920ea
movl -0x10c(%rbp), %eax
subl $0xc, %eax
cvtsi2sd %eax, %xmm0
cvtsi2sdl -0x114(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq -0x118(%rbp), %rdi
callq 0x5a7b0
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movq %rax, -0x118(%rbp)
jmp 0x920ec
movq -0x50(%rbp), %rdi
callq 0x5d470
cwtl
cvtsi2sd %eax, %xmm0
leaq -0x118(%rbp), %rdi
callq 0x5a7b0
movq %rax, -0x138(%rbp)
leaq -0x138(%rbp), %rdi
movsd 0xf53a4(%rip), %xmm0    # 0x1874c0
callq 0x5c6b0
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x5c030
movl -0x60(%rbp), %eax
movl %eax, -0x1f8(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x5a5a0
movq -0x198(%rbp), %rdi
subl -0x118(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x1f8(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x148(%rbp)
addq $0xf0, %rdi
xorl %esi, %esi
callq 0x5b110
testb $0x1, %al
jne 0x9218d
jmp 0x921cd
movl -0x60(%rbp), %eax
movl %eax, -0x1fc(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x5a5a0
movq -0x198(%rbp), %rcx
subl -0x118(%rbp), %eax
subl 0x188(%rcx), %eax
subl $0x7, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x1fc(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x148(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x200(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x591a0
movq -0x198(%rbp), %rdi
subl -0x114(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x200(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x144(%rbp)
movl -0x148(%rbp), %eax
addl -0x118(%rbp), %eax
movl %eax, -0x140(%rbp)
movl -0x144(%rbp), %eax
addl -0x114(%rbp), %eax
movl %eax, -0x13c(%rbp)
movq (%rdi), %rax
callq *0x98(%rax)
testb $0x1, %al
jne 0x92237
jmp 0x922b5
movq -0x198(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, -0x210(%rbp)
addq $0x5b8, %rax            # imm = 0x5B8
movq %rax, -0x208(%rbp)
leaq -0x160(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x5c2c0
movq -0x198(%rbp), %rdi
addq $0x5b8, %rdi            # imm = 0x5B8
callq 0x5ce60
movq %rax, %rdx
leaq -0x158(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x59ff0
movq -0x210(%rbp), %rdi
movq -0x208(%rbp), %rsi
leaq -0x158(%rbp), %rdx
leaq -0x148(%rbp), %rcx
callq 0x59dd0
jmp 0x92384
movq -0x198(%rbp), %rsi
addq $0x5b8, %rsi            # imm = 0x5B8
leaq -0x168(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x5b7e0
movq -0x218(%rbp), %rdi
callq 0x5b360
jmp 0x922e4
movq -0x50(%rbp), %rax
movq %rax, -0x220(%rbp)
leaq -0x180(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x5c2c0
jmp 0x92301
movq -0x198(%rbp), %rdi
addq $0x5b8, %rdi            # imm = 0x5B8
callq 0x5ce60
movq %rax, -0x228(%rbp)
jmp 0x9231d
movq -0x228(%rbp), %rdx
leaq -0x178(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x59ff0
jmp 0x92339
movq -0x220(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0x178(%rbp), %rdx
leaq -0x148(%rbp), %rcx
callq 0x59dd0
jmp 0x9235c
leaq -0x168(%rbp), %rdi
callq 0x5de40
jmp 0x92384
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x5de40
jmp 0x923ec
jmp 0x92386
jmp 0x92388
leaq -0x190(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x5ca80
movq -0x238(%rbp), %rdi
callq 0x59680
movl %eax, -0x22c(%rbp)
jmp 0x923af
movl -0x22c(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x5a410
jmp 0x923e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x5a410
jmp 0x923ec
movl -0x4(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x5b6b0
nopw %cs:(%rax,%rax)
nop