void wxTabbedCtrl::GenerateConextMenu( wxPoint & mouse ) { wxMenu popup(""); for ( int i = 0; i < GetPageCount(); i++ ) { if ( i==active) { popup.AppendCheckItem( i, GetPageText( i ) ); popup.Check( i, true ); } else popup.Append( i, GetPageText( i ) ); } PopupMenu(&popup, mouse.x, mouse.y); }
int wxTreebookExt::SetSelection(size_t n) { int i = wxTreebook::SetSelection(n); wxString Temp = wxString(_("Preferences: ")) + GetPageText( n ); ((wxDialog*)GetParent())->SetTitle( Temp ); return i; }
bool wxSTEditorNotebook::CloseAllPages(bool query_save_if_modified, int except_this_page) { if (query_save_if_modified && !QuerySaveIfModified()) return false; if (except_this_page < 0) { DeleteAllPages(); } else { wxWindow* win = GetPage(except_this_page); wxString title(GetPageText(except_this_page)); if (win && RemovePage(except_this_page)) { DeleteAllPages(); AddPage(win, title, true); } } if ((GetPageCount() == 0) && !GetOptions().HasNotebookOption(STN_ALLOW_NO_PAGES)) InsertEditorSplitter(-1, wxID_ANY, GetOptions().GetDefaultFileName(), true); UpdateAllItems(); return true; }
int wxTreebookExt::ChangeSelection(size_t n) { int i = wxTreebook::ChangeSelection(n); wxString Temp = GetPageText( n ); static_cast<wxDialog*>(GetParent())->SetTitle( Temp ); static_cast<wxDialog*>(GetParent())->SetName( Temp ); return i; };
wxArrayString Notebook::GetPagesTextInOrder() const { wxArrayString labels; for(size_t i=0; i<GetPageCount(); ++i) { labels.Add( GetPageText(i) ); } return labels; }
void wxListbook::SetImageList(wxImageList *imageList) { wxListView * const list = GetListView(); #ifdef CAN_USE_REPORT_VIEW // If imageList presence has changed, we update the list control view if ( (imageList != NULL) != (GetImageList() != NULL) ) { wxArrayString labels; labels.Alloc(GetPageCount()); wxArrayInt imageIds; imageIds.Alloc(GetPageCount()); const int oldSel = GetSelection(); size_t i; // Grab snapshot of all list control items before changing the window // style (which deletes the items) for ( i = 0; i < GetPageCount(); i++ ) { labels.Add(GetPageText(i)); imageIds.Add(GetPageImage(i)); } // Update the style to use icon view for images, report view otherwise long style = wxLC_SINGLE_SEL; if ( imageList ) { style |= GetListCtrlIconViewFlags(); } else // no image list { style |= GetListCtrlReportViewFlags(); } list->SetWindowStyleFlag(style); if ( !imageList ) list->InsertColumn(0, wxT("Pages")); // Add back the list control items for ( i = 0; i < GetPageCount(); i++ ) { list->InsertItem(i, labels[i], imageIds[i]); } // Restore selection if ( oldSel != wxNOT_FOUND ) SetSelection(oldSel); } list->SetImageList(imageList, wxIMAGE_LIST_NORMAL); #endif // CAN_USE_REPORT_VIEW wxBookCtrlBase::SetImageList(imageList); }
size_t Notebook::GetPageIndex(const wxString& text) const { for (size_t i=0; i< GetPageCount(); i++) { if (GetPageText(i) == text) { return i; } } return Notebook::npos; }
const wxNotebookPageInfoList& wxNotebook::GetPageInfos() const { wxNotebookPageInfoList* list = const_cast< wxNotebookPageInfoList* >( &m_pageInfos ) ; WX_CLEAR_LIST( wxNotebookPageInfoList , *list ) ; for( size_t i = 0 ; i < GetPageCount() ; ++i ) { wxNotebookPageInfo *info = new wxNotebookPageInfo() ; info->Create( const_cast<wxNotebook*>(this)->GetPage(i) , GetPageText(i) , GetSelection() == int(i) , GetPageImage(i) ) ; list->Append( info ) ; } return m_pageInfos ; }
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ wxWindow* Notebook::getPage(const std::string& _title) { for(unsigned x = 0; x < GetPageCount(); x++) { if (wx2std(GetPageText(x)) == _title) { return GetPage(x); } } return NULL; }
bool wxSTEditorNotebook::InsertEditorSplitter(int nPage, wxSTEditorSplitter* splitter, bool bSelect) { wxCHECK_MSG(splitter && (splitter->GetParent() == this), false, wxT("Invalid wxSTEditorSplitter or parent")); if (GetPageCount() >= GetMaxPageCount()) { wxMessageBox(_("Maximum number of notebook pages exceeded,\nplease close one first."), _("Too many pages opened"), wxOK|wxICON_ERROR, this); delete splitter; return false; } wxString title(FileNameToTabName(splitter->GetEditor())); size_t n_pages = GetPageCount(); if (nPage < 0) // they want to insert it anywhere { // presort the insert page to reduce flicker if ((n_pages > 0) && GetOptions().HasNotebookOption(STN_ALPHABETICAL_TABS)) { wxArrayString names; names.Add(title+wxT("=999999")); // insert after any other pages with same name for (size_t n = 0; n < n_pages; n++) { wxString name(GetPageText(n)); if ((name.Length() > 0) && (name[0u] == wxT('*'))) name = name.Mid(1); names.Add(name + wxString::Format(wxT("=%d"), (int)n)); } names.Sort(STN_SortNameCompareFunction); nPage = names.Index(title+wxT("=999999")); } else nPage = (int)n_pages; } if (n_pages < 1) bSelect = true; if (nPage < int(n_pages)) return InsertPage(nPage, splitter, title, bSelect); bool ret = AddPage(splitter, title, bSelect); UpdateAllItems(); return ret; }
void CItemMessage::r_Write( CScript & s ) { CItemVendable::r_Write( s ); s.WriteKey( "AUTHOR", m_sAuthor ); TCHAR *pszTemp = Str_GetTemp(); // Store the message body lines. MAX_BOOK_PAGES for ( int i=0; i<GetPageCount(); i++ ) { sprintf(pszTemp, "BODY.%d", i); LPCTSTR pszText = GetPageText(i); s.WriteKey(pszTemp, ( pszText ) ? pszText : "" ); } }
void CItemMessage::r_Write(CScript & s) { ADDTOCALLSTACK_INTENSIVE("CItemMessage::r_Write"); CItemVendable::r_Write(s); s.WriteKey("AUTHOR", m_sAuthor); // Store the message body lines. MAX_BOOK_PAGES TemporaryString pszTemp; for ( size_t i = 0; i < GetPageCount(); ++i ) { sprintf(pszTemp, "BODY.%" FMTSIZE_T, i); LPCTSTR pszText = GetPageText(i); s.WriteKey(pszTemp, pszText != NULL ? pszText : ""); } }
int wxTreebookExt::SetSelection(size_t n) { int i = wxTreebook::SetSelection(n); wxString Temp = wxString(mTitlePrefix) + GetPageText( n ); static_cast<wxDialog*>(GetParent())->SetTitle( Temp ); static_cast<wxDialog*>(GetParent())->SetName( Temp ); PrefsPanel *const panel = static_cast<PrefsPanel *>(GetPage(n)); const bool showApply = panel->ShowsApplyButton(); wxWindow *const applyButton = wxWindow::FindWindowById(wxID_APPLY, GetParent()); if (applyButton) { // might still be NULL during population const bool changed = applyButton->Show(showApply); if (changed) GetParent()->Layout(); } return i; }
bool CChatSelector::ProcessMessage(uint64 sender_id, const wxString& message) { CChatSession* session = GetPageByClientID(sender_id); // Try to get the name (core sent it?) int separator = message.Find(wxT("|")); wxString client_name; wxString client_message; if (separator != -1) { client_name = message.Left(separator); client_message = message.Mid(separator+1); } else { // No need to define client_name. If needed, will be build on tab creation. client_message = message; } bool newtab = !session; if ( !session ) { // This must be a mesage from a client that is not already chatting if (client_name.IsEmpty()) { // Core did not send us the name. // This must NOT happen. // Build a client name based on the ID uint32 ip = IP_FROM_GUI_ID(sender_id); client_name = CFormat(wxT("IP: %s Port: %u")) % Uint32toStringIP(ip) % PORT_FROM_GUI_ID(sender_id); } session = StartSession( sender_id, client_name, true ); } // Other client connected after disconnection or a new session if ( !session->m_active ) { session->m_active = true; session->AddText( _("*** Connected to Client ***"), COLOR_RED ); } // Page text is client name session->AddText( GetPageText(GetTabByClientID(sender_id)), COLOR_BLUE, false ); session->AddText( wxT(": ") + client_message, COLOR_BLACK ); return newtab; }
void wxTabbedCtrl::SetVisible( int pg ) { if( GetPageCount() == 0 ) return; if ( !IsVisible( pg ) ) { if ( pg < m_intStartPage ) { if ( m_intLastPage < ( GetPageCount() - 1 ) ) m_intStartPage = pg; else m_intStartPage = 0; } else { int width, pom; wxSize size = GetSize(); wxClientDC dc(this); int posx = ( size.x - BUTTON_BAR_SIZE ); wxFont normal_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont bold_font = normal_font; bold_font.SetWeight(wxFONTWEIGHT_BOLD); int i = pg; for ( ; i > 0; i-- ) { dc.SetFont((i==pg) ? bold_font : normal_font); dc.GetTextExtent(GetPageText(i), &width, &pom); int space = padding.x; posx -= ( space + width +space + padding.x ); if ( posx <= 0 ) { m_intStartPage = i+1; Refresh(); return; } } m_intStartPage = 0; } } Refresh(); }
std::vector<Document::SearchHit> PDFDocument::SearchOnPage( const std::string& search_string, int page, int context_length) { const size_t margin = context_length > static_cast<int>(search_string.length()) ? (context_length - search_string.length() + 1) / 2 : 0; std::vector<SearchHit> search_hits; const std::string& page_text = GetPageText(page, ' '); for (size_t pos = 0;; ++pos) { if ((pos = CaseInsensitiveSearch(page_text, search_string, pos)) == std::string::npos) { break; } const size_t context_start_pos = pos >= margin ? pos - margin : 0; search_hits.emplace_back( page, page_text.substr(context_start_pos, context_length), pos - context_start_pos); } return search_hits; }
wxString GLIBitmapNotebook::GetBitmapValueString() const { wxString retString; // Loop and get the data for all bitmaps at that point for(uint i=0; i<bitmapViews.size(); i++) { // Get the bitmap data for the page if(i < GetPageCount()) { retString += GetPageText(i) + wxT(" = ") + bitmapViews[i]->GetBitmapValueString(selectPos); } // Add a newline if(i != bitmapViews.size()-1) { retString += wxT("\n"); } } return retString; }
int wxTabbedCtrl::HitTest(const wxPoint &p, long *flags) { int height, width, pom; wxSize size = GetSize(); wxClientDC dc(this); wxFont normal_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont bold_font = normal_font; bold_font.SetWeight(wxFONTWEIGHT_BOLD); if(flags) *flags = wxTB_HITTEST_NOWHERE; dc.SetFont(bold_font); dc.GetTextExtent("Aq", &pom, &height); if(p.x <= 0 || p.x >= size.x) return wxNOT_FOUND; if(p.y <= 0 || p.y >= height+padding.y*2 ) return wxNOT_FOUND; int posx = 3; for(int i = m_intStartPage; i <= m_intLastPage; i++) { dc.SetFont((i==GetSelection()) ? bold_font : normal_font); dc.GetTextExtent(GetPageText(i), &width, &pom); int space = padding.x; if(p.x > posx && p.x < posx+width+space+padding.x) { if(flags) *flags = wxTB_HITTEST_ONLABEL; return i; } posx += width+space+padding.x; } return wxNOT_FOUND; }
/* * DescDialogProc: Dialog procedure for dialog containing an * item's long description. */ BOOL CALLBACK DescDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam) { DescDialogStruct *info; static HWND hwndBitmap; static Bool changed; // True when player has changed description HWND hEdit, hwndOK, hURL, hFixed; HDC hdc; HFONT hFont; RECT dlg_rect, edit_rect, fixed_rect; AREA area; char *desc, *str, url[MAX_URL + 1], *pPageBreak; DRAWITEMSTRUCT *lpdis; char descriptionBuffer[MAX_PAGE_DESCRIPTION_TEXT+1]; int height; info = (DescDialogStruct *) GetWindowLong(hDlg, DWL_USER); switch (message) { case WM_INITDIALOG: info = (DescDialogStruct *) lParam; /* Store structure in dialog box's extra bytes */ SetWindowLong(hDlg, DWL_USER, (long) info); hwndBitmap = GetDlgItem(hDlg, IDC_DESCBITMAP); hFixed = GetDlgItem(hDlg, IDC_DESCFIXED); hEdit = GetDlgItem(hDlg, IDC_DESCBOX); hwndOK = GetDlgItem(hDlg, IDOK); // Item Name. height = SetFontToFitText(info,GetDlgItem(hDlg, IDC_DESCNAME), (int)FONT_TITLES, info->name); SetDlgItemText(hDlg, IDC_DESCNAME, info->name); hdc = GetDC(hDlg); SetTextColor(hdc,GetPlayerNameColor(info->obj,info->name)); ReleaseDC(hDlg,hdc); // Item Description. hFont = GetFont(FONT_EDIT); SetWindowFont(hFixed, hFont, FALSE); SetWindowFont(hEdit, hFont, FALSE); str = info->description; if (str) { pPageBreak = strchr(str,PAGE_BREAK_CHAR); while (pPageBreak) { info->numPages++; str = pPageBreak+1; pPageBreak = strchr(str,PAGE_BREAK_CHAR); } info->numPages++; GetPageText(descriptionBuffer,info); Edit_SetText(hEdit, descriptionBuffer); } // Show fixed string, if appropriate if (info->fixed_string != NULL) { SetDlgItemText(hDlg, IDC_DESCFIXED, info->fixed_string); SetWindowFont(GetDlgItem(hDlg, IDC_DESCFIXED), GetFont(FONT_EDIT), FALSE); } // Can this player edit this object's description? if (info->flags & DF_EDITABLE) Edit_SetReadOnly(hEdit, FALSE); Edit_LimitText(hEdit, MAX_DESCRIPTION); if (!(info->flags & (DF_EDITABLE | DF_INSCRIBED)) && !str) { GetWindowRect(hFixed, &fixed_rect); GetWindowRect(hEdit, &edit_rect); UnionRect(&fixed_rect, &fixed_rect, &edit_rect); ScreenToClient(hDlg, (LPPOINT)(&fixed_rect)); ScreenToClient(hDlg, (LPPOINT)(&fixed_rect)+1); MoveWindow(hFixed, fixed_rect.left, fixed_rect.top, fixed_rect.right - fixed_rect.left, fixed_rect.bottom - fixed_rect.top, FALSE); ShowWindow(hEdit, SW_HIDE); } // Resize and move dialog controls GetWindowRect(hDlg, &dlg_rect); if (GetWindowLong(hEdit, GWL_STYLE) & WS_VISIBLE) { ShowWindow(hEdit, SW_HIDE); ResizeEditToFitText(hFixed, hFont); ResizeDialog(hDlg, &dlg_rect, desc_controls); ShowWindow(hEdit, SW_SHOW); } else { ResizeEditToFitText(hFixed, hFont); ResizeDialog(hDlg, &dlg_rect, desc_controls); } if (GetWindowLong(hEdit, GWL_STYLE) & WS_VISIBLE) { GetWindowRect(hFixed, &fixed_rect); GetWindowRect(hEdit, &edit_rect); height = fixed_rect.bottom-edit_rect.top; ScreenToClient(hDlg, (LPPOINT)(&edit_rect)); ScreenToClient(hDlg, (LPPOINT)(&edit_rect)+1); ShowWindow(hFixed, SW_HIDE); OffsetRect(&edit_rect, 0, height); MoveWindow(hEdit, edit_rect.left, edit_rect.top, edit_rect.right - edit_rect.left, edit_rect.bottom - edit_rect.top, FALSE); GetWindowRect(hDlg, &dlg_rect); ResizeEditToFitText(hEdit, hFont); ResizeDialog(hDlg, &dlg_rect, desc_controls); ShowWindow(hFixed, SW_SHOW); } CenterWindow(hDlg, GetParent(hDlg)); // Show URL, if appropriate if (info->url != NULL) { hURL = GetDlgItem(hDlg, IDC_URL); SetWindowText(hURL, info->url); SetWindowFont(hURL, GetFont(FONT_EDIT), FALSE); if (info->flags & DF_EDITABLE) Edit_SetReadOnly(hURL, FALSE); Edit_LimitText(hURL, MAX_URL); } // Show appropriate buttons if (!(desc_flags & DESC_GET)) DestroyWindow(GetDlgItem(hDlg, IDC_GET)); if (!(desc_flags & DESC_DROP)) DestroyWindow(GetDlgItem(hDlg, IDC_DROP)); if (!(desc_flags & DESC_USE)) DestroyWindow(GetDlgItem(hDlg, IDC_USE)); if (!(desc_flags & DESC_UNUSE)) DestroyWindow(GetDlgItem(hDlg, IDC_UNUSE)); if (!(desc_flags & DESC_INSIDE)) DestroyWindow(GetDlgItem(hDlg, IDC_INSIDE)); if (!(desc_flags & DESC_ACTIVATE)) DestroyWindow(GetDlgItem(hDlg, IDC_ACTIVATE)); if (!(desc_flags & DESC_APPLY)) DestroyWindow(GetDlgItem(hDlg, IDC_APPLY)); SetLookPageButtons(hDlg, info); #if 0 if (info->numPages < 2) { HWND hwnd = GetDlgItem(hDlg,IDC_NEXT); if (hwnd) DestroyWindow(GetDlgItem(hDlg, IDC_NEXT)); hwnd = GetDlgItem(hDlg,IDC_PREV); if (hwnd) DestroyWindow(GetDlgItem(hDlg, IDC_PREV)); } else { HWND hwnd = GetDlgItem(hDlg,IDC_PREV); if (hwnd) EnableWindow(hwnd,FALSE); } #endif SetFocus(hwndOK); hDescDialog = hDlg; changed = False; return FALSE; case WM_PAINT: InvalidateRect(hwndBitmap, NULL, TRUE); UpdateWindow(hwndBitmap); /* fall through */ case BK_ANIMATE: /* Draw object's bitmap */ hdc = GetDC(hwndBitmap); GetClientRect(hwndBitmap, &dlg_rect); RectToArea(&dlg_rect, &area); DrawStretchedObjectGroup(hdc, info->obj, info->obj->animate->group, &area, GetSysColorBrush(COLOR_3DFACE)); ReleaseDC(hwndBitmap, hdc); break; HANDLE_MSG(hDlg, WM_CTLCOLOREDIT, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORLISTBOX, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORSTATIC, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORDLG, DialogCtlColor); case WM_DESTROY: hDescDialog = NULL; return TRUE; case WM_DRAWITEM: // Draw player name in color that reflects murderer status lpdis = (DRAWITEMSTRUCT *) lParam; switch (lpdis->itemAction) { case ODA_SELECT: case ODA_DRAWENTIRE: SelectPalette(lpdis->hDC, hPal, FALSE); hFont = info->hFontTitle; SelectObject(lpdis->hDC, hFont); SetBkMode(lpdis->hDC, TRANSPARENT); str = LookupNameRsc(info->obj->name_res); SetTextColor(lpdis->hDC, NAME_COLOR_NORMAL_BG); DrawText(lpdis->hDC, str, strlen(str), &lpdis->rcItem, DT_LEFT | DT_VCENTER | DT_NOPREFIX); OffsetRect(&lpdis->rcItem, -1, -1); SetTextColor(lpdis->hDC, GetPlayerNameColor(info->obj, info->name)); DrawText(lpdis->hDC, str, strlen(str), &lpdis->rcItem, DT_LEFT | DT_VCENTER | DT_NOPREFIX); break; } return TRUE; case WM_COMMAND: switch(GET_WM_COMMAND_ID(wParam, lParam)) { case IDC_PREV: if (info->currentPage > 0) info->currentPage--; GetPageText(descriptionBuffer,info); SetLookPageButtons(hDlg, info); Edit_SetText(GetDlgItem(hDlg, IDC_DESCBOX), descriptionBuffer); #if 0 EnableWindow(GetDlgItem(hDlg,IDC_PREV),info->currentPage > 0); EnableWindow(GetDlgItem(hDlg,IDC_NEXT),info->currentPage < info->numPages-1); #endif return TRUE; case IDC_NEXT: if (info->currentPage < info->numPages-1) info->currentPage++; GetPageText(descriptionBuffer,info); Edit_SetText(GetDlgItem(hDlg, IDC_DESCBOX), descriptionBuffer); SetLookPageButtons(hDlg, info); #if 0 EnableWindow(GetDlgItem(hDlg,IDC_PREV),info->currentPage > 0); EnableWindow(GetDlgItem(hDlg,IDC_NEXT),info->currentPage < info->numPages-1); #endif return TRUE; case IDC_GET: RequestPickup(info->obj->id); EndDialog(hDlg, 0); return TRUE; case IDC_DROP: // Drop all of number items info->obj->temp_amount = info->obj->amount; RequestDrop(info->obj); EndDialog(hDlg, 0); return TRUE; case IDC_USE: // If player isn't holding the object (i.e. there's a Get button), pick object up first if (IsWindowVisible(GetDlgItem(hDlg, IDC_GET))) RequestPickup(info->obj->id); RequestUse(info->obj->id); EndDialog(hDlg, 0); return TRUE; case IDC_UNUSE: RequestUnuse(info->obj->id); EndDialog(hDlg, 0); return TRUE; case IDC_INSIDE: RequestObjectContents(info->obj->id); EndDialog(hDlg, 0); return TRUE; case IDC_ACTIVATE: RequestActivate(info->obj->id); EndDialog(hDlg, 0); return TRUE; case IDC_APPLY: StartApply(info->obj->id); EndDialog(hDlg, 0); return TRUE; case IDC_DESCBOX: if (GET_WM_COMMAND_CMD(wParam, lParam) != EN_CHANGE) break; changed = True; return TRUE; case IDC_URLBUTTON: hURL = GetDlgItem(hDlg, IDC_URL); Edit_GetText(hURL, url, MAX_URL); WebLaunchBrowser(url); return TRUE; case IDOK: // Send new description if changed if (changed) { desc = (char *) SafeMalloc(MAX_DESCRIPTION + 1); GetDlgItemText(hDlg, IDC_DESCBOX, desc, MAX_DESCRIPTION); RequestChangeDescription(info->obj->id, desc); SafeFree(desc); } // Send new URL if changed if (info->url != NULL) { GetDlgItemText(hDlg, IDC_URL, url, MAX_URL); if (strcmp(url, info->url)) RequestChangeURL(player.id, url); } // FALLTHRU case IDCANCEL: SetWindowFont(GetDlgItem(hDlg,IDC_DESCNAME), GetFont(FONT_TITLES), FALSE); if (info->hFontTitle && info->hFontTitle != GetFont(FONT_TITLES)) DeleteObject(info->hFontTitle); info->hFontTitle = NULL; EndDialog(hDlg, IDOK == GET_WM_COMMAND_ID(wParam, lParam)); return TRUE; } break; } return FALSE; }
void wxSTEditorNotebook::UpdateGotoCloseMenu(wxMenu *menu, int startID) { if (!menu) return; size_t n, page_count = GetPageCount(); size_t item_count = menu->GetMenuItemCount(); // ======== Radio items have problems in gtk /* // delete extra menu items (if any) if (page_count < item_count) { for (n=page_count; n < item_count; n++) menu->Delete(startID+n); item_count = page_count; } wxString label; // change labels of existing items for (n=0; n<item_count; n++) { label = wxString::Format(wxT("%2d : %s"), n+1, GetPageText(n).wx_str()); if (menu->GetLabel(startID+n) != label) menu->SetLabel(startID+n, label); } // append new pages for (n=item_count; n<page_count; n++) menu->AppendRadioItem(startID+n, wxString::Format(wxT("%2d : %s"), n+1, GetPageText(n).wx_str())); */ /* // This just clears it and adds the items fresh for (n=0; n<item_count; n++) menu->Delete(startID+n); for (n=0; n<page_count; n++) menu->AppendRadioItem(startID+n, wxString::Format(wxT("%2d : %s"), n+1, GetPageText(n).wx_str())); */ // ==== check items do not // delete extra menu items (if any) if (page_count < item_count) { for (n = page_count; n < item_count; n++) menu->Delete(int(startID+n)); item_count = page_count; } wxString label; // change labels of existing items for (n = 0; n < item_count; n++) { label = wxString::Format(wxT("%2d : %s"), (int)n+1, GetPageText(n).wx_str()); if (menu->GetLabel(int(startID+n)) != label) menu->SetLabel(int(startID+n), label); menu->Check(int(startID+n), false); } // append new pages for (n = item_count; n < page_count; n++) menu->AppendCheckItem(int(startID+n), wxString::Format(wxT("%2d : %s"), (int)n+1, GetPageText(n).wx_str())); /* // use check items for (n = 0; n < item_count; n++) menu->Delete(startID+n); for (n = 0; n < page_count; n++) menu->AppendCheckItem(startID+n, wxString::Format(wxT("%2d : %s"), n+1, GetPageText(n).wx_str())); */ // show what page we're on int sel = GetSelection(); if ((sel >= 0) && (page_count >= 0)) menu->Check(startID+sel, true); }
void wxSTEditorNotebook::SortTabs(int style) { if ((int)GetPageCount() < 2) return; if (STE_HASBIT(style, STN_ALPHABETICAL_TABS)) { int sel = GetSelection(); int new_sel = sel; size_t page_count = GetPageCount(); size_t n; if (page_count < 2) return; wxString curPageName; wxArrayString names; for (n = 0; n < page_count; n++) { wxString name(GetPageText(n)); if ((name.Length() > 0) && (name[0u] == wxT('*'))) name = name.Mid(1); names.Add(name + wxString::Format(wxT("=%d"), (int)n)); } names.Sort(STN_SortNameCompareFunction); bool sel_changed = false; for (n = 0; n < page_count; n++) { long old_page = 0; names[n].AfterLast(wxT('=')).ToLong(&old_page); if (old_page != long(n)) { wxWindow *oldWin = GetPage(old_page); wxString oldName(GetPageText(old_page)); if (oldWin && RemovePage(old_page)) { sel_changed = true; if (old_page == sel) new_sel = (int)n; if (n < page_count - 1) InsertPage((int)(n+1), oldWin, oldName, old_page == sel); else AddPage(oldWin, oldName, old_page == sel); } } } if (sel_changed) { wxNotebookEvent noteEvent(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, GetId(), new_sel, new_sel); noteEvent.SetString(wxT("wxSTEditorNotebook Page Change")); noteEvent.SetExtraLong(new_sel); // FIXME no Clone in wxNotebookEvent // NOTE: this may have to be AddPendingEvent for wx < 2.7 since gtk // can become reentrant GetEventHandler()->AddPendingEvent(noteEvent); } // causes reentrant assert in gtk, even though it's necessary sometimes //SetSelection(new_sel); // force selection for GTK } }
void wxTabbedCtrl::OnMouse(wxMouseEvent &ev) { wxPoint mouse = ev.GetPosition(); int page = HitTest(ev.GetPosition()); if(ev.GetEventType()==wxEVT_MOTION) { bool xhover = mouse.x >= x_rect.x && mouse.x <= x_rect.x+x_rect.width && mouse.y >= x_rect.y && mouse.y <= x_rect.y+x_rect.height; bool nhover = (mouse.x >= Next_rect.x && mouse.x <= Next_rect.x + Next_rect.width && mouse.y >= Next_rect.y && mouse.y <= Next_rect.y + Next_rect.height ) && ( m_intLastPage < ( GetPageCount() - 1 ) ); bool phover = (mouse.x >= Prev_rect.x && mouse.x <= Prev_rect.x + Prev_rect.width && mouse.y >= Prev_rect.y && mouse.y <= Prev_rect.y + Prev_rect.height ) && ( m_intStartPage > 0 ); bool mhover = (mouse.x >= Menu_rect.x && mouse.x <= Menu_rect.x + Menu_rect.width && mouse.y >= Menu_rect.y && mouse.y <= Menu_rect.y + Menu_rect.height ); if(hover != xhover) { hover = xhover; wxClientDC dc(this); DrawX(hover, dc); } else if(hover_next != nhover) { hover_next = nhover; wxClientDC dc(this); DrawNext(hover_next, dc); } else if(hover_prev != phover) { hover_prev = phover; wxClientDC dc(this); DrawPrev(hover_prev, dc); } else if ( hover_menu != mhover ) { hover_menu = mhover; wxClientDC dc(this); DrawMenu(hover_menu, dc); } else { wxToolTip * tooltip = GetToolTip(); if ( page != wxNOT_FOUND ) { if ( tipTab != page ) { tipTab = page; tooltip->Enable( true ); wxString info; int pg = page + 1; info << pg << " of " << GetPageCount() << " - " << GetPageText( page ); tooltip->SetTip( info ); } } else { tipTab = -1; tooltip->Enable( false ); } } } else if( ev.GetEventType()==wxEVT_LEFT_UP ) { if(hover ) { wxClientDC dc(this); DrawX(false, dc); SetVisible( active ); wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, Menu_Close ); GetEventHandler()->ProcessEvent( event ); } else if( hover_next ) { wxClientDC dc(this); DrawNext(false, dc); if( GetPageCount() > ( m_intStartPage + 1 ) && ( m_intLastPage + 1 ) < GetPageCount() ) { m_intStartPage++; Refresh(); } } else if( hover_prev ) { wxClientDC dc(this); DrawPrev(false, dc); if( m_intStartPage > 0 ) { m_intStartPage--; Refresh(); } } else if( hover_menu ) { hover_menu = false; wxClientDC dc(this); DrawMenu(false, dc); GenerateConextMenu( mouse ); } else { if(page != wxNOT_FOUND) SetSelection(page); } } else if( ev.GetEventType() == wxEVT_RIGHT_UP && page == wxNOT_FOUND ) { GenerateConextMenu( mouse ); } }
void wxTabbedCtrl::OnPaint(wxPaintEvent &) { wxPaintDC dc(this); wxSize size = GetSize(); wxBrush back_brush = wxBrush(GetBackgroundColour()); wxBrush nosel_brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); wxBrush sel_brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT)); wxPen border_pen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW)); wxPen sel_pen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT)); wxPen back_pen = wxPen(GetBackgroundColour()); wxFont normal_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont bold_font = normal_font; bold_font.SetWeight(wxFONTWEIGHT_BOLD); bool mirror = style & wxTB_BOTTOM; bool fullborder = !(style & wxNO_BORDER); dc.BeginDrawing(); //background dc.SetTextBackground(GetBackgroundColour()); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT)); dc.SetBrush(back_brush); if(fullborder) { dc.SetPen(border_pen); dc.DrawRectangle(0, 0, size.x, size.y); } else { dc.SetPen(back_pen); dc.DrawRectangle(0, 0, size.x, size.y); dc.SetPen(border_pen); dc.DrawLine(0, mirror ? 0 : size.y-1, size.x, mirror ? 0 : size.y-1); } int height, width, pom; dc.SetFont(bold_font); dc.GetTextExtent("Aq", &pom, &height); int posx = 3; //and tabs int i = m_intStartPage; for( ; i < GetPageCount(); i++) { dc.SetPen(border_pen); dc.SetFont((i==GetSelection()) ? bold_font : normal_font); dc.SetBrush((i==GetSelection()) ? sel_brush : nosel_brush); dc.GetTextExtent(GetPageText(i), &width, &pom); int space = padding.x; if( ( posx + width+space+padding.x + BUTTON_BAR_SIZE ) > size.x ) { break; } dc.DrawRoundedRectangle(posx, size.y-height-padding.y*2, width+space+padding.x, height+padding.y*2+3, 3); dc.DrawText(GetPageText(i), posx+space, size.y-height-padding.y); if(i!=GetSelection()) dc.DrawLine(posx, size.y-1, posx+width+space+padding.x, size.y-1); posx += width+space+padding.x; } m_intLastPage = i - 1; //X DrawX(hover, dc); DrawNext( hover_next, dc ); DrawPrev( hover_prev, dc ); DrawMenu( hover_menu, dc ); dc.EndDrawing(); }
int wxTreebookExt::ChangeSelection(size_t n) { int i = wxTreebook::ChangeSelection(n); wxString Temp = GetPageText( n ); ((wxDialog*)GetParent())->SetTitle( Temp ); return i; };