// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %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 0x7d759
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
movl %eax, %ecx
xorl %eax, %eax
testb %cl, %cl
je 0x7d759
movl %ebx, 0x4(%rsp)
testl %ebx, %ebx
jne 0x7d65e
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, %r15
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %r12
movq %rax, %rbx
shrq $0x20, %rbx
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
leal (%rax,%r12), %ecx
shrq $0x20, %rax
leaq 0x8(%rsp), %rbp
movl %r12d, (%rbp)
movl %ebx, 0x4(%rbp)
movl %ecx, 0x8(%rbp)
addl %ebx, %eax
movl %eax, 0xc(%rbp)
movq 0xeead4(%rip), %rax     # 0x16bfa8
movl (%rax), %ecx
leaq 0x28(%rsp), %r8
movq $0x0, (%r8)
movq 0xedfe7(%rip), %rdx     # 0x16b4d0
movq %r15, 0x18(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0x57930
movq %r15, %rdi
callq 0x58930
cwtl
shll $0x2, %eax
cvtsi2sd %eax, %xmm0
divsd 0x761a7(%rip), %xmm0    # 0xf36b8
cvttsd2si %xmm0, %r12d
movl 0x4(%rbp), %ebx
movl 0xc(%rbp), %r15d
leaq 0x140(%r14), %rdi
movq 0xee88d(%rip), %rsi     # 0x16bdb8
movq %rdi, 0x20(%rsp)
callq 0x57680
addl %ebx, %eax
subl %eax, %r15d
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
mulsd 0x75e4e(%rip), %xmm0    # 0xf3398
callq 0x56cb0
movq %rax, %r13
decl %r13d
movl (%rbp), %r15d
addl %r12d, %r15d
movl 0x4(%rbp), %ebx
addl %r13d, %ebx
addl 0x8(%rbp), %r12d
addl 0xc(%rbp), %r13d
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
callq 0x58930
cwtl
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd 0x78ce5(%rip), %xmm0    # 0xf6270
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm2
cmpltpd %xmm1, %xmm2
movapd %xmm2, %xmm3
andnpd 0x75f8c(%rip), %xmm3    # 0xf3530
andpd 0x75f94(%rip), %xmm2    # 0xf3540
orpd %xmm3, %xmm2
addpd %xmm0, %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %xmm0
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
cvttsd2si %xmm2, %rax
movq %rax, %xmm2
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
cvtdq2pd %xmm0, %xmm0
divpd 0x75f44(%rip), %xmm0    # 0xf3520
movapd %xmm0, %xmm2
cmpltpd %xmm1, %xmm2
movmskpd %xmm2, %eax
movsd 0x75d9f(%rip), %xmm1    # 0xf3390
movapd %xmm1, %xmm2
testb $0x2, %al
jne 0x7d601
movsd 0x75d97(%rip), %xmm2    # 0xf3398
leaq 0xf0(%r14), %rsi
shlq $0x20, %rbx
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm2, %xmm3
cvttsd2si %xmm3, %rcx
testb $0x1, %al
jne 0x7d629
movsd 0x75d6f(%rip), %xmm1    # 0xf3398
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
subl %ecx, %r12d
subl %eax, %r13d
orq %r15, %rbx
shlq $0x20, %r13
orq %r13, %r12
leaq 0x28(%rsp), %rdx
movq %rbx, (%rdx)
movq %r12, 0x8(%rdx)
movq %rbp, %rdi
movq 0x20(%rsp), %rcx
xorl %r8d, %r8d
callq 0x57b80
cmpl $0x0, 0x40(%r14)
jle 0x7d74d
leaq 0x38(%r14), %r15
movl $0x5, %ebx
xorl %ebp, %ebp
movl $0x5, %r12d
movq %r15, %rdi
movl %ebp, %esi
callq 0x5b074
movq (%rax), %r13
movq (%r13), %rax
movq %r13, %rdi
callq *0x128(%rax)
cmpl $0x24, %eax
jne 0x7d6eb
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, 0x8(%rsp)
movl %esi, 0xc(%rsp)
movq (%r13), %rax
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq *0x150(%rax)
movl 0xb0(%r13), %eax
addl %eax, %r12d
addl $0x5, %r12d
jmp 0x7d741
movq (%r13), %rax
movq %r13, %rdi
callq *0x128(%rax)
cmpl $0x14, %eax
jne 0x7d741
movl 0xb4(%r14), %eax
subl 0xb4(%r13), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movl %ebx, 0x8(%rsp)
movl %ecx, 0xc(%rsp)
leaq 0xb0(%r13), %rdx
movq (%r13), %rax
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq *0x150(%rax)
movl 0xb0(%r13), %eax
addl %eax, %ebx
addl $0x5, %ebx
incl %ebp
cmpl 0x40(%r14), %ebp
jl 0x7d67a
movq %r14, %rdi
movl 0x4(%rsp), %esi
callq 0x567d0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq