]> git.sesse.net Git - vlc/commitdiff
beos/MessagesWindow*: fixed messages window
authorEric Petit <titer@videolan.org>
Fri, 20 Aug 2004 15:49:09 +0000 (15:49 +0000)
committerEric Petit <titer@videolan.org>
Fri, 20 Aug 2004 15:49:09 +0000 (15:49 +0000)
modules/gui/beos/MessagesWindow.cpp
modules/gui/beos/MessagesWindow.h

index a3f957d0e31b4a507f4b905d049a67e2be81de3e..e7020e202a35ac330451e565eaf96ffc9ba79eee 100644 (file)
@@ -38,7 +38,6 @@
  *****************************************************************************/
 void MessagesView::Pulse()
 {
-#if 0
     bool isScrolling = false;
     if( fScrollBar->LockLooper() )
     {
@@ -95,14 +94,14 @@ void MessagesView::Pulse()
             if( LockLooper() )
             {
                 oldLength = TextLength();
-               BString string;
-               string << p_sub->p_msg[i_start].psz_module
-                   << " " << psz_module_type << " : "
-                   << p_sub->p_msg[i_start].psz_msg << "\n";
-               Insert( TextLength(), string.String(), strlen( string.String() ) );
-               SetFontAndColor( oldLength, TextLength(), NULL, 0, &color );
-               Draw( Bounds() );
-                   UnlockLooper();
+                BString string;
+                string << p_sub->p_msg[i_start].psz_module
+                    << " " << psz_module_type << " : "
+                    << p_sub->p_msg[i_start].psz_msg << "\n";
+                Insert( TextLength(), string.String(), strlen( string.String() ) );
+                SetFontAndColor( oldLength, TextLength(), NULL, 0, &color );
+                Draw( Bounds() );
+                UnlockLooper();
             }
         }
 
@@ -123,37 +122,37 @@ void MessagesView::Pulse()
     }
 
     BTextView::Pulse();
-#endif
 }
 
 /*****************************************************************************
  * MessagesWindow::MessagesWindow
  *****************************************************************************/
-MessagesWindow::MessagesWindow( intf_thread_t * p_intf,
+MessagesWindow::MessagesWindow( intf_thread_t * _p_intf,
                                 BRect frame, const char * name )
-       : BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
-               B_NOT_ZOOMABLE )
+    : BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
+               B_NOT_ZOOMABLE ),
+    p_intf(_p_intf)
 {
-       this->p_intf = p_intf;
-
     SetSizeLimits( 400, 2000, 200, 2000 );
-       
-       BRect rect, textRect;
-
-       rect = Bounds();
-       rect.right -= B_V_SCROLL_BAR_WIDTH;
-       textRect = rect;
-       textRect.InsetBy( 5, 5 );
-       fMessagesView = new MessagesView( p_intf,
-                                         rect, "messages", textRect,
-                                         B_FOLLOW_ALL, B_WILL_DRAW );
-       fMessagesView->MakeEditable( false );
-       fMessagesView->SetStylable( true );
-       fScrollView = new BScrollView( "scrollview", fMessagesView, B_WILL_DRAW,
-                                      B_FOLLOW_ALL, false, true );
-       fMessagesView->fScrollBar = fScrollView->ScrollBar( B_VERTICAL );
-       AddChild( fScrollView );
-       
+
+    p_sub = msg_Subscribe( p_intf );
+    
+    BRect rect, textRect;
+
+    rect = Bounds();
+    rect.right -= B_V_SCROLL_BAR_WIDTH;
+    textRect = rect;
+    textRect.InsetBy( 5, 5 );
+    fMessagesView = new MessagesView( p_sub,
+                                      rect, "messages", textRect,
+                                      B_FOLLOW_ALL, B_WILL_DRAW );
+    fMessagesView->MakeEditable( false );
+    fMessagesView->SetStylable( true );
+    fScrollView = new BScrollView( "scrollview", fMessagesView, B_WILL_DRAW,
+                                   B_FOLLOW_ALL, false, true );
+    fMessagesView->fScrollBar = fScrollView->ScrollBar( B_VERTICAL );
+    AddChild( fScrollView );
+    
     /* start window thread in hidden state */
     Hide();
     Show();
@@ -164,6 +163,7 @@ MessagesWindow::MessagesWindow( intf_thread_t * p_intf,
  *****************************************************************************/
 MessagesWindow::~MessagesWindow()
 {
+     msg_Unsubscribe( p_intf, p_sub );
 }
 
 /*****************************************************************************
index e6e54add106a9807d17d6673b5e04ca6c4ca6f22..259236c85962a7fc8759215525c0b5c7cf50924a 100644 (file)
 class MessagesView : public BTextView
 {
     public:
-                             MessagesView( intf_thread_t * _p_intf,
+                             MessagesView( msg_subscription_t * _p_sub,
                                            BRect rect, char * name, BRect textRect,
                                            uint32 resizingMode, uint32 flags )
                                  : BTextView( rect, name, textRect,
-                                              resizingMode, flags )
+                                              resizingMode, flags ),
+                                 p_sub(_p_sub)
                              {
-                                 p_intf = _p_intf;
                              }
         virtual void         Pulse();
 
-        intf_thread_t *      p_intf;
         msg_subscription_t * p_sub;
-        BScrollBar *         fScrollBar;
+        BScrollBar         * fScrollBar;
 };
 
 class MessagesWindow : public BWindow
@@ -55,12 +54,13 @@ class MessagesWindow : public BWindow
 
         void                 ReallyQuit();
 
-        intf_thread_t *      p_intf;
+        intf_thread_t      * p_intf;
+        msg_subscription_t * p_sub;
 
         BView *              fBackgroundView;
         MessagesView *       fMessagesView;
         BScrollView *        fScrollView;
 };
 
-#endif // BEOS_PREFERENCES_WINDOW_H
+#endif    // BEOS_PREFERENCES_WINDOW_H