// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/classes/gui/widgets/basic/tabwidget.cpp
// Function: smooth::GUI::TabWidget::Process(int, int, int)
S::Int S::GUI::TabWidget::Process(Int message, Int wParam, Int lParam)
{
	if (!IsRegistered())		 return Error();
	if (!IsActive() || !IsVisible()) return Success();

	switch (message)
	{
		case SM_LBUTTONDOWN:
			{
				Window	*window	 = container->GetContainerWindow();
				Surface	*surface = GetDrawSurface();
				Point	 realPos = GetRealPosition();
				Int	 offset	 = 19 * surface->GetSurfaceDPI() / 96;
				Rect	 frame	 = Rect(Point(0, realPos.y + 1), Size(realPos.x, offset - 1));

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

					const Bitmap	&bitmap = bitmaps.Get(widget->GetHandle());
					Size		 sSize	= bitmap == NIL ? Size() : Size(bitmap.GetSize().cx / (bitmap.GetSize().cy / 15.0) , 15) * surface->GetSurfaceDPI() / 96;

					frame.left  = frame.right + 1;
					frame.right = frame.left + widget->GetScaledTextWidth() + sSize.cx + 6 + Int(widget->GetText() != NIL ? 6 : 0);

					if (!widget->IsVisible() && window->IsMouseOn(frame)) { SelectTab(widget); break; }
				}
			}

			break;
	}

	return Widget::Process(message, wParam, lParam);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, %ebp
movl %edx, %r14d
movl %esi, %r12d
movq %rdi, %r15
movq (%rdi), %rax
callq *0x88(%rax)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb %al, %al
je 0x7e93e
movq (%r15), %rax
movq %r15, %rdi
callq *0x98(%rax)
xorl %ebx, %ebx
testb %al, %al
je 0x7e93e
movq (%r15), %rax
movq %r15, %rdi
callq *0x90(%rax)
testb %al, %al
je 0x7e93e
cmpl $0x7801, %r12d          # imm = 0x7801
jne 0x7e92c
movl %r12d, 0x4(%rsp)
movl %r14d, 0x8(%rsp)
movl %ebp, 0xc(%rsp)
movq 0x190(%r15), %rdi
callq 0x559e0
movq %rax, 0x40(%rsp)
movq (%r15), %rax
movq %r15, %rdi
callq *0x40(%rax)
movq %rax, %r12
movq (%r15), %rax
movq %r15, %rdi
callq *0x48(%rax)
movq %rax, %rbx
movq %rax, %r14
shrq $0x20, %r14
movq %r12, 0x38(%rsp)
movq %r12, %rdi
callq 0x58930
cwtl
leal (%rax,%rax,8), %ecx
leal (%rax,%rcx,2), %eax
cltq
imulq $0x2aaaaaab, %rax, %rax # imm = 0x2AAAAAAB
movq %rax, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rax
sarl $0x4, %eax
leal 0x1(%r14), %edx
movl $0x0, 0x10(%rsp)
movl %edx, 0x14(%rsp)
movl %ebx, 0x18(%rsp)
addl %r14d, %ecx
addl %eax, %ecx
movl %ecx, 0x1c(%rsp)
cmpl $0x0, 0x40(%r15)
jle 0x7e91e
leaq 0x38(%r15), %rax
movq %rax, 0x50(%rsp)
leaq 0x5c0(%r15), %rax
movq %rax, 0x48(%rsp)
xorl %ebx, %ebx
movq 0x50(%rsp), %rdi
movl %ebx, %esi
callq 0x5b0a4
movq (%rax), %rbp
movl 0x8(%rbp), %esi
movq 0x48(%rsp), %rdi
callq 0x7f230
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
callq 0x57e30
movl $0x6, %r12d
testb %al, %al
jne 0x7e895
movq %r14, %rdi
callq 0x58410
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
movapd %xmm0, 0x20(%rsp)
movq %r14, %rdi
callq 0x58410
xorps %xmm0, %xmm0
cvtsi2sdl 0x4(%rax), %xmm0
divsd 0x78976(%rip), %xmm0    # 0xf7170
movapd 0x20(%rsp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
movq 0x38(%rsp), %rdi
callq 0x58930
cwtl
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
cvttpd2dq 0x20(%rsp), %xmm1
cvtdq2pd %xmm1, %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, %xmm0
xorpd %xmm3, %xmm3
cmpltsd %xmm3, %xmm0
movapd %xmm0, %xmm2
movsd 0x75b4d(%rip), %xmm4    # 0xf4390
andpd %xmm4, %xmm2
movsd 0x75b49(%rip), %xmm5    # 0xf4398
andnpd %xmm5, %xmm0
orpd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x75c81(%rip), %xmm0    # 0xf44f0
movapd %xmm0, %xmm1
cmpltsd %xmm3, %xmm1
movapd %xmm1, %xmm2
andpd %xmm4, %xmm2
andnpd %xmm5, %xmm1
orpd %xmm2, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %r12
addl $0x6, %r12d
movl 0x18(%rsp), %r13d
leal 0x1(%r13), %eax
movl %eax, 0x10(%rsp)
movq (%rbp), %rax
movq %rbp, %rdi
callq *0xf8(%rax)
movl %eax, %r14d
movq (%rbp), %rax
movq %rbp, %rdi
callq *0xa8(%rax)
movq %rax, %rdi
xorl %esi, %esi
callq 0x56bd0
leal (%r12,%r13), %ecx
incl %ecx
leal (%rcx,%r14), %edx
testb %al, %al
leal 0x6(%r14,%rcx), %eax
cmovel %edx, %eax
movl %eax, 0x18(%rsp)
movq (%rbp), %rax
movq %rbp, %rdi
callq *0x90(%rax)
testb %al, %al
jne 0x7e905
movq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x578a0
testb %al, %al
jne 0x7e913
incl %ebx
cmpl 0x40(%r15), %ebx
jl 0x7e796
jmp 0x7e91e
movq %r15, %rdi
movq %rbp, %rsi
callq 0x56450
movl 0xc(%rsp), %ebp
movl 0x8(%rsp), %r14d
movl 0x4(%rsp), %r12d
movq %r15, %rdi
movl %r12d, %esi
movl %r14d, %edx
movl %ebp, %ecx
callq 0x58220
movl %eax, %ebx
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop