Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

tipwindow.C

Go to the documentation of this file.
00001 #include "bcdisplayinfo.h"
00002 #include "bcsignals.h"
00003 #include "keys.h"
00004 #include "language.h"
00005 #include "mainsession.h"
00006 #include "mwindow.h"
00007 #include "preferences.h"
00008 #include "theme.h"
00009 #include "tipwindow.h"
00010 
00011 
00012 
00013 // Table of tips of the day
00014 static char *tips[] = 
00015 {
00016         N_("When configuring slow effects, disable playback for the track.  After configuring it,\n"
00017         "re-enable playback to process a single frame."),
00018 
00019         N_("Ctrl + any transport command causes playback to only cover\n"
00020         "the region defined by the in/out points."),
00021 
00022         N_("Shift + clicking a patch causes all other patches except the\n"
00023         "selected one to toggle."),
00024 
00025         N_("Clicking on a patch and dragging across other tracks causes\n"
00026         "the other patches to match the first one."),
00027 
00028         N_("Shift + clicking on an effect boundary causes dragging to affect\n"
00029         "just the one effect."),
00030 
00031         N_("Load multiple files by clicking on one file and shift + clicking on\n"
00032         "another file.  Ctrl + clicking toggles individual files."),
00033 
00034         N_("Ctrl + left clicking on the time bar cycles forward a time format.\n"
00035         "Ctrl + middle clicking on the time bar cycles backward a time format."),
00036 
00037         N_("Use the +/- keys in the Compositor window to zoom in and out.\n"),
00038 
00039         N_("Pressing Alt while clicking in the cropping window causes translation of\n"
00040         "all 4 points.\n"),
00041 
00042         N_("Pressing Tab over a track toggles the Record status.\n"
00043         "Pressing Shift-Tab over a track toggles the Record status of all the other tracks.\n")
00044 };
00045 
00046 static int total_tips = sizeof(tips) / sizeof(char*);
00047 
00048 
00049 
00050 
00051 TipWindow::TipWindow(MWindow *mwindow)
00052  : BC_DialogThread()
00053 {
00054         this->mwindow = mwindow;
00055 }
00056 
00057 BC_Window* TipWindow::new_gui()
00058 {
00059         BC_DisplayInfo display_info;
00060         int x = display_info.get_abs_cursor_x();
00061         int y = display_info.get_abs_cursor_y();
00062         TipWindowGUI *gui = this->gui = new TipWindowGUI(mwindow, 
00063                 this,
00064                 x,
00065                 y);
00066         gui->create_objects();
00067         return gui;
00068 }
00069 
00070 char* TipWindow::get_current_tip()
00071 {
00072         CLAMP(mwindow->session->current_tip, 0, total_tips - 1);
00073         char *result = _(tips[mwindow->session->current_tip]);
00074         mwindow->session->current_tip++;
00075         if(mwindow->session->current_tip >= total_tips)
00076                 mwindow->session->current_tip = 0;
00077         mwindow->save_defaults();
00078         return result;
00079 }
00080 
00081 void TipWindow::next_tip()
00082 {
00083         gui->tip_text->update(get_current_tip());
00084 }
00085 
00086 void TipWindow::prev_tip()
00087 {
00088         for(int i = 0; i < 2; i++)
00089         {
00090                 mwindow->session->current_tip--;
00091                 if(mwindow->session->current_tip < 0)
00092                         mwindow->session->current_tip = total_tips - 1;
00093         }
00094 
00095         gui->tip_text->update(get_current_tip());
00096 }
00097 
00098 
00099 
00100 
00101 
00102 
00103 TipWindowGUI::TipWindowGUI(MWindow *mwindow, 
00104         TipWindow *thread,
00105         int x,
00106         int y)
00107  : BC_Window(PROGRAM_NAME ": Tip of the day",
00108         x,
00109         y,
00110         640,
00111         100,
00112         640,
00113         100,
00114         0,
00115         0,
00116         1)
00117 {
00118         this->mwindow = mwindow;
00119         this->thread = thread;
00120 }
00121 
00122 void TipWindowGUI::create_objects()
00123 {
00124         int x = 10, y = 10;
00125 SET_TRACE
00126         add_subwindow(tip_text = new BC_Title(x, y, thread->get_current_tip()));
00127         y = get_h() - 30;
00128 SET_TRACE
00129         BC_CheckBox *checkbox; 
00130         add_subwindow(checkbox = new TipDisable(mwindow, this, x, y));
00131 SET_TRACE
00132         BC_Button *button;
00133         y = get_h() - TipClose::calculate_h(mwindow) - 10;
00134         x = get_w() - TipClose::calculate_w(mwindow) - 10;
00135         add_subwindow(button = new TipClose(mwindow, this, x, y));
00136 SET_TRACE
00137         x -= TipNext::calculate_w(mwindow) + 10;
00138         add_subwindow(button = new TipNext(mwindow, this, x, y));
00139 SET_TRACE
00140         x -= TipPrev::calculate_w(mwindow) + 10;
00141         add_subwindow(button = new TipPrev(mwindow, this, x, y));
00142 SET_TRACE
00143         x += button->get_w() + 10;
00144 
00145         show_window();
00146         raise_window();
00147 }
00148 
00149 int TipWindowGUI::keypress_event()
00150 {
00151         switch(get_keypress())
00152         {
00153                 case RETURN:
00154                 case ESC:
00155                 case 'w':
00156                         set_done(0);
00157                         break;
00158         }
00159         return 0;
00160 }
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 TipDisable::TipDisable(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
00169  : BC_CheckBox(x, 
00170         y, 
00171         mwindow->preferences->use_tipwindow, 
00172         _("Show tip of the day."))
00173 {
00174         this->mwindow = mwindow;
00175         this->gui = gui;
00176 }
00177 
00178 int TipDisable::handle_event()
00179 {
00180         mwindow->preferences->use_tipwindow = get_value();
00181         return 1;
00182 }
00183 
00184 
00185 
00186 TipNext::TipNext(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
00187  : BC_Button(x, 
00188         y, 
00189         mwindow->theme->get_image_set("next_tip"))
00190 {
00191         this->mwindow = mwindow;
00192         this->gui = gui;
00193         set_tooltip(_("Next tip"));
00194 }
00195 int TipNext::handle_event()
00196 {
00197         gui->thread->next_tip();
00198         return 1;
00199 }
00200 
00201 int TipNext::calculate_w(MWindow *mwindow)
00202 {
00203         return mwindow->theme->get_image_set("next_tip")[0]->get_w();
00204 }
00205 
00206 
00207 
00208 
00209 
00210 
00211 TipPrev::TipPrev(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
00212  : BC_Button(x, y, mwindow->theme->get_image_set("prev_tip"))
00213 {
00214         this->mwindow = mwindow;
00215         this->gui = gui;
00216         set_tooltip(_("Previous tip"));
00217 }
00218 
00219 int TipPrev::handle_event()
00220 {
00221         gui->thread->prev_tip();
00222         return 1;
00223 }
00224 int TipPrev::calculate_w(MWindow *mwindow)
00225 {
00226         return mwindow->theme->get_image_set("prev_tip")[0]->get_w();
00227 }
00228 
00229 
00230 
00231 
00232 
00233 
00234 
00235 
00236 
00237 TipClose::TipClose(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
00238  : BC_Button(x, y, mwindow->theme->get_image_set("close_tip"))
00239 {
00240         this->mwindow = mwindow;
00241         this->gui = gui;
00242         set_tooltip(_("Close"));
00243 }
00244 
00245 int TipClose::handle_event()
00246 {
00247         gui->set_done(0);
00248         return 1;
00249 }
00250 
00251 int TipClose::calculate_w(MWindow *mwindow)
00252 {
00253         return mwindow->theme->get_image_set("close_tip")[0]->get_w();
00254 }
00255 int TipClose::calculate_h(MWindow *mwindow)
00256 {
00257         return mwindow->theme->get_image_set("close_tip")[0]->get_h();
00258 }
00259 
00260 
00261 

Generated on Sun Jan 8 13:39:00 2006 for Cinelerra-svn by  doxygen 1.4.4