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

	Surface	*surface	= GetDrawSurface();
	Point	 realPos	= GetRealPosition();
	Size	 realSize	= GetRealSize();

	Bool	 smallHotspots	= (subtype == OR_HORZ && (GetWidth() <= 55)) || (subtype == OR_VERT && (GetHeight() <= 55));
	Int	 hotspotSize	= Math::Round((smallHotspots ? 10 : (subtype == OR_HORZ ? GetHeight() : GetWidth())) * surface->GetSurfaceDPI() / 96.0) - 4;

	Rect	 arrow1Frame	= Rect(realPos + Point(subtype == OR_HORZ ? realSize.cx - (hotspotSize + 4) : 0, subtype == OR_VERT ? realSize.cy - (hotspotSize + 4) : 0), subtype == OR_HORZ ? Size(hotspotSize + 4, realSize.cy) : Size(realSize.cx, hotspotSize + 4));
	Rect	 arrow2Frame	= Rect(realPos + Point(0, 0), subtype == OR_HORZ ? Size(hotspotSize + 4, realSize.cy) : Size(realSize.cx, hotspotSize + 4));
	Int	 arrowColor	= Setup::TextColor;

	if (!IsActive()) arrowColor = Setup::InactiveTextColor;

	switch (message)
	{
		case SP_PAINT:
			surface->StartPaint(Rect(realPos, realSize));

			OnValueChange();

			surface->Box(arrow1Frame, Setup::BackgroundColor, Rect::Filled);
			surface->Box(arrow2Frame, Setup::BackgroundColor, Rect::Filled);

			surface->Frame(arrow1Frame, FRAME_UP);
			surface->Frame(arrow2Frame, FRAME_UP);

			if (subtype == OR_HORZ)
			{
				Int	 size = Math::Round(3 * surface->GetSurfaceDPI() / 96.0);

				for (Int i = 0; i < size; i++)
				{
					Point	 lineStart = Point(realPos.x + (hotspotSize + 4) / 2 - size / 2 + i, realPos.y + realSize.cy / 2 - i);
					Point	 lineEnd   = lineStart + Point(0, 2 * i + 1);

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

				for (Int i = 0; i < size; i++)
				{
					Point	 lineStart = Point(realPos.x + realSize.cx - (hotspotSize + 4) / 2 - (size + 1) / 2 + i, realPos.y + realSize.cy / 2 - size + 1 + i);
					Point	 lineEnd   = lineStart + Point(0, 2 * (size - i) - 1);

					surface->Line(lineStart, lineEnd, arrowColor);
				}
			}
			else if (subtype == OR_VERT)
			{
				Int	 size = Math::Round(3 * surface->GetSurfaceDPI() / 96.0);

				for (Int i = 0; i < size; i++)
				{
					Point	 lineStart = Point(realPos.x + realSize.cx / 2 + (IsRightToLeft() ? 1 : 0) - i, (realPos.y + (hotspotSize + 4) / 2) - size / 2 + i);
					Point	 lineEnd   = lineStart + Point(2 * i + 1, 0);

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

				for (Int i = 0; i < size; i++)
				{
					Point	 lineStart = Point(realPos.x + realSize.cx / 2 + (IsRightToLeft() ? 1 : 0) - size + 1 + i, (realPos.y + realSize.cy - (hotspotSize + 4) / 2) - (size + 1) / 2 + i);
					Point	 lineEnd   = lineStart + Point(2 * (size - i) - 1, 0);

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

			surface->EndPaint();

			break;
	}

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %esi, %ebp
movq %rdi, %r14
movq (%rdi), %rax
callq *0x88(%rax)
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb %cl, %cl
je 0x7bbb8
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
movl %eax, %ecx
xorl %eax, %eax
testb %cl, %cl
je 0x7bbb8
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, 0x8(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %r15
movq %rax, 0x18(%rsp)
shrq $0x20, %r15
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
movq %rax, %r12
movl %r12d, %r13d
shrq $0x20, %rax
movq %rax, 0x10(%rsp)
movzwl 0x1a0(%r14), %eax
cmpl $0x2, %eax
je 0x7b6fa
cmpl $0x1, %eax
jne 0x7b709
movl $0xa, %ebx
cmpl $0x38, 0xb0(%r14)
jl 0x7b710
movl 0xb4(%r14), %ebx
jmp 0x7b710
movl $0xa, %ebx
cmpl $0x38, 0xb4(%r14)
jl 0x7b710
movl 0xb0(%r14), %ebx
movq 0x8(%rsp), %rdi
callq 0x58930
cwtl
imull %ebx, %eax
cvtsi2sd %eax, %xmm0
divsd 0x77f8e(%rip), %xmm0    # 0xf36b8
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x780b2(%rip), %rcx     # 0xf37f0
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rbx
movzwl 0x1a0(%r14), %eax
subl %ebx, %r12d
movq 0x10(%rsp), %rsi
movl %esi, %ecx
subl %ebx, %ecx
xorl %edx, %edx
cmpw $0x2, %ax
cmovnel %edx, %ecx
cmpw $0x1, %ax
cmovnel %edx, %r12d
movl %r13d, %eax
cmovel %ebx, %eax
movl %ebx, %edx
cmovel %esi, %edx
movq 0x18(%rsp), %rdi
leal (%rdi,%r12), %esi
addl %r15d, %ecx
movl %esi, 0x58(%rsp)
movl %ecx, 0x5c(%rsp)
addl %eax, %esi
movl %esi, 0x60(%rsp)
addl %edx, %ecx
movl %ecx, 0x64(%rsp)
movl %edi, 0x68(%rsp)
movl %r15d, 0x6c(%rsp)
addl %edi, %eax
movl %eax, 0x70(%rsp)
addl %r15d, %edx
movl %edx, 0x74(%rsp)
movq 0xf0233(%rip), %rax     # 0x16b9e8
movq 0x8(%rax), %r12
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
testb %al, %al
jne 0x7b7d4
movq 0xf0180(%rip), %rax     # 0x16b950
movq 0x8(%rax), %r12
testl %ebp, %ebp
jne 0x7bbb6
movq %r12, 0x40(%rsp)
leaq 0x28(%rsp), %r12
movq 0x18(%rsp), %rax
movl %eax, (%r12)
movl %r15d, 0x4(%r12)
movq %r13, 0x38(%rsp)
leal (%r13,%rax), %ebp
movl %ebp, 0x8(%r12)
movq 0x10(%rsp), %rax
addl %r15d, %eax
movq %rax, 0x48(%rsp)
movl %eax, 0xc(%r12)
movq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x55160
movq %r14, %rdi
callq 0x591a0
movq 0xf0774(%rip), %rax     # 0x16bfa8
movl (%rax), %ecx
xorl %eax, %eax
movq %rax, (%r12)
movq 0xefc8d(%rip), %rdx     # 0x16b4d0
leaq 0x58(%rsp), %rsi
leaq 0x28(%rsp), %r12
movq %r13, %rdi
movq %r12, %r8
callq 0x57930
movq 0xf0749(%rip), %rax     # 0x16bfa8
movl (%rax), %ecx
xorl %eax, %eax
movq %rax, (%r12)
leaq 0x68(%rsp), %r12
leaq 0x28(%rsp), %r8
movq %r13, %rdi
movq %r12, %rsi
movq 0xefc52(%rip), %rdx     # 0x16b4d0
callq 0x57930
movq %r13, %rdi
leaq 0x58(%rsp), %rsi
xorl %edx, %edx
callq 0x57890
movq %r13, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x57890
movzwl 0x1a0(%r14), %eax
cmpl $0x2, %eax
je 0x7ba24
cmpl $0x1, %eax
jne 0x7bbac
movq 0x8(%rsp), %rdi
callq 0x58930
cwtl
leal (%rax,%rax,2), %eax
cvtsi2sd %eax, %xmm0
divsd 0x77de5(%rip), %xmm0    # 0xf36b8
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x77f09(%rip), %rcx     # 0xf37f0
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %r12
testl %r12d, %r12d
jle 0x7bbac
movl %ebx, %ecx
shrl $0x1f, %ecx
addl %ebx, %ecx
sarl %ecx
movq 0x18(%rsp), %rax
movq %rcx, 0x48(%rsp)
leal (%rcx,%rax), %ebx
movl %r12d, %eax
shrl %eax
subl %eax, %ebx
movq 0x10(%rsp), %rax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
leal (%rcx,%r15), %r14d
movslq 0x40(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %r12, 0x10(%rsp)
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movq %rcx, 0x38(%rsp)
leal (%rcx,%r15), %r13d
incl %r13d
movl %ebx, (%rsp)
movl %r14d, 0x4(%rsp)
movq %r13, %rax
shlq $0x20, %rax
movl %ebx, %ecx
orq %rax, %rcx
movq %rcx, 0x20(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x30(%rsp)
movl $0x0, 0x28(%rsp)
movq 0x8(%rsp), %rdi
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
leaq 0x28(%rsp), %rcx
callq 0x58300
incl %r13d
incl %ebx
decl %r14d
decq %r12
jne 0x7b94b
movq 0x10(%rsp), %rcx
testl %ecx, %ecx
jle 0x7bbac
subl 0x48(%rsp), %ebp
leal 0x1(%rcx), %eax
shrl %eax
subl %eax, %ebp
movq 0x38(%rsp), %rax
leal (%rax,%r15), %ebx
subl %ecx, %ebx
incl %ebx
movslq 0x40(%rsp), %r14
movl %ecx, %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
addl %ecx, %r15d
addl %eax, %r15d
leaq 0x28(%rsp), %r12
movl %ebp, (%rsp)
movl %ebx, 0x4(%rsp)
movq %r15, %rax
shlq $0x20, %rax
movl %ebp, %ecx
orq %rax, %rcx
movq %rcx, 0x20(%rsp)
movq %r14, 0x30(%rsp)
movl $0x0, 0x28(%rsp)
movq 0x8(%rsp), %rdi
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %r12, %rcx
callq 0x58300
incl %ebx
decl %r15d
incl %ebp
decq %r13
jne 0x7b9d9
jmp 0x7bbac
movq 0x38(%rsp), %r12
movq %r13, %rdi
callq 0x58930
cwtl
leal (%rax,%rax,2), %eax
cvtsi2sd %eax, %xmm0
divsd 0x77c77(%rip), %xmm0    # 0xf36b8
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x77d9b(%rip), %rcx     # 0xf37f0
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rdx
testl %edx, %edx
jle 0x7bbac
movq %r12, %rax
shrl $0x1f, %r12d
addl %eax, %r12d
sarl %r12d
movq 0x18(%rsp), %rcx
leal (%r12,%rcx), %ebp
movl %ebx, %eax
shrl $0x1f, %eax
addl %ebx, %eax
sarl %eax
movl %eax, 0x54(%rsp)
addl %eax, %r15d
movl %edx, %eax
shrl %eax
subl %eax, %r15d
movslq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x38(%rsp)
movl %edx, %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
leal (%r12,%rcx), %r13d
incl %r13d
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
movzbl %al, %eax
leal (%rax,%rbp), %ecx
movl %ecx, (%rsp)
movl %r15d, 0x4(%rsp)
addl %r13d, %eax
movq %r15, %rcx
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
movl $0x0, 0x28(%rsp)
movq 0x8(%rsp), %rdi
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
leaq 0x28(%rsp), %rcx
callq 0x58300
incl %r13d
incl %r15d
decl %ebp
decq %rbx
jne 0x7bab2
movq 0x38(%rsp), %rcx
testl %ecx, %ecx
movq 0x48(%rsp), %r13
jle 0x7bbac
subl 0x54(%rsp), %r13d
leal 0x1(%rcx), %eax
shrl %eax
subl %eax, %r13d
movslq 0x40(%rsp), %r15
movl %ecx, %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
addl 0x18(%rsp), %r12d
leal (%r12,%rcx), %ebp
subl %ecx, %r12d
incl %r12d
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
movzbl %al, %eax
leal (%r12,%rax), %ecx
movl %ecx, (%rsp)
movl %r13d, 0x4(%rsp)
addl %ebp, %eax
movq %r13, %rcx
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x20(%rsp)
movq %r15, 0x30(%rsp)
movl $0x0, 0x28(%rsp)
movq 0x8(%rsp), %rdi
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
leaq 0x28(%rsp), %rcx
callq 0x58300
incl %r13d
decl %ebp
incl %r12d
decq %rbx
jne 0x7bb4f
movq 0x8(%rsp), %rdi
callq 0x58780
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop