Esempio n. 1
0
	virtual void OnMouseReleased(MouseCode code)
	{
		// ensure mouse capture gets released
		if (IsUseCaptureMouseEnabled())
		{
			input()->SetMouseCapture(NULL);
		}

		// make sure the button gets unselected
		SetSelected(false);
		Repaint();

		if (code == MOUSE_RIGHT)
		{
			KeyValues *kv = new KeyValues("OpenContextMenu");
			kv->SetPtr( "page", m_pPage );
			kv->SetPtr( "contextlabel", m_pContextLabel );
			PostActionSignal( kv );
		}
	}
Esempio n. 2
0
void CUIListBox::SendMessage(CUIWindow* pWnd, s16 msg, void* pData)
{
	if (m_pad->IsChild(pWnd))
	{
		switch (msg){
			case LIST_ITEM_SELECT:	
				GetMessageTarget()->SendMessage(this, LIST_ITEM_SELECT, pData);
				break;
			case LIST_ITEM_CLICKED:
				GetMessageTarget()->SendMessage(this, LIST_ITEM_CLICKED, pData);
				break;
			case LIST_ITEM_FOCUS_RECEIVED:
				if (m_bImmediateSelection)
                    SetSelected(pWnd);
				break;
		}		
	}

	CUIScrollView::SendMessage(pWnd, msg, pData);
}
Esempio n. 3
0
	BOOL CSkinTabCtrl::AddItem(LPCTSTR lpszCaption, HICON hIcon/* = 0*/)
	{
		ASSERT(m_hWnd != NULL && m_ItemCount < MAX_TABITEM - 1);
		size_t nLength;

		if ( lpszCaption && ( nLength = _tcslen(lpszCaption) ) )
		{
			m_pItems[m_ItemCount].lpszCaption = (LPTSTR)malloc( (nLength + 1) * sizeof(TCHAR) );
			_tcscpy_s( m_pItems[m_ItemCount].lpszCaption, (nLength + 1), lpszCaption );
		}
		m_pItems[m_ItemCount].hIcon = hIcon;
		int nLeft = m_ItemCount * (TABITEM_WIDTH + TABITEM_DISTANCE);
		SetRect(&m_pItems[m_ItemCount].rc, nLeft, 0, nLeft + TABITEM_WIDTH, TABITEM_HEIGHT);

		m_ItemCount++;
		if ( -1 == m_CurSelected )
			SetSelected(0);
		else
			DrawSkin(TRUE);
		return TRUE;
	}
unsigned CClanMemberItem::Process( unsigned uiMsg, WPARAM wParam, LPARAM lParam )
{
	if( !IsInside( LOWORD(lParam), HIWORD( lParam )) ) return 0;
	switch( uiMsg )
	{
	case WM_LBUTTONDOWN:
		{
			CTDialog* pDlg = g_itMGR.FindDlg( DLG_TYPE_CLAN );
			if( pDlg )
			{
				CClanDlg* pClanDlg = (CClanDlg*)pDlg;
				pClanDlg->SetSelectedMember( m_iClanPoint );
			}
			SetSelected();
		}
		return GetControlID();
	default:
		break;
	}
	return 0;
}
void
nsXFormsSwitchElement::CaseChanged(nsIDOMNode* aCase, PRBool aRemoved)
{
    if (!aCase)
        return;

    if (aRemoved) {
        if (aCase == mSelected) {
            nsXFormsUtils::DispatchEvent(mSelected, eEvent_Deselect);
            nsCOMPtr<nsIDOMElement> el(do_QueryInterface(aCase));
            Init(el);
            if (mSelected)
                nsXFormsUtils::DispatchEvent(mSelected, eEvent_Select);
        }
        return;
    }

    nsCOMPtr<nsIDOMElement> element(do_QueryInterface(aCase));
    if (!element)
        return;

    if (!mSelected) {
        Init();
        if (mSelected)
            nsXFormsUtils::DispatchEvent(mSelected, eEvent_Select);
        return;
    }

    if (!nsXFormsUtils::IsXFormsElement(aCase, NS_LITERAL_STRING("case")))
        return;

    nsCOMPtr<nsIXFormsCaseElement> caseElem(do_QueryInterface(element));
    if (caseElem) {
        PRBool selected;
        caseElem->GetInitialSelectedState(&selected);
        if (selected) {
            SetSelected(element, PR_TRUE);
        }
    }
}
Esempio n. 6
0
void GUI_ListBox::Draw(SURFHANDLE surf, RECT &drawablerect, int xoffset, int yoffset)
{

	BLITDATA blitdata;
	calculateBlitData(xoffset + rect.left, yoffset + rect.top, drawablerect, blitdata);

	//width or height == 0 indicates that the element is completely outside its
	//parents rect, so no need to draw.
	if (blitdata.width > 0 && blitdata.height > 0)
	{
		//draw background and frame
		oapiBlt(surf, src, &blitdata.tgtrect, &blitdata.srcrect, SURF_PREDEF_CK);
	}

	//find printable rect (
	RECT printableRect = _R(rect.left + xoffset + style->MarginLeft(), rect.top + yoffset + style->MarginTop(), rect.right + xoffset - scrlBarWidth - style->MarginLeft(), rect.bottom + yoffset - style->MarginBottom());

	//draw entries

	SetSelected(selected);
	int posInDrawList = 0;						//notes the position in the currently visible list as opposed to the entire list


	auto s = cState();

	for (UINT i = scrollbar->GetScrollPos(); i < s->entries.size() && int(i) < scrollbar->GetScrollPos() + nLines; ++i, ++posInDrawList)
	{
		int tgty = printableRect.top + (posInDrawList * (font->GetfHeight() + lineSpace));	
		
		if (!s->noSelect && !s->selectBox && selected == i || s->selectBox && IsHighlight(i)) 
		{
			font->Print(surf, s->entries[i], printableRect.left, tgty, printableRect, true, listJustification);
		}
		else
		{
			font->Print(surf, s->entries[i], printableRect.left, tgty, printableRect, false, listJustification);
		}
	}

}
void CGUIDialogVisualisationPresetList::SetVisualisation(CGUIVisualisationControl* vis)
{
  m_viz = vis;
  Reset();
  if (m_viz)
  {
    SetUseDetails(false);
    SetMultiSelection(false);
    SetHeading(CVariant{StringUtils::Format(g_localizeStrings.Get(13407).c_str(), m_viz->Name().c_str())});
    std::vector<std::string> presets;
    if (m_viz->GetPresetList(presets))
    {
      for (const auto& preset : presets)
      {
        CFileItem item(preset);
        item.RemoveExtension();
        Add(item);
      }
      SetSelected(m_viz->GetActivePreset());
    }
  }
}
Esempio n. 8
0
	//Fire action signal when mouse is pressed down instead  of on release.
	virtual void OnMousePressed(MouseCode code) 
	{
		// check for context menu open
		if (!IsEnabled())
			return;
		
		if (!IsMouseClickEnabled(code))
			return;
		
		if (IsUseCaptureMouseEnabled())
		{
			{
				RequestFocus();
				FireActionSignal();
				SetSelected(true);
				Repaint();
			}
			
			// lock mouse input to going to this button
			input()->SetMouseCapture(GetVPanel());
		}
	}
Esempio n. 9
0
	virtual bool IsDroppable( CUtlVector< KeyValues * >&msglist )
	{
		// It's never droppable, but should activate
		FireActionSignal();
		SetSelected(true);
		Repaint();
		if ( !GetParent() )
			return false;

		PropertySheet *sheet = IsDroppingSheet( msglist );
		if ( sheet )
		{
			return GetParent()->IsDroppable( msglist );
		}

		// Defer to active page...
		Panel *active = m_pParent->GetActivePage();
		if ( !active || !active->IsDroppable( msglist ) )
			return false;

		return active->IsDroppable( msglist );
	}
Esempio n. 10
0
void MgdFeatureInfoRenderer::ProcessMarker(LineBuffer*   lb,
                                        RS_MarkerDef& mdef,
                                        bool          allowOverpost,
                                        RS_Bounds*    bounds)
{
    if(m_pointTest && m_featurePending)
    {
        double scale_factor;
        if (mdef.units() == RS_Units_Device)
            scale_factor = m_mapScale / m_metersPerUnit;
        else
            scale_factor = 1.0 / m_metersPerUnit;

        double cx = mdef.width() * scale_factor;
        double cy = mdef.height() * scale_factor;
        double ix = mdef.insx() * cx;
        double iy = mdef.insy() * cy;
        double angleRad = mdef.rotation() * M_PI180;
        double angleCos = cos(angleRad);
        double angleSin = sin(angleRad);

        for (int i = 0; i < lb->point_count(); i++)
        {
            double ox = lb->x_coord(i), oy = lb->y_coord(i);
            double x0 = ox - ix, x1 = x0 + cx;
            double y0 = oy - iy, y1 = y0 + cy;
            double sx = m_point[0] - ox, sy = m_point[1] - oy;
            double rx = sx * angleCos + sy * angleSin;
            double ry = sy * angleCos - sx * angleSin;
            double dx = rx + ox, dy = ry + oy;

            if(dx > x0 && dx < x1 && dy > y0 && dy < y1)
            {
                SetSelected();
                break;
            }
        }
    }
}
Esempio n. 11
0
void nuiComboBox::OnSelect(const nuiEvent& rEvent)
{
  nuiWidget::SetSelected(false);

  nuiPopupMenu* pMenu = (nuiPopupMenu*)rEvent.mpUser;
  nuiTreeNode* pNode = pMenu->GetSelectedNode();

  SetSelected(pNode ? pNode : mpOldSelected);
//  if (mpOldSelected)
//    mpOldSelected->Release();
  mpOldSelected = NULL;
  if (pNode)
  {
    ValueChanged();
  }
  
  pMenu->SetTrashRemoval(true);
  InvalidateLayout();
      
  rEvent.Cancel();
  
  Focus();
}
Esempio n. 12
0
Request::FieldsDialog::ListFieldSingle::ListFieldSingle(
    PurpleRequestField *field)
    : field(field)
{
    g_assert(field);

    char *text = g_strdup_printf("%s%s",
                                 purple_request_field_is_required(field) ? "*" : "",
                                 purple_request_field_get_label(field));
    SetText(text);
    g_free(text);

    GList *list = purple_request_field_list_get_items(field);
    for (int i = 0; list; i++, list = list->next) {
        const char *text = reinterpret_cast<const char*>(list->data);
        AddOption(text);
        if (purple_request_field_list_is_selected(field, text))
            SetSelected(i);
    }

    signal_selection_changed.connect(sigc::mem_fun(this,
                                     &ListFieldSingle::OnSelectionChanged));
}
Esempio n. 13
0
//****************************************************************************
HRESULT CBCGPToolBoxPage::accSelect(long flagsSelect, VARIANT varChild)
{
	if (varChild.vt != VT_I4)
	{
		return E_INVALIDARG;
	}

	if (flagsSelect == SELFLAG_NONE || varChild.lVal == CHILDID_SELF)
	{
		return S_FALSE;
	}

	if (flagsSelect == SELFLAG_TAKEFOCUS || flagsSelect == SELFLAG_TAKESELECTION)
	{
		CBCGPToolBoxButton* pButton = GetAccChild(varChild.lVal);
		if (pButton != NULL)
		{
			SetSelected(varChild.lVal - 1);
			return S_OK;
		}
	}

	return S_FALSE;
}
Esempio n. 14
0
int ListBox::OnLButtonUp(int x, int y)
{
    if (captured) {
        mouse_x = x-rect.x;
        mouse_y = y-rect.y;

        if (dragging) {
            if (mouse_x < 0 || mouse_x > rect.w || mouse_y < 0 || mouse_y > rect.h) {
                FormWindow* parent_form = (FormWindow*) form;

                if (parent_form) {
                    ActiveWindow* drop_target = parent_form->FindControl(x,y);

                    if (drop_target && drop_target->IsEnabled() && drop_target->IsShown())
                    drop_target->OnDragDrop(x,y,this);
                }
            }
        }
        else if (preselected) {
            if (multiselect && Keyboard::KeyDown(VK_SHIFT)) {
                SetSelected(list_index, false);
                Button::PlaySound(Button::SND_LIST_SELECT);
            }
        }

        ReleaseCapture();
        captured = false;

        Mouse::SetCursor((Mouse::CURSOR) old_cursor);
    }

    dragging    = false;
    selecting   = false;

    return ActiveWindow::OnLButtonUp(x,y);
}
Esempio n. 15
0
void CGUIDialogSelect::SetSelected(std::vector<int> selectedIndexes)
{
  for (auto i : selectedIndexes)
    SetSelected(i);
}
Esempio n. 16
0
	bool PopupMenu::EventKey( cevent_key* pEvent )
	{
		if ( sub.ptr() && sub->EventKey( pEvent ) ) { return true; }

		if ( pEvent->Type() == EV_KEYDOWN )
		{
			int i;

			switch ( pEvent->Key() )
			{
				case VK_DOWN:
					for ( i = ( selected >= 0 && selected + 1 < list.count() ) ? selected + 1 : 0; i < list.count(); i++ )
					{
						if ( !IsSplit( i ) )
						{
							SetSelected( i );
							return true;
						}
					}

					break;

				case  VK_UP:
					for ( i = ( selected > 0 ) ? selected - 1 : list.count() - 1; i >= 0; i-- )
					{
						if ( !IsSplit( i ) )
						{
							SetSelected( i );
							return true;
						}
					}

					break;


				case VK_RIGHT:
					if ( OpenSubmenu() ) { return true; };

					break;

				//case VK_LEFT:
				// return false; // to prevent grabbing default case

				case VK_NUMPAD_RETURN:
				case VK_RETURN:
					if ( IsCmd( selected ) && IsEnabled( selected ) )
					{
						int id = list[selected].data->id;

						if ( IsModal() )
						{
							EndModal( id );
						}
						else if ( Parent() )
						{
							Parent()->Command( id, 0, this, 0 );
						}

						return true;
					}

					return OpenSubmenu();

				case VK_ESCAPE:
					if ( IsModal() )
					{
						EndModal( 0 );
					}
					else if ( Parent() )
					{
						Parent()->Command( CMD_MENU_INFO, SCMD_MENU_CANCEL, this, 0 );
					}
					else {/* Botva */}

					return true;

				default:
				{
					// check if hotkey matches, and process
					// XXX: pEvent->Key() returns key (like Shift-F1, etc). isHotkeyMatching() expects unicode char, which is not the same
					unicode_t c = UnicodeUC( pEvent->Char() );

					for ( int i = 0; i < list.count(); i++ )
					{
						MenuData::Node* node = list[i].data;

						if ( node->leftText.isHotkeyMatching( c ) )
						{
							if ( node->id != 0 ) // menu command
							{
								if ( Parent() )
								{
									Parent()->Command( node->id, 0, this, 0 );
								}

								return true;
							}
							else // sumbenu
							{
								SetSelected( i );
								OpenSubmenu();
								return true;
							}
						}
					}

					return false;
				}

			}
		}

		return false;
	}
Esempio n. 17
0
	bool PopupMenu::EventMouse( cevent_mouse* pEvent )
	{
		int N = -1;
		cpoint point = pEvent->Point();

		for ( int i = 0; i < list.count(); i++ )
		{
			crect* pr = &( list[i].rect );

			if ( point.x >= pr->left && point.x < pr->right && point.y >= pr->top && point.y < pr->bottom )
			{
				N = i;
				break;
			}
		}

		switch ( pEvent->Type() )
		{
			case EV_MOUSE_MOVE:
				if ( N < 0 )
				{
					if ( !sub.ptr() ) { return false; }

					crect rect = ScreenRect();
					crect sr = sub->ScreenRect();
					pEvent->Point().x += rect.left - sr.left;
					pEvent->Point().y += rect.top - sr.top;
					return sub->EventMouse( pEvent );
				}

				if ( SetSelected( N ) )
				{
					if ( this->IsSub( selected ) && IsEnabled( selected ) )
					{
						OpenSubmenu();
					}
				}

				return true;


			case EV_MOUSE_PRESS:
				if ( N < 0 )
				{
					if ( sub.ptr() )
					{
						crect rect = ScreenRect();
						crect sr = sub->ScreenRect();
						pEvent->Point().x += rect.left - sr.left;
						pEvent->Point().y += rect.top - sr.top;

						if ( sub->EventMouse( pEvent ) ) { return true; }
					}

					if ( IsModal() )
					{
						EndModal( 0 );
					}
					else if ( Parent() ) { Parent()->Command( CMD_MENU_INFO, SCMD_MENU_CANCEL, this, 0 ); }

					return true;
				}

				if ( SetSelected( N ) )
				{
					if ( IsCmd( selected ) && IsEnabled( selected ) )
					{
						int id = list[N].data->id;

						if ( IsModal() ) { EndModal( id ); }
						else if ( Parent() ) { Parent()->Command( id, 0, this, 0 ); }
					}
					else
					{
						OpenSubmenu();
					}
				}

				return true;
		}

		return false;
	}
Esempio n. 18
0
void					SeqTrack::SelectTrack()
{
  SeqPanel->UnselectTracks();
  SetSelected(true);
}
Esempio n. 19
0
//Select a specific frame
void WidgetSpriteFrameView::SetSelected(WidgetSpriteFrameView_Frame* frame)
{
    SetSelected(frames.indexOf(frame));
}
Esempio n. 20
0
void PluginPanel::OnPluginSelected( wxMouseEvent &event )
{
      SetSelected( true );
      m_PluginListPanel->SelectPlugin( this );
}
Esempio n. 21
0
bool CEvent::SetAttribute( enum E_EventAttribute inAttr, int32 inValue )
{
	uint8		cmd = Command();

	switch (inAttr) {
	case EvAttr_StartTime:					// start time
		SetStart( inValue );
		return true;

	case EvAttr_Duration:						// event duration
		if (HasProperty( Prop_Duration ))
		{
			SetDuration(1 > inValue ? 1 : inValue);
			return true;
		}
		return false;
	
	case EvAttr_StopTime:						// event stop time
		return false;						// Can't set stop -- must set duration

	case EvAttr_Type:						// event type
		SetCommand( CLAMP( EvtType_End, inValue, EvtType_Count - 1 ) );
		return true;

	case EvAttr_Selected:						// Whether it's selected or not
		SetSelected( inValue != 0 );
		return true;
	
	case EvAttr_Channel:						// virtual channel number
		if (HasProperty( Prop_Channel ))
			SetVChannel( CLAMP( 0L, inValue, Max_Destinations ) );
		return true;
	
	case EvAttr_Pitch:						// pitch attribute
		if (	cmd == EvtType_Note || cmd == EvtType_NoteOff)
		{
			note.pitch = CLAMP( 0L, inValue, 127 );
			return true;
		}
		else if (cmd == EvtType_PolyATouch)
		{
			aTouch.pitch = CLAMP( 0L, inValue, 127 );
			return true;
		}
		else return false;

	case EvAttr_AttackVelocity:				// attack velocity
		if (	cmd == EvtType_Note || cmd == EvtType_NoteOff)
		{
			note.attackVelocity = CLAMP( 1L, inValue, 127 );
	
			return true;
		}
		else return false;

	case EvAttr_ReleaseVelocity:				// release velocity
		if (	cmd == EvtType_Note || cmd == EvtType_NoteOff)
		{
			note.releaseVelocity = CLAMP( 0L, inValue, 127 );
			return true;
		}
		else return false;

	case EvAttr_AfterTouch:					// aftertouch value
		if (	cmd == EvtType_PolyATouch)
		{
			aTouch.value = CLAMP( 0L, inValue, 127 );
			return true;
		}
		else return false;

	case EvAttr_Program:						// program number attribute
		if (	cmd == EvtType_ProgramChange)
		{
			programChange.program = CLAMP( 0L, inValue, 127 );
			return true;
		}
		return false;

	case EvAttr_ProgramBank:					// program bank number
		if (	cmd == EvtType_ProgramChange)
		{
			inValue = CLAMP( 0L, inValue, 0x3fff );
			programChange.bankMSB = inValue >> 7;
			programChange.bankLSB = inValue & 0x7f;
			return true;
		}
		return false;

	case EvAttr_VPos:						// arbitrary vertical position
		if (HasProperty( Prop_VertPos )) repeat.vPos = CLAMP( 0L, inValue, 63 );
		return false;

	case EvAttr_ControllerNumber:				// controller number
		if (cmd == EvtType_Controller)
		{
			controlChange.controller = CLAMP( 0L, inValue, 127 );
		}
		return false;

	case EvAttr_ControllerValue8:				// 8-bit controller value
		if (cmd == EvtType_Controller)
		{
			controlChange.MSB = CLAMP( 0L, inValue, 127 );
			controlChange.LSB = 0;
		}
		return false;

	case EvAttr_ControllerValue16:			// 16-bit controller value
		if (	cmd == EvtType_Controller)
		{
			inValue = CLAMP( 0L, inValue, 0x3fff );
			controlChange.MSB = inValue >> 7;
			controlChange.LSB = inValue & 0x7f;
			return true;
		}
Esempio n. 22
0
File: event.c Progetto: dawik/aok
void Event(SDL_Event* event)
{
	int mousePosition[2], selected_unit;
	static int keytaps = 0; // Något slags fulhax
    if(drawconsole){
        char legal[] = "abcdefghijklmnopqrstuvwxyzåäö1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ,.-;:_*^~!¤%&/()=?+\\<>|øæ ";
        if(event->type == SDL_KEYUP){
            if(event->key.keysym.sym == SDLK_RETURN){
                if(strlen(console)>0){
                    char buff[PACKETSIZE];
                    strncpy(buff, console ,PACKETSIZE);
                    cmdsend(1,0,client_id,console,NULL);
                }
                drawconsole = false;
                int i;
                for(i=0; i<MESSAGESIZE; i++) console[i] = '\0';
                keytaps=0;
                if(DEBUG) fprintf(stderr,"Chat toggle = FALSE\n");
            }
        } else if(event->type == SDL_KEYDOWN) {
            if(event->key.keysym.sym == SDLK_BACKSPACE){
                int len = strlen(console);
                if(keytaps>0) keytaps--;
                console[len-1 > 0 ? len-1 : 0] = '\0';
            } else {
                int i;
                if(strlen(console)+1 < MESSAGESIZE){
                    for(i=0; i<strlen(legal); i++){
                        if(legal[i] == event->key.keysym.unicode){
                            console[keytaps] = event->key.keysym.unicode;
                            keytaps++;
                            break;
                        }
                    }
                }
            }
        }
    }
    else if(mapmakerOpen) mmEvent(event);
    else if(menuOpen) menuEvent(event);
    else if(startMenuOpen) startMenuEvent(event);
    else //In-game
    {
        switch (event->type)
        {
            case SDL_QUIT:
                running = false;
                break;
            case SDL_KEYDOWN:
                switch (event->key.keysym.sym)
                {
                    case SDLK_ESCAPE:
                        running = false;
                        break;
                    case SDLK_q:
                        running = false;
                        break;
                    case SDLK_F10:
                        offsetflag[0] = 0;
                        offsetflag[1] = 0;
                        altDown = false;
                        tabDown = false;
                        menuOpen = true;
                        break;
                    case SDLK_CAPSLOCK:
                        capsActive = true;
                        break;
                    case SDLK_LEFT:
                        offsetflag[0]=-1;
                        break;
                    case SDLK_RIGHT:
                        offsetflag[0]=1;
                        break;
                    case SDLK_DOWN:
                        offsetflag[1]=1;
                        break;
                    case SDLK_UP:
                        offsetflag[1]=-1;
                        break;
                    case SDLK_m:
                        PlayGameSound(MUSIC);
                        break;
                    case SDLK_LSHIFT:
                    case SDLK_RSHIFT:
                        shiftDown = true;
                        if(DEBUG) fprintf(stderr,"Shift Down\n");
                        break;
                    case SDLK_LALT:
                        altDown = true;
                        if(DEBUG) fprintf(stderr,"Alt Down\n");
                        break;
                    case SDLK_LCTRL:
                    case SDLK_RCTRL:
                        ctrlDown = true;
                        if(DEBUG) fprintf(stderr,"Ctrl Down\n");
                        break;
                    case SDLK_TAB:
                        cmdsend(80,client_id,0," "," ");
                        tabDown = true;
                        if(DEBUG) fprintf(stderr,"TAB Down\n");
                        break;
                    case SDLK_0: //Handles control groups
                    case SDLK_1:
                    case SDLK_2:
                    case SDLK_3:
                    case SDLK_4:
                    case SDLK_5:
                    case SDLK_6:
                    case SDLK_7:
                    case SDLK_8:
                    case SDLK_9:
                        if(ctrlDown)
                        {
                            SetControlGroup(event->key.keysym.sym-48);
                            if(DEBUG)fprintf(stderr,"Setting control group: %i\n",event->key.keysym.sym-48);
                        }
                        else
                        {
                            GetControlGroup(event->key.keysym.sym-48);
                            if(DEBUG)fprintf(stderr,"Getting control group: %i\n",event->key.keysym.sym-48);
                        }
                        break;
                    default:
                        break;
                }
                break;
            case SDL_KEYUP:
                switch (event->key.keysym.sym)
                {
                    case SDLK_RETURN:
                        drawconsole = true;
                        fprintf(stderr, "Chat toggle = TRUE\n");
                        break;
                    case SDLK_LEFT:
                        if(offsetflag[0] == -1) offsetflag[0]=0;
                        break;
                    case SDLK_RIGHT:
                        if(offsetflag[0] == 1) offsetflag[0]=0;
                        break;
                    case SDLK_DOWN:
                        if(offsetflag[1] == 1) offsetflag[1]=0;
                        break;
                    case SDLK_UP:
                        if(offsetflag[1] == -1) offsetflag[1]=0;
                        break;
                    case SDLK_LSHIFT:
                    case SDLK_RSHIFT:
                        shiftDown = false;
                        if(DEBUG) fprintf(stderr,"Shift Up\n");
                        break;
                    case SDLK_LALT:
                        altDown = false;
                        if(DEBUG) fprintf(stderr,"Alt Up\n");
                        break;
                    case SDLK_LCTRL:
                    case SDLK_RCTRL:
                        ctrlDown = false;
                        if(DEBUG) fprintf(stderr,"Ctrl Up\n");
                        break;
                    case SDLK_TAB:
                        tabDown = false;
                        if(DEBUG) fprintf(stderr,"TAB Up\n");
                        break;
                    case SDLK_CAPSLOCK:
                        capsActive = false;
                        break;
                    default:
                        break;
                }
                break;
            case SDL_MOUSEMOTION:
                SDL_GetMouseState(&mousePosition[0],&mousePosition[1]);
                if(   mousePosition[0] < 5 || mousePosition[0] > WINDOWWIDTH-5 //Checks if mouse is close to the screen borders
                   || mousePosition[1] < 5 || mousePosition[1] > WINDOWHEIGHT-5)
                {
                    if(mousePosition[0] < 5) offsetflagmouse[0] = -1; //Sets offset flags according to mouse position
                    if(mousePosition[0] > WINDOWWIDTH-5) offsetflagmouse[0] = 1;
                    if(mousePosition[1] < 5) offsetflagmouse[1] = -1;
                    if(mousePosition[1] > WINDOWHEIGHT-5) offsetflagmouse[1] = 1;
                }
                else //Sets offset flags to 0 if mouse is not close to the borders
                {
                    offsetflagmouse[0] = 0;
                    offsetflagmouse[1] = 0;
                }
                if(scrollDown)
                {
                    SDL_GetMouseState(&mousePosition[0],&mousePosition[1]);
                    if(mousePosition[0] > scrollDownStart[0] + 10) offsetflagscroll[0] = 1;
                    if(mousePosition[0] < scrollDownStart[0] - 10) offsetflagscroll[0] = -1;
                    if(mousePosition[1] > scrollDownStart[1] + 10) offsetflagscroll[1] = 1;
                    if(mousePosition[1] < scrollDownStart[1] - 10) offsetflagscroll[1] = -1;
                }

                if(leftMouseDown)
                {
                    boxEnd[0] = mousePosition[0]+offset[0]*TILEDIAGONAL;
                    boxEnd[1] = mousePosition[1]+offset[1]*TILEDIAGONAL/2;
                }
                break;
            case SDL_MOUSEBUTTONDOWN:
                {
                    SDL_GetMouseState(&mousePosition[0],&mousePosition[1]);
                    switch (event->button.button)
                    {
                        case SDL_BUTTON_LEFT:
                            if(showEndgameStatus) showEndgameStatus = false;
                            lastSelectedGroup = -1;
                            if(mousePosition[1] < WINDOWHEIGHT-HUD_HEIGHT) //If the mouse is within the game area
                            {
                                SetSelected(mousePosition);
                                SDL_GetMouseState(&mousePosition[0],&mousePosition[1]);
                                boxStart[0] = mousePosition[0]+offset[0]*TILEDIAGONAL;
                                boxStart[1] = mousePosition[1]+offset[1]*TILEDIAGONAL/2;
                                boxEnd[0] = boxStart[0]; //Prevents graphical errors
                                boxEnd[1] = boxStart[1];
                                leftMouseDown = true;
                            }
                            else
                            {
                                hudClick = true;
                                ClickHUDButton(mousePosition);
                            }
                            break;
                        case SDL_BUTTON_RIGHT:
                            if(mousePosition[1] < WINDOWHEIGHT-HUD_HEIGHT) { //If the mouse is within the game area
                                //fprintf(stdout,"RIGHTCLICK\n");
                                selected_unit = SetTarget(mousePosition);
                                SDL_GetMouseState(&mousePosition[0],&mousePosition[1]); //New mouse coordinates as SetTarget manipulates them
                                SendUnits(mousePosition,selected_unit);
/*                                if ( selected_unit == -1 )//Tries to set target
                                {
                                    if ( SetDestination(mousePosition) == true  ) //Only set destination if target set failed
                                    {
                                        if(DEBUG) fprintf(stdout,"Sending selected unit(s) to %i,%i\n",mousePosition[0],mousePosition[1]);
                                    }
                                }
                                else if (unit[selected_unit].owner == client_id) {
                                fprintf(stdout,"Following unit %i\n",selected_unit);
                                }
                                else if (unit[selected_unit].owner != client_id) {
                                fprintf(stdout,"Attacking unit %i\n",selected_unit);
                                }*/
                            }
                            break;
                        case SDL_BUTTON_WHEELUP:
                            zoomSchedueled += 1;
                            break;
                        case SDL_BUTTON_WHEELDOWN:
                            zoomSchedueled -= 1;
                            break;
                        case SDL_BUTTON_MIDDLE:
                            scrollDown = true;
                            SDL_GetMouseState(&scrollDownStart[0],&scrollDownStart[1]);
                            if(DEBUG) fprintf(stderr,"Middle mouse button Down\n");
                            break;
                    }
                }
                break;
            case SDL_MOUSEBUTTONUP:
                {
                    switch (event->button.button)
                    {
                        case SDL_BUTTON_LEFT:
                            if(hudClick)
                            {
                                hudClick = false;
                                break;
                            }
                            leftMouseDown = false;
                            int temp;
                            SDL_GetMouseState(&mousePosition[0],&mousePosition[1]);
                            boxEnd[0] = mousePosition[0]+offset[0]*TILEDIAGONAL;
                            boxEnd[1] = mousePosition[1]+offset[1]*TILEDIAGONAL/2;
                            boxDiff[0] = boxStart[0] - boxEnd[0];
                            boxDiff[1] = boxStart[1] - boxEnd[1];
                            if(boxDiff[0] < 0)
                            {
                                boxDiff[0] *= -1;
                            }
                            else
                            {
                                temp = boxStart[0];
                                boxStart[0] = boxEnd[0];
                                boxEnd[0] = temp;
                            }
                            if(boxDiff[1] < 0)
                            {
                                boxDiff[1] *= -1;
                            }
                            else
                            {
                                temp = boxStart[1];
                                boxStart[1] = boxEnd[1];
                                boxEnd[1] = temp;
                            }
                            if(boxDiff[0] > BOX_LIMIT || boxDiff[1] > BOX_LIMIT) SetSelectedGroup(); //Only use the SetSelectedGroup function if the box is large enough
                            break;
                        case SDL_BUTTON_MIDDLE:
                            scrollDown = false;
                            offsetflagscroll[0] = 0;
                            offsetflagscroll[1] = 0;
                            if(DEBUG) fprintf(stderr,"Middle mouse button Up\n");
                            break;
                    }
                }
                break;
            }
        }
}
Esempio n. 23
0
void CUIListBox::SetSelectedText(LPCSTR txt)
{
	SetSelected(GetItemByText(txt));
}
Esempio n. 24
0
ENDDISPATCH

/*	TTreeView::DoKeyEvent
 *
 *		Tree event
 */

long TTreeView::DoKeyEvent(long arg, void *)
{
	TreeEventRecord tevent;
	TableDrawRecord tr;
	short i;
	short mods;
	short key;
	uint32 item;
	
	key = GETLOWORD(arg);
	mods = GETHIWORD(arg);
	
	if (mods & KSpecialKey) {
		/*
		 *	Scan for the various arrow keys
		 */
		
		switch (key) {
			case KKeyUpCursor:
				if (fLength <= 0) return 0;
				for (i = 0; i < fLength; ++i) {
					fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
					if (tr.entry->fSelected) {
						--i;
						break;
					}
				}
				if (i >= fLength || i < 0) i = 0;
				fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
				if (!(mods & KKeyShift)) {
					ClearSelection();
				}
				SetSelected((uint32)tr.entry,true);
				tevent.child = (uint32)tr.entry;
				DoDispatch(KEventTreeClick,GetViewID(),(void *)&tevent);
				return 0;
			case KKeyDownCursor:
				if (fLength <= 0) return 0;
				for (i = fLength - 1; i >= 0; --i) {
					fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
					if (tr.entry->fSelected) {
						++i;
						break;
					}
				}
				if (i >= fLength || i < 0) i = fLength - 1;
				fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
				if (!(mods & KKeyShift)) {
					ClearSelection();
				}
				SetSelected((uint32)tr.entry,true);
				tevent.child = (uint32)tr.entry;
				DoDispatch(KEventTreeClick,GetViewID(),(void *)&tevent);
				return 0;
			case KKeyLeftCursor:
				if (fSelectedCount == 1) {
					item = 0;
					if (fSelection->fOpen) {
						item = (uint32)fSelection;
					} else {
						item = (uint32)(fSelection->parent);
					}
					
					if (item) {
						OpenItem( item, false );
						SetSelection( item );
						
						tevent.child = item;
						DoDispatch(KEventTreeClick,GetViewID(),(void *)&tevent);
					}
				}
				return 0;
			case KKeyRightCursor:
				if (fSelectedCount == 1) {
					item = (uint32)(fSelection->child);
					if (item) {
						OpenItem( (uint32)fSelection, true );
						SetSelection( item );
						
						tevent.child = item;
						DoDispatch(KEventTreeClick,GetViewID(),(void *)&tevent);
					}
				}
				return 0;
			default:
				return -1;
		}
	} else {
		/*
		 *	Scan for the regular keys
		 */
		
#if 0
		if (key == 0x0D) {
			/*
			 *	Enter key == double-click
			 */
			
			if (fSelect != NULL) {
				tevent.child = (uint32)fSelect;
				DoDispatch(KEventTreeDoubleClick,GetViewID(),(void *)&tevent);
			}
			return 0;
		} else if (key == ' ') {
			/*
			 *	Space key == open/close item
			 */
			
			if (fSelect) {
				OpenItem((uint32)fSelect,!(fSelect->fOpen));
				return 0;
			}
		}
#endif
		return -1;
	}
}
Esempio n. 25
0
void CGUIDialogSelect::SetSelected(const std::vector<std::string> &selectedLabels)
{
  for (const auto& label : selectedLabels)
    SetSelected(label);
}
Esempio n. 26
0
/*--------------------------------------------------------------------------*/
SIGNED PegCheckBox::Message(const PegMessage &Mesg)
{
    switch(Mesg.wType)
    {
    case PM_LBUTTONDOWN:
        if (mwStyle & AF_ENABLED)
        {
            CapturePointer();
        }
        break;

    case PM_LBUTTONUP:
        if (StatusIs(PSF_OWNS_POINTER))
        {
            if (mReal.Contains(Mesg.Point))
            {
                if (mwStyle & BF_SELECTED)
                {
                    SetSelected(FALSE);
                }
                else
                {
                    SetSelected(TRUE);
                }
            }
            ReleasePointer();
        }
        break;

    case PM_POINTER_MOVE:
    case PM_POINTER_EXIT:
        break;

   #ifdef PEG_KEYBOARD_SUPPORT

    case PM_KEY:
        if ((Mesg.iData == PK_CR || Mesg.iData == PK_SPACE) &&
            (mwStyle & AF_ENABLED))
        {
            if (!(mwStyle & BF_SELECTED))
            {
                SetSelected(TRUE);
            }
            else
            {
                SetSelected(FALSE);
            }
        }
        else
        {
            PegThing::Message(Mesg);
        }
        break;

    case PM_KEY_RELEASE:
        if (Mesg.iData == PK_CR)
        {
            break;
        }
        else
        {
            PegThing::Message(Mesg);
        }
        break;
   #endif

    default:
        PegButton::Message(Mesg);
        break;
    }
    return(0);
}
Esempio n. 27
0
bool TTreeView::DoMouseDown(Point where, short flags)
{
	XRect r,t;
	long len;
	long x,y;
	long h;
	long i;
	short lh,lt;
	short it;
	TableDrawRecord tr;
	short at;
	TreeEventRecord tevent;
	
	XGDraw draw(this);
	draw.SetFont(XGFont::LoadFont(1));
	if (!fDrawFlag) EnableDrawing();
	SetFocus();

	tevent.ev_flags = flags;
	
	/*
	 *	Get the drawing parameters so I know where these are
	 */
	
	r = GetContentRect();
	GetScrollParams(&x,&y,&h);
	x *= h;
	
	len = (r.bottom - r.top + h - 1) / h;
	len += y;
	if (len > fLength) len = fLength;
	
	lh = draw.GetFontHeight();			// lh == line height
	lt = (h-1-lh)/2;					// lt == line top (of label)
	it = (h-17)/2;						// it == icon top (for 16x16 icon)
	at = (h-13)/2;						// at == arrow top
	
	/*
	 *	Iterate through buttons
	 */
	
	for (i = y; i < len; i++) {
		fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
		if (1 || tr.inset > 0) {
			
			if (tr.entry->child || tr.entry->fChildDefer) {
				t.top = (i - y) * h + at;
				t.left = 22 * (tr.inset) - x + 2;

				t.bottom = t.top + 12;
				t.right = t.left + 12;
				if (PtInRect(where,&t)) {
					/*
					 *	Clicked on open icon.
					 */
					
					if (tr.entry->child == NULL) {
						/*
						 *	Defer open--dispatch event to give the
						 *	app a chance to fill in the children
						 */
						
						tevent.child = (uint32)tr.entry;
						DoDispatch(KEventTreeOpen,GetViewID(),(void *)&tevent);
					}
					tr.entry->fOpen = !(tr.entry->fOpen);
					Update();
					return false;
				}
			}
		}	
	}

	/*
	 *	Iterate through text.
	 */
	
	for (i = y; i < len; i++) {
		char buffer[256];
		
		fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
		GetItemData( (uint32)tr.entry, buffer, sizeof(buffer)-1 );
		
		r.top = (i - y) * h;
		r.bottom = r.top + h;
		r.left = 22 * (tr.inset+1) - x;
		r.right = r.left + draw.StringWidth(buffer) + 6;
		if (tr.entry->icon) r.right += 16;
		if (PtInRect(where,&r)) {
			/*
			 *	Clicked on an object
			 */
			
			fDrawList.GetMemory(i*sizeof(tr),sizeof(tr),&tr);
			tevent.child = (uint32)tr.entry;
			if (flags & KKeyShift) {
				SetSelected((uint32)tr.entry, !tr.entry->fSelected);
			} else {
				SetSelection((uint32)tr.entry);
			}
			if (flags & KDoubleClick) {
				/*
				 *	We double-clicked on this object
				 */
				
				DoDispatch(KEventTreeDoubleClick,GetViewID(),(void *)&tevent);
			} else {
				/*
				 *	We single-clicked here
				 */
				 
				DoDispatch(KEventTreeClick,GetViewID(),(void *)&tevent);
				
				if ((tr.entry->dragID) && XGDragger::Wait(this,where)) {
					/*
					 *	Should I drag?
					 */
					
					TreeDragRecord tdr;
					
					tdr.tree = this;
					tdr.dragID = (uint32)tr.entry;
					if (0 == DoDispatch(KEventTreeStartDrag,GetViewID(),(void *)&tdr)) {
						return false;
					}
					
					/*
					 *	Drag this one item
					 */
					 
					if ((tr.entry->dragSize.h != -1) && (tr.entry->dragSize.v != -1)) {
						r.left = where.h;
						r.top = where.v;
						r.right = r.left + tr.entry->dragSize.h;
						r.bottom = r.top + tr.entry->dragSize.v;
					}
					
					XGDragger drag(this,tr.entry->fInternDrag);
					
					/*char buffer[256];
					short len;
					len = fData.GetData(tr.entry->dragData,sizeof(buffer),buffer);
					
					drag.AddObject(1,tr.entry->dragID,buffer,len,&r);*/
					char buffer[256];
					int len = GetExtraData((uint32)tr.entry, buffer, sizeof(buffer));
					
					drag.AddObject(1,tr.entry->dragID, buffer, len, &r);
					drag.Track();
				}
			}
			
			return false;
		}
	}
	
	/*
	 *	If we get here, we didn't click on anything. Clear selection
	 */
	
	ClearSelection();
	tevent.child = NULL;
	DoDispatch(KEventTreeClick,GetViewID(),(void *)&tevent);
	return false;
}
Esempio n. 28
0
void CUIListBox::SetSelectedIDX(u32 idx)
{
	SetSelected(GetItemByIDX(idx));
}
Esempio n. 29
0
static BOOL HandleReq( struct AHIAudioModeRequesterExt *req )

// Returns FALSE if requester was cancelled

{
  BOOL done=FALSE,rc=TRUE;
  ULONG class,sec,oldsec=0,micro,oldmicro=0,oldid=AHI_INVALID_ID;
  UWORD code;
  UWORD qual;
  struct Gadget *pgsel;
  struct IntuiMessage *imsg;
  struct IDnode *idnode;
  LONG   sliderlevels,sliderlevel,i,selected;
  struct MenuItem *item;

  while(!done)
  {
    Wait(1L << req->Window->UserPort->mp_SigBit);

    while ((imsg=GT_GetIMsg(req->Window->UserPort)) != NULL )
    {

      if(imsg->IDCMPWindow == req->InfoWindow)
      {
        class = imsg->Class;
        GT_ReplyIMsg(imsg);

        switch(class)
        {
        case IDCMP_CLOSEWINDOW:
          CloseInfoWindow(req);
          break;
        case IDCMP_REFRESHWINDOW :
          GT_BeginRefresh(req->InfoWindow);
          GT_EndRefresh(req->InfoWindow,TRUE);
          break;
        }
        continue; // Get next IntuiMessage
      }

      else if(imsg->IDCMPWindow != req->Window) // Not my window!
      {
        if(req->IntuiMsgFunc)
          CallHookPkt(req->IntuiMsgFunc,req,imsg);
        // else what to do??? Reply and forget? FIXIT!
        continue;
      }

      sec=imsg->Seconds;
      micro=imsg->Micros;
      qual=imsg->Qualifier;
      class=imsg->Class;
      code=imsg->Code;
      pgsel=(struct Gadget *)imsg->IAddress; // pgsel illegal if not gadget
      GT_ReplyIMsg(imsg);

      switch ( class )
      {
      case IDCMP_RAWKEY:
        switch (code)
        {
        case 0x4c: // Cursor Up
          selected=GetSelected(req);
          if(selected == ~0)
            selected=0;
          if(selected > 0)
            selected--;
          idnode=(struct IDnode *)req->list->mlh_Head;
          for(i=0;i<selected;i++)
            idnode=(struct IDnode *)idnode->node.ln_Succ;
          req->tempAudioID=idnode->ID;
          SetSelected(req,TRUE);
          break;
        case 0x4d: // Cursor Down
          selected=GetSelected(req);
          selected++; // ~0 => 0
          idnode=(struct IDnode *)req->list->mlh_Head;
          for(i=0;i<selected;i++)
            if(idnode->node.ln_Succ->ln_Succ)
              idnode=(struct IDnode *)idnode->node.ln_Succ;
          req->tempAudioID=idnode->ID;
          SetSelected(req,TRUE);
          break;
        case 0x4e: // Cursor Right
          GetSliderAttrs(req,&sliderlevels,&sliderlevel);
          sliderlevel += (qual & (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT) ? 10 :1);
          if(sliderlevel >= sliderlevels)
            sliderlevel=sliderlevels-1;
          AHI_GetAudioAttrs(req->tempAudioID, NULL,
              AHIDB_FrequencyArg,sliderlevel,
              AHIDB_Frequency, (ULONG) &req->tempFrequency,
              TAG_DONE);
          SetSelected(req,FALSE);
          break;
        case 0x4f: // Cursor Left
          GetSliderAttrs(req,&sliderlevels,&sliderlevel);
          sliderlevel -= (qual & (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT) ? 10 :1);
          if(sliderlevel < 0)
            sliderlevel=0;
          AHI_GetAudioAttrs(req->tempAudioID, NULL,
              AHIDB_FrequencyArg,sliderlevel,
              AHIDB_Frequency, (ULONG) &req->tempFrequency,
              TAG_DONE);
          SetSelected(req,FALSE);
          break;
        }
        break;
      case IDCMP_GADGETUP :
        switch ( pgsel->GadgetID )
        {
        case OKBUTTON:
          done=TRUE;
          break;
        case CANCELBUTTON:
          done=TRUE;
          rc=FALSE;
          break;
        case FREQSLIDER:
          AHI_GetAudioAttrs(req->tempAudioID, NULL,
              AHIDB_FrequencyArg,code,
              AHIDB_Frequency, (ULONG) &req->tempFrequency,
              TAG_DONE);
          break;
        case LISTVIEW:
          idnode=(struct IDnode *)req->list->mlh_Head;
          for(i=0;i<code;i++)
            idnode=(struct IDnode *)idnode->node.ln_Succ;
          req->tempAudioID=idnode->ID;
          SetSelected(req,FALSE);
          // Test doubleclick and save timestamp
          if( (oldid == req->tempAudioID) && DoubleClick(oldsec,oldmicro,sec,micro))
            done=TRUE;
          oldsec=sec;
          oldmicro=micro;
          oldid=req->tempAudioID;

          break;
        }
        break;

      case IDCMP_NEWSIZE:
        if(!(LayOutReq(req,req->TextAttr)))
          if(!(LayOutReq(req,&Topaz80)))
          {
            // ERROR! Quit.
            done=TRUE;
            break;
          }
        break;
      case IDCMP_CLOSEWINDOW:
        done=TRUE;
        rc=FALSE;
        break;
      case IDCMP_REFRESHWINDOW :
        GT_BeginRefresh(req->Window);
        GT_EndRefresh(req->Window,TRUE);
        break;
      case IDCMP_SIZEVERIFY:
        break;
      case IDCMP_MENUPICK:
        while((code != MENUNULL) && !done)
        {
          item=ItemAddress(req->Menu, code);
          switch((ULONG)GTMENUITEM_USERDATA(item))
          {
          case LASTMODEITEM:
            selected=GetSelected(req);
            if(selected == ~0)
              selected=0;
            if(selected > 0)
              selected--;
            idnode=(struct IDnode *)req->list->mlh_Head;
            for(i=0;i<selected;i++)
              idnode=(struct IDnode *)idnode->node.ln_Succ;
            req->tempAudioID=idnode->ID;
            SetSelected(req,TRUE);
            break;
          case NEXTMODEITEM:
            selected=GetSelected(req);
            selected++; // ~0 => 0
            idnode=(struct IDnode *)req->list->mlh_Head;
            for(i=0;i<selected;i++)
              if(idnode->node.ln_Succ->ln_Succ)
                idnode=(struct IDnode *)idnode->node.ln_Succ;
            req->tempAudioID=idnode->ID;
            SetSelected(req,TRUE);
            break;
          case PROPERTYITEM:
            OpenInfoWindow(req);
            break;
          case RESTOREITEM:
            req->tempAudioID=req->Req.ahiam_AudioID;
            req->tempFrequency=req->Req.ahiam_MixFreq;
            SetSelected(req,TRUE);
            break;
          case OKITEM:
            done=TRUE;
            break;
          case CANCELITEM:
            done=TRUE;
            rc=FALSE;
            break;
          }
          code = item->NextSelect;
        }
        break;
      }
    }
  }
Esempio n. 30
0
void CUIListBox::SetSelectedTAG(u32 tag_val)
{
	SetSelected(GetItemByTAG(tag_val));
}