Beispiel #1
0
void slider::mouse_wheel(const SDL_MouseWheelEvent& event) {
	bool prev_change = value_change_;
	int x, y;
	SDL_GetMouseState(&x, &y);

	if (!sdl::point_in_rect(x, y, location()))
		return;

	if (event.y > 0 || event.x > 0) {
		value_change_ = false;
		set_focus(true);
		set_value(value_ + increment_);
		if(value_change_) {
			sound::play_UI_sound(game_config::sounds::slider_adjust);
		} else {
			value_change_ = prev_change;
		}
	}
	if (event.y < 0 || event.x < 0) {
		value_change_ = false;
		set_focus(true);
		set_value(value_ - increment_);
		if(value_change_) {
			sound::play_UI_sound(game_config::sounds::slider_adjust);
		} else {
			value_change_ = prev_change;
		}
	}
}
CL_Component *CL_GUIManager_Generic::tab_previous()
{
	// First try to find component by tab id:
	CL_Component *tab_component = owner->find_tab_id(--current_tab_id);
	if (current_tab_id == -1) // reached beginning, start from end
	{
		current_tab_id = find_highest_tab_id(owner);
		tab_component = owner->find_tab_id(current_tab_id);
	}
	if (tab_component)
	{
		set_focus(tab_component);
		return comp_focus;
	}

	if(comp_focus == 0)
		return 0;

	// No tab ids - fall back to tree walking:
	CL_Component *cur = comp_focus;
	while (true)
	{
		CL_Component *parent = cur->get_parent();
		if (parent == 0) break;

		// Search siblings:
		std::list<CL_Component *>::const_iterator it;
		for (it = parent->get_children().begin(); it != parent->get_children().end(); it++)
		{
			if (*it == cur)
			{
				// no more siblings
				if (it == parent->get_children().begin()) break;

				it--;

				// give sibling focus
				set_focus(*it);
				return comp_focus;
			}
		}

		// Was last sibling, continue search in parent (uncles)
		cur = parent;
	}

	// walked through all components. Restart at end component:
	cur = owner;
	while (!cur->get_children().empty()) cur = cur->get_children().back();
	set_focus(cur);
	return comp_focus;
}
Beispiel #3
0
int AxisCam::get_focus(int* focus)
{
    if (last_autofocus_enabled)
        set_focus(0, true); // manual focus but don't move it

    int ret = query_params();

    if (last_autofocus_enabled)
        set_focus(0); // re-enable autofocus

    *focus = last_focus;
    return ret;
}
void PopUpMenu::popup() {
	

	pre_show_signal.call();
	show();	
	set_focus( 0 ); //clear focus	
}
Beispiel #5
0
bool MainCtrl::on_mouse (ui::MouseEvent mouse_event)
{
	if (!(mouse_event.m & (ui::LEFT_CLICK | ui::LEFT_DCLICK | ui::RIGHT_CLICK))) {
		return false;
	}
	unsigned k = mouse_event.p.y + scroll_.get_first();
	unsigned scroll_focus = scroll_.get_focus();
	if (k >= scroll_focus) {
		unsigned expand_lines = w().global_options.get_num (GLOBAL_OPTION_EXPAND_LINES);
		if (k < scroll_focus + expand_lines) {
			k = scroll_focus;
		}
		else {
			k -= expand_lines - 1;
		}
	}
	if (k >= w().get_current_list ().size ()) {
		return false;
	}
	set_focus (k);
	if (mouse_event.m & ui::LEFT_DCLICK) {
		w().view_current ();
	}
	else if (mouse_event.m & ui::RIGHT_CLICK) {
		w().context_menu->show (mouse_event.p + get_pos (), true);
	}
	return true;
}
Beispiel #6
0
Patch::~Patch()
{
   //XXX - Moved this up here...
   _textures.delete_all();

   // Get out of the patch list if needed:
   if (_mesh) _mesh->unlist(this);
   _mesh = nullptr;

   // The patch owns its tri_strips, crease strips, and Gtexures, 
   // but not its faces, edge strips, or vert strips. So it deletes
   // the former but not the latter.
   while (!_tri_strips.empty()) {
      delete _tri_strips.back();
      _tri_strips.pop_back();
   }
   delete _creases;
   delete _borders;   

   //XXX - Moved this higher so that GTextures that do things
   //      like unobserving meshes on destruction, still have
   //      a valid _mesh pointer...
   //_textures.delete_all();
   
   for (Bface_list::size_type i=0; i<_faces.size(); i++) {
      _faces[i]->set_patch(nullptr);
      _faces[i]->set_patch_index(-1);
   }

   if (is_focus(this))
      set_focus(nullptr);
}
Beispiel #7
0
void slider::mouse_down(const SDL_MouseButtonEvent& event)
{
	bool prev_change = value_change_;

	if (!sdl::point_in_rect(event.x, event.y, location()))
		return;


	if (event.button != SDL_BUTTON_LEFT)
		return;

	state_ = CLICKED;
	set_focus(true);
	if (sdl::point_in_rect(event.x, event.y, slider_area())) {
		sound::play_UI_sound(game_config::sounds::button_press);
	} else {
		value_change_ = false;
		set_slider_position(event.x);
		if(value_change_) {
			sound::play_UI_sound(game_config::sounds::slider_adjust);
		} else {
			value_change_ = prev_change;
		}
	}
}
void PopUpMenu::popup(const Point &p_pos) {
	
	set_pos(p_pos);
	show();	
	set_focus( 0 ); //clear focus	
	
}
Beispiel #9
0
void MainWindow::on_button_enter() {
    std::thread(
        [this](int dummy) {
            std::string query = m_entry.get_text();

            m_entry.set_sensitive(false);
            m_entry.set_text("計算中です...");

            CrTrimString(query);
            auto result = ChJustDoIt(query);
            ChFixResultForDisplay(result);

            std::string contents("にゅうりょく:");
            contents += query;
            contents += '\n';
            contents += result;
            contents += '\n';
            add_output(contents);

            if (result.find("しゅうりょうします") != std::string::npos) {
                m_entry.set_text("終了中です...");
                hide();
            }

            m_entry.set_text("");
            m_entry.set_sensitive(true);
            set_focus(m_entry);
        }, 0
    ).detach();
}
Beispiel #10
0
/**********************************************************************
 *              EVENT_FocusIn
 */
static void EVENT_FocusIn( HWND hwnd, XEvent *xev )
{
    XFocusChangeEvent *event = &xev->xfocus;
    XIC xic;

    if (!hwnd) return;

    TRACE( "win %p xwin %lx detail=%s\n", hwnd, event->window, focus_details[event->detail] );

    if (event->detail == NotifyPointer) return;

    if ((xic = X11DRV_get_ic( hwnd )))
    {
        wine_tsx11_lock();
        XSetICFocus( xic );
        wine_tsx11_unlock();
    }
    if (use_take_focus) return;  /* ignore FocusIn if we are using take focus */

    if (!can_activate_window(hwnd))
    {
        HWND hwnd = GetFocus();
        if (hwnd) hwnd = GetAncestor( hwnd, GA_ROOT );
        if (!hwnd) hwnd = GetActiveWindow();
        if (!hwnd) hwnd = x11drv_thread_data()->last_focus;
        if (hwnd && can_activate_window(hwnd)) set_focus( hwnd, CurrentTime );
    }
    else SetForegroundWindow( hwnd );
}
Beispiel #11
0
Datei: menu.c Projekt: Cougar/pwm
static void set_active_menu(WMenu *menu)
{
	if(wglobal.input_mode==INPUT_CTXMENU)
		wglobal.grab_holder=(WThing*)menu;
	else
		set_focus((WThing*)menu);
}
Beispiel #12
0
void need_scr()
{
  scr_handle = tty_open();    
  tty_set_attribute(scr_handle,0x02,0x00);
  tty_clear_display(scr_handle);
  set_focus(0,scr_handle,1);
  seed();
}
Beispiel #13
0
void TMemo::go_to(int idx1, int idx2, int nscroll)
{
	if (idx2==-1) idx2 = idx1;
	set_focus();
	set_selection(idx1,idx2);
    scroll_caret();
	scroll_line(nscroll); //*SJD* Should have an estimate of the page size!!
}
Beispiel #14
0
bool GridComponent::on_input_pressed(const clan::InputEvent &e)
{
	set_focus();

	if (e.id == clan::mouse_left && deliver_input_to_tab(e))
		return true;
	return edit_state.on_input_pressed(offset_event(e));
}
void PopUpMenu::popup(const Point &p_pos) {
	
	pre_show_signal.call();
	set_pos(p_pos);
	show();	
	set_focus( 0 ); //clear focus	
	
}
Beispiel #16
0
void GUI_PopMenuItem::on_mouse_click(MouseEventArgs const& e)
{
	set_focus(true);
	if (Application::instance().m_message_queue.m_reader)
	{
		Parameter_GameObject* p = new Parameter_GameObject();
		p->m_object = m_object;
		Application::instance().m_message_queue.push(p);
	}
	//Owner->Destroy(Owner);
	//Owner->Game->GUI->MapViewer->SetFocus(true);
	//Owner->Game->GUI->MapViewer->UnderCursor(MouseEventArgs(Point(e.Position.x + Owner->x, e.Position.y + Owner->y), e.Flags));
	//Owner->Game->GUI->MapViewer->MouseClick(MouseEventArgs(Point(e.Position.x + Owner->x, e.Position.y + Owner->y), e.Flags));
	set_focus(false);
	m_owner->destroy(m_owner);
	/*char buf2[32];
	itoa(e.Position.y + Owner->y, buf2, 10);
	MessageBox(NULL, buf2, "Down", MB_OK);*/
}
Beispiel #17
0
login_dialog::login_dialog() : QDialog(0)
{
  QVBoxLayout* top_layout = new QVBoxLayout(this);
  QGridLayout* grid = new QGridLayout();
  top_layout->addLayout(grid);

  int row=0;
  grid->addWidget(new QLabel(tr("Database name:"), this), row, 0);
  m_dbname = new QComboBox(this);
  m_dbname->setEditable(true);
  grid->addWidget(m_dbname, row, 1);
  row++;

  grid->addWidget(new QLabel(tr("Login:"******"Password:"******"Host:"), this), row, 0);
  m_host = new QLineEdit(this);
  grid->addWidget(m_host, row, 1);
  row++;

  grid->addWidget(new QLabel(tr("More parameters:"), this), row, 0);
  m_params = new QLineEdit(this);
  grid->addWidget(m_params, row, 1);
  row++;

  QHBoxLayout* hbox = new QHBoxLayout();
  top_layout->addLayout(hbox);

  hbox->setMargin(10);
  hbox->setSpacing(20);
  QPushButton* wok = new QPushButton(tr("OK"), this);
  QPushButton* whelp = new QPushButton(tr("Help"), this);
  QPushButton* wcancel = new QPushButton(tr("Cancel"), this);
  hbox->addWidget(wok);
  hbox->addWidget(whelp);
  hbox->addWidget(wcancel);
  connect(wok, SIGNAL(clicked()), this, SLOT(ok()));
  connect(wcancel, SIGNAL(clicked()), this, SLOT(reject()));
  connect(whelp, SIGNAL(clicked()), this, SLOT(help()));

  setWindowTitle(tr("Connect to a manitou database"));
  setWindowIcon(UI_ICON(ICON16_DISCONNECT));

  init_settings();
  set_focus();
}
void CL_GUIManager_Generic::on_input_down(const CL_InputEvent &key)
{
	if (!input_enabled) return;

	// Transform from screen coordinates to GUI coordinate.
	int mouse_x = (int) key.mouse_pos.x;
	int mouse_y = (int) key.mouse_pos.y;
	owner->sig_transform_coords()(mouse_x, mouse_y);

	CL_InputEvent transformed_key = key;
	transformed_key.mouse_pos.x = mouse_x;
	transformed_key.mouse_pos.y = mouse_y;

	// Figure out what our focus component is (whom to send message):
	focus_component = find_focus_component(transformed_key);
	if (!focus_component)
		return;

	// If its a mouse click, make the clicked component get focus.
	if (key.device.get_type() == CL_InputDevice::mouse)
		if (focus_component->is_focusable())
			set_focus(focus_component);

	// If its a tab click, pass on keyboard input to next component.
	if (key.id == CL_KEY_TAB)
	{
		if(key.device.get_keycode(CL_KEY_LSHIFT) || key.device.get_keycode(CL_KEY_RSHIFT))
			focus_component = tab_previous();
		else
			focus_component = tab_next();
	}

	if (!focus_component)
		return;

	// If component is disabled, do not send event:
	if (focus_component->is_enabled() == false || focus_component->is_visible() == false)
		return;

	// Make coordinates relative to focus component.
	transformed_key.mouse_pos.x -= focus_component->get_screen_rect().left;
	transformed_key.mouse_pos.y -= focus_component->get_screen_rect().top;

	// Send input down event:
	focus_component->sig_input_down()(transformed_key);
	if (focus_component == 0) return; // component was deleted.

	// Send key down event:
	if(key.device.get_type() == CL_InputDevice::keyboard)
		focus_component->sig_key_down()(transformed_key);

	// Send mouse down event:
	if(key.device.get_type() == CL_InputDevice::mouse)
		focus_component->sig_mouse_down()(transformed_key);
}
Beispiel #19
0
void palette_manager::handle_event(const SDL_Event& event) {

	gui::widget::handle_event(event);

	if (event.type == SDL_MOUSEMOTION) {
		// If the mouse is inside the palette, give it focus.
		if (sdl::point_in_rect(event.button.x, event.button.y, location())) {
			if (!focus(&event)) set_focus(true);
		}
		// If the mouse is outside, remove focus.
		else if (focus(&event)) set_focus(false);
	}
	if (!focus(&event)) {
		return;
	}

	const SDL_MouseButtonEvent &mouse_button_event = event.button;


	if (event.type == SDL_MOUSEWHEEL) {
		if (event.wheel.y > 0) {
			scroll_up();
		} else if (event.wheel.y < 0) {
			scroll_down();
		}

		if (event.wheel.x < 0) {
			active_palette().prev_group();
			scroll_top();
		} else if (event.wheel.x > 0) {
			active_palette().next_group();
			scroll_top();
		}
	}

	if (mouse_button_event.type == SDL_MOUSEBUTTONUP) {
		//set_dirty(true);
//		draw(true);
//		set_dirty(active_palette().mouse_click());
//		gui_.invalidate_game_status();
	}
}
Beispiel #20
0
bool
ButtonWindow::on_mouse_down(int x, int y)
{
  if (is_tab_stop())
    set_focus();

  set_down(true);
  set_capture();
  dragging = true;
  return true;
}
Beispiel #21
0
int GetAGroup::detect()
{
	if( !enable_flag )
		return 0;

	err_when( focused_geta < 0 || focused_geta > geta_num);

	GetA *getPtr = &geta_array[focused_geta];
	err_when( !getPtr->enable_flag );

	unsigned keyCode = getPtr->detect_key();
	if( keyCode )
	{
		getPtr->paint(1);
		// detect change field focus button
		if( keyCode == KEY_RETURN || keyCode == KEY_DOWN || keyCode == KEY_TAB )
		{
			set_focus(-1);
		}
		else if( keyCode == KEY_UP )
		{
			set_focus(-2);
		}
		return 1;
	}

	// detect clicking on the area
	for( int i = 0; i < geta_num; ++i )
	{
		getPtr = &geta_array[i];
		if( getPtr->detect_click() )
		{
			set_focus(i);
			return 1;
		}
	}
	return 0;
}
Beispiel #22
0
int Ge::set_focus( void *component)
{
    if ( component == 0) {
        if ( subpalette_mapped)
            set_focus( subpalette);
        else if ( plant_mapped)
            set_focus( plantctx);
    }
    else if ( component == (void *)graph) {
        graph->set_inputfocus( 1);
        if ( subpalette_mapped)
            subpalette->set_inputfocus( 0);
        if ( plant_mapped)
            plantctx->set_inputfocus(0);
        focused_component = component;
    }
    else if ( component == (void *)subpalette) {
        if ( subpalette_mapped) {
            graph->set_inputfocus( 0);
            subpalette->set_inputfocus( 1);
            focused_component = component;
            if ( plant_mapped)
                plantctx->set_inputfocus(0);
        }
    }
    else if ( component == (void *)plantctx) {
        if ( plant_mapped) {
            if ( subpalette_mapped)
                subpalette->set_inputfocus(0);
            graph->set_inputfocus( 0);
            plantctx->set_inputfocus( 1);
            focused_component = component;
        }
    }

    return 1;
}
Beispiel #23
0
MainWindow::MainWindow() {
    set_title("ひらがな電卓Calc-H ver.0.8.8");
    set_size_request(500, 280);

    Pango::FontDescription font_desc;
    #ifdef _WIN32
        font_desc.set_family("MS Gothic");
    #else
        font_desc.set_family("typewriter");
    #endif
    m_label.modify_font(font_desc);
    m_entry.modify_font(font_desc);
    m_textview.modify_font(font_desc);
    m_button_enter.modify_font(font_desc);

    set_border_width(4);
    m_hbox.set_border_width(8);
    m_vbox.set_border_width(8);

    m_text_buf = Gtk::TextBuffer::create();
    m_textview.set_buffer(m_text_buf);

    m_label.set_label("にゅうりょく:");
    m_entry.set_text("");

    m_button_enter.set_label("Enter");
    m_button_enter.signal_clicked().connect(
        sigc::mem_fun(*this, &MainWindow::on_button_enter)
    );

    m_hbox.pack_start(m_label, Gtk::PACK_SHRINK);
    m_hbox.pack_start(m_entry);
    m_hbox.pack_start(m_button_enter, Gtk::PACK_SHRINK);

    m_vbox.pack_start(m_textview);
    m_vbox.pack_start(m_hbox, Gtk::PACK_SHRINK);

    add(m_vbox);

    show_all_children();
    m_button_enter.set_can_default();

    set_focus(m_entry);

    std::string contents;
    contents += ch_logo;
    contents += '\n';
    add_output(contents);
} // MainWindow::MainWindow
Beispiel #24
0
static void restore_focus(WScreen *scr)
{
	WWorkspace *ws=scr->current_workspace;
	WWindow *wwin;
	
	if(ws==NULL)
		return;
	
	wwin=find_current(ws);
	if(wwin==NULL)
		return;
	
	set_focus((WThing*)wwin);
	
}
Beispiel #25
0
void goto_frame(int id)
{
	WFrame *frame;
	
	frame=find_frame_by_id(id);
	
	if(frame!=NULL){
		goto_winobj((WWinObj*)frame);

		if(!WFRAME_IS_NORMAL(frame))
			set_frame_state(frame, frame->flags&~(WFRAME_HIDDEN|WFRAME_SHADE));	
		
		if(frame->current_cwin!=NULL)
			set_focus((WThing*)frame->current_cwin);
	}
}
Beispiel #26
0
int
main(int argc, char **argv)
{
	xcb_window_t win;

	if (argc != 2 || strncmp(argv[0], "-h", 2) == 0)
		usage(argv[0]);

	init_xcb(&conn);

	win = strtoul(argv[1], NULL, 16);

	set_focus(win);

	kill_xcb(&conn);
	return 0;
}
Beispiel #27
0
static void handle_enter_window(XEvent *ev)
{
	XEnterWindowEvent *eev=&(ev->xcrossing);
	WThing *thing=NULL;
	bool inf=TRUE;
	
#if 0
	/* when enabling this check you can't change focus by moving the pointer when in command mode */
	if(grab_held())
		return;
#endif

	if(eev->mode==NotifyGrab)
		return;
	
	/*
	 * mode==NotifyUngrab events are generated en masse on XUngrab*()
	 * and are generally ignored; unfortunately a refocussing
	 * ButtonRelease usually happens in this mode too. argh.
	 */
	if(eev->mode==NotifyUngrab)
		return;

	do{
		if(eev->detail!=NotifyInferior)/* && !eev->send_event)*/
			inf=FALSE;
	}while(XCheckMaskEvent(wglobal.dpy, EnterWindowMask, ev));

	if(inf)
		return;

	if(eev->window==eev->root){
		/* Ignore root window enter */
		return;
	}
	

	thing=FIND_WINDOW_T(eev->window, WThing);
	
	if(thing==NULL)
		return;

	set_previous(thing);
	set_focus(thing);
}
Beispiel #28
0
static void goto_clientwin(WClientWin *cwin)
{
	WFrame *frame;
	int ws, x, y;
	
	if(!CWIN_HAS_FRAME(cwin))
		return;
	
	frame=CWIN_FRAME(cwin);
	
	goto_winobj((WWinObj*)frame);
	
	if(frame->current_cwin!=cwin)
		frame_switch_clientwin(frame, cwin);
	
	if(!WFRAME_IS_NORMAL(frame))
		set_frame_state(frame, frame->flags&~(WFRAME_HIDDEN|WFRAME_SHADE));	
	
	set_focus((WThing*)cwin);
}
void CL_GUIManager_Generic::on_mouse_dblclk(const CL_InputEvent &key)
{
	if (!input_enabled) return;

	// Transform from screen coordinates to GUI coordinate.
	int mouse_x = (int) key.mouse_pos.x;
	int mouse_y = (int) key.mouse_pos.y;
	owner->sig_transform_coords()(mouse_x, mouse_y);

	CL_InputEvent transformed_key = key;
	transformed_key.mouse_pos.x = mouse_x;
	transformed_key.mouse_pos.y = mouse_y;

	// Figure out what our focus component is (whom to send message):
	focus_component = find_focus_component(transformed_key);
	if (!focus_component)
		return;

	// If its a mouse click, make the clicked component get focus.
	if (focus_component->is_focusable())
		set_focus(focus_component);

	// If component is disabled, do not send event:
	if (focus_component->is_enabled() == false || focus_component->is_visible() == false)
		return;

	// Make coordinates relative to focus component.
	transformed_key.mouse_pos.x -= focus_component->get_screen_rect().left;
	transformed_key.mouse_pos.y -= focus_component->get_screen_rect().top;

	// Send input down event:
	focus_component->sig_input_down()(transformed_key);
	if (focus_component == 0) return; // component was deleted.

	transformed_key.repeat_count = 2;

	// Send mouse down event:
	focus_component->sig_mouse_dblclk()(transformed_key);
}
Beispiel #30
0
void xlui::line_edit::mouse_press_event(xlui::mouse_event &event) {
	_selection = false;

	int32_t width = 0;
	int32_t count = 0;
	xlui::string text = _text;
	uint32_t pos  = event.get_position().get_x();

	m_iCursorPos = pos;
//	xlui::string_dimension dim(_font, this);
	xlui::font_metric dim(_font);

	do {
		width = dim.get_width(text);
		m_iCursorPos = width;
		count = text.get_character_count();
		text = text.mid(0, count - 1);
		count = text.get_character_count();
	} while(pos < width && count > 0);

	if(pos < width) {
		m_iCursorPos = 0;
	} else {
		++count;
	}

	m_SelectionStart.set_x(m_iCursorPos);
	m_SelectionStart.set_y(event.get_position().get_y());

	m_iActualCursor = count;

	set_focus();

	stop_timer(m_iTimerId);
	m_iTimerId = start_timer(500);
	update();
}