int CALLBACK GetMemoData( LPVOID lp, int nGetType, LPVOID lpData, int nDataSize) { switch( nGetType) { case _GET_MEMO: return GetMemo( lp, lpData, nDataSize); case _GET_TITLE: return GetTitle( lp, lpData, nDataSize); case _GET_FONT: return GetFont( lp, lpData, nDataSize); case _GET_FORECOLOR: return GetForeColor( lp, lpData, nDataSize); case _GET_BACKCOLOR: return GetBackColor( lp, lpData, nDataSize); case _GET_ICON: return GetIconIndex( lp); case _GET_ZORDER: return GetZOrder( lp); case _GET_WINDOWTYPE: return GetWindowType( lp); case _GET_RECT_NORMAL: return GetNormalRect( lp, lpData, nDataSize); case _GET_POINT_TITLE: return GetTitlePoint( lp, lpData, nDataSize); case _GET_POINT_ICON: return GetIconPoint( lp, lpData, nDataSize); case _GET_RECT_TITLE: return GetTitleRect( lp, lpData, nDataSize); case _GET_RECT_ICON: return GetIconRect( lp, lpData, nDataSize); case _GET_TIMERENABLE: return IsTimerEnable( lp); case _GET_TIMER_TYPE: return GetTimerType( lp); case _GET_TIMER_MONTH: return GetTimerMonth( lp); case _GET_TIMER_DAY: return GetTimerDay( lp); case _GET_TIMER_HOUR: return GetTimerHour( lp); case _GET_TIMER_MIN: return GetTimerMin( lp); case _GET_TIMER_WEEK: return GetTimerWeek( lp); case _GET_TIMER_SOUND: return GetTimerSound( lp, lpData, nDataSize); case _GET_LINKENABLE: return IsLink( lp); case _GET_LINK_FILE: return GetLinkFile( lp, lpData, nDataSize); case _GET_LINK_PARAM: return GetLinkParam( lp, lpData, nDataSize); case _GET_CREATE_YEAR: return GetCreateYear( lp); case _GET_CREATE_MONTH: return GetCreateMonth( lp); case _GET_CREATE_DAY: return GetCreateDay( lp); case _GET_DEF_FONT: return GetDefFont( lpData, nDataSize); case _GET_DEF_FORECLR: return GetDefForeColor( lpData, nDataSize); case _GET_DEF_BACKCLR: return GetDefBackColor( lpData, nDataSize); case _GET_VERSION: return VERSION_CODE; } return 0; }
void VividTree::OnPaint() { CPaintDC dc(this); // Device context for painting CDC dc_ff; // Memory base device context for flicker free painting CBitmap bm_ff; // The bitmap we paint into CBitmap *bm_old; CFont *font, *old_font; CFont fontDC; int old_mode; GetClientRect(&m_rect); SCROLLINFO scroll_info; // Determine window portal to draw into taking into account // scrolling position if ( GetScrollInfo( SB_HORZ, &scroll_info, SIF_POS | SIF_RANGE ) ) { m_h_offset = -scroll_info.nPos; m_h_size = max( scroll_info.nMax+1, m_rect.Width()); } else { m_h_offset = m_rect.left; m_h_size = m_rect.Width(); } if ( GetScrollInfo( SB_VERT, &scroll_info, SIF_POS | SIF_RANGE ) ) { if ( scroll_info.nMin == 0 && scroll_info.nMax == 100) scroll_info.nMax = 0; m_v_offset = -scroll_info.nPos * GetItemHeight(); m_v_size = max( (scroll_info.nMax+2)*((int)GetItemHeight()+1), m_rect.Height() ); } else { m_v_offset = m_rect.top; m_v_size = m_rect.Height(); } // Create an offscreen dc to paint with (prevents flicker issues) dc_ff.CreateCompatibleDC( &dc ); bm_ff.CreateCompatibleBitmap( &dc, m_rect.Width(), m_rect.Height() ); // Select the bitmap into the off-screen DC. bm_old = (CBitmap *)dc_ff.SelectObject( &bm_ff ); // Default font in the DC is not the font used by the tree control, so grab it and select it in. font = GetFont(); old_font = dc_ff.SelectObject( font ); // We're going to draw text transparently. old_mode = dc_ff.SetBkMode( TRANSPARENT ); DrawBackGround( &dc_ff ); DrawItems( &dc_ff ); // Now Blt the changes to the real device context - this prevents flicker. dc.BitBlt( m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(), &dc_ff, 0, 0, SRCCOPY); dc_ff.SelectObject( old_font ); dc_ff.SetBkMode( old_mode ); dc_ff.SelectObject( bm_old ); // printx("Enter VividTree::OnPaint().\n"); }
void CClientListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if (!theApp.emuledlg->IsRunning()) return; if (!lpDrawItemStruct->itemData) return; CDC* odc = CDC::FromHandle(lpDrawItemStruct->hDC); BOOL bCtrlFocused = ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS)); if (lpDrawItemStruct->itemState & ODS_SELECTED) { if (bCtrlFocused) odc->SetBkColor(m_crHighlight); else odc->SetBkColor(m_crNoHighlight); } else odc->SetBkColor(GetBkColor()); const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData; CMemDC dc(odc, &lpDrawItemStruct->rcItem); CFont* pOldFont = dc.SelectObject(GetFont()); CRect cur_rec(lpDrawItemStruct->rcItem); COLORREF crOldTextColor = dc.SetTextColor((lpDrawItemStruct->itemState & ODS_SELECTED) ? m_crHighlightText : m_crWindowText); int iOldBkMode; if (m_crWindowTextBk == CLR_NONE){ DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)dc, 0); iOldBkMode = dc.SetBkMode(TRANSPARENT); } else iOldBkMode = OPAQUE; CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl(); int iCount = pHeaderCtrl->GetItemCount(); cur_rec.right = cur_rec.left - 8; cur_rec.left += 4; CString Sbuffer; for(int iCurrent = 0; iCurrent < iCount; iCurrent++){ int iColumn = pHeaderCtrl->OrderToIndex(iCurrent); if( !IsColumnHidden(iColumn) ){ cur_rec.right += GetColumnWidth(iColumn); switch(iColumn){ case 0:{ uint8 image; if (client->IsFriend()) image = 2; else if (client->GetClientSoft() == SO_EDONKEYHYBRID) image = 4; else if (client->GetClientSoft() == SO_MLDONKEY) image = 3; else if (client->GetClientSoft() == SO_SHAREAZA) image = 5; else if (client->GetClientSoft() == SO_URL) image = 6; else if (client->GetClientSoft() == SO_AMULE) image = 7; else if (client->GetClientSoft() == SO_LPHANT) image = 8; else if (client->ExtProtocolAvailable()) image = 1; else image = 0; uint32 nOverlayImage = 0; if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED)) nOverlayImage |= 1; if (client->IsObfuscatedConnectionEstablished()) nOverlayImage |= 2; POINT point = {cur_rec.left, cur_rec.top+1}; imagelist.Draw(dc,image, point, ILD_NORMAL | ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED) ? INDEXTOOVERLAYMASK(1) : 0)); if (client->GetUserName()==NULL) Sbuffer.Format(_T("(%s)"), GetResString(IDS_UNKNOWN)); else Sbuffer = client->GetUserName(); //EastShare Start - added by AndCycle, IP to Country CString tempStr; tempStr.Format(_T("%s%s"), client->GetCountryName(), Sbuffer); Sbuffer = tempStr; if(CGlobalVariable::ip2country->ShowCountryFlag()){ cur_rec.left+=20; POINT point2= {cur_rec.left,cur_rec.top+1}; CGlobalVariable::ip2country->GetFlagImageList()->DrawIndirect(dc, client->GetCountryFlagIndex(), point2, CSize(18,16), CPoint(0,0), ILD_NORMAL); } //EastShare End - added by AndCycle, IP to Country cur_rec.left +=20; dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT); cur_rec.left -=20; //EastShare Start - added by AndCycle, IP to Country if(CGlobalVariable::ip2country->ShowCountryFlag()){ cur_rec.left-=20; } //EastShare End - added by AndCycle, IP to Country break; } case 1:{ Sbuffer = client->GetUploadStateDisplayString(); break; } case 2:{ if(client->credits) Sbuffer = CastItoXBytes(client->credits->GetUploadedTotal(), false, false); else Sbuffer.Empty(); break; } case 3:{ Sbuffer = client->GetDownloadStateDisplayString(); break; } case 4:{ if(client->credits) Sbuffer = CastItoXBytes(client->credits->GetDownloadedTotal(), false, false); else Sbuffer.Empty(); break; } case 5:{ Sbuffer = client->GetClientSoftVer(); if (Sbuffer.IsEmpty()) Sbuffer = GetResString(IDS_UNKNOWN); break; } case 6:{ if(client->socket){ if(client->socket->IsConnected()){ Sbuffer = GetResString(IDS_YES); break; } } Sbuffer = GetResString(IDS_NO); break; } case 7: Sbuffer = md4str(client->GetUserHash()); break; } if( iColumn != 0) dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT); cur_rec.left += GetColumnWidth(iColumn); } } // draw rectangle around selected item(s) if (lpDrawItemStruct->itemState & ODS_SELECTED) { RECT outline_rec = lpDrawItemStruct->rcItem; outline_rec.top--; outline_rec.bottom++; dc.FrameRect(&outline_rec, &CBrush(GetBkColor())); outline_rec.top++; outline_rec.bottom--; outline_rec.left++; outline_rec.right--; if(bCtrlFocused) dc.FrameRect(&outline_rec, &CBrush(m_crFocusLine)); else dc.FrameRect(&outline_rec, &CBrush(m_crNoFocusLine)); } if (m_crWindowTextBk == CLR_NONE) dc.SetBkMode(iOldBkMode); dc.SelectObject(pOldFont); dc.SetTextColor(crOldTextColor); }
void wxStaticText::DoSetLabel(const wxString& label) { m_label = RemoveMnemonics(label); GetPeer()->SetLabel(m_label , GetFont().GetEncoding() ); }
bool wxMenuItem::OnMeasureItem( size_t* pWidth, size_t* pHeight ) { wxMemoryDC vDC; wxString sStr = GetName(); // // If we have a valid accel string, then pad out // the menu string so that the menu and accel string are not // placed on top of each other. wxString accel = GetItemLabel().AfterFirst(wxT('\t')); if (!accel.empty() ) { sStr.Pad(sStr.length()%8); sStr += accel; } vDC.SetFont(GetFont()); vDC.GetTextExtent( sStr ,(wxCoord *)pWidth ,(wxCoord *)pHeight ); if (!accel.empty()) { // // Measure the accelerator string, and add its width to // the total item width, plus 16 (Accelerators are right justified, // with the right edge of the text rectangle 16 pixels left of // the right edge of the menu) // int nAccelWidth; int nAccelHeight; vDC.GetTextExtent( m_strAccel ,&nAccelWidth ,&nAccelHeight ); *pWidth += nAccelWidth; } // // Add space at the end of the menu for the submenu expansion arrow. // This will also allow offsetting the accel string from the right edge // *pWidth = (size_t)(*pWidth + GetDefaultMarginWidth() * 1.5); // // JACS: items still look too tightly packed, so adding 5 pixels. // (*pHeight) += 5; // // Ray Gilbert's changes - Corrects the problem of a BMP // being placed next to text in a menu item, and the BMP does // not match the size expected by the system. This will // resize the space so the BMP will fit. Without this, BMPs // must be no larger or smaller than 16x16. // if (m_bmpChecked.Ok()) { // // Is BMP height larger then text height? // size_t nAdjustedHeight = m_bmpChecked.GetHeight() + wxSystemSettings::GetMetric(wxSYS_EDGE_Y); if (*pHeight < nAdjustedHeight) *pHeight = nAdjustedHeight; // // Does BMP encroach on default check menu position? // size_t nAdjustedWidth = m_bmpChecked.GetWidth() + (wxSystemSettings::GetMetric(wxSYS_EDGE_X) * 2); // // Do we need to widen margin to fit BMP? // if ((size_t)GetMarginWidth() < nAdjustedWidth) SetMarginWidth(nAdjustedWidth); // // Add the size of the bitmap to our total size... // *pWidth += GetMarginWidth(); } // // Add the size of the bitmap to our total size - even if we don't have // a bitmap we leave room for one... // *pWidth += GetMarginWidth(); // // Make sure that this item is at least as // tall as the user's system settings specify // const size_t heightStd = 6; // FIXME: get value from the system if ( *pHeight < heightStd ) *pHeight = heightStd; m_nHeight = *pHeight; // remember height for use in OnDrawItem return true; } // end of wxOwnerDrawn::OnMeasureItem
bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], int majorDim, long style, const wxValidator& val, const wxString& name) { // common initialization if ( !wxStaticBox::Create(parent, id, title, pos, size, style, name) ) return false; // the code elsewhere in this file supposes that either wxRA_SPECIFY_COLS // or wxRA_SPECIFY_ROWS is set, ensure that this is indeed the case if ( !(style & (wxRA_SPECIFY_ROWS | wxRA_SPECIFY_COLS)) ) style |= wxRA_SPECIFY_COLS; #if wxUSE_VALIDATORS SetValidator(val); #else wxUnusedVar(val); #endif // wxUSE_VALIDATORS/!wxUSE_VALIDATORS // We need an extra one to keep track of the 'dummy' item we // create to end the radio group, so it will be destroyed and // it's id will be released. But we want it separate from the // other buttons since the wxSubwindows will operate on it as // well and we just want to ignore it until destroying it. // For instance, we don't want the bounding box of the radio // buttons to include the dummy button m_radioButtons = new wxSubwindows(n); m_radioWidth = new int[n]; m_radioHeight = new int[n]; for ( int i = 0; i < n; i++ ) { m_radioWidth[i] = m_radioHeight[i] = wxDefaultCoord; long styleBtn = BS_AUTORADIOBUTTON | WS_TABSTOP | WS_CHILD | WS_VISIBLE; if ( i == 0 ) styleBtn |= WS_GROUP; wxWindowIDRef subid = NewControlId(); HWND hwndBtn = ::CreateWindow(wxT("BUTTON"), choices[i].t_str(), styleBtn, 0, 0, 0, 0, // will be set in SetSize() GetHwndOf(parent), (HMENU)wxUIntToPtr(subid.GetValue()), wxGetInstance(), NULL); if ( !hwndBtn ) { wxLogLastError(wxT("CreateWindow(radio btn)")); return false; } // Keep track of the subwindow m_radioButtons->Set(i, hwndBtn, subid); SubclassRadioButton((WXHWND)hwndBtn); // Also, make it a subcontrol of this control m_subControls.Add(subid); } // Create a dummy radio control to end the group. m_dummyId = NewControlId(); m_dummyHwnd = (WXHWND)::CreateWindow(wxT("BUTTON"), wxEmptyString, WS_GROUP | BS_AUTORADIOBUTTON | WS_CHILD, 0, 0, 0, 0, GetHwndOf(parent), (HMENU)wxUIntToPtr(m_dummyId.GetValue()), wxGetInstance(), NULL); m_radioButtons->SetFont(GetFont()); SetMajorDim(majorDim == 0 ? n : majorDim, style); // Select the first radio button if we have any buttons at all. if ( n > 0 ) SetSelection(0); SetSize(pos.x, pos.y, size.x, size.y); // Now that we have items determine what is the best size and set it. SetInitialSize(size); // And update all the buttons positions to match it. const wxSize actualSize = GetSize(); PositionAllButtons(pos.x, pos.y, actualSize.x, actualSize.y); // The base wxStaticBox class never accepts focus, but we do because giving // focus to a wxRadioBox actually gives it to one of its buttons, which are // not visible at wx level and hence are not taken into account by the // logic in wxControlContainer code. m_container.EnableSelfFocus(); return true; }
wxSize wxChoice::DoGetBestSize() const { int lbWidth = GetCount() > 0 ? 20 : 100; // some defaults int lbHeight = 20; int wLine; #if TARGET_CARBON SInt32 metric ; GetThemeMetric( kThemeMetricPopupButtonHeight , &metric ); lbHeight = metric ; #endif { #if wxMAC_USE_CORE_GRAPHICS wxClientDC dc(const_cast<wxChoice*>(this)); #else wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetTopLevelWindowRef() ) ) ; if ( m_font.Ok() ) { ::TextFont( m_font.MacGetFontNum() ) ; ::TextSize( m_font.MacGetFontSize() ) ; ::TextFace( m_font.MacGetFontStyle() ) ; } else { ::TextFont( kFontIDMonaco ) ; ::TextSize( 9 ) ; ::TextFace( 0 ) ; } #endif // Find the widest line for(unsigned int i = 0; i < GetCount(); i++) { wxString str(GetString(i)); #if wxMAC_USE_CORE_GRAPHICS wxCoord width, height ; dc.GetTextExtent( str , &width, &height); wLine = width ; #else #if wxUSE_UNICODE Point bounds = { 0, 0 } ; SInt16 baseline ; ::GetThemeTextDimensions( wxMacCFStringHolder( str , GetFont().GetEncoding() ) , kThemeCurrentPortFont, kThemeStateActive, false, &bounds, &baseline ); wLine = bounds.h ; #else wLine = ::TextWidth( str.c_str() , 0 , str.length() ) ; #endif #endif lbWidth = wxMax( lbWidth, wLine ) ; } // Add room for the popup arrow lbWidth += 2 * lbHeight ; #if wxMAC_USE_CORE_GRAPHICS wxCoord width, height ; dc.GetTextExtent( wxT("X"), &width, &height); int cx = width ; lbHeight += 4; #else // And just a bit more int cx = ::TextWidth( "X" , 0 , 1 ) ; #endif lbWidth += cx ; } return wxSize( lbWidth, lbHeight ); }
frmMain::frmMain(const wxString &title) : pgFrame((wxFrame *)NULL, title) { msgLevel = 0; lastPluginUtility = NULL; pluginUtilityCount = 0; m_refreshing = false; dlgName = wxT("frmMain"); SetMinSize(wxSize(600, 450)); RestorePosition(50, 50, 750, 550, 600, 450); wxWindowBase::SetFont(settings->GetSystemFont()); { wxLogInfo(wxT("Using fontmetrics %d/%d, %d Point"), GetCharWidth(), GetCharHeight(), GetFont().GetPointSize()); wxLogInfo(wxT("Native Description '%s'"), GetFont().GetNativeFontInfoDesc().c_str()); wxWindowDC dc(this); dc.SetFont(GetFont()); wxCoord w, h, d, e; dc.GetTextExtent(wxT("M"), &w, &h, &d, &e); wxLogInfo(wxT("Draw size of 'M': w=%d, h=%d, descent %d, external lead %d."), w, h, d, e); dc.GetTextExtent(wxT("g"), &w, &h, &d, &e); wxLogInfo(wxT("Draw size of 'g': w=%d, h=%d, descent %d, external lead %d."), w, h, d, e); dc.GetTextExtent(wxT("Mg"), &w, &h, &d, &e); wxLogInfo(wxT("Draw size of 'Mg': w=%d, h=%d, descent %d, external lead %d."), w, h, d, e); } // Current database denyCollapseItem = wxTreeItemId(); currentObject = 0; appearanceFactory->SetIcons(this); // notify wxAUI which frame to use manager.SetManagedWindow(this); manager.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_TRANSPARENT_DRAG | wxAUI_MGR_ALLOW_ACTIVE_PANE); // wxGTK needs this deferred pgaFactory::RealizeImages(); CreateMenus(); // Setup the object browser browser = new ctlTree(this, CTL_BROWSER, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS | wxSIMPLE_BORDER); browser->SetImageList(imageList); // Setup the listview listViews = new ctlAuiNotebook(this, CTL_NOTEBOOK, wxDefaultPosition, wxDefaultSize, wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_MOVE | wxAUI_NB_TAB_EXTERNAL_MOVE | wxAUI_NB_SCROLL_BUTTONS | wxAUI_NB_WINDOWLIST_BUTTON); // Switch to the generic list control. Native doesn't play well with // multi-row select on Mac. #ifdef __WXMAC__ wxSystemOptions::SetOption(wxT("mac.listctrl.always_use_generic"), true); #endif properties = new ctlListView(listViews, CTL_PROPVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER); statistics = new ctlListView(listViews, CTL_STATVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER); dependencies = new ctlListView(listViews, CTL_DEPVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER); dependents = new ctlListView(listViews, CTL_REFVIEW, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER); // Switch back to the native list control. #ifdef __WXMAC__ wxSystemOptions::SetOption(wxT("mac.listctrl.always_use_generic"), false); #endif listViews->AddPage(properties, _("Properties")); // NBP_PROPERTIES listViews->AddPage(statistics, _("Statistics")); // NBP_STATISTICS listViews->AddPage(dependencies, _("Dependencies")); // NBP_DEPENDENCIES listViews->AddPage(dependents, _("Dependents")); // NBP_DEPENDENTS properties->SetImageList(imageList, wxIMAGE_LIST_SMALL); statistics->SetImageList(imageList, wxIMAGE_LIST_SMALL); dependencies->SetImageList(imageList, wxIMAGE_LIST_SMALL); dependents->SetImageList(imageList, wxIMAGE_LIST_SMALL); wxColour background; background = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE); statistics->SetBackgroundColour(background); dependencies->SetBackgroundColour(background); dependents->SetBackgroundColour(background); // Setup the SQL pane sqlPane = new ctlSQLBox(this, CTL_SQLPANE, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxSIMPLE_BORDER | wxTE_READONLY | wxTE_RICH2); sqlPane->SetBackgroundColour(background); // Setup menus pgaFactory::RegisterMenu(this, wxCommandEventHandler(frmMain::OnNew)); menuFactories->RegisterMenu(this, wxCommandEventHandler(frmMain::OnAction)); menuFactories->CheckMenu(0, menuBar, toolBar); // Kickstart wxAUI manager.AddPane(browser, wxAuiPaneInfo().Name(wxT("objectBrowser")).Caption(_("Object browser")).Left().MinSize(wxSize(100, 200)).BestSize(wxSize(200, 450))); manager.AddPane(listViews, wxAuiPaneInfo().Name(wxT("listViews")).Caption(_("Info pane")).Center().CaptionVisible(false).CloseButton(false).MinSize(wxSize(200, 100)).BestSize(wxSize(400, 200))); manager.AddPane(sqlPane, wxAuiPaneInfo().Name(wxT("sqlPane")).Caption(_("SQL pane")).Bottom().MinSize(wxSize(200, 100)).BestSize(wxSize(400, 200))); manager.AddPane(toolBar, wxAuiPaneInfo().Name(wxT("toolBar")).Caption(_("Tool bar")).ToolbarPane().Top().LeftDockable(false).RightDockable(false)); // Now load the layout wxString perspective; settings->Read(wxT("frmMain/Perspective-") + wxString(FRMMAIN_PERSPECTIVE_VER), &perspective, FRMMAIN_DEFAULT_PERSPECTIVE); manager.LoadPerspective(perspective, true); // and reset the captions for the current language manager.GetPane(wxT("objectBrowser")).Caption(_("Object browser")); manager.GetPane(wxT("listViews")).Caption(_("Info pane")); manager.GetPane(wxT("sqlPane")).Caption(_("SQL pane")); manager.GetPane(wxT("toolBar")).Caption(_("Tool bar")); // Sync the View menu options viewMenu->Check(MNU_SQLPANE, manager.GetPane(wxT("sqlPane")).IsShown()); viewMenu->Check(MNU_OBJECTBROWSER, manager.GetPane(wxT("objectBrowser")).IsShown()); viewMenu->Check(MNU_TOOLBAR, manager.GetPane(wxT("toolBar")).IsShown()); ResetLists(); // tell the manager to "commit" all the changes just made manager.Update(); // Add the root node serversObj = new pgServerCollection(serverFactory.GetCollectionFactory()); wxTreeItemId root = browser->AddRoot(_("Server Groups"), serversObj->GetIconId(), -1, serversObj); // Work around a bug in the generic tree control in wxWidgets, // Per http://trac.wxwidgets.org/ticket/10085 browser->SetItemText(root, _("Server Groups")); // Load servers RetrieveServers(); browser->Expand(root); browser->SortChildren(root); }
BOOL CTaskDialog::OnInitDialog(HWND /* hWnd */, LPARAM /* lParam */) { // update dialog font SetFont(hFont_, FALSE); // calculate various dimensions { RECT rect = { 0, 0, _cx_margin, _cy_margin }; MapDialogRect(&rect); cx_margin = rect.right; cy_margin = rect.bottom; } { RECT rect = { 0, 0, _cx_spacing, _cy_spacing }; MapDialogRect(&rect); cx_spacing = rect.right; cy_spacing = rect.bottom; } { RECT rect = { 0, 0, _cx_smspacing, _cy_smspacing }; MapDialogRect(&rect); cx_smspacing = rect.right; cy_smspacing = rect.bottom; } { RECT rect = { 0, 0, _cx_button, _cy_button }; MapDialogRect(&rect); cx_button = rect.right; cy_button = rect.bottom; } { RECT rect = { 0, 0, _cx_button_margin, 0 }; MapDialogRect(&rect); cx_button_margin = rect.right; } { RECT rect = { 0, 0, 0, _cy_progress_bar }; MapDialogRect(&rect); cy_progress_bar = rect.bottom; } // create useful GDI objects hFont_ = GetFont(); hFontInstruction_ = CreateSystemFont(16, FW_BOLD); hFontContent_ = CreateSystemFont(12); hBrushWhite_ = ::CreateSolidBrush(COLOR_WHITE); // layout controls LayoutWindow(); // callback Callback(TDN_CREATED); return FALSE; }
/* * AdminValueDialogProc: Dialog procedure for editing a property's value. * lParam of INITDIALOG message is index of property in object list box. */ BOOL CALLBACK AdminValueDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static int index; int type, i; char *value, line[MAX_PROPERTYLEN], *str, property[MAX_PROPERTYLEN]; static HWND hEdit; switch (message) { case WM_INITDIALOG: index = lParam; hEdit = GetDlgItem(hDlg, IDC_EDITVALUE); Edit_LimitText(hEdit, MAX_PROPERTYLEN - 1); ListBox_GetText(hObjectList, index, line); value = AdminPropertyValue(line, &type); if (value != NULL) { // Initialize dialog with current value for (i = 0; type_table[i].word != NULL; i++) if (type == type_table[i].type) CheckDlgButton(hDlg, type_table[i].control, 1); Edit_SetText(hEdit, value); Edit_SetSel(hEdit, 0, -1); strcpy(property, AdminNthToken(line, 1)); str = strchr(property, ' '); if (str != NULL) *str = 0; SetDlgItemText(hDlg, IDC_PROPERTY, property); } sprintf(line, "%d", current_obj); SetDlgItemText(hDlg, IDC_OBJECTNUM, line); CenterWindow(hDlg, GetParent(hDlg)); SetWindowFont(hEdit, GetFont(FONT_INPUT), TRUE); SetFocus(hEdit); return FALSE; case WM_COMMAND: switch (GET_WM_COMMAND_ID(wParam, lParam)) { case IDOK: // Get type and value str = NULL; for (i = 0; type_table[i].word != NULL; i++) if (IsDlgButtonChecked(hDlg, type_table[i].control)) { str = type_table[i].word; break; } if (str != NULL) { Edit_GetText(hEdit, line, MAX_PROPERTYLEN); GetDlgItemText(hDlg, IDC_PROPERTY, property, MAX_PROPERTYLEN); // Special case for NIL: value must be zero if (type_table[i].type == TAG_NIL) strcpy(line, "0"); sprintf(command, "set object %d %s %s %s", current_obj, property, str, line); SendMessage(hAdminDlg, BK_SENDCMD, 0, (LPARAM) command); // Change value in object list box sprintf(command, "%s = %s %s", property, str, line); WindowBeginUpdate(hObjectList); ListBox_DeleteString(hObjectList, index); ListBox_InsertString(hObjectList, index, command); WindowEndUpdate(hObjectList); } EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; } break; } return FALSE; }
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT ) style |= wxBORDER_SIMPLE; SetWindowStyle(style); WXDWORD exStyle = 0; WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ; wxSize sizeText(size), sizeBtn(size); sizeBtn.x = GetBestSpinnerSize(IsVertical(style)).x / 2; if ( sizeText.x == wxDefaultCoord ) { // DEFAULT_ITEM_WIDTH is the default width for the text control sizeText.x = DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN + sizeBtn.x; } sizeText.x -= sizeBtn.x + MARGIN_BETWEEN; if ( sizeText.x <= 0 ) { wxLogDebug(_T("not enough space for wxSpinCtrl!")); } wxPoint posBtn(pos); posBtn.x += sizeText.x + MARGIN_BETWEEN; // we need to turn '\n's into "\r\n"s for the multiline controls wxString valueWin; if ( m_windowStyle & wxTE_MULTILINE ) { valueWin = wxTextFile::Translate(value, wxTextFileType_Dos); } else // single line { valueWin = value; } // we must create the list control before the spin button for the purpose // of the dialog navigation: if there is a static text just before the spin // control, activating it by Alt-letter should give focus to the text // control, not the spin and the dialog navigation code will give focus to // the next control (at Windows level), not the one after it // create the text window m_hwndBuddy = (WXHWND)::CreateWindowEx ( exStyle, // sunken border _T("EDIT"), // window class valueWin, // no window title msStyle, // style (will be shown later) pos.x, pos.y, // position 0, 0, // size (will be set later) GetHwndOf(parent), // parent (HMENU)-1, // control id wxGetInstance(), // app instance NULL // unused client data ); if ( !m_hwndBuddy ) { wxLogLastError(wxT("CreateWindow(buddy text window)")); return false; } // initialize wxControl if ( !CreateControl(parent, id, posBtn, sizeBtn, style, validator, name) ) return false; // now create the real HWND WXDWORD spiner_style = WS_VISIBLE | UDS_ALIGNRIGHT | UDS_EXPANDABLE | UDS_NOSCROLL; if ( !IsVertical(style) ) spiner_style |= UDS_HORZ; if ( style & wxSP_WRAP ) spiner_style |= UDS_WRAP; if ( !MSWCreateControl(UPDOWN_CLASS, spiner_style, posBtn, sizeBtn, _T(""), 0) ) return false; // subclass the text ctrl to be able to intercept some events wxSetWindowUserData(GetBuddyHwnd(), this); m_wndProcBuddy = (WXFARPROC)wxSetWindowProc(GetBuddyHwnd(), wxBuddyTextCtrlWndProc); // set up fonts and colours (This is nomally done in MSWCreateControl) InheritAttributes(); if (!m_hasFont) SetFont(GetDefaultAttributes().font); // set the size of the text window - can do it only now, because we // couldn't call DoGetBestSize() before as font wasn't set if ( sizeText.y <= 0 ) { int cx, cy; wxGetCharSize(GetHWND(), &cx, &cy, GetFont()); sizeText.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy); } SetBestSize(size); (void)::ShowWindow(GetBuddyHwnd(), SW_SHOW); // associate the list window with the spin button (void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)GetBuddyHwnd(), 0); // do it after finishing with m_hwndBuddy creation to avoid generating // initial wxEVT_COMMAND_TEXT_UPDATED message ms_allTextSpins.Add(this); return true; }
void CIconListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { // TODO: Add your code to draw the specified item CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); if (((LONG)(lpDrawItemStruct->itemID) >= 0) && (lpDrawItemStruct->itemAction & (ODA_DRAWENTIRE | ODA_SELECT))){ CRect rcItem(lpDrawItemStruct->rcItem); // To draw the focus rect. CRect rClient(rcItem.left,rcItem.top,rcItem.right,rcItem.bottom); // Rect to highlight the Item CRect rText(rClient); // Rect To display the Text CPoint Pt( rClient.left , rClient.top ); // Point To draw the Image // if the Image list exists for the list box // adjust the Rect sizes to accomodate the Image for each item. int cyItem = GetItemHeight(lpDrawItemStruct->itemID); if (m_cyText == 0) { CClientDC dc(this); CFont* pOldFont = dc.SelectObject(GetFont()); TEXTMETRIC tm; VERIFY (dc.GetTextMetrics ( &tm )); dc.SelectObject(pOldFont); m_cyText = tm.tmHeight; } if(m_pImageList) { rClient.left += 32; rText.left += 32; rText.top += max(0, (cyItem - m_cyText) / 2); } else { rText.top += max(0, (cyItem - m_cyText) / 2); } COLORREF crText; CString strText; // Image information in the item data. int iImg = (int)lpDrawItemStruct->itemData; // If item selected, draw the highlight rectangle. // Or if item deselected, draw the rectangle using the window color. if ((lpDrawItemStruct->itemState & ODS_SELECTED) && (lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE))) { CBrush br(::GetSysColor(COLOR_HIGHLIGHT)); //CRect r(rcItem.left+10,rcItem.top,rcItem.right,rcItem.bottom); pDC->FillRect(&rClient, &br); } else if (!(lpDrawItemStruct->itemState & ODS_SELECTED) && (lpDrawItemStruct->itemAction & ODA_SELECT)) { CBrush br(::GetSysColor(COLOR_WINDOW)); //CRect r(rcItem.left+10,rcItem.top,rcItem.right,rcItem.bottom); pDC->FillRect(&rClient, &br); } // If the item has focus, draw the focus rect. // If the item does not have focus, erase the focus rect. if ((lpDrawItemStruct->itemAction & ODA_FOCUS) && (lpDrawItemStruct->itemState & ODS_FOCUS)) { pDC->DrawFocusRect(&rcItem); } else if ((lpDrawItemStruct->itemAction & ODA_FOCUS) && !(lpDrawItemStruct->itemState & ODS_FOCUS)) { pDC->DrawFocusRect(&rcItem); } // To draw the Text set the background mode to Transparent. //lpDrawItemStruct->CtlID if (lpDrawItemStruct->itemState & ODS_SELECTED) crText = pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT)); else if (lpDrawItemStruct->itemState & ODS_DISABLED) crText = pDC->SetTextColor(::GetSysColor(COLOR_GRAYTEXT)); else crText = pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT)); // Get the item text. GetText(lpDrawItemStruct->itemID, strText); int iBkMode = pDC->SetBkMode(TRANSPARENT); // Setup the text format. UINT nFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER; if (GetStyle() & LBS_USETABSTOPS) nFormat |= DT_EXPANDTABS; // if the ImageList is Existing and there is an associated Image // for the Item, draw the Image. if(m_pImageList && (iImg != -1 )){ m_pImageList->Draw(pDC,iImg,Pt,ILD_NORMAL); CPen myPen; myPen.CreatePen(PS_SOLID,2,RGB(255,0,0)); pDC->SetROP2(R2_NOTXORPEN); CPen* oldPen=pDC->SelectObject(&myPen); pDC->Rectangle(Pt.x,Pt.y,Pt.x+32,Pt.y+32); pDC->SelectObject(oldPen); } //Draw the Text pDC->DrawText(strText, -1, &rText, nFormat | DT_CALCRECT); pDC->DrawText(strText, -1, &rText, nFormat); pDC->SetTextColor(crText); pDC->SetBkMode(iBkMode); } }
unsigned LargeTextWindow::GetVisibleRows() const { return GetHeight() / GetFont().GetHeight(); }
void Button::Paint( GC& gc, const crect& paintRect ) { unsigned colorBg = UiGetColor( uiBackground, 0, 0, 0x808080 ); //GetColor(0); crect cr = this->ClientRect(); crect rect = cr; DrawBorder( gc, rect, ColorTone( colorBg, +20 ) ); rect.Dec(); DrawBorder( gc, rect, ColorTone( colorBg, -200 ) ); rect.Dec(); gc.SetFillColor( colorBg ); gc.FillRect( rect ); if ( pressed ) { #if USE_3D_BUTTONS Draw3DButtonW2( gc, rect, colorBg, false ); #endif rect.Dec(); rect.Dec(); } else { #if USE_3D_BUTTONS Draw3DButtonW2( gc, rect, colorBg, true ); #endif rect.Dec(); if ( InFocus() ) { DrawBorder( gc, rect, /*GetColor(IC_FOCUS_MARK)*/ UiGetColor( uiFocusFrameColor, 0, 0, 0 ) ); } #if USE_3D_BUTTONS rect.Dec(); #endif } gc.SetTextColor( /*GetColor(IsEnabled() ? IC_TEXT : IC_GRAY_TEXT)*/ UiGetColor( uiColor, 0, 0, 0 ) ); gc.Set( GetFont() ); cpoint tsize = text.GetTextExtents(gc); /* int l = tsize.x + (icon.ptr() ? icon->Width() + ICONX_RIGHTSPACE : 0); int w = rect.Width() - LEFTSPACE - RIGHTSPACE; if (icon.ptr()) w-=ICONX_RIGHTSPACE; //int x = rect.left + LEFTSPACE + (w > l ? (w - l)/2 : 0) +(pressed?2:0); int x = rect.left + LEFTSPACE + (w-l)/2 +(pressed?2:0); */ int l = tsize.x + ( icon.ptr() ? icon->Width() + ICONX_RIGHTSPACE : 0 ); int w = rect.Width(); int x = rect.left + ( w > l ? ( w - l ) / 2 : 0 ) + ( pressed ? 2 : 0 ); if ( icon.ptr() ) { gc.DrawIcon( x, rect.top + ( rect.Height() - icon->Height() ) / 2 + ( pressed ? 2 : 0 ), icon.ptr() ); x += icon->Width() + ICONX_RIGHTSPACE; } gc.SetClipRgn( &rect ); text.DrawItem(gc, x, rect.top + (rect.Height() - tsize.y) / 2 + (pressed ? 2 : 0), UiGetColor(uiColor, 0, 0, 0), UiGetColor(uiHotkeyColor, 0, 0, 0)); }
bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name ) { m_needParent = true; m_acceptsFocus = true; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxTextCtrl creation failed") ); return false; } m_vScrollbarVisible = false; bool multi_line = (style & wxTE_MULTILINE) != 0; if (multi_line) { // create our control ... m_text = gtk_text_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); // ... and put into the upper left hand corner of the table bool bHasHScrollbar = false; m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); gtk_table_attach( GTK_TABLE(m_widget), m_text, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK), (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK), 0, 0); // always wrap words gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE ); // finally, put the vertical scrollbar in the upper right corner m_vScrollbar = gtk_vscrollbar_new( GTK_TEXT(m_text)->vadj ); GTK_WIDGET_UNSET_FLAGS( m_vScrollbar, GTK_CAN_FOCUS ); gtk_table_attach(GTK_TABLE(m_widget), m_vScrollbar, 1, 2, 0, 1, GTK_FILL, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), 0, 0); } else { // a single-line text control: no need for scrollbars m_widget = m_text = gtk_entry_new(); } m_parent->DoAddChild( this ); m_focusWidget = m_text; PostCreation(size); if (multi_line) gtk_widget_show(m_text); if (multi_line) { gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed", (GtkSignalFunc) gtk_scrollbar_changed_callback, (gpointer) this ); // only initialize gs_gtk_text_draw once, starting from the next the // klass::draw will already be wxgtk_text_draw if ( !gs_gtk_text_draw ) { GtkDrawCallback& draw = GTK_WIDGET_CLASS(GTK_OBJECT(m_text)->klass)->draw; gs_gtk_text_draw = draw; draw = wxgtk_text_draw; } } if (!value.empty()) { #if !GTK_CHECK_VERSION(1, 2, 0) // if we don't realize it, GTK 1.0.6 dies with a SIGSEGV in // gtk_editable_insert_text() gtk_widget_realize(m_text); #endif // GTK 1.0 gint tmp = 0; #if wxUSE_UNICODE wxWX2MBbuf val = value.mbc_str(); gtk_editable_insert_text( GTK_EDITABLE(m_text), val, strlen(val), &tmp ); #else gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.length(), &tmp ); #endif if (multi_line) { // Bring editable's cursor uptodate. Bug in GTK. SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) )); } } if (style & wxTE_PASSWORD) { if (!multi_line) gtk_entry_set_visibility( GTK_ENTRY(m_text), FALSE ); } if (style & wxTE_READONLY) { if (!multi_line) gtk_entry_set_editable( GTK_ENTRY(m_text), FALSE ); } else { if (multi_line) gtk_text_set_editable( GTK_TEXT(m_text), 1 ); } // We want to be notified about text changes. gtk_signal_connect( GTK_OBJECT(m_text), "changed", GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); m_cursor = wxCursor( wxCURSOR_IBEAM ); wxTextAttr attrDef(GetForegroundColour(), GetBackgroundColour(), GetFont()); SetDefaultStyle( attrDef ); return true; }
// // Draw a line // // This is called by the listbox when it needs to redraw the view. // void KeyView::OnDrawItem(wxDC & dc, const wxRect & rect, size_t line) const { const KeyNode *node = mLines[line]; wxString label = node->label; // Make sure the DC has a valid font dc.SetFont(GetFont()); // Set the text color based on selection and focus if (IsSelected(line) && FindFocus() == this) { dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT)); } else { dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT)); } // Tree views get bitmaps if (mViewType == ViewByTree) { // Adjust left edge to account for scrolling wxCoord x = rect.x - mScrollX; if (node->iscat) { // Draw categories bitmap at left edge dc.DrawBitmap(node->isopen ? *mOpen : *mClosed, x, rect.y); } else if (node->ispfx) { // Draw prefix bitmap to the right of the category bitmap dc.DrawBitmap(node->isopen ? *mOpen : *mClosed, x + KV_BITMAP_SIZE, rect.y); } // Indent text x += KV_LEFT_MARGIN; // Draw the command and key columns dc.DrawText(label, x + node->depth * KV_BITMAP_SIZE, rect.y); dc.DrawText(node->key, x + mCommandWidth + KV_COLUMN_SPACER, rect.y); } else { // Adjust left edge by margin and account for scrolling wxCoord x = rect.x + KV_LEFT_MARGIN - mScrollX; // Prepend prefix if available if (!node->prefix.IsEmpty()) { label = node->prefix + wxT(" - ") + label; } // Swap the columns based on view type if(mViewType == ViewByName) { // Draw command column and then key column dc.DrawText(label, x, rect.y); dc.DrawText(node->key, x + mCommandWidth + KV_COLUMN_SPACER, rect.y); } else if(mViewType == ViewByKey) { // Draw key columnd and then command column dc.DrawText(node->key, x, rect.y); dc.DrawText(label, x + mKeyWidth + KV_COLUMN_SPACER, rect.y); } } return; }
// CCheckList message handlers void CCheckList::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here // Do not call CListCtrl::OnPaint() for painting messages //创建需要的画笔 CFont* Font = GetFont( ); CFont* OldFont = dc.SelectObject( Font ); CPen PenTiny,PenThick; PenTiny.CreatePen( PS_SOLID, 1, RGB( 0xc0, 0xc0, 0xc0 ) ); PenThick.CreatePen( PS_SOLID, 1, RGB( 0, 0, 0 ) ); CPen* OldPen = dc.SelectObject( &PenThick ); //获得客户区大小 CRect ClientRect; GetClientRect( &ClientRect ); int Vert = ClientRect.bottom - ClientRect.top; int ItemCount = GetItemCount( ); if( ItemCount == 0 ) return; CRect ItemRect; GetItemRect( 0, &ItemRect, LVIR_BOUNDS ); int Pos = GetScrollPos( SB_VERT ); int End = min( Pos + Vert/( ItemRect.bottom - ItemRect.top ), ItemCount ); //跟踪每一行绘制其中文字和内容 for( int i=Pos; i<End; i++ ) { GetItemRect( i, &ItemRect, LVIR_BOUNDS ); int sx = ItemRect.left + 3; LVCOLUMN Lv; Lv.mask = LVCF_WIDTH ; int r = GetColumn( 0, &Lv ); if( !r ) break; RECT DrawRect = { sx, ItemRect.top, sx + Lv.cx - 4 , ItemRect.bottom }; dc.SetBkColor( RGB( 255, 255, 255 ) ); dc.DrawText( GetItemText( i, 0 ), &DrawRect, DT_LEFT ); sx += Lv.cx; dc.SelectObject( &PenThick ); for( int j = 1; ; j++ ) { LVCOLUMN Lv; Lv.mask = LVCF_WIDTH; int r = GetColumn( j, &Lv ); if( !r ) break; //边框绘制 int EndCheck = sx + Lv.cx - 4; if( Lv.cx >= ItemRect.Height() ) { EndCheck = sx + ItemRect.Height() - 4; dc.MoveTo( EndCheck, ItemRect.bottom - 3 ); dc.LineTo( EndCheck, ItemRect.top + 1 ); } if( EndCheck > sx ) { dc.MoveTo( EndCheck, ItemRect.top + 1 ); dc.LineTo( sx, ItemRect.top + 1 ); dc.LineTo( sx, ItemRect.bottom - 3 ); dc.LineTo( EndCheck, ItemRect.bottom - 3 ); } //选中绘制 BOOL Draw = FALSE; ListNode* Node = (ListNode*)GetItemData( i ); if( j == 1 && Node->m_ExpType == enumPT_VERTEXANI ) Draw = TRUE; if( j == 2 && Node->m_ExpType == enumPT_SKELETALANI ) Draw = TRUE; if( j == 3 && Node->m_ExpType == enumPT_NONEANI ) Draw = TRUE; if( EndCheck - 1 > sx + 2 && Draw ) dc.FillSolidRect( &CRect( sx + 2, ItemRect.top + 3, EndCheck - 1, ItemRect.bottom - 4 ), RGB( 128, 128, 128 ) ); sx += Lv.cx; } dc.SelectObject( &PenTiny ); dc.MoveTo( ClientRect.left, ItemRect.bottom-1 ); dc.LineTo( ClientRect.right, ItemRect.bottom-1 ); } dc.SelectObject( OldFont ); dc.SelectObject( OldPen ); }
void COwnerDrawnListControl::DrawItem(LPDRAWITEMSTRUCT pdis) { COwnerDrawnListItem *item = (COwnerDrawnListItem *)(pdis->itemData); CDC *pdc = CDC::FromHandle(pdis->hDC); CRect rcItem(pdis->rcItem); if(m_showGrid) { rcItem.bottom--; rcItem.right--; } CDC dcmem; dcmem.CreateCompatibleDC(pdc); CBitmap bm; bm.CreateCompatibleBitmap(pdc, rcItem.Width(), rcItem.Height()); CSelectObject sobm(&dcmem, &bm); dcmem.FillSolidRect(rcItem - rcItem.TopLeft(), GetItemBackgroundColor(pdis->itemID)); bool drawFocus = (pdis->itemState & ODS_FOCUS) != 0 && HasFocus() && IsFullRowSelection(); CArray<int, int> order; order.SetSize(GetHeaderCtrl()->GetItemCount()); GetHeaderCtrl()->GetOrderArray(order.GetData(), int(order.GetSize())); CRect rcFocus = rcItem; rcFocus.DeflateRect(0, LABEL_Y_MARGIN - 1); for(int i = 0; i < order.GetSize(); i++) { int subitem = order[i]; CRect rc = GetWholeSubitemRect(pdis->itemID, subitem); CRect rcDraw = rc - rcItem.TopLeft(); int focusLeft = rcDraw.left; if(!item->DrawSubitem(subitem, &dcmem, rcDraw, pdis->itemState, NULL, &focusLeft)) { item->DrawSelection(this, &dcmem, rcDraw, pdis->itemState); CRect rcText = rcDraw; rcText.DeflateRect(TEXT_X_MARGIN, 0); CSetBkMode bk(&dcmem, TRANSPARENT); CSelectObject sofont(&dcmem, GetFont()); CString s = item->GetText(subitem); UINT align = IsColumnRightAligned(subitem) ? DT_RIGHT : DT_LEFT; // Get the correct color in case of compressed or encrypted items COLORREF textColor = item->GetItemTextColor(); // Except if the item is selected - in this case just use standard colors if((pdis->itemState & ODS_SELECTED) && (HasFocus() || IsShowSelectionAlways()) && (IsFullRowSelection())) { textColor = GetItemSelectionTextColor(pdis->itemID); } // Set the text color CSetTextColor tc(&dcmem, textColor); // Draw the (sub)item text dcmem.DrawText(s, rcText, DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS | DT_NOPREFIX | align); // Test: dcmem.FillSolidRect(rcDraw, 0); } if(focusLeft > rcDraw.left) { if(drawFocus && i > 0) { pdc->DrawFocusRect(rcFocus); } rcFocus.left = focusLeft; } rcFocus.right = rcDraw.right; pdc->BitBlt(rcItem.left + rcDraw.left, rcItem.top + rcDraw.top, rcDraw.Width(), rcDraw.Height(), &dcmem, rcDraw.left, rcDraw.top, SRCCOPY); } if(drawFocus) { pdc->DrawFocusRect(rcFocus); } }
void wxRadioBox::PositionAllButtons(int x, int y, int width, int WXUNUSED(height)) { wxSize maxSize = GetMaxButtonSize(); int maxWidth = maxSize.x, maxHeight = maxSize.y; // Now position all the buttons: the current button will be put at // wxPoint(x_offset, y_offset) and the new row/column will start at // startX/startY. The size of all buttons will be the same wxSize(maxWidth, // maxHeight) except for the buttons in the last column which should extend // to the right border of radiobox and thus can be wider than this. // Also, remember that wxRA_SPECIFY_COLS means that we arrange buttons in // left to right order and GetMajorDim() is the number of columns while // wxRA_SPECIFY_ROWS means that the buttons are arranged top to bottom and // GetMajorDim() is the number of rows. int cx1, cy1; wxGetCharSize(m_hWnd, &cx1, &cy1, GetFont()); int x_offset = x + cx1; int y_offset = y + cy1; // Add extra space under the label, if it exists. if (!wxControl::GetLabel().empty()) y_offset += cy1/2; int startX = x_offset; int startY = y_offset; const unsigned int count = GetCount(); for (unsigned int i = 0; i < count; i++) { // the last button in the row may be wider than the other ones as the // radiobox may be wider than the sum of the button widths (as it // happens, for example, when the radiobox label is very long) bool isLastInTheRow; if ( m_windowStyle & wxRA_SPECIFY_COLS ) { // item is the last in its row if it is a multiple of the number of // columns or if it is just the last item unsigned int n = i + 1; isLastInTheRow = ((n % GetMajorDim()) == 0) || (n == count); } else // wxRA_SPECIFY_ROWS { // item is the last in the row if it is in the last columns isLastInTheRow = i >= (count/GetMajorDim())*GetMajorDim(); } // is this the start of new row/column? if ( i && (i % GetMajorDim() == 0) ) { if ( m_windowStyle & wxRA_SPECIFY_ROWS ) { // start of new column y_offset = startY; x_offset += maxWidth + cx1; } else // start of new row { x_offset = startX; y_offset += maxHeight; if (m_radioWidth[0]>0) y_offset += cy1/2; } } int widthBtn; if ( isLastInTheRow ) { // make the button go to the end of radio box widthBtn = startX + width - x_offset - 2*cx1; if ( widthBtn < maxWidth ) widthBtn = maxWidth; } else { // normal button, always of the same size widthBtn = maxWidth; } // make all buttons of the same, maximal size - like this they cover // the radiobox entirely and the radiobox tooltips are always shown // (otherwise they are not when the mouse pointer is in the radiobox // part not belonging to any radiobutton) DoMoveSibling((*m_radioButtons)[i], x_offset, y_offset, widthBtn, maxHeight); // where do we put the next button? if ( m_windowStyle & wxRA_SPECIFY_ROWS ) { // below this one y_offset += maxHeight; if (m_radioWidth[0]>0) y_offset += cy1/2; } else { // to the right of this one x_offset += widthBtn + cx1; } } }
void CLogListBox::Init() { NormalFont = GetFont(); UnderlineFont = MakeFontUnderLine(NormalFont); BoldFont = MakeFontBold(NormalFont); }
void BStatusBar::Draw(BRect updateRect) { rgb_color backgroundColor = LowColor(); font_height fontHeight; GetFontHeight(&fontHeight); BRect barFrame = _BarFrame(&fontHeight); BRect outerFrame = barFrame.InsetByCopy(-2, -2); BRegion background(updateRect); background.Exclude(outerFrame); FillRegion(&background, B_SOLID_LOW); // Draw labels/texts BRect rect = outerFrame; rect.top = 0; rect.bottom = outerFrame.top - 1; if (updateRect.Intersects(rect)) { // update labels BString leftText; leftText << fLabel << fText; BString rightText; rightText << fTrailingText << fTrailingLabel; float baseLine = ceilf(fontHeight.ascent) + 1; fTextDivider = rect.right; BFont font; GetFont(&font); if (rightText.Length()) { font.TruncateString(&rightText, B_TRUNCATE_BEGINNING, rect.Width()); fTextDivider -= StringWidth(rightText.String()); } if (leftText.Length()) { float width = max_c(0.0, fTextDivider - rect.left); font.TruncateString(&leftText, B_TRUNCATE_END, width); } SetHighColor(ui_color(B_CONTROL_TEXT_COLOR)); if (leftText.Length()) DrawString(leftText.String(), BPoint(rect.left, baseLine)); if (rightText.Length()) DrawString(rightText.String(), BPoint(fTextDivider, baseLine)); } // Draw bar if (!updateRect.Intersects(outerFrame)) return; rect = outerFrame; if (be_control_look != NULL) { be_control_look->DrawStatusBar(this, rect, updateRect, backgroundColor, fBarColor, _BarPosition(barFrame)); return; } // First bevel SetHighColor(tint_color(ui_color ( B_PANEL_BACKGROUND_COLOR ), B_DARKEN_1_TINT)); StrokeLine(rect.LeftBottom(), rect.LeftTop()); StrokeLine(rect.RightTop()); SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_2_TINT)); StrokeLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom()); StrokeLine(BPoint(rect.right, rect.top + 1)); rect.InsetBy(1, 1); // Second bevel SetHighColor(tint_color(ui_color ( B_PANEL_BACKGROUND_COLOR ), B_DARKEN_4_TINT)); StrokeLine(rect.LeftBottom(), rect.LeftTop()); StrokeLine(rect.RightTop()); SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); StrokeLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom()); StrokeLine(BPoint(rect.right, rect.top + 1)); rect = barFrame; rect.right = _BarPosition(barFrame); // draw bar itself if (rect.right >= rect.left) { // Bevel SetHighColor(tint_color(fBarColor, B_LIGHTEN_2_TINT)); StrokeLine(rect.LeftBottom(), rect.LeftTop()); StrokeLine(rect.RightTop()); SetHighColor(tint_color(fBarColor, B_DARKEN_2_TINT)); StrokeLine(BPoint(rect.left + 1, rect.bottom), rect.RightBottom()); StrokeLine(BPoint(rect.right, rect.top + 1)); // filling SetHighColor(fBarColor); FillRect(rect.InsetByCopy(1, 1)); } if (rect.right < barFrame.right) { // empty space rect.left = rect.right + 1; rect.right = barFrame.right; SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_MAX_TINT)); FillRect(rect); } }
wxFont wxBannerWindow::GetTitleFont() const { wxFont font = GetFont(); font.MakeBold().MakeLarger(); return font; }
void CProgressCtrlX::DrawText(const CDrawInfo& info, const CRect &rcMax, const CRect &rcBar) { if(!(info.dwStyle&PBS_TEXTMASK)) return; BOOL fVert = info.dwStyle&PBS_VERTICAL; CDC *pDC = info.pDC; int nValue = 0; CString sFormat; GetWindowText(sFormat); switch(info.dwStyle&PBS_TEXTMASK) { case PBS_SHOW_PERCENT: if(sFormat.IsEmpty()) sFormat = _T("%d%%"); // retrieve current position and range nValue = (int)((float)(info.nCurPos-info.nLower) * 100 / ((info.nUpper-info.nLower == 0) ? 1 : info.nUpper-info.nLower)); break; case PBS_SHOW_POSITION: if(sFormat.IsEmpty()) sFormat = _T("%d"); // retrieve current position nValue = info.nCurPos; break; } if (sFormat.IsEmpty()) return; CFont* pFont = GetFont(); CSelFont sf(pDC, pFont); CSelTextColor tc(pDC, m_clrTextOnBar); CSelBkMode bm(pDC, TRANSPARENT); CSelTextAlign ta(pDC, TA_BOTTOM|TA_CENTER); CPoint ptOrg = pDC->GetWindowOrg(); CString sText; sText.Format(sFormat, nValue); LONG grad = 0; if(pFont) { LOGFONT lf; pFont->GetLogFont(&lf); grad = lf.lfEscapement/10; } int x = 0, y = 0, dx = 0, dy = 0; CSize sizText = pDC->GetTextExtent(sText); if(grad == 0) { x = sizText.cx; y = sizText.cy; dx = 0; dy = sizText.cy;} else if(grad == 90) { x = sizText.cy; y = sizText.cx; dx = sizText.cy; dy = 0;} else if(grad == 180) { x = sizText.cx; y = sizText.cy; dx = 0; dy = -sizText.cy;} else if(grad == 270) { x = sizText.cy; y = sizText.cx; dx = -sizText.cy; dy = 0;} else ASSERT(0); // angle not supported CPoint pt = pDC->GetViewportOrg(); if(info.dwStyle&PBS_TIED_TEXT) { CRect rcFill(ConvertToReal(info, rcBar)); if((fVert ? y : x) <= rcBar.Width()) { pDC->SetViewportOrg(rcFill.left + (rcFill.Width() + dx)/2, rcFill.top + (rcFill.Height() + dy)/2); DrawClippedText(info, rcBar, sText, ptOrg); } } else { pDC->SetViewportOrg(info.rcClient.left + (info.rcClient.Width() + dx)/2, info.rcClient.top + (info.rcClient.Height() + dy)/2); if(m_clrTextOnBar == m_clrTextOnBk) // if the same color for bar and background draw text once DrawClippedText(info, rcMax, sText, ptOrg); else { // else, draw clipped parts of text // draw text on gradient if(rcBar.left != rcBar.right) DrawClippedText(info, rcBar, sText, ptOrg); // draw text out of gradient if(rcMax.right > rcBar.right) { tc.Select(m_clrTextOnBk); CRect rc(rcMax); rc.left = rcBar.right; DrawClippedText(info, rc, sText, ptOrg); } if(rcMax.left < rcBar.left) { tc.Select(m_clrTextOnBk); CRect rc(rcMax); rc.right = rcBar.left; DrawClippedText(info, rc, sText, ptOrg); } } } pDC->SetViewportOrg(pt); }
//! Redraw the button depending on whether it's up or down void CPUButton::Draw(BRect rect) { bool value = (bool)Value(); SetHighColor(value ? fOnColor : fOffColor); if (!fReplicant) { SetLowColor(Parent()->LowColor()); FillRect(Bounds(), B_SOLID_LOW); } BRect bounds = Bounds(); if (fReplicant && !fReplicantInDeskbar) { bounds.bottom -= 4; bounds.right -= 4; } else if (!fReplicant) { bounds.bottom -= 7; bounds.right -= 7; } BRect color_rect(bounds); color_rect.InsetBy(2, 2); if (value) { color_rect.bottom -= 1; color_rect.right -= 1; } FillRect(bounds); if (value) SetHighColor(80, 80, 80); else SetHighColor(255, 255, 255); BPoint start(0, 0); BPoint end(bounds.right, 0); StrokeLine(start, end); end.Set(0, bounds.bottom); StrokeLine(start, end); if (value) SetHighColor(32, 32, 32); else SetHighColor(216, 216, 216); start.Set(1, 1); end.Set(bounds.right - 1, 1); StrokeLine(start, end); end.Set(1, bounds.bottom - 1); StrokeLine(start, end); if (value) SetHighColor(216, 216, 216); else SetHighColor(80, 80, 80); start.Set(bounds.left + 1, bounds.bottom - 1); end.Set(bounds.right - 1, bounds.bottom - 1); StrokeLine(start, end); start.Set(bounds.right - 1, bounds.top + 1); StrokeLine(start, end); if (value) SetHighColor(255, 255, 255); else SetHighColor(32, 32, 32); start.Set(bounds.left, bounds.bottom); end.Set(bounds.right, bounds.bottom); StrokeLine(start, end); start.Set(bounds.right, bounds.top); StrokeLine(start, end); if (value) { SetHighColor(0, 0, 0); start.Set(bounds.left + 2, bounds.bottom - 2); end.Set(bounds.right - 2, bounds.bottom - 2); StrokeLine(start, end); start.Set(bounds.right - 2, bounds.top + 2); StrokeLine(start, end); } // Try to keep the text centered BFont font; GetFont(&font); int label_width = (int)font.StringWidth(Label()); int rect_width = bounds.IntegerWidth() - 1; int rect_height = bounds.IntegerHeight(); font_height fh; font.GetHeight(&fh); int label_height = (int)fh.ascent; int x_pos = (int)(((double)(rect_width - label_width) / 2.0) + 0.5); int y_pos = (rect_height - label_height) / 2 + label_height; MovePenTo(x_pos, y_pos); SetHighColor(0, 0, 0); SetDrawingMode(B_OP_OVER); DrawString(Label()); }
// // Main window procedure - just used to host the CodeView and UniView windows // LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { int width = LOWORD(lParam); int height = HIWORD(lParam); int height2; RECT rect; switch(msg) { case WM_CREATE: g_seq.init(INITIAL_TEXT, lstrlen(INITIAL_TEXT)); hwndUniView = CreateUniView(hwnd, &g_seq); hwndSpanView = CreateSpanView(hwnd, &g_seq); return 0; case WM_CLOSE: DestroyWindow(hwnd); return 0; case WM_SIZE: GetWindowRect(hwndUniView, &rect); height2 = rect.bottom-rect.top; MoveWindow(hwndUniView, 0, 0, width, height2, TRUE); MoveWindow(hwndSpanView, 0, height2+2, width, height-height2-2, TRUE); InvalidateRect(hwndSpanView, 0,0); return 0; case WM_USER: InvalidateRect(hwndSpanView, 0, 0); return 0; case WM_SETFOCUS: SetFocus(hwndUniView); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; case WM_COMMAND: switch(LOWORD(wParam)) { case IDM_FILE_FONT: if(GetFont(hwnd, &g_LogFont)) { DeleteObject(g_hFont); g_hFont = CreateFontIndirect(&g_LogFont); UpdateFont(); InvalidateRect(hwndUniView, 0, 0); SetFocus(hwndMain); SetFocus(hwndUniView); } return 0; case IDM_FILE_ABOUT: MessageBox(hwnd, _T("Piece Chain Demo\r\n\r\nCopyright(c) 2006 by Catch22 Productions.\r\nWritten by J Brown.\r\n\r\nHompage at www.catch22.net"), _T("Piece Chain Demo"), MB_ICONINFORMATION); return 0; // Quit :) case IDM_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0); return 0; } } return DefWindowProc(hwnd, msg, wParam, lParam); }
bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style, int min, int max, int initial, const wxString& name) { // before using DoGetBestSize(), have to set style to let the base class // know whether this is a horizontal or vertical control (we're always // vertical) style |= wxSP_VERTICAL; if ( (style & wxBORDER_MASK) == wxBORDER_DEFAULT ) style |= wxBORDER_SUNKEN; SetWindowStyle(style); WXDWORD exStyle = 0; WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ; // Scroll text automatically if there is not enough space to show all of // it, this is better than not allowing to enter more digits at all. msStyle |= ES_AUTOHSCROLL; // propagate text alignment style to text ctrl if ( style & wxALIGN_RIGHT ) msStyle |= ES_RIGHT; else if ( style & wxALIGN_CENTER ) msStyle |= ES_CENTER; // calculate the sizes: the size given is the total size for both controls // and we need to fit them both in the given width (height is the same) wxSize sizeText(size), sizeBtn(size); sizeBtn.x = wxSpinButton::DoGetBestSize().x; if ( sizeText.x <= 0 ) { // DEFAULT_ITEM_WIDTH is the default width for the text control sizeText.x = DEFAULT_ITEM_WIDTH + MARGIN_BETWEEN + sizeBtn.x; } sizeText.x -= sizeBtn.x + MARGIN_BETWEEN; if ( sizeText.x <= 0 ) { wxLogDebug(wxS("wxSpinCtrl \"%s\": initial width %d is too small, ") wxS("at least %d pixels needed."), name, size.x, sizeBtn.x + MARGIN_BETWEEN + 1); } wxPoint posBtn(pos); posBtn.x += sizeText.x + MARGIN_BETWEEN; // we must create the text control before the spin button for the purpose // of the dialog navigation: if there is a static text just before the spin // control, activating it by Alt-letter should give focus to the text // control, not the spin and the dialog navigation code will give focus to // the next control (at Windows level), not the one after it // create the text window m_hwndBuddy = (WXHWND)::CreateWindowEx ( exStyle, // sunken border wxT("EDIT"), // window class NULL, // no window title msStyle, // style (will be shown later) pos.x, pos.y, // position 0, 0, // size (will be set later) GetHwndOf(parent), // parent (HMENU)-1, // control id wxGetInstance(), // app instance NULL // unused client data ); if ( !m_hwndBuddy ) { wxLogLastError(wxT("CreateWindow(buddy text window)")); return false; } // create the spin button if ( !wxSpinButton::Create(parent, id, posBtn, sizeBtn, style, name) ) { return false; } wxSpinButtonBase::SetRange(min, max); // subclass the text ctrl to be able to intercept some events gs_spinForTextCtrl[GetBuddyHwnd()] = this; m_wndProcBuddy = (WXFARPROC)wxSetWindowProc(GetBuddyHwnd(), wxBuddyTextWndProc); // set up fonts and colours (This is nomally done in MSWCreateControl) InheritAttributes(); if (!m_hasFont) SetFont(GetDefaultAttributes().font); // set the size of the text window - can do it only now, because we // couldn't call DoGetBestSize() before as font wasn't set if ( sizeText.y <= 0 ) { int cx, cy; wxGetCharSize(GetHWND(), &cx, &cy, GetFont()); sizeText.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy); } SetInitialSize(size); (void)::ShowWindow(GetBuddyHwnd(), SW_SHOW); // associate the text window with the spin button (void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)m_hwndBuddy, 0); // If the initial text value is actually a number, it overrides the // "initial" argument specified later. long initialFromText; if ( value.ToLong(&initialFromText) ) initial = initialFromText; // Set the range in the native control: notice that we must do it before // calling SetValue() to use the correct validity checks for the initial // value. SetRange(min, max); SetValue(initial); // Also set the text part of the control if it was specified independently // but don't generate an event for this, it would be unexpected. m_blockEvent = true; if ( !value.empty() ) SetValue(value); m_blockEvent = false; return true; }
SIZE COptionUI::EstimateSize(SIZE szAvailable) { if( m_cxyFixed.cy == 0 ) return CDuiSize(m_cxyFixed.cx, m_pManager->GetFontInfo(GetFont())->tm.tmHeight + 8); return CControlUI::EstimateSize(szAvailable); }
void TextInputResetFont(void) { SetWindowFont(hwndInput, GetFont(FONT_INPUT), TRUE); CalculateWindowHeight(); }
void CToolTipCtrlEx::OnPaint() { POINT Pos; GetCursorPos(&Pos); CRect PRect; WindowFromPoint(Pos)->GetWindowRect(PRect); CPaintDC dc(this); // device context for painting CRect Rect,R1; CRect WRect; Orientations Orient=NW; BOOL Over=0,Left=0; Over=Pos.y >(PRect.top+(PRect.bottom-PRect.top)/2); Left=Pos.x <(PRect.left+(PRect.right-PRect.left)/2); if(Over & Left)Orient=NW; else if(Over & !Left)Orient=NE; else if(!Over & Left)Orient=SW; else if(!Over & !Left)Orient=SE; dc.SelectObject(GetFont()); CString Tip=_T(""),TStr=_T(""); GetWindowText(Tip); UINT Width=0; UINT Rows=1; UINT iPos=0; Tip.Replace(_T("\r"),_T("")); while(iPos<Tip.GetLength()) { if(Tip.GetAt(iPos)=='\n') { CSize Sz1=dc.GetTextExtent(TStr); Width=(Width > Sz1.cx) ? Width : Sz1.cx; Rows+=1; TStr=_T(""); } else { TStr+=Tip.GetAt(iPos); } iPos++; } if(TStr.GetLength()) { CSize Sz1=dc.GetTextExtent(TStr); Width=(Width > Sz1.cx) ? Width : Sz1.cx; } if(Rows==1) { CSize Sz1=dc.GetTextExtent(Tip); Width=(Width > Sz1.cx) ? Width : Sz1.cx; } Width+=2; GetWindowRect(WRect); TEXTMETRIC TM; dc.GetTextMetrics(&TM); if(Over) { WRect.bottom=PRect.top; WRect.top=WRect.bottom-(Rows*(TM.tmHeight)+4); } else { WRect.top=PRect.bottom; WRect.bottom=WRect.top+(Rows*(TM.tmHeight)+4); } UINT T=WRect.Width()-(20+Width); WRect.left=Pos.x; WRect.right=WRect.left+20+Width; if(WRect.right>GetSystemMetrics(SM_CXSCREEN)-25) { WRect.OffsetRect(-(WRect.right-(GetSystemMetrics(SM_CXSCREEN)-25)),0); } MoveWindow(&WRect,1); ShowWindow(1); GetClientRect(Rect); dc.FillSolidRect(Rect,m_bkColor); R1=Rect; R1.right=R1.left+15; dc.FillSolidRect(R1,m_leftColor); Rect.left=R1.right+1; dc.SetBkMode(TRANSPARENT); Rect.top+=1; UINT iT=(Rect.Width()-Width)/2; Rect.left+=iT; dc.SetTextColor(m_textColor); if(Rows==1) { dc.DrawText(Tip,Rect,DT_LEFT|DT_VCENTER|DT_SINGLELINE); } else { dc.DrawText(Tip,Rect,DT_TOP|DT_LEFT|DT_WORDBREAK); } Rect.top-=1; Rect.left-=iT; GetClientRect(Rect); // Rect.InflateRect(1,1,1,1); dc.Draw3dRect(Rect,m_frameColor,m_frameColor); CPen Pen,*OldPen=0; Pen.CreatePen(PS_SOLID,1,m_arrowColor); OldPen=dc.SelectObject(&Pen); switch(Orient) { case SE: { CPoint ArrowPt=CPoint(R1.left+2,R1.top+2); POINT Pt[18]= { {ArrowPt.x, ArrowPt.y}, {ArrowPt.x, ArrowPt.y + 6}, {ArrowPt.x + 1, ArrowPt.y + 6}, {ArrowPt.x + 1, ArrowPt.y}, {ArrowPt.x + 6, ArrowPt.y}, {ArrowPt.x + 6, ArrowPt.y + 1}, {ArrowPt.x + 2, ArrowPt.y + 1}, {ArrowPt.x + 2, ArrowPt.y + 4}, {ArrowPt.x + 5, ArrowPt.y + 7}, {ArrowPt.x + 6, ArrowPt.y + 7}, {ArrowPt.x + 3, ArrowPt.y + 4}, {ArrowPt.x + 3, ArrowPt.y + 3}, {ArrowPt.x + 6, ArrowPt.y + 6}, {ArrowPt.x + 7, ArrowPt.y + 6}, {ArrowPt.x + 3, ArrowPt.y + 2}, {ArrowPt.x + 4, ArrowPt.y + 2}, {ArrowPt.x + 7, ArrowPt.y + 5}, {ArrowPt.x + 7, ArrowPt.y + 6} }; dc.Polyline(Pt,18); } break; case SW: { CPoint ArrowPt=CPoint(R1.right - 3, R1.top + 2); POINT Pt[18]= { {ArrowPt.x, ArrowPt.y}, {ArrowPt.x, ArrowPt.y + 6}, {ArrowPt.x - 1, ArrowPt.y + 6}, {ArrowPt.x - 1, ArrowPt.y}, {ArrowPt.x - 6, ArrowPt.y}, {ArrowPt.x - 6, ArrowPt.y + 1}, {ArrowPt.x - 2, ArrowPt.y + 1}, {ArrowPt.x - 2, ArrowPt.y + 4}, {ArrowPt.x - 5, ArrowPt.y + 7}, {ArrowPt.x - 6, ArrowPt.y + 7}, {ArrowPt.x - 3, ArrowPt.y + 4}, {ArrowPt.x - 3, ArrowPt.y + 3}, {ArrowPt.x - 6, ArrowPt.y + 6}, {ArrowPt.x - 7, ArrowPt.y + 6}, {ArrowPt.x - 3, ArrowPt.y + 2}, {ArrowPt.x - 4, ArrowPt.y + 2}, {ArrowPt.x - 7, ArrowPt.y + 5}, {ArrowPt.x - 7, ArrowPt.y + 6} }; dc.Polyline(Pt,18); } break; case NE: { CPoint ArrowPt=CPoint(R1.left+ 3, R1.bottom - 3); POINT Pt[18]= { {ArrowPt.x, ArrowPt.y}, {ArrowPt.x, ArrowPt.y - 6}, {ArrowPt.x + 1, ArrowPt.y - 6}, {ArrowPt.x + 1, ArrowPt.y}, {ArrowPt.x + 6, ArrowPt.y}, {ArrowPt.x + 6, ArrowPt.y - 1}, {ArrowPt.x + 2, ArrowPt.y - 1}, {ArrowPt.x + 2, ArrowPt.y - 4}, {ArrowPt.x + 5, ArrowPt.y - 7}, {ArrowPt.x + 6, ArrowPt.y - 7}, {ArrowPt.x + 3, ArrowPt.y - 4}, {ArrowPt.x + 3, ArrowPt.y - 3}, {ArrowPt.x + 6, ArrowPt.y - 6}, {ArrowPt.x + 7, ArrowPt.y - 6}, {ArrowPt.x + 3, ArrowPt.y - 2}, {ArrowPt.x + 4, ArrowPt.y - 2}, {ArrowPt.x + 7, ArrowPt.y - 5}, {ArrowPt.x + 7, ArrowPt.y - 6} }; dc.Polyline(Pt,18); } break; case NW: { CPoint ArrowPt=CPoint(R1.right- 3, R1.bottom - 3); POINT Pt[18]= { {ArrowPt.x, ArrowPt.y}, {ArrowPt.x, ArrowPt.y - 6}, {ArrowPt.x - 1, ArrowPt.y - 6}, {ArrowPt.x - 1, ArrowPt.y}, {ArrowPt.x - 6, ArrowPt.y}, {ArrowPt.x - 6, ArrowPt.y - 1}, {ArrowPt.x - 2, ArrowPt.y - 1}, {ArrowPt.x - 2, ArrowPt.y - 4}, {ArrowPt.x - 5, ArrowPt.y - 7}, {ArrowPt.x - 6, ArrowPt.y - 7}, {ArrowPt.x - 3, ArrowPt.y - 4}, {ArrowPt.x - 3, ArrowPt.y - 3}, {ArrowPt.x - 6, ArrowPt.y - 6}, {ArrowPt.x - 7, ArrowPt.y - 6}, {ArrowPt.x - 3, ArrowPt.y - 2}, {ArrowPt.x - 4, ArrowPt.y - 2}, {ArrowPt.x - 7, ArrowPt.y - 5}, {ArrowPt.x - 7, ArrowPt.y - 6} }; dc.Polyline(Pt,18); } break; }; dc.SelectObject(OldPen); Pen.DeleteObject(); }
float Screen::GetFontDescender(Text::TextureFont *font) { if (!font) font = GetFont().Get(); return font->GetDescender() * fontScale[1]; }