void DeviceToolBar::OnCaptureKey(wxCommandEvent &event)
{
   wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject();
   int keyCode = kevent->GetKeyCode();

   // Pass UP/DOWN/LEFT/RIGHT through for input/output choice
   if (FindFocus() == mInput && (keyCode == WXK_LEFT || keyCode == WXK_RIGHT
                                 || keyCode == WXK_UP || keyCode == WXK_DOWN)) {
      return;
   }

   if (FindFocus() == mOutput && (keyCode == WXK_LEFT || keyCode == WXK_RIGHT
                                 || keyCode == WXK_UP || keyCode == WXK_DOWN)) {
      return;
   }
   event.Skip();

   return;
}
void wxTopLevelWindowMSW::DoSaveLastFocus()
{
    if ( m_iconized )
        return;

    // remember the last focused child if it is our child
    wxWindow* const winFocus = FindFocus();

    m_winLastFocused = IsDescendant(winFocus) ? winFocus : NULL;
}
void SelectionBar::OnUpdate(wxCommandEvent &evt)
{
   int index = evt.GetInt();
   wxWindow *w = FindFocus();
   bool leftFocus = (w == mLeftTime);
   bool rightFocus = (w == mRightTime);
   bool audioFocus = (w == mAudioTime);
   
   evt.Skip(false);
   
   /* we don't actually need a TimeTextCtrl, but need it's 
    * translations which are done at runtime */
   
   TimeTextCtrl *ttc = new TimeTextCtrl(this, wxID_ANY, wxT(""), 0.0, mRate);
   wxString formatName(ttc->GetBuiltinName(index));
   gPrefs->Write(wxT("/SelectionFormat"), formatName);
   gPrefs->Flush();
   #if wxUSE_TOOLTIPS
      mSnapTo->SetToolTip(wxString::Format(_("Snap Clicks/Selections to %s"), formatName.c_str()));
   #endif
   delete ttc;

   // ToolBar::ReCreateButtons() will get rid of our sizers and controls
   // so reset pointers first.
   mLeftTime =
   mRightTime =
   mAudioTime = NULL;

   mRightEndButton =
   mRightLengthButton = NULL;

   mRateBox = NULL;
   mRateText = NULL;

   ToolBar::ReCreateButtons();

   ValuesToControls();

   wxString formatString = mLeftTime->GetBuiltinFormat(index);
   mLeftTime->SetFormatString(formatString);
   mRightTime->SetFormatString(formatString);
   mAudioTime->SetFormatString(formatString);

   if (leftFocus) {
      mLeftTime->SetFocus();
   }
   else if (rightFocus) {
      mRightTime->SetFocus();
   }
   else if (audioFocus) {
      mAudioTime->SetFocus();
   }

   Updated();
}
Exemple #4
0
// Default activation behaviour - set the focus for the first child
// subwindow found.
void wxFrame::OnActivate(wxActivateEvent& event)
{
    if ( !event.GetActive() )
    {
       // remember the last focused child if it is our child
        m_winLastFocused = FindFocus();

        // so we NULL it out if it's a child from some other frame
        wxWindow *win = m_winLastFocused;
        while ( win )
        {
            if ( win->IsTopLevel() )
            {
                if ( win != this )
                    m_winLastFocused = NULL;

                break;
            }

            win = win->GetParent();
        }

        event.Skip();
    }
    else
    {
        // restore focus to the child which was last focused
        wxWindow *parent = m_winLastFocused
            ? m_winLastFocused->GetParent()
            : NULL;

        if (parent == NULL)
            parent = this;

        wxSetFocusToChild(parent, &m_winLastFocused);

#if wxUSE_MENUS
        if (m_frameMenuBar != NULL)
        {
            m_frameMenuBar->MacInstallMenuBar();
        }
        else
        {
            wxFrame *tlf = wxDynamicCast( wxTheApp->GetTopWindow(), wxFrame );
            if (tlf != NULL)
            {
                // Trying top-level frame membar
                if (tlf->GetMenuBar())
                    tlf->GetMenuBar()->MacInstallMenuBar();
            }
        }
#endif
    }
}
Exemple #5
0
void NyqBench::OnOutputUpdate(wxUpdateUIEvent & e)
{
   if (mOutputBox && mOutput && FindFocus() == mOutput) {
      wxString label = mOutputBox->GetLabel();
      if (label == _("Output")) {
         label += wxT("*");
         mOutputBox->SetLabel(label);
         mScriptBox->SetLabel(_("Script"));
      }
   }
}
Exemple #6
0
void MvcController::UponChildFocus(wxChildFocusEvent& event)
{
    event.Skip();

    wxWindow* new_focused_window = FindFocus();

    // A wxChildFocusEvent is sent for every window in the hierarchy,
    // from new_focused_window up to this MvcController. Ignore all
    // but the "deepest" one--see:
    //   http://lists.nongnu.org/archive/html/lmi/2009-01/msg00001.html
    if(event.GetWindow() != new_focused_window)
        {
        return;
        }

    // Do nothing if focus hasn't changed. This case arises when
    // another application is activated, and then this application
    // is reactivated.
    if(last_focused_window_ == new_focused_window)
        {
        return;
        }

    if
        (  wxID_CANCEL == new_focused_window->GetId()
        || wxID_HELP   == new_focused_window->GetId()
        )
        {
        return;
        }

    if(Validate())
        {
        if(new_focused_window)
            {
            last_focused_window_ = new_focused_window;
            }
        else
            {
            warning() << "Keyboard focus was lost." << LMI_FLUSH;
            RefocusLastFocusedWindow();
            }
        }
    else
        {
        LMI_ASSERT(!unit_test_refocus_event_pending_);
        if(!unit_test_under_way_)
            {
            wxCommandEvent event0(wxEVT_REFOCUS_INVALID_CONTROL);
            wxPostEvent(this, event0);
            }
        unit_test_refocus_event_pending_ = true;
        }
}
Exemple #7
0
void ControlToolBar::SetStop(bool down)
{
   if (down)
      mStop->PushDown();
   else {
      if(FindFocus() == mStop)
         mPlay->SetFocus();
      mStop->PopUp();
   }
   EnableDisableButtons();
}
/*---------------------------------------------------------------------------*/
void wxSQLBook::OnClearAllClick(wxCommandEvent& event)
{
    wxWindow* window = FindFocus();
    if (window)
    {
        if (window == m_SQLEdit)
            m_SQLEdit->ClearAll();
        else if (window == m_LogResult)
            m_LogResult->SetValue(wxEmptyString);
    }
}
Exemple #9
0
void wxNonOwnedWindow::SetDfbFocus()
{
    wxCHECK_RET( IsShown(), "cannot set focus to hidden window" );
    wxASSERT_MSG( FindFocus() && FindFocus()->GetTLW() == this,
                  "setting DirectFB focus to unexpected window" );

    // Don't set DirectFB focus if we're called from HandleFocusEvent() on
    // this window, because we already have the focus in that case. Not only
    // would it be unnecessary, it would be harmful: RequestFocus() adds
    // an event to DirectFB event queue and calling it when in
    // HandleFocusEvent() could result in a window being focused when it
    // should not be. Consider this example:
    //
    //     tlw1->SetFocus(); // (1)
    //     tlw2->SetFocus(); // (2)
    //
    // This results in adding these events to DFB queue:
    //
    //     DWET_GOTFOCUS(tlw1)
    //     DWET_LOSTFOCUS(tlw1)
    //     DWET_GOTFOCUS(tlw2)
    //
    // Note that the events are processed by event loop, i.e. not between
    // execution of lines (1) and (2) above. So by the time the first
    // DWET_GOTFOCUS event is handled, tlw2->SetFocus() was already executed.
    // If we onconditionally called RequestFocus() from here, handling the
    // first event would result in this change to the event queue:
    //
    //     DWET_LOSTFOCUS(tlw1)
    //     DWET_GOTFOCUS(tlw2) // (3)
    //     DWET_LOSTFOCUS(tlw2)
    //     DWET_GOTFOCUS(tlw1)
    //
    // And the focus would get back to tlw1 even though that's not what we
    // wanted.

    if ( gs_insideDFBFocusHandlerOf == this )
        return;

    GetDirectFBWindow()->RequestFocus();
}
Exemple #10
0
void MixerToolBar::OnCaptureKey(wxCommandEvent &event)
{
   wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject();
   int keyCode = kevent->GetKeyCode();

   // Pass LEFT/RIGHT/UP/DOWN/PAGEUP/PAGEDOWN through for input/output sliders
   if (FindFocus() == mOutputSlider && (keyCode == WXK_LEFT || keyCode == WXK_RIGHT
                                    || keyCode == WXK_UP || keyCode == WXK_DOWN
                                    || keyCode == WXK_PAGEUP || keyCode == WXK_PAGEDOWN)) {
      return;
   }
   if (FindFocus() == mInputSlider && (keyCode == WXK_LEFT || keyCode == WXK_RIGHT
                                    || keyCode == WXK_UP || keyCode == WXK_DOWN
                                    || keyCode == WXK_PAGEUP || keyCode == WXK_PAGEDOWN)) {
      return;
   }

   event.Skip();

   return;
}
Exemple #11
0
void SelectionBar::OnUpdate(wxCommandEvent &evt)
{
   int index = evt.GetInt();
   wxWindow *w = FindFocus();
   bool leftFocus = (w == mLeftTime);
   bool rightFocus = (w == mRightTime);
   bool audioFocus = (w == mAudioTime);

   evt.Skip(false);

   wxString format;

   // Save format name before recreating the controls so they resize properly
   format = mLeftTime->GetBuiltinName(index);
   mListener->AS_SetSelectionFormat(format);

#if wxUSE_TOOLTIPS
   mSnapTo->SetToolTip(wxString::Format(_("Snap Clicks/Selections to %s"), format.c_str()));
#endif

   // ToolBar::ReCreateButtons() will get rid of our sizers and controls
   // so reset pointers first.
   mLeftTime =
   mRightTime =
   mAudioTime = NULL;

   mRightEndButton =
   mRightLengthButton = NULL;

   mRateBox = NULL;
   mRateText = NULL;

   ToolBar::ReCreateButtons();

   ValuesToControls();

   format = mLeftTime->GetBuiltinFormat(index);
   mLeftTime->SetFormatString(format);
   mRightTime->SetFormatString(format);
   mAudioTime->SetFormatString(format);

   if (leftFocus) {
      mLeftTime->SetFocus();
   }
   else if (rightFocus) {
      mRightTime->SetFocus();
   }
   else if (audioFocus) {
      mAudioTime->SetFocus();
   }

   Updated();
}
/*---------------------------------------------------------------------------*/
void wxTableBook::OnCopyClick(wxCommandEvent& event)
{
    wxWindow* window = FindFocus();

    if (window && ((window == m_PageDdl)||
                   (m_PageColumns && m_PageColumns->HasFocus())||
                   (m_PageData && m_PageData->HasFocus())||
                   (m_PageForeignKey && m_PageForeignKey->HasFocus())||
                   (m_PageTriggers && m_PageTriggers->HasFocus())||
                   (m_PageIndexes && m_PageIndexes->HasFocus())))
        window->GetEventHandler()->ProcessEvent(event);
}
Exemple #13
0
void MvcController::EnsureOptimalFocus()
{
    wxWindow* f = FindFocus();
    if(f && f->IsEnabled() && f->AcceptsFocus())
        {
        return;
        }

    SetFocus();
    typedef std::vector<wxWindow*>::const_iterator wvci;
    std::vector<wxWindow*> page_lineage = Lineage(&CurrentPage());
    for(wvci i = page_lineage.begin(); i != page_lineage.end(); ++i)
        {
        wxWindow* w = *i;
        if(w && w->IsEnabled() && w->AcceptsFocus())
            {
            w->SetFocus();
            break;
            }
        }

    f = FindFocus();
    if(!(f && f->IsEnabled()))
        {
#if defined __WXGTK__
        // SOMEDAY !! Probably this condition should be used for all
        // platforms, after adequate testing.
        if(IsModal())
#endif // defined __WXGTK__
            {
            EndModal(wxID_CANCEL);
            }
        fatal_error()
            << "Dialog cancelled because a disabled or null window ("
            << NameLabelId(f)
            << ") improperly had focus."
            << LMI_FLUSH
            ;
        }
}
Exemple #14
0
/*---------------------------------------------------------------------------*/
void wxSQLBook::OnClearAllUpdate(wxUpdateUIEvent& event)
{
    wxWindow* window = FindFocus();
    if (window)
    {
        if (window == m_SQLEdit)
            event.Enable(m_SQLEdit->GetLength() > 0);
        else if (window == m_LogResult)
            event.Enable(m_LogResult->GetLastPosition() > 0);
    }
    else
        event.Enable(false);
}
Exemple #15
0
void wxCheckListBox::OnLeftClick(wxMouseEvent& event)
{
    // clicking on the item selects it, clicking on the checkmark toggles

    int nItem = HitTest(event.GetX(), event.GetY());

    if ( nItem != wxNOT_FOUND )
    {
        wxRect rect;
        GetItemRect(nItem, rect);

        // convert item rect to check mark rect
        wxSize size = wxRendererNative::Get().GetCheckBoxSize(this);
        rect.x += CHECKMARK_EXTRA_SPACE;
        rect.y += (rect.GetHeight() - size.GetHeight()) / 2;
        rect.SetSize(size);

        if ( rect.Contains(event.GetX(), event.GetY()) )
        {
            // people expect to get "kill focus" event for the currently
            // focused control before getting events from the other controls
            // and, equally importantly, they may prevent the focus change from
            // taking place at all (e.g. because the old control contents is
            // invalid and needs to be corrected) in which case we shouldn't
            // generate this event at all
            SetFocus();
            if ( FindFocus() == this )
            {
                Toggle(nItem);
                SendEvent(nItem);

                // scroll one item down if the item is the last one
                // and isn't visible at all
                int h;
                GetClientSize(NULL, &h);
                if ( rect.GetBottom() > h )
                    ScrollLines(1);
            }
        }
        else
        {
            // implement default behaviour: clicking on the item selects it
            event.Skip();
        }
    }
    else
    {
        // implement default behaviour on click outside of client zone
        event.Skip();
    }
}
Exemple #16
0
// Default activation behaviour - set the focus for the first child
// subwindow found.
void wxFrame::OnActivate(wxActivateEvent& event)
{
    if ( !event.GetActive() )
    {
       // remember the last focused child if it is our child
        m_winLastFocused = FindFocus();

        // so we NULL it out if it's a child from some other frame
        wxWindow *win = m_winLastFocused;
        while ( win )
        {
            if ( win->IsTopLevel() )
            {
                if ( win != this )
                {
                    m_winLastFocused = NULL;
                }

                break;
            }

            win = win->GetParent();
        }

        event.Skip();
    }
    else
    {
        // restore focus to the child which was last focused
        wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent()
                                            : NULL;
        if ( !parent )
        {
            parent = this;
        }

        wxSetFocusToChild(parent, &m_winLastFocused);

        if ( m_frameMenuBar != NULL )
        {
            m_frameMenuBar->MacInstallMenuBar() ;
        }
        else if (wxTheApp->GetTopWindow() && wxTheApp->GetTopWindow()->IsKindOf(CLASSINFO(wxFrame)))
        {
            // Trying toplevel frame menbar
            if( ((wxFrame*)wxTheApp->GetTopWindow())->GetMenuBar() )
                ((wxFrame*)wxTheApp->GetTopWindow())->GetMenuBar()->MacInstallMenuBar();
         }
    }
}
/*---------------------------------------------------------------------------*/
void wxTableBook::OnCopyUpdate(wxUpdateUIEvent& event)
{
    wxWindow* window = FindFocus();

    if (window && ((window == m_PageDdl)||
                   (m_PageColumns && m_PageColumns->HasFocus())||
                   (m_PageData && m_PageData->HasFocus())||
                   (m_PageForeignKey && m_PageForeignKey->HasFocus())||
                   (m_PageTriggers && m_PageTriggers->HasFocus())||
                   (m_PageIndexes && m_PageIndexes->HasFocus())))
        window->GetEventHandler()->ProcessEvent(event);
    else
        event.Enable(false);
}
Exemple #18
0
void SelectionBar::OnUpdate(wxCommandEvent &evt)
{
   int index = evt.GetInt();
   wxWindow *w = FindFocus();
   bool leftFocus = (w == mLeftTime);
   bool rightFocus = (w == mRightTime);
   bool audioFocus = (w == mAudioTime);
   
   evt.Skip(false);

   /* we need an object to call these methods on. It actually doesn't matter
    * which as they have no effect on the object state, so we just use the first
    * one to hand */
   wxString formatName =  mLeftTime->GetBuiltinName(index);
   wxString formatString = mLeftTime->GetBuiltinFormat(index);

   gPrefs->Write(wxT("/SelectionFormat"), formatName);

   // ToolBar::ReCreateButtons() will get rid of our sizers and controls
   // so reset pointers first.
   mLeftTime =
   mRightTime =
   mAudioTime = NULL;

   mRightEndButton =
   mRightLengthButton = NULL;

   mRateBox = NULL;

   ToolBar::ReCreateButtons();

   ValuesToControls();

   mLeftTime->SetFormatString(formatString);
   mRightTime->SetFormatString(formatString);
   mAudioTime->SetFormatString(formatString);

   if (leftFocus) {
      mLeftTime->SetFocus();
   }
   else if (rightFocus) {
      mRightTime->SetFocus();
   }
   else if (audioFocus) {
      mAudioTime->SetFocus();
   }

   Updated();
}
Exemple #19
0
bool SearchPanel::IsActive() const {
	if (!IsShown()) return false;

	// Check if any local control has focus
	wxWindow* focused = FindFocus();
	if (focused == (wxWindow*)searchbox) return true;
	if (focused == (wxWindow*)replaceBox) return true;
	if (focused == (wxWindow*)nextButton) return true;
	if (focused == (wxWindow*)prevButton) return true;
	if (focused == (wxWindow*)replaceButton) return true;
	if (focused == (wxWindow*)allButton) return true;
	if (focused == (wxWindow*)closeButton) return true;

	return false; // no focus
}
Exemple #20
0
void wxSTEditorFindReplacePanel::OnIdle(wxIdleEvent &event)
{
    if (IsShown())
    {
        // This is a really ugly hack because the combo forgets it's insertion
        //   point in MSW whenever it loses focus
        wxWindow* focus = FindFocus();
        if (m_findCombo && (focus == m_findCombo))
            m_find_insert_pos = m_findCombo->GetInsertionPoint();
        if (m_replaceCombo && (focus == m_replaceCombo))
            m_replace_insert_pos = m_replaceCombo->GetInsertionPoint();
    }

    event.Skip();
}
Exemple #21
0
/*---------------------------------------------------------------------------*/
void wxSQLBook::OnSelectallClick(wxCommandEvent& event)
{
    /*
    wxWindow* window = FindFocus();
    if (window && ((window == m_SQLEdit)||(window == m_LogResult)))
       window->GetEventHandler()->ProcessEvent(event);
    */

    wxWindow* window = FindFocus();

    if (window && ((window == m_SQLEdit)||/*(window == m_LogResult)||*/
                   (m_Explain && m_Explain->HasFocus())||(m_DataResult && m_DataResult->HasFocus())))
        window->GetEventHandler()->ProcessEvent(event);

}
Exemple #22
0
//
// Draw the background for a given line
//
// This is called by the listbox when it needs to redraw the view.
//
void
KeyView::OnDrawBackground(wxDC & dc, const wxRect & rect, size_t line) const
{
   const KeyNode *node = mLines[line];
   wxRect r = rect;
   wxCoord indent = 0;

   // When in tree view mode, each younger branch gets indented by the
   // width of the open/close bitmaps
   if (mViewType == ViewByTree)
   {
      indent += node->depth * KV_BITMAP_SIZE;
   }

   // Offset left side by the indentation (if any) and scroll amounts
   r.x = indent - mScrollX;

   // If the line width is less than the client width, then we want to
   // extend the background to the right edge of the client view.  Otherwise,
   // go all the way to the end of the line width...this will draw past the 
   // right edge, but that's what we want.
   r.width = wxMax(mWidth, r.width);

   // Selected lines get a solid background
   if (IsSelected(line))
   {
      if (FindFocus() == this)
      {
         // Focused lines get highlighted background
         dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)));
         AColor::DrawFocus(dc, r);
         dc.DrawRectangle(r);
      }
      else
      {
         // Non ocused lines get a light background
         dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)));
         dc.SetPen(*wxTRANSPARENT_PEN);
         dc.DrawRectangle(r);
      }
   }
   else
   {
      // Non-selected lines get a thin bottom border
      dc.SetPen(wxColour(240, 240, 240));
      dc.DrawLine(r.GetLeft(), r.GetBottom(), r.GetRight(), r.GetBottom());
   }
}
void SpectralSelectionBar::OnUpdate(wxCommandEvent &evt)
{
   int index = evt.GetInt();
   wxWindow *w = FindFocus();
   bool centerFocus = (w && w == mCenterCtrl);
   bool widthFocus = (w && w == mWidthCtrl);
   bool lowFocus = (w && w == mLowCtrl);
   bool highFocus = (w && w == mHighCtrl);

   evt.Skip(false);

   // Save formats before recreating the controls so they resize properly
   wxEventType type = evt.GetEventType();
   if (type == EVT_FREQUENCYTEXTCTRL_UPDATED) {
      NumericTextCtrl *frequencyCtrl = (mbCenterAndWidth ? mCenterCtrl : mLowCtrl);
      wxString frequencyFormatName = frequencyCtrl->GetBuiltinName(index);
      mListener->SSBL_SetFrequencySelectionFormatName(frequencyFormatName);
   }
   else if (mbCenterAndWidth &&
            type == EVT_BANDWIDTHTEXTCTRL_UPDATED) {
      wxString bandwidthFormatName = mWidthCtrl->GetBuiltinName(index);
      mListener->SSBL_SetBandwidthSelectionFormatName(bandwidthFormatName);
   }

   // ToolBar::ReCreateButtons() will get rid of our sizers and controls
   // so reset pointers first.
   mCenterCtrl = mWidthCtrl = NULL;
   mLowCtrl = mHighCtrl = NULL;

   ToolBar::ReCreateButtons();
   ValuesToControls();


   if (centerFocus) {
      mCenterCtrl->SetFocus();
   }
   else if (widthFocus) {
      mWidthCtrl->SetFocus();
   }
   else if (lowFocus) {
      mLowCtrl->SetFocus();
   }
   else if (highFocus) {
      mHighCtrl->SetFocus();
   }

   Updated();
}
void LogFinderFrame::OnTabKeyPress(wxKeyEvent& Event)
{
    wxWindow *Window = FindFocus();

    if(Event.GetKeyCode() == WXK_TAB)
        {
            bool Backward = Event.ShiftDown();
            switch (Window->GetId())
            {
                case ID_TEXT_FILE_PATH:
                    if(Backward)
                        FindWindow(ID_EXPORT_BUTTON)->SetFocus();
                    else
                        FindWindow(ID_FILE_BUTTON)->SetFocus();
                    break;
                case ID_FILE_BUTTON:
                    if(Backward)
                        FindWindow(ID_TEXT_FILE_PATH)->SetFocus();
                    else
                        FindWindow(ID_WORD_SEARCH)->SetFocus();
                    break;
                case ID_WORD_SEARCH:
                    if(Backward)
                        FindWindow(ID_FILE_BUTTON)->SetFocus();
                    else
                        FindWindow(ID_SEARCH_BUTTON)->SetFocus();
                    break;
                case ID_SEARCH_BUTTON:
                    if(Backward)
                        FindWindow(ID_WORD_SEARCH)->SetFocus();
                    else
                        FindWindow(ID_EXPORT_BUTTON)->SetFocus();
                    break;
                case ID_EXPORT_BUTTON:
                    if(Backward)
                        FindWindow(ID_SEARCH_BUTTON)->SetFocus();
                    else
                        FindWindow(ID_TEXT_FILE_PATH)->SetFocus();
                    break;
                default:
                    if(Backward)
                        FindWindow(ID_EXPORT_BUTTON)->SetFocus();
                    else
                        FindWindow(ID_TEXT_FILE_PATH)->SetFocus();
            }
        }
}
void TimeTextCtrl::OnPaint(wxPaintEvent &event)
{
   wxPaintDC dc(this);
   bool focused = (FindFocus() == this);

   dc.DrawBitmap(*mBackgroundBitmap, 0, 0);

   wxPen   Pen;
   wxBrush Brush;
   if (focused) {
      theTheme.SetPenColour( Pen, clrTimeFontFocus );
      dc.SetPen(Pen);
      dc.SetBrush(*wxTRANSPARENT_BRUSH);
      dc.DrawRectangle(0, 0, mWidth, mHeight);
      dc.SetPen( wxNullPen );
   }

   dc.SetFont(*mDigitFont);
   dc.SetTextForeground(theTheme.Colour( clrTimeFont ));
   dc.SetTextBackground(theTheme.Colour( clrTimeBack ));

   dc.SetPen(*wxTRANSPARENT_PEN);
   theTheme.SetBrushColour( Brush , clrTimeBackFocus );
   dc.SetBrush( Brush );

   int i;
   for(i=0; i<(int)mDigits.GetCount(); i++) {
      wxRect box = mDigits[i].digitBox;
      if (focused && mFocusedDigit == i) {
         dc.DrawRectangle(box);
         dc.SetTextForeground(theTheme.Colour( clrTimeFontFocus ));
         dc.SetTextBackground(theTheme.Colour( clrTimeBackFocus ));
      }
      int pos = mDigits[i].pos;
      wxString digit = mValueString.Mid(pos, 1);
      int x = box.x + (mDigitBoxW - mDigitW)/2;
      int y = box.y + (mDigitBoxH - mDigitH)/2;
      dc.DrawText(digit, x, y);
      if (focused && mFocusedDigit == i) {
         dc.SetTextForeground(theTheme.Colour( clrTimeFont ));
         dc.SetTextBackground(theTheme.Colour( clrTimeBack ));
      }
   }
   dc.SetPen( wxNullPen );
   dc.SetBrush( wxNullBrush );
}
Exemple #26
0
void MyFrame::OnKey(wxKeyEvent& event)
{
	int key;

	key = event.GetKeyCode();

	if((currentcanvas != NULL) && (currentcanvas != FindFocus()))
	{
		if((key == WXK_F1) || (key == WXK_F2))
		{
			currentcanvas->OnKey(event);
			currentcanvas->SetFocus();
			return;
		}
	}

	event.Skip();
}
void FreqWindow::Recalc()
{
   if (!mData || mDataLen < mWindowSize) {
      DrawPlot();
      return;
   }

   SpectrumAnalyst::Algorithm alg =
      SpectrumAnalyst::Algorithm(mAlgChoice->GetSelection());
   int windowFunc = mFuncChoice->GetSelection();

   wxWindow *hadFocus = FindFocus();
   // In wxMac, the skipped window MUST be a top level window.  I'd originally made it
   // just the mProgress window with the idea of preventing user interaction with the
   // controls while the plot was being recalculated.  This doesn't appear to be necessary
   // so just use the the top level window instead.
   {
      Maybe<wxWindowDisabler> blocker;
      if (IsShown())
         blocker.create(this);
      wxYieldIfNeeded();

      mAnalyst->Calculate(alg, windowFunc, mWindowSize, mRate,
         mData.get(), mDataLen,
         &mYMin, &mYMax, mProgress);
   }
   if (hadFocus) {
      hadFocus->SetFocus();
   }

   if (alg == SpectrumAnalyst::Spectrum) {
      if(mYMin < -dBRange)
         mYMin = -dBRange;
      if(mYMax <= -dBRange)
         mYMax = -dBRange + 10.; // it's all out of range, but show a scale.
      else
         mYMax += .5;
   }

   // Prime the scrollbar
   mPanScroller->SetScrollbar(0, (mYMax - mYMin) * 100, (mYMax - mYMin) * 100, 1);

   DrawPlot();
}
Exemple #28
0
bool wxNonOwnedWindow::Show(bool show)
{
    // NB: this calls wxWindow::Show() and so ensures DoRefreshWindow() is
    //     called on the window -- we'll need that below
    if ( !wxWindow::Show(show) )
        return false;

    // If this is the first time Show was called, send size event,
    // so that the frame can adjust itself (think auto layout or single child)
    if ( !m_sizeSet )
    {
        m_sizeSet = true;
        wxSizeEvent event(GetSize(), GetId());
        event.SetEventObject(this);
        HandleWindowEvent(event);
    }

    // make sure the window is fully painted, with all pending updates, before
    // DFB WM shows it, otherwise it would attempt to show either empty (=
    // black) window surface (if shown for the first time) or it would show
    // window with outdated content; note that the window was already refreshed
    // in the wxWindow::Show() call above:
    if ( show )
        Update();

    // hide/show the window by setting its opacity to 0/full:
    m_dfbwin->SetOpacity(show ? m_opacity : 0);

    if ( show )
    {
        wxWindow *focused = FindFocus();
        if ( focused && focused->GetTLW() == this )
        {
            // focus is on this frame or its children, apply it to DirectFB
            SetDfbFocus();
        }
        // else: don't do anything, if this is wxFrame or wxDialog that should
        //       get focus when it's shown,
        //       wxTopLevelWindowDFB::HandleFocusEvent() will do it as soon as
        //       the event loop starts
    }

    return true;
}
Exemple #29
0
bool wxDialogEx::ProcessEvent(wxEvent& event)
{
	if(event.GetEventType() != wxEVT_MENU) {
		return wxDialog::ProcessEvent(event);
	}

	wxTextEntry* e = GetSpecialTextEntry(FindFocus(), 'V');
	if( e && event.GetId() == pasteId ) {
		e->Paste();
		return true;
	}
	else if( e && event.GetId() == selectAllId ) {
		e->SelectAll();
		return true;
	}
	else {
		return wxDialog::ProcessEvent(event);
	}
}
Exemple #30
0
bool wxWindow::Enable(bool enable)
{
    if ( !wxWindowNative::Enable(enable) )
        return false;

    // disabled window can't keep focus
    if ( FindFocus() == this && GetParent() != NULL )
    {
        GetParent()->SetFocus();
    }

    if ( m_renderer )
    {
        // a window with renderer is drawn by ourselves and it has to be
        // refreshed to reflect its new status
        Refresh();
    }

    return true;
}