int clAuiSimpleTabArt::GetBestTabCtrlSize(wxWindow* wnd, const wxAuiNotebookPageArray& pages, const wxSize& required_bmp_size) { wxClientDC dc(wnd); dc.SetFont(m_measuring_font); int x_ext = 0; // sometimes a standard bitmap size needs to be enforced, especially // if some tabs have bitmaps and others don't. This is important because // it prevents the tab control from resizing when tabs are added. wxBitmap bmp; if (pages.GetCount() && pages.Item(0).bitmap.IsOk()) { bmp = pages.Item(0).bitmap; } wxSize s = GetTabSize(dc, wnd, wxT("ABCDEFGHIj"), bmp.IsOk() ? bmp : wxNullBitmap, true, wxAUI_BUTTON_STATE_HIDDEN, &x_ext); return s.y+3; }
int wxGISTabArt::GetBestTabCtrlSize(wxWindow* wnd, const wxAuiNotebookPageArray& WXUNUSED(pages), const wxSize& WXUNUSED(required_bmp_size)) { wxClientDC dc(wnd); dc.SetFont(m_measuringFont); int x_ext = 0; wxSize s = GetTabSize(dc, wnd, wxT("ABCDEFGHIj"), wxNullBitmap, true, wxAUI_BUTTON_STATE_HIDDEN, &x_ext); return s.y + 6; }
void wxTextPrintout::NextTab(float *x, int /* tabcount */) { float tab=0.0f; while (tab<*x) { tab+=GetTabSize()*GetScale(); } // return the new Value *x=tab; }
void Panel::OnSize(UINT nType, int cx, int cy) { CWnd::OnSize(nType, cx, cy); CRect client; GetClientRect(client); m_tab.MoveWindow(client,TRUE); // Update the tabs CRect tabSize = GetTabSize(); for (int i = 0; i < Number_Tabs; i++) m_tabs[i]->MoveTab(tabSize); }
void EditorBase::SetScintillaValues(HWND hwndedit) { /* XPM */ static wyChar *keyword_xpm[] = KEYWORD_XPM; static wyChar *function_xpm[] = FUNCTION_XPM; static wyChar *database_xpm[] = DATABASE_XPM; static wyChar *table_xpm[] = TABLE_XPM; static wyChar *field_xpm[] = FIELD_XPM; static wyChar *sp_xpm[] = SP_XPM; static wyChar *func_xpm[] = FUNC_XPM; static wyChar *alias_xpm[] = ALIAS_XPM; SendMessage(m_hwnd, SCI_SETLEXERLANGUAGE, 0, (LPARAM)"MySQL"); SendMessage(m_hwnd, SCI_USEPOPUP, 0, 0); SendMessage(hwndedit, SCI_CLEARREGISTEREDIMAGES, 0, 0); SendMessage(hwndedit, SCI_REGISTERIMAGE, 8, (LPARAM)alias_xpm); SendMessage(hwndedit, SCI_REGISTERIMAGE, 7, (LPARAM)func_xpm); SendMessage(hwndedit, SCI_REGISTERIMAGE, 6, (LPARAM)sp_xpm); SendMessage(hwndedit, SCI_REGISTERIMAGE, 5, (LPARAM)field_xpm); SendMessage(hwndedit, SCI_REGISTERIMAGE, 4, (LPARAM)table_xpm); SendMessage(hwndedit, SCI_REGISTERIMAGE, 3, (LPARAM)database_xpm); SendMessage(hwndedit, SCI_REGISTERIMAGE, 2, (LPARAM)function_xpm); SendMessage(hwndedit, SCI_REGISTERIMAGE, 1, (LPARAM)keyword_xpm); if(IsInsertSpacesForTab() == wyTrue) SendMessage(hwndedit,SCI_SETUSETABS, FALSE, 0); else SendMessage(hwndedit,SCI_SETUSETABS, TRUE, 0); SendMessage(hwndedit, SCI_SETTABWIDTH, GetTabSize(), 0 ); SendMessage(hwndedit, SCI_AUTOCSETIGNORECASE, TRUE, 0); SendMessage(hwndedit, SCI_AUTOCSETSEPARATOR, (LPARAM)'\n', 0); SendMessage(hwndedit, SCI_AUTOCSETAUTOHIDE, 0, 0); SendMessage(hwndedit, SCI_AUTOCSTOPS, 0, (LPARAM)" ~`!@#$%^&*()+|\\=-?><,/\":;'{}[]"); SendMessage(hwndedit, SCI_CALLTIPSETBACK, RGB(255, 255, 225), 0); SendMessage(hwndedit, SCI_CALLTIPSETFORE, RGB(0, 0, 0), 0); SendMessage(hwndedit, SCI_CALLTIPSETFOREHLT, RGB(255, 0, 0), 0); SendMessage(hwndedit, SCI_SETCODEPAGE, SC_CP_UTF8, 0); //Increase the Default Autocomplete Window Height SendMessage(hwndedit, SCI_AUTOCSETMAXHEIGHT, 10, 0); SetParanthesisHighlighting(hwndedit); if(pGlobals->m_pcmainwin->m_editorcolumnline > 0) { SendMessage(hwndedit, SCI_SETEDGEMODE, EDGE_LINE, 0); SendMessage(hwndedit, SCI_SETEDGECOLUMN, pGlobals->m_pcmainwin->m_editorcolumnline, 0); } }
//Function to set the font. void EditorFont::SetFont(HWND hwndedit, wyChar tabname[], wyBool fromini) { //First delete the original font if it has been created already. wyWChar *lpfileport = 0; wyWChar directory[MAX_PATH + 1] = {0}; wyString fontname, dirstr; wyInt32 fontitalic = 0; wyInt32 fontstyle = 0; BYTE fontcharset = 0; wyInt32 fontsize = 0; //Get the complete path. SearchFilePath(L"sqlyog", L".ini", MAX_PATH, directory, &lpfileport); dirstr.SetAs(directory); //Get the font details from the ini file if (fromini) { wyIni::IniGetString((LPCSTR)tabname, "FontName", FONTNAME_DEFAULT, &fontname, dirstr.GetString()); fontsize = wyIni::IniGetInt((LPCSTR)tabname, "FontSize", FONTSIZE_DEFAULT, dirstr.GetString()); fontitalic = wyIni::IniGetInt((LPCSTR)tabname, "FontItalic", FONTITALIC_DEFAULT, dirstr.GetString()); fontstyle = wyIni::IniGetInt((LPCSTR)tabname, "FontStyle", FONTSTYLE_DEFAULT, dirstr.GetString()); fontcharset = wyIni::IniGetInt((LPCSTR)tabname, "FontCharSet", DEFAULT_CHARSET , dirstr.GetString()); if(fontstyle != BOLD_DEFINED) fontstyle = 0; fontcharset = wyIni::IniGetInt((LPCSTR)tabname, "FontCharSet", DEFAULT_CHARSET, dirstr.GetString()); } else { fontname.SetAs("Courier New"); fontsize = DEF_FONT_SIZE; } SendMessage(hwndedit, SCI_STYLESETFONT, STYLE_DEFAULT, (LPARAM)fontname.GetString()); SendMessage(hwndedit, SCI_STYLESETSIZE, STYLE_DEFAULT, fontsize); SendMessage(hwndedit, SCI_STYLESETITALIC, STYLE_DEFAULT, fontitalic); SendMessage(hwndedit, SCI_STYLESETBOLD, STYLE_DEFAULT, fontstyle); SendMessage(hwndedit, SCI_STYLESETCHARACTERSET, STYLE_DEFAULT, fontcharset); SendMessage(hwndedit, SCI_SETTABWIDTH, GetTabSize(), 0 ); if(IsInsertSpacesForTab() == wyTrue) SendMessage(hwndedit, SCI_SETUSETABS, FALSE, 0); else SendMessage(hwndedit, SCI_SETUSETABS, TRUE, 0); return; }
void UpdateTabWidth(WindowInfo* win) { int count = (int)win->tabs.size(); bool showSingleTab = gGlobalPrefs->useTabs || win->tabsInTitlebar; bool showTabs = (count > 1) || (showSingleTab && (count > 0)); if (!showTabs) { ShowTabBar(win, false); return; } ShowTabBar(win, true); ClientRect rect(win->hwndTabBar); SizeI tabSize = GetTabSize(win->hwndFrame); auto maxDx = (rect.dx - 3) / count; tabSize.dx = std::min(tabSize.dx, maxDx); TabCtrl_SetItemSize(win->hwndTabBar, tabSize.dx, tabSize.dy); }
int wxAuiGenericTabArt::GetBestTabCtrlSize(wxWindow* wnd, const wxAuiNotebookPageArray& pages, const wxSize& requiredBmp_size) { wxClientDC dc(wnd); dc.SetFont(m_measuringFont); // sometimes a standard bitmap size needs to be enforced, especially // if some tabs have bitmaps and others don't. This is important because // it prevents the tab control from resizing when tabs are added. wxBitmap measureBmp; if (requiredBmp_size.IsFullySpecified()) { measureBmp.Create(requiredBmp_size.x, requiredBmp_size.y); } int max_y = 0; size_t i, page_count = pages.GetCount(); for (i = 0; i < page_count; ++i) { wxAuiNotebookPage& page = pages.Item(i); wxBitmap bmp; if (measureBmp.IsOk()) bmp = measureBmp; else bmp = page.bitmap; // we don't use the caption text because we don't // want tab heights to be different in the case // of a very short piece of text on one tab and a very // tall piece of text on another tab int x_ext = 0; wxSize s = GetTabSize(dc, wnd, wxT("ABCDEFGHIj"), bmp, true, wxAUI_BUTTON_STATE_HIDDEN, &x_ext); max_y = wxMax(max_y, s.y); } return max_y+2; }
void UpdateTabWidth(WindowInfo *win) { int count = (int)win->tabs.Count(); bool showSingleTab = gGlobalPrefs->useTabs || win->tabsInTitlebar; if (count > (showSingleTab ? 0 : 1)) { ShowTabBar(win, true); ClientRect rect(win->hwndTabBar); SizeI tabSize = GetTabSize(win->hwndFrame); if (tabSize.dx > (rect.dx - 3) / count) tabSize.dx = (rect.dx - 3) / count; TabCtrl_SetItemSize(win->hwndTabBar, tabSize.dx, tabSize.dy); } else { ShowTabBar(win, false); } }
void CreateTabbar(WindowInfo* win) { DWORD dwStyle = WS_CHILD | WS_CLIPSIBLINGS /*| WS_VISIBLE*/ | TCS_FOCUSNEVER | TCS_FIXEDWIDTH | TCS_FORCELABELLEFT; DWORD dwStyleEx = 0; auto h = GetModuleHandleW(nullptr); HWND hwndTabBar = CreateWindowExW(dwStyleEx, WC_TABCONTROL, L"", dwStyle, 0, 0, 0, 0, win->hwndFrame, (HMENU)IDC_TABBAR, h, nullptr); SetWindowSubclass(hwndTabBar, TabBarProc, 0, (DWORD_PTR)win); SetWindowSubclass(GetParent(hwndTabBar), TabBarParentProc, 0, (DWORD_PTR)win); SizeI tabSize = GetTabSize(win->hwndFrame); TabPainter* tp = new TabPainter(hwndTabBar, tabSize); SetWindowLongPtr(hwndTabBar, GWLP_USERDATA, (LONG_PTR)tp); SetWindowFont(hwndTabBar, GetDefaultGuiFont(), FALSE); TabCtrl_SetItemSize(hwndTabBar, tabSize.dx, tabSize.dy); win->hwndTabBar = hwndTabBar; win->tabSelectionHistory = new Vec<TabInfo*>(); }
void CreateTabbar(WindowInfo *win) { HWND hwndTabBar = CreateWindow(WC_TABCONTROL, L"", WS_CHILD | WS_CLIPSIBLINGS /*| WS_VISIBLE*/ | TCS_FOCUSNEVER | TCS_FIXEDWIDTH | TCS_FORCELABELLEFT, 0, 0, 0, 0, win->hwndFrame, (HMENU)IDC_TABBAR, GetModuleHandle(nullptr), nullptr); if (!DefWndProcTabBar) DefWndProcTabBar = (WNDPROC)GetWindowLongPtr(hwndTabBar, GWLP_WNDPROC); SetWindowLongPtr(hwndTabBar, GWLP_WNDPROC, (LONG_PTR)WndProcTabBar); SizeI tabSize = GetTabSize(win->hwndFrame); TabPainter *tp = new TabPainter(hwndTabBar, tabSize); SetWindowLongPtr(hwndTabBar, GWLP_USERDATA, (LONG_PTR)tp); SetWindowFont(hwndTabBar, GetDefaultGuiFont(), FALSE); TabCtrl_SetItemSize(hwndTabBar, tabSize.dx, tabSize.dy); win->hwndTabBar = hwndTabBar; win->tabSelectionHistory = new Vec<TabInfo *>(); }
CodeEditor::SyntaxState CodeEditor::ScanSyntax(int line) { SyntaxState st; for(int i = 0; i < 4; i++) if(line >= scache[i].line) { st = scache[i]; break; } if(st.macro != SyntaxState::MACRO_CONT) st.macro = SyntaxState::MACRO_OFF; line = min(line, GetLineCount()); while(st.line < line) { if(st.macro != SyntaxState::MACRO_CONT) st.macro = SyntaxState::MACRO_OFF; WString l = GetWLine(st.line); st.ScanSyntax(l, l.End(), GetTabSize()); st.line++; static int d[] = { 0, 100, 2000 }; for(int i = 0; i < 3; i++) if(st.line == cline - d[i]) scache[i] = st; } scache[3] = st; return st; }
void clAuiGlossyTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { wxColour bgColour = wxColour(EditorConfigST::Get()->GetCurrentOutputviewBgColour()); wxColour penColour; wxColour textColour; bool isBgColourDark = DrawingUtils::IsDark(bgColour); if ( isBgColourDark ) { penColour = DrawingUtils::LightColour(bgColour, 4.0); } else { bgColour = *wxWHITE; penColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW); } textColour = EditorConfigST::Get()->GetCurrentOutputviewFgColour(); int curx = 0; // Allow the plugins to override the default colours clColourEvent colourEvent( wxEVT_COLOUR_TAB ); colourEvent.SetIsActiveTab( page.active ); colourEvent.SetPage( page.window ); if ( EventNotifier::Get()->ProcessEvent( colourEvent ) ) { bgColour = colourEvent.GetBgColour(); textColour = colourEvent.GetFgColour(); } // Allow the plugins to override the border colour wxColour originalPenColour = penColour; clColourEvent borderColourEvent( wxEVT_GET_TAB_BORDER_COLOUR ); if ( EventNotifier::Get()->ProcessEvent( borderColourEvent ) ) { penColour = borderColourEvent.GetBorderColour(); } wxGCDC gdc; if ( !DrawingUtils::GetGCDC(dc, gdc) ) return; m_penColour = penColour; wxGraphicsPath path = gdc.GetGraphicsContext()->CreatePath(); gdc.SetPen( penColour ); wxSize sz = GetTabSize(gdc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxRect rr (in_rect.GetTopLeft(), sz); rr.y += TAB_Y_OFFSET; rr.width -= 1; #ifndef __WXMAC__ if ( page.active ) { rr.y -= 2; rr.height += 2; } #endif #ifdef __WXGTK__ rr.height += TAB_HEIGHT_SPACER; #else rr.height += 4; #endif /// the tab start position (x) curx = rr.x + 7; // Set clipping region int clip_width = rr.width; if (rr.x + clip_width > in_rect.x + in_rect.width) clip_width = (in_rect.x + in_rect.width) - rr.x; // since the above code above doesn't play well with WXDFB or WXCOCOA, // we'll just use a rectangle for the clipping region for now -- gdc.SetClippingRegion(rr.x, rr.y, clip_width, rr.height); gdc.SetBrush( bgColour ); gdc.SetPen( penColour ); if ( page.active ) { path.AddRoundedRectangle(rr.x, rr.y, rr.width-1, rr.height, 6.5); gdc.GetGraphicsContext()->FillPath( path ); gdc.GetGraphicsContext()->StrokePath( path ); } else { if ( !m_bgColour.IsOk() ) { wxColour b, p; DoGetTabAreaBackgroundColour(b, p); m_bgColour = b; } DoDrawInactiveTabSeparator(gdc, rr); } if ( !page.active ) { // Draw a line at the bottom rect gdc.SetPen(penColour); gdc.DrawLine(in_rect.GetBottomLeft(), in_rect.GetBottomRight()); } wxString caption = page.caption; if ( caption.IsEmpty() ) { caption = "Tp"; } wxFont fnt = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); if ( page.active ) { fnt.SetWeight(wxFONTWEIGHT_BOLD); } gdc.SetFont( fnt ); wxSize ext = gdc.GetTextExtent( caption ); if ( caption == "Tp" ) caption.Clear(); /// Draw the bitmap if ( page.bitmap.IsOk() ) { int bmpy = (rr.y + (rr.height - page.bitmap.GetHeight())/2)-TAB_Y_OFFSET; gdc.GetGraphicsContext()->DrawBitmap( page.bitmap, curx, bmpy, page.bitmap.GetWidth(), page.bitmap.GetHeight()); curx += page.bitmap.GetWidth(); curx += 3; } /// Draw the text gdc.SetTextForeground( textColour ); gdc.GetGraphicsContext()->DrawText( page.caption, curx, (rr.y + (rr.height - ext.y)/2)-TAB_Y_OFFSET+TEXT_Y_SPACER); // advance the X offset curx += ext.x; curx += 3; /// Draw the X button on the tab if ( close_button_state != wxAUI_BUTTON_STATE_HIDDEN ) { int btny = (rr.y + (rr.height/2))-TAB_Y_OFFSET+TEXT_Y_SPACER; if ( close_button_state == wxAUI_BUTTON_STATE_PRESSED ) { curx += 1; btny += 1; } /// Defines the rectangle surrounding the X button wxRect xRect = wxRect(curx, btny - X_RADIUS, X_DIAMETER, X_DIAMETER); *out_button_rect = xRect; /// Defines the 'x' inside the circle wxPoint circleCenter( curx + X_RADIUS, btny); wxDouble xx_width = ::sqrt( ::pow(X_DIAMETER, 2.0) /2.0 ); wxDouble x_square = (circleCenter.x - (xx_width/2.0)); wxDouble y_square = (circleCenter.y - (xx_width/2.0)); wxPoint2DDouble ptXTopLeft(x_square, y_square); wxRect2DDouble insideRect(ptXTopLeft.m_x, ptXTopLeft.m_y, xx_width, xx_width); insideRect.Inset(1.0 , 1.0); // Shrink it by 1 pixle /// Draw the 'x' itself wxGraphicsPath xpath = gdc.GetGraphicsContext()->CreatePath(); xpath.MoveToPoint( insideRect.GetLeftTop() ); xpath.AddLineToPoint( insideRect.GetRightBottom()); xpath.MoveToPoint( insideRect.GetRightTop() ); xpath.AddLineToPoint( insideRect.GetLeftBottom() ); gdc.SetPen( wxPen(textColour, 1) ); gdc.GetGraphicsContext()->StrokePath( xpath ); curx += X_DIAMETER; } *out_tab_rect = rr; gdc.DestroyClippingRegion(); }
void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { GtkWidget *widget = wnd->GetHandle(); GtkStyle *style_notebook = gtk_widget_get_style(wxGTKPrivate::GetNotebookWidget()); wxRect const &window_rect = wnd->GetRect(); int focus_width = 0; gtk_widget_style_get(wxGTKPrivate::GetNotebookWidget(), "focus-line-width", &focus_width, NULL); int tab_pos; if (m_flags &wxAUI_NB_BOTTOM) tab_pos = wxAUI_NB_BOTTOM; else //if (m_flags & wxAUI_NB_TOP) {} tab_pos = wxAUI_NB_TOP; // TODO: else if (m_flags &wxAUI_NB_LEFT) {} // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} // figure out the size of the tab wxSize tab_size = GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxRect tab_rect = in_rect; tab_rect.width = tab_size.x; tab_rect.height = tab_size.y; tab_rect.y += 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; if (page.active) tab_rect.height += 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; // if no bitmap is set, we need a tiny correction if (! page.bitmap.IsOk()) tab_rect.height += 1; int gap_rect_height = 6 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; int gap_rect_x = 1, gap_start = 0, gap_width = 0; int gap_rect_y = tab_rect.y - gap_rect_height; int gap_rect_width = window_rect.width; switch (tab_pos) { case wxAUI_NB_TOP: tab_rect.y -= 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; if (!page.active) tab_rect.y += 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; gap_rect_y = tab_rect.y + tab_rect.height - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder / 2; // fall through case wxAUI_NB_BOTTOM: gap_start = tab_rect.x - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder / 2; gap_width = tab_rect.width; break; // TODO: case wxAUI_NB_LEFT: break; // TODO: case wxAUI_NB_RIGHT: break; } tab_rect.y += GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder / 2; gap_rect_y += GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder / 2; int padding = focus_width + GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; int clip_width = tab_rect.width; if (tab_rect.x + tab_rect.width > in_rect.x + in_rect.width) clip_width = (in_rect.x + in_rect.width) - tab_rect.x; dc.SetClippingRegion(tab_rect.x, tab_rect.y - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder, clip_width, tab_rect.height + GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder); GdkRectangle area; area.x = tab_rect.x - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder; area.y = tab_rect.y - 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; area.width = clip_width + GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder; area.height = tab_rect.height + 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder; wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl(); GdkWindow* window = impldc->GetGDKWindow(); if (tab_pos == wxAUI_NB_BOTTOM) { if (page.active) { gtk_paint_box_gap(style_notebook, window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, widget, const_cast<char*>("notebook"), gap_rect_x, gap_rect_y, gap_rect_width, gap_rect_height, GTK_POS_BOTTOM, gap_start , gap_width); } gtk_paint_extension(style_notebook, window, page.active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE, GTK_SHADOW_OUT, &area, widget, const_cast<char*>("tab"), tab_rect.x, tab_rect.y, tab_rect.width, tab_rect.height, GTK_POS_TOP); } else { if (page.active) { gtk_paint_box_gap(style_notebook, window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, widget, const_cast<char*>("notebook"), gap_rect_x, gap_rect_y, gap_rect_width, gap_rect_height, GTK_POS_TOP, gap_start , gap_width); } gtk_paint_extension(style_notebook, window, page.active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE, GTK_SHADOW_OUT, &area, widget, const_cast<char*>("tab"), tab_rect.x, tab_rect.y, tab_rect.width, tab_rect.height, GTK_POS_BOTTOM); } wxCoord textX = tab_rect.x + padding + style_notebook->xthickness; int bitmap_offset = 0; if (page.bitmap.IsOk()) { bitmap_offset = textX; // draw bitmap int bitmapY = tab_rect.y +(tab_rect.height - page.bitmap.GetHeight()) / 2; if(!page.active) { if (tab_pos == wxAUI_NB_TOP) bitmapY += style_notebook->ythickness / 2; else bitmapY -= style_notebook->ythickness / 2; } dc.DrawBitmap(page.bitmap, bitmap_offset, bitmapY, true); textX += page.bitmap.GetWidth() + padding; } wxCoord textW, textH, textY; dc.SetFont(m_normalFont); dc.GetTextExtent(page.caption, &textW, &textH); textY = tab_rect.y + (tab_rect.height - textH) / 2; if(!page.active) { if (tab_pos == wxAUI_NB_TOP) textY += style_notebook->ythickness / 2; else textY -= style_notebook->ythickness / 2; } // draw tab text GdkColor text_colour = page.active ? style_notebook->fg[GTK_STATE_NORMAL] : style_notebook->fg[GTK_STATE_ACTIVE]; dc.SetTextForeground(wxColor(text_colour)); GdkRectangle focus_area; int padding_focus = padding - focus_width; focus_area.x = tab_rect.x + padding_focus; focus_area.y = textY - focus_width; focus_area.width = tab_rect.width - 2 * padding_focus; focus_area.height = textH + 2 * focus_width; if(page.active && (wnd->FindFocus() == wnd) && focus_area.x <= (area.x + area.width)) { // clipping seems not to work here, so we we have to recalc the focus-area manually if((focus_area.x + focus_area.width) > (area.x + area.width)) focus_area.width = area.x + area.width - focus_area.x + focus_width - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder; gtk_paint_focus (style_notebook, window, GTK_STATE_ACTIVE, NULL, widget, "tab", focus_area.x, focus_area.y, focus_area.width, focus_area.height); } dc.DrawText(page.caption, textX, textY); // draw close-button on tab (if enabled) if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { wxRect rect(tab_rect.x, tab_rect.y, tab_rect.width - style_notebook->xthickness, tab_rect.height); if(!page.active) { if (tab_pos == wxAUI_NB_TOP) rect.y += style_notebook->ythickness / 2; else rect.y -= style_notebook->ythickness / 2; } *out_button_rect = DrawCloseButton(dc, widget, close_button_state, rect, wxRIGHT, &area); } tab_rect.width = std::min(tab_rect.width, clip_width); *out_tab_rect = tab_rect; dc.DestroyClippingRegion(); }
void clAuiMainNotebookTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { if(in_rect.GetHeight() == 0) return; // Tabs are not visible int curx = 0; wxGCDC gdc; if(!DrawingUtils::GetGCDC(dc, gdc)) return; wxColour penColour = page.active ? m_activeTabPenColour : m_penColour; wxGraphicsPath path = gdc.GetGraphicsContext()->CreatePath(); gdc.SetPen(penColour); wxSize sz = GetTabSize(gdc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxRect rr(in_rect.GetTopLeft(), sz); rr.y += TAB_Y_OFFSET; rr.width -= 1; #ifndef __WXMAC__ if(page.active) { rr.y -= 2; rr.height += 2; } #endif #ifndef __WXGTK__ rr.height += 4; #endif /// the tab start position (x) curx = rr.x + 7; // Set clipping region int clip_width = rr.width; if(rr.x + clip_width > in_rect.x + in_rect.width) clip_width = (in_rect.x + in_rect.width) - rr.x; gdc.SetClippingRegion(rr.x, rr.y, clip_width, rr.height); gdc.SetBrush(m_bgColour); gdc.SetPen(penColour); if(page.active) { gdc.SetBrush(m_activeTabBgColour); path.AddRoundedRectangle(rr.x, rr.y, rr.width - 1, rr.height, m_tabRadius); gdc.GetGraphicsContext()->FillPath(path); gdc.GetGraphicsContext()->StrokePath(path); } else { wxGraphicsPath outerPath = gdc.GetGraphicsContext()->CreatePath(); gdc.SetPen(penColour); outerPath.AddRoundedRectangle(rr.x, rr.y, rr.width - 1, rr.height, m_tabRadius); gdc.GetGraphicsContext()->StrokePath(outerPath); gdc.SetPen(m_innerPenColour); path.AddRoundedRectangle(rr.x + 1, rr.y + 1, rr.width - 3, rr.height - 1, m_tabRadius); gdc.GetGraphicsContext()->StrokePath(path); gdc.SetBrush(m_tabBgColour); gdc.GetGraphicsContext()->StrokePath(path); gdc.GetGraphicsContext()->FillPath(path); gdc.SetPen(penColour); } if(!page.active) { // Draw a line at the bottom rect gdc.SetPen(m_activeTabPenColour); gdc.DrawLine(in_rect.GetBottomLeft(), in_rect.GetBottomRight()); } wxString caption = page.caption; if(caption.IsEmpty()) { caption = "Tp"; } wxFont fnt = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); gdc.SetFont(fnt); wxSize ext = gdc.GetTextExtent(caption); if(caption == "Tp") caption.Clear(); /// Draw the bitmap if(page.bitmap.IsOk()) { int bmpy = (rr.y + (rr.height - page.bitmap.GetHeight()) / 2) - TAB_Y_OFFSET + BMP_Y_SPACER; gdc.GetGraphicsContext()->DrawBitmap(page.bitmap, curx, bmpy, page.bitmap.GetWidth(), page.bitmap.GetHeight()); curx += page.bitmap.GetWidth(); curx += 3; } /// Draw the text wxColour textColour = page.active ? m_activeTabTextColour : m_tabTextColour; gdc.SetTextForeground(textColour); wxDouble textYOffCorrd = (rr.y + (rr.height - ext.y) / 2) - TAB_Y_OFFSET + TEXT_Y_SPACER; gdc.GetGraphicsContext()->DrawText(page.caption, curx, textYOffCorrd); // advance the X offset curx += ext.x; curx += 3; /// Draw the X button on the tab if(close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { curx += 1; wxBitmap xBmp = m_bmpClose; switch(close_button_state) { case wxAUI_BUTTON_STATE_HOVER: xBmp = m_bmpCloseHover; break; case wxAUI_BUTTON_STATE_PRESSED: xBmp = m_bmpClosePressed; break; } int btny = (rr.y + (rr.height - x_button_height) / 2) - TAB_Y_OFFSET + BMP_Y_SPACER; gdc.GetGraphicsContext()->DrawBitmap(xBmp, curx, btny, x_button_height, x_button_height); *out_button_rect = wxRect(curx, btny, x_button_height, x_button_height); curx += x_button_height; } *out_tab_rect = rr; gdc.DestroyClippingRegion(); }
void CCrystalEditView::OnEditUntab() { if (! QueryEditable() || m_pTextBuffer == NULL) return; BOOL bTabify = FALSE; CPoint ptSelStart, ptSelEnd; if (IsSelection()) { GetSelection(ptSelStart, ptSelEnd); bTabify = ptSelStart.y != ptSelEnd.y; } if (bTabify) { m_pTextBuffer->BeginUndoGroup(); CPoint ptSelStart, ptSelEnd; GetSelection(ptSelStart, ptSelEnd); int nStartLine = ptSelStart.y; int nEndLine = ptSelEnd.y; ptSelStart.x = 0; if (ptSelEnd.x > 0) { if (ptSelEnd.y == GetLineCount() - 1) { ptSelEnd.x = GetLineLength(ptSelEnd.y); } else { ptSelEnd.x = 0; ptSelEnd.y ++; } } else nEndLine --; SetSelection(ptSelStart, ptSelEnd); SetCursorPos(ptSelEnd); EnsureVisible(ptSelEnd); // Shift selection to left m_bHorzScrollBarLocked = TRUE; for (int L = nStartLine; L <= nEndLine; L ++) { int nLength = GetLineLength(L); if (nLength > 0) { LPCTSTR pszChars = GetLineChars(L); int nPos = 0, nOffset = 0; while (nPos < nLength) { if (pszChars[nPos] == _T(' ')) { nPos ++; if (++ nOffset >= GetTabSize()) break; } else { if (pszChars[nPos] == _T('\t')) nPos ++; break; } } if (nPos > 0) m_pTextBuffer->DeleteText(this, L, 0, L, nPos, CE_ACTION_INDENT); // [JRT] } } m_bHorzScrollBarLocked = FALSE; RecalcHorzScrollBar(); m_pTextBuffer->FlushUndoGroup(this); } else { CPoint ptCursorPos = GetCursorPos(); ASSERT_VALIDTEXTPOS(ptCursorPos); if (ptCursorPos.x > 0) { int nTabSize = GetTabSize(); int nOffset = CalculateActualOffset(ptCursorPos.y, ptCursorPos.x); int nNewOffset = nOffset / nTabSize * nTabSize; if (nOffset == nNewOffset && nNewOffset > 0) nNewOffset -= nTabSize; ASSERT(nNewOffset >= 0); LPCTSTR pszChars = GetLineChars(ptCursorPos.y); int nCurrentOffset = 0; int I = 0; while (nCurrentOffset < nNewOffset) { if (pszChars[I] == _T('\t')) nCurrentOffset = nCurrentOffset / nTabSize * nTabSize + nTabSize; else nCurrentOffset ++; I ++; } ASSERT(nCurrentOffset == nNewOffset); ptCursorPos.x = I; ASSERT_VALIDTEXTPOS(ptCursorPos); SetSelection(ptCursorPos, ptCursorPos); SetAnchor(ptCursorPos); SetCursorPos(ptCursorPos); EnsureVisible(ptCursorPos); } } }
void CCrystalEditView::OnEditTab() { if (! QueryEditable() || m_pTextBuffer == NULL) return; BOOL bTabify = FALSE; CPoint ptSelStart, ptSelEnd; if (IsSelection()) { GetSelection(ptSelStart, ptSelEnd); bTabify = ptSelStart.y != ptSelEnd.y; } if (bTabify) { m_pTextBuffer->BeginUndoGroup(); int nStartLine = ptSelStart.y; int nEndLine = ptSelEnd.y; ptSelStart.x = 0; if (ptSelEnd.x > 0) { if (ptSelEnd.y == GetLineCount() - 1) { ptSelEnd.x = GetLineLength(ptSelEnd.y); } else { ptSelEnd.x = 0; ptSelEnd.y ++; } } else nEndLine --; SetSelection(ptSelStart, ptSelEnd); SetCursorPos(ptSelEnd); EnsureVisible(ptSelEnd); // Shift selection to right m_bHorzScrollBarLocked = TRUE; static const TCHAR pszText[] = _T("\t"); for (int L = nStartLine; L <= nEndLine; L ++) { int x, y; m_pTextBuffer->InsertText(this, L, 0, pszText, y, x, CE_ACTION_INDENT); // [JRT] } m_bHorzScrollBarLocked = FALSE; RecalcHorzScrollBar(); m_pTextBuffer->FlushUndoGroup(this); return; } if (m_bOvrMode) { CPoint ptCursorPos = GetCursorPos(); ASSERT_VALIDTEXTPOS(ptCursorPos); int nLineLength = GetLineLength(ptCursorPos.y); LPCTSTR pszLineChars = GetLineChars(ptCursorPos.y); if (ptCursorPos.x < nLineLength) { int nTabSize = GetTabSize(); int nChars = nTabSize - CalculateActualOffset(ptCursorPos.y, ptCursorPos.x) % nTabSize; ASSERT(nChars > 0 && nChars <= nTabSize); while (nChars > 0) { if (ptCursorPos.x == nLineLength) break; if (pszLineChars[ptCursorPos.x] == _T('\t')) { ptCursorPos.x ++; break; } ptCursorPos.x ++; nChars --; } ASSERT(ptCursorPos.x <= nLineLength); ASSERT_VALIDTEXTPOS(ptCursorPos); SetSelection(ptCursorPos, ptCursorPos); SetAnchor(ptCursorPos); SetCursorPos(ptCursorPos); EnsureVisible(ptCursorPos); return; } } m_pTextBuffer->BeginUndoGroup(); DeleteCurrentSelection(); CPoint ptCursorPos = GetCursorPos(); ASSERT_VALIDTEXTPOS(ptCursorPos); static const TCHAR pszText[] = _T("\t"); int x, y; m_pTextBuffer->InsertText(this, ptCursorPos.y, ptCursorPos.x, pszText, y, x, CE_ACTION_TYPING); // [JRT] ptCursorPos.x = x; ptCursorPos.y = y; ASSERT_VALIDTEXTPOS(ptCursorPos); SetSelection(ptCursorPos, ptCursorPos); SetAnchor(ptCursorPos); SetCursorPos(ptCursorPos); EnsureVisible(ptCursorPos); m_pTextBuffer->FlushUndoGroup(this); }
void NbStyleVC71::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { // Visual studio 7.1 style // This code is based on the renderer included in wxFlatNotebook: // http://svn.berlios.de/wsvn/codeblocks/trunk/src/sdk/wxFlatNotebook/src/wxFlatNotebook/renderer.cpp?rev=5106 // figure out the size of the tab wxSize tab_size = GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); #if wxCHECK_VERSION(3, 0, 0) wxCoord tab_height = m_tabCtrlHeight - 3; #else wxCoord tab_height = m_tab_ctrl_height - 3; #endif wxCoord tab_width = tab_size.x; wxCoord tab_x = in_rect.x; wxCoord tab_y = in_rect.y + in_rect.height - tab_height; int clip_width = tab_width; if (tab_x + clip_width > in_rect.x + in_rect.width - 4) clip_width = (in_rect.x + in_rect.width) - tab_x - 4; dc.SetClippingRegion(tab_x, tab_y, clip_width + 1, tab_height - 3); if(m_flags & wxAUI_NB_BOTTOM) tab_y--; dc.SetPen((page.active) ? wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT)) : wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW))); dc.SetBrush((page.active) ? wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)) : wxBrush(*wxTRANSPARENT_BRUSH)); if (page.active) { // int tabH = (m_flags & wxAUI_NB_BOTTOM) ? tab_height - 5 : tab_height - 2; int tabH = tab_height - 2; dc.DrawRectangle(tab_x, tab_y, tab_width, tabH); int rightLineY1 = (m_flags & wxAUI_NB_BOTTOM) ? c_vertical_border_padding - 2 : c_vertical_border_padding - 1; int rightLineY2 = tabH + 3; dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW))); dc.DrawLine(tab_x + tab_width - 1, rightLineY1 + 1, tab_x + tab_width - 1, rightLineY2); if(m_flags & wxAUI_NB_BOTTOM) dc.DrawLine(tab_x + 1, rightLineY2 - 3 , tab_x + tab_width - 1, rightLineY2 - 3); dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DDKSHADOW))); dc.DrawLine(tab_x + tab_width , rightLineY1 , tab_x + tab_width, rightLineY2); if(m_flags & wxAUI_NB_BOTTOM) dc.DrawLine(tab_x , rightLineY2 - 2 , tab_x + tab_width, rightLineY2 - 2); } else { // We dont draw a rectangle for non selected tabs, but only // vertical line on the right int blackLineY1 = (m_flags & wxAUI_NB_BOTTOM) ? c_vertical_border_padding + 2 : c_vertical_border_padding + 1; int blackLineY2 = tab_height - 5; dc.DrawLine(tab_x + tab_width, blackLineY1, tab_x + tab_width, blackLineY2); } wxPoint border_points[2]; if (m_flags & wxAUI_NB_BOTTOM) { border_points[0] = wxPoint(tab_x, tab_y); border_points[1] = wxPoint(tab_x, tab_y + tab_height - 6); } else // if (m_flags & wxAUI_NB_TOP) { border_points[0] = wxPoint(tab_x, tab_y + tab_height - 4); border_points[1] = wxPoint(tab_x, tab_y + 2); } int drawn_tab_yoff = border_points[1].y; int drawn_tab_height = border_points[0].y - border_points[1].y; int text_offset = tab_x + 8; int bitmap_offset = 0; if (page.bitmap.IsOk()) { bitmap_offset = tab_x + 8; // draw bitmap dc.DrawBitmap(page.bitmap, bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2), true); text_offset = bitmap_offset + page.bitmap.GetWidth(); text_offset += 3; // bitmap padding } else { text_offset = tab_x + 8; } // if the caption is empty, measure some temporary text wxString caption = page.caption; if (caption.empty()) caption = wxT("Xj"); wxCoord textx; wxCoord texty; if (page.active) #if wxCHECK_VERSION(3, 0, 0) dc.SetFont(m_selectedFont); #else dc.SetFont(m_selected_font); #endif else
void wxAuiMSWTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { if ( !IsThemed() ) { wxAuiGenericTabArt::DrawTab(dc, wnd, page, in_rect, close_button_state, out_tab_rect, out_button_rect, x_extent); return; } if ( !m_closeBtnSize.IsFullySpecified() ) InitSizes(wnd, dc); // figure out the size of the tab wxSize tabSize = GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxCoord tabHeight = tabSize.y; wxCoord tabWidth = tabSize.x; wxCoord tabX = in_rect.x; wxCoord tabY = 0; if (!page.active) { tabY += wnd->FromDIP(2); tabHeight -= wnd->FromDIP(2); } else { tabX -= wnd->FromDIP(2); tabWidth += wnd->FromDIP(4); tabHeight += 2; } int clipWidth = tabWidth; if ( tabX + clipWidth > in_rect.x + in_rect.width ) clipWidth = (in_rect.x + in_rect.width) - tabX; dc.SetClippingRegion(tabX - wnd->FromDIP(2), tabY, clipWidth + wnd->FromDIP(4), tabHeight); // draw tab wxRect tabRect(tabX, tabY, tabWidth, tabHeight); int tabState; if ( page.active ) tabState = TIS_SELECTED; else if ( page.hover ) tabState = TIS_HOT; else tabState = TIS_NORMAL; wxUxThemeHandle hTabTheme(wnd, L"Tab"); RECT tabR; wxCopyRectToRECT(tabRect, tabR); ::DrawThemeBackground(hTabTheme, GetHdcOf(dc.GetTempHDC()), TABP_TABITEM, tabState, &tabR, NULL); // Apparently, in at least some Windows 10 installations the call above // does not draw the left edge of the first tab and it needs to be drawn // separately, or it wouldn't be drawn at all. if ( tabX == GetIndentSize() ) { ::DrawThemeBackground ( hTabTheme, GetHdcOf(dc.GetTempHDC()), TABP_TABITEMLEFTEDGE, tabState, &tabR, NULL ); } wxRect textRect = tabRect; if ( !page.active ) textRect.Offset(0, wnd->FromDIP(1)); if ( close_button_state != wxAUI_BUTTON_STATE_HIDDEN ) textRect.width -= m_closeBtnSize.x + wnd->FromDIP(3); dc.SetFont(wnd->GetFont()); dc.DrawLabel(page.caption, page.bitmap, textRect, wxALIGN_CENTRE); // draw focus rectangle if ( page.active && (wnd->FindFocus() == wnd) ) { wxRect focusRect = tabRect; focusRect.Deflate(wnd->FromDIP(2)); wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0); } // draw close button if ( close_button_state != wxAUI_BUTTON_STATE_HIDDEN ) { wxUxThemeHandle hToolTipTheme(wnd, L"TOOLTIP"); int btnState; if ( close_button_state == wxAUI_BUTTON_STATE_HOVER ) btnState = TTCS_HOT; else if ( close_button_state == wxAUI_BUTTON_STATE_PRESSED ) btnState = TTCS_PRESSED; else btnState = TTCS_NORMAL; int offsetY = tabY; if ( wxGetWinVersion() < wxWinVersion_Vista ) offsetY++; // WinXP theme needs a little more padding wxRect rect(tabX + tabWidth - m_closeBtnSize.x - wnd->FromDIP(4), offsetY + (tabHeight / 2) - (m_closeBtnSize.y / 2), m_closeBtnSize.x, m_closeBtnSize.y); RECT btnR; wxCopyRectToRECT(rect, btnR); ::DrawThemeBackground(hToolTipTheme, GetHdcOf(dc.GetTempHDC()), TTP_CLOSE, btnState, &btnR, NULL); if ( out_button_rect ) *out_button_rect = rect; } *out_tab_rect = wxRect(tabX, tabY, tabWidth, tabHeight); dc.DestroyClippingRegion(); }
bool CSECEditor::ExpandLine (PLINEDESC pLine, CString &strText) { LPTSTR pszBuffer; int iBufferSize; LPCSTR pchText; int iLength; int iTabWidth; int iBufferOffset=0; int iOffset; ASSERT (pLine != NULL); if (pLine == NULL) return (false); iTabWidth = GetTabSize (); if (iTabWidth == 0) iTabWidth = 1; pchText = pLine->pText; ASSERT (pchText != NULL); if (pchText == NULL) return (false); iLength = pLine->iTxtSize; if (iLength >= 2 && pchText[iLength - 2] == '\r' && pchText[iLength - 1] == '\n') { iLength -= 2; }; // As many characters as could be occupied by line containing // tabs only. Allocate one extra character for null terminator. iBufferSize = iLength * iTabWidth + 1; pszBuffer = new TCHAR[iBufferSize + 1]; ASSERT (pszBuffer != NULL); if (pszBuffer == NULL) return (false); for (iOffset = 0; iOffset < iLength; ++iOffset) { char ch; ch = pchText[iOffset]; if (ch == '\t') { int iSpaces; iSpaces = 4 - (iBufferOffset % iTabWidth); while (iSpaces-- != 0) { if (iBufferOffset == iBufferSize) { delete pszBuffer; return (false); }; pszBuffer[iBufferOffset++] = _T (' '); }; } else { if (iBufferOffset == iBufferSize) { delete pszBuffer; return (false); }; pszBuffer[iBufferOffset++] = ch; }; }; pszBuffer[iBufferOffset] = _T ('\0'); strText = pszBuffer; delete pszBuffer; return (true); }
void wxGISTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { wxSize tab_size = GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxCoord tab_height = m_tabCtrlHeight - 2; wxCoord tab_width = tab_size.x; wxCoord tab_x = in_rect.x; wxCoord tab_y = in_rect.y + in_rect.height - tab_height; int clip_width = tab_width; if (tab_x + clip_width > in_rect.x + in_rect.width - 4) clip_width = (in_rect.x + in_rect.width) - tab_x - 4; dc.SetClippingRegion(tab_x, tab_y, clip_width + 1, tab_height - 3); wxPoint tabPoints[7]; int adjust = 0; if (!page.active) { adjust = 1; } tabPoints[0].x = tab_x + 3; tabPoints[0].y = (m_flags & wxAUI_NB_BOTTOM) ? 3 : tab_height - 2; tabPoints[1].x = tabPoints[0].x; tabPoints[1].y = (m_flags & wxAUI_NB_BOTTOM) ? tab_height - (VERT_PADDING + 2) - adjust : (VERT_PADDING + 2) + adjust; tabPoints[2].x = tabPoints[1].x+2; tabPoints[2].y = (m_flags & wxAUI_NB_BOTTOM) ? tab_height - VERT_PADDING - adjust: VERT_PADDING + adjust; tabPoints[3].x = tab_x +tab_width - 2; tabPoints[3].y = tabPoints[2].y; tabPoints[4].x = tabPoints[3].x + 2; tabPoints[4].y = tabPoints[1].y; tabPoints[5].x = tabPoints[4].x; tabPoints[5].y = tabPoints[0].y; tabPoints[6].x = tabPoints[0].x; tabPoints[6].y = tabPoints[0].y; dc.SetBrush((page.active) ? wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)) : wxBrush(*wxTRANSPARENT_BRUSH)); dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW))); dc.DrawPolygon(7, tabPoints); dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE))); if (page.active) { dc.DrawLine(tabPoints[0].x + 1, tabPoints[0].y, tabPoints[5].x , tabPoints[0].y); } int drawn_tab_yoff = tabPoints[1].y; int drawn_tab_height = tabPoints[0].y - tabPoints[2].y; int text_offset = tab_x + 8; int bitmap_offset = 0; if (page.bitmap.IsOk()) { bitmap_offset = tab_x + 8; // draw bitmap dc.DrawBitmap(page.bitmap, bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2), true); text_offset = bitmap_offset + page.bitmap.GetWidth(); text_offset += 3; // bitmap padding } else { text_offset = tab_x + 8; } // if the caption is empty, measure some temporary text wxString caption = page.caption; if (caption.empty()) caption = wxT("Xj"); wxCoord textx; wxCoord texty; if (page.active) dc.SetFont(m_selectedFont); else dc.SetFont(m_normalFont); dc.GetTextExtent(caption, &textx, &texty); // draw tab text dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT)); dc.DrawText(page.caption, text_offset, drawn_tab_yoff + drawn_tab_height / 2 - texty / 2 - 1); // draw 'x' on tab (if enabled) if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { int close_button_width = m_activeCloseBmp.GetWidth(); wxBitmap bmp = m_disabledCloseBmp; if ((close_button_state == wxAUI_BUTTON_STATE_HOVER) || (close_button_state == wxAUI_BUTTON_STATE_PRESSED)) bmp = m_activeCloseBmp; wxRect rect(tab_x + tab_width - close_button_width - 3, drawn_tab_yoff + (drawn_tab_height / 2) - (bmp.GetHeight() / 2), close_button_width, tab_height); // Indent the button if it is pressed down: if (close_button_state == wxAUI_BUTTON_STATE_PRESSED) { rect.x++; rect.y++; } dc.DrawBitmap(bmp, rect.x, rect.y, true); *out_button_rect = rect; } *out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height); dc.DestroyClippingRegion(); }
void CEditWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { CTextWnd::OnKeyDown(nChar, nRepCnt, nFlags); if (!QueryEditable() || m_pTextBuffer == NULL) return; bool isShift = (GetKeyState(VK_SHIFT) & 0xF0) != 0; bool isCtrl = (GetKeyState(VK_CONTROL) & 0xF0) != 0; if (nChar == VK_TAB) { BOOL bTabify = FALSE; CPoint ptSelStart, ptSelEnd; if (IsSelection()) { GetSelection(ptSelStart, ptSelEnd); bTabify = ptSelStart.y != ptSelEnd.y; } if (bTabify) { m_pTextBuffer->BeginUndoGroup(); int nStartLine = ptSelStart.y; int nEndLine = ptSelEnd.y; ptSelStart.x = 0; if (ptSelEnd.x > 0) { if (ptSelEnd.y == GetLineCount() - 1) { ptSelEnd.x = GetLineLength(ptSelEnd.y); } else { ptSelEnd.x = 0; ptSelEnd.y ++; } } else nEndLine --; SetSelection(ptSelStart, ptSelEnd); SetCursorPos(ptSelEnd); EnsureVisible(ptSelEnd); // Shift selection to right m_bHorzScrollBarLocked = TRUE; //static const TCHAR pszText[] = _T("\t"); CString pszText; if (!m_bReplaceTabs) pszText = "\t"; else { CString tmp(' ', GetTabSize()); pszText = tmp; } for (int L = nStartLine; L <= nEndLine; L ++) { int x, y; m_pTextBuffer->InsertText(this, L, 0, pszText, y, x, CE_ACTION_INDENT); } m_bHorzScrollBarLocked = FALSE; RecalcHorzScrollBar(); m_pTextBuffer->FlushUndoGroup(this); } else { m_pTextBuffer->BeginUndoGroup(); DeleteCurrentSelection(); CPoint ptCursorPos = GetCursorPos(); ASSERT_VALIDTEXTPOS(ptCursorPos); CString pszText; if (!m_bReplaceTabs) pszText = "\t"; else { CString tmp(' ', GetTabSize()); pszText = tmp; } int x, y; m_pTextBuffer->InsertText(this, ptCursorPos.y, ptCursorPos.x, pszText, y, x, CE_ACTION_TYPING); ptCursorPos.x = x; ptCursorPos.y = y; ASSERT_VALIDTEXTPOS(ptCursorPos); SetSelection(ptCursorPos, ptCursorPos); SetAnchor(ptCursorPos); SetCursorPos(ptCursorPos); EnsureVisible(ptCursorPos); m_pTextBuffer->FlushUndoGroup(this); } } if (nChar == VK_BACK && !IsSelection()) { CPoint ptCursorPos = GetCursorPos(); if (ptCursorPos.y > 0 || (ptCursorPos.x > 0 && ptCursorPos.y == 0)) { CPoint ptCurrentCursorPos = ptCursorPos; bool bDeleted = false; if(ptCursorPos.x == 0) { ptCursorPos.y--; ptCursorPos.x = GetLineLength(ptCursorPos.y); bDeleted = true; } else { ptCursorPos.x--; bDeleted = true; } ASSERT_VALIDTEXTPOS(ptCursorPos); SetAnchor(ptCursorPos); SetSelection(ptCursorPos, ptCursorPos); SetCursorPos(ptCursorPos); EnsureVisible(ptCursorPos); if (bDeleted) m_pTextBuffer->DeleteText(this, ptCursorPos.y, ptCursorPos.x, ptCurrentCursorPos.y, ptCurrentCursorPos.x, CE_ACTION_BACKSPACE); } } if (nChar == VK_DELETE && !isShift) { CPoint ptSelStart, ptSelEnd; GetSelection(ptSelStart, ptSelEnd); if (ptSelStart == ptSelEnd) { if (ptSelEnd.x == GetLineLength(ptSelEnd.y)) { if (ptSelEnd.y == GetLineCount() - 1) return; ptSelEnd.y++; ptSelEnd.x = 0; if (GetLineLength(ptSelStart.y) != 0) { LPCSTR chars = GetLineChars(ptSelEnd.y); for (int j = 0; j < QUOTE_LENGTH && j < GetLineLength(ptSelEnd.y); j++) if (chars[j] == '>') ptSelEnd.x = j + 1; while (ptSelEnd.x < GetLineLength(ptSelEnd.y) && (chars[ptSelEnd.x] == ' ' || chars[ptSelEnd.x] == '\t')) ptSelEnd.x++; } } else ptSelEnd.x++; } CPoint ptCursorPos = ptSelStart; ASSERT_VALIDTEXTPOS(ptCursorPos); SetAnchor(ptCursorPos); SetSelection(ptCursorPos, ptCursorPos); SetCursorPos(ptCursorPos); EnsureVisible(ptCursorPos); m_pTextBuffer->DeleteText(this, ptSelStart.y, ptSelStart.x, ptSelEnd.y, ptSelEnd.x, CE_ACTION_DELETE); } if ((nChar == 'X' && isCtrl) || (nChar == VK_DELETE && isShift)) Cut(); if ((nChar == 'V' && isCtrl) || (nChar == VK_INSERT && isShift)) Paste(); if (nChar == 'Z' && isCtrl && isShift) Redo(); if (nChar == 'Z' && isCtrl && !isShift) Undo(); }
void wxAuiGenericTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { wxCoord normal_textx, normal_texty; wxCoord selected_textx, selected_texty; wxCoord texty; // if the caption is empty, measure some temporary text wxString caption = page.caption; if (caption.empty()) caption = wxT("Xj"); dc.SetFont(m_selectedFont); dc.GetTextExtent(caption, &selected_textx, &selected_texty); dc.SetFont(m_normalFont); dc.GetTextExtent(caption, &normal_textx, &normal_texty); // figure out the size of the tab wxSize tab_size = GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxCoord tab_height = m_tabCtrlHeight - 3; wxCoord tab_width = tab_size.x; wxCoord tab_x = in_rect.x; wxCoord tab_y = in_rect.y + in_rect.height - tab_height; caption = page.caption; // select pen, brush and font for the tab to be drawn if (page.active) { dc.SetFont(m_selectedFont); texty = selected_texty; } else { dc.SetFont(m_normalFont); texty = normal_texty; } // create points that will make the tab outline int clip_width = tab_width; if (tab_x + clip_width > in_rect.x + in_rect.width) clip_width = (in_rect.x + in_rect.width) - tab_x; /* wxPoint clip_points[6]; clip_points[0] = wxPoint(tab_x, tab_y+tab_height-3); clip_points[1] = wxPoint(tab_x, tab_y+2); clip_points[2] = wxPoint(tab_x+2, tab_y); clip_points[3] = wxPoint(tab_x+clip_width-1, tab_y); clip_points[4] = wxPoint(tab_x+clip_width+1, tab_y+2); clip_points[5] = wxPoint(tab_x+clip_width+1, tab_y+tab_height-3); // FIXME: these ports don't provide wxRegion ctor from array of points #if !defined(__WXDFB__) && !defined(__WXCOCOA__) // set the clipping region for the tab -- wxRegion clipping_region(WXSIZEOF(clip_points), clip_points); dc.SetClippingRegion(clipping_region); #endif // !wxDFB && !wxCocoa */ // since the above code above doesn't play well with WXDFB or WXCOCOA, // we'll just use a rectangle for the clipping region for now -- dc.SetClippingRegion(tab_x, tab_y, clip_width+1, tab_height-3); wxPoint border_points[6]; if (m_flags &wxAUI_NB_BOTTOM) { border_points[0] = wxPoint(tab_x, tab_y); border_points[1] = wxPoint(tab_x, tab_y+tab_height-6); border_points[2] = wxPoint(tab_x+2, tab_y+tab_height-4); border_points[3] = wxPoint(tab_x+tab_width-2, tab_y+tab_height-4); border_points[4] = wxPoint(tab_x+tab_width, tab_y+tab_height-6); border_points[5] = wxPoint(tab_x+tab_width, tab_y); } else //if (m_flags & wxAUI_NB_TOP) {} { border_points[0] = wxPoint(tab_x, tab_y+tab_height-4); border_points[1] = wxPoint(tab_x, tab_y+2); border_points[2] = wxPoint(tab_x+2, tab_y); border_points[3] = wxPoint(tab_x+tab_width-2, tab_y); border_points[4] = wxPoint(tab_x+tab_width, tab_y+2); border_points[5] = wxPoint(tab_x+tab_width, tab_y+tab_height-4); } // TODO: else if (m_flags &wxAUI_NB_LEFT) {} // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} int drawn_tab_yoff = border_points[1].y; int drawn_tab_height = border_points[0].y - border_points[1].y; if (page.active) { // draw active tab // draw base background color wxRect r(tab_x, tab_y, tab_width, tab_height); dc.SetPen(wxPen(m_activeColour)); dc.SetBrush(wxBrush(m_activeColour)); dc.DrawRectangle(r.x+1, r.y+1, r.width-1, r.height-4); // this white helps fill out the gradient at the top of the tab dc.SetPen(*wxWHITE_PEN); dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRectangle(r.x+2, r.y+1, r.width-3, r.height-4); // these two points help the rounded corners appear more antialiased dc.SetPen(wxPen(m_activeColour)); dc.DrawPoint(r.x+2, r.y+1); dc.DrawPoint(r.x+r.width-2, r.y+1); // set rectangle down a bit for gradient drawing r.SetHeight(r.GetHeight()/2); r.x += 2; r.width -= 3; r.y += r.height; r.y -= 2; // draw gradient background wxColor top_color = *wxWHITE; wxColor bottom_color = m_activeColour; dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH); } else { // draw inactive tab wxRect r(tab_x, tab_y+1, tab_width, tab_height-3); // start the gradent up a bit and leave the inside border inset // by a pixel for a 3D look. Only the top half of the inactive // tab will have a slight gradient r.x += 3; r.y++; r.width -= 4; r.height /= 2; r.height--; // -- draw top gradient fill for glossy look wxColor top_color = m_baseColour; wxColor bottom_color = top_color.ChangeLightness(160); dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH); r.y += r.height; r.y--; // -- draw bottom fill for glossy look top_color = m_baseColour; bottom_color = m_baseColour; dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH); } // draw tab outline dc.SetPen(m_borderPen); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawPolygon(WXSIZEOF(border_points), border_points); // there are two horizontal grey lines at the bottom of the tab control, // this gets rid of the top one of those lines in the tab control if (page.active) { if (m_flags &wxAUI_NB_BOTTOM) dc.SetPen(wxPen(m_baseColour.ChangeLightness(170))); // TODO: else if (m_flags &wxAUI_NB_LEFT) {} // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} else //for wxAUI_NB_TOP dc.SetPen(m_baseColourPen); dc.DrawLine(border_points[0].x+1, border_points[0].y, border_points[5].x, border_points[5].y); } int text_offset = tab_x + 8; int close_button_width = 0; if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { close_button_width = m_activeCloseBmp.GetWidth(); } int bitmap_offset = 0; if (page.bitmap.IsOk()) { bitmap_offset = tab_x + 8; // draw bitmap dc.DrawBitmap(page.bitmap, bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2), true); text_offset = bitmap_offset + page.bitmap.GetWidth(); text_offset += 3; // bitmap padding } else { text_offset = tab_x + 8; } wxString draw_text = wxAuiChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width); // draw tab text dc.DrawText(draw_text, text_offset, drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1); // draw focus rectangle if (page.active && (wnd->FindFocus() == wnd)) { wxRect focusRectText(text_offset, (drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1), selected_textx, selected_texty); wxRect focusRect; wxRect focusRectBitmap; if (page.bitmap.IsOk()) focusRectBitmap = wxRect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2), page.bitmap.GetWidth(), page.bitmap.GetHeight()); if (page.bitmap.IsOk() && draw_text.IsEmpty()) focusRect = focusRectBitmap; else if (!page.bitmap.IsOk() && !draw_text.IsEmpty()) focusRect = focusRectText; else if (page.bitmap.IsOk() && !draw_text.IsEmpty()) focusRect = focusRectText.Union(focusRectBitmap); focusRect.Inflate(2, 2); wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0); } // draw close button if necessary if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { wxBitmap bmp = m_disabledCloseBmp; if (close_button_state == wxAUI_BUTTON_STATE_HOVER || close_button_state == wxAUI_BUTTON_STATE_PRESSED) { bmp = m_activeCloseBmp; } int offsetY = tab_y-1; if (m_flags & wxAUI_NB_BOTTOM) offsetY = 1; wxRect rect(tab_x + tab_width - close_button_width - 1, offsetY + (tab_height/2) - (bmp.GetHeight()/2), close_button_width, tab_height); IndentPressedBitmap(&rect, close_button_state); dc.DrawBitmap(bmp, rect.x, rect.y, true); *out_button_rect = rect; } *out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height); dc.DestroyClippingRegion(); }
void SAuiTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { wxCoord normal_textx, normal_texty; wxCoord selected_textx, selected_texty; wxCoord texty; // if the caption is empty, measure some temporary text wxString caption = page.caption; if (caption.empty()) caption = wxT("Xj"); dc.SetFont(m_selectedFont); dc.GetTextExtent(caption, &selected_textx, &selected_texty); dc.SetFont(m_normalFont); dc.GetTextExtent(caption, &normal_textx, &normal_texty); bool bluetab = false; if (page.window->GetName() == "startpage") bluetab = true; // figure out the size of the tab wxSize tab_size = GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxCoord tab_height = m_tabCtrlHeight + 2;// -1;// -3; wxCoord tab_width = tab_size.x; wxCoord tab_x = in_rect.x; wxCoord tab_y = in_rect.y + in_rect.height - tab_height + 3; if (!page.active) { tab_height -= 2; tab_y += 2; } caption = page.caption; // select pen, brush and font for the tab to be drawn if (page.active) { dc.SetFont(m_selectedFont); texty = selected_texty; } else { dc.SetFont(m_normalFont); texty = normal_texty; } // create points that will make the tab outline int clip_width = tab_width; if (tab_x + clip_width > in_rect.x + in_rect.width) clip_width = (in_rect.x + in_rect.width) - tab_x; dc.SetClippingRegion(tab_x, tab_y, clip_width + 1, tab_height - 3); wxPoint border_points[6]; if (m_flags &wxAUI_NB_BOTTOM) { border_points[0] = wxPoint(tab_x, tab_y); border_points[1] = wxPoint(tab_x, tab_y + tab_height - 4); border_points[2] = wxPoint(tab_x, tab_y + tab_height - 4); border_points[3] = wxPoint(tab_x + tab_width, tab_y + tab_height - 4); border_points[4] = wxPoint(tab_x + tab_width, tab_y + tab_height - 4); border_points[5] = wxPoint(tab_x + tab_width, tab_y); } else { border_points[0] = wxPoint(tab_x, tab_y + tab_height - 4); border_points[1] = wxPoint(tab_x, tab_y); border_points[2] = wxPoint(tab_x + 2, tab_y); border_points[3] = wxPoint(tab_x + tab_width - 2, tab_y); border_points[4] = wxPoint(tab_x + tab_width, tab_y); border_points[5] = wxPoint(tab_x + tab_width, tab_y + tab_height - 4); } int drawn_tab_yoff = border_points[1].y + 1; int drawn_tab_height = border_points[0].y - border_points[1].y; wxColour bgcol; if (page.active) { // draw active tab bgcol = m_activeColour; // draw base background color wxRect r(tab_x, tab_y, tab_width, tab_height); dc.SetPen(wxPen(bluetab ? wxColor(224, 238, 255) : m_activeColour)); dc.SetBrush(wxBrush(bluetab ? wxColor(224, 238, 255) : m_activeColour)); dc.DrawRectangle(r.x + 1, r.y + 1, r.width - 1, r.height - 5); // highlight top of tab wxColour col_hilight = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); dc.SetPen(*wxTRANSPARENT_PEN);// *wxWHITE_PEN); dc.SetBrush(wxBrush(col_hilight));// *wxWHITE_BRUSH); dc.DrawRectangle(r.x + 1, r.y + 1, r.width - 1, 1); } else { bgcol = m_inactiveTabColour; wxRect r(tab_x, tab_y, tab_width, tab_height); wxPoint mouse = wnd->ScreenToClient(wxGetMousePosition()); /*if (r.Contains(mouse)) { dc.SetPen(wxPen(m_activeColour)); dc.SetBrush(wxBrush(m_activeColour)); } else {*/ dc.SetPen(wxPen(m_inactiveTabColour)); dc.SetBrush(wxBrush(m_inactiveTabColour)); //} dc.DrawRectangle(r.x + 1, r.y + 1, r.width - 1, r.height - 4); } // draw tab outline dc.SetPen(m_borderPen); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawPolygon(WXSIZEOF(border_points), border_points); // there are two horizontal grey lines at the bottom of the tab control, // this gets rid of the top one of those lines in the tab control if (page.active) { if (m_flags &wxAUI_NB_BOTTOM) dc.SetPen(wxPen(m_baseColour.ChangeLightness(170))); else dc.SetPen(wxPen(bluetab ? wxColor(224, 238, 255) : m_activeColour)); dc.DrawLine(border_points[0].x + 1, border_points[0].y, border_points[5].x, border_points[5].y); } int text_offset = tab_x + 8; int close_button_width = 0; if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { close_button_width = m_activeCloseBmp.GetWidth(); } int bitmap_offset = 0; if (page.bitmap.IsOk()) { bitmap_offset = tab_x + 8; // draw bitmap dc.DrawBitmap(page.bitmap, bitmap_offset, drawn_tab_yoff + (drawn_tab_height / 2) - (page.bitmap.GetHeight() / 2), true); text_offset = bitmap_offset + page.bitmap.GetWidth(); text_offset += 4; // bitmap padding } else { text_offset = tab_x + 8; } dc.SetTextForeground((page.active && bluetab) ? wxColor(0,0,0) : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); wxString draw_text = wxAuiChopText(dc, caption, tab_width - (text_offset - tab_x) - close_button_width); // draw tab text dc.DrawText(draw_text, text_offset, drawn_tab_yoff + (drawn_tab_height) / 2 - (texty / 2) - 0); // draw focus rectangle if (page.active && (wnd->FindFocus() == wnd)) { wxRect focusRectText(text_offset, (drawn_tab_yoff + (drawn_tab_height) / 2 - (texty / 2) - 1), selected_textx, selected_texty); wxRect focusRect; wxRect focusRectBitmap; if (page.bitmap.IsOk()) focusRectBitmap = wxRect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height / 2) - (page.bitmap.GetHeight() / 2), page.bitmap.GetWidth(), page.bitmap.GetHeight()); if (page.bitmap.IsOk() && draw_text.IsEmpty()) focusRect = focusRectBitmap; else if (!page.bitmap.IsOk() && !draw_text.IsEmpty()) focusRect = focusRectText; else if (page.bitmap.IsOk() && !draw_text.IsEmpty()) focusRect = focusRectText.Union(focusRectBitmap); focusRect.Inflate(2, 2); wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0); } // draw close button if necessary if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { wxBitmap bmp = m_disabledCloseBmp; int offsetY = tab_y; if (m_flags & wxAUI_NB_BOTTOM) offsetY = 1; wxRect rect(tab_x + tab_width - close_button_width - 3, offsetY + (tab_height / 2) - (bmp.GetHeight() / 2), close_button_width, tab_height); IndentPressedBitmap(&rect, close_button_state); if (close_button_state == wxAUI_BUTTON_STATE_HOVER || close_button_state == wxAUI_BUTTON_STATE_PRESSED) { /*wxColour bcol = m_borderPen.GetColour(); float r = ((float)bcol.Red() * 0.2f) + ((float)m_activeColour.Red() * 0.8f); float g = ((float)bcol.Green() * 0.2f) + ((float)m_activeColour.Green() * 0.8f); float b = ((float)bcol.Blue() * 0.2f) + ((float)m_activeColour.Blue() * 0.8f);*/ //captionAccentColour = wxColor(r, g, b); //dc.SetPen(*wxTRANSPARENT_PEN); dc.SetPen(wxPen(Drawing::darkColour(bgcol, 2.0f))); dc.SetBrush(wxBrush(Drawing::lightColour(bgcol, 1.0f))); dc.DrawRectangle(rect.x, rect.y + 1, rect.width - 1, rect.width - 2); bmp = m_activeCloseBmp; //dc.DrawBitmap(bmp, rect.x + 1, rect.y, true); //dc.DrawBitmap(bmp, rect.x - 1, rect.y, true); dc.DrawBitmap(bmp, rect.x, rect.y, true); } else { bmp = m_disabledCloseBmp; dc.DrawBitmap(bmp, rect.x, rect.y, true); } *out_button_rect = rect; } *out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height); dc.DestroyClippingRegion(); }
void wxAuiSimpleTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { wxCoord normal_textx, normal_texty; wxCoord selected_textx, selected_texty; wxCoord textx, texty; // if the caption is empty, measure some temporary text wxString caption = page.caption; if (caption.empty()) caption = wxT("Xj"); dc.SetFont(m_selectedFont); dc.GetTextExtent(caption, &selected_textx, &selected_texty); dc.SetFont(m_normalFont); dc.GetTextExtent(caption, &normal_textx, &normal_texty); // figure out the size of the tab wxSize tab_size = GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxCoord tab_height = tab_size.y; wxCoord tab_width = tab_size.x; wxCoord tab_x = in_rect.x; wxCoord tab_y = in_rect.y + in_rect.height - tab_height; caption = page.caption; // select pen, brush and font for the tab to be drawn if (page.active) { dc.SetPen(m_selectedBkPen); dc.SetBrush(m_selectedBkBrush); dc.SetFont(m_selectedFont); textx = selected_textx; texty = selected_texty; } else { dc.SetPen(m_normalBkPen); dc.SetBrush(m_normalBkBrush); dc.SetFont(m_normalFont); textx = normal_textx; texty = normal_texty; } // -- draw line -- wxPoint points[7]; points[0].x = tab_x; points[0].y = tab_y + tab_height - 1; points[1].x = tab_x + tab_height - 3; points[1].y = tab_y + 2; points[2].x = tab_x + tab_height + 3; points[2].y = tab_y; points[3].x = tab_x + tab_width - 2; points[3].y = tab_y; points[4].x = tab_x + tab_width; points[4].y = tab_y + 2; points[5].x = tab_x + tab_width; points[5].y = tab_y + tab_height - 1; points[6] = points[0]; dc.SetClippingRegion(in_rect); dc.DrawPolygon(WXSIZEOF(points) - 1, points); dc.SetPen(*wxGREY_PEN); //dc.DrawLines(active ? WXSIZEOF(points) - 1 : WXSIZEOF(points), points); dc.DrawLines(WXSIZEOF(points), points); int text_offset; int close_button_width = 0; if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { close_button_width = m_activeCloseBmp.GetWidth(); text_offset = tab_x + (tab_height/2) + ((tab_width-close_button_width)/2) - (textx/2); } else { text_offset = tab_x + (tab_height/3) + (tab_width/2) - (textx/2); } // set minimum text offset if (text_offset < tab_x + tab_height) text_offset = tab_x + tab_height; // chop text if necessary wxString draw_text = wxAuiChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width); // draw tab text dc.DrawText(draw_text, text_offset, (tab_y + tab_height)/2 - (texty/2) + 1); // draw focus rectangle if (page.active && (wnd->FindFocus() == wnd)) { wxRect focusRect(text_offset, ((tab_y + tab_height)/2 - (texty/2) + 1), selected_textx, selected_texty); focusRect.Inflate(2, 2); wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0); } // draw close button if necessary if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { wxBitmap bmp; if (page.active) bmp = m_activeCloseBmp; else bmp = m_disabledCloseBmp; wxRect rect(tab_x + tab_width - close_button_width - 1, tab_y + (tab_height/2) - (bmp.GetHeight()/2) + 1, close_button_width, tab_height - 1); DrawButtons(dc, rect, bmp, *wxWHITE, close_button_state); *out_button_rect = rect; } *out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height); dc.DestroyClippingRegion(); }
void clAuiMainNotebookTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { int curx = 0; wxGCDC gdc; if(!DrawingUtils::GetGCDC(dc, gdc)) return; wxColour penColour = page.active ? m_activeTabPenColour : m_penColour; wxGraphicsPath path = gdc.GetGraphicsContext()->CreatePath(); gdc.SetPen(penColour); wxSize sz = GetTabSize(gdc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxRect rr(in_rect.GetTopLeft(), sz); rr.y += TAB_Y_OFFSET; rr.width -= 1; #ifndef __WXMAC__ if(page.active) { rr.y -= 2; rr.height += 2; } #endif #ifdef __WXGTK__ rr.height += TAB_HEIGHT_SPACER; #else rr.height += 4; #endif /// the tab start position (x) curx = rr.x + 7; // Set clipping region int clip_width = rr.width; if(rr.x + clip_width > in_rect.x + in_rect.width) clip_width = (in_rect.x + in_rect.width) - rr.x; gdc.SetClippingRegion(rr.x, rr.y, clip_width, rr.height); gdc.SetBrush(m_bgColour); gdc.SetPen(penColour); if(page.active) { gdc.SetBrush(m_activeTabBgColour); path.AddRoundedRectangle(rr.x, rr.y, rr.width - 1, rr.height, TAB_RADIUS); gdc.GetGraphicsContext()->FillPath(path); gdc.GetGraphicsContext()->StrokePath(path); } else { wxGraphicsPath outerPath = gdc.GetGraphicsContext()->CreatePath(); gdc.SetPen(penColour); outerPath.AddRoundedRectangle(rr.x, rr.y, rr.width - 1, rr.height, TAB_RADIUS); gdc.GetGraphicsContext()->StrokePath(outerPath); gdc.SetPen(m_innerPenColour); path.AddRoundedRectangle(rr.x + 1, rr.y + 1, rr.width - 3, rr.height - 1, TAB_RADIUS); gdc.GetGraphicsContext()->StrokePath(path); gdc.SetBrush(m_tabBgColour); gdc.GetGraphicsContext()->StrokePath(path); gdc.GetGraphicsContext()->FillPath(path); gdc.SetPen(penColour); } if(!page.active) { // Draw a line at the bottom rect gdc.SetPen(m_activeTabPenColour); gdc.DrawLine(in_rect.GetBottomLeft(), in_rect.GetBottomRight()); } wxString caption = page.caption; if(caption.IsEmpty()) { caption = "Tp"; } wxFont fnt = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); if(page.active) { fnt.SetWeight(wxFONTWEIGHT_BOLD); } gdc.SetFont(fnt); wxSize ext = gdc.GetTextExtent(caption); if(caption == "Tp") caption.Clear(); /// Draw the bitmap if(page.bitmap.IsOk()) { int bmpy = (rr.y + (rr.height - page.bitmap.GetHeight()) / 2) - TAB_Y_OFFSET; gdc.GetGraphicsContext()->DrawBitmap(page.bitmap, curx, bmpy, page.bitmap.GetWidth(), page.bitmap.GetHeight()); curx += page.bitmap.GetWidth(); curx += 3; } /// Draw the text wxColour textColour = page.active ? m_activeTabTextColour : m_tabTextColour; gdc.SetTextForeground(textColour); gdc.GetGraphicsContext()->DrawText( page.caption, curx, (rr.y + (rr.height - ext.y) / 2) - TAB_Y_OFFSET + TEXT_Y_SPACER); // advance the X offset curx += ext.x; curx += 3; /// Draw the X button on the tab if(close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { int btny = (rr.y + (rr.height / 2)) - TAB_Y_OFFSET + TEXT_Y_SPACER; if(close_button_state == wxAUI_BUTTON_STATE_PRESSED) { curx += 1; btny += 1; } /// Defines the rectangle surrounding the X button wxRect xRect = wxRect(curx, btny - X_RADIUS, X_DIAMETER, X_DIAMETER); *out_button_rect = xRect; /// Defines the 'x' inside the circle wxPoint circleCenter(curx + X_RADIUS, btny); wxDouble xx_width = ::sqrt(::pow(X_DIAMETER, 2.0) / 2.0); wxDouble x_square = (circleCenter.x - (xx_width / 2.0)); wxDouble y_square = (circleCenter.y - (xx_width / 2.0)); wxPoint2DDouble ptXTopLeft(x_square, y_square); wxRect2DDouble insideRect(ptXTopLeft.m_x, ptXTopLeft.m_y, xx_width, xx_width); insideRect.Inset(1.0, 1.0); // Shrink it by 1 pixle /// Draw the 'x' itself wxGraphicsPath xpath = gdc.GetGraphicsContext()->CreatePath(); xpath.MoveToPoint(insideRect.GetLeftTop()); xpath.AddLineToPoint(insideRect.GetRightBottom()); xpath.MoveToPoint(insideRect.GetRightTop()); xpath.AddLineToPoint(insideRect.GetLeftBottom()); gdc.SetPen(wxPen(textColour, 1)); gdc.GetGraphicsContext()->StrokePath(xpath); curx += X_DIAMETER; } *out_tab_rect = rr; gdc.DestroyClippingRegion(); }