void AISTargetListDialog::RecalculateSize() { if(g_bresponsive){ // Make an estimate of the dialog size wxSize esize; esize.x = GetCharWidth() * 110; esize.y = GetCharHeight() * 40; wxSize dsize = gFrame->GetClientSize(); esize.y = wxMin(esize.y, dsize.y - (4 * GetCharHeight())); esize.x = wxMin(esize.x, dsize.x - (2 * GetCharHeight())); SetClientSize(esize); wxSize fsize = GetSize(); fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight())); fsize.x = wxMin(fsize.x, dsize.x - (2 * GetCharHeight())); SetSize(fsize); if( m_pAuiManager ){ wxAuiPaneInfo &pane = m_pAuiManager->GetPane(_T("AISTargetList")); if(pane.IsOk()){ pane.FloatingSize(fsize.x, fsize.y); wxPoint pos = gFrame->GetScreenPosition(); pane.FloatingPosition(pos.x + (dsize.x - fsize.x)/2, pos.y + (dsize.y - fsize.y)/2); } m_pAuiManager->Update(); } } }
void WindowSetCursor (PCONINFO con, int x, int y, bool IsKanji) { if (IsKanji) ChangeCaretSize (con->hWnd, GetCCharWidth (), GetCharHeight ()); else ChangeCaretSize (con->hWnd, GetCharWidth (), GetCharHeight ()); SetCaretPos (con->hWnd, x * GetCharWidth (), y * GetCharHeight ()); }
RECT CBitmapFont::CalculateRect(int id) { RECT rCell; rCell.left = (id % GetNumCols()) * GetCharWidth(); rCell.top = (id / GetNumCols()) * GetCharHeight(); rCell.right = rCell.left + GetCharWidth(); rCell.bottom = rCell.top + GetCharHeight(); return rCell; }
void AISTargetAlertDialog::RecalculateSize( void ) { // Count the lines in the currently displayed text string unsigned int i=0; int nline = 0; while(i < m_alert_text.Length() ){ if(m_alert_text[i] == '\n') nline++; i++; } if(nline > m_max_nline) m_max_nline = nline; wxSize esize; esize.x = GetCharWidth() * 45; esize.y = GetCharHeight() * (m_max_nline + 4); // SetSize(esize); int height = m_pAlertTextCtl->GetInternalRepresentation()->GetHeight(); int adj_height = height + (GetCharHeight() * 4); m_adj_height = wxMax(m_adj_height, adj_height); esize.y = wxMin(esize.y, m_adj_height); /// SetClientSize(esize); /* wxSize dsize = GetParent()->GetClientSize(); wxSize fsize = GetSize(); fsize.y = wxMin(fsize.y, dsize.y - (1 * GetCharHeight())); fsize.x = wxMin(fsize.x, dsize.x - (1 * GetCharHeight())); SetSize(fsize); */ if(!m_bsizeSet){ Fit(); // Sets the horizontal size OK m_bsizeSet = true; } wxSize gSize = GetClientSize(); if(gSize.y != esize.y) SetClientSize(gSize.x, esize.y); g_Platform->PositionAISAlert( this ); }
void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const { wxStaticBoxBase::GetBordersForSizer(borderTop, borderOther); // need extra space for the label: *borderTop += GetCharHeight(); }
void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const { static int extraTop = -1; // Uninitted static int other = 5; if ( extraTop == -1 ) { // The minimal border used for the top. Later on the staticbox' // font height is added to this. extraTop = 0; if ( UMAGetSystemVersion() >= 0x1030 /*Panther*/ ) { // As indicated by the HIG, Panther needs an extra border of 11 // pixels (otherwise overlapping occurs at the top). The "other" // border has to be 11. extraTop = 11; other = 11; } } *borderTop = extraTop + GetCharHeight(); *borderOther = other; }
wxSize wxRadioBox::GetTotalButtonSize( const wxSize& rSizeBtn ) const { int nCx1; int nCy1; int nHeight; int nWidth; int nWidthLabel = 0; nCx1 = GetCharWidth(); nCy1 = GetCharHeight(); nHeight = GetRowCount() * rSizeBtn.y + (2 * nCy1); nWidth = GetColumnCount() * (rSizeBtn.x + nCx1) + nCx1; // // And also wide enough for its label // wxString sStr = wxGetWindowText(GetHwnd()); if (!sStr.empty()) { GetTextExtent( sStr ,&nWidthLabel ,NULL ); nWidthLabel += 2*nCx1; } if (nWidthLabel > nWidth) nWidth = nWidthLabel; wxSize total( nWidth, nHeight ); return total; } // end of wxRadioBox::GetTotalButtonSize
wxSize wxChoice::DoGetSizeFromTextSize(int xlen, int ylen) const { wxASSERT_MSG( m_widget, wxS("GetSizeFromTextSize called before creation") ); // a GtkEntry for wxComboBox and a GtkCellView for wxChoice GtkWidget* childPart = gtk_bin_get_child(GTK_BIN(m_widget)); // Set a as small as possible size for the control, so preferred sizes // return "natural" sizes, not taking into account the previous ones (which // seems to be GTK+3 behaviour) gtk_widget_set_size_request(m_widget, 0, 0); // We are interested in the difference of sizes between the whole contol // and its child part. I.e. arrow, separators, etc. GtkRequisition req; gtk_widget_get_preferred_size(childPart, NULL, &req); wxSize totalS = GTKGetPreferredSize(m_widget); wxSize tsize(xlen + totalS.x - req.width, totalS.y); // For a wxChoice, not for wxComboBox, add some margins if ( !GTK_IS_ENTRY(childPart) ) tsize.IncBy(5, 0); // Perhaps the user wants something different from CharHeight if ( ylen > 0 ) tsize.IncBy(0, ylen - GetCharHeight()); return tsize; }
void wxBitmapComboBox::PostCreate() { m_fontHeight = GetCharHeight() + EXTRA_FONT_HEIGHT; while ( m_bitmaps.GetCount() < GetCount() ) m_bitmaps.Add( new wxBitmap() ); }
wxSize wxChoice::DoGetSizeFromTextSize(int xlen, int ylen) const { wxASSERT_MSG( m_widget, wxS("GetSizeFromTextSize called before creation") ); // a GtkEntry for wxComboBox and a GtkCellView for wxChoice GtkWidget* childPart = gtk_bin_get_child(GTK_BIN(m_widget)); // We are interested in the difference of sizes between the whole contol // and its child part. I.e. arrow, separators, etc. GtkRequisition req; gtk_widget_get_preferred_size(childPart, NULL, &req); wxSize totalS = GTKGetPreferredSize(m_widget); wxSize tsize(xlen + totalS.x - req.width, totalS.y); // For a wxChoice, not for wxComboBox, add some margins if ( !GTK_IS_ENTRY(childPart) ) tsize.IncBy(5, 0); // Perhaps the user wants something different from CharHeight if ( ylen > 0 ) tsize.IncBy(0, ylen - GetCharHeight()); return tsize; }
wxSize wxChoice::DoGetBestSize() const { // find the widest string int wChoice = 0; const unsigned int nItems = GetCount(); for ( unsigned int i = 0; i < nItems; i++ ) { int wLine; GetTextExtent(GetString(i), &wLine, NULL); if ( wLine > wChoice ) wChoice = wLine; } // give it some reasonable default value if there are no strings in the // list if ( wChoice == 0 ) wChoice = 100; // the combobox should be slightly larger than the widest string wChoice += 5*GetCharWidth(); wxSize best(wChoice, EDIT_HEIGHT_FROM_CHAR_HEIGHT(GetCharHeight())); CacheBestSize(best); return best; }
PathProp::PathProp( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { m_opList = NULL; m_nSelected = 0; m_pEnroutePoint = NULL; m_bStartNow = false; m_pPath = NULL; m_pEnroutePoint = NULL; m_bStartNow = false; #ifdef __WXOSX__ style |= wxSTAY_ON_TOP; #endif SetExtraStyle( GetExtraStyle() | wxWS_EX_BLOCK_EVENTS ); wxDialog::Create( parent, id, caption, pos, size, style ); wxFont *qFont = OCPNGetFont(_("Dialog"), 0); SetFont( *qFont ); CreateControls(); // Make an estimate of the dialog size, without scrollbars showing wxSize esize; esize.x = GetCharWidth() * 110; esize.y = GetCharHeight() * 40; SetSize( esize ); Centre(); }
void RainExceptionDialog::_addExtraControls() { m_pSaveBtn = new wxButton(this, wxID_SAVE, wxT("Copy to Clipboard")); m_pStaticLine = new wxStaticLine(this, wxID_ANY); m_pDetailList = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxLC_REPORT | wxLC_SINGLE_SEL); m_pDetailList->InsertColumn(0, wxT("Message")); m_pDetailList->InsertColumn(1, wxT("File")); m_pDetailList->InsertColumn(2, wxT("Ln.")); size_t count = m_aMessages.GetCount(); for(size_t n = 0; n < count; ++n) { m_pDetailList->InsertItem(n, m_aMessages[n]); m_pDetailList->SetItem(n, 1, m_aFiles[n]); m_pDetailList->SetItem(n, 2, wxString::Format(wxT("%li"), m_aLines[n])); } m_pDetailList->SetColumnWidth(0, wxLIST_AUTOSIZE); m_pDetailList->SetColumnWidth(1, wxLIST_AUTOSIZE); m_pDetailList->SetColumnWidth(2, wxLIST_AUTOSIZE); int height = GetCharHeight()*(count + 4); int heightMax = wxGetDisplaySize().y - GetPosition().y - 2*GetMinHeight(); heightMax *= 9; heightMax /= 10; m_pDetailList->SetSize(wxDefaultCoord, wxMin(height, heightMax)); }
wxSize wxChoice::DoGetSizeFromTextSize(int xlen, int ylen) const { int cHeight = GetCharHeight(); // We are interested in the difference of sizes between the whole control // and its child part. I.e. arrow, separators, etc. wxSize tsize(xlen, 0); // FIXME-VC6: Only VC6 needs this guard, see WINVER definition in // include/wx/msw/wrapwin.h #if defined(WINVER) && WINVER >= 0x0500 WinStruct<COMBOBOXINFO> info; if ( MSWGetComboBoxInfo(&info) ) { tsize.x += info.rcItem.left + info.rcButton.right - info.rcItem.right + info.rcItem.left + 3; // right and extra margins } else // Just use some rough approximation. #endif // WINVER >= 0x0500 { tsize.x += 4*cHeight; } // set height on our own if( HasFlag( wxCB_SIMPLE ) ) tsize.y = SetHeightSimpleComboBox(GetCount()); else tsize.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cHeight); // Perhaps the user wants something different from CharHeight if ( ylen > 0 ) tsize.IncBy(0, ylen - cHeight); return tsize; }
wxSize wxSpinCtrlGTKBase::DoGetSizeFromTextSize(int xlen, int ylen) const { wxASSERT_MSG( m_widget, wxS("GetSizeFromTextSize called before creation") ); // Set an as small as possible size for the control, so preferred sizes // return "natural" sizes, not taking into account the previous ones (which // seems to be GTK+3 behaviour) gtk_widget_set_size_request(m_widget, 0, 0); // Both Gtk+2 and Gtk+3 use current value/range to measure control's width. // So, we can't ask Gtk+ for its width. Instead, we used hardcoded values. // Returned height is OK wxSize totalS = GTKGetPreferredSize(m_widget); #if GTK_CHECK_VERSION(3,4,0) // two buttons in horizontal totalS.x = 46 + 15; // margins included #else // two small buttons in vertical totalS.x = GetFont().GetPixelSize().y + 13; // margins included #endif wxSize tsize(xlen + totalS.x, totalS.y); // Check if the user requested a non-standard height. if ( ylen > 0 ) tsize.IncBy(0, ylen - GetCharHeight()); return tsize; }
void RenderLine(uint8 *pStart, float xOff, float vLineTop, float vLineBottom, int nCursor, int nSelStart, int nSelEnd, View *pcView, bool bSelected) { Color32_s sCursCol(40,40,40); Color32_s sCursLineCol(255,235,186); if( ! bSelected ) { sCursCol = lighten_color(sCursCol); sCursLineCol = lighten_color(sCursLineCol); } float vCharWidth = GetCharWidth(); float vCharHeight = GetCharHeight(); uint8 *pEnd = GetBuffer() + GetBufferLength(); static char zLine[(3 * BYTES_PER_LINE) + 1]; uint8 *p = pStart; for( int x = 0; x < 3 * BYTES_PER_LINE; x+=3 ) { if( p < pEnd ) { zLine[x] = get_nibble_char(*p, true); zLine[x + 1] = get_nibble_char(*p, false); p++; } else { zLine[x] = ' '; zLine[x + 1] = ' '; } zLine[x + 2] = ' '; } Rect cRect(xOff + GetX() + 2, vLineTop, xOff + GetX() + GetWidth() - 2, vLineBottom); pcView->SetFgColor(Color32_s(0,0,0)); if( nSelStart < 0 ) { if( nCursor >= 0 ) pcView->FillRect(cRect, sCursLineCol); pcView->DrawText(cRect, zLine); if( nCursor >= 0 ) { float vCursorX = cRect.left + (3 * vCharWidth * nCursor); if( m_bSecondChar ) vCursorX += vCharWidth; pcView->SetFgColor(sCursCol); pcView->DrawLine(Point(vCursorX, vLineTop), Point(vCursorX, vLineBottom)); vCursorX++; pcView->DrawLine(Point(vCursorX, vLineTop), Point(vCursorX, vLineBottom)); } } else { IPoint cSel1((int)(nSelStart * 3 * vCharWidth), (int)vCharHeight); IPoint cSel2((int)((nSelEnd * 3 * vCharWidth) + (vCharWidth * 2)), (int)vCharHeight); pcView->DrawSelectedText(cRect, zLine, cSel1, cSel2, SEL_CHAR); } }
void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const { wxStaticBoxBase::GetBordersForSizer(borderTop, borderOther); // need extra space, don't know how much but this seems to be enough *borderTop += GetCharHeight()/3; }
wxSize wxListBox::DoGetBestClientSize() const { wxCoord width = 0, height = 0; size_t count = m_strings->GetCount(); for ( size_t n = 0; n < count; n++ ) { wxCoord w,h; GetTextExtent(this->GetString(n), &w, &h); if ( w > width ) width = w; if ( h > height ) height = h; } // if the listbox is empty, still give it some non zero (even if // arbitrary) size - otherwise, leave small margin around the strings if ( !width ) width = 100; else width += 3*GetCharWidth(); if ( !height ) height = GetCharHeight(); // we need the height of the entire listbox, not just of one line height *= wxMax(count, 7); return wxSize(width, height); }
void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const { static int extraTop = -1; // Uninitted static int other = 5; if ( extraTop == -1 ) { // The minimal border used for the top. // Later on, the staticbox's font height is added to this. extraTop = 0; // As indicated by the HIG, Panther needs an extra border of 11 // pixels (otherwise overlapping occurs at the top). The "other" // border has to be 11. extraTop = 11; #if wxOSX_USE_COCOA other = 17; #else other = 11; #endif } *borderTop = extraTop; if ( !m_label.empty() ) *borderTop += GetCharHeight(); *borderOther = other; }
bool wxStatusBarGeneric::Create(wxWindow *parent, wxWindowID id, long style, const wxString& name) { style |= wxTAB_TRAVERSAL | wxFULL_REPAINT_ON_RESIZE; if ( !wxWindow::Create(parent, id, wxDefaultPosition, wxDefaultSize, style, name) ) return false; // The status bar should have a themed background SetThemeEnabled( true ); InitColours(); int height = (int)((11*GetCharHeight())/10 + 2*GetBorderY()); SetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, height); SetFieldsCount(1); #if defined( __WXGTK20__ ) #if GTK_CHECK_VERSION(2,12,0) if (HasFlag(wxSTB_SHOW_TIPS) && wx_is_at_least_gtk2(12)) { g_object_set(m_widget, "has-tooltip", TRUE, NULL); g_signal_connect(m_widget, "query-tooltip", G_CALLBACK(statusbar_query_tooltip), this); } #endif #endif return true; }
void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const { const int BORDER = 5; // FIXME: hardcoded value *borderTop = GetLabel().empty() ? 2*BORDER : GetCharHeight(); *borderOther = BORDER; }
CSlideShowPanel::CSlideShowPanel( wxWindow* parent ) : wxPanel( parent, wxID_ANY, wxDefaultPosition, wxSize(290+(2*SLIDESHOWBORDER), 126+(2*SLIDESHOWBORDER)), wxBORDER_NONE ) { int w, h; wxBoxSizer* bSizer1; bSizer1 = new wxBoxSizer( wxVERTICAL ); m_institution = new CTransparentStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizer1->Add( m_institution, 0, 0, 0 ); m_scienceArea = new CTransparentStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizer1->Add( m_scienceArea, 0, 0, 0 ); bSizer1->AddSpacer(DESCRIPTIONSPACER); m_description = new CScrolledTextBox( this ); GetSize(&w, &h); m_description->SetMinSize(wxSize(w, h - (2 * GetCharHeight()) - DESCRIPTIONSPACER)); bSizer1->Add( m_description, 1, wxEXPAND, 0 ); this->SetSizer( bSizer1 ); this->Layout(); m_SlideBitmap = wxNullBitmap; m_bCurrentSlideIsDefault = false; m_bGotAllProjectsList = false; #ifdef __WXMAC__ // Tell accessibility aids to ignore this panel (but not its contents) HIObjectSetAccessibilityIgnored((HIObjectRef)GetHandle(), true); #endif m_ChangeSlideTimer = new wxTimer(this, ID_CHANGE_SLIDE_TIMER); m_ChangeSlideTimer->Start(10000); }
// This is a helper for all wxControls made with UPDOWN native control. // In wxMSW it was only wxSpinCtrl derived from wxSpinButton but in // WinCE of Smartphones this happens also for native wxTextCtrl, // wxChoice and others. wxSize wxControl::GetBestSpinnerSize(const bool is_vertical) const { // take size according to layout wxSize bestSize( #if defined(__SMARTPHONE__) && defined(__WXWINCE__) 0,GetCharHeight() #else ::GetSystemMetrics(is_vertical ? SM_CXVSCROLL : SM_CXHSCROLL), ::GetSystemMetrics(is_vertical ? SM_CYVSCROLL : SM_CYHSCROLL) #endif ); // correct size as for undocumented MSW variants cases (WinCE and perhaps others) if (bestSize.x==0) bestSize.x = bestSize.y; if (bestSize.y==0) bestSize.y = bestSize.x; // double size according to layout if (is_vertical) bestSize.y *= 2; else bestSize.x *= 2; return bestSize; }
wxSize wxDatePickerCtrl::DoGetBestSize() const { const int y = GetCharHeight(); wxSize best(DEFAULT_ITEM_WIDTH, EDIT_HEIGHT_FROM_CHAR_HEIGHT(y)); CacheBestSize(best); return best; }
void WindowScrollDown (PCONINFO con, int scroll, int color) { RECT rcScroll; if ((con->ymin != 0) || (con->dispxmax != con->xmax) || (con->dispymax != con->ymax)) { rcScroll.left = 0; rcScroll.top = 0; rcScroll.right = con->xmax * GetCharWidth (); rcScroll.bottom = con->ymax * GetCharHeight (); ScrollWindow (con->hWnd, 0, scroll * GetCharHeight (), &rcScroll, NULL); } else ScrollWindow (con->hWnd, 0, scroll * GetCharHeight (), NULL, NULL); }
void ListBox::UpdateValues() { Size newSize = Size(m_width, (m_charHeight + m_gapBetLines) * m_lineNbr + m_lineOffset.y * 2 - m_gapBetLines); if (!IsSize(newSize)) SetSize(newSize); for (uint8 i = 0; i < m_lineNbr; i++) { m_lines[i]->SetPosition(Point(m_lineOffset.x, (GetCharHeight() + m_gapBetLines) * i + m_lineOffset.y)); m_lines[i]->SetColor(GetColor()); m_lines[i]->SetCharHeight(GetCharHeight()); m_lines[i]->SetCharWidth(GetCharWidh()); m_lines[i]->SetCharInterval(GetCharInterval()); if (IsItalic()) m_lines[i]->SetItalic(); else m_lines[i]->RemoveItalic(); } }
void wxStatusBarGeneric::SetMinHeight(int height) { // check that this min height is not less than minimal height for the // current font (min height is as calculated above in Create() except for border) int minHeight = (int)((11*GetCharHeight())/10); if ( height > minHeight ) SetSize(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, height + 2*m_borderY); }
wxSize wxBitmapComboBox::DoGetBestSize() const { wxSize best = wxComboBox::DoGetBestSize(); int delta = GetBitmapSize().y - GetCharHeight(); if ( delta > 0 ) best.y += delta; return best; }
void CScrolledTextBox::OnOutputLine(const wxString& line) { if ( !line.empty() ) { m_TextSizer->Add(new CTransparentStaticText(this, wxID_ANY, line)); } else { // empty line, no need to create a control for it if ( !m_hLine ) { m_hLine = GetCharHeight(); } m_TextSizer->Add(5, m_hLine); } }
void HandleMouseLeftUpWhenCaptured (PCONINFO con, int x, int y, WPARAM wParam) { x /= GetCharWidth (); y /= GetCharHeight (); TextCopy (con, con->m_origx, con->m_origy, x, y); con->m_oldx = x; con->m_oldy = y; }