/* make settings for the grid here instead in the constructor */ void CBOINCGridCtrl::Setup() { //make grid cursor invisible SetCellHighlightPenWidth(0); SetCellHighlightROPenWidth(0); //change default selection colours SetSelectionBackground(*wxLIGHT_GREY); SetSelectionForeground(*wxBLACK); // SetRowLabelSize(1);//hide row labels SetColLabelSize(20); //make header row smaller as default SetColLabelAlignment(wxALIGN_LEFT,wxALIGN_CENTER); EnableGridLines(false); EnableDragRowSize(false);//prevent the user from changing the row height with the mouse EnableDragCell(false); EnableEditing(false);//make the whole grid read-only SetDefaultCellBackgroundColour(*wxWHITE); #ifdef __WXMAC__ SetLabelFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); SetDefaultCellFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE)); #else SetLabelFont(*wxNORMAL_FONT); #endif this->SetScrollLineX(5); this->SetScrollLineY(5); }
void ctlSQLGrid::OnMouseWheel(wxMouseEvent &event) { if (event.ControlDown() || event.CmdDown()) { wxFont fontlabel = GetLabelFont(); wxFont fontcells = GetDefaultCellFont(); if (event.GetWheelRotation() > 0) { fontlabel.SetPointSize(fontlabel.GetPointSize() - 1); fontcells.SetPointSize(fontcells.GetPointSize() - 1); } else { fontlabel.SetPointSize(fontlabel.GetPointSize() + 1); fontcells.SetPointSize(fontcells.GetPointSize() + 1); } SetLabelFont(fontlabel); SetDefaultCellFont(fontcells); SetColLabelSize(fontlabel.GetPointSize() * 4); SetDefaultRowSize(fontcells.GetPointSize() * 2); for (int index = 0; index < GetNumberCols(); index++) SetColSize(index, -1); ForceRefresh(); } else event.Skip(); }
//------------------------------------------------------------------------------ // custom grid implementation //------------------------------------------------------------------------------ CustomGrid::CustomGrid( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) : wxGrid( parent, id, pos, size, style, name ) { //create grid SetTable( new wxGridStringTable(0, 0), true, wxGridSelectRows ); //some general settings EnableEditing( false ); EnableGridLines( true ); EnableDragGridSize( false ); SetMargins( 0, 0 ); EnableDragColMove( false ); EnableDragColSize( false ); EnableDragRowSize( false ); //init rows pref wxFileConfig *pConf = GetOCPNConfigObject(); if (pConf) { pConf->SetPath(_T("/Settings/GRIB")); m_IsDigit = pConf->Read(_T("GribDataTableRowPref"), _T("XXX")); } if( m_IsDigit.Len() != wxString(_T("XXX")).Len() ) m_IsDigit = _T("XXX"); //create structure for all numerical rows for( unsigned int i = 0; i < m_IsDigit.Len(); i++ ){ m_NumRow.push_back(wxNOT_FOUND); m_NumRowVal.push_back(std::vector <double>()); } //init labels attr wxFont labelfont = GetOCPNGUIScaledFont_PlugIn( _T("Dialog") ).MakeBold(); SetLabelFont(labelfont); wxColour colour; GetGlobalColor(_T("DILG0"), &colour); SetLabelBackgroundColour(colour); //set row label size int w; GetTextExtent( _T("Ab"), &w, NULL, 0, 0, &labelfont); double x = (double)w * 6.5; SetRowLabelSize((int)x); //colour settings GetGlobalColor(_T("GREEN1"), &m_greenColour); GetGlobalColor(_T("DILG1"), &m_greyColour); #ifdef __WXOSX__ m_bLeftDown = false; #endif //connect events at dialog level Connect(wxEVT_SCROLLWIN_THUMBTRACK, wxScrollEventHandler( CustomGrid::OnScroll ), NULL, this ); Connect(wxEVT_SIZE, wxSizeEventHandler( CustomGrid::OnResize ), NULL, this ); Connect(wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEventHandler( CustomGrid::OnLabeClick ), NULL, this ); //connect events at grid level GetGridWindow()->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler( CustomGrid::OnMouseEvent ), NULL, this ); GetGridWindow()->Connect(wxEVT_LEFT_UP, wxMouseEventHandler( CustomGrid::OnMouseEvent ), NULL, this ); GetGridWindow()->Connect(wxEVT_MOTION, wxMouseEventHandler( CustomGrid::OnMouseEvent ), NULL, this ); //timer event m_tRefreshTimer.Connect(wxEVT_TIMER, wxTimerEventHandler( CustomGrid::OnRefreshTimer ), NULL, this); }
MyGrid::MyGrid(wxNotebook * parent) : wxGrid(parent, wxID_ANY) { CreateGrid(30, 30); SetRowLabelSize(50); SetColLabelSize(25); SetRowLabelAlignment(wxALIGN_RIGHT, wxALIGN_CENTRE); SetLabelFont(wxFont(9, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD)); for (int i = 0; i < 30; i++) { this->SetRowSize(i, 25); } }
ctlSQLGrid::ctlSQLGrid(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) : wxGrid(parent, id, pos, size, wxWANTS_CHARS | wxVSCROLL | wxHSCROLL) { // Set cells font wxFont fntCells(settings->GetSQLFont()); SetDefaultCellFont(fntCells); // Set labels font wxFont fntLabel(settings->GetSystemFont()); fntLabel.SetWeight(wxBOLD); SetLabelFont(fntLabel); SetColLabelAlignment(wxALIGN_LEFT, wxALIGN_CENTER); SetRowLabelSize(50); SetDefaultRowSize(fntCells.GetPointSize() * 2); SetColLabelSize(fntLabel.GetPointSize() * 4); SetDefaultCellOverflow(false); Connect(wxID_ANY, wxEVT_GRID_LABEL_LEFT_DCLICK, wxGridEventHandler(ctlSQLGrid::OnLabelDoubleClick)); }
void FontTestPanel::ApplySchemeSettings(vgui::IScheme *pScheme) { BaseClass::ApplySchemeSettings(pScheme); SetPaintBackgroundEnabled(true); SetPaintBackgroundType(0); SetBgColor(Color(0,0,0,255)); for (int i=0;i<ASW_FONT_TEST_LABELS;i++) { m_pLabel[i]->SetFgColor(pScheme->GetColor("White", Color(255,255,255,255))); } int k=0; SetLabelFont(pScheme, k++, "Default", "Default 123456 NO", false); SetLabelFont(pScheme, k++, "Default", "Default proportional 123456 YES", true); SetLabelFont(pScheme, k++, "DefaultUnderline", "DefaultUnderline 123456 NO", false); SetLabelFont(pScheme, k++, "DefaultUnderline", "DefaultUnderline proportional 123456 YES", true); SetLabelFont(pScheme, k++, "DefaultSmall", "DefaultSmall 123456 NO", false); SetLabelFont(pScheme, k++, "DefaultSmall", "DefaultSmall proportional 123456 YES", true); SetLabelFont(pScheme, k++, "DefaultMedium", "DefaultMedium 123456 NO", false); SetLabelFont(pScheme, k++, "DefaultMedium", "DefaultMedium proportional 123456 YES", true); SetLabelFont(pScheme, k++, "DefaultVerySmall", "DefaultVerySmall 123456 NO", false); SetLabelFont(pScheme, k++, "DefaultVerySmall", "DefaultVerySmall proportional 123456 YES", true); SetLabelFont(pScheme, k++, "DefaultLarge", "DefaultLarge 123456 NO", false); SetLabelFont(pScheme, k++, "DefaultLarge", "DefaultLarge proportional 123456 YES", true); SetLabelFont(pScheme, k++, "DefaultExtraLarge", "DefaultExtraLarge 123456 NO", false); SetLabelFont(pScheme, k++, "DefaultExtraLarge", "DefaultExtraLarge proportional 123456 YES", true); SetLabelFont(pScheme, k++, "DefaultLarge", "DefaultLarge 123456 NO", false); SetLabelFont(pScheme, k++, "DefaultLarge", "DefaultLarge proportional 123456 YES", true); SetLabelFont(pScheme, k++, "Sansman8", "Sansman8 123456 NO", false); SetLabelFont(pScheme, k++, "Sansman8", "Sansman8 proportional 123456 YES", true); SetLabelFont(pScheme, k++, "Sansman10", "Sansman10 123456 NO", false); SetLabelFont(pScheme, k++, "Sansman10", "Sansman10 proportional 123456 YES", true); SetLabelFont(pScheme, k++, "Sansman12", "Sansman12 123456 NO", false); SetLabelFont(pScheme, k++, "Sansman12", "Sansman12 proportional 123456 YES", true); SetLabelFont(pScheme, k++, "Sansman14", "Sansman14 123456 NO", false); SetLabelFont(pScheme, k++, "Sansman14", "Sansman14 proportional 123456 YES", true); SetLabelFont(pScheme, k++, "Sansman16", "Sansman16 123456 NO", false); SetLabelFont(pScheme, k++, "Sansman16", "Sansman16 proportional 123456 YES", true); SetLabelFont(pScheme, k++, "Sansman18", "Sansman18 123456 NO", false); SetLabelFont(pScheme, k++, "Sansman18", "Sansman18 proportional 123456 YES", true); SetLabelFont(pScheme, k++, "Sansman20", "Sansman20 123456 NO", false); SetLabelFont(pScheme, k++, "Sansman20", "Sansman20 proportional 123456 YES", true); SetLabelFont(pScheme, k++, "CleanHUD", "CleanHUD 123456 NO", false); SetLabelFont(pScheme, k++, "CleanHUD", "CleanHUD proportional 123456 YES", true); SetLabelFont(pScheme, k++, "Courier", "Courier 123456 NO", false); SetLabelFont(pScheme, k++, "Courier", "Courier proportional 123456 YES", true); SetLabelFont(pScheme, k++, "SmallCourier", "SmallCourier 123456 NO", false); SetLabelFont(pScheme, k++, "SmallCourier", "SmallCourier proportional 123456 YES", true); SetLabelFont(pScheme, k++, "Verdana", "Verdana 123456 NO", false); SetLabelFont(pScheme, k++, "Verdana", "Verdana proportional 123456 YES", true); SetLabelFont(pScheme, k++, "VerdanaSmall", "VerdanaSmall 123456 NO", false); SetLabelFont(pScheme, k++, "VerdanaSmall", "VerdanaSmall proportional 123456 YES", true); SetLabelFont(pScheme, k++, "CampaignTitle", "CampaignTitle 123456 NO", false); SetLabelFont(pScheme, k++, "CampaignTitle", "CampaignTitle proportional 123456 YES", true); SetLabelFont(pScheme, k++, "MainMenu", "MainMenu 123456 NO", false); SetLabelFont(pScheme, k++, "MainMenu", "MainMenu proportional 123456 YES", true); SetLabelFont(pScheme, k++, "MissionChooserFont", "MissionChooserFont 123456 NO", false); SetLabelFont(pScheme, k++, "MissionChooserFont", "MissionChooserFont proportional 123456 YES", true); }
/*** * 功能: 窗体FrmWiFi的初始化函数,建立窗体控件、注册消息处理 * 参数: 1.void *pWndObj: 指向当前窗体对象 * 返回: 成功返回零,失败返回非零值 * 备注: ***/ int FrmWiFiInit(void *pWndObj) { //错误标志、返回值定义 int iReturn = 0; int i = 0; GUIMESSAGE *pMsg = NULL; //得到当前窗体对象 pFrmWiFi = (GUIWINDOW *) pWndObj; pWifiFntBlack = CreateFont(FontFileDirectory"unicode.fnt", 16, 16, 0x0000000, 0xFFFFFFFF); //初始化文本资源必须在建立文本CreateText()或建立标签CreateLabel()之前 WiFiTextRes_Init(NULL, 0, NULL, 0); /* 桌面背景图片 */ pWiFiBtnLeftBg = CreatePicture(0, 0, 681, 480, BmpFileDirectory"bg_wifi.bmp"); /*菜单部分*/ pWiFiMenuBg = CreatePicture(681, 39, 119, 441, BmpFileDirectory"wifi_global_menu_bg.bmp"); int y = 40; for (i = 0; i < 5; ++i) { pWiFiMenu[i] = CreatePicture(681, y + 51 * i, 119, 51, BmpFileDirectory"wifi_menu_item_unpress.bmp"); pWiFiLblMenu[i] = CreateLabel(681, y + 51 * i + 13, 119, 24, pWiFiStrMenu[i]); SetLabelAlign(GUILABEL_ALIGN_CENTER, pWiFiLblMenu[i]); } /* 窗体标题Label */ pWiFiLblFrmName = CreateLabel(0, 20, 100, 24, pWiFiStrFrmName); SetLabelAlign(GUILABEL_ALIGN_CENTER, pWiFiLblFrmName); SetLabelFont(pWifiFntBlack, pWiFiLblFrmName); /* 打开关闭WiFi区域控件定义 */ pWiFiBtnREnableOn = CreatePicture(350, 45, 84, 32, BmpFileDirectory"btn_wifi_on_unpress.bmp"); pWiFiBtnREnableOff = CreatePicture(434, 45, 84, 32, BmpFileDirectory"btn_wifi_off_unpress.bmp"); pWiFiBtnConnect = CreatePicture(350, 95, 84, 32, BmpFileDirectory"btn_wifi_on_unpress.bmp");//victor pWiFiBtnOnOffBg = CreatePicture(28, 74, 313, 24, BmpFileDirectory"btn_wifi_ssid_unpress.bmp"); pWiFiLblOnOffInfo = CreateLabel(28, 76, 300, 24, pWiFiStrOnOffInfo); //pWiFiLblConnecting = CreateLabel(28, 116, 300, 24, pWiFiStrConnecting);//victor pWiFiLblConnecting = CreateLabel(250, 95, 300, 24, pWiFiStrConnecting);//victor SetLabelAlign(GUILABEL_ALIGN_CENTER, pWiFiLblConnecting ); SetLabelFont(pWifiFntBlack, pWiFiLblConnecting ); /* wifi列表 */ for(i = 0; i < WIFIITEM; i++) { pWiFiItem[i] = CreatePicture(10, 170+(i*30), 313, 28, BmpFileDirectory"btn_wifi_ssid_unpress.bmp"); pWiFiLblItem[i] = CreateLabel(10, 170+(i*30), 313, 28, pWiFiStrItem[i]); SetLabelFont(pWifiFntBlack, pWiFiLblItem[i]); } AddWindowComp(OBJTYP_GUIWINDOW, sizeof(GUIWINDOW), pFrmWiFi, pFrmWiFi); //注册桌面上的控件 AddWindowComp(OBJTYP_GUIPICTURE, sizeof(GUIPICTURE), pWiFiBtnREnableOn, pFrmWiFi); AddWindowComp(OBJTYP_GUIPICTURE, sizeof(GUIPICTURE), pWiFiBtnREnableOff, pFrmWiFi); AddWindowComp(OBJTYP_GUIPICTURE, sizeof(GUIPICTURE), pWiFiBtnConnect, pFrmWiFi);//victor for(i= 0; i < 5; i++) { AddWindowComp(OBJTYP_GUIPICTURE, sizeof(GUIPICTURE), pWiFiMenu[i], pFrmWiFi); } for(i = 0; i < WIFIITEM; i++) { AddWindowComp(OBJTYP_GUIPICTURE, sizeof(GUIPICTURE), pWiFiItem[i], pFrmWiFi); } pMsg = GetCurrMessage(); //注册窗体的按键消息处理 LoginMessageReg(GUIMESSAGE_KEY_DOWN, pFrmWiFi, WiFiWndKey_Down, NULL, 0, pMsg); LoginMessageReg(GUIMESSAGE_KEY_UP, pFrmWiFi, WiFiWndKey_Up, NULL, 0, pMsg); //注册桌面上控件的消息处理 LoginMessageReg(GUIMESSAGE_TCH_DOWN, pWiFiBtnREnableOn, WiFiBtnEnableOn_Down, NULL, 0, pMsg); LoginMessageReg(GUIMESSAGE_TCH_DOWN, pWiFiBtnREnableOff, WiFiBtnEnableOff_Down, NULL, 0, pMsg); LoginMessageReg(GUIMESSAGE_TCH_UP, pWiFiBtnREnableOn, WiFiBtnEnableOn_Up, NULL, 0, pMsg); LoginMessageReg(GUIMESSAGE_TCH_UP, pWiFiBtnREnableOff, WiFiBtnEnableOff_Up, NULL, 0, pMsg); LoginMessageReg(GUIMESSAGE_TCH_UP, pWiFiBtnConnect, WiFiBtnConnect, NULL, 0, pMsg);//victor for(i= 0; i < 5; i++) { LoginMessageReg(GUIMESSAGE_TCH_DOWN, pWiFiMenu[i], WiFiBtnMenu_Down, NULL, i, pMsg); LoginMessageReg(GUIMESSAGE_TCH_UP, pWiFiMenu[i], WiFiBtnMenu_Up, NULL, i, pMsg); } for(i = 0; i < WIFIITEM; i++) { LoginMessageReg(GUIMESSAGE_TCH_DOWN, pWiFiItem[i], WiFiBtnItemSSID_Down, NULL, i, pMsg); LoginMessageReg(GUIMESSAGE_TCH_UP, pWiFiItem[i], WiFiBtnItemSSID_Up, NULL, i, pMsg); } return iReturn; }