这篇教程C++ wxMax函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中wxMax函数的典型用法代码示例。如果您正苦于以下问题:C++ wxMax函数的具体用法?C++ wxMax怎么用?C++ wxMax使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了wxMax函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: wxRectvoid ViewPort::SetBoxes( void ){ // In the case where canvas rotation is applied, we need to define a larger "virtual" pixel window size to ensure that // enough chart data is fatched and available to fill the rotated screen. rv_rect = wxRect( 0, 0, pix_width, pix_height ); // Specify the minimum required rectangle in unrotated screen space which will supply full screen data after specified rotation if( ( g_bskew_comp && ( fabs( skew ) > .001 ) ) || ( fabs( rotation ) > .001 ) ) { double rotator = rotation; if(g_bskew_comp) rotator -= skew; int dy = wxRound( fabs( pix_height * cos( rotator ) ) + fabs( pix_width * sin( rotator ) ) ); int dx = wxRound( fabs( pix_width * cos( rotator ) ) + fabs( pix_height * sin( rotator ) ) ); // It is important for MSW build that viewport pixel dimensions be multiples of 4..... if( dy % 4 ) dy += 4 - ( dy % 4 ); if( dx % 4 ) dx += 4 - ( dx % 4 ); int inflate_x = wxMax(( dx - pix_width ) / 2, 0); int inflate_y = wxMax(( dy - pix_height ) / 2, 0); // Grow the source rectangle appropriately if( fabs( rotator ) > .001 ) rv_rect.Inflate( inflate_x, inflate_y ); } // Compute Viewport lat/lon reference points for co-ordinate hit testing // This must be done in unrotated space with respect to full unrotated screen space calculated above double rotation_save = rotation; SetRotationAngle( 0. ); wxPoint ul( rv_rect.x, rv_rect.y ), lr( rv_rect.x + rv_rect.width, rv_rect.y + rv_rect.height ); double dlat_min, dlat_max, dlon_min, dlon_max; bool hourglass = false; switch(m_projection_type) { case PROJECTION_TRANSVERSE_MERCATOR: case PROJECTION_STEREOGRAPHIC: case PROJECTION_GNOMONIC: hourglass = true; case PROJECTION_POLYCONIC: case PROJECTION_POLAR: case PROJECTION_ORTHOGRAPHIC: { double d; if( clat > 0 ) { // north polar wxPoint u( rv_rect.x + rv_rect.width/2, rv_rect.y ); wxPoint ur( rv_rect.x + rv_rect.width, rv_rect.y ); GetLLFromPix( ul, &d, &dlon_min ); GetLLFromPix( ur, &d, &dlon_max ); GetLLFromPix( lr, &dlat_min, &d ); GetLLFromPix( u, &dlat_max, &d ); if(fabs(fabs(d - clon) - 180) < 1) { // the pole is onscreen dlat_max = 90; dlon_min = -180; dlon_max = 180; } else if(wxIsNaN(dlat_max)) dlat_max = 90; if(hourglass) { // near equator, center may be less wxPoint l( rv_rect.x + rv_rect.width/2, rv_rect.y + rv_rect.height ); double dlat_min2; GetLLFromPix( l, &dlat_min2, &d ); dlat_min = wxMin(dlat_min, dlat_min2); } if(wxIsNaN(dlat_min)) // world is off-screen dlat_min = clat - 90; } else { // south polar wxPoint l( rv_rect.x + rv_rect.width/2, rv_rect.y + rv_rect.height ); wxPoint ll( rv_rect.x, rv_rect.y + rv_rect.height ); GetLLFromPix( ul, &dlat_max, &d ); GetLLFromPix( lr, &d, &dlon_max ); GetLLFromPix( ll, &d, &dlon_min ); GetLLFromPix( l, &dlat_min, &d ); if(fabs(fabs(d - clon) - 180) < 1) { // the pole is onscreen dlat_min = -90; dlon_min = -180; dlon_max = 180; } else if(wxIsNaN(dlat_min)) dlat_min = -90; if(hourglass) { // near equator, center may be less wxPoint u( rv_rect.x + rv_rect.width/2, rv_rect.y ); double dlat_max2; GetLLFromPix( u, &dlat_max2, &d ); dlat_max = wxMax(dlat_max, dlat_max2); }//.........这里部分代码省略.........
开发者ID:thielj,项目名称:OpenCPN,代码行数:101,
示例2: wxDialogVampEffectDialog::VampEffectDialog(VampEffect *effect, wxWindow *parent, Vamp::Plugin *plugin) : wxDialog(parent, -1, effect->GetEffectName(), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), mEffect(effect), mPlugin(plugin){ Vamp::Plugin::ProgramList programs = plugin->getPrograms(); mParameters = plugin->getParameterDescriptors();#ifdef __WXMSW__ // On Windows, for some reason, wxWindows calls OnTextCtrl during creation // of the text control, and VampEffectDialog::OnTextCtrl calls HandleText, // which assumes all the fields have been initialized. // This can give us a bad pointer crash, so manipulate inSlider to // no-op HandleText during creation. inSlider = true;#else inSlider = false;#endif inText = false; int count = mParameters.size(); toggles = new wxCheckBox*[count]; sliders = new wxSlider*[count]; fields = new wxTextCtrl*[count]; labels = new wxStaticText*[count]; combos = new wxComboBox*[count]; wxControl *item; wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL); item = new wxStaticText(this, 0, LAT1CTOWX(plugin->getName().c_str()) + wxString(_(" - Vamp audio analysis plugin"))); vSizer->Add(item, 0, wxALL, 5); item = new wxStaticText(this, 0, LAT1CTOWX(plugin->getDescription().c_str())); vSizer->Add(item, 0, wxALL, 5); item = new wxStaticText(this, 0, wxString(_("Author: ")) + LAT1CTOWX(plugin->getMaker().c_str())); vSizer->Add(item, 0, wxALL, 5); item = new wxStaticText(this, 0, LAT1CTOWX(plugin->getCopyright().c_str())); vSizer->Add(item, 0, wxALL, 5); wxScrolledWindow *w = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL | wxTAB_TRAVERSAL); // Try to give the window a sensible default/minimum size w->SetMinSize(wxSize( wxMax(400, parent->GetSize().GetWidth() / 2), parent->GetSize().GetHeight() / 2)); w->SetScrollRate(0, 20); vSizer->Add(w, 1, wxEXPAND|wxALL, 5); vSizer->Add(CreateStdButtonSizer(this, eCancelButton|eOkButton), 0, wxEXPAND); SetSizer(vSizer); wxSizer *paramSizer = new wxStaticBoxSizer(wxVERTICAL, w, _("Plugin Settings")); wxFlexGridSizer *gridSizer = new wxFlexGridSizer(5, 0, 0); gridSizer->AddGrowableCol(3); programCombo = 0; if (!programs.empty()) { wxArrayString choices; wxString currentProgram = wxString(mPlugin->getCurrentProgram().c_str(), wxConvISO8859_1); for (size_t i = 0; i < programs.size(); ++i) { wxString choice = wxString(programs[i].c_str(), wxConvISO8859_1); choices.Add(choice); } gridSizer->Add(new wxStaticText(w, 0, _("Program")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); programCombo = new wxComboBox(w, 9999, currentProgram, wxDefaultPosition, wxDefaultSize,//.........这里部分代码省略.........
开发者ID:tuanmasterit,项目名称:audacity,代码行数:101,
示例3: wxMaxbool wxRibbonButtonBar::TryCollapseLayout(wxRibbonButtonBarLayout* original, size_t first_btn, size_t* last_button){ size_t btn_count = m_buttons.Count(); size_t btn_i; int used_height = 0; int used_width = 0; int available_width = 0; int available_height = 0; for(btn_i = first_btn + 1; btn_i > 0; /* decrement is inside loop */) { --btn_i; wxRibbonButtonBarButtonBase* button = m_buttons.Item(btn_i); wxRibbonButtonBarButtonState large_size_class = button->GetLargestSize(); wxSize large_size = button->sizes[large_size_class].size; int t_available_height = wxMax(available_height, large_size.GetHeight()); int t_available_width = available_width + large_size.GetWidth(); wxRibbonButtonBarButtonState small_size_class = large_size_class; if(!button->GetSmallerSize(&small_size_class)) { return false; } wxSize small_size = button->sizes[small_size_class].size; int t_used_height = used_height + small_size.GetHeight(); int t_used_width = wxMax(used_width, small_size.GetWidth()); if(t_used_height > t_available_height) { ++btn_i; break; } else { used_height = t_used_height; used_width = t_used_width; available_width = t_available_width; available_height = t_available_height; } } if(btn_i >= first_btn || used_width >= available_width) { return false; } if(last_button != NULL) { *last_button = btn_i; } wxRibbonButtonBarLayout* layout = new wxRibbonButtonBarLayout; WX_APPEND_ARRAY(layout->buttons, original->buttons); wxPoint cursor(layout->buttons.Item(btn_i).position); bool preserve_height = false; if(btn_i == 0) { // If height isn't preserved (i.e. it is reduced), then the minimum // size for the button bar will decrease, preventing the original // layout from being used (in some cases). // It may be a good idea to always preserve the height, but for now // it is only done when the first button is involved in a collapse. preserve_height = true; } for(; btn_i <= first_btn; ++btn_i) { wxRibbonButtonBarButtonInstance& instance = layout->buttons.Item(btn_i); instance.base->GetSmallerSize(&instance.size); instance.position = cursor; cursor.y += instance.base->sizes[instance.size].size.GetHeight(); } int x_adjust = available_width - used_width; for(; btn_i < btn_count; ++btn_i) { wxRibbonButtonBarButtonInstance& instance = layout->buttons.Item(btn_i); instance.position.x -= x_adjust; } layout->CalculateOverallSize(); // Sanity check if(layout->overall_size.GetWidth() >= original->overall_size.GetWidth() || layout->overall_size.GetHeight() > original->overall_size.GetHeight()) { delete layout; wxFAIL_MSG("Layout collapse resulted in increased size"); return false; } if(preserve_height) { layout->overall_size.SetHeight(original->overall_size.GetHeight()); } m_layouts.Add(layout); return true;}
开发者ID:mael15,项目名称:wxWidgets,代码行数:100,
示例4: wxMax//*********************************************************************************// draw pressure scale//*********************************************************************************void DashboardInstrument_BaroHistory::DrawWindSpeedScale(wxGCDC* dc){ wxString label1,label2,label3,label4,label5; wxColour cl; int width, height; cl=wxColour(61,61,204,255); dc->SetTextForeground(cl); dc->SetFont(*g_pFontSmall); //round m_MaxPress up to the next hpa ... if (m_MaxPress > 1100) m_MaxPress=1100; if (m_TotalMinPress < 930) m_TotalMinPress=930; m_MaxPressScale= (int)((m_MaxPress+15)-(m_TotalMinPress-15)); if(!m_IsRunning) { label1=_T("-- hPa"); label2=_T("-- hPa"); label3=_T("-- hPa"); label4=_T("-- hPa"); label5=_T("-- hPa"); } else {/* The goal is to draw the legend with decimals only, if we really have them !*/ // top legend for max press label1.Printf(_T("%.0f hPa"), m_MaxPressScale +(m_TotalMinPress-18) ); // 3/4 legend label2.Printf(_T("%.0f hPa"), m_MaxPressScale *3./4 + (m_TotalMinPress-18) ); // center legend label3.Printf(_T("%.0f hPa"), m_MaxPressScale /2 +(m_TotalMinPress-18)); // 1/4 legend label4.Printf(_T("%.0f hPa"), m_MaxPressScale /4 +(m_TotalMinPress-18) ); //bottom legend for min wind label5.Printf(_T("%.0f hPa"), (m_TotalMinPress-18)); } dc->GetTextExtent(label1, &m_LeftLegend, &height, 0, 0, g_pFontSmall); dc->DrawText(label1, 4, (int)(m_TopLineHeight-height/2)); dc->GetTextExtent(label2, &width, &height, 0, 0, g_pFontSmall); dc->DrawText(label2, 4, (int)(m_TopLineHeight+m_DrawAreaRect.height/4-height/2)); m_LeftLegend = wxMax(width,m_LeftLegend); dc->GetTextExtent(label3, &width, &height, 0, 0, g_pFontSmall); dc->DrawText(label3, 4, (int)(m_TopLineHeight+m_DrawAreaRect.height/2-height/2)); m_LeftLegend = wxMax(width,m_LeftLegend); dc->GetTextExtent(label4, &width, &height, 0, 0, g_pFontSmall); dc->DrawText(label4, 4, (int)(m_TopLineHeight+m_DrawAreaRect.height*0.75-height/2)); m_LeftLegend = wxMax(width,m_LeftLegend); dc->GetTextExtent(label5, &width, &height, 0, 0, g_pFontSmall); dc->DrawText(label5, 4, (int)(m_TopLineHeight+m_DrawAreaRect.height-height/2)); m_LeftLegend = wxMax(width,m_LeftLegend); m_LeftLegend+=4;}
开发者ID:KastB,项目名称:OpenCPN,代码行数:66,
示例5: bordersvoid HexEditorCtrl::OnResize( wxSizeEvent &event ){ int x = event.GetSize().GetX(); int y = event.GetSize().GetY(); int charx = hex_ctrl->GetCharSize().GetX(); int chartx = text_ctrl->GetCharSize().GetX(); int offset_x = offset_ctrl->GetCharSize().GetX()*offset_ctrl->GetLineSize();// + 4; offset_x = offset_ctrl->IsShown() ? offset_x : 0; x -= offset_x; //Remove Offset Control box X because its changeable x -= offset_scroll_real->GetSize().GetX(); //Remove Offset scroll size x -= 4*2; //+x 4 pixel external borders (dark ones, 2 pix each size) x = wxMax(0,x); //Avoid X being negative y -= m_static_byteview->GetSize().GetY(); //Remove Head Text Y //AutoFill: bool custom_hex_format; wxConfig::Get()->Read( wxT("UseCustomHexFormat"), &custom_hex_format, false ); wxString fmt(wxT("xx ")); if( custom_hex_format ) wxConfig::Get()->Read( wxT("CustomHexFormat"), &fmt, wxT("xx "));// TODO (death#1#): Move style engine somewhere else to speedy resizing. hex_ctrl->SetFormat( fmt ); int cnt_chr=0; //Counted character at current format for( unsigned i = 0 ; i < fmt.Len() ; i++ ){ if( fmt[i]!=' ' ) cnt_chr++; } cnt_chr/=2; // divide 2 for find byte per hex representation. int hexchr=0,textchr = 0; //Recalculate available area due hidden panels. hexchr+=hex_ctrl->IsShown() ? fmt.Len() : 0; textchr+=text_ctrl->IsShown() ? cnt_chr : 0; int available_space=0; available_space=x/(hexchr*charx+textchr*chartx/(GetCharToHexSize()/2)); //Limiting Bytes Per Line bool use_BytesPerLineLimit; wxConfig::Get()->Read( wxT("UseBytesPerLineLimit"), &use_BytesPerLineLimit, false ); if( use_BytesPerLineLimit ){ int BytesPerLineLimit; wxConfig::Get()->Read( wxT("BytesPerLineLimit"), reinterpret_cast<int*>(&BytesPerLineLimit), 16); //Downsizing is available if( available_space*cnt_chr > BytesPerLineLimit ) available_space = BytesPerLineLimit/cnt_chr; } //Calculation of available area for Hex and Text panels. int text_x = chartx*available_space*cnt_chr/(GetCharToHexSize()/2) +2 +4; int hex_x = charx*available_space*fmt.Len() +2 +4 - charx ; //no need for last gap; int ByteShownPerLine=available_space*cnt_chr; text_x = text_ctrl->IsShown() ? text_x : 0; hex_x = hex_ctrl->IsShown() ? hex_x : 0;#ifdef _DEBUG_SIZE_ std::cout<< "HexEditorCtrl::OnResize()" << std::endl << "HexEditorCtrl SizeEvent ReSize Command=(" << event.GetSize().GetX() << ',' << event.GetSize().GetY() << ")/n" << "Offset Scrll: /t(" << offset_scroll->GetSize().GetX() << ',' << event.GetSize().GetY() <<")/n" << "Offset Ctrl: /t(" << offset_ctrl->GetSize().GetX() << ',' << event.GetSize().GetY() <<")/n" << "Hex Ctrl: /t(" << hex_x << ',' << event.GetSize().GetY() << ")/n" << "Text Ctrl: /t(" << text_x << ',' << event.GetSize().GetY() << ")/n" << "Hex Char: /t" << charx << std::endl << "ByteShownPerLine: /t" << ByteShownPerLine << std::endl;#endif offset_ctrl->SetMinSize( wxSize( offset_x , y ) );// offset_ctrl->SetSize( wxSize( offset_x , y ) ); //Not needed, Layout() Makes the job well. m_static_offset->SetMinSize( wxSize(offset_x, m_static_offset->GetSize().GetY()) ); hex_ctrl->SetMinSize( wxSize( hex_x, y ));// hex_ctrl->SetSize( wxSize( hex_x, y )); m_static_address->SetMinSize( wxSize(hex_x, m_static_offset->GetSize().GetY()) ) ; text_ctrl->SetMinSize( wxSize( text_x, y ));// text_ctrl->SetSize( wxSize( text_x, y )); m_static_byteview->SetMinSize( wxSize( text_x, m_static_offset->GetSize().GetY()) ); // Destroy the sizer created by the form builder before adding the windows // managed by it to another sizer, otherwise we would crash later when // destroying the sizer as it wouldn't know about the windows it contains. SetSizer(NULL); //Preparing Sizer wxFlexGridSizer* fgSizer1 = new wxFlexGridSizer( 2, 4, 0, 0 );#if 1 fgSizer1->Add( m_static_offset, 0, wxALIGN_CENTER|wxLEFT, 5 ); fgSizer1->Add( m_static_address, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT, 2 ); fgSizer1->Add( m_static_byteview, 0, wxALIGN_CENTER|wxALL, 0 ); fgSizer1->Add( m_static_null, 0, wxALIGN_CENTER, 3 ); fgSizer1->Add( offset_ctrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 0 ); fgSizer1->Add( hex_ctrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 0 ); fgSizer1->Add( text_ctrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 0 ); fgSizer1->Add( offset_scroll_real, 0, wxEXPAND, 0 );#else fgSizer1->Add( m_static_offset, 0, wxALIGN_CENTER|wxLEFT, 0 );//.........这里部分代码省略.........
开发者ID:ChunHungLiu,项目名称:wxHexEditor,代码行数:101,
示例6: RecalculateSize//.........这里部分代码省略......... m_ptextctrl = new wxTextCtrl( this, -1, _T(""), wxPoint( sx * 3 / 100, 6 ), texc_size , wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP); int bsx, bsy, bpx, bpy; PR_button->GetSize( &bsx, &bsy ); PR_button->GetPosition( &bpx, &bpy ); NX_button = new wxButton( this, ID_TCWIN_NX, _( "Next" ), wxPoint( bpx + bsx + 5, sy - (m_tsy + 10) ), wxSize( -1, -1 ) ); m_TCWinPopupTimer.SetOwner( this, TCWININF_TIMER ); wxScreenDC dc; int text_height; dc.GetTextExtent(_T("W"), NULL, &text_height); m_button_height = m_tsy; //text_height + 20; // Build graphics tools wxFont *dlg_font = FontMgr::Get().GetFont( _("Dialog") ); int dlg_font_size = dlg_font->GetPointSize(); pSFont = FontMgr::Get().FindOrCreateFont( dlg_font_size-2, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, FALSE, wxString( _T ( "Arial" ) ) ); pSMFont = FontMgr::Get().FindOrCreateFont( dlg_font_size-1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, FALSE, wxString( _T ( "Arial" ) ) ); pMFont = FontMgr::Get().FindOrCreateFont( dlg_font_size, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, FALSE, wxString( _T ( "Arial" ) ) ); pLFont = FontMgr::Get().FindOrCreateFont( dlg_font_size+1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, FALSE, wxString( _T ( "Arial" ) ) ); pblack_1 = wxThePenList->FindOrCreatePen( GetGlobalColor( _T ( "UINFD" ) ), wxMax(1,(int)(m_tcwin_scaler+0.5)), wxPENSTYLE_SOLID ); pblack_2 = wxThePenList->FindOrCreatePen( GetGlobalColor( _T ( "UINFD" ) ), wxMax(2,(int)(2*m_tcwin_scaler+0.5)), wxPENSTYLE_SOLID ); pblack_3 = wxThePenList->FindOrCreatePen( GetGlobalColor( _T ( "UWHIT" ) ), wxMax(1,(int)(m_tcwin_scaler+0.5)), wxPENSTYLE_SOLID ); pred_2 = wxThePenList->FindOrCreatePen( GetGlobalColor( _T ( "UINFR" ) ), wxMax(4,(int)(4*m_tcwin_scaler+0.5)), wxPENSTYLE_SOLID ); pltgray = wxTheBrushList->FindOrCreateBrush( GetGlobalColor( _T ( "UIBCK" ) ), wxBRUSHSTYLE_SOLID ); pltgray2 = wxTheBrushList->FindOrCreateBrush( GetGlobalColor( _T ( "DILG1" ) ), wxBRUSHSTYLE_SOLID ); DimeControl( this ); // Fill in some static text control information // Tidi station information m_ptextctrl->Clear(); wxString locn( pIDX->IDX_station_name, wxConvUTF8 ); wxString locna, locnb; if( locn.Contains( wxString( _T ( "," ) ) ) ) { locna = locn.BeforeFirst( ',' ); locnb = locn.AfterFirst( ',' ); } else { locna = locn; locnb.Empty(); } // write the first line wxTextAttr style; style.SetFont( *pLFont );
开发者ID:mookiejones,项目名称:OpenCPN,代码行数:67,
示例7: endCallbackvoid __CALL_CONVENTION endCallback(void){ // Create a TriPrim char buf[40]; if(s_nvcall > s_nvmax) // keep track of largest number of triangle vertices s_nvmax = s_nvcall; switch(s_gltri_type) { case GL_TRIANGLE_FAN: case GL_TRIANGLE_STRIP: case GL_TRIANGLES: { TriPrim *pTPG = new TriPrim; if(NULL == s_pTPG_Last) { s_pTPG_Head = pTPG; s_pTPG_Last = pTPG; } else { s_pTPG_Last->p_next = pTPG; s_pTPG_Last = pTPG; } pTPG->p_next = NULL; pTPG->type = s_gltri_type; pTPG->nVert = s_nvcall; // Calculate bounding box float sxmax = -1000; // this poly BBox float sxmin = 1000; float symax = -90; float symin = 90; GLdouble *pvr = s_pwork_buf; for(int iv=0 ; iv < s_nvcall ; iv++) { GLdouble xd, yd; xd = *pvr++; yd = *pvr++; if(s_bmerc_transform) { double valx = ( xd * s_transform_x_rate ) + s_transform_x_origin; double valy = ( yd * s_transform_y_rate ) + s_transform_y_origin; // Convert to lat/lon double lat = ( 2.0 * atan ( exp ( valy/CM93_semimajor_axis_meters ) ) - PI/2. ) / DEGREE; double lon = ( valx / ( DEGREE * CM93_semimajor_axis_meters ) ); sxmax = wxMax(lon, sxmax); sxmin = wxMin(lon, sxmin); symax = wxMax(lat, symax); symin = wxMin(lat, symin); } else { sxmax = wxMax(xd, sxmax); sxmin = wxMin(xd, sxmin); symax = wxMax(yd, symax); symin = wxMin(yd, symin); } } pTPG->tri_box.Set(symin, sxmin, symax, sxmax); // Transcribe this geometry to TriPrim, converting to SM if called for if(s_bSENC_SM) { GLdouble *pds = s_pwork_buf; pTPG->p_vertex = (double *)malloc(s_nvcall * 2 * sizeof(double)); GLdouble *pdd = (GLdouble*)pTPG->p_vertex; for(int ip = 0 ; ip < s_nvcall ; ip++) { double dlon = *pds++; double dlat = *pds++; double easting, northing; toSM(dlat, dlon, s_ref_lat, s_ref_lon, &easting, &northing); *pdd++ = easting; *pdd++ = northing; } } else { pTPG->p_vertex = (double *)malloc(s_nvcall * 2 * sizeof(double)); memcpy(pTPG->p_vertex, s_pwork_buf, s_nvcall * 2 * sizeof(double)); } break; } default: { sprintf(buf, "....begin Callback unknown/n");//.........这里部分代码省略.........
开发者ID:balp,项目名称:OpenCPN,代码行数:101,
示例8: WXUNUSEDLV2EffectDialog::LV2EffectDialog(LV2Effect *effect, wxWindow *parent, const LilvPlugin *data, int sampleRate, double length, double WXUNUSED(noteLength), unsigned char WXUNUSED(noteVelocity), unsigned char WXUNUSED(noteKey)): wxDialog(parent, wxID_ANY, mEffect->GetString(lilv_plugin_get_name(data)), wxDefaultPosition, wxSize(500, -1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), mEffect(effect), mData(data), mControls(effect->GetControls()), mSampleRate(sampleRate), mLength(length){#if defined(__WXMSW__) // On Windows, for some reason, wxWindows calls OnTextCtrl during creation // of the text control, and LV2EffectDialog::OnTextCtrl calls HandleText, // which assumes all the mFields have been initialized. // This can give us a bad pointer crash, so manipulate inSlider to // no-op HandleText during creation. inSlider = true;#else inSlider = false;#endif inText = false; inText = true; // Allocate memory for the user parameter controls int ctrlcnt = (int) mControls.GetCount(); mToggles = new wxCheckBox*[ctrlcnt]; mSliders = new wxSlider*[ctrlcnt]; mFields = new wxTextCtrl*[ctrlcnt]; mLabels = new wxStaticText*[ctrlcnt]; mEnums = new wxChoice*[ctrlcnt]; wxControl *item; wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL); // Add information about the plugin LilvNode *tmpValue = lilv_plugin_get_author_name(data); if (tmpValue) { wxString author(_("Author: ") + mEffect->GetString(tmpValue)); item = new wxStaticText(this, wxID_ANY, author); vSizer->Add(item, 0, wxALL, 5); lilv_node_free(tmpValue); } wxScrolledWindow *w = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL | wxTAB_TRAVERSAL); // Try to give the window a sensible default/minimum size w->SetMinSize(wxSize( wxMax(600, parent->GetSize().GetWidth() * 2/3), parent->GetSize().GetHeight() / 2)); w->SetScrollRate(0, 20); vSizer->Add(w, 1, wxEXPAND|wxALL, 5); // Preview, OK, & Cancel buttons vSizer->Add(CreateStdButtonSizer(this, ePreviewButton|eCancelButton|eOkButton), 0, wxEXPAND); SetSizer(vSizer); wxSizer *paramSizer = new wxStaticBoxSizer(wxVERTICAL, w, _("Effect Settings")); wxFlexGridSizer *gridSizer = new wxFlexGridSizer(5, 0, 0); gridSizer->AddGrowableCol(3); // Now add the length control if (mEffect->GetEffectFlags() & INSERT_EFFECT) { item = new wxStaticText(w, 0, _("Length (seconds)")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); mSeconds = new wxTextCtrl(w, LADSPA_SECONDS_ID, Internat::ToDisplayString(length)); mSeconds->SetName(_("Length (seconds)")); gridSizer->Add(mSeconds, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); ConnectFocus(mSeconds); } // The note controls if the plugin is a synth if (mEffect->IsSynth()) { // Note length control item = new wxStaticText(w, wxID_ANY, _("Note length (seconds)")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);//.........这里部分代码省略.........
开发者ID:jazhaozhao,项目名称:audacity,代码行数:101,
示例9: GetSizevoid wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags){ int i; wxRadioButton *current; // define the position int x_current, y_current; int x_offset, y_offset; int widthOld, heightOld; GetSize( &widthOld, &heightOld ); GetPosition( &x_current, &y_current ); x_offset = x; y_offset = y; if (!(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { if (x == wxDefaultCoord) x_offset = x_current; if (y == wxDefaultCoord) y_offset = y_current; } // define size int charWidth, charHeight; int maxWidth, maxHeight; int eachWidth[128], eachHeight[128]; int totWidth, totHeight; GetTextExtent( wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight ); charWidth /= 52; maxWidth = -1; maxHeight = -1; wxSize bestSizeRadio ; if ( m_radioButtonCycle ) bestSizeRadio = m_radioButtonCycle->GetBestSize(); for (unsigned int i = 0 ; i < m_noItems; i++) { GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i] ); eachWidth[i] = eachWidth[i] + RADIO_SIZE; eachHeight[i] = wxMax( eachHeight[i], bestSizeRadio.y ); if (maxWidth < eachWidth[i]) maxWidth = eachWidth[i]; if (maxHeight < eachHeight[i]) maxHeight = eachHeight[i]; } // according to HIG (official space - 3 Pixels Diff between Frame and Layout size) int space = 3; if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI ) space = 2; totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * space; totWidth = GetColumnCount() * (maxWidth + charWidth); wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) ) ; // change the width / height only when specified if ( width == wxDefaultCoord ) { if ( sizeFlags & wxSIZE_AUTO_WIDTH ) width = sz.x; else width = widthOld; } if ( height == wxDefaultCoord ) { if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) height = sz.y; else height = heightOld; } wxControl::DoSetSize( x_offset, y_offset, width, height, wxSIZE_AUTO ); // arrange radio buttons int x_start, y_start; x_start = ( width - sz.x ) / 2; y_start = ( height - sz.y ) / 2; x_offset = x_start; y_offset = y_start; current = m_radioButtonCycle; for (i = 0 ; i < (int)m_noItems; i++) { // not to do for the zero button! if ((i > 0) && ((i % GetMajorDim()) == 0)) { if (m_windowStyle & wxRA_SPECIFY_ROWS) {//.........这里部分代码省略.........
开发者ID:Kaoswerk,项目名称:newton-dynamics,代码行数:101,
示例10: wxASSERTvoid GutterCtrl::OnMouseLeftDown(wxMouseEvent& event) { //wxLogDebug("OnMouseLeftDown"); //wxASSERT(m_editorCtrl); wxASSERT(m_currentSel == -1); Lines& lines = m_editorCtrl.GetLines(); // Get Mouse location const int x = event.GetX(); const int y = event.GetY() + m_editorCtrl.GetYScrollPos(); // Handle bookmarks if (m_showBookmarks && x < (int)m_numberX) { // Find out which line was clicked on if ((int)y < lines.GetHeight()) { const unsigned int line_id = lines.GetLineFromYPos(y); m_editorCtrl.AddBookmark(line_id, true /*toggle*/); DrawGutter(); // Redraw gutter to show bookmarks return; } } // Handle folding if (m_showFolds && x > (int)m_foldStartX) { ClickOnFold(y); return; } bool hasSelection = false; interval sel(0, 0); if (event.ShiftDown() && lines.IsSelected()) { sel = lines.GetSelections()[lines.GetLastSelection()]; hasSelection = true; } // If not multiselecting or extending, remove previous selections if (!event.ControlDown()) { lines.RemoveAllSelections(); } // Find out which line was clicked on if (y < lines.GetHeight()) { const unsigned int line_id = lines.GetLineFromYPos(y); // Select the line if (!lines.isLineVirtual(line_id)) { int startpos = lines.GetLineStartpos(line_id); int endpos = lines.GetLineEndpos(line_id, false); if (hasSelection) { startpos = wxMin(startpos, (int)sel.start); endpos = wxMax(endpos, (int)sel.end); } m_currentSel = lines.AddSelection(startpos, endpos); lines.SetPos(endpos); m_editorCtrl.SetFocus(); m_sel_startline = m_sel_endline = line_id; } m_sel_startoutside = false; } else { const unsigned int linecount = lines.GetLineCount(); m_sel_startline = m_sel_endline = linecount ? linecount-1 : 0; m_sel_startoutside = true; if (hasSelection) { m_currentSel = lines.AddSelection(sel.start, lines.GetLength()); lines.SetPos(lines.GetLength()); m_editorCtrl.SetFocus(); } } // Make sure we capure all mouse events // this is released in OnMouseLeftUp() CaptureMouse(); // Redraw the editCtrl to show new selection m_editorCtrl.DrawLayout();}
开发者ID:dxtravi,项目名称:e,代码行数:80,
示例11: ifvoid GutterCtrl::OnMouseMotion(wxMouseEvent& event) { Lines& lines = m_editorCtrl.GetLines(); // Get Mouse location const int y = event.GetY() + m_editorCtrl.GetYScrollPos(); if (event.LeftIsDown() && HasCapture()) { // Find out what is under mouse unsigned int line_id; if (y < 0) line_id = 0; else if (y < lines.GetHeight()) { line_id = lines.GetLineFromYPos(y); } else { if (m_sel_startoutside && m_currentSel != -1) { // Make sure we remove current selection m_currentSel = lines.UpdateSelection(m_currentSel, 0, 0); lines.SetPos(lines.GetLength()); m_editorCtrl.DrawLayout(); return; } const unsigned int linecount = lines.GetLineCount(); line_id = linecount ? linecount-1 : 0; } // Select the lines if (line_id != m_sel_endline) { m_sel_endline = line_id; int sel_start = lines.GetLineStartpos(wxMin(m_sel_startline, m_sel_endline)); int sel_end = lines.GetLineEndpos(wxMax(m_sel_startline, m_sel_endline), false); if (sel_start == sel_end) { lines.RemoveAllSelections(); m_currentSel = -1; } else { // Update the lines selection info if (m_currentSel == -1) { m_currentSel = lines.AddSelection(sel_start, sel_end); } else { m_currentSel = lines.UpdateSelection(m_currentSel, sel_start, sel_end); } lines.SetPos(m_sel_endline < m_sel_startline ? sel_start : sel_end); } m_editorCtrl.MakeCaretVisible(); // also ensures scrolling if outside window m_editorCtrl.DrawLayout(); } } else if (event.GetX() > (int)m_foldStartX && 0 <=y && y < lines.GetHeight()) { const unsigned int line_id = lines.GetLineFromYPos(y); vector<cxFold*> foldStack = m_editorCtrl.GetFoldStack(line_id); if (!foldStack.empty()) { m_currentFold = foldStack.back(); DrawGutter(); // Redraw gutter to show highlights return; } } if (m_currentFold) { m_currentFold = NULL; DrawGutter(); // Redraw gutter to remove highlights }}
开发者ID:dxtravi,项目名称:e,代码行数:67,
示例12: bmp// Build the calibration "step" graph which will appear on the lefthand side of the panelswxBitmap CalReviewDialog::CreateGraph(bool AO){ wxMemoryDC memDC; wxBitmap bmp(CALREVIEW_BITMAP_SIZE, CALREVIEW_BITMAP_SIZE, -1); wxPen axisPen("GREY", 3, wxCROSS_HATCH); wxColour raColor = pFrame->pGraphLog->GetRaOrDxColor(); wxColour decColor = pFrame->pGraphLog->GetDecOrDyColor(); wxPen raPen(raColor, 3, wxSOLID); wxPen decPen(decColor, 3, wxSOLID); wxBrush raBrush(raColor, wxSOLID); wxBrush decBrush(decColor, wxSOLID); CalibrationDetails calDetails; double scaleFactor; int ptRadius; if (!pSecondaryMount) { pMount->GetCalibrationDetails(&calDetails); // Normal case, no AO } else { if (AO) { pMount->GetCalibrationDetails(&calDetails); // AO tab, use AO details } else { pSecondaryMount->GetCalibrationDetails(&calDetails); // Mount tab, use mount details } } // Find the max excursion from the origin in order to scale the points to fit the bitmap double biggestVal = -100.0; for (std::vector<wxRealPoint>::const_iterator it = calDetails.raSteps.begin(); it != calDetails.raSteps.end(); ++it) { biggestVal = wxMax(biggestVal, fabs(it->x)); biggestVal = wxMax(biggestVal, fabs(it->y)); } for (std::vector<wxRealPoint>::const_iterator it = calDetails.decSteps.begin(); it != calDetails.decSteps.end(); ++it) { biggestVal = wxMax(biggestVal, fabs(it->x)); biggestVal = wxMax(biggestVal, fabs(it->y)); } if (biggestVal > 0.0) scaleFactor = ((CALREVIEW_BITMAP_SIZE - 5) / 2) / biggestVal; // Leave room for circular point else scaleFactor = 1.0; memDC.SelectObject(bmp); memDC.SetBackground(*wxBLACK_BRUSH); memDC.Clear(); memDC.SetPen(axisPen); // Draw the axes memDC.SetDeviceOrigin(wxCoord(CALREVIEW_BITMAP_SIZE / 2), wxCoord(CALREVIEW_BITMAP_SIZE / 2)); memDC.DrawLine(-CALREVIEW_BITMAP_SIZE / 2, 0, CALREVIEW_BITMAP_SIZE / 2, 0); // x memDC.DrawLine(0, -CALREVIEW_BITMAP_SIZE / 2, 0, CALREVIEW_BITMAP_SIZE / 2); // y if (calDetails.raStepCount > 0) { // Draw the RA data memDC.SetPen(raPen); memDC.SetBrush(raBrush); ptRadius = 2; // Scale the points, then plot them individually for (int i = 0; i < (int) calDetails.raSteps.size(); i++) { if (i == calDetails.raStepCount + 2) // Valid even for "single-step" calibration { memDC.SetPen(wxPen(raColor, 1)); // 1-pixel-thick outline memDC.SetBrush(wxNullBrush); // Outline only for "return" data points ptRadius = 3; } memDC.DrawCircle(IntPoint(calDetails.raSteps.at(i), scaleFactor), ptRadius); } // Show the line PHD2 will use for the rate memDC.SetPen(raPen); if ((int)calDetails.raSteps.size() > calDetails.raStepCount) // New calib, includes return values memDC.DrawLine(IntPoint(calDetails.raSteps.at(0), scaleFactor), IntPoint(calDetails.raSteps.at(calDetails.raStepCount), scaleFactor)); else memDC.DrawLine(IntPoint(calDetails.raSteps.at(0), scaleFactor), IntPoint(calDetails.raSteps.at(calDetails.raStepCount - 1), scaleFactor)); } // Handle the Dec data memDC.SetPen(decPen); memDC.SetBrush(decBrush); ptRadius = 2; if (calDetails.decStepCount > 0) { for (int i = 0; i < (int) calDetails.decSteps.size(); i++) { if (i == calDetails.decStepCount + 2) { memDC.SetPen(wxPen(decColor, 1)); // 1-pixel-thick outline memDC.SetBrush(wxNullBrush); // Outline only for "return" data points ptRadius = 3; }//.........这里部分代码省略.........
开发者ID:AndresPozo,项目名称:phd2,代码行数:101,
示例13: wxColour//*********************************************************************************// draw wind speed scale//*********************************************************************************void TacticsInstrument_WindDirHistory::DrawWindSpeedScale(wxGCDC* dc){ wxString label1, label2, label3, label4, label5; wxColour cl; int width, height; double val1; double WindSpdScale; cl = wxColour(61, 61, 204, 255); dc->SetTextForeground(cl); dc->SetFont(*g_pFontSmall); //round maxWindSpd up to the next full knot; nicer view ... m_MaxWindSpdScale = (int)m_MaxWindSpd + 1; if (!m_IsRunning) { label1.Printf(_T("--- %s"), m_WindSpeedUnit.c_str()); label2 = label1; label3 = label1; label4 = label1; label5 = label1; } else { /*we round the speed up to the next full knot ==> the top and bottom line have full numbers as legend (e.g. 23 kn -- 0 kn) but the intermediate lines may have decimal values (e.g. center line : 23/2=11.5 or quarter line 23/4=5.75), so in worst case we end up with 23 - 17.25 - 11.5 - 5.75 - 0 The goal is to draw the legend with decimals only, if we really have them ! */ // top legend for max wind label1.Printf(_T("%.0f %s"), toUsrSpeed_Plugin(m_MaxWindSpdScale, g_iDashWindSpeedUnit), m_WindSpeedUnit.c_str()); // 3/4 legend WindSpdScale = m_MaxWindSpdScale*3. / 4.; // do we need a decimal ? val1 = (int)((WindSpdScale - (int)WindSpdScale) * 100); if (val1 == 25 || val1 == 75) // it's a .25 or a .75 label2.Printf(_T("%.2f %s"), toUsrSpeed_Plugin(WindSpdScale, g_iDashWindSpeedUnit), m_WindSpeedUnit.c_str()); else if (val1 == 50) label2.Printf(_T("%.1f %s"), toUsrSpeed_Plugin(WindSpdScale, g_iDashWindSpeedUnit), m_WindSpeedUnit.c_str()); else label2.Printf(_T("%.0f %s"), toUsrSpeed_Plugin(WindSpdScale, g_iDashWindSpeedUnit), m_WindSpeedUnit.c_str()); // center legend WindSpdScale = m_MaxWindSpdScale / 2.; // center line can either have a .0 or .5 value ! if ((int)(WindSpdScale * 10) % 10 == 5) label3.Printf(_T("%.1f %s"), toUsrSpeed_Plugin(WindSpdScale, g_iDashWindSpeedUnit), m_WindSpeedUnit.c_str()); else label3.Printf(_T("%.0f %s"), toUsrSpeed_Plugin(WindSpdScale, g_iDashWindSpeedUnit), m_WindSpeedUnit.c_str()); // 1/4 legend WindSpdScale = m_MaxWindSpdScale / 4.; // do we need a decimal ? val1 = (int)((WindSpdScale - (int)WindSpdScale) * 100); if (val1 == 25 || val1 == 75) label4.Printf(_T("%.2f %s"), toUsrSpeed_Plugin(WindSpdScale, g_iDashWindSpeedUnit), m_WindSpeedUnit.c_str()); else if (val1 == 50) label4.Printf(_T("%.1f %s"), toUsrSpeed_Plugin(WindSpdScale, g_iDashWindSpeedUnit), m_WindSpeedUnit.c_str()); else label4.Printf(_T("%.0f %s"), toUsrSpeed_Plugin(WindSpdScale, g_iDashWindSpeedUnit), m_WindSpeedUnit.c_str()); //bottom legend for min wind, always 0 label5.Printf(_T("%.0f %s"), 0.0, m_WindSpeedUnit.c_str()); } dc->GetTextExtent(label1, &m_LeftLegend, &height, 0, 0, g_pFontSmall); dc->DrawText(label1, 4, (int)(m_TopLineHeight - height / 2)); dc->GetTextExtent(label2, &width, &height, 0, 0, g_pFontSmall); dc->DrawText(label2, 4, (int)(m_TopLineHeight + m_DrawAreaRect.height / 4 - height / 2)); m_LeftLegend = wxMax(width, m_LeftLegend); dc->GetTextExtent(label3, &width, &height, 0, 0, g_pFontSmall); dc->DrawText(label3, 4, (int)(m_TopLineHeight + m_DrawAreaRect.height / 2 - height / 2)); m_LeftLegend = wxMax(width, m_LeftLegend); dc->GetTextExtent(label4, &width, &height, 0, 0, g_pFontSmall); dc->DrawText(label4, 4, (int)(m_TopLineHeight + m_DrawAreaRect.height*0.75 - height / 2)); m_LeftLegend = wxMax(width, m_LeftLegend); dc->GetTextExtent(label5, &width, &height, 0, 0, g_pFontSmall); dc->DrawText(label5, 4, (int)(m_TopLineHeight + m_DrawAreaRect.height - height / 2)); m_LeftLegend = wxMax(width, m_LeftLegend); m_LeftLegend += 4;}
开发者ID:tom-r,项目名称:tactics_pi,代码行数:79,
示例14: wxMaxvoid Styler_SearchHL::Style(StyleRun& sr) { const unsigned int rstart = sr.GetRunStart(); const unsigned int rend = sr.GetRunEnd(); // Style the run with search ranges for (vector<interval>::const_iterator r = m_searchRanges.begin(); r != m_searchRanges.end(); ++r) { if (r->end > rstart && r->start < rend) { unsigned int start = wxMax(rstart, r->start); unsigned int end = wxMin(rend, r->end); sr.SetBackgroundColor(start, end, m_rangeColor); } } // No need for more styling if no search text if (m_text.empty()) return; // Extend stylerun start/end to get better search results (round up to whole EXTSIZEs) unsigned int sr_start = rstart> 100 ? rstart - 100 : 0; const unsigned int ext_end = ((rend/EXTSIZE) * EXTSIZE) + EXTSIZE; unsigned int sr_end = ext_end < m_lines.GetLength() ? ext_end : m_lines.GetLength(); // Make sure the extended positions are valid cxLOCKDOC_READ(m_doc) sr_start = doc.GetValidCharPos(sr_start); if (sr_end != m_lines.GetLength()) sr_end = doc.GetValidCharPos(sr_end); cxENDLOCK //wxLogDebug("Style %u %u", rstart, rend); //wxLogDebug(" %u %u - %u %u", sr_start, sr_end, m_search_start, m_search_end); // Check if we need to do a new search if (sr_start < m_search_start || m_search_end < sr_end) { // Check if there is overlap so we can just extend the search area if (sr_end > m_search_start && sr_start < m_search_end) { sr_start = wxMin(sr_start, m_search_start); sr_end = wxMax(sr_end, m_search_end); } else { // Else we have to move it m_matches.clear(); m_search_start = 0; m_search_end = 0; } // Do the search if (sr_start < m_search_start) { // Search from top DoSearch(sr_start, sr_end); } else if (sr_end > m_search_end) { // Search from bottom DoSearch(sr_start, sr_end, true); } else wxASSERT(false); m_search_start = sr_start; m_search_end = sr_end; } // Style the run with matches for (vector<interval>::iterator p = m_matches.begin(); p != m_matches.end(); ++p) { if (p->start > rend) break; // Check for overlap (or zero-length sel at start-of-line) if ((p->end > rstart && p->start < rend) || (p->start == p->end && p->end == rstart)) { unsigned int start = wxMax(rstart, p->start); unsigned int end = wxMin(rend, p->end); // Only draw it if it is in range if (!m_searchRanges.empty()) { bool inRange = false; for (vector<interval>::const_iterator s = m_searchRanges.begin(); s != m_searchRanges.end(); ++s) { if (start >= s->start && start < s->end) { inRange = true; break; } } if (!inRange) continue; } ApplyStyle(sr, start, end); } }}
开发者ID:GunioRobot,项目名称:e,代码行数:83,
示例15: rect//.........这里部分代码省略......... topMargin = sashWindow->GetExtraBorderSize(); bottomMargin = sashWindow->GetExtraBorderSize(); if (sashWindow->GetSashVisible(wxSASH_LEFT)) leftMargin += sashWindow->GetDefaultBorderSize(); if (sashWindow->GetSashVisible(wxSASH_RIGHT)) rightMargin += sashWindow->GetDefaultBorderSize(); if (sashWindow->GetSashVisible(wxSASH_TOP)) topMargin += sashWindow->GetDefaultBorderSize(); if (sashWindow->GetSashVisible(wxSASH_BOTTOM)) bottomMargin += sashWindow->GetDefaultBorderSize(); }#endif // wxUSE_SASH int cw, ch; parent->GetClientSize(& cw, & ch); wxRect rect(leftMargin, topMargin, cw - leftMargin - rightMargin, ch - topMargin - bottomMargin); wxCalculateLayoutEvent event; event.SetRect(rect); // Find the last layout-aware window, so we can make it fill all remaining // space. wxWindow *lastAwareWindow = NULL; wxWindowList::compatibility_iterator node = parent->GetChildren().GetFirst(); while (node) { wxWindow* win = node->GetData(); if (win->IsShown()) { wxCalculateLayoutEvent tempEvent(win->GetId()); tempEvent.SetEventObject(win); tempEvent.SetFlags(wxLAYOUT_QUERY); tempEvent.SetRect(event.GetRect()); if (win->GetEventHandler()->ProcessEvent(tempEvent)) lastAwareWindow = win; } node = node->GetNext(); } // Now do a dummy run to see if we have any space left for the final window (fail if not) node = parent->GetChildren().GetFirst(); while (node) { wxWindow* win = node->GetData(); // If mainWindow is NULL and we're at the last window, // skip this, because we'll simply make it fit the remaining space. if (win->IsShown() && (win != mainWindow) && (mainWindow != NULL || win != lastAwareWindow)) { event.SetId(win->GetId()); event.SetEventObject(win); event.SetFlags(wxLAYOUT_QUERY); win->GetEventHandler()->ProcessEvent(event); } node = node->GetNext(); } if (event.GetRect().GetWidth() < 0 || event.GetRect().GetHeight() < 0) return false; event.SetRect(rect); node = parent->GetChildren().GetFirst(); while (node) { wxWindow* win = node->GetData(); // If mainWindow is NULL and we're at the last window, // skip this, because we'll simply make it fit the remaining space. if (win->IsShown() && (win != mainWindow) && (mainWindow != NULL || win != lastAwareWindow)) { event.SetId(win->GetId()); event.SetEventObject(win); event.SetFlags(0); // ?? win->GetEventHandler()->ProcessEvent(event); } node = node->GetNext(); } rect = event.GetRect(); if (mainWindow) mainWindow->SetSize(rect.x, rect.y, wxMax(0, rect.width), wxMax(0, rect.height)); else if (lastAwareWindow) { // Fit the remaining space lastAwareWindow->SetSize(rect.x, rect.y, wxMax(0, rect.width), wxMax(0, rect.height)); } return true;}
开发者ID:BauerBox,项目名称:wxWidgets,代码行数:101,
示例16: GetClientSize//.........这里部分代码省略......... int m = station_offset - ( h * 60 ); if( m_graphday.IsDST() ) h += 1; m_stz.Printf( _T("UTC %+03d:%02d"), h, m ); // Make the "nice" (for the US) station time-zone string, brutally by hand double lat = ptcmgr->GetStationLat(pIDX); if( lat > 20.0 ){ wxString mtz; switch( ptcmgr->GetStationTimeOffset( pIDX ) ) { case -240: mtz = _T( "AST" ); break; case -300: mtz = _T( "EST" ); break; case -360: mtz = _T( "CST" ); break; } if( mtz.Len() ) { if( m_graphday.IsDST() ) mtz[1] = 'D'; m_stz = mtz; } } dc.SetFont( *pSFont ); dc.GetTextExtent( m_stz, &w, &h ); dc.DrawText( m_stz, x / 2 - w / 2, y - 2.5 * m_button_height ); wxString sdate; if(g_locale == _T("en_US")) sdate = m_graphday.Format( _T ( "%A %b %d, %Y" ) ); else sdate = m_graphday.Format( _T ( "%A %d %b %Y" ) ); dc.SetFont( *pMFont ); dc.GetTextExtent( sdate, &w, &h ); dc.DrawText( sdate, x / 2 - w / 2, y - 2.0 * m_button_height ); Station_Data *pmsd = pIDX->pref_sta_data; if( pmsd ) { dc.GetTextExtent( wxString( pmsd->units_conv, wxConvUTF8 ), &w, &h ); dc.DrawRotatedText( wxString( pmsd->units_conv, wxConvUTF8 ), 5, m_graph_rect.y + m_graph_rect.height / 2 + w / 2, 90. ); } // Show flood and ebb directions if(( strchr( "c", pIDX->IDX_type ) ) || ( strchr( "C", pIDX->IDX_type ) )) { dc.SetFont( *pSFont ); wxString fdir; fdir.Printf( _T("%03d"), pIDX->IDX_flood_dir ); dc.DrawText( fdir, m_graph_rect.x + m_graph_rect.width + 4, m_graph_rect.y + m_graph_rect.height * 1 / 4 ); wxString edir; edir.Printf( _T("%03d"), pIDX->IDX_ebb_dir ); dc.DrawText( edir, m_graph_rect.x + m_graph_rect.width + 4, m_graph_rect.y + m_graph_rect.height * 3 / 4 ); }// Today or tomorrow if( (m_button_height * 15) < x && cur_time){ // large enough horizontally? wxString sday; int day = m_graphday.GetDayOfYear(); if( m_graphday.GetYear() == this_now.GetYear() ) { if( day == this_now.GetDayOfYear() ) sday.Append( _( "Today" ) ); else if( day == this_now.GetDayOfYear() + 1 ) sday.Append( _( "Tomorrow" ) ); else sday.Append( m_graphday.GetWeekDayName( m_graphday.GetWeekDay() ) ); } else if( m_graphday.GetYear() == this_now.GetYear() + 1 && day == this_now.Add( wxTimeSpan::Day() ).GetDayOfYear() ) sday.Append( _( "Tomorrow" ) ); dc.SetFont( *pSFont ); dc.GetTextExtent( sday, &w, &h ); dc.DrawText( sday, 55 - w / 2, y - 2 * m_button_height ); } // Render "Spot of interest" double spotDim = 4 * g_Platform->GetDisplayDPmm(); dc.SetBrush( *wxTheBrushList->FindOrCreateBrush( GetGlobalColor( _T ( "YELO1" ) ), wxBRUSHSTYLE_SOLID ) ); dc.SetPen( wxPen( GetGlobalColor( _T ( "URED" ) ), wxMax(2, 0.5 * g_Platform->GetDisplayDPmm()) ) ); dc.DrawRoundedRectangle(xSpot - spotDim/2, ySpot - spotDim/2, spotDim, spotDim, spotDim/2); dc.SetBrush( *wxTheBrushList->FindOrCreateBrush( GetGlobalColor( _T ( "UBLCK" ) ), wxBRUSHSTYLE_SOLID ) ); dc.SetPen( wxPen( GetGlobalColor( _T ( "UBLCK" ) ), 1 ) ); double ispotDim = spotDim / 5.; dc.DrawRoundedRectangle(xSpot - ispotDim/2, ySpot - ispotDim/2, ispotDim, ispotDim, ispotDim/2); }}
开发者ID:mookiejones,项目名称:OpenCPN,代码行数:101,
示例17: RangeCheckstatic int RangeCheck(int thisval){ return wxMin(wxMax(thisval, 0), (int) ProfileWizard::STATE_DONE);}
开发者ID:AndresPozo,项目名称:phd2,代码行数:4,
示例18: LAT1CTOWXLadspaEffectDialog::LadspaEffectDialog(LadspaEffect *eff, wxWindow * parent, const LADSPA_Descriptor *data, float *inputControls, int sampleRate, double length) :wxDialog(parent, -1, LAT1CTOWX(data->Name), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), effect(eff){ mLength = length; numParams = 0; this->mData = data; this->inputControls = inputControls; this->sampleRate = sampleRate;#ifdef __WXMSW__ // On Windows, for some reason, wxWindows calls OnTextCtrl during creation // of the text control, and LadspaEffectDialog::OnTextCtrl calls HandleText, // which assumes all the fields have been initialized. // This can give us a bad pointer crash, so manipulate inSlider to // no-op HandleText during creation. inSlider = true;#else inSlider = false;#endif inText = false; toggles = new wxCheckBox*[mData->PortCount]; sliders = new wxSlider*[mData->PortCount]; fields = new wxTextCtrl*[mData->PortCount]; labels = new wxStaticText*[mData->PortCount]; ports = new unsigned long [mData->PortCount]; unsigned long p; for(p=0; p<mData->PortCount; p++) { LADSPA_PortDescriptor d = mData->PortDescriptors[p]; if (LADSPA_IS_PORT_CONTROL(d) && LADSPA_IS_PORT_INPUT(d)) { ports[numParams] = p; numParams++; } } wxControl *item; wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL); if (mData->Maker && mData->Maker[0] && LAT1CTOWX(mData->Maker) != wxString(_("None"))) { item = new wxStaticText(this, 0, wxString(_("Author: "))+LAT1CTOWX(mData->Maker)); vSizer->Add(item, 0, wxALL, 5); } if (mData->Copyright && mData->Copyright[0] && LAT1CTOWX(mData->Copyright) != wxString(_("None"))) { item = new wxStaticText(this, 0, LAT1CTOWX(mData->Copyright)); vSizer->Add(item, 0, wxALL, 5); } wxScrolledWindow *w = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL | wxTAB_TRAVERSAL); // Try to give the window a sensible default/minimum size w->SetMinSize(wxSize( wxMax(600, parent->GetSize().GetWidth() * 2/3), parent->GetSize().GetHeight() / 2)); w->SetScrollRate(0, 20); vSizer->Add(w, 1, wxEXPAND|wxALL, 5); // Preview, OK, & Cancel buttons vSizer->Add(CreateStdButtonSizer(this, ePreviewButton|eCancelButton|eOkButton), 0, wxEXPAND); SetSizer(vSizer); wxSizer *paramSizer = new wxStaticBoxSizer(wxVERTICAL, w, _("Effect Settings")); wxFlexGridSizer *gridSizer = new wxFlexGridSizer(5, 0, 0); gridSizer->AddGrowableCol(3); for (p = 0; p < numParams; p++) { wxString labelText = LAT1CTOWX(mData->PortNames[ports[p]]); item = new wxStaticText(w, 0, labelText + wxT(":")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); wxString fieldText; LADSPA_PortRangeHint hint = mData->PortRangeHints[ports[p]]; if (LADSPA_IS_HINT_TOGGLED(hint.HintDescriptor)) {//.........这里部分代码省略.........
开发者ID:ruthmagnus,项目名称:audacity,代码行数:101,
示例19: my_bufgets// Build PolyGeo Object from SENC file recordPolyTessGeo::PolyTessGeo(unsigned char *polybuf, int nrecl, int index, int senc_file_version){#define POLY_LINE_HDR_MAX 1000// Todo Add a try/catch set here, in case SENC file is corrupted?? m_pxgeom = NULL; char hdr_buf[POLY_LINE_HDR_MAX]; int twkb_len; m_buf_head = (char *) polybuf; // buffer beginning m_buf_ptr = m_buf_head; m_nrecl = nrecl; my_bufgets( hdr_buf, POLY_LINE_HDR_MAX ); // Read the s57obj extents as lat/lon sscanf(hdr_buf, " POLYTESSGEOPROP %lf %lf %lf %lf", &xmin, &ymin, &xmax, &ymax); PolyTriGroup *ppg = new PolyTriGroup; ppg->m_bSMSENC = true; ppg->data_type = DATA_TYPE_DOUBLE; int nctr; my_bufgets( hdr_buf, POLY_LINE_HDR_MAX ); sscanf(hdr_buf, "Contours/nWKB %d %d", &nctr, &twkb_len); ppg->nContours = nctr; ppg->pn_vertex = (int *)malloc(nctr * sizeof(int)); int *pctr = ppg->pn_vertex; size_t buf_len = wxMax(twkb_len + 2, 20 + (nctr * 6)); char *buf = (char *)malloc(buf_len); // allocate a buffer guaranteed big enough my_bufgets( buf, buf_len ); // contour nVert, as a char line wxString ivc_str(buf + 10, wxConvUTF8); wxStringTokenizer tkc(ivc_str, wxT(" ,/n")); long icv = 0; while ( tkc.HasMoreTokens() ) { wxString token = tkc.GetNextToken(); if(token.ToLong(&icv)) { if(icv) { *pctr = icv; pctr++; } } } // Read Raw Geometry float *ppolygeo = (float *)malloc(twkb_len + 1); // allow for crlf memcpy(ppolygeo, m_buf_ptr, twkb_len + 1); m_buf_ptr += twkb_len + 1; ppg->pgroup_geom = ppolygeo; TriPrim **p_prev_triprim = &(ppg->tri_prim_head); // Read the PTG_Triangle Geometry in a loop unsigned int tri_type; int nvert; int nvert_max = 0; bool not_finished = true; int total_byte_size = 2 * sizeof(float); while(not_finished) { if((m_buf_ptr - m_buf_head) != m_nrecl) { int *pi = (int *)m_buf_ptr; tri_type = *pi++; nvert = *pi; m_buf_ptr += 2 * sizeof(int); // Here is the usual stop condition, which results from // interpreting the string "POLYEND" as an int if(tri_type == 0x594c4f50) { not_finished = false; break; } TriPrim *tp = new TriPrim; *p_prev_triprim = tp; // make the link p_prev_triprim = &(tp->p_next); tp->p_next = NULL; tp->type = tri_type; tp->nVert = nvert; if(nvert > nvert_max ) // Keep a running tab of largest vertex count nvert_max = nvert;//.........这里部分代码省略.........
开发者ID:balp,项目名称:OpenCPN,代码行数:101,
示例20: ifvoid wxGridSelection::UpdateRows( size_t pos, int numRows ){ size_t count = m_cellSelection.GetCount(); size_t n; for ( n = 0; n < count; n++ ) { wxGridCellCoords& coords = m_cellSelection[n]; wxCoord row = coords.GetRow(); if ((size_t)row >= pos) { if (numRows > 0) { // If rows inserted, increase row counter where necessary coords.SetRow(row + numRows); } else if (numRows < 0) { // If rows deleted ... if ((size_t)row >= pos - numRows) { // ...either decrement row counter (if row still exists)... coords.SetRow(row + numRows); } else { // ...or remove the attribute m_cellSelection.RemoveAt(n); n--; count--; } } } } count = m_blockSelectionTopLeft.GetCount(); for ( n = 0; n < count; n++ ) { wxGridCellCoords& coords1 = m_blockSelectionTopLeft[n]; wxGridCellCoords& coords2 = m_blockSelectionBottomRight[n]; wxCoord row1 = coords1.GetRow(); wxCoord row2 = coords2.GetRow(); if ((size_t)row2 >= pos) { if (numRows > 0) { // If rows inserted, increase row counter where necessary coords2.SetRow( row2 + numRows ); if ((size_t)row1 >= pos) coords1.SetRow( row1 + numRows ); } else if (numRows < 0) { // If rows deleted ... if ((size_t)row2 >= pos - numRows) { // ...either decrement row counter (if row still exists)... coords2.SetRow( row2 + numRows ); if ((size_t)row1 >= pos) coords1.SetRow( wxMax(row1 + numRows, (int)pos) ); } else { if ((size_t)row1 >= pos) { // ...or remove the attribute m_blockSelectionTopLeft.RemoveAt(n); m_blockSelectionBottomRight.RemoveAt(n); n--; count--; } else coords2.SetRow( pos ); } } } } count = m_rowSelection.GetCount(); for ( n = 0; n < count; n++ ) { int rowOrCol_ = m_rowSelection[n]; if ((size_t) rowOrCol_ >= pos) { if ( numRows > 0 ) { m_rowSelection[n] += numRows; } else if ( numRows < 0 ) { if ((size_t)rowOrCol_ >= (pos - numRows)) m_rowSelection[n] += numRows; else { m_rowSelection.RemoveAt( n ); n--; count--; }//.........这里部分代码省略.........
开发者ID:chromylei,项目名称:third_party,代码行数:101,
示例21: wxMaxwxCoord ODIconCombo::OnMeasureItem( size_t item ) const{ int bmpHeight = bmpArray.Item(item).GetHeight(); return wxMax(itemHeight, bmpHeight);}
开发者ID:nohal,项目名称:ocpn_draw_pi,代码行数:6,
示例22: GetGlobalColorvoid Route::DrawGLRouteLines( ViewPort &vp ){#ifdef ocpnUSE_GL // Hiliting first // Being special case to draw something for a 1 point route.... ocpnDC dc; if(m_hiliteWidth) { wxColour y = GetGlobalColor( _T ( "YELO1" ) ); wxColour hilt( y.Red(), y.Green(), y.Blue(), 128 ); wxPen HiPen( hilt, m_hiliteWidth, wxPENSTYLE_SOLID ); ocpnDC dc; dc.SetPen( HiPen ); DrawGLLines(vp, &dc); } /* determine color and width */ wxColour col; int width = g_pRouteMan->GetRoutePen()->GetWidth(); //g_route_line_width; if( m_width != wxPENSTYLE_INVALID ) width = m_width; if( m_bRtIsActive ) { col = g_pRouteMan->GetActiveRoutePen()->GetColour(); } else if( m_bRtIsSelected ) { col = g_pRouteMan->GetSelectedRoutePen()->GetColour(); } else { if( m_Colour == wxEmptyString ) { col = g_pRouteMan->GetRoutePen()->GetColour(); } else { for( unsigned int i = 0; i < sizeof( ::GpxxColorNames ) / sizeof(wxString); i++ ) { if( m_Colour == ::GpxxColorNames[i] ) { col = ::GpxxColors[i]; break; } } } } wxPenStyle style = wxPENSTYLE_SOLID; if( m_style != wxPENSTYLE_INVALID ) style = m_style; dc.SetPen( *wxThePenList->FindOrCreatePen( col, width, style ) ); glColor3ub(col.Red(), col.Green(), col.Blue()); glLineWidth( wxMax( g_GLMinSymbolLineWidth, width ) ); dc.SetGLStipple(); DrawGLLines(vp, NULL); glDisable (GL_LINE_STIPPLE); /* direction arrows.. could probably be further optimized for opengl */ wxRoutePointListNode *node = pRoutePointList->GetFirst(); wxPoint rpt1, rpt2; while(node) { RoutePoint *prp = node->GetData(); cc1->GetCanvasPointPix( prp->m_lat, prp->m_lon, &rpt2 ); if(node != pRoutePointList->GetFirst()) RenderSegmentArrowsGL( rpt1.x, rpt1.y, rpt2.x, rpt2.y, vp ); rpt1 = rpt2; node = node->GetNext(); }#endif}
开发者ID:CarCode,项目名称:Cocoa-OCPN,代码行数:69,
示例23: wxMaxvoid wxNewBitmapButton::RenderLabelImage( wxBitmap*& destBmp, wxBitmap* srcBmp, bool isEnabled, bool isPressed ){ if ( destBmp != 0 ) return; // render labels on-demand wxMemoryDC srcDc; srcDc.SelectObject( *srcBmp ); bool hasText = ( mTextAlignment != NB_NO_TEXT ) && ( mLabelText.length() != 0 ); bool hasImage = (mTextAlignment != NB_NO_IMAGE); wxSize destDim; wxPoint txtPos; wxPoint imgPos; if ( hasText ) { long txtWidth, txtHeight; srcDc.SetFont( wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) ); srcDc.GetTextExtent( mLabelText, &txtWidth, &txtHeight ); if ( mTextAlignment == NB_ALIGN_TEXT_RIGHT ) { destDim.x = srcBmp->GetWidth() + 2*mTextToLabelGap + txtWidth; destDim.y = wxMax( srcBmp->GetHeight(), txtHeight ); txtPos.x = srcBmp->GetWidth() + mTextToLabelGap; txtPos.y = (destDim.y - txtHeight)/2; imgPos.x = 0; imgPos.y = (destDim.y - srcBmp->GetHeight())/2; } else if ( mTextAlignment == NB_ALIGN_TEXT_BOTTOM ) { destDim.x = wxMax( srcBmp->GetWidth(), txtWidth ); destDim.y = srcBmp->GetHeight() + mTextToLabelGap + txtHeight; txtPos.x = (destDim.x - txtWidth)/2; txtPos.y = srcBmp->GetHeight() + mTextToLabelGap; imgPos.x = (destDim.x - srcBmp->GetWidth())/2; imgPos.y = 0; } else { wxFAIL_MSG(wxT("Unsupported FL alignment type detected in wxNewBitmapButton::RenderLabelImage()")); } } else { imgPos.x = 0; imgPos.y = 0; destDim.x = srcBmp->GetWidth(); destDim.y = srcBmp->GetHeight(); } destBmp = new wxBitmap( int(destDim.x), int(destDim.y) ); wxMemoryDC destDc; destDc.SelectObject( *destBmp ); wxBrush grayBrush( wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE), wxSOLID ); destDc.SetBrush( grayBrush ); destDc.SetPen( *wxTRANSPARENT_PEN ); destDc.DrawRectangle( 0,0, destDim.x+1, destDim.y+1 ); if ( isPressed ) { ++imgPos.x; ++imgPos.y; ++txtPos.x; ++txtPos.y; } if ( hasImage ) { destDc.Blit( imgPos.x, imgPos.y, srcBmp->GetWidth(), srcBmp->GetHeight(), &srcDc, 0,0, wxCOPY,true ); } if ( hasText ) { wxWindow* pTopWnd = this; do { wxWindow* pParent = pTopWnd->GetParent(); if ( pParent == 0 ) break;//.........这里部分代码省略.........
开发者ID:Bluehorn,项目名称:wxPython,代码行数:101,
示例24: gtk_collapsiblepane_expanded_callbackstatic voidgtk_collapsiblepane_expanded_callback(GObject * WXUNUSED(object), GParamSpec * WXUNUSED(param_spec), wxCollapsiblePane *p){ // NB: unlike for the "activate" signal, when this callback is called, if // we try to query the "collapsed" status through p->IsCollapsed(), we // get the right value. I.e. here p->IsCollapsed() will return false if // this callback has been called at the end of a collapsed->expanded // transition and viceversa. Inside the "activate" signal callback // p->IsCollapsed() would return the wrong value! wxSize sz; if ( p->IsExpanded() ) { // NB: we cannot use the p->GetBestSize() or p->GetMinSize() functions // here as they would return the size for the collapsed expander // even if the collapsed->expanded transition has already been // completed; we solve this problem doing: sz = p->m_szCollapsed; wxSize panesz = p->GetPane()->GetBestSize(); sz.x = wxMax(sz.x, panesz.x); sz.y += gtk_expander_get_spacing(GTK_EXPANDER(p->m_widget)) + panesz.y; } else // collapsed { // same problem described above: using p->Get[Best|Min]Size() here we // would get the size of the control when it is expanded even if the // expanded->collapsed transition should be complete now... // So, we use the size cached at control-creation time... sz = p->m_szCollapsed; } // VERY IMPORTANT: // just calling // p->OnStateChange(sz); // here would work work BUT: // 1) in the expanded->collapsed transition it provokes a lot of flickering // 2) in the collapsed->expanded transition using the "Change status" wxButton // in samples/collpane application some strange warnings would be generated // by the "clearlooks" theme, if that's your theme. // // So we prefer to use some GTK+ native optimized calls, which prevent too many resize // calculations to happen. Note that the following code has been very carefully designed // and tested - be VERY careful when changing it! // 1) need to update our size hints // NB: this function call won't actually do any long operation // (redraw/relayout/resize) so that it's flicker-free p->SetMinSize(sz); if (p->HasFlag(wxCP_NO_TLW_RESIZE)) { // fire an event wxCollapsiblePaneEvent ev(p, p->GetId(), p->IsCollapsed()); p->HandleWindowEvent(ev); // the user asked to explicitly handle the resizing itself... return; } wxTopLevelWindow * top = wxDynamicCast(wxGetTopLevelParent(p), wxTopLevelWindow); if ( top && top->GetSizer() ) { // 2) recalculate minimal size of the top window sz = top->GetSizer()->CalcMin(); if (top->m_mainWidget) { // 3) MAGIC HACK: if you ever used GtkExpander in a GTK+ program // you know that this magic call is required to make it possible // to shrink the top level window in the expanded->collapsed // transition. This may be sometimes undesired but *is* // necessary and if you look carefully, all GTK+ programs using // GtkExpander perform this trick (e.g. the standard "open file" // dialog of GTK+>=2.4 is not resizable when the expander is // collapsed!) gtk_window_set_resizable (GTK_WINDOW (top->m_widget), p->IsExpanded()); // 4) set size hints top->SetMinClientSize(sz); // 5) set size top->SetClientSize(sz); } } if ( p->m_bIgnoreNextChange ) { // change generated programmatically - do not send an event! p->m_bIgnoreNextChange = false; return; } // fire an event wxCollapsiblePaneEvent ev(p, p->GetId(), p->IsCollapsed()); p->HandleWindowEvent(ev);//.........这里部分代码省略.........
开发者ID:CustomCardsOnline,项目名称:wxWidgets,代码行数:101,
示例25: MaxPositionbool StepGuider::UpdateCalibrationState(const PHD_Point& currentLocation){ bool bError = false; try { if (!m_calibrationStartingLocation.IsValid()) { m_calibrationStartingLocation = currentLocation; Debug.AddLine(wxString::Format("Stepguider::UpdateCalibrationstate: starting location = %.2f,%.2f", currentLocation.X, currentLocation.Y)); } wxString status0, status1; int stepsRemainingUp = MaxPosition(UP) - CurrentPosition(UP); int stepsRemainingDown = MaxPosition(DOWN) - CurrentPosition(DOWN); int stepsRemainingRight = MaxPosition(RIGHT) - CurrentPosition(RIGHT); int stepsRemainingLeft = MaxPosition(LEFT) - CurrentPosition(LEFT); stepsRemainingUp /= m_calibrationStepsPerIteration; stepsRemainingDown /= m_calibrationStepsPerIteration; stepsRemainingRight /= m_calibrationStepsPerIteration; stepsRemainingLeft /= m_calibrationStepsPerIteration; int stepsRemainingDownAndRight = wxMax(stepsRemainingDown, stepsRemainingRight); assert(stepsRemainingUp >= 0); assert(stepsRemainingDown >= 0); assert(stepsRemainingRight >= 0); assert(stepsRemainingLeft >= 0); assert(stepsRemainingDownAndRight >= 0); bool moveUp = false; bool moveDown = false; bool moveRight = false; bool moveLeft = false; double x_dist; double y_dist; switch (m_calibrationState) { case CALIBRATION_STATE_GOTO_LOWER_RIGHT_CORNER: if (stepsRemainingDownAndRight > 0) { status0.Printf(_("Init Calibration: %3d"), stepsRemainingDownAndRight); moveDown = stepsRemainingDown > 0; moveRight = stepsRemainingRight > 0; break; } Debug.AddLine(wxString::Format("Falling through to state AVERAGE_STARTING_LOCATION, position=(%.2f, %.2f)", currentLocation.X, currentLocation.Y)); m_calibrationAverageSamples = 0; m_calibrationAveragedLocation.SetXY(0.0, 0.0); m_calibrationState = CALIBRATION_STATE_AVERAGE_STARTING_LOCATION; // fall through case CALIBRATION_STATE_AVERAGE_STARTING_LOCATION: m_calibrationAverageSamples++; m_calibrationAveragedLocation += currentLocation; status0.Printf(_("Averaging: %3d"), m_samplesToAverage - m_calibrationAverageSamples + 1); if (m_calibrationAverageSamples < m_samplesToAverage ) { break; } m_calibrationAveragedLocation /= m_calibrationAverageSamples; m_calibrationStartingLocation = m_calibrationAveragedLocation; m_calibrationIterations = 0; Debug.AddLine(wxString::Format("Falling through to state GO_LEFT, startinglocation=(%.2f, %.2f)", m_calibrationStartingLocation.X, m_calibrationStartingLocation.Y)); m_calibrationState = CALIBRATION_STATE_GO_LEFT; // fall through case CALIBRATION_STATE_GO_LEFT: if (stepsRemainingLeft > 0) { status0.Printf(_("Left Calibration: %3d"), stepsRemainingLeft); m_calibrationIterations++; moveLeft = true; x_dist = m_calibrationStartingLocation.dX(currentLocation); y_dist = m_calibrationStartingLocation.dY(currentLocation); GuideLog.CalibrationStep(this, "Left", stepsRemainingLeft, x_dist, y_dist, currentLocation, m_calibrationStartingLocation.Distance(currentLocation)); m_calibrationDetails.raSteps.push_back(wxRealPoint(x_dist, y_dist)); // Just put "left" in "ra" steps break; } Debug.AddLine(wxString::Format("Falling through to state AVERAGE_CENTER_LOCATION, position=(%.2f, %.2f)", currentLocation.X, currentLocation.Y)); m_calibrationAverageSamples = 0; m_calibrationAveragedLocation.SetXY(0.0, 0.0); m_calibrationState = CALIBRATION_STATE_AVERAGE_CENTER_LOCATION; // fall through case CALIBRATION_STATE_AVERAGE_CENTER_LOCATION: m_calibrationAverageSamples++; m_calibrationAveragedLocation += currentLocation; status0.Printf(_("Averaging: %3d"), m_samplesToAverage -m_calibrationAverageSamples+1); if (m_calibrationAverageSamples < m_samplesToAverage ) { break; } m_calibrationAveragedLocation /= m_calibrationAverageSamples; m_calibration.xAngle = m_calibrationStartingLocation.Angle(m_calibrationAveragedLocation);//.........这里部分代码省略.........
开发者ID:bgodard,项目名称:open-phd-guiding,代码行数:101,
示例26: iterbool EffectTruncSilence::Process(){ SelectedTrackListOfKindIterator iter(Track::Wave, mTracks); WaveTrack *t; double t0 = mT0; double t1 = mT1; int tndx; int tcount = 0; int fr; // Init using first track t = (WaveTrack *) iter.First(); double rate = t->GetRate(); sampleCount blockLen = t->GetMaxBlockSize(); // Get the left and right bounds for all tracks while (t) { // Make sure all tracks have the same sample rate if (rate != t->GetRate()) { wxMessageBox(_("All tracks must have the same sample rate"), _("Truncate Silence")); return false; } // Count the tracks tcount++; // Set the current bounds to whichever left marker is // greater and whichever right marker is less t0 = wxMax(mT0, t->GetStartTime()); t1 = wxMin(mT1, t->GetEndTime()); // Use the smallest block size of all the tracks blockLen = wxMin(blockLen, t->GetMaxBlockSize()); // Iterate to the next track t = (WaveTrack*) iter.Next(); } // Just a sanity check, really it should be much higher if(blockLen < 4*mBlendFrameCount) blockLen = 4*mBlendFrameCount; // Transform the marker timepoints to samples t = (WaveTrack *) iter.First(); sampleCount start = t->TimeToLongSamples(t0); sampleCount end = t->TimeToLongSamples(t1); // Bigger buffers reduce 'reset' //blockLen *= 8; // Stress-test the logic for cutting samples through block endpoints //blockLen /= 8; // Set thresholds // We have a lower bound on the amount of silence we chop out at a time // to avoid chopping up low frequency sounds. We're good down to 10Hz // if we use 100ms. const float minTruncMs = 1.0f; double truncDbSilenceThreshold = Enums::Db2Signal[mTruncDbChoiceIndex]; int truncInitialAllowedSilentSamples = int((wxMax( mTruncInitialAllowedSilentMs, minTruncMs) * rate) / 1000.0); int truncLongestAllowedSilentSamples = int((wxMax( mTruncLongestAllowedSilentMs, minTruncMs) * rate) / 1000.0); // Require at least 4 samples for lengths if(truncInitialAllowedSilentSamples < 4) truncInitialAllowedSilentSamples = 4; if(truncLongestAllowedSilentSamples < 4) truncLongestAllowedSilentSamples = 4; // If the cross-fade is longer than the minimum length, // then limit the cross-fade length to the minimum length // This allows us to have reasonable cross-fade by default // and still allow for 1ms minimum lengths if(truncInitialAllowedSilentSamples < mBlendFrameCount) mBlendFrameCount = truncInitialAllowedSilentSamples; if(truncLongestAllowedSilentSamples < mBlendFrameCount) mBlendFrameCount = truncLongestAllowedSilentSamples; // For sake of efficiency, don't let blockLen be less than double the longest silent samples // up until a sane limit of 1Meg samples while((blockLen > 0) && (blockLen < truncLongestAllowedSilentSamples*2) && (blockLen < 1048576)) { blockLen *= 2; } // Don't allow either value to be more than half of the block length if(truncLongestAllowedSilentSamples > blockLen/2) truncLongestAllowedSilentSamples = blockLen/2; if(truncInitialAllowedSilentSamples > truncLongestAllowedSilentSamples) truncInitialAllowedSilentSamples = truncLongestAllowedSilentSamples; // We use the 'longest' variable as additive to the 'initial' variable truncLongestAllowedSilentSamples -= truncInitialAllowedSilentSamples; // Perform the crossfade half-way through the minimum removed silence duration int rampInFrames = (truncInitialAllowedSilentSamples + mBlendFrameCount) / 2; if(rampInFrames > truncInitialAllowedSilentSamples) rampInFrames = truncInitialAllowedSilentSamples; // Allocate buffers float **buffer = new float*[tcount]; for (tndx = 0; tndx < tcount; tndx++) {//.........这里部分代码省略.........
开发者ID:tuanmasterit,项目名称:audacity,代码行数:101,
示例27: wxMaxvoid TexFont::Build( wxFont &font, bool blur ){ /* avoid rebuilding if the parameters are the same */ if(font == m_font && blur == m_blur) return; m_font = font; m_blur = blur; m_maxglyphw = 0; m_maxglyphh = 0; wxScreenDC sdc; sdc.SetFont( font ); for( int i = MIN_GLYPH; i < MAX_GLYPH; i++ ) { wxCoord gw, gh; wxString text; if(i == DEGREE_GLYPH) text = wxString::Format(_T("%c"), 0x00B0); //_T("°"); else text = wxString::Format(_T("%c"), i); wxCoord descent, exlead; sdc.GetTextExtent( text, &gw, &gh, &descent, &exlead, &font ); // measure the text tgi[i].width = gw; tgi[i].height = gh; tgi[i].advance = gw; m_maxglyphw = wxMax(tgi[i].width, m_maxglyphw); m_maxglyphh = wxMax(tgi[i].height, m_maxglyphh); } /* add extra pixel to give a border between rows of characters without this, in some cases a faint line can be see on the edge from the character above */ m_maxglyphh++; int w = COLS_GLYPHS * m_maxglyphw; int h = ROWS_GLYPHS * m_maxglyphh; wxASSERT(w < 2048 && h < 2048); /* make power of 2 */ for(tex_w = 1; tex_w < w; tex_w *= 2); for(tex_h = 1; tex_h < h; tex_h *= 2); wxBitmap tbmp(tex_w, tex_h); wxMemoryDC dc; dc.SelectObject(tbmp); dc.SetFont( font ); /* fill bitmap with black */ dc.SetBackground( wxBrush( wxColour( 0, 0, 0 ) ) ); dc.Clear(); /* draw the text white */ dc.SetTextForeground( wxColour( 255, 255, 255 ) ); /* wxPen pen(wxColour( 255, 255, 255 )); wxBrush brush(wxColour( 255, 255, 255 ), wxTRANSPARENT); dc.SetPen(pen); dc.SetBrush(brush); */ int row = 0, col = 0; for( int i = MIN_GLYPH; i < MAX_GLYPH; i++ ) { if(col == COLS_GLYPHS) { col = 0; row++; } tgi[i].x = col * m_maxglyphw; tgi[i].y = row * m_maxglyphh; wxString text; if(i == DEGREE_GLYPH) text = wxString::Format(_T("%c"), 0x00B0); //_T("°"); else text = wxString::Format(_T("%c"), i); dc.DrawText(text, tgi[i].x, tgi[i].y );// dc.DrawRectangle(tgi[i].x, tgi[i].y, tgi[i].advance, tgi[i].height); col++; } dc.SelectObject(wxNullBitmap); wxImage image = tbmp.ConvertToImage(); GLuint format, internalformat; int stride; format = GL_ALPHA; internalformat = format; stride = 1; if( m_blur )//.........这里部分代码省略.........
开发者ID:CarCode,项目名称:Cocoa-OCPN,代码行数:101,
示例28: whileOCPNRegion ViewPort::GetVPRegionIntersect( const OCPNRegion &Region, size_t nPoints, float *llpoints, int chart_native_scale, wxPoint *ppoints ){ // Calculate the intersection between a given OCPNRegion (Region) and a polygon specified by lat/lon points. // If the viewpoint is highly overzoomed wrt to chart native scale, the polygon region may be huge. // This can be very expensive, and lead to crashes on some platforms (gtk in particular) // So, look for this case and handle appropriately with respect to the given Region if( chart_scale < chart_native_scale / 10 ) { // Make a positive definite vp ViewPort vp_positive = *this; while( vp_positive.vpBBox.GetMinX() < 0 ) { vp_positive.clon += 360.; wxPoint2DDouble t( 360., 0. ); vp_positive.vpBBox.Translate( t ); } // Scan the points one-by-one, so that we can get min/max to make a bbox float *pfp = llpoints; float lon_max = -10000.; float lon_min = 10000.; float lat_max = -10000.; float lat_min = 10000.; for( unsigned int ip = 0; ip < nPoints; ip++ ) { lon_max = wxMax(lon_max, pfp[1]); lon_min = wxMin(lon_min, pfp[1]); lat_max = wxMax(lat_max, pfp[0]); lat_min = wxMin(lat_min, pfp[0]); pfp += 2; } wxBoundingBox chart_box( lon_min, lat_min, lon_max, lat_max ); // Case: vpBBox is completely outside the chart box, or vice versa // Return an empty region if( chart_box.IntersectOut( (wxBoundingBox&) vp_positive.vpBBox ) ) { if( chart_box.IntersectOut( (wxBoundingBox&) vpBBox ) ) { // try again with the chart translated 360 wxPoint2DDouble rtw( 360., 0. ); wxBoundingBox trans_box = chart_box; trans_box.Translate( rtw ); if( trans_box.IntersectOut( (wxBoundingBox&) vp_positive.vpBBox ) ) { if( trans_box.IntersectOut( (wxBoundingBox&) vpBBox ) ) { return OCPNRegion(); } } } } // Case: vpBBox is completely inside the chart box // Note that this test is not perfect, and will fail for some charts. // The chart coverage may be essentially triangular, and the viewport box // may be in the "cut off" segment of the chart_box, and not actually // exhibit any true overlap. Results will be reported incorrectly. // How to fix: maybe scrub the chart points and see if it is likely that // a region may be safely built and intersection tested. if( _IN == chart_box.Intersect( (wxBoundingBox&) vp_positive.vpBBox ) ) { return Region; } if(_IN == chart_box.Intersect((wxBoundingBox&)vpBBox)) { return Region; } // The ViewPort and the chart region overlap in some way.... // Create the intersection of the two bboxes // Boxes must be same phase while( chart_box.GetMinX() < 0 ) { wxPoint2DDouble t( 360., 0. ); chart_box.Translate( t ); } double cb_minlon = wxMax(chart_box.GetMinX(), vp_positive.vpBBox.GetMinX()); double cb_maxlon = wxMin(chart_box.GetMaxX(), vp_positive.vpBBox.GetMaxX()); double cb_minlat = wxMax(chart_box.GetMinY(), vp_positive.vpBBox.GetMinY()); double cb_maxlat = wxMin(chart_box.GetMaxY(), vp_positive.vpBBox.GetMaxY()); if( cb_maxlon < cb_minlon ) cb_maxlon += 360.; wxPoint p1 = GetPixFromLL( cb_maxlat, cb_minlon ); // upper left wxPoint p2 = GetPixFromLL( cb_minlat, cb_maxlon ); // lower right OCPNRegion r( p1, p2 ); r.Intersect( Region ); return r; } // More "normal" case wxPoint *pp; // Use the passed point buffer if available if( ppoints == NULL ) pp = new wxPoint[nPoints]; else//.........这里部分代码省略.........
开发者ID:thielj,项目名称:OpenCPN,代码行数:101,
注:本文中的wxMax函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ wxMessageBox函数代码示例 C++ wxLogWarning函数代码示例 |