mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-05-15 06:05:49 -06:00
Optimization for linux.
Исправлено форматирование и учтены особенности GTK для корректного отображения Log View.
This commit is contained in:
parent
dd868d51fd
commit
5aeb93b625
3 changed files with 1517 additions and 1489 deletions
|
|
@ -128,7 +128,11 @@ void ExplainShape::SetLabel(const wxString &str, int tokenNo, int detailNo)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct autospacesolver {
|
||||
int flags = 0;
|
||||
wxSize min{-1,-1};
|
||||
wxSize max;
|
||||
} autospacesolver;
|
||||
void ExplainShape::OnDraw(wxDC &dc)
|
||||
{
|
||||
wxBitmap &bmp = GetBitmap();
|
||||
|
|
@ -168,7 +172,8 @@ void ExplainShape::OnDraw(wxDC &dc)
|
|||
dc2.Clear();
|
||||
int w = bmpm.GetWidth();
|
||||
int h = bmpm.GetHeight();
|
||||
dc2.DrawRectangle(0, 0, w, h);
|
||||
dc2.DrawRoundedRectangle(wxRect(0, 0, w, h),2);
|
||||
//dc2.DrawRectangle(0, 0, w, h);
|
||||
wxRegEx r("Hits: (\\d+) Misses: (\\d+) Evictions: (\\d+) Overflows: (\\d+) Memory Usage: (\\d+\\S+)");
|
||||
long hit=0, mis=0, evi=0, ovr=0;
|
||||
wxString mem;
|
||||
|
|
@ -190,14 +195,24 @@ void ExplainShape::OnDraw(wxDC &dc)
|
|||
y += th+ border;
|
||||
//dc2.DrawText("TEst", 0, 0);
|
||||
mem = wxEmptyString;
|
||||
int spaceV = h-y; // label Cache
|
||||
int rr = 4;
|
||||
int h_line = th / 2;
|
||||
if (r.Matches(condition)) {
|
||||
hit=StrToLong( r.GetMatch(condition, 1));
|
||||
mis = StrToLong(r.GetMatch(condition, 2));
|
||||
evi = StrToLong(r.GetMatch(condition, 3));
|
||||
ovr = StrToLong(r.GetMatch(condition, 4));
|
||||
mem = (r.GetMatch(condition, 5));
|
||||
spaceV = spaceV - th; // memory usage
|
||||
if (evi || ovr) {
|
||||
spaceV = spaceV - 2 * rr;
|
||||
if (spaceV < 8) {
|
||||
border = 1; h_line = 6; rr = 3;
|
||||
}
|
||||
wxRect rect(border, y, w - 2 * border, th / 2);
|
||||
}
|
||||
}
|
||||
wxRect rect(border, y, w - 2 * border, h_line);
|
||||
//dc2.DrawRectangle(0, 0, w, h);
|
||||
if ((mis + hit) > 0) {
|
||||
int hitwidth = rect.width * hit * 1.0 / (mis + hit);
|
||||
|
|
@ -210,7 +225,8 @@ void ExplainShape::OnDraw(wxDC &dc)
|
|||
dc2.DrawRectangle(BMP_BORDER, y, hitwidth, rect.height);
|
||||
dc2.SetPen(dc.GetPen());
|
||||
dc2.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc2.DrawRectangle(rect);
|
||||
dc2.DrawRoundedRectangle(rect,(double)2.0);
|
||||
|
||||
}
|
||||
y += rect.height + border;
|
||||
}
|
||||
|
|
@ -227,18 +243,16 @@ void ExplainShape::OnDraw(wxDC &dc)
|
|||
x = border;
|
||||
if (evi > 0) {
|
||||
wxDCBrushChanger br(dc2, wxBrush(*wxBLUE));
|
||||
int r = 4;
|
||||
wxPoint p(x+r,y+r);
|
||||
dc2.DrawCircle(p, r);
|
||||
wxPoint p(x+rr,y+rr);
|
||||
dc2.DrawCircle(p, rr);
|
||||
//y + 2 * r + 1;
|
||||
x += 2 * r + r;
|
||||
x += 2 * rr + rr;
|
||||
}
|
||||
if (ovr > 0) {
|
||||
wxDCBrushChanger br(dc2, wxBrush(*wxRED));
|
||||
int r = 4;
|
||||
wxPoint p(x + r, y + r);
|
||||
dc2.DrawCircle(p, r);
|
||||
x += 2 * r + 3;
|
||||
wxPoint p(x + rr, y + rr);
|
||||
dc2.DrawCircle(p, rr);
|
||||
x += 2 * rr + 3;
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ void MyThread::getFilename() {
|
|||
while (!set->Eof()) {
|
||||
|
||||
wxString fn = set->GetVal(wxT("filename"));
|
||||
wxString key = wxString::Format("%i_server_%s",i,fn);
|
||||
wxString key = wxString::Format("%lu_server_%s",i,fn);
|
||||
info_files inf;
|
||||
long len= set->GetLong(wxT("len"));
|
||||
if (auto it = readfiles.find(key); it != readfiles.end()) {
|
||||
|
|
@ -622,7 +622,6 @@ void frmLog::OnAddLabelTextThread(wxThreadEvent& event) {
|
|||
void frmLog::OnTimer(wxTimerEvent& event) {
|
||||
|
||||
if (!DBthread->isReadyRows()) return;
|
||||
|
||||
wxString rez=DBthread->AppendNewRows(my_view, m_storage_model->getStorage());
|
||||
msgtext = wxString::Format("%s%d", rez, m_storage_model->GetRowCount());
|
||||
status->SetLabelText(msgtext);
|
||||
|
|
@ -1215,6 +1214,7 @@ frmLog::frmLog(frmMain *form, const wxString &_title, pgServer *srv) : pgFrame(N
|
|||
//m_notebook->SetSelectedFont(settings->GetSystemFont());
|
||||
//m_notebook->SetNormalFont(settings->GetSystemFont());
|
||||
m_notebook->SetFont(settings->GetSystemFont());
|
||||
my_view->SetFont(settings->GetSystemFont());
|
||||
bool b=true;
|
||||
settings->Read(dlgName + "/Mode",&b, false);
|
||||
group->SetValue(b);
|
||||
|
|
@ -1262,6 +1262,7 @@ pgServer* frmLog::getServer(wxString& strserver) {
|
|||
|
||||
frmLog::~frmLog()
|
||||
{
|
||||
m_timer.Stop();
|
||||
// If connection is still available, delete it
|
||||
SavePosition();
|
||||
wxString srvs;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ public:
|
|||
Storage* st;
|
||||
int row;
|
||||
int countRows = 0;
|
||||
wxColour quoteselcolor;
|
||||
// This renderer can be either activatable or editable, for demonstration
|
||||
// purposes. In real programs, you should select whether the user should be
|
||||
// able to activate or edit the cell and it doesn't make sense to switch
|
||||
|
|
@ -46,11 +47,24 @@ public:
|
|||
EnableEllipsize(wxELLIPSIZE_END);
|
||||
col = column;
|
||||
st = NULL;
|
||||
wxColour textColour;
|
||||
#ifdef __WXGTK__
|
||||
textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
|
||||
#else
|
||||
textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT);
|
||||
#endif // __WXGTK__
|
||||
if (ContrastColorBlackOrWhite(textColour) == "#000000") {
|
||||
quoteselcolor = wxColour(wxString("#7f7f7f"));
|
||||
}
|
||||
else quoteselcolor = *wxYELLOW;
|
||||
}
|
||||
|
||||
virtual bool Render(wxRect rect, wxDC* dc, int state) wxOVERRIDE
|
||||
{
|
||||
//dc->SetBrush( *wxLIGHT_GREY_BRUSH );
|
||||
if (state & wxDATAVIEW_CELL_SELECTED)
|
||||
dc->SetBrush(quoteselcolor);
|
||||
else
|
||||
dc->SetBrush(*wxYELLOW_BRUSH);
|
||||
dc->SetPen(*wxTRANSPARENT_PEN);
|
||||
rect.Deflate(2);
|
||||
|
|
@ -71,7 +85,6 @@ public:
|
|||
int startX = 0;
|
||||
|
||||
wxRect rectCol;
|
||||
|
||||
while (i < s.Len()) {
|
||||
|
||||
t = "";
|
||||
|
|
@ -105,16 +118,12 @@ public:
|
|||
t += s[i];
|
||||
i++;
|
||||
}
|
||||
RenderText(t,
|
||||
x, // no offset
|
||||
//wxRect(dc->GetTextExtent(m_value)).CentreIn(rect),
|
||||
rect,
|
||||
dc,
|
||||
state);
|
||||
RenderText(t, x, rect, dc, state);
|
||||
rect.y = rect.y + h.GetHeight() + 0;
|
||||
rect.height = rect.height - (h.GetHeight() + 0);
|
||||
|
||||
ex = true;
|
||||
}
|
||||
if (!ex) RenderText(t, x, rect, dc, state);
|
||||
|
||||
if (countRows > 0 && col == StorageModel::cols::Col_Host) {
|
||||
dc->SetBrush(*wxGREEN_BRUSH);
|
||||
|
|
@ -170,8 +179,12 @@ public:
|
|||
if (lines > 1) {
|
||||
wxString position;
|
||||
position = wxString::Format("lines %d,hieght 1 row %d full h=%d", lines, txtSize.GetHeight(), txtSize.GetHeight() * lines + 1 * lines);
|
||||
// wxLogMessage("MyCustomRendererText GetSize() %s", position);
|
||||
#ifdef __WXGTK__
|
||||
wxSize charSize = GetTextExtent("H");
|
||||
txtSize.SetHeight(txtSize.GetHeight() + charSize.GetHeight()/2);
|
||||
#else
|
||||
txtSize.SetHeight(txtSize.GetHeight() * lines + 1 * lines);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
txtSize.SetHeight(-1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue