// File: /workspace/github_c_makefile_star2_O1/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 $0x88, %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 0x7bf96
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
movl %eax, %ecx
xorl %eax, %eax
testb %cl, %cl
je 0x7bf96
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, %r13
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %r15
shrq $0x20, %rax
movq %rax, 0x48(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
movq %rax, %r12
movq %rax, 0x50(%rsp)
shrq $0x20, %rax
movq %rax, 0x8(%rsp)
movzwl 0x1a0(%r14), %eax
movl $0xa, %ebx
cmpw $0x1, %ax
jne 0x7ba4c
cmpl $0x38, 0xb0(%r14)
jl 0x7ba72
cmpw $0x2, %ax
jne 0x7ba5c
cmpl $0x38, 0xb4(%r14)
jl 0x7ba72
cmpw $0x1, %ax
jne 0x7ba6b
movl 0xb4(%r14), %ebx
jmp 0x7ba72
movl 0xb0(%r14), %ebx
movq %r13, %rdi
callq 0x58930
cwtl
imull %ebx, %eax
cvtsi2sd %eax, %xmm0
divsd 0x78a66(%rip), %xmm0    # 0xf44f0
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x78cf2(%rip), %rcx     # 0xf4790
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rsi
movzwl 0x1a0(%r14), %eax
subl %esi, %r12d
movq 0x8(%rsp), %rdi
movl %edi, %ecx
subl %esi, %ecx
xorl %edx, %edx
cmpw $0x2, %ax
cmovnel %edx, %ecx
cmpw $0x1, %ax
cmovnel %edx, %r12d
movq 0x50(%rsp), %rax
cmovel %esi, %eax
movq %rsi, 0x40(%rsp)
movl %esi, %edx
cmovel %edi, %edx
addl %r15d, %r12d
movq 0x48(%rsp), %rbx
addl %ebx, %ecx
movl %r12d, 0x60(%rsp)
movl %ecx, 0x64(%rsp)
addl %eax, %r12d
movl %r12d, 0x68(%rsp)
addl %edx, %ecx
movl %ecx, 0x6c(%rsp)
movl %r15d, 0x70(%rsp)
movl %ebx, 0x74(%rsp)
addl %r15d, %eax
movl %eax, 0x78(%rsp)
addl %ebx, %edx
movl %edx, 0x7c(%rsp)
movq 0xf0ecb(%rip), %rax     # 0x16c9e8
movq 0x8(%rax), %r12
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
testb %al, %al
jne 0x7bb3c
movq 0xf0e18(%rip), %rax     # 0x16c950
movq 0x8(%rax), %r12
testl %ebp, %ebp
jne 0x7bf94
movq %r12, 0x38(%rsp)
leaq 0x18(%rsp), %r12
movl %r15d, (%r12)
movl %ebx, 0x4(%r12)
movq %r15, 0x58(%rsp)
movq 0x50(%rsp), %rax
leal (%rax,%r15), %ebp
movl %ebp, 0x8(%r12)
movq 0x8(%rsp), %rax
addl %ebx, %eax
movq %rax, 0x80(%rsp)
movl %eax, 0xc(%r12)
movq %r13, %rdi
movq %r12, %rsi
callq 0x55160
movq %r14, %rdi
callq 0x591a0
movq 0xf1410(%rip), %rbx     # 0x16cfa8
movl (%rbx), %ecx
xorl %r15d, %r15d
movq %r15, (%r12)
movq 0xf0928(%rip), %rdx     # 0x16c4d0
leaq 0x60(%rsp), %rsi
leaq 0x18(%rsp), %r12
movq %r13, %rdi
movq %r12, %r8
callq 0x57930
movl (%rbx), %ecx
movq %r15, (%r12)
leaq 0x70(%rsp), %r12
leaq 0x18(%rsp), %r8
movq %r13, %rdi
movq %r12, %rsi
movq 0xf08f6(%rip), %rdx     # 0x16c4d0
callq 0x57930
movq %r13, %rdi
leaq 0x60(%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
movq %r13, 0x28(%rsp)
je 0x7bdb5
cmpl $0x1, %eax
jne 0x7bf8a
movq 0x28(%rsp), %rdi
callq 0x58930
cwtl
leal (%rax,%rax,2), %eax
cvtsi2sd %eax, %xmm0
divsd 0x788bc(%rip), %xmm0    # 0xf44f0
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x78b48(%rip), %rcx     # 0xf4790
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %r15
testl %r15d, %r15d
jle 0x7bcfc
movq 0x40(%rsp), %rax
movl %eax, %r13d
shrl $0x1f, %r13d
addl %eax, %r13d
sarl %r13d
addl 0x58(%rsp), %r13d
movl %r15d, %eax
shrl %eax
subl %eax, %r13d
movq 0x8(%rsp), %rcx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
movslq 0x38(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movl %r15d, %r14d
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
movq 0x48(%rsp), %rcx
leal (%rax,%rcx), %r12d
incl %r12d
movl %eax, %ebx
addl %ecx, %ebx
movl %r13d, (%rsp)
movl %ebx, 0x4(%rsp)
movq %r12, %rax
shlq $0x20, %rax
movl %r13d, %ecx
orq %rax, %rcx
movq %rcx, 0x10(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movl $0x0, 0x18(%rsp)
movq 0x28(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
leaq 0x18(%rsp), %rcx
callq 0x58300
incl %r12d
decl %ebx
incq %r13
decq %r14
jne 0x7bcac
testl %r15d, %r15d
movq 0x48(%rsp), %rbx
jle 0x7bf8a
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
movq 0x40(%rsp), %rcx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
subl %eax, %ebp
leal 0x1(%r15), %eax
shrl %eax
subl %eax, %ebp
movq 0x8(%rsp), %rcx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
addl %eax, %ebx
subl %r15d, %ebx
incl %ebx
movslq 0x38(%rsp), %r13
movl %r15d, %r12d
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
shlq $0x21, %r15
movq %rbx, %rax
shlq $0x20, %rax
addq %rdx, %r15
addq %rax, %r15
leaq 0x18(%rsp), %r14
movl %ebp, %eax
addq %r15, %rax
movl %ebp, (%rsp)
movl %ebx, 0x4(%rsp)
movq %rax, 0x10(%rsp)
movq %r13, 0x20(%rsp)
movl $0x0, 0x18(%rsp)
movq 0x28(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rcx
callq 0x58300
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
addq %rax, %r15
incq %rbp
incl %ebx
decq %r12
jne 0x7bd66
jmp 0x7bf8a
movq %r13, %rdi
callq 0x58930
cwtl
leal (%rax,%rax,2), %eax
cvtsi2sd %eax, %xmm0
divsd 0x78723(%rip), %xmm0    # 0xf44f0
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x789af(%rip), %rcx     # 0xf4790
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x8(%rsp)
testl %eax, %eax
jle 0x7beba
movq 0x50(%rsp), %rcx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
movq 0x58(%rsp), %rdx
leal (%rax,%rdx), %r12d
movq 0x40(%rsp), %rcx
movl %ecx, %r15d
shrl $0x1f, %r15d
addl %ecx, %r15d
sarl %r15d
addl 0x48(%rsp), %r15d
movq 0x8(%rsp), %rbx
movl %ebx, %ecx
shrl %ecx
subl %ecx, %r15d
movslq 0x38(%rsp), %rcx
movq %rcx, 0x30(%rsp)
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
leal (%rax,%rdx), %r13d
incl %r13d
movq %r15, %rbp
shlq $0x20, %rbp
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
movzbl %al, %eax
leal (%r12,%rax), %ecx
movl %ecx, (%rsp)
movl %r15d, 0x4(%rsp)
addl %r13d, %eax
addq %rbp, %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movl $0x0, 0x18(%rsp)
movq 0x28(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
leaq 0x18(%rsp), %rcx
callq 0x58300
incl %r13d
decl %r12d
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %rbp
incl %r15d
decq %rbx
jne 0x7be50
movq 0x8(%rsp), %rsi
testl %esi, %esi
movq 0x80(%rsp), %r12
jle 0x7bf8a
movq 0x50(%rsp), %rax
movl %eax, %r15d
shrl $0x1f, %r15d
addl %eax, %r15d
sarl %r15d
movq 0x40(%rsp), %rcx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
subl %eax, %r12d
leal 0x1(%rsi), %eax
shrl %eax
subl %eax, %r12d
movslq 0x38(%rsp), %rax
movq %rax, 0x30(%rsp)
movl %esi, %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
addl 0x58(%rsp), %r15d
leal (%r15,%rsi), %ebx
movq %r12, %r13
shlq $0x20, %r13
subl %esi, %r15d
incl %r15d
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
movzbl %al, %eax
leal (%r15,%rax), %ecx
movl %ecx, (%rsp)
movl %r12d, 0x4(%rsp)
addl %ebx, %eax
addq %r13, %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movl $0x0, 0x18(%rsp)
movq 0x28(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
leaq 0x18(%rsp), %rcx
callq 0x58300
decl %ebx
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r13
incl %r12d
incl %r15d
decq %rbp
jne 0x7bf22
movq 0x28(%rsp), %rdi
callq 0x58780
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq