]> git.saurik.com Git - wxWidgets.git/commitdiff
menu changed, many uninitialized variables are now initialized - thanks Purify
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 9 Jun 1999 11:36:45 +0000 (11:36 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 9 Jun 1999 11:36:45 +0000 (11:36 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2725 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/richedit/wxllist.cpp
samples/richedit/wxllist.h
samples/richedit/wxlwindow.cpp
samples/richedit/wxlwindow.h

index 83ff44ef42007bddb38cd267427dfea75506cf7a..cbec218f8e57c4bc964fc17260f416fc89d2d22d 100644 (file)
@@ -463,23 +463,16 @@ wxLayoutStyleInfo::wxLayoutStyleInfo(int ifamily,
                                      wxColour *fg,
                                      wxColour *bg)
 {
-   family = ifamily; size = isize;
-   style = istyle; weight = iweight;
+   family = ifamily;
+   size = isize;
+   style = istyle;
+   weight = iweight;
    underline = iul != 0;
-   if(fg)
-   {
-      m_fg = *fg;
-      m_fg_valid = TRUE;
-   }
-   else
-      m_fg = *wxBLACK;
-   if(bg)
-   {
-      m_bg = *bg;
-      m_bg_valid = TRUE;
-   }
-   else
-      m_bg = *wxWHITE;
+
+   m_fg_valid = fg != 0;
+   m_bg_valid = bg != 0;
+   m_fg = m_fg_valid ? *fg : *wxBLACK;
+   m_bg = m_fg_valid ? *bg : *wxWHITE;
 }
 
 #define COPY_SI_(what) if(right.what != -1) what = right.what;
@@ -632,6 +625,7 @@ wxLayoutLine::wxLayoutLine(wxLayoutLine *prev, wxLayoutList *llist)
    m_LineNumber = 0;
    m_Width = m_Height = 0;
    m_Length = 0;
+   m_updateLeft = -1;
    MarkDirty(0);
    m_Previous = prev;
    m_Next = NULL;
index d0d7c94ae61aa97cf028005fd558ad815bc6bb78..552c2551b06347d0ff42de44f7d052dd57be94bc 100644 (file)
@@ -904,7 +904,6 @@ public:
    inline void SetFontColour(wxColour *fg, wxColour *bg = NULL)
       { SetFont(-1,-1,-1,-1,-1,fg,bg); }
 
-
    /**
       Returns a pointer to the default settings.
       This is only valid temporarily and should not be stored
@@ -913,6 +912,27 @@ public:
    */
    wxLayoutStyleInfo &GetDefaultStyleInfo(void) { return m_DefaultStyleInfo ; }
    wxLayoutStyleInfo &GetStyleInfo(void) { return m_CurrentStyleInfo ; }
+   const wxLayoutStyleInfo &GetStyleInfo(void) const { return m_CurrentStyleInfo ; }
+
+   /// is the current font underlined?
+   bool IsFontUnderlined() const { return GetStyleInfo().underline != 0; }
+   /// is the current font bold?
+   bool IsFontBold() const { return GetStyleInfo().weight == wxBOLD; }
+   /// is the current font italic?
+   bool IsFontItalic() const { return GetStyleInfo().style == wxITALIC; }
+
+   /// set underline if it was off, turn it off if it was on
+   void ToggleFontUnderline()
+      { SetFontUnderline(!IsFontUnderlined()); }
+
+   /// make font bold if it was normal or make it normal if it was bold
+   void ToggleFontWeight()
+      { SetFontWeight(IsFontBold() ? wxNORMAL : wxBOLD); }
+
+   /// make font italic if it was normal or make it normal if it was italic
+   void ToggleFontItalics()
+      { SetFontStyle(IsFontItalic() ? wxNORMAL : wxITALIC); }
+
    //@}
 
    /**@name Drawing */
index e893d1adac82d01404a7a096c9bcb948d8c7b0a1..44a575d665e812f78b0b23e948b38e8824a19140 100644 (file)
@@ -85,13 +85,20 @@ static const int Y_SCROLL_PAGE = 20;
 
 BEGIN_EVENT_TABLE(wxLayoutWindow,wxScrolledWindow)
    EVT_PAINT    (wxLayoutWindow::OnPaint)
+
    EVT_CHAR     (wxLayoutWindow::OnChar)
    EVT_KEY_UP   (wxLayoutWindow::OnKeyUp)
+
    EVT_LEFT_DOWN(wxLayoutWindow::OnLeftMouseClick)
    EVT_RIGHT_DOWN(wxLayoutWindow::OnRightMouseClick)
    EVT_LEFT_DCLICK(wxLayoutWindow::OnMouseDblClick)
    EVT_MOTION    (wxLayoutWindow::OnMouseMove)
+
+   EVT_UPDATE_UI(WXLOWIN_MENU_UNDERLINE, wxLayoutWindow::OnUpdateMenuUnderline)
+   EVT_UPDATE_UI(WXLOWIN_MENU_BOLD, wxLayoutWindow::OnUpdateMenuBold)
+   EVT_UPDATE_UI(WXLOWIN_MENU_ITALICS, wxLayoutWindow::OnUpdateMenuItalic)
    EVT_MENU_RANGE(WXLOWIN_MENU_FIRST, WXLOWIN_MENU_LAST, wxLayoutWindow::OnMenu)
+
    EVT_SET_FOCUS(wxLayoutWindow::OnSetFocus)
    EVT_KILL_FOCUS(wxLayoutWindow::OnKillFocus)
 END_EVENT_TABLE()
@@ -154,7 +161,8 @@ wxLayoutWindow::wxLayoutWindow(wxWindow *parent)
    caret->Show();
 #endif // WXLAYOUT_USE_CARET
 
-   SetCursorVisibility(-1);
+   m_HandCursor = FALSE;
+   m_CursorVisibility = -1;
    SetCursor(wxCURSOR_IBEAM);
    SetDirty();
 }
@@ -951,39 +959,53 @@ wxLayoutWindow::MakeFormatMenu()
    m->Append(WXLOWIN_MENU_LARGER   ,_("&Larger"),_("Switch to larger font."), false);
    m->Append(WXLOWIN_MENU_SMALLER  ,_("&Smaller"),_("Switch to smaller font."), false);
    m->AppendSeparator();
-   m->Append(WXLOWIN_MENU_UNDERLINE_ON, _("&Underline on"),_("Activate underline mode."), false);
-   m->Append(WXLOWIN_MENU_UNDERLINE_OFF,_("&Underline off"),_("Deactivate underline mode."), false);
-   m->Append(WXLOWIN_MENU_BOLD_ON      ,_("&Bold on"),_("Activate bold mode."), false);
-   m->Append(WXLOWIN_MENU_BOLD_OFF     ,_("&Bold off"),_("Deactivate bold mode."), false);
-   m->Append(WXLOWIN_MENU_ITALICS_ON   ,_("&Italics on"),_("Activate italics mode."), false);
-   m->Append(WXLOWIN_MENU_ITALICS_OFF  ,_("&Italics off"),_("Deactivate italics mode."), false);
+   m->Append(WXLOWIN_MENU_UNDERLINE, _("&Underline"),_("Underline mode."), true);
+   m->Append(WXLOWIN_MENU_BOLD, _("&Bold"),_("Bold mode."), true);
+   m->Append(WXLOWIN_MENU_ITALICS, _("&Italics"),_("Italics mode."), true);
    m->AppendSeparator();
    m->Append(WXLOWIN_MENU_ROMAN     ,_("&Roman"),_("Switch to roman font."), false);
    m->Append(WXLOWIN_MENU_TYPEWRITER,_("&Typewriter"),_("Switch to typewriter font."), false);
    m->Append(WXLOWIN_MENU_SANSSERIF ,_("&Sans Serif"),_("Switch to sans serif font."), false);
+
    return m;
 }
 
+void wxLayoutWindow::OnUpdateMenuUnderline(wxUpdateUIEvent& event)
+{
+   event.Check(m_llist->IsFontUnderlined());
+}
+
+void wxLayoutWindow::OnUpdateMenuBold(wxUpdateUIEvent& event)
+{
+   event.Check(m_llist->IsFontBold());
+}
+
+void wxLayoutWindow::OnUpdateMenuItalic(wxUpdateUIEvent& event)
+{
+   event.Check(m_llist->IsFontItalic());
+}
+
 void wxLayoutWindow::OnMenu(wxCommandEvent& event)
 {
    switch (event.GetId())
    {
    case WXLOWIN_MENU_LARGER:
-      m_llist->SetFontLarger(); break;
+      m_llist->SetFontLarger();
+      break;
    case WXLOWIN_MENU_SMALLER:
-      m_llist->SetFontSmaller(); break;
-   case WXLOWIN_MENU_UNDERLINE_ON:
-      m_llist->SetFontUnderline(true); break;
-   case WXLOWIN_MENU_UNDERLINE_OFF:
-      m_llist->SetFontUnderline(false); break;
-   case WXLOWIN_MENU_BOLD_ON:
-      m_llist->SetFontWeight(wxBOLD); break;
-   case WXLOWIN_MENU_BOLD_OFF:
-      m_llist->SetFontWeight(wxNORMAL); break;
-   case WXLOWIN_MENU_ITALICS_ON:
-      m_llist->SetFontStyle(wxITALIC); break;
-   case WXLOWIN_MENU_ITALICS_OFF:
-      m_llist->SetFontStyle(wxNORMAL); break;
+      m_llist->SetFontSmaller();
+      break;
+
+   case WXLOWIN_MENU_UNDERLINE:
+      m_llist->ToggleFontUnderline();
+      break;
+   case WXLOWIN_MENU_BOLD:
+      m_llist->ToggleFontWeight();
+      break;
+   case WXLOWIN_MENU_ITALICS:
+      m_llist->ToggleFontItalics();
+      break;
+
    case WXLOWIN_MENU_ROMAN:
       m_llist->SetFontFamily(wxROMAN); break;
    case WXLOWIN_MENU_TYPEWRITER:
index 7e4d0ce70fa1e2be36947ea95956f8714a817435..6344296e965d7f9daf3ba6d9a0f3feeab89f2b6e 100644 (file)
@@ -29,12 +29,9 @@ enum
 {
    WXLOWIN_MENU_LARGER = WXLOWIN_MENU_FIRST,
    WXLOWIN_MENU_SMALLER,
-   WXLOWIN_MENU_UNDERLINE_ON,
-   WXLOWIN_MENU_UNDERLINE_OFF,
-   WXLOWIN_MENU_BOLD_ON,
-   WXLOWIN_MENU_BOLD_OFF,
-   WXLOWIN_MENU_ITALICS_ON,
-   WXLOWIN_MENU_ITALICS_OFF,
+   WXLOWIN_MENU_UNDERLINE,
+   WXLOWIN_MENU_BOLD,
+   WXLOWIN_MENU_ITALICS,
    WXLOWIN_MENU_ROMAN,
    WXLOWIN_MENU_TYPEWRITER,
    WXLOWIN_MENU_SANSSERIF,
@@ -132,6 +129,9 @@ public:
    void OnPaint(wxPaintEvent &event);
    void OnChar(wxKeyEvent& event);
    void OnKeyUp(wxKeyEvent& event);
+   void OnUpdateMenuUnderline(wxUpdateUIEvent& event);
+   void OnUpdateMenuBold(wxUpdateUIEvent& event);
+   void OnUpdateMenuItalic(wxUpdateUIEvent& event);
    void OnMenu(wxCommandEvent& event);
    void OnLeftMouseClick(wxMouseEvent& event)  { OnMouse(WXLOWIN_MENU_LCLICK, event); }
    void OnRightMouseClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_RCLICK, event); }