// File: /workspace/github_c_makefile_star2_O2/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 $0x58, %rsp
movl %esi, %ebx
movq %rdi, %r14
movq (%rdi), %rax
callq *0x88(%rax)
testb %al, %al
je 0x7bdf9
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
movl %eax, %ecx
xorl %eax, %eax
testb %cl, %cl
je 0x7be0a
movl %ebx, 0xc(%rsp)
testl %ebx, %ebx
jne 0x7bd10
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 0x10(%rsp), %r13
movl %r12d, (%r13)
movl %ebx, 0x4(%r13)
movl %ecx, 0x8(%r13)
addl %ebx, %eax
movl %eax, 0xc(%r13)
movq 0xe63ac(%rip), %rax     # 0x161fa8
movl (%rax), %ecx
leaq 0x30(%rsp), %r8
andq $0x0, (%r8)
movq 0xe58c2(%rip), %rdx     # 0x1614d0
movq %r15, %rdi
movq %r13, %rsi
callq 0x58b80
leaq 0xf0(%r14), %rax
movq %rax, 0x28(%rsp)
movq %r15, %rdi
callq 0x59c60
cwtl
shll $0x2, %eax
cvtsi2sd %eax, %xmm0
divsd 0x678d3(%rip), %xmm0    # 0xe3510
cvttsd2si %xmm0, %ebx
movl 0x4(%r13), %ebp
movl 0xc(%r13), %r12d
leaq 0x140(%r14), %rdi
movq %rdi, 0x20(%rsp)
movq 0xe615c(%rip), %rsi     # 0x161db8
callq 0x588a0
addl %ebp, %eax
subl %eax, %r12d
cvtsi2sd %r12d, %xmm0
mulsd 0x6770d(%rip), %xmm0    # 0xe3380
callq 0x57e30
decl %eax
leaq 0x50(%rsp), %rsi
movl %ebx, (%rsi)
movl %eax, 0x4(%rsi)
movq %r13, %rdi
callq 0x58930
movq %rax, %r13
movq %rdx, %r12
movabsq $0x200000008, %rax      # imm = 0x200000008
leaq 0x48(%rsp), %rbp
movq %rax, (%rbp)
movq %r15, %rdi
callq 0x59c60
cwtl
cvtsi2sd %eax, %xmm0
movq %rbp, %rdi
callq 0x57480
leaq 0x40(%rsp), %rdi
movq %rax, (%rdi)
movsd 0x67846(%rip), %xmm0    # 0xe3510
callq 0x59050
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
movl %r12d, %edx
subl %eax, %edx
andq %rcx, %rax
subq %rax, %r12
andq %rcx, %r12
orq %r12, %rdx
leaq 0x30(%rsp), %rax
movq %r13, (%rax)
movq %rdx, 0x8(%rax)
leaq 0x30(%rsp), %rdx
movq %r15, %rdi
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rcx
xorl %r8d, %r8d
callq 0x58df0
xorl %ebp, %ebp
pushq $0x5
popq %r13
leaq 0x10(%rsp), %r15
movl %r13d, %ebx
cmpl 0x40(%r14), %ebp
jge 0x7bdfe
movq %r14, %rdi
movl %ebp, %esi
callq 0x58c90
movq %rax, %r12
movq (%rax), %rax
movq %r12, %rdi
callq *0x128(%rax)
cmpl $0x24, %eax
jne 0x7bd9c
movq %r12, %rcx
addq $0xb0, %rcx
movl 0xb0(%r12), %esi
movl 0xb4(%r14), %eax
subl 0xb4(%r12), %eax
addl %r13d, %esi
cltd
pushq $0x2
popq %rdi
idivl %edi
movl %esi, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq (%r12), %rax
movq %r12, %rdi
movq %r15, %rsi
movq %rcx, %rdx
callq *0x150(%rax)
movl 0xb0(%r12), %eax
addl %eax, %r13d
addl $0x5, %r13d
jmp 0x7bdf2
movq (%r12), %rax
movq %r12, %rdi
callq *0x128(%rax)
cmpl $0x14, %eax
jne 0x7bdf2
movl 0xb4(%r14), %eax
subl 0xb4(%r12), %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movl %ebx, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq %r12, %rdx
addq $0xb0, %rdx
movq (%r12), %rax
movq %r12, %rdi
movq %r15, %rsi
callq *0x150(%rax)
movl 0xb0(%r12), %eax
addl %eax, %ebx
addl $0x5, %ebx
incl %ebp
jmp 0x7bd1e
pushq $-0x1
popq %rax
jmp 0x7be0a
movq %r14, %rdi
movl 0xc(%rsp), %esi
callq 0x57910
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop