// File: /workspace/github_c_makefile_star2_O2/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)
testb %al, %al
je 0x7c9d9
movq (%r15), %rax
movq %r15, %rdi
callq *0x98(%rax)
xorl %ebx, %ebx
testb %al, %al
je 0x7c9dc
movq (%r15), %rax
movq %r15, %rdi
callq *0x90(%rax)
testb %al, %al
je 0x7c9dc
cmpl $0x7801, %r12d          # imm = 0x7801
jne 0x7ca06
movl %r12d, 0xc(%rsp)
movl %r14d, 0x10(%rsp)
movl %ebp, 0x14(%rsp)
movq 0x190(%r15), %rdi
callq 0x56a50
movq %rax, 0x38(%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, 0x30(%rsp)
movq %r12, %rdi
callq 0x59c60
cwtl
imull $0x13, %eax, %eax
pushq $0x60
popq %rcx
cltd
idivl %ecx
leal 0x1(%r14), %ecx
leaq 0x20(%rsp), %rdx
andl $0x0, (%rdx)
movl %ecx, 0x4(%rdx)
movl %ebx, 0x8(%rdx)
addl %r14d, %eax
movl %eax, 0xc(%rdx)
leaq 0x5c0(%r15), %rax
movq %rax, 0x48(%rsp)
xorl %r13d, %r13d
cmpl 0x40(%r15), %r13d
jge 0x7c9f8
movq %r15, %rdi
movl %r13d, %esi
callq 0x58c90
movq %rax, %rbx
movl 0x8(%rax), %esi
movq 0x48(%rsp), %rdi
callq 0x7d23a
movq %rax, %r14
movq %rax, %rdi
xorl %esi, %esi
callq 0x590c0
pushq $0x6
popq %rcx
movl %ecx, %ebp
testb %al, %al
jne 0x7c963
movq %r14, %rdi
callq 0x596e0
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movq %r14, %rdi
callq 0x596e0
cvtsi2sdl 0x4(%rax), %xmm0
divsd 0x698d5(%rip), %xmm0    # 0xe61e8
movsd 0x40(%rsp), %xmm1
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
movl %eax, 0x18(%rsp)
movl $0xf, 0x1c(%rsp)
movq 0x30(%rsp), %rdi
callq 0x59c60
cwtl
cvtsi2sd %eax, %xmm0
leaq 0x18(%rsp), %rdi
callq 0x57480
movq %rax, 0x50(%rsp)
leaq 0x50(%rsp), %rdi
movsd 0x66bb8(%rip), %xmm0    # 0xe3510
callq 0x59050
movq %rax, %rbp
addl $0x6, %ebp
movl 0x28(%rsp), %r12d
leal 0x1(%r12), %eax
movl %eax, 0x20(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xf8(%rax)
movl %eax, %r14d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xa8(%rax)
movq %rax, %rdi
xorl %esi, %esi
callq 0x57d40
leal (%r12,%rbp), %ecx
incl %ecx
leal (%rcx,%r14), %edx
testb %al, %al
leal 0x6(%r14,%rcx), %eax
cmovel %edx, %eax
movl %eax, 0x28(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x90(%rax)
testb %al, %al
jne 0x7c9d1
movq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x58ae0
testb %al, %al
jne 0x7c9ed
incl %r13d
jmp 0x7c8b1
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
movq %rbx, %rsi
callq 0x57550
movl 0x14(%rsp), %ebp
movl 0x10(%rsp), %r14d
movl 0xc(%rsp), %r12d
movq %r15, %rdi
movl %r12d, %esi
movl %r14d, %edx
movl %ebp, %ecx
callq 0x594d0
movl %eax, %ebx
jmp 0x7c9dc