コード例 #1
0
ファイル: caca.c プロジェクト: RodrigoNieves/vlc
/**
 * This function initializes libcaca vout method.
 */
static int Open(vlc_object_t *object)
{
    vout_display_t *vd = (vout_display_t *)object;
    vout_display_sys_t *sys;

#if !defined(__APPLE__) && !defined(WIN32)
# ifndef X_DISPLAY_MISSING
    if (!vlc_xlib_init(object))
        return VLC_EGENERIC;
# endif
#endif

#if defined(WIN32)
    CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
    SMALL_RECT rect;
    COORD coord;
    HANDLE hstdout;

    if (!AllocConsole()) {
        msg_Err(vd, "cannot create console");
        return VLC_EGENERIC;
    }

    hstdout =
        CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
                                  FILE_SHARE_READ | FILE_SHARE_WRITE,
                                  NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
    if (!hstdout || hstdout == INVALID_HANDLE_VALUE) {
        msg_Err(vd, "cannot create screen buffer");
        FreeConsole();
        return VLC_EGENERIC;
    }

    if (!SetConsoleActiveScreenBuffer(hstdout)) {
        msg_Err(vd, "cannot set active screen buffer");
        FreeConsole();
        return VLC_EGENERIC;
    }

    coord = GetLargestConsoleWindowSize(hstdout);
    msg_Dbg(vd, "SetConsoleWindowInfo: %ix%i", coord.X, coord.Y);

    /* Force size for now */
    coord.X = 100;
    coord.Y = 40;

    if (!SetConsoleScreenBufferSize(hstdout, coord))
        msg_Warn(vd, "SetConsoleScreenBufferSize %i %i",
                  coord.X, coord.Y);

    /* Get the current screen buffer size and window position. */
    if (GetConsoleScreenBufferInfo(hstdout, &csbiInfo)) {
        rect.Top = 0; rect.Left = 0;
        rect.Right = csbiInfo.dwMaximumWindowSize.X - 1;
        rect.Bottom = csbiInfo.dwMaximumWindowSize.Y - 1;
        if (!SetConsoleWindowInfo(hstdout, TRUE, &rect))
            msg_Dbg(vd, "SetConsoleWindowInfo failed: %ix%i",
                     rect.Right, rect.Bottom);
    }
#endif

    /* Allocate structure */
    vd->sys = sys = calloc(1, sizeof(*sys));
    if (!sys)
        goto error;

    sys->cv = cucul_create_canvas(0, 0);
    if (!sys->cv) {
        msg_Err(vd, "cannot initialize libcucul");
        goto error;
    }

    const char *driver = NULL;
#ifdef __APPLE__
    // Make sure we don't try to open a window.
    driver = "ncurses";
#endif

    sys->dp = caca_create_display_with_driver(sys->cv, driver);
    if (!sys->dp) {
        msg_Err(vd, "cannot initialize libcaca");
        goto error;
    }
    vout_display_DeleteWindow(vd, NULL);

    if (vd->cfg->display.title)
        caca_set_display_title(sys->dp,
                               vd->cfg->display.title);
    else
        caca_set_display_title(sys->dp,
                               VOUT_TITLE "(Colour AsCii Art)");

    /* Fix format */
    video_format_t fmt = vd->fmt;
    if (fmt.i_chroma != VLC_CODEC_RGB32) {
        fmt.i_chroma = VLC_CODEC_RGB32;
        fmt.i_rmask = 0x00ff0000;
        fmt.i_gmask = 0x0000ff00;
        fmt.i_bmask = 0x000000ff;
    }

    /* TODO */
    vout_display_info_t info = vd->info;

    /* Setup vout_display now that everything is fine */
    vd->fmt = fmt;
    vd->info = info;

    vd->pool    = Pool;
    vd->prepare = Prepare;
    vd->display = PictureDisplay;
    vd->control = Control;
    vd->manage  = Manage;

    /* Fix initial state */
    vout_display_SendEventFullscreen(vd, false);
    Refresh(vd);

    return VLC_SUCCESS;

error:
    if (sys) {
        if (sys->pool)
            picture_pool_Delete(sys->pool);
        if (sys->dither)
            cucul_free_dither(sys->dither);
        if (sys->dp)
            caca_free_display(sys->dp);
        if (sys->cv)
            cucul_free_canvas(sys->cv);

        free(sys);
    }
#if defined(WIN32)
    FreeConsole();
#endif
    return VLC_EGENERIC;
}
コード例 #2
0
ファイル: cmd_line_view.cpp プロジェクト: cosarara97/hex
void CmdLineView::Render (const char * str)
{
  Erase();
  Print(str);
  Refresh();
}
コード例 #3
0
void wxPendulumDlg::OnTimer(wxTimerEvent& WXUNUSED(event))
{
	// force refresh
	Refresh();
}
コード例 #4
0
bool mmMultiButton::Enable(bool enable)
{
  bool ret = wxWindowBase::Enable(enable);
  Refresh();
  return ret;
} // Enable
コード例 #5
0
////////////////
// Mouse events
void VideoSlider::OnMouse(wxMouseEvent &event) {
	// Coordinates
	int x = event.GetX();
	int y = event.GetY();
	bool shift = event.m_shiftDown;

	// Left click
	if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
		// Check if it's OK to drag
		bool canDrag = wxWindow::FindFocus() == this;
		if (!canDrag) {
			int tolerance = 4;
			int curX = GetXAtValue(GetValue());
			if (x-curX < -tolerance || x-curX > tolerance) canDrag = true;
		}

		// Drag
		if (canDrag) {
			// Shift click to snap to keyframe
			if (shift && Display) {
				wxArrayInt KeyFrames = Display->GetKeyFrames();
				int keys = KeyFrames.Count();
				int clickedFrame = GetValueAtX(x);
				int closest = 0;
				int cur;

				// Find closest
				for (int i=0;i<keys;i++) {
					cur = KeyFrames[i];
					if (abs(cur-clickedFrame) < abs(closest-clickedFrame)) {
						closest = cur;
					}
				}

				// Jump to frame
				if (closest == GetValue()) return;
				SetValue(closest);
			}

			// Normal click
			else {
				int go = GetValueAtX(x);
				if (go == GetValue()) return;
				SetValue(go);
			}
			Refresh(false);

			// Playing?
			if (Display->IsPlaying) {
				Display->Stop();
				UpdateVideo();
				Display->Play();
			}
			else UpdateVideo();
		}

		// Get focus
		SetFocus();
	}

	// Right/middle click
	if (event.ButtonDown(wxMOUSE_BTN_RIGHT) || event.ButtonDown(wxMOUSE_BTN_MIDDLE)) {
		SetFocus();
	}

	// Something else
	else if (!Display->IsPlaying) event.Skip();
}
コード例 #6
0
void mmMultiButton::SetStyle(const long style)
{
  mStyle = style;
  Refresh();
} // SetStyle
コード例 #7
0
void mmMultiButton::SetSelected(const bool isSelected)
// Update button state.
{
  mIsSelected = isSelected;
  Refresh();
} // SetSelected
コード例 #8
0
ファイル: driver.cpp プロジェクト: kozarovv/mednafen-ps3
	virtual void RepaintPanel()
	{
		Refresh(false);
		Update();
	}
コード例 #9
0
ファイル: ImageBox.cpp プロジェクト: aszlig/wx-Youtube
void wxImageBox::UpdatePaintBox()
{
  m_repaint = true;
  UpdateScaleValue();
  Refresh();
}
コード例 #10
0
ファイル: ProcessesDialog.cpp プロジェクト: AlexHayton/decoda
ProcessesDialog::ProcessesDialog( wxWindow* parent )
    : wxDialog( parent, wxID_ANY, _("Processes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER )
{
	
	wxFlexGridSizer* fgSizer2;
	fgSizer2 = new wxFlexGridSizer( 1, 1, 0, 0 );
	fgSizer2->AddGrowableCol( 0 );
	fgSizer2->AddGrowableRow( 0 );
	fgSizer2->SetFlexibleDirection( wxBOTH );
	
	wxStaticBoxSizer* sbSizer1;
	sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, -1, wxT("Available Processes") ), wxHORIZONTAL );
	
	wxFlexGridSizer* fgSizer1;
	fgSizer1 = new wxFlexGridSizer( 2, 1, 0, 0 );
	fgSizer1->AddGrowableCol( 0 );
	fgSizer1->AddGrowableRow( 0 );
	fgSizer1->SetFlexibleDirection( wxBOTH );
	
	m_processList = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxSize(400, 300), wxLC_REPORT | wxLC_SINGLE_SEL);
    m_processList->InsertColumn(0, "Process");
    m_processList->InsertColumn(1, "ID");
    m_processList->InsertColumn(2, "Title");	

    m_processList->SetColumnWidth(0, 100);
    m_processList->SetColumnWidth(1, 50);
    m_processList->SetColumnWidth(2, 350);

    fgSizer1->Add( m_processList, 0, wxALL|wxEXPAND, 5 );
	
	sbSizer1->Add( fgSizer1, 1, wxEXPAND, 5 );
	
	fgSizer2->Add( sbSizer1, 1, wxALL|wxEXPAND, 5 );
	
	wxBoxSizer* bSizer1;
	bSizer1 = new wxBoxSizer( wxHORIZONTAL );
	
	m_refresh = new wxButton( this, ID_Refresh, wxT("&Refresh"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer1->Add( m_refresh, 0, wxALL, 5 );
	
	m_attach = new wxButton( this, wxID_OK, wxT("&Attach"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer1->Add( m_attach, 0, wxALL, 5 );
	
	m_close = new wxButton( this, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
	bSizer1->Add( m_close, 0, wxALL, 5 );
	
	fgSizer2->Add( bSizer1, 1, wxALL | wxALIGN_RIGHT, 5 );
	
	SetSizer( fgSizer2 );
	
    wxSize minSize = fgSizer2->GetMinSize();
    SetClientSize(minSize);
    SetMinSize(GetSize());
    
    Layout();

    m_sortColumn = 0;
    m_sortForward = true;

    Refresh();

}
コード例 #11
0
ファイル: BookmarkView.cpp プロジェクト: Dantali0n/CubicSDR
void BookmarkView::refreshLayout() {
    GetSizer()->Layout();
    Update();
    Refresh();
}
コード例 #12
0
ファイル: ProcessesDialog.cpp プロジェクト: AlexHayton/decoda
void ProcessesDialog::OnRefresh(wxCommandEvent& event)
{
    Refresh();
}
コード例 #13
0
void
ClipboardWidget::Paste()
{
	// Get the window and selection manager for use below.
	JXWindow* window           = GetWindow();
	JXSelectionManager* selMgr = GetSelectionManager();

	// If the clipboard is not empty, retrieve the available types.
	JArray<Atom> typeList;
	if (selMgr->GetAvailableTypes(kJXClipboardName, CurrentTime, &typeList))
		{

		// Loop through the available types to see if the clipboard has
		// one that we want.
		const JSize typeCount = typeList.GetElementCount();
		for (JIndex i=1; i<=typeCount; i++)
			{
			const Atom atom = typeList.GetElement(i);

			// Check if the i-th type is one we can use.
			if (atom == XA_STRING || atom == selMgr->GetTextXAtom())
				{
				// Get the data of the appropriate type.
				unsigned char* data = NULL;
				JSize dataLength;
				Atom returnType;
				JXSelectionManager::DeleteMethod dMethod;
				if (selMgr->GetData(kJXClipboardName, CurrentTime,
						atom, &returnType, &data, &dataLength,
						&dMethod))
					{
					// We can only handle the simplest format.
					if (returnType == XA_STRING)
						{
						// Copy the data into our text.
						itsText.Set(reinterpret_cast<JCharacter*>(data), dataLength);

						// Our text changed, so we need to refresh.
						Refresh();
						}

					// This is required to delete the allocated data.
					// Forgetting to do this will cause a memory leak!
					selMgr->DeleteData(&data, dMethod);

					if (returnType == XA_STRING)
						{
						// We succeeded, so we return.
						return;
						}
					}
				else
					{
					(JGetUserNotification())->ReportError(
						"Unable to retrieve text from the clipboard.");
					}
				}
			}

		// If we got this far, the data type that we want wasn't on the
		// clipboard.
		(JGetUserNotification())->ReportError("Unable to paste from clipboard.");
		}
	else
		{
		// There isn't anything on the clipboard.
		(JGetUserNotification())->ReportError("Clipboard is empty.");
		}
}
コード例 #14
0
bool CGUIWindowEventLog::OnMessage(CGUIMessage& message)
{
  switch (message.GetMessage())
  {
  case GUI_MSG_WINDOW_INIT:
  {
    m_rootDir.AllowNonLocalSources(false);

    // is this the first time the window is opened?
    if (m_vecItems->GetPath() == "?" && message.GetStringParam().empty())
      m_vecItems->SetPath("");

    break;
  }

  case GUI_MSG_CLICKED:
  {
    int iControl = message.GetSenderId();

    // check if we should clear all items
    if (iControl == CONTROL_BUTTON_CLEAR)
    {
      CEventLog::GetInstance().Clear(CViewStateSettings::GetInstance().GetEventLevel(), CViewStateSettings::GetInstance().ShowHigherEventLevels());

      // refresh the list
      Refresh(true);
      return true;
    }

    // check if we should change the level
    if (iControl == CONTROL_BUTTON_LEVEL)
    {
      // update the event level
      CViewStateSettings::GetInstance().CycleEventLevel();
      CSettings::GetInstance().Save();

      // update the listing
      Refresh();
      return true;
    }

    // check if we should change the level
    if (iControl == CONTROL_BUTTON_LEVEL_ONLY)
    {
      // update whether to show higher event levels
      CViewStateSettings::GetInstance().ToggleShowHigherEventLevels();
      CSettings::GetInstance().Save();

      // update the listing
      Refresh();
      return true;
    }

    // check if the user interacted with one of the events
    if (m_viewControl.HasControl(iControl))
    {
      // get selected item
      int itemIndex = m_viewControl.GetSelectedItem();
      if (itemIndex < 0 || itemIndex >= m_vecItems->Size())
        break;

      CFileItemPtr item = m_vecItems->Get(itemIndex);
      int actionId = message.GetParam1();

      if (actionId == ACTION_DELETE_ITEM)
        return OnDelete(item);
    }

    break;
  }

  case GUI_MSG_NOTIFY_ALL:
  {
    CFileItemPtr item = std::dynamic_pointer_cast<CFileItem>(message.GetItem());
    if (item == nullptr)
      break;

    switch (message.GetParam1())
    {
    case GUI_MSG_EVENT_ADDED:
      OnEventAdded(item);
      return true;

    case GUI_MSG_EVENT_REMOVED:
      OnEventRemoved(item);
      return true;

    default:
      break;
    }
  }

  default:
    break;
  }

  return CGUIMediaWindow::OnMessage(message);
}
コード例 #15
0
void mmMultiButton::SetDefaultBitmap(wxBitmap& bm)
{
  mDefaultBitmap = &bm;
  Refresh();
} // SetDefaultBitmap
コード例 #16
0
ファイル: vscroll.cpp プロジェクト: ACanadianKernel/pcsx2
void wxVScrolledWindow::RefreshAll()
{
    UpdateScrollbar();

    Refresh();
}
コード例 #17
0
void mmMultiButton::SetLabel(wxString label)
// Sets the string label.
{
  mLabelStr = label;
  Refresh();
} // SetLabel
コード例 #18
0
ファイル: gauge.cpp プロジェクト: CustomCardsOnline/wxWidgets
void wxGauge::SetRange(int range)
{
    wxGaugeBase::SetRange(range);

    Refresh();
}
コード例 #19
0
void mmMultiButton::SetFocus(const bool hasFocus)
// Update button state.
{
  mHasFocus = hasFocus;
  Refresh();
} // SetSelected
コード例 #20
0
ファイル: gauge.cpp プロジェクト: CustomCardsOnline/wxWidgets
void wxGauge::SetValue(int pos)
{
    wxGaugeBase::SetValue(pos);

    Refresh();
}
コード例 #21
0
void mmMultiButton::SetDropToggleDown(const bool isDropToggleDown)
// Update button state.
{
  mIsDropToggleDown = isDropToggleDown;
  Refresh();
} // SetDropToggleDown
コード例 #22
0
ファイル: TileMapPanel.cpp プロジェクト: HaoDrang/GD
void TileMapPanel::OnMouseEvent(wxMouseEvent &event)
{
    if(!m_tilemap || !m_tileset)
        return;

    //Get the current tile position (column and row)
    unsigned int currentColumn, currentRow;
    wxPoint mousePos = CalcUnscrolledPosition(event.GetPosition());
    GetTileAt(mousePos, currentColumn, currentRow);

    if(currentColumn >= m_tilemap->GetColumnsCount() || currentRow >= m_tilemap->GetRowsCount())
        return; //Stop if the position is out of range

    if(m_insertionMode == PencilMode)
    {
        if(event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_RIGHT_DOWN || event.GetEventType() == wxEVT_MOTION)
        {
            if(event.LeftIsDown()) //Left mouse button pressed
            {
                //Add a tile to the current position (only if the tile has not been set before)
                if(m_tilemap->GetTile(m_mapCurrentLayer, currentColumn, currentRow) != m_tileToBeInserted)
                    m_commandProcessor.Submit(new ChangeTileCommand(*m_tilemap, m_mapCurrentLayer, currentColumn, currentRow, m_tileToBeInserted));
                Refresh();
            }
            else if(event.RightIsDown())
            {
                //Remove the tile
                m_commandProcessor.Submit(new ChangeTileCommand(*m_tilemap, m_mapCurrentLayer, currentColumn, currentRow, -1));
                Refresh();
            }
        }
    }
    else if(m_insertionMode == RectangleMode)
    {
        if(event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_RIGHT_DOWN)
        {
            m_isDrawingRectangle = true;
            m_beginCol = m_endCol = currentColumn;
            m_beginRow = m_endRow = currentRow;

            Update();
        }
        else if(event.GetEventType() == wxEVT_MOTION)
        {
            m_endCol = currentColumn;
            m_endRow = currentRow;
            Update();
        }
        else if(event.GetEventType() == wxEVT_LEFT_UP)
        {
            m_endCol = currentColumn;
            m_endRow = currentRow;
            m_isDrawingRectangle = false;

            m_commandProcessor.Submit(new ChangeTileCommand(*m_tilemap, m_mapCurrentLayer, std::min(m_beginCol, m_endCol),
                                                                                           std::min(m_beginRow, m_endRow),
                                                                                           std::max(m_beginCol, m_endCol),
                                                                                           std::max(m_beginRow, m_endRow),
                                                                                           m_tileToBeInserted));

            Update();
        }
        else if(event.GetEventType() == wxEVT_RIGHT_UP)
        {
            m_endCol = currentColumn;
            m_endRow = currentRow;
            m_isDrawingRectangle = false;

            m_commandProcessor.Submit(new ChangeTileCommand(*m_tilemap, m_mapCurrentLayer, std::min(m_beginCol, m_endCol),
                                                                                           std::min(m_beginRow, m_endRow),
                                                                                           std::max(m_beginCol, m_endCol),
                                                                                           std::max(m_beginRow, m_endRow),
                                                                                           -1));

            Update();
        }
    }
    else if(m_insertionMode == FillMode)
    {
        if(event.GetEventType() == wxEVT_LEFT_DOWN)
        {
            m_commandProcessor.Submit(new FloodFillCommand(*m_tilemap, m_mapCurrentLayer, currentColumn, currentRow, m_tileToBeInserted));

            Update();
        }
    }
}
コード例 #23
0
WXLRESULT wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
    if ( nMsg == WM_NCHITTEST )
    {
        // This code breaks some other processing such as enter/leave tracking
        // so it's off by default.

        static int s_useHTClient = -1;
        if (s_useHTClient == -1)
            s_useHTClient = wxSystemOptions::GetOptionInt(wxT("msw.staticbox.htclient"));
        if (s_useHTClient == 1)
        {
            int xPos = GET_X_LPARAM(lParam);
            int yPos = GET_Y_LPARAM(lParam);

            ScreenToClient(&xPos, &yPos);

            // Make sure you can drag by the top of the groupbox, but let
            // other (enclosed) controls get mouse events also
            if ( yPos < 10 )
                return (long)HTCLIENT;
        }
    }

    if ( nMsg == WM_PRINTCLIENT )
    {
        // we have to process WM_PRINTCLIENT ourselves as otherwise child
        // windows' background (eg buttons in radio box) would never be drawn
        // unless we have a parent with non default background

        // so check first if we have one
        if ( !HandlePrintClient((WXHDC)wParam) )
        {
            // no, we don't, erase the background ourselves
            // (don't use our own) - see PaintBackground for explanation
            wxBrush brush(GetParent()->GetBackgroundColour());
            wxFillRect(GetHwnd(), (HDC)wParam, GetHbrushOf(brush));
        }

        return 0;
    }

    if ( nMsg == WM_UPDATEUISTATE )
    {
        // DefWindowProc() redraws just the static box text when it gets this
        // message and it does it using the standard (blue in standard theme)
        // colour and not our own label colour that we use in PaintForeground()
        // resulting in the label mysteriously changing the colour when e.g.
        // "Alt" is pressed anywhere in the window, see #12497.
        //
        // To avoid this we simply refresh the window forcing our own code
        // redrawing the label in the correct colour to be called. This is
        // inefficient but there doesn't seem to be anything else we can do.
        //
        // Notice that the problem is XP-specific and doesn't arise under later
        // systems.
        if ( m_hasFgCol && wxGetWinVersion() == wxWinVersion_XP )
            Refresh();
    }

    return wxControl::MSWWindowProc(nMsg, wParam, lParam);
}
コード例 #24
0
ファイル: TileMapPanel.cpp プロジェクト: HaoDrang/GD
void TileMapPanel::HideUpperLayers(bool enable)
{
    m_hideUpperLayers = enable;
    Refresh();
}
コード例 #25
0
////////////////
// Focus change
void VideoSlider::OnFocus(wxFocusEvent &event) {
	Refresh(false);
}
コード例 #26
0
ファイル: TileMapPanel.cpp プロジェクト: HaoDrang/GD
void TileMapPanel::SetCurrentLayer(int currentLayer)
{
    m_mapCurrentLayer = currentLayer;
    Refresh();
}
コード例 #27
0
void wxPendulumDlg::wxPendulumDlgSize(wxSizeEvent& WXUNUSED(event))
{
    Refresh();
}
コード例 #28
0
void mmMultiButton::OnMouse(wxMouseEvent& event)
// Update button state
{
#ifdef __MMDEBUG__
  //*gDebug<<"mmMultiButton::OnMouse,type:"<<event.GetEventType()<<"\n";
#endif

  mIsActivated = FALSE;

  if ((mStyle & mmMB_STATIC) || !IsEnabled())
  {
    mHasFocus              = FALSE;
    mIsToggleDown          = FALSE;
    mIsWholeDropToggleDown = FALSE;
    mIsDropToggleDown      = FALSE;
    mIsSelected            = FALSE;
    return;
  }

  if (!(mStyle & mmMB_TOGGLE))
    mIsToggleDown          = FALSE;

  if (!(mStyle & mmMB_WHOLEDROPDOWN))
    mIsWholeDropToggleDown = FALSE;

  if (!(mStyle & mmMB_DROPDOWN))
    mIsDropToggleDown      = FALSE;

  bool focus_changed           = FALSE,
       toggle_changed          = FALSE,
       wholedroptoggle_changed = FALSE,
       droptoggle_changed      = FALSE,
       selected_changed        = FALSE;

  int w,h;
  GetClientSize(&w,&h);
  wxPoint mp = event.GetPosition();

  if (event.Entering())
  { // ENTER
    if ((mStyle & mmMB_AUTODRAW) || (mStyle & mmMB_FOCUS))
      focus_changed = !mHasFocus;
    mHasFocus = TRUE;
  }
  else
  if (event.Leaving())
  { // LEAVE
    mIsSelected = FALSE;
    if (!mIsDropToggleDown && !mIsWholeDropToggleDown)
    {
      if ((mStyle & mmMB_AUTODRAW) || (mStyle & mmMB_FOCUS))
        focus_changed = mHasFocus;
      mHasFocus = FALSE;
      if (HasCapture()) ReleaseMouse();
    }
  }
  else
  if (event.LeftDown() || event.LeftDClick())
  { // SELECT
    if (mStyle & mmMB_TOGGLE)
    { // TOGGLE
      if (mIsSelected)
        selected_changed = TRUE;
      mIsSelected = FALSE;
      CaptureMouse();
    }
    else
    if (mStyle & mmMB_WHOLEDROPDOWN)
    { // WHOLEDROPDOWN
      if (MouseIsOnButton())
      {
        if (!mIsSelected)
          selected_changed = TRUE;
        mIsSelected = TRUE;
        wholedroptoggle_changed = TRUE;
        mIsWholeDropToggleDown = !mIsWholeDropToggleDown;
        if (mIsWholeDropToggleDown)
	  CaptureMouse();
        else
          if (HasCapture()) ReleaseMouse();
      }
      else
      { // Pressed outside of button
        if (mIsSelected)
          selected_changed = TRUE;
	mIsSelected = FALSE;
        if (mIsWholeDropToggleDown)
          wholedroptoggle_changed = TRUE;
	mIsWholeDropToggleDown = FALSE;
        if (HasCapture()) ReleaseMouse();
      }
    }
    else
    /*
    if (mStyle & mmMB_DROPDOWN)
    { // DROPDOWN
      if (mp.x > w-gDownBM.GetWidth()-mBorderSize && mp.x < w &&
	      mp.y > mBorderSize && mp.y < h-mBorderSize)
      { // Drop down arrow pressed
        if (mIsSelected)
          selected_changed = TRUE;
	mIsSelected = FALSE;
        droptoggle_changed = TRUE;
        mIsDropToggleDown = !mIsDropToggleDown;
	if (mIsDropToggleDown)
	  CaptureMouse();
        else
          if (HasCapture()) ReleaseMouse();
      }
      else
      if (MouseIsOnButton())
      { // Button (not arrow) pressed
        if (!mIsSelected)
          selected_changed = TRUE;
	mIsSelected = TRUE;
        //if (mIsDropToggleDown)
          //droptoggle_changed = TRUE;
	//mIsDropToggleDown = FALSE;
        CaptureMouse();
      }
      else
      { // Pressed outside of button
        if (mIsSelected)
          selected_changed = TRUE;
	mIsSelected = FALSE;
        if (mIsDropToggleDown)
          droptoggle_changed = TRUE;
	mIsDropToggleDown = FALSE;
        if (HasCapture()) ReleaseMouse();
      }
    }
    else
    */
    { // 'Normal' button
      if (!mIsSelected)
        selected_changed = TRUE;
      mIsSelected = TRUE;
      CaptureMouse();
    }
    if (!MouseIsOnButton())
    {
      focus_changed = mHasFocus;
      mHasFocus = FALSE;
    }
  }
  else
  if (event.LeftUp())
  { // ACTIVATE
    if (mStyle & mmMB_TOGGLE)
    { // TOGGLE
      if (mIsSelected)
        selected_changed = TRUE;
      mIsSelected = FALSE;
      toggle_changed = TRUE;
      mIsToggleDown = !mIsToggleDown;
      if (HasCapture()) ReleaseMouse();
    }
    else
    if (mStyle & mmMB_WHOLEDROPDOWN)
    { // WHOLEDROPDOWN
      if (mIsSelected)
        selected_changed = TRUE;
      mIsSelected = FALSE;
      if (!mIsWholeDropToggleDown)
        if (HasCapture()) ReleaseMouse();
    }
    /*
    else
    if (mStyle & mmMB_DROPDOWN)
    { // DROPDOWN
      if (mIsSelected)
        selected_changed = TRUE;
      mIsSelected = FALSE;
      if (mp.x > w-gDownBM.GetWidth()-mBorderSize && mp.x < w &&
	      mp.y > mBorderSize && mp.y < h-mBorderSize)
      { // Drop down arrow pressed
        if (!mIsDropToggleDown)
          if (HasCapture()) ReleaseMouse();
      }
      else
      if (MouseIsOnButton())
      { // Button (not arrow) pressed
        if (mIsDropToggleDown)
          droptoggle_changed = TRUE;
	mIsDropToggleDown = FALSE;
	if (!droptoggle_changed)
          mIsActivated = TRUE; // NOTE! SEND ACTIVATE SIGNAL!
        if (HasCapture()) ReleaseMouse();
      }
    }
    */
    else
    { // 'Normal' button
      if (mIsSelected)
        selected_changed = TRUE;
      mIsSelected = FALSE;
      mIsActivated = TRUE; // NOTE! SEND ACTIVATE SIGNAL!
      if (HasCapture()) ReleaseMouse();
    }
  }

  // Redraw only if neccessary
  if (focus_changed || selected_changed || wholedroptoggle_changed || droptoggle_changed || toggle_changed)
  {
    Refresh();
    // Generate events to let derived class know what happened
    if (focus_changed)
    { // ENTER/LEAVE
      wxCommandEvent ev(event.GetEventType(),GetId());
      if (mHasFocus)
        ev.SetEventType(wxEVT_ENTER_WINDOW);
      else
        ev.SetEventType(wxEVT_LEAVE_WINDOW);
      GetEventHandler()->ProcessEvent(ev); // Neccessary?
    }
    if (toggle_changed)
    { // TOGGLE
      wxCommandEvent ev(mmEVT_TOGGLE,GetId());
      GetEventHandler()->ProcessEvent(ev);
    }
    if (wholedroptoggle_changed)
    { // WHOLEDROPDOWN
      wxCommandEvent ev(mmEVT_WHOLEDROP_TOGGLE,GetId());
      GetEventHandler()->ProcessEvent(ev);
    }
    if (droptoggle_changed)
    { // DROPDOWN
      wxCommandEvent ev(mmEVT_DROP_TOGGLE,GetId());
      GetEventHandler()->ProcessEvent(ev);
    }
    if (selected_changed)
    { // SELECT
      wxCommandEvent ev(wxEVT_COMMAND_LEFT_CLICK,GetId());
      GetEventHandler()->ProcessEvent(ev);
    }
    if (mIsActivated)
    { // ACTIVATE
      wxCommandEvent ev(wxEVT_COMMAND_BUTTON_CLICKED,GetId());
      GetEventHandler()->ProcessEvent(ev);
    }
  } // if
  event.Skip();
} // OnMouse
コード例 #29
0
ファイル: toolbar.cpp プロジェクト: Kaoswerk/newton-dynamics
void wxRibbonToolBar::OnMouseMove(wxMouseEvent& evt)
{
    wxPoint pos(evt.GetPosition());
    wxRibbonToolBarToolBase *new_hover = NULL;

    size_t group_count = m_groups.GetCount();
    size_t g, t;
    for(g = 0; g < group_count; ++g)
    {
        wxRibbonToolBarToolGroup* group = m_groups.Item(g);
        if(group->position.x <= pos.x && pos.x < group->position.x + group->size.x
            && group->position.y <= pos.y && pos.y < group->position.y + group->size.y)
        {
            size_t tool_count = group->tools.GetCount();
            pos -= group->position;
            for(t = 0; t < tool_count; ++t)
            {
                wxRibbonToolBarToolBase* tool = group->tools.Item(t);
                if(tool->position.x <= pos.x && pos.x < tool->position.x + tool->size.x
                    && tool->position.y <= pos.y && pos.y < tool->position.y + tool->size.y)
                {
                    pos -= tool->position;
                    new_hover = tool;
                    break;
                }
            }
            break;
        }
    }

#if wxUSE_TOOLTIPS
    if(new_hover)
    {
        SetToolTip(new_hover->help_string);
    }
    else if(GetToolTip())
    {
        UnsetToolTip();
    }
#endif

    if(new_hover && new_hover->state & wxRIBBON_TOOLBAR_TOOL_DISABLED)
    {
        new_hover = NULL; // A disabled tool can not be hilighted
    }

    if(new_hover != m_hover_tool)
    {
        if(m_hover_tool)
        {
            m_hover_tool->state &= ~(wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
                | wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK);
        }
        m_hover_tool = new_hover;
        if(new_hover)
        {
            long what = wxRIBBON_TOOLBAR_TOOL_NORMAL_HOVERED;
            if(new_hover->dropdown.Contains(pos))
                what = wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED;

            new_hover->state |= what;

            if(new_hover == m_active_tool)
            {
                new_hover->state &= ~wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK;
                new_hover->state |= (what << 2);
            }
        }
        Refresh(false);
    }
    else if(m_hover_tool && m_hover_tool->kind == wxRIBBON_BUTTON_HYBRID)
    {
        long newstate = m_hover_tool->state &~wxRIBBON_TOOLBAR_TOOL_HOVER_MASK;
        long what = wxRIBBON_TOOLBAR_TOOL_NORMAL_HOVERED;
        if(m_hover_tool->dropdown.Contains(pos))
            what = wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED;
        newstate |= what;
        if(newstate != m_hover_tool->state)
        {
            m_hover_tool->state = newstate;
            if(m_hover_tool == m_active_tool)
            {
                m_hover_tool->state &= ~wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK;
                m_hover_tool->state |= (what << 2);
            }
            Refresh(false);
        }
    }
}
コード例 #30
0
ファイル: caca.c プロジェクト: RodrigoNieves/vlc
/**
 * Display a picture
 */
static void PictureDisplay(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
{
    Refresh(vd);
    picture_Release(picture);
    VLC_UNUSED(subpicture);
}