double wxTransformMatrix::Get_scaleX() { double scale_factor; double rot_angle = CheckInt(atan2(m_matrix[1][0],m_matrix[0][0])*180/pi); if ( !wxIsSameDouble(rot_angle, 90) && !wxIsSameDouble(rot_angle, -90) ) scale_factor = m_matrix[0][0]/cos((rot_angle/180)*pi); else scale_factor = m_matrix[0][0]/sin((rot_angle/180)*pi); // er kan nl. niet door 0 gedeeld worden ! scale_factor = CheckInt(scale_factor); if (scale_factor < 0) scale_factor = -scale_factor; return scale_factor; }
bool wxGridCellFloatEditor::EndEdit(int WXUNUSED(row), int WXUNUSED(col), const wxGrid* WXUNUSED(grid), const wxString& oldval, wxString *newval) { const wxString text(Text()->GetValue()); double value; if ( !text.empty() ) { if ( !text.ToDouble(&value) ) return false; } else // new value is empty string { if ( oldval.empty() ) return false; // nothing changed value = 0.; } // the test for empty strings ensures that we don't skip the value setting // when "" is replaced by "0" or vice versa as "" numeric value is also 0. if ( wxIsSameDouble(value, m_value) && !text.empty() && !oldval.empty() ) return false; // nothing changed m_value = value; if ( newval ) *newval = text; return true; }
bool wxTransformMatrix::operator == (const wxTransformMatrix& mat) const { if (m_isIdentity && mat.m_isIdentity) return true; int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { if ( !wxIsSameDouble(m_matrix[i][j], mat.m_matrix[i][j]) ) return false; } } return true; }
bool wxTextMeasureBase::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths, double scaleX) { int totalWidth = 0; // reset the cache if font or horizontal scale have changed if ( !s_fontWidthCache.m_widths || !wxIsSameDouble(s_fontWidthCache.m_scaleX, scaleX) || (s_fontWidthCache.m_font != *m_font) ) { s_fontWidthCache.Reset(); s_fontWidthCache.m_font = *m_font; s_fontWidthCache.m_scaleX = scaleX; } // Calculate the position of each character based on the widths of // the previous characters. This is inexact for not fixed fonts. int n = 0; for ( wxString::const_iterator it = text.begin(); it != text.end(); ++it ) { const wxChar c = *it; unsigned int c_int = (unsigned int)c; int w; if ((c_int < FWC_SIZE) && (s_fontWidthCache.m_widths[c_int] != 0)) { w = s_fontWidthCache.m_widths[c_int]; } else { DoGetTextExtent(c, &w, NULL); if (c_int < FWC_SIZE) s_fontWidthCache.m_widths[c_int] = w; } totalWidth += w; widths[n++] = totalWidth; } return true; }
static void gtk_value_changed(GtkRange* range, wxSlider* win) { const double value = gtk_range_get_value(range); const double oldPos = win->m_pos; win->m_pos = value; if (!win->m_hasVMT || g_blockEventsOnDrag) return; if (win->GTKEventsDisabled()) { win->m_scrollEventType = GTK_SCROLL_NONE; return; } wxEventType eventType = wxEVT_NULL; if (win->m_isScrolling) { eventType = wxEVT_SCROLL_THUMBTRACK; } else if (win->m_scrollEventType != GTK_SCROLL_NONE) { // Scroll event from "move-slider" (keyboard) eventType = GtkScrollTypeToWx(win->m_scrollEventType); } else if (win->m_mouseButtonDown) { // Difference from last change event const double diff = value - oldPos; const bool isDown = diff > 0; GtkAdjustment* adj = gtk_range_get_adjustment(range); if (IsScrollIncrement(gtk_adjustment_get_page_increment(adj), diff)) { eventType = isDown ? wxEVT_SCROLL_PAGEDOWN : wxEVT_SCROLL_PAGEUP; } else if (wxIsSameDouble(value, 0)) { eventType = wxEVT_SCROLL_PAGEUP; } else if (wxIsSameDouble(value, gtk_adjustment_get_upper(adj))) { eventType = wxEVT_SCROLL_PAGEDOWN; } else { // Assume track event eventType = wxEVT_SCROLL_THUMBTRACK; // Remember that we're tracking win->m_isScrolling = true; } } win->m_scrollEventType = GTK_SCROLL_NONE; // If integral position has changed if (wxRound(oldPos) != wxRound(value)) { ProcessScrollEvent(win, eventType); win->m_needThumbRelease = eventType == wxEVT_SCROLL_THUMBTRACK; } }