1/* $Id$ 2 * 3 * Copyright (c) 2004, Joe English 4 * 5 * ttk::separator and ttk::sizegrip widgets. 6 */ 7 8#include <tk.h> 9 10#include "ttkTheme.h" 11#include "ttkWidget.h" 12 13/* +++ Separator widget record: 14 */ 15typedef struct 16{ 17 Tcl_Obj *orientObj; 18 int orient; 19} SeparatorPart; 20 21typedef struct 22{ 23 WidgetCore core; 24 SeparatorPart separator; 25} Separator; 26 27static Tk_OptionSpec SeparatorOptionSpecs[] = 28{ 29 {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal", 30 Tk_Offset(Separator,separator.orientObj), 31 Tk_Offset(Separator,separator.orient), 32 0,(ClientData)ttkOrientStrings,STYLE_CHANGED }, 33 34 WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) 35}; 36 37/* 38 * GetLayout hook -- 39 * Choose layout based on -orient option. 40 */ 41static Ttk_Layout SeparatorGetLayout( 42 Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr) 43{ 44 Separator *sep = recordPtr; 45 return TtkWidgetGetOrientedLayout( 46 interp, theme, recordPtr, sep->separator.orientObj); 47} 48 49/* 50 * Widget commands: 51 */ 52static const Ttk_Ensemble SeparatorCommands[] = { 53 { "configure", TtkWidgetConfigureCommand,0 }, 54 { "cget", TtkWidgetCgetCommand,0 }, 55 { "identify", TtkWidgetIdentifyCommand,0 }, 56 { "instate", TtkWidgetInstateCommand,0 }, 57 { "state", TtkWidgetStateCommand,0 }, 58 { 0,0,0 } 59}; 60 61/* 62 * Widget specification: 63 */ 64static WidgetSpec SeparatorWidgetSpec = 65{ 66 "TSeparator", /* className */ 67 sizeof(Separator), /* recordSize */ 68 SeparatorOptionSpecs, /* optionSpecs */ 69 SeparatorCommands, /* subcommands */ 70 TtkNullInitialize, /* initializeProc */ 71 TtkNullCleanup, /* cleanupProc */ 72 TtkCoreConfigure, /* configureProc */ 73 TtkNullPostConfigure, /* postConfigureProc */ 74 SeparatorGetLayout, /* getLayoutProc */ 75 TtkWidgetSize, /* sizeProc */ 76 TtkWidgetDoLayout, /* layoutProc */ 77 TtkWidgetDisplay /* displayProc */ 78}; 79 80TTK_BEGIN_LAYOUT(SeparatorLayout) 81 TTK_NODE("Separator.separator", TTK_FILL_BOTH) 82TTK_END_LAYOUT 83 84/* +++ Sizegrip widget: 85 * Has no options or methods other than the standard ones. 86 */ 87 88static const Ttk_Ensemble SizegripCommands[] = { 89 { "configure", TtkWidgetConfigureCommand,0 }, 90 { "cget", TtkWidgetCgetCommand,0 }, 91 { "identify", TtkWidgetIdentifyCommand,0 }, 92 { "instate", TtkWidgetInstateCommand,0 }, 93 { "state", TtkWidgetStateCommand,0 }, 94 { 0,0,0 } 95}; 96 97static WidgetSpec SizegripWidgetSpec = 98{ 99 "TSizegrip", /* className */ 100 sizeof(WidgetCore), /* recordSize */ 101 ttkCoreOptionSpecs, /* optionSpecs */ 102 SizegripCommands, /* subcommands */ 103 TtkNullInitialize, /* initializeProc */ 104 TtkNullCleanup, /* cleanupProc */ 105 TtkCoreConfigure, /* configureProc */ 106 TtkNullPostConfigure, /* postConfigureProc */ 107 TtkWidgetGetLayout, /* getLayoutProc */ 108 TtkWidgetSize, /* sizeProc */ 109 TtkWidgetDoLayout, /* layoutProc */ 110 TtkWidgetDisplay /* displayProc */ 111}; 112 113TTK_BEGIN_LAYOUT(SizegripLayout) 114 TTK_NODE("Sizegrip.sizegrip", TTK_PACK_BOTTOM|TTK_STICK_S|TTK_STICK_E) 115TTK_END_LAYOUT 116 117/* +++ Initialization: 118 */ 119 120MODULE_SCOPE 121void TtkSeparator_Init(Tcl_Interp *interp) 122{ 123 Ttk_Theme theme = Ttk_GetDefaultTheme(interp); 124 125 Ttk_RegisterLayout(theme, "TSeparator", SeparatorLayout); 126 Ttk_RegisterLayout(theme, "TSizegrip", SizegripLayout); 127 128 RegisterWidget(interp, "ttk::separator", &SeparatorWidgetSpec); 129 RegisterWidget(interp, "ttk::sizegrip", &SizegripWidgetSpec); 130} 131 132/*EOF*/ 133