bsp
propctl.h
00001 #pragma once
00002 #include <windows.h>
00003 #include "window.h"
00004 #include "wcontrol.h"
00005 
00006 //
00007 // WPropEdit
00008 //
00009 class WPropertyGrid;
00010 class WPropEdit : public WEdit
00011 {
00012 public:
00013     WPropertyGrid *wprop;
00014     WPropEdit(HWND parent,int id,char * text,int cx,int cy, int width,int height,WPropertyGrid *wprop);
00015     LRESULT WndProc(UINT msg,WPARAM wParam,LPARAM lParam);
00016 };
00017 
00018 /*
00019 enum EditType {
00020         ET_NONE,
00021         ET_EDIT,
00022         ET_COMBO,
00023         ET_COLOR
00024 };
00025 
00026 //
00027 // WPropItem
00028 //
00029 class WPropItem {
00030 public:
00031         WPropItem(char *name, char *data, EditType edit_type = ET_NONE, void *param = 0);
00032         ~WPropItem();
00033         void set_name(char*);
00034         void set_display(char*);
00035         void set_value(char*);
00036 
00037         int idx;                                // added index
00038         EditType edit_type;             // editing controls to display
00039         void *param;                    // extra user data
00040         bool header;                    // header item
00041         bool disabled;                  // grayed out
00042         bool modified;                  // set when value changes
00043         bool error;                             // error state
00044         COLORREF backcolor;             // background color (auto fg), or -1 for auto bg
00045 
00046         char *name;
00047         int namelen;
00048         char *value;
00049         int valuelen;
00050         char *display;
00051         int displaylen;
00052 };
00053 //
00054 // WProperties
00055 //
00056 class WProperties : public WControl {
00057 public:
00058         WProperties(HWND parent,int id,int cx,int cy, int width,int height);
00059         ~WProperties();
00060 
00061         LRESULT WndProc(UINT msg,WPARAM wParam,LPARAM lParam);
00062 
00063         list<WPropItem*> items;
00064         WPropItem *Add(char *name, char *value, EditType et = ET_NONE, void *param = 0);
00065         void Clear();
00066 
00067         WEdit *wpedit;
00068         WFloatingList *wplist;
00069         DrawButton *button;
00070 
00071         WScroll scroll;
00072         RECT rect;
00073         bool get_item_rect(int idx, RECT *rc);
00074         void redraw();
00075         void mousedown(POINT pt);
00076         void mouseup(POINT pt);
00077         void mousemove(POINT pt);
00078         void resize(int cx, int cy);
00079         void resize_scrollbar();
00080         void scroll_into_view();
00081         int item_from_point(int Y);
00082         WPITEM *get_item(int idx);
00083         void start_edit();
00084         bool stop_edit();
00085         EditType edit_type;
00086 
00087         int splitter_pos;
00088         int item_height;
00089         int selected_idx;
00090         int edit_idx;
00091 
00092         bool edit_drag_hack;
00093         int edit_drag_start;
00094         int edit_drag_mx;
00095 
00096         bool mdown;
00097         bool splitdown;
00098         bool seldown;
00099         bool onsplit;
00100 };
00101 */
00102 
00103 
00104 //
00105 // WPropItem
00106 //
00107 class WPropItem
00108 {
00109 public:
00110     WPropItem(char *name, char *value = 0, DWORD data = 0);
00111     ~WPropItem();
00112     void set_name(char*);
00113     void set_value(char*);
00114 
00115     bool header;                        // header item
00116     bool disabled;                      // grayed out
00117     bool modified;                      // set true when name or value has been changed
00118     COLORREF backcolor;         // -1 for default
00119     COLORREF forecolor;         // -1 for default
00120 
00121     char *name;
00122     int namelen;
00123     char *value;
00124     int valuelen;
00125 
00126     DWORD data;                         // custom data
00127     //dropdown list support:
00128     DWORD list_name;            // these are the actual values to use for lists.
00129     DWORD list_value;           // set_name/set_value are just for display
00130 
00131     int button_type;            // button type of item
00132     int max_edit_width;         // limit width of edit - use to show bgcolor
00133 };
00134 
00135 typedef listitem<WPropItem*> WPITEM;
00136 #define WP_BWIDTH    13
00137 
00138 #define PM_CLICK        WM_USER+1       //left single click, wparam=wpropitem, lparam=part
00139 #define PM_RCLICK       WM_USER+2   //right single click, wparam=wpropitem, lparam=part
00140 #define PM_DBLCLICK     WM_USER+3       //left double click, wparam=wpropitem, lparam=part
00141 #define PM_CHANGE       WM_USER+4       //wparam = wpropitem, lparam = new string. return true to accept
00142 #define PM_POPLIST      WM_USER+5       //wparam = wpropitem, lparam = WList
00143 #define PM_EDITBTN      WM_USER+6       //wparam = wpropitem, lparam = 0
00144 #define PM_LIST_CHANGE WM_USER+7        //wparam = list item id
00145 #define PM_TABBED       WM_USER+8       //wparam = shift held
00146 #define PM_SELCHANGE WM_USER+9  //return button part for default edit button
00147 
00148 class WPropertyGrid : public WControl
00149 {
00150 public:
00151     enum Parts {partNone=0,partLeft,partRight,partHeader,partSplitter,partAny};
00152     enum ButtonType {btypeNone=0,btypeDrop,btypeList};
00153 
00154     WPropertyGrid(HWND parent,int id,int cx,int cy, int width,int height);
00155     ~WPropertyGrid();
00156 
00157     LRESULT WndProc(UINT msg,WPARAM wParam,LPARAM lParam);
00158 
00159     list<WPropItem*> items;
00160     WPropItem *Add(char *name, char *value = 0, DWORD data = 0);
00161     void Clear();
00162 
00163     WFloatingList *wplist;
00164     WPropEdit *wpedit;
00165 
00166     WScroll scroll;
00167     RECT rect;
00168     DrawButton *edit_button;
00169     void Redraw();
00170     void mousedown(POINT pt, int button, bool doubleclick=false);
00171     void mouseup(POINT pt, int button);
00172     void mousemove(POINT pt);
00173     void Resize(int cx, int cy);
00174     void ResizeScrollbar();
00175     void ResizeList();
00176     void ScrollIntoView();
00177     void MoveSelUp();
00178     void MoveSelDown();
00179     void ScrollUp();
00180     void ScrollDown();
00181     int ItemFromPoint(int Y);
00182     void ClickEditButton();
00183     WPITEM *GetItem(int idx = -1);
00184     bool GetItemRect(int idx, RECT *rc);
00185 
00186     void ResizeEdit();
00187     void ShowEdit(int part);
00188     bool HideEdit(bool change);
00189     bool edit_visible;
00190     int edit_part;
00191 
00192     bool modified;
00193     int splitter_pos;
00194     int item_height;
00195     int selected_idx;
00196     int tmp_idx;
00197     bool mdown;
00198     bool splitdown;
00199     bool onsplit;
00200 };
 All Classes Functions