rollouts.h

Go to the documentation of this file.
00001 /*  
00002  *      Rollouts.h - Rollout panel classes & functions for MAXScript
00003  *
00004  *          Copyright (c) John Wainwright 1996
00005  *
00006  */
00007 
00008 #pragma once
00009 
00010 #include "..\kernel\value.h"
00011 #include "..\foundation\streams.h"
00012 #include "..\..\custcont.h"
00013 #include "..\..\control.h"
00014 #include "..\..\maxapi.h"
00015 
00016 // forward declarations
00017 class Array;
00018 class IMtlParams;
00019 class TexDADMgr;
00020 class MtlDADMgr;
00021 struct ParamDef;
00022 
00023 struct layout_data      // rollout control layout data
00024 {
00025     int left;
00026     int top;
00027     int width;
00028     int height;
00029     int columns;
00030 };
00031 
00032 /* some layout constants (in pixels) ... */
00033 
00034 #define TOP_MARGIN              2
00035 #define SIDE_MARGIN             4
00036 #define RADIO_DOT_WIDTH         23
00037 #define CHECK_BOX_WIDTH         24
00038 #define LEFT_ALIGN              13
00039 #define RIGHT_ALIGN             13
00040 #define GROUP_BOX_Y_MARGIN      6
00041 #define GROUP_BOX_X_MARGIN      4
00042 #define SPACING_BEFORE          5
00043 
00044 /* ---------------------- Rollout class ----------------------- */
00045 
00046 /* contains the defintion of  rollout panel.  This includes:
00047  *     - an 'instance variable' array, these variables can be accessed as locals in rollout handlers
00048  *     - a control array, containing rolout control instances
00049  *     - a hashtable of event handler functions
00050  *   there are associated Thunks for the locals & controls so you can ref them as variables in
00051  *   handlers
00052  */
00053 
00054 class RolloutControl;
00055 class RolloutFloater;
00056 class MSPlugin;
00057 class RolloutChangeCallback;
00058 class PB2Param;
00059 struct NotifyInfo;
00060 
00061 visible_class_debug_ok (Rollout)
00062 
00063 class Rollout : public Value
00064 {
00065 public:
00066     Value*      name;                       // rollout's variable name
00067     Value*      title;                      // title factor         
00068     HashTable*  local_scope;                // local name space         
00069     Value**     locals;                     // local var array          
00070     Value**     local_inits;                //   "    "    "  init vals 
00071     int         local_count;                //   "    "  count          
00072     RolloutControl** controls;              // control array            
00073     int         control_count;              //    "    "  count         
00074     HashTable*  handlers;                   // handler tables           
00075     short       flags;                      // rollout flags            
00076     short       order;                      // rollout open order no.   
00077     Interface*  ip;                         // Interface pointer        
00078     HWND        page;                       // my dialog HWND when visible 
00079     HDC         rollout_dc;                 // my dialog dev. context   
00080     HFONT       font;                       // dialog's default font    
00081     int         text_height;                // metrics....              
00082     int         default_control_leading;
00083     int         rollout_width;
00084     int         rollout_height;
00085     int         rollout_category;
00086     int         current_width;              // used for across: processing...
00087     int         current_left;
00088     int         max_y, last_y;
00089     int         across_count;
00090     WORD        close_button_ID;            // id of gen'd close button 
00091     BOOL        selected;                   // selected to be open  
00092     BOOL        disabled;                   // error in handler -> ro disabled      
00093     CharStream* source;                     // source text if available 
00094     BOOL        init_values;                // whether to init ctrl/local values on (re)open
00095     MSPlugin*   plugin;                     // plugin I'm open on if non-NULL
00096     RolloutChangeCallback* tcb;             // timechange callback if rollout has controller-linked spinners
00097     IMtlParams* imp;                        // MtlEditor interface if open in Mtl Editor and other stuff...
00098     TexDADMgr*  texDadMgr;
00099     MtlDADMgr*  mtlDadMgr;
00100     HWND        hwMtlEdit;
00101     RolloutFloater* rof;                    // owning rolloutfloater window if present there
00102     WORD        next_id;                    // dialog item ID allocators
00103     Tab<RolloutControl*> id_map;            // dialog item ID map for taking item ID's to associated RolloutControl
00104 
00105                 Rollout(short iflags);
00106     void        init(Value* name, Value* title, int local_count, Value** inits, HashTable* local_scope, RolloutControl** controls, int control_count, HashTable* handlers, CharStream* source);
00107                ~Rollout();
00108 
00109     static void ColorChangeNotifyProc(void* param, NotifyInfo* pInfo);
00110 #   define      is_rollout(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(Rollout))
00111                 classof_methods (Rollout, Value);
00112     void        collect() { delete this; }
00113     void        gc_trace();
00114     ScripterExport void     sprin1(CharStream* s);
00115 
00116     ScripterExport BOOL add_page(Interface *ip, HINSTANCE hInstance, int ro_flags = 0, RolloutFloater* rof = NULL);
00117     ScripterExport void delete_page(Interface *ip, RolloutFloater* rof = NULL);
00118     void        open(Interface *ip, BOOL rolled_up = FALSE);
00119     ScripterExport void close(Interface *ip, RolloutFloater* rof = NULL);
00120     ScripterExport BOOL ok_to_close(RolloutFloater* rof = NULL);
00121     ScripterExport void run_event_handler(Value* event, Value** arg_list, int count);
00122     ScripterExport bool has_event_handler(Value* event); // return true if event handler defined for rollout
00123 
00124     Value*      call_event_handler(Value* event, Value** arg_list, int count);
00125     void        add_close_button(HINSTANCE hInstance, int& current_y);
00126     void        edit_script();
00127     void        TimeChanged(TimeValue t);
00128 
00129     // various open/close for scripted plug-in rollouts
00130     // command panel
00131     void        BeginEditParams(IObjParam* ip, MSPlugin* plugin, ULONG flags, Animatable *prev);
00132     void        EndEditParams(IObjParam* ip, MSPlugin* plugin, ULONG flags, Animatable *next);
00133     // mtl editor
00134     void        CreateParamDlg(HWND hwMtlEdit, IMtlParams* imp, MSPlugin* plugin, TexDADMgr* texDadMgr, MtlDADMgr* mtlDadMgr);
00135     void        SetThing(MSPlugin* plugin);
00136     void        ReloadDialog();
00137     void        SetTime(TimeValue t);
00138     void        DeleteThis();
00139     // update/reload
00140     void        InvalidateUI();
00141     void        InvalidateUI(ParamID id, int tabIndex=-1); // nominated param
00142 
00143     virtual Value*  get_property(Value** arg_list, int count);
00144     virtual Value*  set_property(Value** arg_list, int count);
00145     virtual Value*  set_nested_controller(Value** arg_list, int count);
00146 
00147     // added 3/21/05. Used by debugger to dump locals and externals to standard out
00148     void        dump_local_vars_and_externals(int indentLevel);
00149 };
00150 
00151 #define RO_NO_CLOSEBUTTON   0x0001
00152 #define RO_HIDDEN           0x0002
00153 #define RO_ROLLED_UP        0x0004
00154 #define RO_IN_FLOATER       0x0008
00155 #define RO_INSTALLED        0x0010
00156 #define RO_UTIL_MASTER      0x0020
00157 #define RO_SILENT_ERRORS    0x0040
00158 #define RO_HIDDEN2          0x0080
00159 #define RO_PLUGIN_OWNED     0x0100
00160 #define RO_CONTROLS_INSTALLED   0x0200
00161 
00162 /* --------------------- RolloutFloater class ------------------------ */
00163 
00164 visible_class (RolloutFloater)
00165 
00166 class RolloutFloater : public Value, public IRollupCallback
00167 {
00168 public:
00169     //NOTE: May be null.  All affected code should have null checking
00170     HWND            window;     // modeless dialog window
00171 
00172     HWND            ru_window;  // host rollup winddow cust control
00173     IRollupWindow*  irw;
00174     Tab<Rollout*>   rollouts;   // my rollouts
00175     int             width, height; // window size...
00176     int             left, top; 
00177     bool            inDelete;
00178 
00179                 RolloutFloater(HWND hWnd);
00180                 RolloutFloater(MCHAR* title, int left, int top, int width, int height);
00181                 RolloutFloater() {window=ru_window=NULL;irw=NULL;width=height=left=top=0;inDelete=false;tag = class_tag(RolloutFloater);}
00182                ~RolloutFloater();
00183 #   define      is_rolloutfloater(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == class_tag(RolloutFloater))
00184 
00185     void        HandleDestroy(); // from IRollupCallback
00186 
00187                 classof_methods (RolloutFloater, Value);
00188     void        collect() { delete this; }
00189 
00190     // Needed to solve ambiguity between Collectable's operators and MaxHeapOperators
00191     using Collectable::operator new;
00192     using Collectable::operator delete;
00193 
00194     void        add_rollout(Rollout* ro, BOOL rolledUp, BOOL borderless);
00195     void        remove_rollout(Rollout* ro);
00196 
00197     Value*      get_property(Value** arg_list, int count);
00198     Value*      set_property(Value** arg_list, int count);
00199 };
00200 #pragma warning(push)
00201 #pragma warning(disable:4100)
00202 
00203 /* -------------------- RolloutControl classes ----------------------- */
00204 
00205 /* represent controls such as buttons & spinners on rollout panels, RolloutControl is abstract
00206  * root of all controls */
00207 
00208 visible_class (RolloutControl)
00209 
00210 class RolloutControl : public Value, public ReferenceMaker
00211 {
00212 public:
00213     Value*      name;
00214     Value*      caption;
00215     Value*      init_caption;
00216     BOOL        enabled;
00217     Value**     keyparms;
00218     int         keyparm_count;
00219     Rollout*    parent_rollout;
00220     WORD        control_ID;
00221     Control*    controller;     // optional linked animation controller
00222     ParamDimension*  dim;       // controllers dimension
00223     PB2Param*   pid;            // if non-NULL, indicates this control is associated with an MSPlugin parameter &
00224                                 //   points at ParamUIRep-like data for it
00225     short       flags;
00226 
00227     ScripterExport  RolloutControl();
00228     ScripterExport  RolloutControl(Value* name, Value* caption, Value** keyparms, int keyparm_count);
00229     ScripterExport ~RolloutControl();
00230 
00231                 classof_methods (RolloutControl, Value);
00232     BOOL        _is_rolloutcontrol() { return 1; }
00233 #   define      is_rolloutcontrol(v) ((v)->_is_rolloutcontrol())
00234     void        collect() { delete this; }
00235     ScripterExport void gc_trace();
00236 
00237     // Needed to solve ambiguity between Collectable's operators and MaxHeapOperators
00238     using Collectable::operator new;
00239     using Collectable::operator delete;
00240 
00241     virtual ScripterExport void add_control(Rollout *ro, HWND parent, HINSTANCE hInstance, int& current_y);
00242     virtual LPCMSTR get_control_class() = 0;
00243     virtual DWORD   get_control_style() { return WS_TABSTOP; }
00244     virtual DWORD   get_control_ex_style() { return 0; }
00245     virtual void    init_control(HWND control) { }
00246     virtual void    compute_layout(Rollout *ro, layout_data* pos) { }
00247     virtual ScripterExport void compute_layout(Rollout *ro, layout_data* pos, int& current_y);
00248     virtual ScripterExport void process_layout_params(Rollout *ro, layout_data* pos, int& current_y);
00249     virtual ScripterExport void setup_layout(Rollout *ro, layout_data* pos, int& current_y);
00250     virtual ScripterExport void process_common_params();
00251     virtual ScripterExport void call_event_handler(Rollout *ro, Value* event, Value** arg_list, int count);
00252     virtual ScripterExport void run_event_handler(Rollout *ro, Value* event, Value** arg_list, int count);
00253     virtual BOOL    handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam) { return FALSE; }
00254             ScripterExport WORD next_id();
00255 
00256     virtual ScripterExport Value* get_property(Value** arg_list, int count);
00257     virtual ScripterExport Value* set_property(Value** arg_list, int count);
00258     virtual ScripterExport void set_text(MCHAR* text, HWND ctl = NULL, Value* align = NULL);
00259     virtual ScripterExport void set_enable();
00260     virtual ScripterExport BOOL set_focus();
00261     virtual ScripterExport int num_controls() { return 1; }
00262             ScripterExport Value* get_event_handler(Value* event);
00263     // Animatable
00264     virtual Class_ID ClassID() { return Class_ID(0x3d063ac9, 0x7136487c); }
00265 
00266 
00267     // ReferenceMaker
00268     int         NumRefs() { return 1; }
00269     RefTargetHandle GetReference(int i) { return controller; }
00270 protected:
00271     virtual void        SetReference(int i, RefTargetHandle rtarg) { controller = (Control*)rtarg; }
00272 public:
00273     ScripterExport RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID,  RefMessage message);
00274     virtual void controller_changed() { }
00275     virtual BOOL controller_ok(Control* c) { return FALSE; }
00276 
00277     // PB2 UI update
00278     ScripterExport IParamBlock2* get_pblock();
00279     virtual void Reload() { }
00280     virtual void InvalidateUI() { }
00281     virtual void set_pb2_value() { }
00282     virtual void get_pb2_value(BOOL load_UI=TRUE) { }
00283     virtual void SetTexDADMgr(DADMgr* dad) { }
00284     virtual int FindSubTexFromHWND(HWND hw) { return -1; }
00285     virtual void SetMtlDADMgr(DADMgr* dad) { }
00286     virtual int FindSubMtlFromHWND(HWND hw) { return -1; } 
00287 
00288     // added for r8. wraps handler function in a PluginMethod pointing at scripted plugin associated with rollout 
00289             ScripterExport Value* get_wrapped_event_handler(Value* event);
00290 
00291     // added for r11
00292     HWND GetHWND();
00293 };
00294 
00295 // flag bits for RolloutControl::flags
00296 #define ROC_FIXED_WIDTH             0x0001  // a specific width: supplied, don't resize buttons on .text =
00297 #define ROC_MAKING_EDIT             0x0002
00298 #define ROC_INVISIBLE               0x0004  // rollout control is set to invisible and is disabled
00299 #define ROC_VAL_CHANGED             0x0008  // value was changed while control had focus
00300 #define ROC_EDITTEXT_MULTILINE      0x0010  // edittext control is multiline
00301 #define ROC_COLORSWATCH_POINT4      0x0010  // Set if color swatch is a Point4 (FRGBA)
00302 #define ROC_PICKBUTTON_AUTODISP     0x0010  // Set if autoDisplay is turned on for pickbutton (autodisplay node name)
00303 #define ROC_SPINNER_KEYBRACKETS     0x0010  // Set if spinner's setKeyBrakets is true(on).
00304 
00305 #define ROC_IN_HANDLER              0x0020  // Set if currently running event handler
00306 #define ROC_HANDLER_REENTRANT       0x0040  // Set if rollout control's event handlers are re-entrant. Only case is checkbutton.
00307 #define ROC_EDITTEXT_READONLY       0x0080  // edittext control is read-only
00308 
00309 #define ROC_DELETE_TOOLTIP          0x0100  // control has an extender-based tooltip to be manually deleted
00310 
00311 extern LPCMSTR cust_button_class;
00312 
00313 /* ------------- PB2Param class -------------------- */
00314 
00315 // present in a UI control if rollout is part of a scripted plugin
00316 // and this control is associated with a ParamBlock2  param
00317 
00318 class PB2Param
00319 {
00320 public:
00321     ParamID id;         // pblock param ID
00322     int index;          // pblock direct index of param
00323     int tabIndex;       // element index if param is Tab<>
00324     int block_id;       // owning block's ID
00325     int subobjno;       // texmap or mtl param subobjno in the block
00326     ParamDimension* dim;// parameter's dimension
00327     ParamType2 type;    // parameter's type
00328 
00329     PB2Param(const ParamDef& pd, int index, int block_id, int subobjno, int tabIndex = -1);
00330 }; 
00331 
00332 /* -------------------- LabelControl  ------------------- */
00333 
00334 visible_class (LabelControl)
00335 
00336 class LabelControl : public RolloutControl
00337 {
00338 public:
00339                 LabelControl(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00340                     : RolloutControl(name, caption, keyparms, keyparm_count) { tag = class_tag(LabelControl); }
00341 
00342     static RolloutControl* create(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00343                             { return new LabelControl (name, caption, keyparms, keyparm_count); }
00344 
00345                 classof_methods (LabelControl, RolloutControl);
00346     void        collect() { delete this; }
00347     ScripterExport void     sprin1(CharStream* s) { s->printf(_M("LabelControl:%s"), name->to_string()); }
00348 
00349     LPCMSTR     get_control_class() { return _M("STATIC"); }
00350     DWORD       get_control_style();
00351     void        compute_layout(Rollout *ro, layout_data* pos);
00352 };
00353 
00354 /* -------------------- ButtonControl  ------------------- */
00355 
00356 visible_class (ButtonControl)
00357 
00358 class ButtonControl : public RolloutControl
00359 {
00360 public:
00361     HIMAGELIST  images;
00362     int         image_width, image_height;
00363     int         iOutEn, iInEn, iOutDis, iInDis;
00364     MSTR        m_toolTip;
00365     int         colortheme;
00366     MSTR        images_filename;
00367 
00368                 ButtonControl(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00369                     : RolloutControl(name, caption, keyparms, keyparm_count)
00370                         {
00371                             tag = class_tag(ButtonControl);
00372                             images = NULL;
00373                             colortheme = FALSE;
00374                         }
00375                ~ButtonControl();
00376 
00377     static RolloutControl* create(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00378                             { return new ButtonControl (name, caption, keyparms, keyparm_count); }
00379 
00380                 classof_methods (ButtonControl, RolloutControl);
00381     void        collect() { delete this; }
00382     void        sprin1(CharStream* s) { s->printf(_M("ButtonControl:%s"), name->to_string()); }
00383 
00384     void        ColorChangeNotifyProc(void* param, NotifyInfo* pInfo);
00385     LPCMSTR     get_control_class() { return cust_button_class; }
00386     void        init_control(HWND control);
00387     void        compute_layout(Rollout *ro, layout_data* pos);
00388     BOOL        handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam);
00389     Value*      get_property(Value** arg_list, int count);
00390     Value*      set_property(Value** arg_list, int count);
00391     void        set_enable();
00392 };  
00393 
00394 /* -------------------- CheckButtonControl  ------------------- */
00395 
00396 visible_class (CheckButtonControl)
00397 
00398 class CheckButtonControl : public RolloutControl
00399 {
00400 public:
00401     int         checked;    // LAM - 2/11/02 - changed from BOOL (which is actually an int) since now tristate
00402     HIMAGELIST  images;
00403     int         image_width, image_height;
00404     int         iOutEn, iInEn, iOutDis, iInDis;
00405     MSTR        m_toolTip;
00406     int         colortheme;
00407     MSTR        images_filename;
00408 
00409                 CheckButtonControl(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00410                     : RolloutControl(name, caption, keyparms, keyparm_count)
00411                         {
00412                             tag = class_tag(CheckButtonControl);
00413                             images = NULL;
00414                             colortheme = FALSE;
00415                         }
00416                ~CheckButtonControl();
00417 
00418     static RolloutControl* create(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00419                             { return new CheckButtonControl (name, caption, keyparms, keyparm_count); }
00420 
00421                 classof_methods (CheckButtonControl, RolloutControl);
00422     void        collect() { delete this; }
00423     void        sprin1(CharStream* s) { s->printf(_M("CheckButtonControl:%s"), name->to_string()); }
00424 
00425     void        ColorChangeNotifyProc(void* param, NotifyInfo* pInfo);
00426     LPCMSTR     get_control_class() { return cust_button_class; }
00427     void        init_control(HWND control);
00428     void        compute_layout(Rollout *ro, layout_data* pos);
00429     BOOL        handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam);
00430     Value*      get_property(Value** arg_list, int count);
00431     Value*      set_property(Value** arg_list, int count);
00432     void        set_enable();
00433 
00434     void        Reload();
00435     void        InvalidateUI();
00436     void        set_pb2_value();
00437     void        get_pb2_value(BOOL load_UI=TRUE);
00438 };  
00439 
00440 /* -------------------- EditTextControl  ------------------- */
00441 
00442 visible_class (EditTextControl)
00443 
00444 class EditTextControl : public RolloutControl
00445 {
00446 public:
00447     Value*      text;
00448     Value*      bold;
00449     bool        in_setvalue;
00450 
00451                 EditTextControl(Value* name, Value* caption, Value** keyparms, int keyparm_count);
00452 
00453     static RolloutControl* create(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00454                             { return new EditTextControl (name, caption, keyparms, keyparm_count); }
00455 
00456                 classof_methods (EditTextControl, RolloutControl);
00457     void        collect() { delete this; }
00458     void        sprin1(CharStream* s) { s->printf(_M("EditTextControl:%s"), name->to_string()); }
00459     void        gc_trace();
00460 
00461     void        add_control(Rollout *ro, HWND parent, HINSTANCE hInstance, int& current_y);
00462     LPCMSTR     get_control_class() { return CUSTEDITWINDOWCLASS; }
00463     void        compute_layout(Rollout *ro, layout_data* pos, int& current_y);
00464     BOOL        handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam);
00465     Value*      get_property(Value** arg_list, int count);
00466     Value*      set_property(Value** arg_list, int count);
00467     void        set_enable();
00468     int         num_controls() { return 2; }
00469 
00470     void        Reload();
00471     void        InvalidateUI();
00472     void        set_pb2_value();
00473     void        get_pb2_value(BOOL load_UI=TRUE);
00474 };
00475 
00476 /* -------------------- ComboBoxControl  ------------------- */
00477 
00478 visible_class (ComboBoxControl)
00479 
00480 class ComboBoxControl : public RolloutControl
00481 {
00482 public:
00483     Array*      item_array;
00484     int         selection;
00485     short       type;
00486     short       flags;
00487 
00488                 ComboBoxControl(Value* name, Value* caption, Value** keyparms, int keyparm_count, int type = CBS_SIMPLE);
00489 
00490     static RolloutControl* create_cb(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00491                             { return new ComboBoxControl (name, caption, keyparms, keyparm_count); }
00492     static RolloutControl* create_dd(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00493                             { return new ComboBoxControl (name, caption, keyparms, keyparm_count, CBS_DROPDOWNLIST); }
00494 
00495                 classof_methods (ComboBoxControl, RolloutControl);
00496     void        collect() { delete this; }
00497     void        sprin1(CharStream* s) { s->printf(_M("ComboBoxControl:%s"), name->to_string()); }
00498     void        gc_trace();
00499 
00500     void        add_control(Rollout *ro, HWND parent, HINSTANCE hInstance, int& current_y);
00501     LPCMSTR     get_control_class() { return _M("COMBOBOX"); }
00502     DWORD       get_control_style() { return CBS_DROPDOWNLIST | CBS_NOINTEGRALHEIGHT | WS_TABSTOP; }
00503     void        compute_layout(Rollout *ro, layout_data* pos, int& current_y);
00504     BOOL        handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam);
00505     Value*      get_property(Value** arg_list, int count);
00506     Value*      set_property(Value** arg_list, int count);
00507     void        set_enable();
00508     int         num_controls() { return 2; }
00509 
00510     void        Reload();
00511     void        InvalidateUI();
00512     void        set_pb2_value();
00513     void        get_pb2_value(BOOL load_UI=TRUE);
00514 };
00515 
00516 #define CBF_EDIT_FIELD_CHANGING     0x0001
00517 
00518 /* -------------------- ListBoxControl  ------------------- */
00519 
00520 visible_class (ListBoxControl)
00521 
00522 class ListBoxControl : public RolloutControl
00523 {
00524 public:
00525     Array*      item_array;
00526     int         selection;
00527 
00528                 ListBoxControl(Value* name, Value* caption, Value** keyparms, int keyparm_count);
00529 
00530     static RolloutControl* create(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00531                             { return new ListBoxControl (name, caption, keyparms, keyparm_count); }
00532 
00533                 classof_methods (ListBoxControl, RolloutControl);
00534     void        collect() { delete this; }
00535     void        sprin1(CharStream* s) { s->printf(_M("ListBoxControl:%s"), name->to_string()); }
00536     void        gc_trace();
00537 
00538     void        add_control(Rollout *ro, HWND parent, HINSTANCE hInstance, int& current_y);
00539     LPCMSTR     get_control_class() { return _M("LISTBOX"); }
00540     DWORD       get_control_style() { return WS_TABSTOP; }
00541     void        compute_layout(Rollout *ro, layout_data* pos, int& current_y);
00542     BOOL        handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam);
00543     Value*      get_property(Value** arg_list, int count);
00544     Value*      set_property(Value** arg_list, int count);
00545     void        set_enable();
00546     int         num_controls() { return 2; }
00547 
00548     void        Reload();
00549     void        InvalidateUI();
00550     void        set_pb2_value();
00551     void        get_pb2_value(BOOL load_UI=TRUE);
00552 };
00553 
00554 /* -------------------- SpinnerControl  ------------------- */
00555 
00556 visible_class (SpinnerControl)
00557 
00558 class SpinnerControl : public RolloutControl
00559 {
00560 public:
00561     float       fvalue;
00562     int         ivalue;
00563     float       max, min;
00564     float       scale;
00565     EditSpinnerType spin_type;
00566 
00567                 SpinnerControl(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00568                     : RolloutControl(name, caption, keyparms, keyparm_count)  { tag = class_tag(SpinnerControl); }
00569 
00570     static RolloutControl* create(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00571                             { return new SpinnerControl (name, caption, keyparms, keyparm_count); }
00572 
00573                 classof_methods (SpinnerControl, RolloutControl);
00574     void        collect() { delete this; }
00575     void        sprin1(CharStream* s) { s->printf(_M("SpinnerControl:%s"), name->to_string()); }
00576 
00577     void        add_control(Rollout *ro, HWND parent, HINSTANCE hInstance, int& current_y);
00578     LPCMSTR     get_control_class() { return SPINNERWINDOWCLASS; }
00579     void        compute_layout(Rollout *ro, layout_data* pos, int& current_y);
00580     BOOL        handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam);
00581 
00582     Value*      get_property(Value** arg_list, int count);
00583     Value*      set_property(Value** arg_list, int count);
00584     void        set_enable();
00585     BOOL        set_focus();
00586     int         num_controls() { return 3; }
00587 
00588     void        controller_changed();
00589     BOOL        controller_ok(Control* c) { return c->SuperClassID() == CTRL_FLOAT_CLASS_ID; }
00590 
00591     void        Reload();
00592     void        InvalidateUI();
00593     void        set_pb2_value();
00594     void        get_pb2_value(BOOL load_UI=TRUE);
00595 };
00596 
00597 /* -------------------- SliderControl  ------------------- */
00598 
00599 visible_class (SliderControl)
00600 
00601 class SliderControl : public RolloutControl
00602 {
00603 public:
00604     float       value;
00605     float       max, min;
00606     int         ticks;
00607     int         slider_type;
00608     bool        vertical;
00609     bool        sliding;
00610 
00611                 SliderControl(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00612                     : RolloutControl(name, caption, keyparms, keyparm_count), sliding(false)  { tag = class_tag(SliderControl); }
00613 
00614     static RolloutControl* create(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00615                             { return new SliderControl (name, caption, keyparms, keyparm_count); }
00616 
00617                 classof_methods (SliderControl, RolloutControl);
00618     void        collect() { delete this; }
00619     void        sprin1(CharStream* s) { s->printf(_M("SliderControl:%s"), name->to_string()); }
00620 
00621     void        add_control(Rollout *ro, HWND parent, HINSTANCE hInstance, int& current_y);
00622     LPCMSTR     get_control_class();
00623     void        compute_layout(Rollout *ro, layout_data* pos, int& current_y);
00624     BOOL        handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam);
00625 
00626     Value*      get_property(Value** arg_list, int count);
00627     Value*      set_property(Value** arg_list, int count);
00628     void        set_enable();
00629     int         num_controls() { return 2; }
00630 
00631     void        controller_changed();
00632     BOOL        controller_ok(Control* c) { return c->SuperClassID() == CTRL_FLOAT_CLASS_ID; }
00633 
00634     void        Reload();
00635     void        InvalidateUI();
00636     void        set_pb2_value();
00637     void        get_pb2_value(BOOL load_UI=TRUE);
00638 };
00639 
00640 /* -------------------- PickerControl  ------------------- */
00641 
00642 class PickerControl;
00643 
00644 class PickerControlFilter : public PickNodeCallback
00645 {
00646 public:
00647         Value*  filter_fn;
00648         PickerControl*  picker;
00649 
00650                 PickerControlFilter(Value* filter, PickerControl* picker) : filter_fn(filter), picker(picker) { }
00651         BOOL    Filter(INode *node);
00652 };
00653 
00654 class PickerControlMode : public PickModeCallback
00655 {
00656 public:
00657         PickerControlFilter* pick_filter;
00658         MSTR            msg;
00659         PickerControl*  picker;
00660 
00661         PickerControlMode(PickerControlFilter* ifilter, MCHAR* imsg, PickerControl* ipick);
00662 
00663         BOOL    HitTest(IObjParam *ip, HWND hWnd, ViewExp *vpt, IPoint2 m, int flags);
00664         BOOL    Pick(IObjParam *ip, ViewExp *vpt);
00665         PickNodeCallback *GetFilter() { return pick_filter; }
00666         BOOL    RightClick(IObjParam *ip, ViewExp *vpt) { return TRUE; }
00667         void    EnterMode(IObjParam *ip);
00668         void    ExitMode(IObjParam *ip);
00669 };
00670 
00671 visible_class (PickerControl)
00672 
00673 class PickerControl : public RolloutControl
00674 {
00675 public:
00676     PickerControlFilter* pick_filter;
00677     PickerControlMode*   pick_mode;
00678     ICustButton*         cust_button; 
00679     Value*               picked_object;
00680     MSTR                 m_toolTip;
00681 
00682                 PickerControl(Value* name, Value* caption, Value** keyparms, int keyparm_count);
00683                ~PickerControl();
00684 
00685     static RolloutControl* create(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00686                             { return new PickerControl (name, caption, keyparms, keyparm_count); }
00687 
00688                 classof_methods (PickerControl, RolloutControl);
00689     void        collect() { delete this; }
00690     void        gc_trace();
00691     void        sprin1(CharStream* s) { s->printf(_M("PickerControl:%s"), name->to_string()); }
00692 
00693     LPCMSTR     get_control_class() { return cust_button_class; }
00694     void        compute_layout(Rollout *ro, layout_data* pos);
00695     void        init_control(HWND control);
00696     BOOL        handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam);
00697     Value*      get_property(Value** arg_list, int count);
00698     Value*      set_property(Value** arg_list, int count);
00699     void        set_enable();
00700 
00701     void        Reload();
00702     void        InvalidateUI();
00703     void        set_pb2_value();
00704     void        get_pb2_value(BOOL load_UI=TRUE);
00705 };
00706 
00707 /* -------------------- ColorPickerControl  ------------------- */
00708 
00709 visible_class (ColorPickerControl)
00710 
00711 class ColorPickerControl : public RolloutControl
00712 {
00713 public:
00714     Value*        color;
00715     IColorSwatch* csw;
00716     Value*        title;
00717     BOOL          notifyAfterAccept;
00718 
00719                 ColorPickerControl(Value* name, Value* caption, Value** keyparms, int keyparm_count);
00720                ~ColorPickerControl();
00721 
00722     static RolloutControl* create(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00723                             { return new ColorPickerControl (name, caption, keyparms, keyparm_count); }
00724 
00725                 classof_methods (ColorPickerControl, RolloutControl);
00726     void        collect() { delete this; }
00727     void        gc_trace();
00728     void        sprin1(CharStream* s) { s->printf(_M("ColorPickerControl:%s"), name->to_string()); }
00729 
00730     LPCMSTR     get_control_class() { return COLORSWATCHWINDOWCLASS; }
00731     void        init_control(HWND control);
00732     void        add_control(Rollout *ro, HWND parent, HINSTANCE hInstance, int& current_y);
00733     void        compute_layout(Rollout *ro, layout_data* pos, int& current_y);
00734     BOOL        handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam);
00735     Value*      get_property(Value** arg_list, int count);
00736     Value*      set_property(Value** arg_list, int count);
00737     void        set_enable();
00738     int         num_controls() { return 2; }
00739 
00740     void        Reload();
00741     void        InvalidateUI();
00742     void        set_pb2_value();
00743     void        get_pb2_value(BOOL load_UI=TRUE);
00744 };
00745 
00746 /* -------------------- RadioControl  ------------------- */
00747 
00748 visible_class (RadioControl)
00749 
00750 class RadioControl : public RolloutControl
00751 {
00752 public:
00753     int         state;
00754     int         btn_count;
00755 
00756                 RadioControl(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00757                     : RolloutControl(name, caption, keyparms, keyparm_count)  { tag = class_tag(RadioControl); }
00758 
00759     static RolloutControl* create(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00760                             { return new RadioControl (name, caption, keyparms, keyparm_count); }
00761 
00762                 classof_methods (RadioControl, RolloutControl);
00763     void        collect() { delete this; }
00764     void        sprin1(CharStream* s) { s->printf(_M("RadioControl:%s"), name->to_string()); }
00765 
00766     void        add_control(Rollout *ro, HWND parent, HINSTANCE hInstance, int& current_y);
00767     LPCMSTR     get_control_class() { return _M("BUTTON"); }
00768     DWORD       get_control_style() {  return BS_AUTORADIOBUTTON; }
00769     void        compute_layout(Rollout *ro, layout_data* pos, int& current_y);
00770     BOOL        handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam);
00771 
00772     Value*      get_property(Value** arg_list, int count);
00773     Value*      set_property(Value** arg_list, int count);
00774     void        set_enable();
00775     BOOL        set_focus();
00776     int         num_controls() { return btn_count + 1; } // buttons and caption. don't count 1 dummy button that ends group
00777 
00778     void        Reload();
00779     void        InvalidateUI();
00780     void        set_pb2_value();
00781     void        get_pb2_value(BOOL load_UI=TRUE);
00782 };
00783 
00784 /* -------------------- CheckBoxControl  ------------------- */
00785 
00786 visible_class (CheckBoxControl)
00787 
00788 class CheckBoxControl : public RolloutControl
00789 {
00790 public:
00791     int         checked; // LAM - 2/11/02 - added 3rd state (indeterminate). Changed from BOOL to int just for clarity.
00792 
00793                 CheckBoxControl(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00794                     : RolloutControl(name, caption, keyparms, keyparm_count)  { tag = class_tag(CheckBoxControl); }
00795 
00796     static RolloutControl* create(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00797                             { return new CheckBoxControl (name, caption, keyparms, keyparm_count); }
00798 
00799                 classof_methods (CheckBoxControl, RolloutControl);
00800     void        collect() { delete this; }
00801     void        sprin1(CharStream* s) { s->printf(_M("CheckBoxControl:%s"), name->to_string()); }
00802 
00803     LPCMSTR     get_control_class() { return _M("BUTTON"); }
00804     DWORD       get_control_style() {  return BS_AUTO3STATE | BS_MULTILINE | WS_TABSTOP; }
00805     void        init_control(HWND control);
00806     void        compute_layout(Rollout *ro, layout_data* pos);
00807     BOOL        handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam);
00808 
00809     Value*      get_property(Value** arg_list, int count);
00810     Value*      set_property(Value** arg_list, int count);
00811 
00812     void        Reload();
00813     void        InvalidateUI();
00814     void        set_pb2_value();
00815     void        get_pb2_value(BOOL load_UI=TRUE);
00816 };
00817 
00818 /* -------------------- BitmapControl  ------------------- */
00819 
00820 visible_class (BitmapControl)
00821 
00822 class BitmapControl : public RolloutControl
00823 {
00824 public:
00825     Value*      file_name;
00826     Value*      max_bitmap;    // if supplied
00827     HBITMAP     bitmap;
00828 
00829                 BitmapControl(Value* name, Value* caption, Value** keyparms, int keyparm_count);
00830                ~BitmapControl();
00831 
00832     static RolloutControl* create(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00833                             { return new BitmapControl (name, caption, keyparms, keyparm_count); }
00834 
00835                 classof_methods (BitmapControl, RolloutControl);
00836     void        collect() { delete this; }
00837     void        sprin1(CharStream* s) { s->printf(_M("BitmapControl:%s"), name->to_string()); }
00838     void        gc_trace();
00839 
00840     LPCMSTR     get_control_class() { return _M("STATIC"); }
00841     DWORD       get_control_style() { return SS_BITMAP + SS_CENTERIMAGE; }
00842     DWORD       get_control_ex_style() { return WS_EX_CLIENTEDGE; }
00843     void        compute_layout(Rollout *ro, layout_data* pos);
00844     void        process_layout_params(Rollout *ro, layout_data* pos, int& current_y);
00845     void        init_control(HWND control);
00846     Value*      get_property(Value** arg_list, int count);
00847     Value*      set_property(Value** arg_list, int count);
00848 };
00849 
00850 /* -------------------- MapButtonControl  ------------------- */
00851 
00852 visible_class (MapButtonControl)
00853 
00854 class MapButtonControl : public ButtonControl
00855 {
00856 public:
00857         Value*       map;
00858         ICustButton* btn;
00859 
00860                 MapButtonControl(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00861                     : ButtonControl(name, caption, keyparms, keyparm_count)
00862                         {
00863                             tag = class_tag(MapButtonControl);
00864                             btn = NULL;
00865                             map = NULL;
00866                         }
00867                 ~MapButtonControl() { if (btn != NULL) ReleaseICustButton(btn); }
00868 
00869     static RolloutControl* create(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00870                             { return new MapButtonControl (name, caption, keyparms, keyparm_count); }
00871 
00872                 classof_methods (MapButtonControl, RolloutControl);
00873     void        gc_trace();
00874     void        collect() { delete this; }
00875     void        sprin1(CharStream* s) { s->printf(_M("MapButtonControl:%s"), name->to_string()); }
00876 
00877     void        init_control(HWND control);
00878     BOOL        handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam);
00879     Value*      get_property(Value** arg_list, int count);
00880     Value*      set_property(Value** arg_list, int count);
00881 
00882     void        Reload();
00883     void        InvalidateUI();
00884     void        set_pb2_value();
00885     void        get_pb2_value(BOOL load_UI=TRUE);
00886 
00887     void        SetTexDADMgr(DADMgr* dad) { if (btn) btn->SetDADMgr(dad); }
00888     int         FindSubTexFromHWND(HWND hw);
00889 };  
00890 
00891 /* -------------------- MtlButtonControl  ------------------- */
00892 
00893 visible_class (MtlButtonControl)
00894 
00895 class MtlButtonControl : public ButtonControl
00896 {
00897 public:
00898         Value*       mtl;
00899         ICustButton* btn;
00900 
00901                 MtlButtonControl(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00902                     : ButtonControl(name, caption, keyparms, keyparm_count)
00903                         {
00904                             tag = class_tag(MtlButtonControl);
00905                             btn = NULL;
00906                             mtl = NULL;
00907                         }
00908                 ~MtlButtonControl() { if (btn != NULL) ReleaseICustButton(btn); }
00909 
00910     static RolloutControl* create(Value* name, Value* caption, Value** keyparms, int keyparm_count)
00911                             { return new MtlButtonControl (name, caption, keyparms, keyparm_count); }
00912 
00913                 classof_methods (MtlButtonControl, RolloutControl);
00914     void        gc_trace();
00915     void        collect() { delete this; }
00916     void        sprin1(CharStream* s) { s->printf(_M("MtlButtonControl:%s"), name->to_string()); }
00917 
00918     void        init_control(HWND control);
00919     BOOL        handle_message(Rollout *ro, UINT message, WPARAM wParam, LPARAM lParam);
00920     Value*      get_property(Value** arg_list, int count);
00921     Value*      set_property(Value** arg_list, int count);
00922     void        set_enable();
00923 
00924     void        Reload();
00925     void        InvalidateUI();
00926     void        set_pb2_value();
00927     void        get_pb2_value(BOOL load_UI=TRUE);
00928 
00929     void        SetMtlDADMgr(DADMgr* dad) { if (btn) btn->SetDADMgr(dad); }
00930     int         FindSubMtlFromHWND(HWND hw);
00931 };  
00932 
00933 /* ----------------------- GroupControls  ---------------------- */
00934 
00935 visible_class (GroupStartControl)
00936 
00937 class GroupStartControl : public RolloutControl
00938 {
00939 public:
00940     int     start_y;            /* y coord of top of group */
00941 
00942             GroupStartControl(Value* caption)
00943                 : RolloutControl(NULL, caption, NULL, 0)  
00944             { tag = class_tag(GroupStartControl); flags |= ROC_FIXED_WIDTH; }
00945 
00946             classof_methods (GroupStartControl, RolloutControl);
00947     void    collect() { delete this; }
00948     void    sprin1(CharStream* s) { s->printf(_M("GroupStartControl:%s"), caption->to_string()); }
00949 
00950     void    add_control(Rollout *ro, HWND parent, HINSTANCE hInstance, int& current_y);
00951     LPCMSTR get_control_class() { return _M(""); }
00952     void    compute_layout(Rollout *ro, layout_data* pos) { }
00953 };
00954 
00955 visible_class (GroupEndControl)
00956 
00957 class GroupEndControl : public RolloutControl
00958 {
00959     GroupStartControl* my_start;            /* link back to my group start control */
00960 public:
00961             GroupEndControl(GroupStartControl* starter)
00962                 : RolloutControl(NULL, starter->caption, NULL, 0) 
00963             { tag = class_tag(GroupEndControl); my_start = starter; flags |= ROC_FIXED_WIDTH;}
00964 
00965             classof_methods (GroupEndControl, RolloutControl);
00966     void    collect() { delete this; }
00967     void    sprin1(CharStream* s) { s->printf(_M("GroupEndControl:%s"), caption->to_string()); }
00968 
00969     void    add_control(Rollout *ro, HWND parent, HINSTANCE hInstance, int& current_y);
00970     LPCMSTR get_control_class() { return _M(""); }
00971     void    compute_layout(Rollout *ro, layout_data* pos) { }
00972 };
00973 #pragma warning(pop) // for C4100
00974 // ---- time change callback for rollouts with controller-linked spinners in them ----
00975 
00976 class RolloutChangeCallback : public TimeChangeCallback
00977 {
00978 public:
00979     Rollout*    ro;
00980                 RolloutChangeCallback(Rollout* iro) { ro = iro; }
00981     void        TimeChanged(TimeValue t) { ro->TimeChanged(t); }
00982 };
00983 
00984 /* control keyword parameter access macros... */
00985 
00986 extern ScripterExport Value* _get_control_param(Value** keyparms, int count, Value* key_name);
00987 extern ScripterExport Value* _get_control_param_or_default(Value** keyparms, int count, Value* key_name, Value* def);
00988 
00989 #define control_param(key)                  _get_control_param(keyparms, keyparm_count, n_##key)
00990 #define control_param_or_default(key, def)  _get_control_param_or_default(keyparms, keyparm_count, n_##key##, def)
00991 #define int_control_param(key, var, def)    ((var = _get_control_param(keyparms, keyparm_count, n_##key)) == &unsupplied ? def : var->to_int())
00992 #define float_control_param(key, var, def)  ((var = _get_control_param(keyparms, keyparm_count, n_##key)) == &unsupplied ? def : var->to_float())
00993