Example #1
0
    virtual BOOL on_mouse(HELEMENT he, HELEMENT target, UINT event_type, POINT pt, UINT mouseButtons, UINT keyboardStates )
    {
    
      if( event_type == MOUSE_WHEEL )
      {
        int dir = (int)mouseButtons;
        return on_scroll( he, target, dir < 0? SCROLL_STEP_PLUS : SCROLL_STEP_MINUS, 0, TRUE );
      }
    
      if( event_type != MOUSE_DOWN && event_type != MOUSE_DCLICK )
        return false;

      if(mouseButtons != MAIN_MOUSE_BUTTON) 
        return false;

      dom::element table = get_table(he);
      dom::element row = target_row(table, dom::element(target));

      if(row.is_valid()) // click on the row
      {
        if( (int)row.index() < (int)fixed_rows(table) )
        {
          // click on the header cell
          dom::element header_cell = target_header(row,target);
          if( header_cell.is_valid() )  
              on_column_click(table, header_cell);
          return true;
        }
        set_current_row(table, row, keyboardStates,  event_type == MOUSE_DCLICK);
      }
      return true; // as it is always ours then stop event bubbling
    }
Example #2
0
	LRESULT CComWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
	{
		switch(uMsg)
		{
		case WM_INITDIALOG:		return on_create(m_hWnd, GetModuleHandle(0));
		case WM_VSCROLL: 
		case WM_HSCROLL:		return on_scroll(uMsg, wParam, lParam);
		case WM_SIZE:			
								__super::HandleMessage(uMsg, wParam, lParam, bHandled);
								return on_size(LOWORD(lParam), HIWORD(lParam));
		case WM_CLOSE:			return on_close();
		case WM_COMMAND:		return on_command(HWND(lParam), LOWORD(wParam), HIWORD(wParam));
		case WM_DEVICECHANGE:	return on_device_change(wParam, (DEV_BROADCAST_HDR*)lParam);
		case WM_SETTINGCHANGE:	return on_setting_change(wParam, LPCTSTR(lParam));
		case WM_CONTEXTMENU:	return on_contextmenu(HWND(wParam), GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
		case WM_LBUTTONDOWN:	return SendMessage(WM_NCLBUTTONDOWN, HTCAPTION, 0);
		}
		if (uMsg >= WM_APP && uMsg <= 0xBFFF)
			return on_app(uMsg, wParam, lParam);

		return __super::HandleMessage(uMsg, wParam, lParam, bHandled);
	}
Example #3
0
bool CL_ListView_Impl::on_keyboard_pressed(CL_InputEvent &event)
{
	bool event_consumed = false;

	if (document_item.get_child_count() == 0)
		return event_consumed;

	if (event.id == CL_KEY_LEFT || event.id == CL_KEY_RIGHT || event.id == CL_KEY_UP || event.id == CL_KEY_DOWN)
	{
		event_consumed = true;

		// Ensure we have a selected item.
		if (selection.get_first().is_null())
		{
			CL_ListViewItem item = document_item.get_first_child();
			listview->set_selected(item, true);
		}

		CL_ListViewSelectedItem sel = selection.get_last();
		CL_ListViewItem sel_item = sel.get_item();

		CL_ListViewItem new_selected_item;

		if (event.id == CL_KEY_LEFT)
		{
			if (display_mode == listview_mode_details)
			{
				if (sel_item.has_children() && sel_item.is_open())
				{
					sel_item.set_open(false);
					layout->invalidate();
					update_scrollbar();
					new_selected_item = sel_item;
				}
				else
				{
					new_selected_item = layout->get_neighbour(sel_item, CL_ListViewLayout::neighbour_left);
				}
			}
			else
			{
				new_selected_item = layout->get_neighbour(sel_item, CL_ListViewLayout::neighbour_left);
			}
		}
		else if (event.id == CL_KEY_RIGHT)
		{
			if (display_mode == listview_mode_details)
			{
				if (sel_item.has_children() && !sel_item.is_open())
				{
					sel_item.set_open(true);
					layout->invalidate();
					update_scrollbar();
					new_selected_item = sel_item;
				}
				else
				{
					new_selected_item = layout->get_neighbour(sel_item, CL_ListViewLayout::neighbour_right);
				}
			}
			else
			{
				new_selected_item = layout->get_neighbour(sel_item, CL_ListViewLayout::neighbour_right);
			}
		}
		else if (event.id == CL_KEY_UP)
		{
			new_selected_item = layout->get_neighbour(sel_item, CL_ListViewLayout::neighbour_up);
		}
		else if (event.id == CL_KEY_DOWN)
		{
			new_selected_item = layout->get_neighbour(sel_item, CL_ListViewLayout::neighbour_down);
		}

		if (!event.ctrl)
			listview->set_selected(new_selected_item);
		else
			selection.append(new_selected_item);

        if (!layout->is_visible(new_selected_item))
		{
			if (event.id == CL_KEY_UP || event.id == CL_KEY_LEFT)
			{
				int scroll_pos = scrollbar->get_position();
				scroll_pos -= layout->get_row_height();
				scrollbar->set_position(scroll_pos);
				on_scroll();
			}
			else
			{
				int scroll_pos = scrollbar->get_position();
				scroll_pos += layout->get_row_height();
				scrollbar->set_position(scroll_pos);
				on_scroll();
			}
		}
	}
	else if (event.id == CL_KEY_F2)
	{
		std::vector<ListViewShownItem> &items = layout->get_shown_items();
		std::vector<ListViewShownItem>::iterator it;
		for (it = items.begin(); it != items.end(); ++it)
		{
			ListViewShownItem &si = (*it);
			if (si.is_null())
				continue;
			if (si.item.is_null())
				continue;

			if (si.item.is_selected())
				edit_item(*it);
		}

	}
	else if (event.type == CL_InputEvent::pressed && event.id == CL_KEY_HOME)
	{
		scrollbar->set_position(scrollbar->get_min());
		on_scroll();
		std::vector<ListViewShownItem> show_items = layout->get_shown_items();
		if (!show_items.empty())
			listview->set_selected(show_items[0].item, true);
	}
	else if (event.type == CL_InputEvent::pressed && event.id == CL_KEY_END)
	{
		scrollbar->set_position(scrollbar->get_max());
		on_scroll();
		std::vector<ListViewShownItem> show_items = layout->get_shown_items();
		if (!show_items.empty())
			listview->set_selected(show_items.back().item, true);
	}
	else if (event.type == CL_InputEvent::pressed && event.id == CL_KEY_PRIOR)
	{
		// PageUp - selects the first item of the visible items if another item is selected.
		// If first item already selected, do a page up.

		std::vector<ListViewShownItem> show_items = layout->get_shown_items();
		if (show_items.size() > 1)
		{
			if (selection.get_first().get_item() != show_items[0].item)
				listview->set_selected(show_items[0].item, true);
			else
			{
				scrollbar->set_position(scrollbar->get_position()-scrollbar->get_page_step());
				on_scroll();
				std::vector<ListViewShownItem> show_items = layout->get_shown_items();
				if (!show_items.empty())
					listview->set_selected(show_items[0].item, true);
			}
		}
	}
	else if (event.type == CL_InputEvent::pressed && event.id == CL_KEY_NEXT)
	{
		// PageDown - selects the last item of the visible items if last item is selected.
		// If last item is already selected, do a page down.
		
		std::vector<ListViewShownItem> show_items = layout->get_shown_items();
		if (show_items.size() > 1)
		{
			if (selection.get_first().get_item() != show_items.back().item)
				listview->set_selected(show_items.back().item, true);
			else
			{
				scrollbar->set_position(scrollbar->get_position() + scrollbar->get_page_step());
				on_scroll();
				std::vector<ListViewShownItem> show_items = layout->get_shown_items();
				if (!show_items.empty())
					listview->set_selected(show_items.back().item, true);
			}
		}
	}
	else
	{
		if (!func_key_pressed.is_null())
			func_key_pressed.invoke(event);
	}

	return event_consumed;
}
Example #4
0
void CL_ListView_Impl::on_process_message(CL_GUIMessage &msg)
{
	if (msg.is_type(CL_GUIMessage_Input::get_type_name()))
	{
		CL_GUIMessage_Input input = msg;
		CL_InputEvent input_event = input.get_event();

		if (input_event.type == CL_InputEvent::pointer_moved)
		{
			on_mouse_move(input, input_event);
		}
		else if (input_event.type == CL_InputEvent::pressed && input_event.id == CL_MOUSE_LEFT)
		{
			on_mouse_lbutton_down(input, input_event);
			msg.set_consumed();
		}
		else if (input_event.type == CL_InputEvent::pressed && input_event.id == CL_MOUSE_WHEEL_UP)
		{
			scrollbar->set_position(scrollbar->get_position()-scrollbar->get_line_step());
			on_scroll();
			msg.set_consumed();
		}
		else if (input_event.type == CL_InputEvent::pressed && input_event.id == CL_MOUSE_WHEEL_DOWN)
		{
			scrollbar->set_position(scrollbar->get_position() + scrollbar->get_line_step());
			on_scroll();
			msg.set_consumed();
		}
		else if (input_event.type == CL_InputEvent::released && input_event.id == CL_MOUSE_LEFT)
		{
			on_mouse_lbutton_up(input, input_event);
			msg.set_consumed();
		}
		else if (input_event.type == CL_InputEvent::doubleclick && input_event.id == CL_MOUSE_LEFT)
		{
			on_mouse_lbutton_doubleclick(input, input_event);
			msg.set_consumed();
		}
		else if (input_event.type == CL_InputEvent::pressed && input_event.id == CL_MOUSE_RIGHT)
		{
			on_mouse_rbutton_down(input, input_event);
			msg.set_consumed();
		}
		else if (input_event.type == CL_InputEvent::released && input_event.id == CL_MOUSE_RIGHT)
		{
			on_mouse_rbutton_up(input, input_event);
			msg.set_consumed();
		}
		else if (input_event.type == CL_InputEvent::pressed && input_event.device.get_type() == CL_InputDevice::keyboard)
		{
			bool consumed = on_keyboard_pressed(input_event);
			if (consumed)
				msg.set_consumed();
		}
		else if (input_event.type == CL_InputEvent::released && input_event.device.get_type() == CL_InputDevice::keyboard)
		{
			bool consumed = on_keyboard_released(input_event);
			if (consumed)
				msg.set_consumed();
		}
	}
	else if (msg.is_type(CL_GUIMessage_Pointer::get_type_name()))
	{
		CL_GUIMessage_Pointer pointer = msg;
		if (pointer.get_pointer_type() == CL_GUIMessage_Pointer::pointer_leave)
			on_mouse_leave();
		else if (pointer.get_pointer_type() == CL_GUIMessage_Pointer::pointer_enter)
			on_mouse_enter();
	}
	else if (msg.is_type(CL_GUIMessage_FocusChange::get_type_name()))
	{
		CL_GUIMessage_FocusChange fc = msg;
		if (fc.get_focus_type() == CL_GUIMessage_FocusChange::gained_focus)
		{
			// ..
		}
		else
		{
			if (just_launched_lineedit)
				just_launched_lineedit = false;
			else
				cancel_edit();
		}
		listview->request_repaint();
	}
}
 virtual BOOL handle_scroll(HELEMENT he, SCROLL_PARAMS &params)
 {
     return on_scroll(he, params.target, (SCROLL_EVENTS)params.cmd,
         params.pos, params.vertical);
 }