mirror of
https://github.com/levinsv/pgadmin3.git
synced 2026-05-15 06:05:49 -06:00
Support hotkey for context help window.
Улучшена поддержка клавиши для навигации в контекстной справке. Краткий список: PAGEDOWN,PAGEUP,UP,DOWN,HOME,END - скроллинг окна. + - увеличить размер окна. S - screenshot контекстной справки. C - копирование в html формате.
This commit is contained in:
parent
a0ff59ae98
commit
d47a0fb61c
3 changed files with 130 additions and 130 deletions
|
|
@ -90,7 +90,7 @@ ctlSQLBox::ctlSQLBox(wxWindow *parent, wxWindowID id, const wxPoint &pos, const
|
||||||
m_dlgFindReplace = 0;
|
m_dlgFindReplace = 0;
|
||||||
m_dlgTransformText = 0;
|
m_dlgTransformText = 0;
|
||||||
m_database = NULL;
|
m_database = NULL;
|
||||||
|
|
||||||
m_autocompDisabled = false;
|
m_autocompDisabled = false;
|
||||||
process = 0;
|
process = 0;
|
||||||
processID = 0;
|
processID = 0;
|
||||||
|
|
@ -378,7 +378,7 @@ void ctlSQLBox::OnTextMark(wxCommandEvent& ev) {
|
||||||
int spos=0;
|
int spos=0;
|
||||||
if (ind>0) {
|
if (ind>0) {
|
||||||
spos=IndicatorStart(9,curr);
|
spos=IndicatorStart(9,curr);
|
||||||
if (spos>=0) {
|
if (spos>=0) {
|
||||||
epos=IndicatorEnd(9,curr);
|
epos=IndicatorEnd(9,curr);
|
||||||
len=epos-spos;
|
len=epos-spos;
|
||||||
//len=PositionRelative(spos,epos);
|
//len=PositionRelative(spos,epos);
|
||||||
|
|
@ -386,7 +386,7 @@ void ctlSQLBox::OnTextMark(wxCommandEvent& ev) {
|
||||||
IndicatorClearRange(spos,len);
|
IndicatorClearRange(spos,len);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// goto
|
// goto
|
||||||
epos=IndicatorEnd(9,curr);
|
epos=IndicatorEnd(9,curr);
|
||||||
if (epos==0) return;
|
if (epos==0) return;
|
||||||
if (epos==GetTextLength()) {
|
if (epos==GetTextLength()) {
|
||||||
|
|
@ -396,13 +396,13 @@ void ctlSQLBox::OnTextMark(wxCommandEvent& ev) {
|
||||||
GotoPos(epos);
|
GotoPos(epos);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (epos!=GetTextLength()) {
|
if (epos!=GetTextLength()) {
|
||||||
epos=IndicatorEnd(9,epos);
|
epos=IndicatorEnd(9,epos);
|
||||||
GotoPos(epos);
|
GotoPos(epos);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -637,7 +637,7 @@ void ctlSQLBox::OnCopy(wxCommandEvent& ev) {
|
||||||
Copy();
|
Copy();
|
||||||
}
|
}
|
||||||
void ctlSQLBox::OnFuncHelp(wxCommandEvent& ev) {
|
void ctlSQLBox::OnFuncHelp(wxCommandEvent& ev) {
|
||||||
|
|
||||||
FunctionPGHelper *fh=winMain->GetFunctionPGHelper();
|
FunctionPGHelper *fh=winMain->GetFunctionPGHelper();
|
||||||
int pos = GetCurrentPos();
|
int pos = GetCurrentPos();
|
||||||
if (!fh->isValid()) return;
|
if (!fh->isValid()) return;
|
||||||
|
|
@ -685,12 +685,12 @@ void ctlSQLBox::OnFuncHelp(wxCommandEvent& ev) {
|
||||||
if (bigtext) {
|
if (bigtext) {
|
||||||
rr.x=(int) sizeScreen.x*0.8;rr.y=sizeScreen.y*0.7;
|
rr.x=(int) sizeScreen.x*0.8;rr.y=sizeScreen.y*0.7;
|
||||||
}
|
}
|
||||||
m_PopupHelp = new popuphelp(this->GetParent(), key, fh,p,rr);
|
m_PopupHelp = new popuphelp(this, key, fh,p,rr);
|
||||||
if (m_PopupHelp && m_PopupHelp->IsValid() && rr != m_PopupHelp->GetSizePopup() && !bigtext) {
|
if (m_PopupHelp && m_PopupHelp->IsValid() && rr != m_PopupHelp->GetSizePopup() && !bigtext) {
|
||||||
// recreate with new size
|
// recreate with new size
|
||||||
rr = m_PopupHelp->GetSizePopup();
|
rr = m_PopupHelp->GetSizePopup();
|
||||||
delete m_PopupHelp;
|
delete m_PopupHelp;
|
||||||
m_PopupHelp = new popuphelp(this->GetParent(), key, fh, p, rr);
|
m_PopupHelp = new popuphelp(this, key, fh, p, rr);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (m_PopupHelp && m_PopupHelp->IsValid()) {
|
if (m_PopupHelp && m_PopupHelp->IsValid()) {
|
||||||
|
|
@ -756,7 +756,7 @@ void ctlSQLBox::Colourise(int start, int end)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hword = -1;
|
hword = -1;
|
||||||
|
|
||||||
nextchar:
|
nextchar:
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
int i = IsDBCSLeadByte(ch) ? 2 : 1;
|
int i = IsDBCSLeadByte(ch) ? 2 : 1;
|
||||||
|
|
@ -882,7 +882,7 @@ void ctlSQLBox::OnKeyDown(wxKeyEvent &event)
|
||||||
}
|
}
|
||||||
if (!AutoCompActive()) {
|
if (!AutoCompActive()) {
|
||||||
// work only hide autocomplite
|
// work only hide autocomplite
|
||||||
|
|
||||||
if (m_hint_mode) {
|
if (m_hint_mode) {
|
||||||
if (event.GetKeyCode() == WXK_RIGHT && event.GetModifiers() == wxMOD_ALT && !hint.IsEmpty()) {
|
if (event.GetKeyCode() == WXK_RIGHT && event.GetModifiers() == wxMOD_ALT && !hint.IsEmpty()) {
|
||||||
wxString ins = hint.substr(s.length());
|
wxString ins = hint.substr(s.length());
|
||||||
|
|
@ -954,7 +954,7 @@ void ctlSQLBox::OnKeyDown(wxKeyEvent &event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((event.GetKeyCode() == '9')&&(event.GetModifiers() == (wxMOD_SHIFT)))
|
if ((event.GetKeyCode() == '9')&&(event.GetModifiers() == (wxMOD_SHIFT)))
|
||||||
{
|
{
|
||||||
int pos = GetCurrentPos() ;
|
int pos = GetCurrentPos() ;
|
||||||
|
|
@ -1027,7 +1027,7 @@ void ctlSQLBox::OnKeyDown(wxKeyEvent &event)
|
||||||
if (pos==wxNOT_FOUND||(pos==calltip.length())) pos=ct_hl;
|
if (pos==wxNOT_FOUND||(pos==calltip.length())) pos=ct_hl;
|
||||||
}
|
}
|
||||||
CallTipSetHighlight(prev,pos);
|
CallTipSetHighlight(prev,pos);
|
||||||
|
|
||||||
ct_hl=pos;
|
ct_hl=pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1079,7 +1079,7 @@ void ctlSQLBox::OnKeyDown(wxKeyEvent &event)
|
||||||
{
|
{
|
||||||
f=true;
|
f=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (t.EndsWith(rpl)&&f)
|
if (t.EndsWith(rpl)&&f)
|
||||||
{
|
{
|
||||||
|
|
@ -1354,7 +1354,7 @@ wxString ctlSQLBox::ExternalFormat(int typecmd)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wxArrayString choiceCmpOpts;
|
wxArrayString choiceCmpOpts;
|
||||||
|
|
||||||
choiceCmpOpts.Add(_("All line (use all EOL)"));
|
choiceCmpOpts.Add(_("All line (use all EOL)"));
|
||||||
choiceCmpOpts.Add(_("First line pattern (ignore all but the first EOL)"));
|
choiceCmpOpts.Add(_("First line pattern (ignore all but the first EOL)"));
|
||||||
choiceCmpOpts.Add(_("Try looking for patterns above"));
|
choiceCmpOpts.Add(_("Try looking for patterns above"));
|
||||||
|
|
@ -1527,7 +1527,7 @@ std::pair<int,int> ctlSQLBox::SelectQuery(int startposition)
|
||||||
#endif
|
#endif
|
||||||
pos=pos+i;
|
pos=pos+i;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
pos--;
|
pos--;
|
||||||
while ((pos) >= 0)
|
while ((pos) >= 0)
|
||||||
|
|
@ -1558,7 +1558,7 @@ std::pair<int,int> ctlSQLBox::SelectQuery(int startposition)
|
||||||
if (startposition<0) SetSelection(pstart,pend);
|
if (startposition<0) SetSelection(pstart,pend);
|
||||||
//return result {pstart,pend};
|
//return result {pstart,pend};
|
||||||
return std::make_pair(pstart, pend);
|
return std::make_pair(pstart, pend);
|
||||||
|
|
||||||
}
|
}
|
||||||
void ctlSQLBox::HighlightBrace(int start, int len, int inicator) {
|
void ctlSQLBox::HighlightBrace(int start, int len, int inicator) {
|
||||||
{
|
{
|
||||||
|
|
@ -1688,7 +1688,7 @@ void ctlSQLBox::OnPositionStc(wxStyledTextEvent &event)
|
||||||
}
|
}
|
||||||
ident.Clear();
|
ident.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (st != 1 &&st != 2 && st != 6 && st != 7 &&(ch==';')&&startsql==0) startsql=pos+1;
|
if (st != 1 &&st != 2 && st != 6 && st != 7 &&(ch==';')&&startsql==0) startsql=pos+1;
|
||||||
if (( ch == '}' ||
|
if (( ch == '}' ||
|
||||||
|
|
@ -1708,11 +1708,11 @@ void ctlSQLBox::OnPositionStc(wxStyledTextEvent &event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int endtext= GetLength();
|
int endtext= GetLength();
|
||||||
bool isfrom=false;
|
bool isfrom=false;
|
||||||
pos=startsql;
|
pos=startsql;
|
||||||
|
|
||||||
ident.Clear();
|
ident.Clear();
|
||||||
while (pos<endtext) {
|
while (pos<endtext) {
|
||||||
ch = GetCharAt(pos);
|
ch = GetCharAt(pos);
|
||||||
|
|
@ -1829,7 +1829,7 @@ wxString ctlSQLBox::TextToHtml(int start, int end,bool isAddNewLine, const std::
|
||||||
if (isAddNewLine) newline = L"\u2936<br>";
|
if (isAddNewLine) newline = L"\u2936<br>";
|
||||||
//if (isAddNewLine) newline = L"⤶<br>";
|
//if (isAddNewLine) newline = L"⤶<br>";
|
||||||
//if (isAddNewLine) newline = L"<br>\x0b78";
|
//if (isAddNewLine) newline = L"<br>\x0b78";
|
||||||
|
|
||||||
int IndexObj=0;
|
int IndexObj=0;
|
||||||
int pos=999999999;
|
int pos=999999999;
|
||||||
wxString obj;
|
wxString obj;
|
||||||
|
|
@ -1851,13 +1851,13 @@ wxString ctlSQLBox::TextToHtml(int start, int end,bool isAddNewLine, const std::
|
||||||
int s = 0;
|
int s = 0;
|
||||||
//wxUniChar c = selText[k].GetValue();
|
//wxUniChar c = selText[k].GetValue();
|
||||||
if (c == '\r') { k++; continue; };
|
if (c == '\r') { k++; continue; };
|
||||||
|
|
||||||
if (c == '\n') { lstr += newline; k++; continue; };
|
if (c == '\n') { lstr += newline; k++; continue; };
|
||||||
if (c == 9) s = 5;
|
if (c == 9) s = 5;
|
||||||
if (c == 32) s = 1;
|
if (c == 32) s = 1;
|
||||||
if (c == '<') { lstr+="<"; k++; continue; };
|
if (c == '<') { lstr+="<"; k++; continue; };
|
||||||
if (c == '>') { lstr+=">"; k++; continue; };
|
if (c == '>') { lstr+=">"; k++; continue; };
|
||||||
if (c == '&') { lstr+="&"; k++; continue; };
|
if (c == '&') { lstr+="&"; k++; continue; };
|
||||||
if (s > 0) for (int tt = 0; tt < s; tt++) lstr += " ";
|
if (s > 0) for (int tt = 0; tt < s; tt++) lstr += " ";
|
||||||
else lstr += c;
|
else lstr += c;
|
||||||
k++;
|
k++;
|
||||||
|
|
@ -1895,7 +1895,7 @@ void ctlSQLBox::Copy() {
|
||||||
wxTheClipboard->SetData(dataobj);
|
wxTheClipboard->SetData(dataobj);
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else wxStyledTextCtrl::Copy();
|
} else wxStyledTextCtrl::Copy();
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1920,7 +1920,7 @@ void ctlSQLBox::OnAutoComplete(wxCommandEvent &rev)
|
||||||
int poshome=PositionFromLine(GetCurrentLine());
|
int poshome=PositionFromLine(GetCurrentLine());
|
||||||
int posspc=PositionRelative(poshome,spaceidx);
|
int posspc=PositionRelative(poshome,spaceidx);
|
||||||
if (spaceidx != -1) {
|
if (spaceidx != -1) {
|
||||||
|
|
||||||
while (poshome< posspc) {
|
while (poshome< posspc) {
|
||||||
int ch = GetCharAt(posspc);
|
int ch = GetCharAt(posspc);
|
||||||
int st = GetStyleAt(posspc) & 0x1F;
|
int st = GetStyleAt(posspc) & 0x1F;
|
||||||
|
|
@ -1932,7 +1932,7 @@ void ctlSQLBox::OnAutoComplete(wxCommandEvent &rev)
|
||||||
} else if (ch==' ') {
|
} else if (ch==' ') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
wxString lastexp=GetTextRange(PositionFromLine(GetCurrentLine()),posspc);
|
wxString lastexp=GetTextRange(PositionFromLine(GetCurrentLine()),posspc);
|
||||||
spacecharidx=lastexp.Length();
|
spacecharidx=lastexp.Length();
|
||||||
|
|
@ -2019,7 +2019,7 @@ void ctlSQLBox::OnAutoComplete(wxCommandEvent &rev)
|
||||||
if (!field.IsEmpty()) {
|
if (!field.IsEmpty()) {
|
||||||
wxString lf;
|
wxString lf;
|
||||||
wxString tabn;
|
wxString tabn;
|
||||||
|
|
||||||
wxString r=f.GetColsList(field, lf, tabn);
|
wxString r=f.GetColsList(field, lf, tabn);
|
||||||
if (r == "\t") r.clear();
|
if (r == "\t") r.clear();
|
||||||
int l2 = 0;
|
int l2 = 0;
|
||||||
|
|
@ -2111,7 +2111,7 @@ void ctlSQLBox::OnAutoComplete(wxCommandEvent &rev)
|
||||||
}
|
}
|
||||||
wxString f_name;
|
wxString f_name;
|
||||||
if (!fl && !alias.IsEmpty()) {
|
if (!fl && !alias.IsEmpty()) {
|
||||||
|
|
||||||
wxString lst=list_table;
|
wxString lst=list_table;
|
||||||
wxString table;
|
wxString table;
|
||||||
//alias.Replace(wxT("."), wxT(""));
|
//alias.Replace(wxT("."), wxT(""));
|
||||||
|
|
@ -2151,7 +2151,7 @@ void ctlSQLBox::OnAutoComplete(wxCommandEvent &rev)
|
||||||
AutoCompShow(l2, prev);
|
AutoCompShow(l2, prev);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//list_table.Find(alias
|
//list_table.Find(alias
|
||||||
}
|
}
|
||||||
l=0;
|
l=0;
|
||||||
for (int kk=what.Len()-1;kk>=0;kk--) {
|
for (int kk=what.Len()-1;kk>=0;kk--) {
|
||||||
|
|
|
||||||
|
|
@ -991,7 +991,7 @@ void ctlSQLGrid::OnShowPopup(wxThreadEvent& event) {
|
||||||
// recreate with new size
|
// recreate with new size
|
||||||
rr = m_Popup->GetSizePopup();
|
rr = m_Popup->GetSizePopup();
|
||||||
delete m_Popup;
|
delete m_Popup;
|
||||||
m_Popup = new popuphelp((wxWindow*)winMain, key, &fh, p, rr);
|
m_Popup = new popuphelp(this, key, &fh, p, rr);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (m_Popup && m_Popup->IsValid()) {
|
if (m_Popup && m_Popup->IsValid()) {
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,99 @@ public:
|
||||||
sizew = sz;
|
sizew = sz;
|
||||||
}
|
}
|
||||||
wxSize GetSizePopup() { return sizew; }
|
wxSize GetSizePopup() { return sizew; }
|
||||||
popuphelp(wxWindow* parent,wxString keyword, FunctionPGHelper *hhelper,wxPoint &posit,wxSize &newSz) : wxPopupTransientWindow(parent) {
|
void keyProcessing(wxKeyEvent& event) {
|
||||||
|
if (event.GetKeyCode() == WXK_ESCAPE) {
|
||||||
|
Hide();
|
||||||
|
event.Skip();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.GetKeyCode() == WXK_NUMPAD_ADD) {
|
||||||
|
wxSize sz = this->GetSize();
|
||||||
|
wxSize szh = htmlWindow->GetSize();
|
||||||
|
int xx, yy;
|
||||||
|
htmlWindow->GetVirtualSize(&xx, &yy);
|
||||||
|
wxPoint p = GetScreenPosition();
|
||||||
|
wxSize sizeScreen = getScreenSizeForPoint(p);
|
||||||
|
if (yy > szh.y) {
|
||||||
|
if (p.y + sz.y + 50 < sizeScreen.y)
|
||||||
|
sz.y += 50;
|
||||||
|
else
|
||||||
|
if (p.y > 50) { p.y = p.y - 50; sz.y += 50; }
|
||||||
|
}
|
||||||
|
if (p.x + sz.x + 50 < sizeScreen.x)
|
||||||
|
sz.x += 50;
|
||||||
|
else
|
||||||
|
if (p.x > 50) { p.x = p.x - 50; sz.x += 50; }
|
||||||
|
SetSize(p.x, p.y, sz.x, sz.y, wxSIZE_USE_EXISTING);
|
||||||
|
Layout();
|
||||||
|
wxSize newsz = GetSize();
|
||||||
|
//std::cout << sz.GetWidth() << "," << sz.GetHeight() << " new: " << newsz.GetWidth() << "," << newsz.GetHeight() << std::endl;
|
||||||
|
}
|
||||||
|
if (event.GetKeyCode() == WXK_PAGEDOWN) htmlWindow->ScrollPages(1);
|
||||||
|
if (event.GetKeyCode() == WXK_PAGEUP) htmlWindow->ScrollPages(-1);
|
||||||
|
if (event.GetKeyCode() == WXK_DOWN) htmlWindow->ScrollLines(1);
|
||||||
|
if (event.GetKeyCode() == WXK_UP) htmlWindow->ScrollLines(-1);
|
||||||
|
if (event.GetKeyCode() == WXK_HOME) htmlWindow->ScrollPages(-1000);
|
||||||
|
if (event.GetKeyCode() == WXK_END) htmlWindow->ScrollPages(1000);
|
||||||
|
//std::cout << "key code " << event.GetKeyCode() << " " << std::endl;
|
||||||
|
if (event.GetKeyCode() == 'C' && hist.size() > 0) {
|
||||||
|
|
||||||
|
if (wxTheClipboard->Open())
|
||||||
|
{
|
||||||
|
wxString h = hist[hist.size() - 1];
|
||||||
|
// Добавляем данные (можно добавить несколько форматов, если нужно)
|
||||||
|
wxDataObjectComposite* dataobj = new wxDataObjectComposite();
|
||||||
|
dataobj->Add(new wxHTMLDataObject(h));
|
||||||
|
wxTheClipboard->SetData(dataobj);
|
||||||
|
// fix for linux app crush
|
||||||
|
wxSafeYield();
|
||||||
|
wxTheClipboard->Close(); // crush app without wxSafeYield();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxLogError("No open clipboard.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (event.GetKeyCode() == 'S') {
|
||||||
|
wxSize clientSize = this->GetClientSize();
|
||||||
|
// Создаём битмап того же размера
|
||||||
|
wxBitmap bitmap(clientSize.x, clientSize.y, -1); // -1 — лучший формат для экрана
|
||||||
|
|
||||||
|
// Создаём DC для рисования в битмап
|
||||||
|
wxMemoryDC memDC;
|
||||||
|
memDC.SelectObject(bitmap);
|
||||||
|
|
||||||
|
// Очищаем фон (опционально, если окно не полностью перерисовано)
|
||||||
|
memDC.SetBackground(*wxWHITE_BRUSH);
|
||||||
|
memDC.Clear();
|
||||||
|
|
||||||
|
// Используем wxClientDC для чтения содержимого окна
|
||||||
|
wxClientDC clientDC(this);
|
||||||
|
// Переносим данные с clientDC в memDC (копируем прямоугольник)
|
||||||
|
// Важно: координаты — относительно окна!
|
||||||
|
memDC.Blit(0, 0, clientSize.x, clientSize.y, &clientDC, 0, 0);
|
||||||
|
|
||||||
|
// Освобождаем DC
|
||||||
|
memDC.SelectObject(wxNullBitmap);
|
||||||
|
// Открываем буфер обмена
|
||||||
|
if (wxTheClipboard->Open())
|
||||||
|
{
|
||||||
|
// Добавляем данные (можно добавить несколько форматов, если нужно)
|
||||||
|
wxTheClipboard->SetData(new wxBitmapDataObject(bitmap));
|
||||||
|
wxTheClipboard->Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxLogError("No open clipboard.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
popuphelp(wxWindow* parent,wxString keyword, FunctionPGHelper *hhelper,wxPoint &posit,wxSize &newSz) : wxPopupTransientWindow(parent, wxPU_CONTAINS_CONTROLS| wxBORDER_NONE) {
|
||||||
wxSize top_sz(newSz);
|
wxSize top_sz(newSz);
|
||||||
sizew = top_sz;
|
sizew = top_sz;
|
||||||
//SetSize(top_sz);
|
//SetSize(top_sz);
|
||||||
|
|
@ -48,7 +140,7 @@ public:
|
||||||
int size = fnt.GetPointSize();
|
int size = fnt.GetPointSize();
|
||||||
SetFont(fnt);
|
SetFont(fnt);
|
||||||
htmlWindow = new wxHtmlWindow(this, -1, wxDefaultPosition, sizew);
|
htmlWindow = new wxHtmlWindow(this, -1, wxDefaultPosition, sizew);
|
||||||
|
|
||||||
wxFont font(size, wxFontFamily::wxFONTFAMILY_MODERN, wxFontStyle::wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
wxFont font(size, wxFontFamily::wxFONTFAMILY_MODERN, wxFontStyle::wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||||
wxString fixf = font.GetFaceName();
|
wxString fixf = font.GetFaceName();
|
||||||
wxString scalf = fnt.GetFaceName();
|
wxString scalf = fnt.GetFaceName();
|
||||||
|
|
@ -64,7 +156,7 @@ public:
|
||||||
|
|
||||||
htmlWindow->SetRelatedStatusBar(0);
|
htmlWindow->SetRelatedStatusBar(0);
|
||||||
//htmlWindow->SetPage("<html><body><h1>TEST</h1><span fgcolor=\"#332233\">Set Page Works</span></body></hmtl>");
|
//htmlWindow->SetPage("<html><body><h1>TEST</h1><span fgcolor=\"#332233\">Set Page Works</span></body></hmtl>");
|
||||||
|
|
||||||
wxString txt;
|
wxString txt;
|
||||||
txt=hhelper->getDBinfoKeyword(keyword,true);
|
txt=hhelper->getDBinfoKeyword(keyword,true);
|
||||||
if (txt.IsEmpty()) {
|
if (txt.IsEmpty()) {
|
||||||
|
|
@ -82,7 +174,7 @@ public:
|
||||||
//wxSize sz= htmlWindow->GetSize();
|
//wxSize sz= htmlWindow->GetSize();
|
||||||
//sz = htmlWindow->GetBestSize();
|
//sz = htmlWindow->GetBestSize();
|
||||||
//htmlWindow->SetHTMLBackgroundImage(wxBitmapBundle::FromSVGFile("data/bg.svg", wxSize(65, 45)));
|
//htmlWindow->SetHTMLBackgroundImage(wxBitmapBundle::FromSVGFile("data/bg.svg", wxSize(65, 45)));
|
||||||
wxBoxSizer* topsizer;
|
wxBoxSizer* topsizer;
|
||||||
topsizer = new wxBoxSizer(wxVERTICAL);
|
topsizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
//htmlWindow->SetInitialSize(wxSize(htmlWindow->GetInternalRepresentation()->GetWidth(), htmlWindow->GetInternalRepresentation()->GetHeight()));
|
//htmlWindow->SetInitialSize(wxSize(htmlWindow->GetInternalRepresentation()->GetWidth(), htmlWindow->GetInternalRepresentation()->GetHeight()));
|
||||||
|
|
@ -129,7 +221,7 @@ public:
|
||||||
|
|
||||||
//this->Bind(wxEVT_HTML_CELL_CLICKED, [&](wxHtmlCellEvent& event) {
|
//this->Bind(wxEVT_HTML_CELL_CLICKED, [&](wxHtmlCellEvent& event) {
|
||||||
// wxHtmlCell* c = event.GetCell();
|
// wxHtmlCell* c = event.GetCell();
|
||||||
//
|
//
|
||||||
// wxString ctext=c->ConvertToText(NULL);
|
// wxString ctext=c->ConvertToText(NULL);
|
||||||
// ctext=htmlWindow->SelectionToText();
|
// ctext=htmlWindow->SelectionToText();
|
||||||
// wxString s = wxString::Format("cell = %s",ctext.c_str());
|
// wxString s = wxString::Format("cell = %s",ctext.c_str());
|
||||||
|
|
@ -146,7 +238,7 @@ public:
|
||||||
SetPage(body);
|
SetPage(body);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
body=this->hhelper->getDBinfoKeyword(name,false);
|
body=this->hhelper->getDBinfoKeyword(name,false);
|
||||||
if (body.IsEmpty()) {
|
if (body.IsEmpty()) {
|
||||||
body=this->hhelper->getHelpString(name);
|
body=this->hhelper->getHelpString(name);
|
||||||
|
|
@ -158,99 +250,7 @@ public:
|
||||||
//ctext=htmlWindow->SelectionToText();
|
//ctext=htmlWindow->SelectionToText();
|
||||||
//wxString s = wxString::Format("cell = %s",ctext.c_str());
|
//wxString s = wxString::Format("cell = %s",ctext.c_str());
|
||||||
});
|
});
|
||||||
htmlWindow->Bind(wxEVT_KEY_DOWN, [&](wxKeyEvent& event) {
|
Bind(wxEVT_CHAR_HOOK, &popuphelp::keyProcessing,this);
|
||||||
if (event.GetKeyCode() == WXK_ESCAPE) {
|
|
||||||
Hide();
|
|
||||||
event.Skip();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (event.GetKeyCode() == WXK_NUMPAD_ADD) {
|
|
||||||
wxSize sz=this->GetSize();
|
|
||||||
wxSize szh=htmlWindow->GetSize();
|
|
||||||
int xx, yy;
|
|
||||||
htmlWindow->GetVirtualSize(&xx, &yy);
|
|
||||||
wxPoint p=GetScreenPosition();
|
|
||||||
wxSize sizeScreen=getScreenSizeForPoint(p);
|
|
||||||
if (yy>szh.y) {
|
|
||||||
if (p.y+sz.y +50 <sizeScreen.y)
|
|
||||||
sz.y+=50;
|
|
||||||
else
|
|
||||||
if (p.y>50) {p.y=p.y-50; sz.y+=50;}
|
|
||||||
}
|
|
||||||
if (p.x+sz.x +50 <sizeScreen.x)
|
|
||||||
sz.x+=50;
|
|
||||||
else
|
|
||||||
if (p.x>50) {p.x=p.x-50; sz.x+=50;}
|
|
||||||
SetSize(p.x,p.y,sz.x,sz.y,wxSIZE_USE_EXISTING);
|
|
||||||
Layout();
|
|
||||||
wxSize newsz=GetSize();
|
|
||||||
//std::cout << sz.GetWidth() << "," << sz.GetHeight() << " new: " << newsz.GetWidth() << "," << newsz.GetHeight() << std::endl;
|
|
||||||
}
|
|
||||||
if (event.GetKeyCode() == WXK_PAGEDOWN) htmlWindow->ScrollPages(1);
|
|
||||||
if (event.GetKeyCode() == WXK_PAGEUP) htmlWindow->ScrollPages(-1);
|
|
||||||
if (event.GetKeyCode() == WXK_DOWN) htmlWindow->ScrollLines(1);
|
|
||||||
if (event.GetKeyCode() == WXK_UP) htmlWindow->ScrollLines(-1);
|
|
||||||
if (event.GetKeyCode() == WXK_HOME) htmlWindow->ScrollPages(-1000);
|
|
||||||
if (event.GetKeyCode() == WXK_END) htmlWindow->ScrollPages(1000);
|
|
||||||
//std::cout << "key code " << event.GetKeyCode() << " " << std::endl;
|
|
||||||
if (event.GetKeyCode() == 'C' && hist.size()>0) {
|
|
||||||
|
|
||||||
if (wxTheClipboard->Open())
|
|
||||||
{
|
|
||||||
wxString h=hist[hist.size()-1];
|
|
||||||
// Добавляем данные (можно добавить несколько форматов, если нужно)
|
|
||||||
wxDataObjectComposite* dataobj = new wxDataObjectComposite();
|
|
||||||
dataobj->Add(new wxHTMLDataObject(h));
|
|
||||||
wxTheClipboard->SetData(dataobj);
|
|
||||||
// fix for linux app crush
|
|
||||||
wxSafeYield();
|
|
||||||
wxTheClipboard->Close(); // crush app without wxSafeYield();
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxLogError("No open clipboard.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (event.GetKeyCode() == 'S') {
|
|
||||||
wxSize clientSize = this->GetClientSize();
|
|
||||||
// Создаём битмап того же размера
|
|
||||||
wxBitmap bitmap(clientSize.x, clientSize.y, -1); // -1 — лучший формат для экрана
|
|
||||||
|
|
||||||
// Создаём DC для рисования в битмап
|
|
||||||
wxMemoryDC memDC;
|
|
||||||
memDC.SelectObject(bitmap);
|
|
||||||
|
|
||||||
// Очищаем фон (опционально, если окно не полностью перерисовано)
|
|
||||||
memDC.SetBackground(*wxWHITE_BRUSH);
|
|
||||||
memDC.Clear();
|
|
||||||
|
|
||||||
// Используем wxClientDC для чтения содержимого окна
|
|
||||||
wxClientDC clientDC(this);
|
|
||||||
// Переносим данные с clientDC в memDC (копируем прямоугольник)
|
|
||||||
// Важно: координаты — относительно окна!
|
|
||||||
memDC.Blit(0, 0, clientSize.x, clientSize.y, &clientDC, 0, 0);
|
|
||||||
|
|
||||||
// Освобождаем DC
|
|
||||||
memDC.SelectObject(wxNullBitmap);
|
|
||||||
// Открываем буфер обмена
|
|
||||||
if (wxTheClipboard->Open())
|
|
||||||
{
|
|
||||||
// Добавляем данные (можно добавить несколько форматов, если нужно)
|
|
||||||
wxDataObjectComposite* dataobj = new wxDataObjectComposite();
|
|
||||||
dataobj->Add(new wxBitmapDataObject(bitmap));
|
|
||||||
wxTheClipboard->SetData(dataobj);
|
|
||||||
wxTheClipboard->Close();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxLogError("No open clipboard.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
htmlWindow->Bind(wxEVT_RIGHT_UP, [&](wxMouseEvent& event) {
|
htmlWindow->Bind(wxEVT_RIGHT_UP, [&](wxMouseEvent& event) {
|
||||||
wxString name;
|
wxString name;
|
||||||
wxLongLong e = wxGetLocalTimeMillis();
|
wxLongLong e = wxGetLocalTimeMillis();
|
||||||
|
|
@ -322,7 +322,7 @@ private:
|
||||||
innerbody.Replace("<body>", "<html><body TEXT=\"#000000\" BGCOLOR=\"#FFFFE0\" LINK=\"#0000FF\" VLINK=\"#FF0000\" ALINK=\"#000088\">", false);
|
innerbody.Replace("<body>", "<html><body TEXT=\"#000000\" BGCOLOR=\"#FFFFE0\" LINK=\"#0000FF\" VLINK=\"#FF0000\" ALINK=\"#000088\">", false);
|
||||||
h = "" + innerbody + "";
|
h = "" + innerbody + "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
h = "<html><body TEXT=\"#000000\" BGCOLOR=\"#FFFFE0\" LINK=\"#0000FF\" VLINK=\"#FF0000\" ALINK=\"#000088\">" + innerbody + "</body></hmtl>";
|
h = "<html><body TEXT=\"#000000\" BGCOLOR=\"#FFFFE0\" LINK=\"#0000FF\" VLINK=\"#FF0000\" ALINK=\"#000088\">" + innerbody + "</body></hmtl>";
|
||||||
|
|
||||||
if (gethistory) {
|
if (gethistory) {
|
||||||
|
|
@ -346,7 +346,7 @@ private:
|
||||||
hist_viewp.pop_back();
|
hist_viewp.pop_back();
|
||||||
htmlWindow->Scroll(ps);
|
htmlWindow->Scroll(ps);
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
wxPoint ps(0,0);
|
wxPoint ps(0,0);
|
||||||
htmlWindow->Scroll(ps);
|
htmlWindow->Scroll(ps);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue