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

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

				surface->StartPaint(frame);

				if (message == SP_PAINT)
				{
					Font	 nFont = font;

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

					surface->Box(frame, GetBackgroundColor(), Rect::Filled);
					surface->SetText(text, frame + Point(frame.GetHeight(), Math::Ceil(Float(frame.GetHeight() - scaledTextSize.cy) / 2) - 1), nFont);
				}

				Float	 scaleFactor = surface->GetSurfaceDPI() / 96.0;
				Int	 inset	     = 3 * scaleFactor;

				Point	 lineStart   = Point(frame.left, frame.top) + Point(3, 3) * scaleFactor + Point(inset + (IsRightToLeft() ? 1 : 0), 0);
				Point	 lineEnd     = lineStart + Point(11 * scaleFactor - 2 * inset, 0);

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

				Int	 innerColor  = (IsActive() ? Setup::ClientColor : Setup::BackgroundColor);

				surface->Line(lineStart, lineEnd, darkColor);

				for (Int i = 0; i < Int(11 * scaleFactor) - 2; i++)
				{
					if	(i <			      inset) { lineStart.x--; lineEnd.x++; }
					else if (i > (11 * scaleFactor) - 2 - inset) { lineStart.x++; lineEnd.x--; }

					lineStart.y++;
					lineEnd.y++;

					surface->Line(lineStart, lineEnd, innerColor);

					Int	 leftColor  = (i > (11 * scaleFactor) - 2 - inset) ? lightColor : (IsRightToLeft() ? lightColor : darkColor);
					Int	 rightColor = (i > (11 * scaleFactor) - 2 - inset) ? lightColor : (IsRightToLeft() ? darkColor : lightColor);

					surface->SetPixel(lineStart, leftColor);
					surface->SetPixel(lineEnd - Point(1, 0), rightColor);
				}

				lineStart.x++;
				lineStart.y++;
				lineEnd.x--;
				lineEnd.y++;

				surface->Line(lineStart, lineEnd, lightColor);

				if (*variable == code)
				{
					for (Int i = 0; i < 2; i++)
					{
						Int	 color	= IsActive() ? Setup::DividerDarkColor : Setup::DividerDarkColor.Average(Setup::BackgroundColor);
						Point	 offset	= Point(IsRightToLeft() ? 0 : 1, 0);

						if (i == 1)
						{
							color	= IsActive() ? Setup::ClientTextColor : Setup::InactiveTextColor;
							offset -= Point(IsRightToLeft() ? -i : i, i);
						}

						Int	 inset	    = 2 * scaleFactor;

						Point	 lineStart  = Point(frame.left, frame.top) + Point(6, 6) * scaleFactor + offset + Point(inset, 0);
						Point	 lineEnd    = lineStart + Point(5 * scaleFactor - 2 * inset, 0);

						for (Int j = 0; j < Int(5 * scaleFactor); j++)
						{
							if	(j <			 inset) { lineStart.x--; lineEnd.x++; }
							else if (j > (5 * scaleFactor) - inset) { lineStart.x++; lineEnd.x--; }

							lineStart.y++;
							lineEnd.y++;

							surface->Line(lineStart, lineEnd, color);
						}
					}
				}

				surface->EndPaint();
			}

			break;
	}

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %esi, %ebp
movq %rdi, %r14
movq (%rdi), %rax
callq *0x88(%rax)
testb %al, %al
je 0x7852c
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x1, %ebp
ja 0x787b4
testb %cl, %cl
je 0x787b4
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, %r12
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
leaq 0x68(%rsp), %rsi
movl %r15d, (%rsi)
movl %ebx, 0x4(%rsi)
movl %ecx, 0x8(%rsi)
addl %ebx, %eax
movl %eax, 0xc(%rsi)
movq %r12, %rdi
callq 0x56160
testl %ebp, %ebp
jne 0x781df
leaq 0x140(%r14), %rsi
leaq 0x98(%rsp), %rdi
callq 0x56bf0
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
testb %al, %al
jne 0x78143
movq 0xe981a(%rip), %rsi     # 0x161950
leaq 0x98(%rsp), %rdi
callq 0x59940
movq (%r14), %rax
movq %r14, %rdi
callq *0x140(%rax)
movq 0xe9e52(%rip), %rcx     # 0x161fa8
movl (%rcx), %ecx
leaq 0x58(%rsp), %r8
andq $0x0, (%r8)
leaq 0x68(%rsp), %rsi
movq %r12, %rdi
movq %rax, %rdx
callq 0x58b80
movl 0x74(%rsp), %ebx
subl 0x6c(%rsp), %ebx
movl %ebx, %eax
subl 0x18c(%r14), %eax
cvtsi2sd %eax, %xmm0
mulsd 0x6b1f2(%rip), %xmm0    # 0xe3380
callq 0x57e30
decl %eax
leaq 0x8(%rsp), %rsi
movl %ebx, (%rsi)
movl %eax, 0x4(%rsi)
leaq 0x68(%rsp), %rdi
callq 0x58930
leaq 0xf0(%r14), %rsi
leaq 0x58(%rsp), %r8
movq %rax, (%r8)
movq %rdx, 0x8(%r8)
leaq 0x98(%rsp), %rcx
movq %r12, %rdi
movq %r8, %rdx
xorl %r8d, %r8d
callq 0x58df0
leaq 0x98(%rsp), %rdi
callq 0x57860
movq %r12, %rdi
callq 0x59c60
cwtl
cvtsi2sd %eax, %xmm1
divsd 0x6b31c(%rip), %xmm1    # 0xe3510
movsd 0x6b384(%rip), %xmm0    # 0xe3580
mulsd %xmm1, %xmm0
movsd %xmm1, 0x80(%rsp)
movapd %xmm0, 0x20(%rsp)
cvttsd2si %xmm0, %r13d
movq %r12, 0x48(%rsp)
movq %r14, %r15
movl 0x6c(%rsp), %r14d
movl 0x68(%rsp), %ebp
addl %r13d, %ebp
movabsq $0x300000003, %rax      # imm = 0x300000003
leaq 0x98(%rsp), %rdi
movq %rax, (%rdi)
movapd %xmm1, %xmm0
callq 0x570c0
movq %rax, %r12
movq %rax, %rbx
shrq $0x20, %rbx
addl %r14d, %ebx
shlq $0x20, %rbx
movq (%r15), %rax
movq %r15, %rdi
callq *0x160(%rax)
movzbl %al, %eax
addl %r12d, %eax
addl %ebp, %eax
leaq (%rax,%rbx), %rsi
movq %r13, 0x90(%rsp)
leal (,%r13,2), %ecx
cvtsi2sd %ecx, %xmm0
leaq 0x58(%rsp), %r12
movsd 0x6dd28(%rip), %xmm1    # 0xe5fb8
mulsd 0x80(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
subsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
addl %eax, %ecx
orq %rbx, %rcx
movq 0xe921d(%rip), %r14     # 0x1614d0
movl 0x8(%r14), %eax
addq $0x8, %r14
movl $0xff, %r8d
movl %eax, %edx
andl %r8d, %edx
movl $0xbf, %edi
cmpl %edi, %edx
movl $0xbf, %r9d
cmovbl %edx, %r9d
addl $0x40, %r9d
movl %eax, %r13d
shrl $0x8, %r13d
andl %r8d, %r13d
cmpl %edi, %r13d
movl $0xbf, %ebx
cmovbl %r13d, %ebx
movq %rsi, (%r12)
shrl $0x10, %eax
andl %r8d, %eax
cmpl %edi, %eax
cmovbl %eax, %edi
shll $0x10, %edi
addl $0x400000, %edi         # imm = 0x400000
shll $0x8, %ebx
addl $0x4000, %ebx           # imm = 0x4000
orl %r9d, %ebx
orl %edi, %ebx
cmpl $0x41, %edx
pushq $0x40
popq %rsi
cmovbl %esi, %edx
addl $-0x40, %edx
cmpl $0x41, %r13d
cmovbl %esi, %r13d
leaq 0x8(%rsp), %rbp
cmpl $0x41, %eax
cmovbl %esi, %eax
movq %rcx, (%rbp)
shll $0x10, %eax
addl $0xffc00000, %eax       # imm = 0xFFC00000
shll $0x8, %r13d
addl $0xffffc000, %r13d      # imm = 0xFFFFC000
orl %edx, %r13d
orl %eax, %r13d
movq (%r15), %rax
movq %r15, 0x38(%rsp)
movq %r15, %rdi
movq 0x48(%rsp), %r15
callq *0x98(%rax)
movq 0xe9300(%rip), %rcx     # 0x161670
addq $0x8, %rcx
testb %al, %al
cmoveq %r14, %rcx
movslq (%rcx), %rax
movq %rax, 0x88(%rsp)
movq %r13, 0x78(%rsp)
leaq 0x98(%rsp), %rax
movq %r13, 0x8(%rax)
andl $0x0, (%rax)
leaq 0x98(%rsp), %rcx
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x595b0
movsd 0x10(%rsp), %xmm1
cvttsd2si %xmm1, %eax
addsd 0x6dbff(%rip), %xmm1    # 0xe5fc0
cvttpd2dq 0x20(%rsp), %xmm0
cvtdq2pd %xmm0, %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
cmpl $0x3, %eax
pushq $0x2
popq %r14
cmovgel %eax, %r14d
addl $-0x2, %r14d
xorl %r12d, %r12d
xorpd %xmm0, %xmm0
cmpl %r12d, %r14d
je 0x78534
cmpl 0x90(%rsp), %r12d
movsd %xmm0, 0x20(%rsp)
jge 0x78414
decl 0x58(%rsp)
incl 0x8(%rsp)
movsd %xmm0, 0x40(%rsp)
jmp 0x7842f
cvtsi2sd %r12d, %xmm2
ucomisd 0x10(%rsp), %xmm2
movsd %xmm2, 0x40(%rsp)
jbe 0x7842f
incl 0x58(%rsp)
decl 0x8(%rsp)
incl 0x5c(%rsp)
incl 0xc(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0xa0(%rsp)
andl $0x0, 0x98(%rsp)
movq %r15, %rdi
leaq 0x58(%rsp), %rsi
leaq 0x8(%rsp), %rdx
leaq 0x98(%rsp), %rcx
callq 0x595b0
movsd 0x40(%rsp), %xmm0
ucomisd 0x10(%rsp), %xmm0
movq %rbx, %r15
movq %rbx, %r13
ja 0x784b3
movq 0x38(%rsp), %r13
movq (%r13), %rax
movq %r13, %rdi
callq *0x160(%rax)
testb %al, %al
movq 0x78(%rsp), %rbp
movq %rbp, %r15
cmovneq %rbx, %r15
movq (%r13), %rax
movq %r13, %rdi
callq *0x160(%rax)
testb %al, %al
movq %rbx, %r13
cmovneq %rbp, %r13
movq %r15, 0xa0(%rsp)
andl $0x0, 0x98(%rsp)
movq 0x48(%rsp), %r15
movq %r15, %rdi
leaq 0x58(%rsp), %rsi
leaq 0x98(%rsp), %rbp
movq %rbp, %rdx
callq 0x56120
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
decl %eax
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x18(%rsp)
movq %r13, 0xa0(%rsp)
andl $0x0, 0x98(%rsp)
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
movq %rbp, %rdx
callq 0x56120
movsd 0x20(%rsp), %xmm0
addsd 0x6ae4c(%rip), %xmm0    # 0xe3370
incl %r12d
jmp 0x783eb
pushq $-0x1
popq %rax
jmp 0x787b4
leaq 0x58(%rsp), %rsi
movq (%rsi), %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, (%rsi)
leaq 0x8(%rsp), %rdx
movq (%rdx), %xmm0
paddd 0x6da76(%rip), %xmm0    # 0xe5fd0
movq %xmm0, (%rdx)
leaq 0x98(%rsp), %rcx
movq %rbx, 0x8(%rcx)
andl $0x0, (%rcx)
movq %r15, %rdi
callq 0x595b0
movq 0x38(%rsp), %r14
movq 0x5b8(%r14), %rax
movl (%rax), %eax
cmpl 0x5c0(%r14), %eax
jne 0x787a8
movsd 0x80(%rsp), %xmm2
movapd %xmm2, %xmm0
addsd %xmm2, %xmm0
cvttsd2si %xmm0, %r15d
leal (%r15,%r15), %eax
cvtsi2sd %eax, %xmm1
movsd 0x6da12(%rip), %xmm3    # 0xe5fc8
mulsd %xmm2, %xmm3
movapd %xmm3, %xmm2
subsd %xmm1, %xmm2
cvttsd2si %xmm2, %eax
movl %eax, 0x88(%rsp)
cvttsd2si %xmm3, %ebx
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
subsd %xmm0, %xmm3
movsd %xmm3, 0x40(%rsp)
xorl %r13d, %r13d
testl %ebx, %ebx
cmovlel %r13d, %ebx
movq 0xe9295(%rip), %rax     # 0x161888
addq $0x8, %rax
movq %rax, 0x78(%rsp)
leaq 0x98(%rsp), %r12
leaq 0x50(%rsp), %rbp
cmpl $0x2, %r13d
je 0x787a8
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
movq 0x78(%rsp), %rcx
testb %al, %al
jne 0x78646
movq %r12, %rdi
movq 0xe9256(%rip), %rsi     # 0x161888
movq 0xe8e97(%rip), %rdx     # 0x1614d0
callq 0x594a0
leaq 0xa0(%rsp), %rcx
movq (%rcx), %rax
movq %rax, 0x10(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
xorb $0x1, %al
movzbl %al, %ecx
movq %r14, %rdi
xorl %r14d, %r14d
cmpl $0x1, %r13d
movl %r13d, 0x90(%rsp)
jne 0x786bf
movq %rcx, 0x20(%rsp)
movq (%rdi), %rax
callq *0x98(%rax)
movq 0xe92c8(%rip), %rcx     # 0x161950
testb %al, %al
je 0x78693
movq 0xe975d(%rip), %rcx     # 0x161df0
movq 0x8(%rcx), %rax
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rdi
movq (%rdi), %rax
callq *0x160(%rax)
movzbl %al, %eax
decl %eax
orl $0x1, %eax
movq 0x20(%rsp), %rcx
addl %eax, %ecx
pushq $-0x1
popq %r13
jmp 0x786c2
xorl %r13d, %r13d
addl 0x6c(%rsp), %r13d
addl %r15d, %ecx
addl 0x68(%rsp), %ecx
movq %rcx, 0x20(%rsp)
movabsq $0x600000006, %rax      # imm = 0x600000006
movq %rax, 0x98(%rsp)
movq %r12, %rdi
movsd 0x80(%rsp), %xmm0
callq 0x570c0
movq 0x20(%rsp), %rcx
addl %eax, %ecx
shrq $0x20, %rax
addl %r13d, %eax
shlq $0x20, %rax
leaq (%rcx,%rax), %rdx
movq %rdx, 0x18(%rsp)
addl 0x88(%rsp), %ecx
orq %rax, %rcx
movq %rcx, 0x50(%rsp)
movslq 0x10(%rsp), %r13
xorpd %xmm0, %xmm0
cmpl %r14d, %ebx
je 0x78793
cmpl %r15d, %r14d
movsd %xmm0, 0x20(%rsp)
jge 0x78743
decl 0x18(%rsp)
incl 0x50(%rsp)
jmp 0x78753
ucomisd 0x40(%rsp), %xmm0
jbe 0x78753
incl 0x18(%rsp)
decl 0x50(%rsp)
incl 0x1c(%rsp)
incl 0x54(%rsp)
movq %r13, 0xa0(%rsp)
andl $0x0, 0x98(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x595b0
movsd 0x20(%rsp), %xmm0
addsd 0x6abe2(%rip), %xmm0    # 0xe3370
incl %r14d
jmp 0x78729
movl 0x90(%rsp), %r13d
incl %r13d
movq 0x38(%rsp), %r14
jmp 0x78609
movq 0x48(%rsp), %rdi
callq 0x59a80
xorl %eax, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x787ca
jmp 0x787ca
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x57860
movq %rbx, %rdi
callq 0x58260