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

	Window	*window	= container->GetContainerWindow();

	if (window == NIL)   return Success();

	widgets.LockForWrite();

	foreach (Widget *widget, widgets)
	{
		if (widget->Process(message, wParam, lParam) == MessageProcessed) { widgets.Unlock(); return MessageProcessed; }
	}

	widgets.Unlock();

	if (!IsVisible())    return Success();
	if (!IsActive())     return Success();

	EnterProtectedRegion();

	Int	 returnValue = Success();
	Point	 mousePos    = window->GetMousePosition();

	switch (message)
	{
		case SM_MOUSEMOVE:
			{
				Point	 realPosition = GetRealPosition();
				Rect	 visibleArea  = GetVisibleArea();

				if (!mouseOver && window->IsMouseOn(visibleArea) && hitTest.Call(mousePos - realPosition))
				{
					mouseOver = True;

					if (statusText != NIL) window->SetStatusText(statusText);

					if ((tooltipText != NIL || tooltipLayer != NIL) && window->IsFocussed())
					{
						Application::Lock	 lock;

						tipPos	 = mousePos;
						tipTimer = new System::Timer();

						tipTimer->onInterval.Connect(&Widget::ActivateTooltip, this);
						tipTimer->Start(Setup::HoverTime);
					}

					Paint(SP_MOUSEIN);

					onMouseOver.Emit();
				}
				else if (mouseOver && !(window->IsMouseOn(visibleArea) && hitTest.Call(mousePos - realPosition)))
				{
					mouseOver = False;

					leftButtonDown	= False;
					rightButtonDown	= False;

					if (statusText != NIL && window->GetStatusText() == statusText) window->RestoreDefaultStatusText();

					DeactivateTooltip();

					Paint(SP_MOUSEOUT);

					onMouseOut.Emit();
				}
				else if (mouseOver && window->IsMouseOn(visibleArea) && hitTest.Call(mousePos - realPosition))
				{
					Application::Lock	 lock;

					if (tipTimer != NIL && wParam == 0 && (Math::Abs(tipPos.x - mousePos.x) > Setup::HoverWidth / 2 || Math::Abs(tipPos.y - mousePos.y) > Setup::HoverHeight / 2))
					{
						tipPos = mousePos;

						tipTimer->Stop();
						tipTimer->Start(Setup::HoverTime);
					}
				}
			}

			if (mouseDragging)
			{
				onMouseDrag.Emit(mousePos);
			}

			break;
		case SM_LBUTTONDOWN:
			if (mouseOver)
			{
				leftButtonDown = True;

				DeactivateTooltip();

				Paint(SP_MOUSEDOWN);

				if (!focussed)
				{
					focussed = True;

					onGetFocus.Emit();
				}
				else
				{
					onClickInFocus.Emit();
				}

				onLeftButtonDown.Emit(mousePos);

				if (!mouseDragging)
				{
					mouseDragging = True;

					onMouseDragStart.Emit(mousePos);
				}
			}
			else
			{
				if (focussed)
				{
					focussed = False;

					onLoseFocus.Emit();
				}
			}

			break;
		case SM_LBUTTONDBLCLK:
			if (mouseOver)
			{
				leftButtonDown = True;

				Paint(SP_MOUSEDOWN);

				onLeftButtonDown.Emit(mousePos);
				onLeftButtonDoubleClick.Emit(mousePos);
			}

			break;
		case SM_LBUTTONUP:
			if (mouseOver)
			{
				Paint(SP_MOUSEUP);

				onLeftButtonUp.Emit(mousePos);

				if (leftButtonDown)
				{
					leftButtonDown = False;

					onLeftButtonClick.Emit(mousePos);
				}
			}

			if (mouseDragging)
			{
				mouseDragging = False;

				onMouseDragEnd.Emit(mousePos);
			}

			break;
		case SM_RBUTTONDOWN:
		case SM_RBUTTONDBLCLK:
			if (mouseOver)
			{
				OpenContextMenu();

				/* Force mouseOut event.
				 */
				window->Process(SM_MOUSEMOVE, 0, 0);
			}

			break;
		case SM_MOUSEWHEEL:
			{
				UnsignedInt	 scrollLines = 0;

#ifdef __WIN32__
				SystemParametersInfo(104, NIL, &scrollLines, NIL);
#endif

				if (scrollLines <= 0) scrollLines = 3;

				onMouseWheel.Emit(Float(wParam) / 120.0 * scrollLines);
			}

			break;
		case SM_KEYDOWN:
			if (!focussed || !tabstopCapable) break;

			if (wParam == Input::Keyboard::KeyTab)
			{
				Widget	*widget = NIL;

				if (Input::Keyboard::GetKeyState(Input::Keyboard::KeyShift)) widget = container->GetPreviousTabstopWidget(GetHandle());
				else							     widget = container->GetNextTabstopWidget(GetHandle());

				if (widget != NIL)
				{
					focussed = False;

					onLoseFocus.Emit();

					widget->SetFocusByKeyboard();
				}

				returnValue = MessageProcessed;
			}

			break;
		case SM_LOSEFOCUS:
			if (focussed)
			{
				Window	*focusWnd = (Window *) Object::GetObject(wParam, Window::classID);

				if (focusWnd != NIL)
				{
					if ((focusWnd->GetObjectType() == ToolWindow::classID && focusWnd->GetOrder() >= window->GetOrder()) || focusWnd == window) break;
				}

				focussed = False;

				onLoseFocus.Emit();
			}

			break;
	}

	LeaveProtectedRegion();

	return returnValue;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %ebx
movl %edx, 0x20(%rsp)
movl %esi, %r13d
movq %rdi, %r14
movq (%rdi), %rax
callq *0x88(%rax)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testb %al, %al
je 0x6f79d
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
xorl %ebp, %ebp
testb %al, %al
je 0x6f79d
movq 0x190(%r14), %r15
movq 0xfd812(%rip), %rax     # 0x16c828
movswl (%rax), %r12d
leaq 0x20(%r15), %rdi
movl %r12d, %esi
callq 0x57520
testb %al, %al
jne 0x6f039
movq 0x190(%r15), %r15
testq %r15, %r15
jne 0x6f01a
xorl %r15d, %r15d
xorl %ebp, %ebp
testq %r15, %r15
je 0x6f79d
movl %r12d, 0x24(%rsp)
movq %r15, 0x18(%rsp)
cmpb $0x1, 0x68(%r14)
jne 0x6f05e
movq 0x70(%r14), %rdi
callq 0x551d0
leaq 0x38(%r14), %rax
movq %rax, 0x40(%rsp)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq %r14, 0x10(%rsp)
movl 0x40(%r14), %eax
decl %eax
cmpl %eax, %r15d
jge 0x6f0e5
incl %r15d
movq 0x40(%rsp), %rdi
movl %r15d, %esi
callq 0x60a40
movq (%rax), %r14
movb $0x1, %cl
xorl %edx, %edx
movl %edx, %r12d
testb $0x1, %cl
je 0x6f0da
movl %ecx, %ebp
movq (%r14), %rax
movq %r14, %rdi
movl %r13d, %esi
movl 0x20(%rsp), %edx
movl %ebx, %ecx
callq *0x80(%rax)
movb $0x1, %dl
xorl %ecx, %ecx
cmpl $-0x1, %eax
jne 0x6f094
movq 0x10(%rsp), %rax
cmpb $0x1, 0x68(%rax)
jne 0x6f0d0
movq 0x70(%rax), %rdi
callq 0x55910
testb $0x1, %bpl
jne 0x6f194
testb $0x1, %r12b
movq 0x10(%rsp), %r14
jne 0x6f072
cmpb $0x1, 0x68(%r14)
jne 0x6f0f5
movq 0x70(%r14), %rdi
callq 0x55910
movq (%r14), %rax
movq %r14, %rdi
callq *0x90(%rax)
testb %al, %al
movl $0x0, %ebp
je 0x6f79d
movq (%r14), %rax
movq %r14, %rdi
callq *0x98(%rax)
testb %al, %al
je 0x6f79d
leaq 0x1c(%r14), %r12
movq %r12, %rdi
callq 0x578f0
movq 0x18(%rsp), %rdi
callq 0x56b50
movq %rax, 0x8(%rsp)
xorl %ebp, %ebp
addl $0xffff8800, %r13d      # imm = 0xFFFF8800
cmpl $0x13, %r13d
ja 0x6f795
leaq 0x87629(%rip), %rax     # 0xf6780
movslq (%rax,%r13,4), %rcx
addq %rax, %rcx
jmpq *%rcx
cmpb $0x1, 0xd4(%r14)
jne 0x6f795
movq %r14, %rdi
callq 0x56b90
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
xorl %ebp, %ebp
movl $0x7800, %esi           # imm = 0x7800
xorl %edx, %edx
xorl %ecx, %ecx
callq *0x80(%rax)
jmp 0x6f795
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x6f79d
cmpb $0x1, 0xd4(%r14)
jne 0x6f1ea
movq (%r14), %rax
movq %r14, %rdi
movl $0x5, %esi
callq *0x78(%rax)
leaq 0x318(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0x70676
cmpb $0x1, 0xd5(%r14)
jne 0x6f1ea
movb $0x0, 0xd5(%r14)
leaq 0x338(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0x70676
cmpb $0x1, 0xd7(%r14)
jne 0x6f795
movb $0x0, 0xd7(%r14)
addq $0x438, %r14            # imm = 0x438
jmp 0x6f735
addq $0x458, %r14            # imm = 0x458
cvtsi2sdl 0x20(%rsp), %xmm0
divsd 0x8754f(%rip), %xmm0    # 0xf6770
mulsd 0x85337(%rip), %xmm0    # 0xf4560
movq %r14, %rdi
callq 0x70710
jmp 0x6f795
cmpb $0x1, 0xcd(%r14)
jne 0x6f795
cmpl $0x9, 0x20(%rsp)
jne 0x6f795
cmpb $0x0, 0xd2(%r14)
je 0x6f795
movl $0x10, %edi
callq 0x57510
movq 0x190(%r14), %rdi
movl 0x8(%r14), %esi
testb %al, %al
je 0x6f764
callq 0x57d00
jmp 0x6f769
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
movq %rax, %rbx
movq %r14, %r15
movq %rax, %r14
shrq $0x20, %r14
movq (%r15), %rax
movq %r15, %rdi
callq *0x130(%rax)
movq %rax, 0x30(%rsp)
movq %rdx, 0x38(%rsp)
cmpb $0x0, 0xd4(%r15)
jne 0x6f520
leaq 0x30(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x578a0
testb %al, %al
je 0x6f520
movq 0x10(%rsp), %rax
leaq 0x1a8(%rax), %rdi
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
subl %ebx, %eax
subl %r14d, %ecx
shlq $0x20, %rcx
orq %rcx, %rax
leaq 0x28(%rsp), %rsi
movq %rax, (%rsi)
callq 0x714a2
testb %al, %al
je 0x6f520
movq 0x10(%rsp), %r14
movb $0x1, 0xd4(%r14)
leaq 0x108(%r14), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x56bd0
testb %al, %al
je 0x6f33d
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
callq *0xd0(%rax)
leaq 0x120(%r14), %rdi
xorl %esi, %esi
callq 0x56bd0
testb %al, %al
jne 0x6f359
cmpq $0x0, 0x138(%r14)
je 0x6f3d2
movq 0x18(%rsp), %rax
cmpb $0x1, 0xcd(%rax)
jne 0x6f3d2
callq 0x55420
movq 0x8(%rsp), %rax
movq %rax, 0x98(%r14)
movl $0x68, %edi
callq 0x556b0
movq %rax, %r14
movq %rax, %rdi
callq 0x55b80
movq 0x10(%rsp), %rcx
movq %r14, 0xa0(%rcx)
addq $0x48, %r14
movq 0xfd494(%rip), %rsi     # 0x16c838
movq %r14, %rdi
xorl %edx, %edx
callq 0x705b8
movq 0x10(%rsp), %rax
movq 0xa0(%rax), %rdi
movq 0xfd8af(%rip), %rax     # 0x16cc70
movl (%rax), %esi
callq 0x55100
callq 0x56e90
movq 0x10(%rsp), %r14
movq (%r14), %rax
movq %r14, %rdi
movl $0x2, %esi
callq *0x78(%rax)
leaq 0x2b8(%r14), %rdi
jmp 0x6f71f
cmpb $0x1, 0xd4(%r14)
jne 0x6f695
movb $0x1, 0xd5(%r14)
movq %r14, %rdi
callq 0x59208
movq (%r14), %rax
movq %r14, %rdi
movl $0x4, %esi
callq *0x78(%rax)
movl $0x538, %edi            # imm = 0x538
cmpb $0x0, 0xcd(%r14)
jne 0x6f434
movb $0x1, 0xcd(%r14)
movl $0x4d8, %edi            # imm = 0x4D8
addq %r14, %rdi
callq 0x70488
leaq 0x2f8(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0x70676
cmpb $0x0, 0xd7(%r14)
jne 0x6f795
movb $0x1, 0xd7(%r14)
addq $0x3f8, %r14            # imm = 0x3F8
jmp 0x6f735
cmpb $0x1, 0xcd(%r14)
jne 0x6f795
movl 0x20(%rsp), %edi
movl 0x24(%rsp), %esi
callq 0x57710
testq %rax, %rax
je 0x6f74b
movq %rax, %rbx
leaq 0x20(%rax), %rdi
movq 0xfd837(%rip), %rax     # 0x16ccd8
movswl (%rax), %esi
callq 0x57520
testb %al, %al
je 0x6f744
movq 0x18(%rsp), %rax
cmpq %rax, %rbx
je 0x6f795
movl 0x5b8(%rax), %eax
cmpl %eax, 0x5b8(%rbx)
jl 0x6f74b
jmp 0x6f795
cmpb $0x1, 0xd4(%r14)
jne 0x6f795
movb $0x1, 0xd5(%r14)
movq (%r14), %rax
movq %r14, %rdi
movl $0x4, %esi
callq *0x78(%rax)
leaq 0x2f8(%r14), %rdi
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x70676
addq $0x358, %r14            # imm = 0x358
movq %r14, %rdi
movq %rbx, %rsi
jmp 0x6f73d
movq 0x10(%rsp), %rax
cmpb $0x1, 0xd4(%rax)
jne 0x6f57a
leaq 0x30(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x578a0
testb %al, %al
je 0x6f6af
movq 0x10(%rsp), %rax
leaq 0x1a8(%rax), %rdi
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
subl %ebx, %eax
subl %r14d, %ecx
shlq $0x20, %rcx
orq %rcx, %rax
leaq 0x28(%rsp), %rsi
movq %rax, (%rsi)
callq 0x714a2
testb %al, %al
je 0x6f6af
movq 0x10(%rsp), %rax
cmpb $0x1, 0xd4(%rax)
jne 0x6f6a8
leaq 0x30(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x578a0
testb %al, %al
je 0x6f6a8
movq 0x10(%rsp), %rdx
leaq 0x1a8(%rdx), %rdi
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
subl %ebx, %eax
subl %r14d, %ecx
movq %rdx, %r14
shlq $0x20, %rcx
orq %rcx, %rax
leaq 0x28(%rsp), %rsi
movq %rax, (%rsi)
callq 0x714a2
testb %al, %al
je 0x6f724
callq 0x55420
movq 0xa0(%r14), %rdi
testq %rdi, %rdi
sete %al
cmpl $0x0, 0x20(%rsp)
setne %cl
orb %al, %cl
jne 0x6f68b
movl 0x98(%r14), %ecx
movl 0x8(%rsp), %edx
movl %ecx, %esi
subl %edx, %esi
sarl $0x1f, %esi
orl $0x1, %esi
xorl %eax, %eax
subl %edx, %ecx
cmovel %eax, %esi
imull %ecx, %esi
movq 0xfd3f5(%rip), %rcx     # 0x16ca18
movl (%rcx), %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
cmpl %edx, %esi
jg 0x6f665
movl 0x9c(%r14), %ecx
movl 0xc(%rsp), %edx
movl %ecx, %esi
subl %edx, %esi
sarl $0x1f, %esi
orl $0x1, %esi
subl %edx, %ecx
cmovel %eax, %esi
imull %ecx, %esi
movq 0xfd8a2(%rip), %rax     # 0x16cef8
movl (%rax), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
cmpl %ecx, %esi
jle 0x6f68b
movq 0x8(%rsp), %rax
movq %rax, 0x98(%r14)
callq 0x59190
movq 0xa0(%r14), %rdi
movq 0xfd5ec(%rip), %rax     # 0x16cc70
movl (%rax), %esi
callq 0x55100
callq 0x56e90
jmp 0x6f724
cmpb $0x1, 0xcd(%r14)
je 0x6f74b
jmp 0x6f795
movq 0x10(%rsp), %r14
jmp 0x6f724
movq 0x10(%rsp), %r14
movw $0x0, 0xd4(%r14)
movb $0x0, 0xd6(%r14)
leaq 0x108(%r14), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x56bd0
testb %al, %al
je 0x6f702
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
callq *0xd8(%rax)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x55900
testb %al, %al
je 0x6f702
movq 0x18(%rsp), %rdi
callq 0x55de0
movq %r14, %rdi
callq 0x59208
movq (%r14), %rax
movq %r14, %rdi
movl $0x3, %esi
callq *0x78(%rax)
leaq 0x2d8(%r14), %rdi
callq 0x70488
cmpb $0x1, 0xd7(%r14)
jne 0x6f795
addq $0x418, %r14            # imm = 0x418
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x70676
jmp 0x6f795
cmpq 0x18(%rsp), %rbx
je 0x6f795
movb $0x0, 0xcd(%r14)
addq $0x518, %r14            # imm = 0x518
movq %r14, %rdi
callq 0x70488
jmp 0x6f795
callq 0x55fe0
movq %rax, %rbx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x6f795
movb $0x0, 0xcd(%r14)
addq $0x518, %r14            # imm = 0x518
movq %r14, %rdi
callq 0x70488
movq %rbx, %rdi
callq 0x56210
movq %r12, %rdi
callq 0x55cc0
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6f7e0
movq %rax, %rbx
movl $0x68, %esi
movq %r14, %rdi
callq 0x55480
jmp 0x6f7d3
movq %rax, %rbx
callq 0x56e90
jmp 0x6f7d8
jmp 0x6f7e0
jmp 0x6f7e0
movq %rax, %rbx
callq 0x56e90
movq %rbx, %rdi
callq 0x57090
movq %rax, %rdi
callq 0x5aede