Go to the FreeLists Home Page Home Signup Help Login
 



[haiku-development] || [Date Prev] [09-2007 Date Index] [Date Next] || [Thread Prev] [09-2007 Thread Index] [Thread Next]

[haiku-development] StyledEdit

  • From: HOST <HOST.HAIKU@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Tue, 04 Sep 2007 00:24:15 +0200
Hi,

attached is a patch for StyledEdit. We are new to the HAIKU development
platform but we would like to support the ongoing offert to recreate the
BeOS system. So we started with something easy.

After investigating the coding guidelines we found some issues in
StyledEdit. Further more we recognized some memory leaking issue. Both
get resolved with the attached patch.

We are excited to work together with the community and look forward your
comments.

Regards,
HOST Team

Index: src/apps/stylededit/StyledEditWindow.cpp
===================================================================
--- src/apps/stylededit/StyledEditWindow.cpp    (Revision 22161)
+++ src/apps/stylededit/StyledEditWindow.cpp    (Arbeitskopie)
@@ -7,7 +7,6 @@
  *             Andrew Bachmann
  */
 
-
 #include "Constants.h"
 #include "ColorMenuItem.h"
 #include "FindWindow.h"
@@ -18,33 +17,32 @@
 
 #include <Alert.h>
 #include <Autolock.h>
-#include <Debug.h>
+#include <CharacterSet.h>
+#include <CharacterSetRoster.h>
 #include <Clipboard.h>
+#include <Debug.h>
 #include <File.h>
+#include <FilePanel.h>
 #include <Menu.h>
+#include <MenuBar.h>
 #include <MenuItem.h>
 #include <PrintJob.h>
-#include <Roster.h>
+#include <Rect.h>
 #include <ScrollView.h>
-#include <String.h>
 #include <TextControl.h>
+#include <TextView.h>
 #include <TranslationUtils.h>
-#include <Window.h>
+#include <Roster.h>
 
-#include <CharacterSet.h>
-#include <CharacterSetRoster.h>
-
 #include <stdlib.h>
 
 using namespace BPrivate;
 
-
 StyledEditWindow::StyledEditWindow(BRect frame, int32 id, uint32 encoding)
        : BWindow(frame, "untitled", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS)
 {
        InitWindow(encoding);
-       BString unTitled;
-       unTitled.SetTo("Untitled ");
+       BString unTitled("Untitled ");
        unTitled << id;
        SetTitle(unTitled.String());
        fSaveItem->SetEnabled(true);
@@ -365,7 +363,7 @@
                {
                        BRect findWindowFrame(100, 100, 400, 235);
                        BWindow* window = new FindWindow(findWindowFrame, this,
-                               &fStringToFind, &fCaseSens, &fWrapAround, 
&fBackSearch);
+                               &fStringToFind, fCaseSens, fWrapAround, 
fBackSearch);
                        window->Show();
                        break;
                }
@@ -388,58 +386,45 @@
                {
                        BRect replaceWindowFrame(100, 100, 400, 284);
                        BWindow* window = new ReplaceWindow(replaceWindowFrame, 
this,
-                               &fStringToFind, &fReplaceString, &fCaseSens, 
&fWrapAround, &fBackSearch);
+                               &fStringToFind, &fReplaceString, fCaseSens, 
fWrapAround, fBackSearch);
                        window->Show();
                        break;
                }
                case MSG_REPLACE:
                {
-                       BString findIt; 
-                       BString replaceWith;
-                       bool caseSens, wrap, backSearch;
+                       message->FindBool("casesens", &fCaseSens);
+                       message->FindBool("wrap", &fWrapAround);
+                       message->FindBool("backsearch", &fBackSearch);
 
-                       message->FindBool("casesens", &caseSens);
-                       message->FindBool("wrap", &wrap);
-                       message->FindBool("backsearch", &backSearch);
+                       message->FindString("FindText", &fStringToFind);
+                       message->FindString("ReplaceText", &fReplaceString);
 
-                       message->FindString("FindText", &findIt);
-                       message->FindString("ReplaceText", &replaceWith);
-                       fStringToFind = findIt;
                        fFindAgainItem->SetEnabled(true);
-                       fReplaceString = replaceWith;
                        fReplaceSameItem->SetEnabled(true);
-                       fCaseSens = caseSens;
-                       fWrapAround = wrap;
-                       fBackSearch = backSearch;
 
-                       Replace(findIt, replaceWith, caseSens, wrap, 
backSearch);
+                       Replace(fStringToFind, fReplaceString, fCaseSens, 
fWrapAround, fBackSearch);
                        break;
                }
                case MENU_REPLACE_SAME:
-                       
Replace(fStringToFind,fReplaceString,fCaseSens,fWrapAround,fBackSearch);
+                       Replace(fStringToFind, fReplaceString, fCaseSens, 
fWrapAround, fBackSearch);
                        break;
 
                case MSG_REPLACE_ALL:
                {
-                       BString findIt; 
-                       BString replaceWith;
-                       bool caseSens, allWindows;
+                       message->FindBool("casesens", &fCaseSens);
+                       message->FindString("FindText",&fStringToFind);
+                       message->FindString("ReplaceText",&fReplaceString);     
                        
 
-                       message->FindBool("casesens", &caseSens);
-                       message->FindString("FindText",&findIt);
-                       message->FindString("ReplaceText",&replaceWith);        
                        
+                       bool allWindows;
                        message->FindBool("allwindows", &allWindows);
 
-                       fStringToFind = findIt;
                        fFindAgainItem->SetEnabled(true);
-                       fReplaceString = replaceWith;
                        fReplaceSameItem->SetEnabled(true);
-                       fCaseSens = caseSens;
 
                        if (allWindows)
-                               SearchAllWindows(findIt, replaceWith, caseSens);
+                               SearchAllWindows(fStringToFind, fReplaceString, 
fCaseSens);
                        else    
-                               ReplaceAll(findIt, replaceWith,caseSens);
+                               ReplaceAll(fStringToFind, fReplaceString, 
fCaseSens);
                        break;  
                }
 
@@ -508,70 +493,34 @@
 
                case ALIGN_LEFT:
                        fTextView->SetAlignment(B_ALIGN_LEFT);
-                       fClean = false;
-                       fUndoCleans = false;
-                       fRedoCleans = false;    
-                       fRevertItem->SetEnabled(fSaveMessage != NULL);
-                       fSaveItem->SetEnabled(true);
-                       fUndoItem->SetLabel("Can't Undo");      
-                       fUndoItem->SetEnabled(false);
-                       fCanUndo = false;
-                       fCanRedo = false;
+                       _UpdateCleanUndoRedoSaveRevert();
                        break;
                case ALIGN_CENTER:
                        fTextView->SetAlignment(B_ALIGN_CENTER);
-                       fClean = false;
-                       fUndoCleans = false;
-                       fRedoCleans = false;    
-                       fRevertItem->SetEnabled(fSaveMessage != NULL);
-                       fSaveItem->SetEnabled(true);
-                       fUndoItem->SetLabel("Can't Undo");      
-                       fUndoItem->SetEnabled(false);
-                       fCanUndo = false;
-                       fCanRedo = false;
+                       _UpdateCleanUndoRedoSaveRevert();
                        break;
                case ALIGN_RIGHT:
                        fTextView->SetAlignment(B_ALIGN_RIGHT);
-                       fClean = false;
-                       fUndoCleans = false;
-                       fRedoCleans = false;    
-                       fRevertItem->SetEnabled(fSaveMessage != NULL);
-                       fSaveItem->SetEnabled(true);
-                       fUndoItem->SetLabel("Can't Undo");      
-                       fUndoItem->SetEnabled(false);
-                       fCanUndo = false;
-                       fCanRedo = false;
+                       _UpdateCleanUndoRedoSaveRevert();
                        break;
                case WRAP_LINES:
+               {
+                       BRect textRect(fTextView->Bounds());
+                       textRect.OffsetTo(B_ORIGIN);
+                       textRect.InsetBy(TEXT_INSET,TEXT_INSET);
                        if (fTextView->DoesWordWrap()) {
                                fTextView->SetWordWrap(false);
                                fWrapItem->SetMarked(false);
-                               BRect textRect;
-                               textRect = fTextView->Bounds();
-                               textRect.OffsetTo(B_ORIGIN);
-                               textRect.InsetBy(TEXT_INSET,TEXT_INSET);
                                // the width comes from stylededit R5. TODO: 
find a better way
-                               
textRect.SetRightBottom(BPoint(1500.0,textRect.RightBottom().y));
-                               fTextView->SetTextRect(textRect);
+                               textRect.SetRightBottom(BPoint(1500.0, 
textRect.RightBottom().y));
                        } else {
                                fTextView->SetWordWrap(true);
                                fWrapItem->SetMarked(true);
-                               BRect textRect;
-                               textRect = fTextView->Bounds();
-                               textRect.OffsetTo(B_ORIGIN);
-                               textRect.InsetBy(TEXT_INSET,TEXT_INSET);
-                               fTextView->SetTextRect(textRect);
-                       }       
-                       fClean = false;
-                       fUndoCleans = false;
-                       fRedoCleans = false;    
-                       fRevertItem->SetEnabled(fSaveMessage != NULL);
-                       fSaveItem->SetEnabled(true);
-                       fUndoItem->SetLabel("Can't Undo");      
-                       fUndoItem->SetEnabled(false);
-                       fCanUndo = false;
-                       fCanRedo = false;
-                       break;
+                       }
+                       fTextView->SetTextRect(textRect);
+
+                       _UpdateCleanUndoRedoSaveRevert();
+               }       break;
                case ENABLE_ITEMS:
                        fCutItem->SetEnabled(true);
                        fCopyItem->SetEnabled(true);
@@ -1303,15 +1252,7 @@
        fTextView->Select(textStart,textFinish);
        fTextView->ScrollToSelection();
 
-       fClean = false;
-       fUndoCleans = false;
-       fRedoCleans = false;    
-       fRevertItem->SetEnabled(fSaveMessage != NULL);
-       fSaveItem->SetEnabled(true);
-       fUndoItem->SetLabel("Can't Undo");      
-       fUndoItem->SetEnabled(false);
-       fCanUndo = false;
-       fCanRedo = false;
+       _UpdateCleanUndoRedoSaveRevert();
 }
 
 
@@ -1348,15 +1289,8 @@
        fTextView->GetFontAndColor(&font, &sameProperties);
        font.SetSize(fontSize);
        fTextView->SetFontAndColor(&font, B_FONT_SIZE);
-       fClean = false;
-       fUndoCleans = false;
-       fRedoCleans = false;
-       fRevertItem->SetEnabled(fSaveMessage != NULL);
-       fSaveItem->SetEnabled(true);
-       fUndoItem->SetLabel("Can't Undo");
-       fUndoItem->SetEnabled(false);
-       fCanUndo = false;
-       fCanRedo = false;
+       
+       _UpdateCleanUndoRedoSaveRevert();
 }
 
 
@@ -1368,15 +1302,8 @@
 
        fTextView->GetFontAndColor(&font, &sameProperties, NULL, NULL);
        fTextView->SetFontAndColor(&font, 0, color);
-       fClean = false;
-       fUndoCleans = false;
-       fRedoCleans = false;    
-       fRevertItem->SetEnabled(fSaveMessage != NULL);
-       fSaveItem->SetEnabled(true);
-       fUndoItem->SetLabel("Can't Undo");      
-       fUndoItem->SetEnabled(false);
-       fCanUndo = false;
-       fCanRedo = false;
+
+       _UpdateCleanUndoRedoSaveRevert();
 }
 
 
@@ -1407,6 +1334,12 @@
        if (superItem != NULL)
                superItem->SetMarked(true);
 
+       _UpdateCleanUndoRedoSaveRevert();
+}
+
+void
+StyledEditWindow::_UpdateCleanUndoRedoSaveRevert()
+{
        fClean = false;
        fUndoCleans = false;
        fRedoCleans = false;    
@@ -1417,3 +1350,4 @@
        fCanUndo = false;
        fCanRedo = false;
 }
+
Index: src/apps/stylededit/ReplaceWindow.cpp
===================================================================
--- src/apps/stylededit/ReplaceWindow.cpp       (Revision 22161)
+++ src/apps/stylededit/ReplaceWindow.cpp       (Arbeitskopie)
@@ -7,23 +7,23 @@
  *             Andrew Bachmann
  */
 
-
 #include "Constants.h"
 #include "ReplaceWindow.h"
 
-#include <Messenger.h>
 #include <Button.h>
 #include <CheckBox.h>
+#include <Handler.h>
+#include <Message.h>
+#include <Messenger.h>
+#include <Rect.h>
 #include <String.h>
 #include <TextControl.h>
-#include <Window.h>
+#include <View.h>
 
-
 ReplaceWindow::ReplaceWindow(BRect frame, BHandler *_handler, BString 
*searchString,
-       BString *replaceString, bool *caseState, bool *wrapState, bool 
*backState)
+       BString *replaceString, bool caseState, bool wrapState, bool backState)
        : BWindow(frame, "ReplaceWindow", B_MODAL_WINDOW,
-               B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS,
-               B_CURRENT_WORKSPACE) 
+               B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS, B_CURRENT_WORKSPACE) 
 {
        AddShortcut('W',B_COMMAND_KEY,new BMessage(B_QUIT_REQUESTED));
        
@@ -41,7 +41,7 @@
        fReplaceView->AddChild(fReplaceString = new BTextControl(BRect(5, 35, 
290, 50), "",
                replaceWithLabel, NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP,
                B_WILL_DRAW | B_NAVIGABLE));
-       float maxWidth = (replaceWithWidth > findWidth ? replaceWithWidth : 
findWidth) + 1;
+       float maxWidth = (replaceWithWidth > findWidth ? replaceWithWidth : 
findWidth) + TEXT_INSET;
        fSearchString->SetDivider(maxWidth);
        fReplaceString->SetDivider(maxWidth);
 
@@ -78,16 +78,17 @@
        fReplaceString->SetText(replacetext);
        fSearchString->MakeFocus(true);
 
-       fCaseSensBox->SetValue(*caseState ? B_CONTROL_ON : B_CONTROL_OFF);
-       fWrapBox->SetValue(*wrapState ? B_CONTROL_ON : B_CONTROL_OFF);
-       fBackSearchBox->SetValue(*backState ? B_CONTROL_ON : B_CONTROL_OFF);
+       fCaseSensBox->SetValue(caseState ? B_CONTROL_ON : B_CONTROL_OFF);
+       fWrapBox->SetValue(wrapState ? B_CONTROL_ON : B_CONTROL_OFF);
+       fBackSearchBox->SetValue(backState ? B_CONTROL_ON : B_CONTROL_OFF);
 }
 
 
 void
 ReplaceWindow::MessageReceived(BMessage *msg)
 {
-       switch (msg->what){
+       switch (msg->what)
+       {
                case MSG_REPLACE:
                        _SendMessage(MSG_REPLACE);
                        break;
@@ -108,22 +109,16 @@
 void
 ReplaceWindow::_ChangeUI()
 {
-       if (!fUIchange) {
-               fReplaceAllButton->MakeDefault(true);
-               fReplaceButton->SetEnabled(false);
-               fWrapBox->SetValue(B_CONTROL_ON);
-               fWrapBox->SetEnabled(false);
-               fBackSearchBox->SetEnabled(false);
-               fUIchange = true;
-       } else {
-               fReplaceButton->MakeDefault(true);
-               fReplaceButton->SetEnabled(true);
-               fReplaceAllButton->SetEnabled(true);
-               fWrapBox->SetValue(B_CONTROL_OFF);
-               fWrapBox->SetEnabled(true);
-               fBackSearchBox->SetEnabled(true);
-               fUIchange = false;
-       }
+       fWrapBox->SetEnabled(fUIchange);        
+       fWrapBox->SetValue(fUIchange ? B_CONTROL_OFF : B_CONTROL_ON);
+       
+       fBackSearchBox->SetEnabled(fUIchange);
+
+       fReplaceButton->SetEnabled(fUIchange);
+       fUIchange ? fReplaceButton->MakeDefault(true)
+                 : fReplaceAllButton->MakeDefault(true);
+
+       fUIchange = !fUIchange;
 }
 
 
Index: src/apps/stylededit/StyledEditView.cpp
===================================================================
--- src/apps/stylededit/StyledEditView.cpp      (Revision 22161)
+++ src/apps/stylededit/StyledEditView.cpp      (Arbeitskopie)
@@ -8,31 +8,29 @@
  *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
  */
 
-
 #include "Constants.h"
 #include "StyledEditView.h"
 
+#include <CharacterSet.h>
+#include <CharacterSetRoster.h>
+#include <DataIO.h>
+#include <File.h>
 #include <Message.h>
 #include <Messenger.h>
+#include <Node.h>
 #include <Rect.h>
-#include <Region.h>
 #include <TranslationUtils.h>
-#include <Node.h>
+#include <UTF8.h>
+
 #include <stdio.h>
 #include <stdlib.h>
-#include <CharacterSet.h>
-#include <CharacterSetRoster.h>
-#include <UTF8.h>
 
-
 using namespace BPrivate;
 
-
 StyledEditView::StyledEditView(BRect viewFrame, BRect textBounds, BHandler 
*handler)
        : BTextView(viewFrame, "textview", textBounds, 
                B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW)
 { 
-       fHandler = handler;
        fMessenger = new BMessenger(handler);
        fSuppressChanges = false;
 }
@@ -45,35 +43,22 @@
 
 
 void
-StyledEditView::FrameResized(float width, float height)
+StyledEditView::Select(int32 start, int32 finish)
 {
-       BTextView::FrameResized(width, height);
+       fMessenger->SendMessage(start == finish ? DISABLE_ITEMS : ENABLE_ITEMS);
 
-       if (DoesWordWrap()) {
-               BRect textRect;
-               textRect = Bounds();
-               textRect.OffsetTo(B_ORIGIN);
-               textRect.InsetBy(TEXT_INSET, TEXT_INSET);
-               SetTextRect(textRect);
-       }
+       BTextView::Select(start, finish);
+}
 
-/*     // I tried to do some sort of intelligent resize thing but it just 
doesn't work
-       // so we revert to the R5 stylededit yucky practice of setting the text 
rect to
-       // some crazy large number when word wrap is turned off :-(
-        else if (textRect.Width() > TextRect().Width()) {
-               SetTextRect(textRect);
-       }
 
-       BRegion region;
-       GetTextRegion(0,TextLength(),&region);
-       float textWidth = region.Frame().Width();
-       if (textWidth < textRect.Width()) {
-               BRect 
textRect(B_ORIGIN,BPoint(textWidth+TEXT_INSET*2,Bounds().Height()));
-               textRect.InsetBy(TEXT_INSET,TEXT_INSET);
-               SetTextRect(textRect);
-       }
-       */
-}                              
+void
+StyledEditView::Reset()
+{
+       fSuppressChanges = true;
+       SetText("");
+       fEncoding = "";
+       fSuppressChanges = false;
+}
 
 
 status_t
@@ -145,38 +130,17 @@
 
 
 void
-StyledEditView::Reset()
-{
-       fSuppressChanges = true;
-       SetText("");
-       fEncoding = "";
-       fSuppressChanges = false;
-}
-
-
-void
-StyledEditView::Select(int32 start, int32 finish)
-{
-       fChangeMessage = new BMessage(start == finish ? DISABLE_ITEMS : 
ENABLE_ITEMS);
-       fMessenger->SendMessage(fChangeMessage);
-
-       BTextView::Select(start, finish);
-}
-
-
-void
 StyledEditView::SetEncoding(uint32 encoding)
 {
-       if (encoding == 0) {
-               fEncoding = "";
+       fEncoding = "";
+       if (encoding == 0)
                return;
-       }
 
-       const BCharacterSet* set = 
BCharacterSetRoster::GetCharacterSetByFontID(encoding);
+       const BCharacterSet* set 
+               = BCharacterSetRoster::GetCharacterSetByFontID(encoding);
+
        if (set != NULL)
                fEncoding = set->GetName();
-       else
-               fEncoding = "";
 }
 
 
@@ -186,8 +150,9 @@
        if (fEncoding == "")
                return 0;
 
-       const BCharacterSet* set = 
BCharacterSetRoster::FindCharacterSetByName(fEncoding.String());
-       if (set != NULL)
+       const BCharacterSet* set = 
+               BCharacterSetRoster::FindCharacterSetByName(fEncoding.String());
+       if(set != NULL)
                return set->GetFontID();
 
        return 0;
@@ -195,22 +160,37 @@
 
 
 void
+StyledEditView::DeleteText(int32 start, int32 finish)
+{
+       if (!fSuppressChanges)
+               fMessenger-> SendMessage(TEXT_CHANGED);
+
+       BTextView::DeleteText(start, finish);
+}
+
+
+void
 StyledEditView::InsertText(const char *text, int32 length, int32 offset,
        const text_run_array *runs)
 {
        if (!fSuppressChanges)
-               fMessenger->SendMessage(new BMessage(TEXT_CHANGED));
+               fMessenger->SendMessage(TEXT_CHANGED);
 
        BTextView::InsertText(text, length, offset, runs);      
 }
 
 
 void
-StyledEditView::DeleteText(int32 start, int32 finish)
+StyledEditView::FrameResized(float width, float height)
 {
-       if (!fSuppressChanges)
-               fMessenger-> SendMessage(new BMessage(TEXT_CHANGED));
+       BTextView::FrameResized(width, height);
 
-       BTextView::DeleteText(start, finish);
-}
+       if (DoesWordWrap()) {
+               BRect textRect;
+               textRect = Bounds();
+               textRect.OffsetTo(B_ORIGIN);
+               textRect.InsetBy(TEXT_INSET, TEXT_INSET);
+               SetTextRect(textRect);
+       }
+}                              
 
Index: src/apps/stylededit/StyledEditWindow.h
===================================================================
--- src/apps/stylededit/StyledEditWindow.h      (Revision 22161)
+++ src/apps/stylededit/StyledEditWindow.h      (Arbeitskopie)
@@ -6,108 +6,114 @@
  *             Mattias Sundblad
  *             Andrew Bachmann
  */
+
 #ifndef STYLED_EDIT_WINDOW_H
 #define STYLED_EDIT_WINDOW_H
 
-
-#include <FilePanel.h>
-#include <MenuBar.h>
+#include <Window.h>
+#include <String.h>
 #include <Message.h>
-#include <Rect.h>
-#include <String.h>
-#include <TextView.h>
-#include <Window.h>
 
+struct entry_ref;
 
+class BMenu;
+class BMessage;
+class BMenuBar;
+class BMenuItem;
+class BFilePanel;
+class BScrollView;
 class StyledEditView;
 
-class StyledEditWindow : public BWindow {
+class StyledEditWindow : public BWindow 
+{
        public:
-                                               StyledEditWindow(BRect frame, 
int32 id, uint32 encoding = 0);
-                                               StyledEditWindow(BRect frame, 
entry_ref *ref, uint32 encoding = 0);
-               virtual                 ~StyledEditWindow();
+                               StyledEditWindow(BRect frame, int32 id, uint32 
encoding = 0);
+                               StyledEditWindow(BRect frame, entry_ref *ref, 
uint32 encoding = 0);
+                               ~StyledEditWindow();
        
-               virtual void    Quit();
-               virtual bool    QuitRequested();
-               virtual void    MessageReceived(BMessage *message);
-               virtual void    MenusBeginning();
+               void            Quit();
+               bool            QuitRequested();
+               void            MessageReceived(BMessage *message);
+               void            MenusBeginning();
 
-               status_t                Save(BMessage *message = 0);
-               status_t                SaveAs(BMessage *message = 0);
-               void                    OpenFile(entry_ref *ref); 
-               status_t                PageSetup(const char *documentname);
-               void                    Print(const char *documentname);
-               void                    SearchAllWindows(BString find, BString 
replace, bool casesens);
+               status_t        Save(BMessage *message = 0);
+               status_t        SaveAs(BMessage *message = 0);
+               void            OpenFile(entry_ref *ref); 
+               status_t        PageSetup(const char *documentname);
+               void            Print(const char *documentname);
+               void            SearchAllWindows(BString find, BString replace, 
bool casesens);
 
        private: 
-               void                    InitWindow(uint32 encoding = 0);
-               bool                    Search(BString searchfor, bool 
casesens, bool wrap, bool backsearch);
-               void                    FindSelection();
-               bool                    Replace(BString findthis, BString 
replacewith, bool casesens, bool wrap, bool backsearch);
-               void                    ReplaceAll(BString find, BString 
replace, bool casesens);
-               void                    SetFontSize(float fontSize);
-               void                    SetFontColor(const rgb_color *color);
-               void                    SetFontStyle(const char *fontFamily, 
const char *fontStyle);
-               status_t                _LoadFile(entry_ref* ref);
-               void                    RevertToSaved();
+               void            InitWindow(uint32 encoding = 0);
+               bool            Search(BString searchfor, bool casesens, bool 
wrap, bool backsearch);
+               void            FindSelection();
+               bool            Replace(BString findthis, BString replacewith, 
bool casesens, 
+                                       bool wrap, bool backsearch);
+               void            ReplaceAll(BString find, BString replace, bool 
casesens);
+               void            SetFontSize(float fontSize);
+               void            SetFontColor(const rgb_color *color);
+               void            SetFontStyle(const char *fontFamily, const char 
*fontStyle);
+               status_t        _LoadFile(entry_ref* ref);
+               void            RevertToSaved();
+               void            _UpdateCleanUndoRedoSaveRevert();
 
-               BMenuBar                *fMenuBar;
-               BMessage                *fPrintSettings;
-               BMessage                *fSaveMessage; 
-               BMenu                   *fRecentMenu;
+               BMenuBar        *fMenuBar;
+               BMessage        *fPrintSettings;
+               BMessage        *fSaveMessage; 
+               BMenu           *fRecentMenu;
 
-               BMenu                   *fFontMenu;
-               BMenu                   *fFontSizeMenu;
-               BMenu                   *fFontColorMenu;
-               BMenuItem               *fCurrentFontItem;
+               BMenu           *fFontMenu;
+               BMenu           *fFontSizeMenu;
+               BMenu           *fFontColorMenu;
+               BMenuItem       *fCurrentFontItem;
 
-               BMenuItem               *fSaveItem;
-               BMenuItem               *fRevertItem;
+               BMenuItem       *fSaveItem;
+               BMenuItem       *fRevertItem;
 
-               BMenuItem               *fUndoItem;
-               BMenuItem               *fCutItem;
-               BMenuItem               *fCopyItem;
-               BMenuItem               *fClearItem;
+               BMenuItem       *fUndoItem;
+               BMenuItem       *fCutItem;
+               BMenuItem       *fCopyItem;
+               BMenuItem       *fClearItem;
 
-               BMenuItem               *fFindAgainItem;
-               BMenuItem               *fReplaceSameItem;
+               BMenuItem       *fFindAgainItem;
+               BMenuItem       *fReplaceSameItem;
 
-               BMenuItem               *fBlackItem;
-               BMenuItem               *fRedItem;
-               BMenuItem               *fGreenItem;
-               BMenuItem               *fBlueItem;
-               BMenuItem               *fCyanItem;
-               BMenuItem               *fMagentaItem;
-               BMenuItem               *fYellowItem;
+               BMenuItem       *fBlackItem;
+               BMenuItem       *fRedItem;
+               BMenuItem       *fGreenItem;
+               BMenuItem       *fBlueItem;
+               BMenuItem       *fCyanItem;
+               BMenuItem       *fMagentaItem;
+               BMenuItem       *fYellowItem;
 
-               BMenuItem               *fWrapItem;
-               BMenuItem               *fAlignLeft;
-               BMenuItem               *fAlignCenter;
-               BMenuItem               *fAlignRight;
+               BMenuItem       *fWrapItem;
+               BMenuItem       *fAlignLeft;
+               BMenuItem       *fAlignCenter;
+               BMenuItem       *fAlignRight;
 
                BString         fStringToFind;
-               BString                 fReplaceString;
+               BString         fReplaceString;
 
                // undo modes
-               bool                    fUndoFlag;   // we just did an undo 
action
-               bool                    fCanUndo;    // we can do an undo 
action next
-               bool                    fRedoFlag;   // we just did a redo 
action
-               bool                    fCanRedo;    // we can do a redo action 
next
+               bool            fUndoFlag;   // we just did an undo action
+               bool            fCanUndo;    // we can do an undo action next
+               bool            fRedoFlag;   // we just did a redo action
+               bool            fCanRedo;    // we can do a redo action next
 
                // clean modes
-               bool                    fUndoCleans; // an undo action will put 
us in a clean state
-               bool                    fRedoCleans; // a redo action will put 
us in a clean state
-               bool                    fClean;      // we are in a clean state
+               bool            fUndoCleans; // an undo action will put us in a 
clean state
+               bool            fRedoCleans; // a redo action will put us in a 
clean state
+               bool            fClean;      // we are in a clean state
 
-               bool                    fCaseSens;
-               bool                    fWrapAround;
-               bool                    fBackSearch;
+               bool            fCaseSens;
+               bool            fWrapAround;
+               bool            fBackSearch;
 
-               StyledEditView  *fTextView;
-               BScrollView             *fScrollView;
+               StyledEditView  *fTextView;
+               BScrollView     *fScrollView;
 
-               BFilePanel              *fSavePanel;
-               BMenu                   *fSavePanelEncodingMenu;
+               BFilePanel      *fSavePanel;
+               BMenu           *fSavePanelEncodingMenu;
 };
 
 #endif // STYLED_EDIT_WINDOW_H
Index: src/apps/stylededit/FindWindow.cpp
===================================================================
--- src/apps/stylededit/FindWindow.cpp  (Revision 22161)
+++ src/apps/stylededit/FindWindow.cpp  (Arbeitskopie)
@@ -7,7 +7,6 @@
  *             Andrew Bachmann
  */
 
-
 #include "Constants.h"
 #include "FindWindow.h"
 
@@ -16,12 +15,10 @@
 #include <String.h>
 #include <TextControl.h>
 
-
 FindWindow::FindWindow(BRect frame, BHandler *_handler, BString *searchString,
-       bool *caseState, bool *wrapState, bool *backState)
+       bool caseState, bool wrapState, bool backState)
        : BWindow(frame, "FindWindow", B_MODAL_WINDOW,
-               B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS,
-               B_CURRENT_WORKSPACE)
+               B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS, B_CURRENT_WORKSPACE)
 {
        AddShortcut('W',B_COMMAND_KEY,new BMessage(B_QUIT_REQUESTED));
        
@@ -31,7 +28,7 @@
 
        font_height height;
        fFindView->GetFontHeight(&height);
-       float lineHeight = height.ascent+height.descent + height.leading;
+       float lineHeight = height.ascent + height.descent + height.leading;
 
        float findWidth = fFindView->StringWidth("Find:") + 6;
 
@@ -65,12 +62,12 @@
 
        const char *text = searchString->String();
 
-    fSearchString->SetText(text);
+       fSearchString->SetText(text);
        fSearchString->MakeFocus(true);
 
-       fCaseSensBox->SetValue(*caseState ? B_CONTROL_ON : B_CONTROL_OFF);
-       fWrapBox->SetValue(*wrapState ? B_CONTROL_ON : B_CONTROL_OFF);
-       fBackSearchBox->SetValue(*backState ? B_CONTROL_ON : B_CONTROL_OFF);
+       fCaseSensBox->SetValue(caseState ? B_CONTROL_ON : B_CONTROL_OFF);
+       fWrapBox->SetValue(wrapState ? B_CONTROL_ON : B_CONTROL_OFF);
+       fBackSearchBox->SetValue(backState ? B_CONTROL_ON : B_CONTROL_OFF);
 }
 
 
Index: src/apps/stylededit/ReplaceWindow.h
===================================================================
--- src/apps/stylededit/ReplaceWindow.h (Revision 22161)
+++ src/apps/stylededit/ReplaceWindow.h (Arbeitskopie)
@@ -6,45 +6,47 @@
  *             Mattias Sundblad
  *             Andrew Bachmann
  */
+
 #ifndef REPLACE_WINDOW_H 
 #define REPLACE_WINDOW_H 
 
-
 #include <Window.h>
-#include <Rect.h>
-#include <Handler.h>
-#include <String.h>
-#include <Message.h>
-#include <View.h>
-#include <TextControl.h>
-#include <CheckBox.h>
-#include <Button.h>
 
+class BView;
+class BString;
+class BButton;
+class BHandler;
+class BMessage;
+class BCheckBox;
+class BTextControl;
 
-class ReplaceWindow : public BWindow {
+class ReplaceWindow : public BWindow 
+{
        public:
-               ReplaceWindow(BRect frame, BHandler *_handler,BString 
*searchString,
-                       BString *replaceString, bool *caseState, bool 
*wrapState, bool *backState);
+                               ReplaceWindow(BRect frame, BHandler *_handler,
+                                       BString *searchString, BString 
*replaceString,
+                                       bool caseState, bool wrapState, bool 
backState);
 
-               virtual void MessageReceived(BMessage* message);
-               virtual void DispatchMessage(BMessage* message, BHandler 
*handler);
+               void            MessageReceived(BMessage* message);
+               void            DispatchMessage(BMessage* message, BHandler 
*handler);
 
        private:
-               void _SendMessage(uint32 what);
-               void _ChangeUI();               
+               void            _SendMessage(uint32 what);
+               void            _ChangeUI();            
 
-               BView                   *fReplaceView;
+               BView           *fReplaceView;
                BTextControl    *fSearchString;
                BTextControl    *fReplaceString;
-               BCheckBox               *fCaseSensBox;
-               BCheckBox               *fWrapBox;
-               BCheckBox               *fBackSearchBox;
-               BCheckBox               *fAllWindowsBox;
-               BButton                 *fReplaceButton;
-               BButton                 *fReplaceAllButton;
-               BButton                 *fCancelButton;
-               BHandler                *fHandler;
-               bool                    fUIchange;
+               BCheckBox       *fCaseSensBox;
+               BCheckBox       *fWrapBox;
+               BCheckBox       *fBackSearchBox;
+               BCheckBox       *fAllWindowsBox;
+               BButton         *fReplaceButton;
+               BButton         *fReplaceAllButton;
+               BButton         *fCancelButton;
+               BHandler        *fHandler;
+               bool            fUIchange;
 };
 
 #endif // REPLACE_WINDOW_H
+
Index: src/apps/stylededit/StyledEditView.h
===================================================================
--- src/apps/stylededit/StyledEditView.h        (Revision 22161)
+++ src/apps/stylededit/StyledEditView.h        (Arbeitskopie)
@@ -7,41 +7,43 @@
  *             Andrew Bachmann
  *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
  */
+
 #ifndef STYLED_EDIT_VIEW_H
 #define STYLED_EDIT_VIEW_H
 
-
-#include <File.h>
-#include <DataIO.h>
 #include <String.h>
 #include <TextView.h>
 
+class BFile;
+class BHandler;
+class BMessanger;
 
 class StyledEditView : public BTextView {
        public:
-               StyledEditView(BRect viewframe, BRect textframe, BHandler 
*handler);
-               virtual ~StyledEditView();
+                               StyledEditView(BRect viewframe, BRect 
textframe, 
+                                       BHandler *handler);
+                               ~StyledEditView();
 
-               virtual void Select(int32 start, int32 finish);
-               virtual void FrameResized(float width, float height);
+               void            Select(int32 start, int32 finish);
        
-               virtual void Reset();
-               virtual status_t GetStyledText(BPositionIO * stream);
-               virtual status_t WriteStyledEditFile(BFile * file);
+               void            Reset();
+               status_t        GetStyledText(BPositionIO * stream);
+               status_t        WriteStyledEditFile(BFile * file);
 
-               virtual void SetEncoding(uint32 encoding);
-               virtual uint32 GetEncoding() const;
+               void            SetEncoding(uint32 encoding);
+               uint32          GetEncoding() const;
 
-       protected:
-               virtual void InsertText(const char *text, int32 length, int32 
offset, const text_run_array *runs = NULL);
-               virtual void DeleteText(int32 start, int32 finish);
-                       
        private:
-               BHandler        *fHandler;
-               BMessage        *fChangeMessage;
+               void            DeleteText(int32 start, int32 finish);
+               void            FrameResized(float width, float height);
+               void            InsertText(const char *text, int32 length, 
int32 offset, 
+                                       const text_run_array *runs = NULL);
+
+       private:
                BMessenger      *fMessenger;
                bool            fSuppressChanges;
                BString         fEncoding;
 };
 
 #endif // STYLED_EDIT_VIEW_H
+
Index: src/apps/stylededit/StyledEditApp.cpp
===================================================================
--- src/apps/stylededit/StyledEditApp.cpp       (Revision 22161)
+++ src/apps/stylededit/StyledEditApp.cpp       (Arbeitskopie)
@@ -7,62 +7,68 @@
  *             Andrew Bachmann
  */
 
+#include "Constants.h"
+#include "StyledEditApp.h"
+#include "StyledEditWindow.h"
 
 #include <Alert.h>
 #include <Autolock.h>
-#include <Path.h>
-#include <MenuItem.h>
+#include <MenuBar.h>
 #include <CharacterSet.h>
 #include <CharacterSetRoster.h>
+#include <FilePanel.h>
+#include <MenuItem.h>
+#include <Message.h>
+#include <Path.h>
 #include <Screen.h>
+
 #include <stdio.h>
 
-#include "Constants.h"
-#include "StyledEditApp.h"
-#include "StyledEditWindow.h"
-
 using namespace BPrivate;
 
 StyledEditApp * styled_edit_app;
 BRect gWindowRect(7-15, 26-15, 507, 426);
 
 
-void
-cascade()
+namespace 
 {
-       BScreen screen(NULL);
-       BRect screenBorder = screen.Frame();
-       float left = gWindowRect.left + 15;
-       if (left + gWindowRect.Width() > screenBorder.right)
-               left = 7;
+       void
+       cascade()
+       {
+               BScreen screen(NULL);
+               BRect screenBorder = screen.Frame();
+               float left = gWindowRect.left + 15;
+               if (left + gWindowRect.Width() > screenBorder.right)
+                       left = 7;
 
-       float top = gWindowRect.top + 15;
-       if (top + gWindowRect.Height() > screenBorder.bottom)
-               top = 26;
+               float top = gWindowRect.top + 15;
+               if (top + gWindowRect.Height() > screenBorder.bottom)
+                       top = 26;
 
-       gWindowRect.OffsetTo(BPoint(left,top)); 
-}
+               gWindowRect.OffsetTo(BPoint(left,top)); 
+       }
 
 
-void
-uncascade()
-{
-       BScreen screen(NULL);
-       BRect screenBorder = screen.Frame();
+       void
+       uncascade()
+       {
+               BScreen screen(NULL);
+               BRect screenBorder = screen.Frame();
 
-       float left = gWindowRect.left - 15;
-       if (left < 7) {
-               left = screenBorder.right - gWindowRect.Width() - 7;
-               left = left - ((int)left % 15) + 7;
-       }
+               float left = gWindowRect.left - 15;
+               if (left < 7) {
+                       left = screenBorder.right - gWindowRect.Width() - 7;
+                       left = left - ((int)left % 15) + 7;
+               }
 
-       float top = gWindowRect.top - 15;
-       if (top < 26) {
-               top = screenBorder.bottom - gWindowRect.Height() - 26;
-               top = top - ((int)left % 15) + 26;
+               float top = gWindowRect.top - 15;
+               if (top < 26) {
+                       top = screenBorder.bottom - gWindowRect.Height() - 26;
+                       top = top - ((int)left % 15) + 26;
+               }
+
+               gWindowRect.OffsetTo(BPoint(left,top)); 
        }
-
-       gWindowRect.OffsetTo(BPoint(left,top)); 
 }
 
 
@@ -71,9 +77,10 @@
 
 StyledEditApp::StyledEditApp()
        : BApplication(APP_SIGNATURE)
+       , fOpenPanel(NULL)
 {
-       fOpenPanel= new BFilePanel();
-       BMenuBar * menuBar =
+       fOpenPanel = new BFilePanel();
+       BMenuBar *menuBar =
                
dynamic_cast<BMenuBar*>(fOpenPanel->Window()->FindView("MenuBar"));
 
        fOpenAsEncoding = 0;
@@ -110,6 +117,12 @@
 }
 
 
+StyledEditApp::~StyledEditApp()
+{
+       delete fOpenPanel;
+}
+
+
 void
 StyledEditApp::DispatchMessage(BMessage *msg, BHandler *handler)
 {
@@ -128,7 +141,7 @@
                if (msg->FindString("cwd", &cwd) != B_OK)
                        cwd = "";
 
-               ArgvReceived(argc, argv, cwd);
+               ArgvReceivedEx(argc, argv, cwd);
        } else
                BApplication::DispatchMessage(msg, handler);
 }
@@ -137,7 +150,8 @@
 void
 StyledEditApp::MessageReceived(BMessage *message)
 {
-       switch (message->what) {
+       switch (message->what)
+       {
                case MENU_NEW:
                        OpenDocument();
                        break;
@@ -205,7 +219,7 @@
 
 
 void
-StyledEditApp::ArgvReceived(int32 argc, const char* argv[], const char* cwd)
+StyledEditApp::ArgvReceivedEx(int32 argc, const char* argv[], const char* cwd)
 {
        for (int i = 1 ; (i < argc) ; i++) {
                BPath path;
Index: src/apps/stylededit/FindWindow.h
===================================================================
--- src/apps/stylededit/FindWindow.h    (Revision 22161)
+++ src/apps/stylededit/FindWindow.h    (Arbeitskopie)
@@ -6,10 +6,10 @@
  *             Mattias Sundblad
  *             Andrew Bachmann
  */
+
 #ifndef FIND_WINDOW_H 
 #define FIND_WINDOW_H 
 
-
 #include <Window.h>
 
 class BButton;
@@ -17,27 +17,26 @@
 class BTextControl;
 class BView;
 
-
 class FindWindow : public BWindow {
        public:
-               FindWindow(BRect frame, BHandler* handler, BString 
*searchString,
-                       bool *caseState, bool *wrapState, bool *backState);
+                               FindWindow(BRect frame, BHandler* handler, 
BString *searchString,
+                                       bool caseState, bool wrapState, bool 
backState);
 
-               virtual void MessageReceived(BMessage* message);
-               virtual void DispatchMessage(BMessage* message, BHandler* 
handler);
+               void            MessageReceived(BMessage* message);
+               void            DispatchMessage(BMessage* message, BHandler* 
handler);
 
        private:
-               void _SendMessage();
+               void            _SendMessage();
 
-               BView                   *fFindView;
+               BView           *fFindView;
                BTextControl    *fSearchString;
-               BCheckBox               *fCaseSensBox;
-               BCheckBox               *fWrapBox;
-               BCheckBox               *fBackSearchBox;
-               BButton                 *fCancelButton;
-               BButton                 *fSearchButton;
+               BCheckBox       *fCaseSensBox;
+               BCheckBox       *fWrapBox;
+               BCheckBox       *fBackSearchBox;
+               BButton         *fCancelButton;
+               BButton         *fSearchButton;
 
-               BHandler                *fHandler;
+               BHandler        *fHandler;
 };
 
 #endif // FIND_WINDOW_H
Index: src/apps/stylededit/StyledEditApp.h
===================================================================
--- src/apps/stylededit/StyledEditApp.h (Revision 22161)
+++ src/apps/stylededit/StyledEditApp.h (Arbeitskopie)
@@ -6,41 +6,50 @@
  *             Mattias Sundblad
  *             Andrew Bachmann
  */
+
 #ifndef STYLED_EDIT_APP
 #define STYLED_EDIT_APP
 
-
 #include <Application.h>
-#include <Message.h>
-#include <FilePanel.h>
 
+struct entry_ref;
 
+class BMenu;
+class BHandler;
+class BMessage;
+class BFilePanel;
 class StyledEditWindow;
 
-class StyledEditApp : public BApplication {
+class StyledEditApp : public BApplication 
+{
        public:
-                                               StyledEditApp();
-               virtual void    MessageReceived(BMessage *message);
-                               void    ArgvReceived(int32 argc, const char 
*argv[], const char * cwd);
-               virtual void    RefsReceived(BMessage *message);
-               virtual void    ReadyToRun();
+                               StyledEditApp();
+                               ~StyledEditApp();
 
-               virtual void    DispatchMessage(BMessage *an_event, BHandler 
*handler);
+               void            MessageReceived(BMessage *message);
+               void            RefsReceived(BMessage *message);
+               void            ReadyToRun();
 
-                               int32   NumberOfWindows();
-                               void    OpenDocument();
-                               void    OpenDocument(entry_ref * ref);
-                               void    CloseDocument();
+               void            DispatchMessage(BMessage *an_event, BHandler 
*handler);
 
+               int32           NumberOfWindows();
+               void            OpenDocument();
+               void            OpenDocument(entry_ref * ref);
+               void            CloseDocument();
+
        private:
-               BFilePanel*             fOpenPanel;
-               BMenu*                  fOpenPanelEncodingMenu;
-               uint32                  fOpenAsEncoding;
-               int32                   fWindowCount;
-               int32                   fNextUntitledWindow;
+               void            ArgvReceivedEx(int32 argc, const char *argv[], 
const char * cwd);
+
+       private:
+               BFilePanel      *fOpenPanel;
+               BMenu           *fOpenPanelEncodingMenu;
+               uint32          fOpenAsEncoding;
+               int32           fWindowCount;
+               int32           fNextUntitledWindow;
                
 };
 
 extern StyledEditApp* styled_edit_app;
 
 #endif // STYLED_EDIT_APP
+
Index: src/apps/stylededit/Constants.h
===================================================================
--- src/apps/stylededit/Constants.h     (Revision 22161)
+++ src/apps/stylededit/Constants.h     (Arbeitskopie)
@@ -6,14 +6,13 @@
  *             Mattias Sundblad
  *             Andrew Bachmann
  */
+
 #ifndef CONSTANTS_H
 #define CONSTANTS_H
 
-
 #include <GraphicsDefs.h>
 #include <SupportDefs.h>
 
-
 #define APP_SIGNATURE  "application/x-vnd.Haiku-StyledEdit"
 
 const float TEXT_INSET = 3.0;
@@ -21,58 +20,59 @@
 // Messages for menu commands
 
 // file menu
-const uint32 MENU_NEW                                  = 'MFnw';
-const uint32 MENU_OPEN                                 = 'MFop';
-const uint32 MENU_SAVE                                 = 'MSav';
-const uint32 MENU_SAVEAS                               = 'MEsa';
-const uint32 MENU_REVERT                               = 'MFre'; 
-const uint32 MENU_CLOSE                                        = 'MFcl';
-const uint32 MENU_PAGESETUP                            = 'MFps';
-const uint32 MENU_PRINT                                        = 'MFpr';
-const uint32 MENU_QUIT                                 = 'MFqu';
+const uint32 MENU_NEW                  = 'MFnw';
+const uint32 MENU_OPEN                 = 'MFop';
+const uint32 MENU_SAVE                 = 'MSav';
+const uint32 MENU_SAVEAS               = 'MEsa';
+const uint32 MENU_REVERT               = 'MFre'; 
+const uint32 MENU_CLOSE                        = 'MFcl';
+const uint32 MENU_PAGESETUP            = 'MFps';
+const uint32 MENU_PRINT                        = 'MFpr';
+const uint32 MENU_QUIT                 = 'MFqu';
 
 // edit menu
-const uint32 MENU_CLEAR                                        = 'MEcl';
-const uint32 MENU_FIND                                 = 'MEfi';
-const uint32 MENU_FIND_AGAIN                   = 'MEfa';
-const uint32 MENU_FIND_SELECTION               = 'MEfs';
-const uint32 MENU_REPLACE                              = 'MEre';
-const uint32 MENU_REPLACE_SAME                 = 'MErs';
+const uint32 MENU_CLEAR                        = 'MEcl';
+const uint32 MENU_FIND                 = 'MEfi';
+const uint32 MENU_FIND_AGAIN           = 'MEfa';
+const uint32 MENU_FIND_SELECTION       = 'MEfs';
+const uint32 MENU_REPLACE              = 'MEre';
+const uint32 MENU_REPLACE_SAME         = 'MErs';
 
-const uint32 MSG_SEARCH                                        = 'msea';
-const uint32 MSG_REPLACE                               = 'msre';
-const uint32 MSG_REPLACE_ALL                   = 'mrea';
+const uint32 MSG_SEARCH                        = 'msea';
+const uint32 MSG_REPLACE               = 'msre';
+const uint32 MSG_REPLACE_ALL           = 'mrea';
 
 // "Font"-menu
-const uint32 FONT_SIZE                                 = 'FMsi';
-const uint32 FONT_FAMILY                               = 'FFch';
-const uint32 FONT_STYLE                                        = 'FSch';
-const uint32 FONT_COLOR                                        = 'Fcol';
+const uint32 FONT_SIZE                 = 'FMsi';
+const uint32 FONT_FAMILY               = 'FFch';
+const uint32 FONT_STYLE                        = 'FSch';
+const uint32 FONT_COLOR                        = 'Fcol';
 
 // fontcolors
-const rgb_color        BLACK                                   = {0, 0, 0, 
255};
-const rgb_color        RED                                     = {255, 0, 0, 
255};
-const rgb_color        GREEN                                   = {0, 255, 0, 
255};
-const rgb_color        BLUE                                    = {0, 0, 255, 
255};
-const rgb_color        CYAN                                    = {0, 255, 255, 
255};
-const rgb_color        MAGENTA                                 = {255, 0, 255, 
255};
-const rgb_color        YELLOW                                  = {255, 255, 0, 
255};
+const rgb_color        BLACK                   = {0, 0, 0, 255};
+const rgb_color        RED                     = {255, 0, 0, 255};
+const rgb_color        GREEN                   = {0, 255, 0, 255};
+const rgb_color        BLUE                    = {0, 0, 255, 255};
+const rgb_color        CYAN                    = {0, 255, 255, 255};
+const rgb_color        MAGENTA                 = {255, 0, 255, 255};
+const rgb_color        YELLOW                  = {255, 255, 0, 255};
 
 // "Document"-menu
-const uint32 ALIGN_LEFT                                        = 'ALle';
-const uint32 ALIGN_CENTER                              = 'ALce';
-const uint32 ALIGN_RIGHT                               = 'ALri';
-const uint32 WRAP_LINES                                        = 'MDwr';
+const uint32 ALIGN_LEFT                        = 'ALle';
+const uint32 ALIGN_CENTER              = 'ALce';
+const uint32 ALIGN_RIGHT               = 'ALri';
+const uint32 WRAP_LINES                        = 'MDwr';
 
 // enables "edit" menuitems
-const uint32 ENABLE_ITEMS                              = 'ENit';
-const uint32 DISABLE_ITEMS                             = 'DIit';
-const uint32 CHANGE_WINDOW                             = 'CHwi'; 
-const uint32 TEXT_CHANGED                              = 'TEch';
+const uint32 ENABLE_ITEMS              = 'ENit';
+const uint32 DISABLE_ITEMS             = 'DIit';
+const uint32 CHANGE_WINDOW             = 'CHwi'; 
+const uint32 TEXT_CHANGED              = 'TEch';
 
 // file panel constants
-const uint32 OPEN_AS_ENCODING                  = 'FPoe';
-const uint32 SAVE_AS_ENCODING                  = 'FPse';
-const uint32 SAVE_THEN_QUIT                            = 'FPsq';
+const uint32 OPEN_AS_ENCODING          = 'FPoe';
+const uint32 SAVE_AS_ENCODING          = 'FPse';
+const uint32 SAVE_THEN_QUIT            = 'FPsq';
 
 #endif // CONSTANTS_H
+
Index: src/apps/stylededit/ColorMenuItem.cpp
===================================================================
--- src/apps/stylededit/ColorMenuItem.cpp       (Revision 22161)
+++ src/apps/stylededit/ColorMenuItem.cpp       (Arbeitskopie)
@@ -7,14 +7,14 @@
  *             Andrew Bachmann
  */
 
-
 #include "ColorMenuItem.h"
 
+#include <Message.h>
 
 ColorMenuItem::ColorMenuItem(const char        *label, rgb_color color, 
BMessage *message)
        : BMenuItem(label, message, 0, 0)
+       , fItemColor(color)
 {
-       fItemColor = color;
 }
 
 
@@ -22,9 +22,11 @@
 ColorMenuItem::DrawContent()
 {
        BMenu *menu = Menu();
-       rgb_color menuColor = menu->HighColor();
+       if (NULL != menu) {
+               rgb_color menuColor = menu->HighColor();
 
-       menu->SetHighColor(fItemColor);
-       BMenuItem::DrawContent();
-       menu->SetHighColor(menuColor);
+               menu->SetHighColor(fItemColor);
+               BMenuItem::DrawContent();
+               menu->SetHighColor(menuColor);
+       }
 }
Index: src/apps/stylededit/ColorMenuItem.h
===================================================================
--- src/apps/stylededit/ColorMenuItem.h (Revision 22161)
+++ src/apps/stylededit/ColorMenuItem.h (Arbeitskopie)
@@ -6,22 +6,22 @@
  *             Mattias Sundblad
  *             Andrew Bachmann
  */
+
 #ifndef COLOR_MENU_ITEM_H
 #define COLOR_MENU_ITEM_H
 
-
 #include <MenuItem.h>
 
+class BMessage;
 
-class ColorMenuItem: public BMenuItem {
+class ColorMenuItem: public BMenuItem 
+{
        public:
-               ColorMenuItem(const char *label, rgb_color color, BMessage 
*message);
+                               ColorMenuItem(const char *label, rgb_color 
color, BMessage *message);
+                               void DrawContent();
 
-       protected:
-               virtual void DrawContent();
-
        private:
-               rgb_color fItemColor;
+               rgb_color       fItemColor;
 };
 
 #endif // COLOR_MENU_ITEM_H






[ Home | Signup | Help | Login | Archives | Lists ]

All trademarks and copyrights within the FreeLists archives are owned by their respective owners.
Everything else ©2007 Avenir Technologies, LLC.