Popup menu and cursor corrected. Some bugs fixed.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2743 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Karsten Ballüder
1999-06-10 17:22:02 +00:00
parent e839ce8d9b
commit da16935f6c
5 changed files with 51 additions and 27 deletions

View File

@@ -36,7 +36,9 @@ IMPLEMENT_APP(MyApp)
enum ids{ ID_ADD_SAMPLE = 1, ID_CLEAR, ID_PRINT, enum ids{ ID_ADD_SAMPLE = 1, ID_CLEAR, ID_PRINT,
ID_PRINT_SETUP, ID_PAGE_SETUP, ID_PREVIEW, ID_PRINT_PS, ID_PRINT_SETUP, ID_PAGE_SETUP, ID_PREVIEW, ID_PRINT_PS,
ID_PRINT_SETUP_PS, ID_PAGE_SETUP_PS,ID_PREVIEW_PS, ID_PRINT_SETUP_PS, ID_PAGE_SETUP_PS,ID_PREVIEW_PS,
ID_WRAP, ID_NOWRAP, ID_PASTE, ID_COPY, ID_CUT, ID_FIND, ID_WRAP, ID_NOWRAP, ID_PASTE, ID_COPY, ID_CUT,
ID_PASTE_PRIMARY,
ID_FIND,
ID_WXLAYOUT_DEBUG, ID_QUIT, ID_CLICK, ID_HTML, ID_TEXT, ID_WXLAYOUT_DEBUG, ID_QUIT, ID_CLICK, ID_HTML, ID_TEXT,
ID_TEST, ID_LINEBREAKS_TEST, ID_LONG_TEST, ID_URL_TEST }; ID_TEST, ID_LINEBREAKS_TEST, ID_LONG_TEST, ID_URL_TEST };
@@ -99,7 +101,10 @@ MyFrame::MyFrame(void) :
edit_menu->AppendSeparator(); edit_menu->AppendSeparator();
edit_menu->Append(ID_COPY, "&Copy", "Copy text to clipboard."); edit_menu->Append(ID_COPY, "&Copy", "Copy text to clipboard.");
edit_menu->Append(ID_CUT, "Cu&t", "Cut text to clipboard."); edit_menu->Append(ID_CUT, "Cu&t", "Cut text to clipboard.");
#ifdef __WXGTK__
edit_menu->Append(ID_PASTE,"&Paste", "Paste text from clipboard."); edit_menu->Append(ID_PASTE,"&Paste", "Paste text from clipboard.");
#endif
edit_menu->Append(ID_PASTE_PRIMARY,"&Paste primary", "Paste text from primary selection.");
edit_menu->Append(ID_FIND, "&Find", "Find text."); edit_menu->Append(ID_FIND, "&Find", "Find text.");
menu_bar->Append(edit_menu, "&Edit" ); menu_bar->Append(edit_menu, "&Edit" );
@@ -267,6 +272,12 @@ void MyFrame::OnCommand( wxCommandEvent &event )
m_lwin->Paste(); m_lwin->Paste();
m_lwin->Refresh(FALSE); m_lwin->Refresh(FALSE);
break; break;
#ifdef __WXGTK__
case ID_PASTE_PRIMARY:
m_lwin->Paste(TRUE);
m_lwin->Refresh(FALSE);
break;
#endif
case ID_COPY: case ID_COPY:
m_lwin->Copy(); m_lwin->Copy();
m_lwin->Refresh(FALSE); m_lwin->Refresh(FALSE);

View File

@@ -1071,6 +1071,7 @@ wxLayoutLine::Layout(wxDC &dc,
wxLayoutList *llist, wxLayoutList *llist,
wxPoint *cursorPos, wxPoint *cursorPos,
wxPoint *cursorSize, wxPoint *cursorSize,
wxLayoutStyleInfo *cursorStyle,
int cx, int cx,
bool suppressSIupdate) bool suppressSIupdate)
{ {
@@ -1134,6 +1135,8 @@ wxLayoutLine::Layout(wxDC &dc,
str = WXLO_CURSORCHAR; str = WXLO_CURSORCHAR;
dc.GetTextExtent(str, &width, &height, &descent); dc.GetTextExtent(str, &width, &height, &descent);
if(cursorStyle) // set style info
*cursorStyle = llist->GetStyleInfo();
if ( cursorSize ) if ( cursorSize )
{ {
// Just in case some joker inserted an empty string object: // Just in case some joker inserted an empty string object:
@@ -1151,6 +1154,7 @@ wxLayoutLine::Layout(wxDC &dc,
{ {
// on some other object // on some other object
CoordType top, bottom; // unused CoordType top, bottom; // unused
if(cursorSize)
*cursorSize = obj->GetSize(&top,&bottom); *cursorSize = obj->GetSize(&top,&bottom);
cursorPos->y = m_Position.y; cursorPos->y = m_Position.y;
cursorFound = true; // no more checks cursorFound = true; // no more checks
@@ -1554,6 +1558,7 @@ wxLayoutList::InternalClear(void)
m_DefaultStyleInfo.m_bg = *wxWHITE; m_DefaultStyleInfo.m_bg = *wxWHITE;
m_CurrentStyleInfo = m_DefaultStyleInfo; m_CurrentStyleInfo = m_DefaultStyleInfo;
m_CursorStyleInfo = m_DefaultStyleInfo;
} }
void void
@@ -2153,11 +2158,13 @@ wxLayoutList::Layout(wxDC &dc, CoordType bottom, bool forceAll,
if(line == m_CursorLine) if(line == m_CursorLine)
line->Layout(dc, this, line->Layout(dc, this,
(wxPoint *)&m_CursorScreenPos, (wxPoint *)&m_CursorScreenPos,
(wxPoint *)&m_CursorSize, m_CursorPos.x); (wxPoint *)&m_CursorSize,
&m_CursorStyleInfo,
m_CursorPos.x);
if(cpos && line->GetLineNumber() == cpos->y) if(cpos && line->GetLineNumber() == cpos->y)
line->Layout(dc, this, line->Layout(dc, this,
cpos, cpos,
csize, cpos->x); csize, NULL, cpos->x);
else else
line->Layout(dc, this); line->Layout(dc, this);
// little condition to speed up redrawing: // little condition to speed up redrawing:

View File

@@ -580,6 +580,7 @@ public:
@param llist th e wxLayoutList @param llist th e wxLayoutList
@param cursorPos if not NULL, set cursor screen position in there @param cursorPos if not NULL, set cursor screen position in there
@param cursorSize if not cursorPos != NULL, set cursor size in there @param cursorSize if not cursorPos != NULL, set cursor size in there
@param cursorStyle if non NULL where to store styleinfo for cursor pos
@param cx if cursorPos != NULL, the cursor x position @param cx if cursorPos != NULL, the cursor x position
@param suppressStyleUpdate FALSe normally, only to suppress updating of m_StyleInfo @param suppressStyleUpdate FALSe normally, only to suppress updating of m_StyleInfo
*/ */
@@ -587,6 +588,7 @@ public:
wxLayoutList *llist, wxLayoutList *llist,
wxPoint *cursorPos = NULL, wxPoint *cursorPos = NULL,
wxPoint *cursorSize = NULL, wxPoint *cursorSize = NULL,
wxLayoutStyleInfo *cursorStyle = NULL,
int cx = 0, int cx = 0,
bool suppressStyleUpdate = FALSE); bool suppressStyleUpdate = FALSE);
/** This function finds an object belonging to a given cursor /** This function finds an object belonging to a given cursor
@@ -919,13 +921,14 @@ public:
wxLayoutStyleInfo &GetDefaultStyleInfo(void) { return m_DefaultStyleInfo ; } wxLayoutStyleInfo &GetDefaultStyleInfo(void) { return m_DefaultStyleInfo ; }
wxLayoutStyleInfo &GetStyleInfo(void) { return m_CurrentStyleInfo ; } wxLayoutStyleInfo &GetStyleInfo(void) { return m_CurrentStyleInfo ; }
const wxLayoutStyleInfo &GetStyleInfo(void) const { return m_CurrentStyleInfo ; } const wxLayoutStyleInfo &GetStyleInfo(void) const { return m_CurrentStyleInfo ; }
const wxLayoutStyleInfo &GetCursorStyleInfo(void) const { return m_CursorStyleInfo ; }
/// is the current font underlined? /// is the current font underlined?
bool IsFontUnderlined() const { return GetStyleInfo().underline != 0; } bool IsFontUnderlined() const { return GetCursorStyleInfo().underline != 0; }
/// is the current font bold? /// is the current font bold?
bool IsFontBold() const { return GetStyleInfo().weight == wxBOLD; } bool IsFontBold() const { return GetCursorStyleInfo().weight == wxBOLD; }
/// is the current font italic? /// is the current font italic?
bool IsFontItalic() const { return GetStyleInfo().style == wxITALIC; } bool IsFontItalic() const { return GetCursorStyleInfo().style == wxITALIC; }
/// set underline if it was off, turn it off if it was on /// set underline if it was off, turn it off if it was on
void ToggleFontUnderline() void ToggleFontUnderline()
@@ -1162,6 +1165,8 @@ private:
wxLayoutStyleInfo m_DefaultStyleInfo; wxLayoutStyleInfo m_DefaultStyleInfo;
/// the current setting: /// the current setting:
wxLayoutStyleInfo m_CurrentStyleInfo; wxLayoutStyleInfo m_CurrentStyleInfo;
/// the current setting:
wxLayoutStyleInfo m_CursorStyleInfo;
//@} //@}
}; };

View File

@@ -95,6 +95,7 @@ BEGIN_EVENT_TABLE(wxLayoutWindow,wxScrolledWindow)
EVT_LEFT_UP(wxLayoutWindow::OnLeftMouseUp) EVT_LEFT_UP(wxLayoutWindow::OnLeftMouseUp)
EVT_RIGHT_DOWN(wxLayoutWindow::OnRightMouseClick) EVT_RIGHT_DOWN(wxLayoutWindow::OnRightMouseClick)
EVT_LEFT_DCLICK(wxLayoutWindow::OnMouseDblClick) EVT_LEFT_DCLICK(wxLayoutWindow::OnMouseDblClick)
EVT_MIDDLE_DOWN(wxLayoutWindow::OnMiddleMouseDown)
EVT_MOTION (wxLayoutWindow::OnMouseMove) EVT_MOTION (wxLayoutWindow::OnMouseMove)
EVT_UPDATE_UI(WXLOWIN_MENU_UNDERLINE, wxLayoutWindow::OnUpdateMenuUnderline) EVT_UPDATE_UI(WXLOWIN_MENU_UNDERLINE, wxLayoutWindow::OnUpdateMenuUnderline)
@@ -340,8 +341,8 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
} }
break; break;
case WXLOWIN_MENU_RCLICK: case WXLOWIN_MENU_MDOWN:
// remove the selection if mouse click is outside it (TODO) Paste(TRUE);
break; break;
case WXLOWIN_MENU_DBLCLICK: case WXLOWIN_MENU_DBLCLICK:
@@ -911,14 +912,19 @@ wxLayoutWindow::ResizeScrollbars(bool exact)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// clipboard operations // clipboard operations
//
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void void
wxLayoutWindow::Paste(void) wxLayoutWindow::Paste(bool primary)
{ {
// Read some text // Read some text
if (wxTheClipboard->Open()) if (wxTheClipboard->Open())
{ {
#if __WXGTK__
if(primary)
wxTheClipboard->UsePrimarySelection();
#endif
#if wxUSE_PRIVATE_CLIPBOARD_FORMAT #if wxUSE_PRIVATE_CLIPBOARD_FORMAT
wxLayoutDataObject wxldo; wxLayoutDataObject wxldo;
if (wxTheClipboard->IsSupported( wxldo.GetFormat() )) if (wxTheClipboard->IsSupported( wxldo.GetFormat() ))
@@ -1089,28 +1095,21 @@ void wxLayoutWindow::OnMenu(wxCommandEvent& event)
switch (event.GetId()) switch (event.GetId())
{ {
case WXLOWIN_MENU_LARGER: case WXLOWIN_MENU_LARGER:
m_llist->SetFontLarger(); m_llist->SetFontLarger(); Refresh(FALSE); break;
break;
case WXLOWIN_MENU_SMALLER: case WXLOWIN_MENU_SMALLER:
m_llist->SetFontSmaller(); m_llist->SetFontSmaller(); Refresh(FALSE); break;
break;
case WXLOWIN_MENU_UNDERLINE: case WXLOWIN_MENU_UNDERLINE:
m_llist->ToggleFontUnderline(); m_llist->ToggleFontUnderline(); Refresh(FALSE); break;
break;
case WXLOWIN_MENU_BOLD: case WXLOWIN_MENU_BOLD:
m_llist->ToggleFontWeight(); m_llist->ToggleFontWeight(); Refresh(FALSE); break;
break;
case WXLOWIN_MENU_ITALICS: case WXLOWIN_MENU_ITALICS:
m_llist->ToggleFontItalics(); m_llist->ToggleFontItalics(); Refresh(FALSE); break;
break;
case WXLOWIN_MENU_ROMAN: case WXLOWIN_MENU_ROMAN:
m_llist->SetFontFamily(wxROMAN); break; m_llist->SetFontFamily(wxROMAN); Refresh(FALSE); break;
case WXLOWIN_MENU_TYPEWRITER: case WXLOWIN_MENU_TYPEWRITER:
m_llist->SetFontFamily(wxFIXED); break; m_llist->SetFontFamily(wxFIXED); Refresh(FALSE); break;
case WXLOWIN_MENU_SANSSERIF: case WXLOWIN_MENU_SANSSERIF:
m_llist->SetFontFamily(wxSWISS); break; m_llist->SetFontFamily(wxSWISS); Refresh(FALSE); break;
} }
} }

View File

@@ -37,6 +37,7 @@ enum
WXLOWIN_MENU_SANSSERIF, WXLOWIN_MENU_SANSSERIF,
WXLOWIN_MENU_RCLICK, WXLOWIN_MENU_RCLICK,
WXLOWIN_MENU_DBLCLICK, WXLOWIN_MENU_DBLCLICK,
WXLOWIN_MENU_MDOWN,
WXLOWIN_MENU_LDOWN, WXLOWIN_MENU_LDOWN,
WXLOWIN_MENU_LUP, WXLOWIN_MENU_LUP,
WXLOWIN_MENU_MOUSEMOVE, WXLOWIN_MENU_MOUSEMOVE,
@@ -89,7 +90,7 @@ public:
m_CursorVisibility = visibility; return v;} m_CursorVisibility = visibility; return v;}
/// Pastes text from clipboard. /// Pastes text from clipboard.
void Paste(void); void Paste(bool usePrimarySelection = FALSE);
/** Copies selection to clipboard. /** Copies selection to clipboard.
@param invalidate used internally, see wxllist.h for details @param invalidate used internally, see wxllist.h for details
*/ */
@@ -138,6 +139,7 @@ public:
void OnLeftMouseDown(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_LDOWN, event); } void OnLeftMouseDown(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_LDOWN, event); }
void OnLeftMouseUp(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_LUP, event); } void OnLeftMouseUp(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_LUP, event); }
void OnRightMouseClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_RCLICK, event); } void OnRightMouseClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_RCLICK, event); }
void OnMiddleMouseDown(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_MDOWN, event); }
void OnMouseDblClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_DBLCLICK, event); } void OnMouseDblClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_DBLCLICK, event); }
void OnMouseMove(wxMouseEvent &event) { OnMouse(WXLOWIN_MENU_MOUSEMOVE, event) ; } void OnMouseMove(wxMouseEvent &event) { OnMouse(WXLOWIN_MENU_MOUSEMOVE, event) ; }
void OnSetFocus(wxFocusEvent &ev); void OnSetFocus(wxFocusEvent &ev);