Changeset 16705

Show
Ignore:
Timestamp:
03/11/06 12:12:27 (3 years ago)
Author:
axeld
Message:

* Made preferences window font sensitive, this fixes bug #196.
* BottomPrefsView is no longer needed (just contained two buttons, moved

their creation to the PrefsWindow class).

* Cleanup.

Location:
haiku/trunk/src/apps/pulse
Files:
2 removed
5 modified

Legend:

Unmodified
Added
Removed
  • haiku/trunk/src/apps/pulse/ConfigView.cpp

    r14878 r16705  
    1 //**************************************************************************************** 
    2 // 
    3 //      File:           ConfigView.cpp 
    4 // 
    5 //      Written by:     Daniel Switkin 
    6 // 
    7 //      Copyright 1999, Be Incorporated 
    8 // 
    9 //**************************************************************************************** 
     1/* 
     2 * Copyright 2002-2006 Haiku, Inc. All Rights Reserved. 
     3 * Distributed under the terms of the MIT license. 
     4 * 
     5 * Copyright 1999, Be Incorporated. All Rights Reserved. 
     6 * This file may be used under the terms of the Be Sample Code License. 
     7 * 
     8 * Written by:  Daniel Switkin 
     9 */ 
     10 
    1011 
    1112#include "ConfigView.h" 
     
    1314#include "PulseApp.h" 
    1415#include "PrefsWindow.h" 
    15 #include <interface/Box.h> 
     16 
     17#include <CheckBox.h> 
     18#include <RadioButton.h> 
     19#include <TextControl.h> 
     20 
     21#include <ctype.h> 
    1622#include <stdlib.h> 
    1723#include <stdio.h> 
    1824#include <string.h> 
    1925 
     26 
    2027RTColorControl::RTColorControl(BPoint point, BMessage *message) 
    21         : BColorControl(point, B_CELLS_32x8, 6, "ColorControl", message, false) { 
    22  
    23 } 
    24  
    25 // Send a message every time the color changes, not just 
    26 // when the mouse button is released 
    27 void RTColorControl::SetValue(int32 color) { 
     28        : BColorControl(point, B_CELLS_32x8, 6, "ColorControl", message, false) 
     29{ 
     30} 
     31 
     32 
     33/*! 
     34        Send a message every time the color changes, not just 
     35        when the mouse button is released 
     36*/ 
     37void 
     38RTColorControl::SetValue(int32 color) 
     39{ 
    2840        BColorControl::SetValue(color); 
    2941        Invoke(); 
    3042} 
    3143 
    32 // A single class for all three prefs views, needs to be 
    33 // customized below to give each control the right message 
    34 ConfigView::ConfigView(BRect rect, const char *name, int mode, Prefs *prefs) : 
    35         BView(rect, name, B_FOLLOW_NONE, B_WILL_DRAW) { 
    36  
    37         this->mode = mode; 
    38         first_time_attached = true; 
    39         fadecolors = NULL; 
    40         active = idle = frame = NULL; 
    41         iconwidth = NULL; 
    42  
    43         BRect r(6, 5, 296, 115); 
    44         BBox *bbox = new BBox(r, "BBox"); 
    45         bbox->SetLabel("Bar Colors"); 
    46         AddChild(bbox); 
    47          
    48         if (mode == NORMAL_WINDOW_MODE) { 
    49                 colorcontrol = new RTColorControl(BPoint(10, 20), 
    50                         new BMessage(PRV_NORMAL_CHANGE_COLOR)); 
    51         } else if (mode == MINI_WINDOW_MODE) { 
    52                 colorcontrol = new RTColorControl(BPoint(10, 20), 
    53                         new BMessage(PRV_MINI_CHANGE_COLOR)); 
     44 
     45//      #pragma mark - 
     46 
     47 
     48/*! 
     49        A single class for all three prefs views, needs to be 
     50        customized below to give each control the right message 
     51*/ 
     52ConfigView::ConfigView(BRect rect, const char *name, uint32 mode, BMessenger& target, 
     53                Prefs *prefs) 
     54        : BBox(rect, name, B_FOLLOW_NONE, B_WILL_DRAW), 
     55        fMode(mode), 
     56        fTarget(target), 
     57        fPrefs(prefs), 
     58        fFirstTimeAttached(true) 
     59{ 
     60        fFadeCheckBox = NULL; 
     61        fActiveButton = fIdleButton = fFrameButton = NULL; 
     62        fIconWidthControl = NULL; 
     63 
     64        SetLabel("Bar Colors"); 
     65 
     66        font_height fontHeight; 
     67        be_bold_font->GetHeight(&fontHeight); 
     68 
     69        fColorControl = new RTColorControl(BPoint(10, 5.0f + fontHeight.ascent 
     70                + fontHeight.descent), new BMessage(fMode)); 
     71        fColorControl->ResizeToPreferred(); 
     72        AddChild(fColorControl); 
     73 
     74        rect = fColorControl->Frame(); 
     75        rect.top = rect.bottom + 10.0f; 
     76        rect.bottom = rect.top + 15.0f; 
     77 
     78        if (mode == PRV_NORMAL_CHANGE_COLOR) { 
     79                // normal mode 
     80 
     81                fFadeCheckBox = new BCheckBox(rect, "FadeColors", "Fade colors", 
     82                        new BMessage(PRV_NORMAL_FADE_COLORS)); 
     83                fFadeCheckBox->ResizeToPreferred(); 
     84                AddChild(fFadeCheckBox); 
     85 
     86                fColorControl->SetValue(fPrefs->normal_bar_color); 
     87                fFadeCheckBox->SetValue(fPrefs->normal_fade_colors); 
     88        } else if (mode == PRV_MINI_CHANGE_COLOR) { 
     89                // mini mode 
     90 
     91                fActiveButton = new BRadioButton(rect, "ActiveColor", "Active color", 
     92                        new BMessage(PRV_MINI_ACTIVE)); 
     93                fActiveButton->ResizeToPreferred(); 
     94                fActiveButton->SetValue(B_CONTROL_ON); 
     95                AddChild(fActiveButton); 
     96 
     97                rect.left = fActiveButton->Frame().right + 5.0f; 
     98                fIdleButton = new BRadioButton(rect, "IdleColor", "Idle color", 
     99                        new BMessage(PRV_MINI_IDLE)); 
     100                fIdleButton->ResizeToPreferred(); 
     101                AddChild(fIdleButton); 
     102 
     103                rect.left = fIdleButton->Frame().right + 5.0f; 
     104                fFrameButton = new BRadioButton(rect, "FrameColor", "Frame color", 
     105                        new BMessage(PRV_MINI_FRAME)); 
     106                fFrameButton->ResizeToPreferred(); 
     107                AddChild(fFrameButton); 
     108 
     109                fColorControl->SetValue(fPrefs->mini_active_color); 
    54110        } else { 
    55                 colorcontrol = new RTColorControl(BPoint(10, 20), 
    56                         new BMessage(PRV_DESKBAR_CHANGE_COLOR)); 
    57         } 
    58  
    59         bbox->AddChild(colorcontrol); 
    60         r = colorcontrol->Frame(); 
    61         r.top = r.bottom + 10; 
    62         r.bottom = r.top + 15; 
    63  
    64         if (mode == NORMAL_WINDOW_MODE) { 
    65                 r.right = r.left + be_plain_font->StringWidth("Fade colors") + 20; 
    66                 fadecolors = new BCheckBox(r, "FadeColors", "Fade colors", 
    67                         new BMessage(PRV_NORMAL_FADE_COLORS)); 
    68                 bbox->AddChild(fadecolors); 
     111                // deskbar mode 
     112                fActiveButton = new BRadioButton(rect, "ActiveColor", "Active color", 
     113                        new BMessage(PRV_DESKBAR_ACTIVE)); 
     114                fActiveButton->ResizeToPreferred(); 
     115                fActiveButton->SetValue(B_CONTROL_ON); 
     116                AddChild(fActiveButton); 
     117 
     118                rect.left = fActiveButton->Frame().right + 5.0f; 
     119                fIdleButton = new BRadioButton(rect, "IdleColor", "Idle color", 
     120                        new BMessage(PRV_DESKBAR_IDLE)); 
     121                fIdleButton->ResizeToPreferred(); 
     122                AddChild(fIdleButton); 
     123 
     124                rect.left = fIdleButton->Frame().right + 5.0f; 
     125                fFrameButton = new BRadioButton(rect, "FrameColor", "Frame color", 
     126                        new BMessage(PRV_DESKBAR_FRAME)); 
     127                fFrameButton->ResizeToPreferred(); 
     128                AddChild(fFrameButton); 
     129 
     130                rect.left = fColorControl->Frame().left; 
     131                rect.top = fActiveButton->Frame().bottom + 5.0f; 
     132 
     133                char temp[10]; 
     134                snprintf(temp, sizeof(temp), "%d", fPrefs->deskbar_icon_width); 
     135                fIconWidthControl = new BTextControl(rect, "Width", "Width of icon:", temp, 
     136                        new BMessage(PRV_DESKBAR_ICON_WIDTH)); 
     137                AddChild(fIconWidthControl); 
     138                fIconWidthControl->SetDivider(be_plain_font->StringWidth( 
     139                        fIconWidthControl->Label()) + 5.0f); 
     140 
     141                for (int c = 0; c < 256; c++) { 
     142                        if (!isdigit(c)) 
     143                                fIconWidthControl->TextView()->DisallowChar(c); 
     144                } 
     145                fIconWidthControl->TextView()->SetMaxBytes(2); 
    69146                 
    70                 colorcontrol->SetValue(prefs->normal_bar_color); 
    71                 fadecolors->SetValue(prefs->normal_fade_colors); 
    72         } else if (mode == MINI_WINDOW_MODE) { 
    73                 r.right = r.left + be_plain_font->StringWidth("Active color") + 20; 
    74                 active = new BRadioButton(r, "ActiveColor", "Active color", 
    75                         new BMessage(PRV_MINI_ACTIVE)); 
    76                 bbox->AddChild(active); 
    77                 active->SetValue(B_CONTROL_ON); 
    78                  
    79                 r.left = r.right + 5; 
    80                 r.right = r.left + be_plain_font->StringWidth("Idle color") + 20; 
    81                 idle = new BRadioButton(r, "IdleColor", "Idle color", 
    82                         new BMessage(PRV_MINI_IDLE)); 
    83                 bbox->AddChild(idle); 
    84                  
    85                 r.left = r.right + 5; 
    86                 r.right = r.left + be_plain_font->StringWidth("Frame color") + 20; 
    87                 frame = new BRadioButton(r, "FrameColor", "Frame color", 
    88                         new BMessage(PRV_MINI_FRAME)); 
    89                 bbox->AddChild(frame); 
    90                  
    91                 colorcontrol->SetValue(prefs->mini_active_color); 
     147                float width, height; 
     148                fIconWidthControl->GetPreferredSize(&width, &height); 
     149                fIconWidthControl->ResizeTo(fIconWidthControl->Divider() + 32.0f 
     150                        + fIconWidthControl->StringWidth("999"), height); 
     151 
     152                fColorControl->SetValue(fPrefs->deskbar_active_color); 
     153        } 
     154} 
     155 
     156 
     157void 
     158ConfigView::GetPreferredSize(float* _width, float* _height) 
     159{ 
     160        float right, bottom; 
     161 
     162        if (fMode == PRV_NORMAL_CHANGE_COLOR) { 
     163                // normal mode 
     164                bottom = fFadeCheckBox->Frame().bottom; 
     165                right = fFadeCheckBox->Frame().right; 
     166        } else if (fMode == PRV_MINI_CHANGE_COLOR) { 
     167                // mini mode 
     168                bottom = fIdleButton->Frame().bottom; 
     169                right = fFrameButton->Frame().right; 
    92170        } else { 
    93                 bbox->ResizeBy(0, 20); 
    94          
    95                 r.right = r.left + be_plain_font->StringWidth("Active color") + 20; 
    96                 active = new BRadioButton(r, "ActiveColor", "Active color", 
    97                         new BMessage(PRV_DESKBAR_ACTIVE)); 
    98                 bbox->AddChild(active); 
    99                 active->SetValue(B_CONTROL_ON); 
    100                  
    101                 r.left = r.right + 5; 
    102                 r.right = r.left + be_plain_font->StringWidth("Idle color") + 20; 
    103                 idle = new BRadioButton(r, "IdleColor", "Idle color", 
    104                         new BMessage(PRV_DESKBAR_IDLE)); 
    105                 bbox->AddChild(idle); 
    106                  
    107                 r.left = r.right + 5; 
    108                 r.right = r.left + be_plain_font->StringWidth("Frame color") + 20; 
    109                 frame = new BRadioButton(r, "FrameColor", "Frame color", 
    110                         new BMessage(PRV_DESKBAR_FRAME)); 
    111                 bbox->AddChild(frame); 
    112                  
    113                 r.top = active->Frame().bottom + 1; 
    114                 r.bottom = r.top + 15; 
    115                 r.left = 10; 
    116                 r.right = r.left + be_plain_font->StringWidth("Width of icon:") + 5 + 30; 
    117                 char temp[10]; 
    118                 sprintf(temp, "%d", prefs->deskbar_icon_width); 
    119                 iconwidth = new BTextControl(r, "Width", "Width of icon:", temp, 
    120                         new BMessage(PRV_DESKBAR_ICON_WIDTH)); 
    121                 bbox->AddChild(iconwidth); 
    122                 iconwidth->SetDivider(be_plain_font->StringWidth("Width of icon:") + 5); 
    123                 //iconwidth->SetModificationMessage(new BMessage(PRV_DESKBAR_ICON_WIDTH)); 
    124                  
    125                 for (int x = 0; x < 256; x++) { 
    126                         if (x < '0' || x > '9') iconwidth->TextView()->DisallowChar(x); 
    127                 } 
    128                 iconwidth->TextView()->SetMaxBytes(2); 
    129                  
    130                 colorcontrol->SetValue(prefs->deskbar_active_color); 
    131         } 
    132 } 
    133  
    134 void ConfigView::AttachedToWindow() { 
     171                // deskbar mode 
     172                bottom = fIconWidthControl->Frame().bottom; 
     173                right = fFrameButton->Frame().right; 
     174        } 
     175 
     176        if (right < fColorControl->Frame().right) 
     177                right = fColorControl->Frame().right; 
     178        if (right < 300) 
     179                right = 300; 
     180 
     181        if (_width) 
     182                *_width = right + 10.0f; 
     183        if (_height) 
     184                *_height = bottom + 8.0f; 
     185} 
     186 
     187 
     188void 
     189ConfigView::AttachedToWindow() 
     190{ 
    135191        BView::AttachedToWindow(); 
    136192         
    137193        // AttachedToWindow() gets called every time this tab is brought 
    138194        // to the front, but we only want this initialization to happen once 
    139         if (first_time_attached) { 
     195        if (fFirstTimeAttached) { 
     196                if (Parent() != NULL) 
     197                        SetViewColor(Parent()->ViewColor()); 
     198                else 
     199                        SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 
     200 
    140201                BMessenger messenger(this); 
    141                 colorcontrol->SetTarget(messenger); 
    142                 if (fadecolors != NULL) fadecolors->SetTarget(messenger); 
    143                 if (active != NULL) active->SetTarget(messenger); 
    144                 if (idle != NULL) idle->SetTarget(messenger); 
    145                 if (frame != NULL) frame->SetTarget(messenger); 
    146                 if (iconwidth != NULL) iconwidth->SetTarget(messenger); 
    147                  
    148                 first_time_attached = false; 
    149         } 
    150 } 
    151  
    152 void ConfigView::MessageReceived(BMessage *message) { 
    153         PrefsWindow *prefswindow = (PrefsWindow *)Window(); 
    154         if (prefswindow == NULL) return; 
    155         Prefs *prefs = prefswindow->prefs; 
    156         BMessenger *messenger = prefswindow->messenger; 
    157          
     202                fColorControl->SetTarget(messenger); 
     203                if (fFadeCheckBox != NULL) 
     204                        fFadeCheckBox->SetTarget(messenger); 
     205                if (fActiveButton != NULL) 
     206                        fActiveButton->SetTarget(messenger); 
     207                if (fIdleButton != NULL) 
     208                        fIdleButton->SetTarget(messenger); 
     209                if (fFrameButton != NULL)        
     210                        fFrameButton->SetTarget(messenger); 
     211                if (fIconWidthControl != NULL) 
     212                        fIconWidthControl->SetTarget(messenger); 
     213 
     214                fFirstTimeAttached = false; 
     215        } 
     216} 
     217 
     218 
     219void 
     220ConfigView::MessageReceived(BMessage *message) 
     221{ 
    158222        switch (message->what) { 
    159223                // These two send the color and the status of the fade checkbox together 
    160224                case PRV_NORMAL_FADE_COLORS: 
    161                 case PRV_NORMAL_CHANGE_COLOR: { 
    162                         bool fade_colors = (bool)fadecolors->Value(); 
    163                         int32 bar_color = colorcontrol->Value(); 
     225                case PRV_NORMAL_CHANGE_COLOR: 
     226                { 
     227                        bool fade_colors = (bool)fFadeCheckBox->Value(); 
     228                        int32 bar_color = fColorControl->Value(); 
    164229                        message->AddInt32("color", bar_color); 
    165230                        message->AddBool("fade", fade_colors); 
    166                         prefs->normal_fade_colors = fade_colors; 
    167                         prefs->normal_bar_color = bar_color; 
    168                         messenger->SendMessage(message); 
     231                        fPrefs->normal_fade_colors = fade_colors; 
     232                        fPrefs->normal_bar_color = bar_color; 
     233 
     234                        fTarget.SendMessage(message); 
    169235                        break; 
    170236                } 
    171237                // Share the single color control among three values 
    172238                case PRV_MINI_ACTIVE: 
    173                         colorcontrol->SetValue(prefs->mini_active_color); 
     239                        fColorControl->SetValue(fPrefs->mini_active_color); 
    174240                        break; 
    175241                case PRV_MINI_IDLE: 
    176                         colorcontrol->SetValue(prefs->mini_idle_color); 
     242                        fColorControl->SetValue(fPrefs->mini_idle_color); 
    177243                        break; 
    178244                case PRV_MINI_FRAME: 
    179                         colorcontrol->SetValue(prefs->mini_frame_color); 
     245                        fColorControl->SetValue(fPrefs->mini_frame_color); 
    180246                        break; 
    181247                case PRV_MINI_CHANGE_COLOR: { 
    182                         int32 color = colorcontrol->Value(); 
    183                         if (active->Value()) { 
    184                                 prefs->mini_active_color = color; 
    185                         } else if (idle->Value()) { 
    186                                 prefs->mini_idle_color = color; 
    187                         } else { 
    188                                 prefs->mini_frame_color = color; 
    189                         } 
    190                         message->AddInt32("active_color", prefs->mini_active_color); 
    191                         message->AddInt32("idle_color", prefs->mini_idle_color); 
    192                         message->AddInt32("frame_color", prefs->mini_frame_color); 
    193                         messenger->SendMessage(message); 
     248                        int32 color = fColorControl->Value(); 
     249                        if (fActiveButton->Value()) 
     250                                fPrefs->mini_active_color = color; 
     251                        else if (fIdleButton->Value()) 
     252                                fPrefs->mini_idle_color = color; 
     253                        else 
     254                                fPrefs->mini_frame_color = color; 
     255 
     256                        message->AddInt32("active_color", fPrefs->mini_active_color); 
     257                        message->AddInt32("idle_color", fPrefs->mini_idle_color); 
     258                        message->AddInt32("frame_color", fPrefs->mini_frame_color); 
     259                        fTarget.SendMessage(message); 
    194260                        break; 
    195261                } 
    196262                case PRV_DESKBAR_ACTIVE: 
    197                         colorcontrol->SetValue(prefs->deskbar_active_color); 
     263                        fColorControl->SetValue(fPrefs->deskbar_active_color); 
    198264                        break; 
    199265                case PRV_DESKBAR_IDLE: 
    200                         colorcontrol->SetValue(prefs->deskbar_idle_color); 
     266                        fColorControl->SetValue(fPrefs->deskbar_idle_color); 
    201267                        break; 
    202268                case PRV_DESKBAR_FRAME: 
    203                         colorcontrol->SetValue(prefs->deskbar_frame_color); 
     269                        fColorControl->SetValue(fPrefs->deskbar_frame_color); 
    204270                        break; 
    205271                case PRV_DESKBAR_ICON_WIDTH: 
     
    207273                        break; 
    208274                case PRV_DESKBAR_CHANGE_COLOR: { 
    209                         int32 color = colorcontrol->Value(); 
    210                         if (active->Value()) { 
    211                                 prefs->deskbar_active_color = color; 
    212                         } else if (idle->Value()) { 
    213                                 prefs->deskbar_idle_color = color; 
    214                         } else { 
    215                                 prefs->deskbar_frame_color = color; 
    216                         } 
    217                         message->AddInt32("active_color", prefs->deskbar_active_color); 
    218                         message->AddInt32("idle_color", prefs->deskbar_idle_color); 
    219                         message->AddInt32("frame_color", prefs->deskbar_frame_color); 
    220                         messenger->SendMessage(message); 
     275                        int32 color = fColorControl->Value(); 
     276                        if (fActiveButton->Value()) 
     277                                fPrefs->deskbar_active_color = color; 
     278                        else if (fIdleButton->Value()) 
     279                                fPrefs->deskbar_idle_color = color; 
     280                        else 
     281                                fPrefs->deskbar_frame_color = color; 
     282 
     283                        message->AddInt32("active_color", fPrefs->deskbar_active_color); 
     284                        message->AddInt32("idle_color", fPrefs->deskbar_idle_color); 
     285                        message->AddInt32("frame_color", fPrefs->deskbar_frame_color); 
     286                        fTarget.SendMessage(message); 
    221287                        break; 
    222288                } 
    223289                case PRV_BOTTOM_DEFAULTS: 
    224                         ResetDefaults(); 
     290                        _ResetDefaults(); 
    225291                        break; 
    226292                default: 
     
    230296} 
    231297 
    232 void ConfigView::UpdateDeskbarIconWidth() { 
    233         PrefsWindow *prefswindow = (PrefsWindow *)Window(); 
    234         if (prefswindow == NULL) return; 
    235         Prefs *prefs = prefswindow->prefs; 
    236         BMessenger *messenger = prefswindow->messenger; 
    237          
     298 
     299void 
     300ConfigView::UpdateDeskbarIconWidth() 
     301{ 
    238302        // Make sure the width shows at least one pixel per CPU and 
    239303        // that it will fit in the tray in any Deskbar orientation 
    240         int width = atoi(iconwidth->Text()); 
     304        int width = atoi(fIconWidthControl->Text()); 
    241305        int min_width = GetMinimumViewWidth(); 
    242306        if (width < min_width || width > 50) { 
     
    249313                        width = 50; 
    250314                } 
    251                 iconwidth->SetText(temp); 
    252         } 
    253          
    254         BMessage *message = new BMessage(PRV_DESKBAR_ICON_WIDTH); 
    255         message->AddInt32("width", width); 
    256         prefs->deskbar_icon_width = width; 
    257         messenger->SendMessage(message); 
    258         delete message; 
    259 } 
    260  
    261 // Only reset our own controls to default 
    262 void ConfigView::ResetDefaults() { 
    263         PrefsWindow *prefswindow = (PrefsWindow *)Window(); 
    264         if (prefswindow == NULL) return; 
    265         Prefs *prefs = prefswindow->prefs; 
    266         BMessenger *messenger = prefswindow->messenger; 
    267          
    268         if (mode == NORMAL_WINDOW_MODE) { 
    269                 colorcontrol->SetValue(DEFAULT_NORMAL_BAR_COLOR); 
    270                 fadecolors->SetValue(DEFAULT_NORMAL_FADE_COLORS); 
    271         } else if (mode == MINI_WINDOW_MODE) { 
    272                 prefs->mini_active_color = DEFAULT_MINI_ACTIVE_COLOR; 
    273                 prefs->mini_idle_color = DEFAULT_MINI_IDLE_COLOR; 
    274                 prefs->mini_frame_color = DEFAULT_MINI_FRAME_COLOR; 
    275                 if (active->Value()) { 
    276                         colorcontrol->SetValue(DEFAULT_MINI_ACTIVE_COLOR); 
    277                 } else if (idle->Value()) { 
    278                         colorcontrol->SetValue(DEFAULT_MINI_IDLE_COLOR); 
    279                 } else { 
    280                         colorcontrol->SetValue(DEFAULT_MINI_FRAME_COLOR); 
    281                 } 
     315                fIconWidthControl->SetText(temp); 
     316        } 
     317 
     318        fPrefs->deskbar_icon_width = width; 
     319 
     320        BMessage message(PRV_DESKBAR_ICON_WIDTH); 
     321        message.AddInt32("width", width); 
     322        fTarget.SendMessage(&message); 
     323} 
     324 
     325 
     326void 
     327ConfigView::_ResetDefaults() 
     328{ 
     329        if (fMode == PRV_NORMAL_CHANGE_COLOR) { 
     330                fColorControl->SetValue(DEFAULT_NORMAL_BAR_COLOR); 
     331                fFadeCheckBox->SetValue(DEFAULT_NORMAL_FADE_COLORS); 
     332        } else if (fMode == PRV_MINI_CHANGE_COLOR) { 
     333                fPrefs->mini_active_color = DEFAULT_MINI_ACTIVE_COLOR; 
     334                fPrefs->mini_idle_color = DEFAULT_MINI_IDLE_COLOR; 
     335                fPrefs->mini_frame_color = DEFAULT_MINI_FRAME_COLOR; 
     336                if (fActiveButton->Value()) 
     337                        fColorControl->SetValue(DEFAULT_MINI_ACTIVE_COLOR); 
     338                else if (fIdleButton->Value()) 
     339                        fColorControl->SetValue(DEFAULT_MINI_IDLE_COLOR); 
     340                else 
     341                        fColorControl->SetValue(DEFAULT_MINI_FRAME_COLOR); 
     342 
    282343                BMessage *message = new BMessage(PRV_MINI_CHANGE_COLOR); 
    283344                message->AddInt32("active_color", DEFAULT_MINI_ACTIVE_COLOR); 
    284345                message->AddInt32("idle_color", DEFAULT_MINI_IDLE_COLOR); 
    285346                message->AddInt32("frame_color", DEFAULT_MINI_FRAME_COLOR); 
    286                 messenger->SendMessage(message); 
     347                fTarget.SendMessage(message); 
    287348        } else {         
    288                 prefs->deskbar_active_color = DEFAULT_DESKBAR_ACTIVE_COLOR; 
    289                 prefs->deskbar_idle_color = DEFAULT_DESKBAR_IDLE_COLOR; 
    290                 prefs->deskbar_frame_color = DEFAULT_DESKBAR_FRAME_COLOR; 
    291                 if (active->Value()) { 
    292                         colorcontrol->SetValue(DEFAULT_DESKBAR_ACTIVE_COLOR); 
    293                 } else if (idle->Value()) { 
    294                         colorcontrol->SetValue(DEFAULT_DESKBAR_IDLE_COLOR); 
    295                 } else { 
    296                         colorcontrol->SetValue(DEFAULT_DESKBAR_FRAME_COLOR); 
    297                 } 
     349                fPrefs->deskbar_active_color = DEFAULT_DESKBAR_ACTIVE_COLOR; 
     350                fPrefs->deskbar_idle_color = DEFAULT_DESKBAR_IDLE_COLOR; 
     351                fPrefs->deskbar_frame_color = DEFAULT_DESKBAR_FRAME_COLOR; 
     352                if (fActiveButton->Value()) 
     353                        fColorControl->SetValue(DEFAULT_DESKBAR_ACTIVE_COLOR); 
     354                else if (fIdleButton->Value()) 
     355                        fColorControl->SetValue(DEFAULT_DESKBAR_IDLE_COLOR); 
     356                else 
     357                        fColorControl->SetValue(DEFAULT_DESKBAR_FRAME_COLOR); 
     358 
    298359                BMessage *message = new BMessage(PRV_DESKBAR_CHANGE_COLOR); 
    299360                message->AddInt32("active_color", DEFAULT_DESKBAR_ACTIVE_COLOR); 
    300361                message->AddInt32("idle_color", DEFAULT_DESKBAR_IDLE_COLOR); 
    301362                message->AddInt32("frame_color", DEFAULT_DESKBAR_FRAME_COLOR); 
    302                 messenger->SendMessage(message); 
    303          
     363                fTarget.SendMessage(message); 
     364 
    304365                char temp[10]; 
    305366                sprintf(temp, "%d", DEFAULT_DESKBAR_ICON_WIDTH); 
    306                 iconwidth->SetText(temp); 
     367                fIconWidthControl->SetText(temp); 
    307368                // Need to force the model message to be sent 
    308                 iconwidth->Invoke(); 
    309         } 
    310 } 
     369                fIconWidthControl->Invoke(); 
     370        } 
     371} 
  • haiku/trunk/src/apps/pulse/ConfigView.h

    r10 r16705  
    1 //**************************************************************************************** 
    2 // 
    3 //      File:           ConfigView.h 
    4 // 
    5 //      Written by:     Daniel Switkin 
    6 // 
    7 //      Copyright 1999, Be Incorporated 
    8 //