// File: /workspace/github_c_makefile_star2_O3/enzo1982[P]smooth/classes/gui/widgets/multi/menu/micromenu.cpp
// Function: smooth::GUI::MicroMenu::Paint(int)
S::Int S::GUI::MicroMenu::Paint(Int message)
{
	if (!IsRegistered()) return Error();
	if (!IsVisible())    return Success();

	Surface	*surface = GetDrawSurface();
	Rect	 frame	 = Rect(GetRealPosition(), GetRealSize());

	switch (message)
	{
		case SP_PAINT:
			surface->StartPaint(frame);

			if (IsBackgroundColorSet()) surface->Box(frame, GetBackgroundColor(), Rect::Filled);

			surface->Frame(frame, 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(frame.left + (frame.GetWidth() - size) / 2 + i, frame.top + frame.GetHeight() / 2 - size + 1 + i);
					Point	 lineEnd   = lineStart + Point(0, 2 * (size - i) - 1);

					if (IsActive())	surface->Line(lineStart, lineEnd, Setup::TextColor);
					else		surface->Line(lineStart, lineEnd, Setup::InactiveTextColor);
				}
			}
			else if (subtype == OR_VERT)
			{
				Int	 size = Math::Round(3 * surface->GetSurfaceDPI() / 96.0);

				for (Int i = 0; i < size; i++)
				{
					Point	 lineStart = Point(frame.left + frame.GetWidth() / 2 - size + 1 + (IsRightToLeft() ? 1 : 0) + i, frame.top + (frame.GetHeight() - size) / 2 + i);
					Point	 lineEnd   = lineStart + Point(2 * (size - i) - 1, 0);

					if (IsActive())	surface->Line(lineStart, lineEnd, Setup::TextColor);
					else		surface->Line(lineStart, lineEnd, Setup::InactiveTextColor);
				}
			}

			surface->EndPaint();

			break;
		case SP_MOUSEOUT:
			if (hotspot->IsActive()) surface->Frame(frame, FRAME_UP);

			break;
	}

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebp
movq %rdi, %r14
movq (%rdi), %rax
callq *0x88(%rax)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb %al, %al
je 0x8b45f
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
xorl %ebx, %ebx
testb %al, %al
je 0x8b45f
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rax, %r13
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %r12
movq %rax, %r15
shrq $0x20, %r15
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
leal (%rax,%r12), %ecx
shrq $0x20, %rax
movl %r12d, (%rsp)
movl %r15d, 0x4(%rsp)
movl %ecx, 0x8(%rsp)
addl %r15d, %eax
movl %eax, 0xc(%rsp)
cmpl $0x3, %ebp
je 0x8b327
testl %ebp, %ebp
jne 0x8b45f
movq %rsp, %rsi
movq %r13, %rdi
callq 0x55160
movq (%r14), %rax
movq %r14, %rdi
callq *0x148(%rax)
testb %al, %al
je 0x8b21e
movq (%r14), %rax
movq %r14, %rdi
callq *0x140(%rax)
movq 0xe0da6(%rip), %rcx     # 0x16bfa8
movl (%rcx), %ecx
leaq 0x10(%rsp), %r8
movq $0x0, (%r8)
movq %rsp, %rsi
movq %r13, %rdi
movq %rax, %rdx
callq 0x57930
movq %rsp, %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x57890
movzwl 0x1a0(%r14), %eax
cmpl $0x2, %eax
movq %r13, 0x18(%rsp)
je 0x8b351
cmpl $0x1, %eax
jne 0x8b455
movq 0x18(%rsp), %rdi
callq 0x58930
cwtl
leal (%rax,%rax,2), %eax
cvtsi2sd %eax, %xmm0
divsd 0x68454(%rip), %xmm0    # 0xf36b8
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x6a8c0(%rip), %rcx     # 0xf5b38
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rbp
testl %ebp, %ebp
jle 0x8b455
movl $0x1, %r15d
subl %ebp, %r15d
xorl %r12d, %r12d
movl %ebp, %r13d
movl 0x8(%rsp), %ecx
movl (%rsp), %eax
movl 0x4(%rsp), %edx
subl %eax, %ecx
subl %ebp, %ecx
movl %ecx, %esi
shrl $0x1f, %esi
addl %ecx, %esi
sarl %esi
addl %r12d, %eax
addl %esi, %eax
movl 0xc(%rsp), %ecx
subl %edx, %ecx
movl %ecx, %esi
shrl $0x1f, %esi
addl %ecx, %esi
sarl %esi
addl %edx, %esi
leal (%r15,%r12), %ecx
addl %esi, %ecx
movl %eax, 0x10(%rsp)
movl %ecx, 0x14(%rsp)
addl %r13d, %esi
shlq $0x20, %rsi
orq %rsi, %rax
movq %rax, 0x20(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
movq 0xe0659(%rip), %rcx     # 0x16b950
testb %al, %al
je 0x8b302
movq 0xe06e6(%rip), %rcx     # 0x16b9e8
movq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x58300
incl %r12d
decl %r13d
jne 0x8b299
jmp 0x8b455
movq 0x688(%r14), %rdi
movq (%rdi), %rax
callq *0x98(%rax)
testb %al, %al
je 0x8b45f
movq %rsp, %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x57890
jmp 0x8b45f
movq %r13, %rdi
callq 0x58930
cwtl
leal (%rax,%rax,2), %eax
cvtsi2sd %eax, %xmm0
divsd 0x6834f(%rip), %xmm0    # 0xf36b8
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm0, %xmm1
seta %al
leaq 0x6a7bb(%rip), %rcx     # 0xf5b38
addsd (%rcx,%rax,8), %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x28(%rsp)
testl %ecx, %ecx
jle 0x8b455
movl $0x1, %ecx
movq 0x28(%rsp), %rax
subl %eax, %ecx
movq %rcx, 0x30(%rsp)
xorl %r13d, %r13d
movl %eax, %r15d
movl (%rsp), %ebp
movl 0x8(%rsp), %eax
subl %ebp, %eax
movl %eax, %r12d
shrl $0x1f, %r12d
addl %eax, %r12d
sarl %r12d
movq (%r14), %rax
movq %r14, %rdi
callq *0x160(%rax)
movzbl %al, %eax
addl %ebp, %r12d
addl %eax, %r12d
movq 0x30(%rsp), %rax
addl %r13d, %eax
addl %r12d, %eax
movl 0x4(%rsp), %ecx
movl 0xc(%rsp), %edx
movq 0x28(%rsp), %rsi
addl %ecx, %esi
subl %esi, %edx
movl %edx, %esi
shrl $0x1f, %esi
addl %edx, %esi
sarl %esi
addl %r13d, %ecx
addl %esi, %ecx
movl %eax, 0x10(%rsp)
movl %ecx, 0x14(%rsp)
addl %r15d, %r12d
shlq $0x20, %rcx
orq %rcx, %r12
movq %r12, 0x20(%rsp)
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
movq 0xe0526(%rip), %rcx     # 0x16b950
testb %al, %al
je 0x8b435
movq 0xe05b3(%rip), %rcx     # 0x16b9e8
movq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x58300
incl %r13d
decl %r15d
jne 0x8b3ab
movq 0x18(%rsp), %rdi
callq 0x58780
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq