// File: /workspace/github_c_makefile_star2_O2/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)
testb %al, %al
je 0x7a1c6
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
movl %eax, %ecx
xorl %eax, %eax
testb %cl, %cl
je 0x7a6ad
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, 0x18(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %r15
movq %rax, %r12
shrq $0x20, %r12
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
movq %rax, %r13
movl %r13d, %ecx
shrq $0x20, %rax
movq %rax, 0x10(%rsp)
movzwl 0x1a0(%r14), %eax
cmpl $0x2, %eax
movq %rcx, 0x20(%rsp)
je 0x7a1ce
cmpl $0x1, %eax
jne 0x7a1dd
cmpl $0x38, 0xb0(%r14)
jl 0x7a1d8
movl 0xb4(%r14), %ebx
jmp 0x7a1e4
pushq $-0x1
popq %rax
jmp 0x7a6ad
cmpl $0x38, 0xb4(%r14)
jge 0x7a1dd
pushq $0xa
popq %rbx
jmp 0x7a1e4
movl 0xb0(%r14), %ebx
movq 0x18(%rsp), %rdi
callq 0x59c60
cwtl
imull %ebx, %eax
cvtsi2sd %eax, %xmm0
divsd 0x69312(%rip), %xmm0    # 0xe3510
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x6959e(%rip), %rcx     # 0xe37b0
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rbx
movzwl 0x1a0(%r14), %eax
subl %ebx, %r13d
movq 0x10(%rsp), %rsi
movl %esi, %ecx
subl %ebx, %ecx
xorl %edx, %edx
cmpw $0x2, %ax
cmovnel %edx, %ecx
cmpw $0x1, %ax
cmovnel %edx, %r13d
movq 0x20(%rsp), %rax
cmovel %ebx, %eax
movl %ebx, %edx
cmovel %esi, %edx
leal (%r15,%r13), %esi
addl %r12d, %ecx
movl %esi, 0x68(%rsp)
movl %ecx, 0x6c(%rsp)
addl %eax, %esi
movl %esi, 0x70(%rsp)
addl %edx, %ecx
movl %ecx, 0x74(%rsp)
movl %r15d, 0x78(%rsp)
movl %r12d, 0x7c(%rsp)
addl %r15d, %eax
movl %eax, 0x80(%rsp)
addl %r12d, %edx
movl %edx, 0x84(%rsp)
movq 0xe775a(%rip), %rax     # 0x1619e8
movq 0x8(%rax), %r13
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
testb %al, %al
jne 0x7a2ad
movq 0xe76a7(%rip), %rax     # 0x161950
movq 0x8(%rax), %r13
testl %ebp, %ebp
jne 0x7a6ab
movq %r13, 0x60(%rsp)
movq %rbx, 0x48(%rsp)
movq %r15, %rax
leaq 0x30(%rsp), %r15
movl %eax, (%r15)
movl %r12d, 0x4(%r15)
movq %rax, 0x50(%rsp)
movq 0x20(%rsp), %rcx
addl %ecx, %eax
movl %eax, 0x58(%rsp)
movl %eax, 0x8(%r15)
movq %r12, 0x40(%rsp)
movq 0x10(%rsp), %rax
addl %r12d, %eax
movl %eax, 0x5c(%rsp)
movl %eax, 0xc(%r15)
movq 0x18(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x56160
movq %r14, %rdi
callq 0x5a528
movq 0xe7c92(%rip), %rbx     # 0x161fa8
movl (%rbx), %ecx
andq $0x0, (%r15)
movq 0xe71ad(%rip), %r15     # 0x1614d0
leaq 0x68(%rsp), %rsi
leaq 0x30(%rsp), %rbp
movq %r12, %rdi
movq %r15, %rdx
movq %rbp, %r8
callq 0x58b80
movl (%rbx), %ecx
andq $0x0, (%rbp)
leaq 0x78(%rsp), %rbx
leaq 0x30(%rsp), %r8
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x58b80
xorl %r13d, %r13d
movq %r12, %rdi
leaq 0x68(%rsp), %rsi
xorl %edx, %edx
callq 0x58ad0
movq %r12, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x58ad0
movzwl 0x1a0(%r14), %eax
cmpl $0x2, %eax
je 0x7a50c
cmpl $0x1, %eax
jne 0x7a6a1
movq 0x18(%rsp), %rdi
callq 0x59c60
cwtl
leal (%rax,%rax,2), %eax
cvtsi2sd %eax, %xmm0
divsd 0x69163(%rip), %xmm0    # 0xe3510
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x693ef(%rip), %rcx     # 0xe37b0
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rdi
pushq $0x2
popq %rsi
movq 0x48(%rsp), %rax
cltd
idivl %esi
movl %eax, %ecx
pushq $-0x2
popq %r8
movl %edi, %eax
cltd
idivl %r8d
movl %eax, %r13d
addl 0x50(%rsp), %r13d
addl %ecx, %r13d
movq 0x10(%rsp), %rax
cltd
idivl %esi
movl %eax, %r14d
movq 0x40(%rsp), %rax
leal (%r14,%rax), %r15d
movslq 0x60(%rsp), %rcx
movq %rcx, 0x10(%rsp)
xorl %r12d, %r12d
testl %edi, %edi
movq %rdi, 0x20(%rsp)
cmovgl %edi, %r12d
leal (%r14,%rax), %ebp
incl %ebp
movq %r12, %rbx
subq $0x1, %rbx
jb 0x7a476
movl %r13d, 0x8(%rsp)
movl %r15d, 0xc(%rsp)
movq %rbp, %rax
shlq $0x20, %rax
movl %r13d, %ecx
orq %rax, %rcx
movq %rcx, 0x28(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x38(%rsp)
andl $0x0, 0x30(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x30(%rsp), %rcx
callq 0x595b0
incl %ebp
incl %r13d
decl %r15d
jmp 0x7a422
movq 0x48(%rsp), %rax
cltd
pushq $-0x2
popq %rdi
idivl %edi
movl %eax, %ecx
addl 0x58(%rsp), %ecx
movq 0x20(%rsp), %rsi
leal 0x1(%rsi), %eax
cltd
idivl %edi
movl %eax, %r15d
addl %ecx, %r15d
movq 0x40(%rsp), %rax
leal (%r14,%rax), %r13d
subl %esi, %r13d
incl %r13d
addl %esi, %r14d
addl %eax, %r14d
leaq 0x8(%rsp), %rbp
leaq 0x30(%rsp), %rbx
subq $0x1, %r12
jb 0x7a6a1
movl %r15d, 0x8(%rsp)
movl %r13d, 0xc(%rsp)
movq %r14, %rax
shlq $0x20, %rax
movl %r15d, %ecx
orq %rax, %rcx
movq %rcx, 0x28(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x38(%rsp)
andl $0x0, 0x30(%rsp)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rcx
callq 0x595b0
incl %r13d
decl %r14d
incl %r15d
jmp 0x7a4b7
movq 0x18(%rsp), %rdi
callq 0x59c60
cwtl
leal (%rax,%rax,2), %eax
cvtsi2sd %eax, %xmm0
divsd 0x68fea(%rip), %xmm0    # 0xe3510
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x69276(%rip), %rcx     # 0xe37b0
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %r8
pushq $0x2
popq %rcx
movq 0x20(%rsp), %rax
cltd
idivl %ecx
movl %eax, %edi
movq 0x50(%rsp), %rsi
leal (%rdi,%rsi), %ebx
movq 0x48(%rsp), %rax
cltd
idivl %ecx
movl %eax, %ecx
pushq $-0x2
popq %r9
movl %r8d, %eax
cltd
idivl %r9d
movq 0x40(%rsp), %r12
addl %eax, %r12d
addl %ecx, %r12d
movslq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
testl %r8d, %r8d
movq %r8, 0x40(%rsp)
cmovgl %r8d, %r13d
movq %rdi, 0x20(%rsp)
leal (%rdi,%rsi), %r15d
incl %r15d
movq %r13, %rbp
subq $0x1, %rbp
jb 0x7a603
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
movzbl %al, %eax
leal (%rbx,%rax), %ecx
movl %ecx, 0x8(%rsp)
movl %r12d, 0xc(%rsp)
addl %r15d, %eax
movq %r12, %rcx
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x28(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x38(%rsp)
andl $0x0, 0x30(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x30(%rsp), %rcx
callq 0x595b0
incl %r15d
incl %r12d
decl %ebx
jmp 0x7a59e
movq 0x48(%rsp), %rax
cltd
pushq $-0x2
popq %rdi
idivl %edi
movl %eax, %ecx
addl 0x5c(%rsp), %ecx
movq 0x40(%rsp), %rsi
leal 0x1(%rsi), %eax
cltd
idivl %edi
movl %eax, %r12d
addl %ecx, %r12d
movq 0x20(%rsp), %r15
addl 0x50(%rsp), %r15d
leal (%r15,%rsi), %ebx
subl %esi, %r15d
incl %r15d
leaq 0x8(%rsp), %rbp
subq $0x1, %r13
jb 0x7a6a1
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
movzbl %al, %eax
leal (%r15,%rax), %ecx
movl %ecx, 0x8(%rsp)
movl %r12d, 0xc(%rsp)
addl %ebx, %eax
movq %r12, %rcx
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x28(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x38(%rsp)
andl $0x0, 0x30(%rsp)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
leaq 0x28(%rsp), %rdx
leaq 0x30(%rsp), %rcx
callq 0x595b0
incl %r12d
decl %ebx
incl %r15d
jmp 0x7a63e
movq 0x18(%rsp), %rdi
callq 0x59a80
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop