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

	switch (message)
	{
		case SP_PAINT:
			{
				Surface	*surface    = GetDrawSurface();

				Rect	 frame	    = Rect(GetRealPosition(), GetRealSize());
				Int	 offset	    = 19 * surface->GetSurfaceDPI() / 96;

				Long	 lightColor = Color(Math::Min(Setup::BackgroundColor.GetRed() + 64, 255), Math::Min(Setup::BackgroundColor.GetGreen() + 64, 255), Math::Min(Setup::BackgroundColor.GetBlue() + 64, 255));
				Long	 darkColor  = Color(Math::Max(Setup::BackgroundColor.GetRed() - 64, 0), Math::Max(Setup::BackgroundColor.GetGreen() - 64, 0), Math::Max(Setup::BackgroundColor.GetBlue() - 64, 0));

				surface->Box(frame, Setup::BackgroundColor, Rect::Filled);
				surface->Frame(frame + Point(0, offset) - Size(0, offset), FRAME_UP);

				frame.right  = frame.left;
				frame.bottom = frame.top + offset;

				for (Int i = 0; i < GetNOfObjects(); i++)
				{
					Widget		*widget = GetNthObject(i);
					Widget		*prev	= (i > 0) ? GetNthObject(i - 1) : NIL;

					const Bitmap	&bitmap = bitmaps.Get(widget->GetHandle());
					Size		 sSize	= bitmap == NIL ? Size() : Size(bitmap.GetSize().cx / (bitmap.GetSize().cy / 15.0) , 15) * surface->GetSurfaceDPI() / 96;

					frame.left  = frame.right + 1;
					frame.right = frame.left + widget->GetScaledTextWidth() + sSize.cx + 6 + Int(widget->GetText() != NIL ? 6 : 0);

					if (widget->IsVisible())
					{
						frame.left--;
						frame.right++;
					}
					else
					{
						frame.top++;
					}

					if (prev != NIL && prev->IsVisible()) frame.left++;

					surface->Frame(frame + Size(1, 1), FRAME_UP);

					if (IsRightToLeft()) { frame.left++; frame.right++; }

					if (prev != NIL && prev->IsVisible())
					{
						surface->Line(Point(frame.left, frame.top + 1), Point(frame.left, frame.bottom), Setup::BackgroundColor); frame.left--;

						if (IsRightToLeft()) surface->SetPixel(Point(frame.left + 1, frame.top), lightColor);
					}
					else
					{
						surface->SetPixel(Point(frame.left, frame.top), Setup::BackgroundColor);
					}

					surface->SetPixel(Point(frame.right, frame.top), Setup::BackgroundColor);

					if (IsRightToLeft()) { frame.left--; frame.right--; }

					if (widget->IsVisible()) frame.bottom--;

					if (bitmap != NIL)
					{
						surface->BlitFromBitmap(bitmap, Rect(Point(0, 0), bitmap.GetSize()), Rect(Point(frame.left + 3 + (widget->IsVisible() ? 1 : 0), frame.top + 2), sSize));
					}

					surface->SetText(widget->GetText(), Rect(Point(frame.left + sSize.cx + 6 + (widget->IsVisible() ? 1 : 0), frame.top + Math::Ceil(Float(frame.GetHeight() - widget->GetFont().GetScaledTextSizeY()) / 2) - 1), Size(widget->GetScaledTextWidth() + sSize.cx, offset - 2)), widget->GetFont());

					if (widget->IsVisible())
					{
						frame.bottom++;

						surface->Line(Point(frame.left + 1, frame.bottom), Point(frame.right + (IsRightToLeft() ? 1 : 0), frame.bottom), Setup::BackgroundColor);
						surface->SetPixel(Point(frame.left + (IsRightToLeft() ? 1 : 0), frame.bottom), (IsRightToLeft() ? darkColor : lightColor));

						if (IsRightToLeft()) surface->SetPixel(Point(frame.right + 1, frame.bottom), lightColor);

						frame.right--;
					}
					else
					{
						if (prev != NIL && prev->IsVisible()) frame.left++;

						surface->Line(Point(frame.left, frame.bottom), Point(frame.right + (IsRightToLeft() ? 2 : 1), frame.bottom), lightColor);

						if (prev != NIL && prev->IsVisible()) frame.left--;

						frame.top--;
					}
				}
			}

			break;
	}

	return Widget::Paint(message);
}

// 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 0x7c7af
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
movl %eax, %ecx
xorl %eax, %eax
testb %cl, %cl
je 0x7c7c2
testl %ebx, %ebx
jne 0x7c7b8
movl %ebx, 0x5c(%rsp)
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
leaq 0xc(%rsp), %rdx
movl %ebx, -0x4(%rdx)
movl %r15d, (%rdx)
leaq 0x10(%rsp), %rdx
movl %ecx, (%rdx)
addl %r15d, %eax
movl %eax, 0x4(%rdx)
movq %r13, %rdi
callq 0x59c60
cwtl
imull $0x13, %eax, %eax
pushq $0x60
popq %rcx
cltd
idivl %ecx
movl %eax, %r15d
movq 0xe543a(%rip), %r8      # 0x1614d0
movl 0x8(%r8), %eax
movl $0xff, %esi
movl %eax, %ecx
andl %esi, %ecx
movl $0xbf, %edx
cmpl %edx, %ecx
movl $0xbf, %edi
cmovbl %ecx, %edi
addl $0x40, %edi
movl %eax, %r9d
shrl $0x8, %r9d
andl %esi, %r9d
cmpl %edx, %r9d
movl $0xbf, %r10d
cmovbl %r9d, %r10d
shrl $0x10, %eax
andl %esi, %eax
cmpl %edx, %eax
cmovbl %eax, %edx
shll $0x10, %edx
addl $0x400000, %edx         # imm = 0x400000
shll $0x8, %r10d
addl $0x4000, %r10d          # imm = 0x4000
orl %edi, %r10d
orl %edx, %r10d
movq %r10, 0x48(%rsp)
cmpl $0x41, %ecx
pushq $0x40
popq %rdx
cmovbl %edx, %ecx
addl $-0x40, %ecx
cmpl $0x41, %r9d
cmovbl %edx, %r9d
cmpl $0x41, %eax
cmovbl %edx, %eax
shll $0x10, %eax
addl $0xffc00000, %eax       # imm = 0xFFC00000
shll $0x8, %r9d
addl $0xffffc000, %r9d       # imm = 0xFFFFC000
orl %ecx, %r9d
orl %eax, %r9d
movq %r9, 0x78(%rsp)
movq 0xe5e74(%rip), %rax     # 0x161fa8
movl (%rax), %ecx
leaq 0x18(%rsp), %rbp
andq $0x0, (%rbp)
leaq 0x8(%rsp), %rbx
movq %r13, %rdi
movq %rbx, %rsi
movq %r8, %rdx
movq %rbp, %r8
callq 0x58b80
leaq 0x28(%rsp), %rsi
andl $0x0, (%rsi)
movl %r15d, 0x4(%rsi)
movq %rbx, %rdi
callq 0x58930
movl %edx, %ecx
shrq $0x20, %rdx
subl %r15d, %edx
shlq $0x20, %rdx
orq %rdx, %rcx
movq %rax, (%rbp)
movq %rcx, 0x8(%rbp)
leaq 0x18(%rsp), %rsi
xorl %r12d, %r12d
movq %r13, 0x38(%rsp)
movq %r13, %rdi
xorl %edx, %edx
callq 0x58ad0
movl (%rbx), %eax
movl %eax, 0x8(%rbx)
movl 0x4(%rbx), %eax
addl %r15d, %eax
movl %eax, 0xc(%rbx)
leaq 0x5c0(%r14), %rax
movq %rax, 0x80(%rsp)
addl $-0x2, %r15d
movq %r15, 0x88(%rsp)
movq %r14, 0x60(%rsp)
cmpl 0x40(%r14), %r12d
jge 0x7c7b4
movq %r14, %rdi
movl %r12d, %esi
callq 0x58c90
movq %rax, %rbx
testl %r12d, %r12d
je 0x7c1f8
leal -0x1(%r12), %esi
movq %r14, %rdi
callq 0x58c90
movq %rax, 0x40(%rsp)
jmp 0x7c201
movq $0x0, 0x40(%rsp)
movq %r12, 0x68(%rsp)
movl 0x8(%rbx), %esi
movq 0x80(%rsp), %rdi
callq 0x7d23a
movq %rax, %r15
xorl %r13d, %r13d
movq %rax, %rdi
xorl %esi, %esi
callq 0x590c0
movl $0x0, %ecx
testb %al, %al
jne 0x7c2a8
movq %r15, %rdi
callq 0x596e0
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0x50(%rsp)
movq %r15, %rdi
callq 0x596e0
cvtsi2sdl 0x4(%rax), %xmm0
divsd 0x69f92(%rip), %xmm0    # 0xe61e8
movsd 0x50(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
movl %eax, 0x28(%rsp)
movl $0xf, 0x2c(%rsp)
movq 0x38(%rsp), %rdi
callq 0x59c60
cwtl
cvtsi2sd %eax, %xmm0
leaq 0x28(%rsp), %rdi
callq 0x57480
movq %rax, 0x18(%rsp)
movq %rbp, %rdi
movsd 0x67277(%rip), %xmm0    # 0xe3510
callq 0x59050
movq %rax, %r13
movq %rax, %rcx
shrq $0x20, %rcx
movq %rcx, 0x90(%rsp)
movl 0x10(%rsp), %ebp
leal 0x1(%rbp), %eax
movl %eax, 0x8(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xf8(%rax)
movl %eax, %r12d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xa8(%rax)
movq %rax, %rdi
xorl %esi, %esi
callq 0x57d40
movq %r13, 0x50(%rsp)
leal 0x7(%r13,%rbp), %ecx
leal (%rcx,%r12), %edx
testb %al, %al
leal 0x6(%r12,%rcx), %eax
cmovel %edx, %eax
movl %eax, 0x10(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x90(%rax)
leaq 0xc(%rsp), %rcx
testb %al, %al
je 0x7c31a
decl 0x8(%rsp)
leaq 0x10(%rsp), %rcx
incl (%rcx)
cmpq $0x0, 0x40(%rsp)
movq 0xe51a7(%rip), %r12     # 0x1614d0
leaq 0x18(%rsp), %rbp
je 0x7c346
movq 0x40(%rsp), %rdi
movq (%rdi), %rax
callq *0x90(%rax)
testb %al, %al
je 0x7c346
incl 0x8(%rsp)
movq 0x8(%rsp), %rax
movl 0x10(%rsp), %ecx
movl 0x14(%rsp), %edx
incl %ecx
incl %edx
shlq $0x20, %rdx
orq %rdx, %rcx
movq %rax, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
movq 0x38(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x58ad0
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
testb %al, %al
je 0x7c38f
incl 0x8(%rsp)
incl 0x10(%rsp)
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x7c421
movq (%rdi), %rax
callq *0x90(%rax)
movl 0x8(%rsp), %ecx
testb %al, %al
je 0x7c425
movl 0xc(%rsp), %eax
movl 0x14(%rsp), %edx
incl %eax
movl %ecx, 0x18(%rsp)
movl %eax, 0x1c(%rsp)
movl %ecx, 0x28(%rsp)
movl %edx, 0x2c(%rsp)
movq 0x38(%rsp), %rdi
movq %rbp, %rsi
leaq 0x28(%rsp), %rdx
movq %r12, %rcx
callq 0x595b0
decl 0x8(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
testb %al, %al
je 0x7c441
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
incl %eax
movl %eax, 0x28(%rsp)
movl %ecx, 0x2c(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x20(%rsp)
andl $0x0, 0x18(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %rbp, %rdx
jmp 0x7c43c
movl 0x8(%rsp), %ecx
movl 0xc(%rsp), %eax
movl %ecx, 0x18(%rsp)
movl %eax, 0x1c(%rsp)
movq 0x38(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x56120
movq 0xc(%rsp), %xmm0
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq %xmm0, 0x18(%rsp)
movq 0x38(%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x56120
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
testb %al, %al
je 0x7c47a
decl 0x8(%rsp)
decl 0x10(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x90(%rax)
testb %al, %al
je 0x7c48e
decl 0x14(%rsp)
movq %r15, %rdi
xorl %esi, %esi
callq 0x574f0
testb %al, %al
movq 0x50(%rsp), %r14
je 0x7c513
movq %r15, %rdi
callq 0x596e0
andq $0x0, 0x18(%rsp)
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movl 0x8(%rsp), %r12d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x90(%rax)
movzbl %al, %eax
movl %r12d, %ecx
addl %eax, %ecx
addl %r12d, %eax
addl $0x3, %eax
movl 0xc(%rsp), %edx
leal 0x2(%rdx), %esi
movl %eax, 0x28(%rsp)
movl %esi, 0x2c(%rsp)
leal 0x3(%r14,%rcx), %eax
movl %eax, 0x30(%rsp)
movq 0x90(%rsp), %rax
leal 0x2(%rdx,%rax), %eax
movl %eax, 0x34(%rsp)
movq 0x38(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rdx
leaq 0x28(%rsp), %rcx
callq 0x56c20
leal 0x6(%r14), %ebp
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xa8(%rax)
movq %rax, %r15
movq (%rbx), %rax
addl 0x8(%rsp), %ebp
movq %rbx, %rdi
callq *0x90(%rax)
movzbl %al, %r12d
addl %ebp, %r12d
movl 0xc(%rsp), %ebp
movl 0x14(%rsp), %r13d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xe8(%rax)
movq %rax, %rdi
movq 0xe585c(%rip), %rsi     # 0x161db8
callq 0x588a0
addl %ebp, %eax
subl %eax, %r13d
cvtsi2sd %r13d, %xmm0
mulsd 0x66e0d(%rip), %xmm0    # 0xe3380
callq 0x57e30
movl %ebp, %r13d
addl %eax, %r13d
addl %eax, %ebp
decl %ebp
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xf8(%rax)
movl %r12d, 0x18(%rsp)
movl %ebp, 0x1c(%rsp)
leaq 0x18(%rsp), %rbp
addl %r14d, %eax
addl %r12d, %eax
movl %eax, 0x20(%rsp)
movq 0x88(%rsp), %rax
addl %r13d, %eax
decl %eax
movq 0x38(%rsp), %r14
movl %eax, 0x24(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xe8(%rax)
movq %r14, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
callq 0x58df0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x90(%rax)
testb %al, %al
je 0x7c6fa
movl 0x14(%rsp), %eax
incl %eax
movl %eax, 0x14(%rsp)
movl 0x8(%rsp), %ecx
movl 0x10(%rsp), %ebx
incl %ecx
movl %ecx, 0x18(%rsp)
movl %eax, 0x1c(%rsp)
movq 0x60(%rsp), %r14
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
movzbl %al, %eax
addl %ebx, %eax
movl 0x14(%rsp), %ecx
movl %eax, 0x28(%rsp)
movl %ecx, 0x2c(%rsp)
movq 0x38(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
leaq 0x28(%rsp), %r15
movq %r15, %rdx
movq 0xe4e88(%rip), %rcx     # 0x1614d0
callq 0x595b0
movl 0x8(%rsp), %ebx
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
movzbl %al, %eax
addl %ebx, %eax
movl 0x14(%rsp), %ecx
movl %eax, 0x28(%rsp)
movl %ecx, 0x2c(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
testb %al, %al
movq 0x48(%rsp), %rax
cmovneq 0x78(%rsp), %rax
movq %rax, 0x20(%rsp)
andl $0x0, 0x18(%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x56120
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
leaq 0x10(%rsp), %rcx
testb %al, %al
movq 0x68(%rsp), %r12
je 0x7c7a5
movl 0x10(%rsp), %eax
movl 0x14(%rsp), %ecx
incl %eax
movl %eax, 0x28(%rsp)
movl %ecx, 0x2c(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x20(%rsp)
andl $0x0, 0x18(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %rbp, %rdx
callq 0x56120
leaq 0x10(%rsp), %rcx
jmp 0x7c7a5
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
movq 0x60(%rsp), %r14
movq 0x68(%rsp), %r12
je 0x7c727
movq (%rdi), %rax
callq *0x90(%rax)
movl 0x8(%rsp), %ecx
testb %al, %al
je 0x7c72b
incl %ecx
movl %ecx, 0x8(%rsp)
jmp 0x7c72b
movl 0x8(%rsp), %ecx
movl 0x10(%rsp), %ebx
movl 0x14(%rsp), %eax
movl %ecx, 0x28(%rsp)
movl %eax, 0x2c(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
movzbl %al, %eax
addl %ebx, %eax
incl %eax
movl 0x14(%rsp), %ecx
movl %eax, 0x70(%rsp)
movl %ecx, 0x74(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x20(%rsp)
andl $0x0, 0x18(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x70(%rsp), %rdx
movq %rbp, %rcx
callq 0x595b0
leaq 0xc(%rsp), %rcx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x7c7a5
movq (%rdi), %rax
callq *0x90(%rax)
leaq 0xc(%rsp), %rcx
testb %al, %al
je 0x7c7a5
decl 0x8(%rsp)
decl (%rcx)
incl %r12d
jmp 0x7c1c7
pushq $-0x1
popq %rax
jmp 0x7c7c2
movl 0x5c(%rsp), %ebx
movq %r14, %rdi
movl %ebx, %esi
callq 0x57910
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq