home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Applications / HyperCuber 2.0 / source / CMouseControlsDialog.cp < prev    next >
Encoding:
Text File  |  1994-05-02  |  5.8 KB  |  173 lines  |  [TEXT/KAHL]

  1. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. //| CMouseEditControlsDialog.cp
  3. //|
  4. //| This implements the dialog used to edit mouse controls
  5. //|_________________________________________________________
  6.  
  7. #include "CMouseControlsArrayPane.h"
  8. #include "CMouseControlsDialog.h"
  9. #include "CHyperCuberPrefs.h"
  10.  
  11. #include "HyperCuber Balloons.h"
  12. #include "HyperCuber Commands.h"
  13.  
  14. #include <CButton.h>
  15. #include <CPaneBorder.h>
  16. #include <CDecorator.h>
  17. #include <CEditText.h>
  18.  
  19. #include <string.h>
  20.  
  21. //============================ Globals ===============================\\
  22.  
  23. extern CDecorator         *gDecorator;
  24. extern CHyperCuberPrefs *gPrefs;
  25.  
  26.  
  27.  
  28. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  29. //| CMouseControlsDialog::IMouseControlsDialog
  30. //|
  31. //| Purpose: Initialize the controls dialog.
  32. //|
  33. //| Parameters: WindowID:   ID of WIND resource to use
  34. //|             enclosure:  the Desktop
  35. //|             supervisor: the supervisor of this DialogDirector
  36. //|             array:      the array of mouse controls
  37. //|______________________________________________________________________________
  38.  
  39. void CMouseControlsDialog::IMouseControlsDialog(short WindowID, CDesktop *enclosure,
  40.                                             CDirector *supervisor, CArray *array,
  41.                                                 CMouseControlsArrayPane *array_pane)
  42. {
  43.  
  44.     
  45. #define OKAY_BUTTON_ID        130
  46. #define CANCEL_BUTTON_ID    131
  47. #define DEFAULTS_BUTTON_ID    132
  48. #define ADD_BUTTON_ID        133
  49. #define REMOVE_BUTTON_ID    134
  50. #define EDIT_BUTTON_ID        135
  51.  
  52.     CDialog::IDialog(WindowID, enclosure, supervisor);    //  Initialize window from WIND resource
  53.  
  54.     helpResID = WINDOW_HELP_RES;                    //  Link in the Balloon Help
  55.  
  56.     CButton        *button;
  57.     button = new(CButton);                            //  Set up the okay button
  58.     button->IButton(OKAY_BUTTON_ID, this, this);
  59.     button->Offset(360, 35, TRUE);
  60.     button->SetClickCmd (cmdOK);
  61.     button->helpResIndex = kMouseOkay;
  62.     SetDefaultButton(button);
  63.     
  64.     button = new (CButton);                            //  Set up the cancel button
  65.     button->IButton(CANCEL_BUTTON_ID, this, this);
  66.     button->Offset(360, 70, TRUE);
  67.     button->SetClickCmd (cmdCancel);
  68.     button->helpResIndex = kMouseCancel;
  69.     
  70.     button = new (CButton);                            //  Set up the Defaults button
  71.     button->IButton(DEFAULTS_BUTTON_ID, this, this);
  72.     button->Offset(360, 105, TRUE);
  73.     button->SetClickCmd (cmdDefaults);
  74.     button->helpResIndex = kMouseDefaults;
  75.     
  76.     button = new (CButton);                            //  Set up the Add button
  77.     button->IButton(ADD_BUTTON_ID, this, this);
  78.     button->Offset(360, 140, TRUE);
  79.     button->SetClickCmd (cmdAdd);
  80.     button->helpResIndex = kMouseAdd;
  81.     
  82.     button = new (CButton);                            //  Set up the Remove button
  83.     button->IButton(REMOVE_BUTTON_ID, this, this);
  84.     button->Offset(360, 175, TRUE);
  85.     button->SetClickCmd (cmdRemove);
  86.     button->helpResIndex = kMouseRemove;
  87.     
  88.     button = new (CButton);                            //  Set up the Edit button
  89.     button->IButton(EDIT_BUTTON_ID, this, this);
  90.     button->Offset(360, 210, TRUE);
  91.     button->SetClickCmd (cmdEdit);
  92.     button->helpResIndex = kMouseEdit;
  93.     
  94.     CScrollPane *scroll_pane;
  95.     scroll_pane = new(CScrollPane);                    //  Set up the scrolling pane
  96.     scroll_pane->IScrollPane(this, this, 320, 254,
  97.                             20, 20,
  98.                             sizFIXEDLEFT, sizFIXEDTOP,
  99.                             FALSE, TRUE, FALSE);
  100.     
  101.     CPaneBorder *border;
  102.     border = new(CPaneBorder);                        //  Add a box around the scroll pane
  103.     border->IPaneBorder(kBorderFrame);
  104.     Rect margin = {1, 1, -1, -1};
  105.     border->SetMargin(&margin);
  106.     scroll_pane->SetBorder(border);
  107.  
  108.     array_pane->IMouseControlsArrayPane(scroll_pane, scroll_pane,
  109.                         10, 10, 0, 0,
  110.                         sizFIXEDLEFT, sizFIXEDTOP);    //  Set up the array pane
  111.     array_pane->FitToEnclosure(TRUE, TRUE);
  112.     array_pane->SetArray(array, TRUE);
  113.     array_pane->SetDblClickCmd(cmdEdit);
  114.     
  115.     scroll_pane->InstallPanorama(array_pane);
  116.  
  117.     CEditText *text;
  118.     text = new(CEditText);                                    //  Set up the Function text
  119.     text->IEditText(this, this, 100, 16,
  120.                     23, 3, sizFIXEDLEFT, sizFIXEDTOP, -1);
  121.     text->SetTextString("\pFunction");
  122.     text->SetFontNumber(systemFont);
  123.     text->SetFontSize(12);
  124.     text->SetWantsClicks(FALSE);
  125.     text->Specify(kNotEditable, kNotSelectable, kNotStylable);
  126.     
  127.     text = new(CEditText);                                    //  Set up the Modifiers text
  128.     text->IEditText(this, this, 100, 16,
  129.                     245, 3, sizFIXEDLEFT, sizFIXEDTOP, -1);
  130.     text->SetTextString("\pModifiers");
  131.     text->SetFontNumber(systemFont);
  132.     text->SetFontSize(12);
  133.     text->SetWantsClicks(FALSE);
  134.     text->Specify(kNotEditable, kNotSelectable, kNotStylable);
  135.     
  136.  
  137.     gDecorator->CenterWindow (this);                //  Center the window on the screen
  138.  
  139. }    //=== CMouseControlsDialog::IMouseControlsDialog() ===\\
  140.  
  141.  
  142.  
  143. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  144. //| CMouseControlsDialog::MatchDialogToPrefs
  145. //|
  146. //| Purpose: Sets the values of the mouse controls in the dialog to match the prefs
  147. //|______________________________________________________________________________
  148.  
  149. void CMouseControlsDialog::MatchDialogToPrefs(void)
  150. {
  151.  
  152.     PrefsStruct prefs = gPrefs->prefs;        // Get current prefs
  153.  
  154. #if 0
  155.     increase_theta_keypane->SetKey(prefs.increase_theta_key);
  156.     decrease_theta_keypane->SetKey(prefs.decrease_theta_key);
  157.     increase_phi_keypane->SetKey(prefs.increase_phi_key);
  158.     decrease_phi_keypane->SetKey(prefs.decrease_phi_key);
  159.     increase_rho_keypane->SetKey(prefs.increase_rho_key);
  160.     decrease_rho_keypane->SetKey(prefs.decrease_rho_key);
  161.     increase_alpha_keypane->SetKey(prefs.increase_alpha_key);
  162.     decrease_alpha_keypane->SetKey(prefs.decrease_alpha_key);
  163.     increase_beta_keypane->SetKey(prefs.increase_beta_key);
  164.     decrease_beta_keypane->SetKey(prefs.decrease_beta_key);
  165.     increase_gamma_keypane->SetKey(prefs.increase_gamma_key);
  166.     decrease_gamma_keypane->SetKey(prefs.decrease_gamma_key);
  167.     increase_delta_keypane->SetKey(prefs.increase_delta_key);
  168.     decrease_delta_keypane->SetKey(prefs.decrease_delta_key);
  169.  
  170.     times_ten_mod_menu->GetMenu()->SelectItem(prefs.times_ten_modifier, pmForceOn);
  171. #endif
  172.     
  173. }    //==== CMouseControlsDialog::MatchDialogToPrefs() ====\\