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

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

				surface->Box(frame, Setup::BackgroundColor, Rect::Filled);
				surface->SetText(text, frame + Point(4 * surface->GetSurfaceDPI() / 96.0, Math::Ceil(Float(frame.GetHeight() - font.GetScaledTextSizeY()) / 2) - 1) - Size(8, 2) * surface->GetSurfaceDPI() / 96.0, font);
			}

			break;
	};

	Int	 occupied_right	= 5;
	Int	 occupied_left	= 5;

#ifdef __APPLE__
	/* Check if macOS version is lower than 10.7 (Darwin 11.0) and
	 * occupy ten pixels for the handle at the right in that case.
	 */
	Int	 resizeGripSize = (Backends::BackendCocoa::IsOSXVersionAtLeast(10, 7, 0) ? 0 : 10);

	occupied_right += resizeGripSize;

	if (resizeGripSize > 0)
	{
		Surface	*surface = GetDrawSurface();
		Rect	 frame	 = Rect(GetRealPosition(), GetRealSize());

		surface->Line(Point(frame.right -  2, frame.bottom - 1), Point(frame.right, frame.bottom -  3), Color(116, 116, 116));
		surface->Line(Point(frame.right -  3, frame.bottom - 1), Point(frame.right, frame.bottom -  4), Color(184, 184, 184));

		surface->Line(Point(frame.right -  6, frame.bottom - 1), Point(frame.right, frame.bottom -  7), Color(116, 116, 116));
		surface->Line(Point(frame.right -  7, frame.bottom - 1), Point(frame.right, frame.bottom -  8), Color(184, 184, 184));

		surface->Line(Point(frame.right - 10, frame.bottom - 1), Point(frame.right, frame.bottom - 11), Color(116, 116, 116));
		surface->Line(Point(frame.right - 11, frame.bottom - 1), Point(frame.right, frame.bottom - 12), Color(184, 184, 184));
	}
#endif

	for (Int i = 0; i < GetNOfObjects(); i++)
	{
		Widget	*object = GetNthObject(i);

		if (object->GetOrientation() == OR_UPPERRIGHT)
		{
			object->SetPosition(Point(occupied_right + object->GetWidth(), (GetHeight() - object->GetHeight()) / 2));

			occupied_right += object->GetWidth() + 5;
		}
		else if (object->GetOrientation() == OR_UPPERLEFT)
		{
			object->SetPosition(Point(occupied_left, (GetHeight() - object->GetHeight()) / 2));

			occupied_left += object->GetWidth() + 5;
		}
	}

	return Widget::Paint(message);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %ebx
movq %rdi, %r14
movq (%rdi), %rax
callq *0x88(%rax)
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb %cl, %cl
je 0x7db2d
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
movl %eax, %ecx
xorl %eax, %eax
testb %cl, %cl
je 0x7db2d
movl %ebx, 0xc(%rsp)
testl %ebx, %ebx
jne 0x7da32
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, %r15
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %r13
movq %rax, %rbx
shrq $0x20, %rbx
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
leal (%rax,%r13), %ecx
shrq $0x20, %rax
leaq 0x10(%rsp), %r12
movl %r13d, (%r12)
movl %ebx, 0x4(%r12)
movl %ecx, 0x8(%r12)
addl %ebx, %eax
movl %eax, 0xc(%r12)
movq 0xef732(%rip), %rax     # 0x16cfa8
movl (%rax), %ecx
leaq 0x38(%rsp), %r8
movq $0x0, (%r8)
movq 0xeec45(%rip), %rdx     # 0x16c4d0
movq %r15, 0x20(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x57930
leaq 0xf0(%r14), %rax
movq %rax, 0x30(%rsp)
movq %r15, %rdi
callq 0x58930
cwtl
shll $0x2, %eax
cvtsi2sd %eax, %xmm0
divsd 0x76c31(%rip), %xmm0    # 0xf44f0
cvttsd2si %xmm0, %ebp
movl 0x4(%r12), %ebx
movl 0xc(%r12), %r15d
leaq 0x140(%r14), %rdi
movq %rdi, 0x28(%rsp)
movq 0xef4d8(%rip), %rsi     # 0x16cdb8
callq 0x57680
addl %ebx, %eax
subl %eax, %r15d
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movsd 0x76a9e(%rip), %xmm1    # 0xf4398
mulsd %xmm1, %xmm0
callq 0x56cb0
movq %rax, %r13
decl %r13d
movl (%r12), %ebx
addl %ebp, %ebx
movl 0x4(%r12), %r15d
addl %r13d, %r15d
shlq $0x20, %r15
addl 0x8(%r12), %ebp
addl 0xc(%r12), %r13d
movq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0x58930
cwtl
cvtsi2sd %eax, %xmm2
movsd 0x766c9(%rip), %xmm3    # 0xf4008
mulsd %xmm2, %xmm3
xorpd %xmm1, %xmm1
movapd %xmm3, %xmm4
cmpltsd %xmm1, %xmm4
movsd 0x76a38(%rip), %xmm0    # 0xf4390
movapd %xmm4, %xmm5
andpd %xmm0, %xmm5
movsd 0x76a30(%rip), %xmm6    # 0xf4398
andnpd %xmm6, %xmm4
orpd %xmm5, %xmm4
addsd %xmm3, %xmm4
cvttsd2si %xmm4, %rax
addsd %xmm2, %xmm2
movapd %xmm2, %xmm3
cmpltsd %xmm1, %xmm3
movapd %xmm3, %xmm4
andpd %xmm0, %xmm4
andnpd %xmm6, %xmm3
orpd %xmm4, %xmm3
addsd %xmm2, %xmm3
cvttsd2si %xmm3, %rcx
xorps %xmm2, %xmm2
cvtsi2sd %eax, %xmm2
movsd 0x76b42(%rip), %xmm5    # 0xf44f0
divsd %xmm5, %xmm2
movapd %xmm2, %xmm3
cmpltsd %xmm1, %xmm3
movapd %xmm3, %xmm4
andpd %xmm0, %xmm4
andnpd %xmm6, %xmm3
orpd %xmm4, %xmm3
addsd %xmm2, %xmm3
cvttsd2si %xmm3, %rax
xorps %xmm2, %xmm2
cvtsi2sd %ecx, %xmm2
divsd %xmm5, %xmm2
movapd %xmm2, %xmm3
cmpltsd %xmm1, %xmm3
andpd %xmm3, %xmm0
andnpd %xmm6, %xmm3
orpd %xmm0, %xmm3
addsd %xmm2, %xmm3
cvttsd2si %xmm3, %rcx
subl %eax, %ebp
subl %ecx, %r13d
orq %r15, %rbx
shlq $0x20, %r13
orq %r13, %rbp
leaq 0x38(%rsp), %rax
movq %rbx, (%rax)
movq %rbp, 0x8(%rax)
leaq 0x38(%rsp), %rdx
movq %r12, %rdi
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rcx
xorl %r8d, %r8d
callq 0x57b80
cmpl $0x0, 0x40(%r14)
jle 0x7db21
leaq 0x38(%r14), %r15
movl $0x5, %ebx
xorl %ebp, %ebp
movl $0x5, %r12d
movq %r15, %rdi
movl %ebp, %esi
callq 0x5b0a4
movq (%rax), %r13
movq (%r13), %rax
movq %r13, %rdi
callq *0x128(%rax)
cmpl $0x24, %eax
jne 0x7dabf
leaq 0xb0(%r13), %rdx
movl 0xb0(%r13), %eax
movl 0xb4(%r14), %ecx
subl 0xb4(%r13), %ecx
addl %r12d, %eax
movl %ecx, %esi
shrl $0x1f, %esi
addl %ecx, %esi
sarl %esi
movl %eax, 0x10(%rsp)
movl %esi, 0x14(%rsp)
movq (%r13), %rax
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
callq *0x150(%rax)
movl 0xb0(%r13), %eax
addl %eax, %r12d
addl $0x5, %r12d
jmp 0x7db15
movq (%r13), %rax
movq %r13, %rdi
callq *0x128(%rax)
cmpl $0x14, %eax
jne 0x7db15
movl 0xb4(%r14), %eax
subl 0xb4(%r13), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movl %ebx, 0x10(%rsp)
movl %ecx, 0x14(%rsp)
leaq 0xb0(%r13), %rdx
movq (%r13), %rax
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
callq *0x150(%rax)
movl 0xb0(%r13), %eax
addl %eax, %ebx
addl $0x5, %ebx
incl %ebp
cmpl 0x40(%r14), %ebp
jl 0x7da4e
movq %r14, %rdi
movl 0xc(%rsp), %esi
callq 0x567d0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq