15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
//==================================================================================================================================
// OGButton.m
//==================================================================================================================================
#define BCM_GETIDEALSIZE 0x1601
#import "OGButton.h"
//==================================================================================================================================
@interface OGButton ()
|
|
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
//==================================================================================================================================
// OGButton.m
//==================================================================================================================================
#define BCM_GETIDEALSIZE 0x1601
#import "OGButton.h"
//==================================================================================================================================
@interface OGButton ()
|
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
{
return [[[self alloc] init] autorelease];
}
//----------------------------------------------------------------------------------------------------------------------------------
- init
{
self = [super init];
//we're specifying a different class name...
//so we'll have to discard the default OGWidget HWND...
DestroyWindow(widget);
//and create a new one
widget = NULL;
HINSTANCE hInst = (HINSTANCE)GetModuleHandle(NULL);
widget = CreateWindow("button", "", BS_PUSHBUTTON,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInst, NULL);
SetWindowLong(widget, GWL_STYLE, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP);
//crazy workaround since we don't have control of our WNDPROC for default "button"s
CommandHandlerData *chd = (CommandHandlerData *)malloc(sizeof(CommandHandlerData));
chd->funct = CH_Command;
chd->object = self;
//and another workaround because "button" class seems to mess with our GWL_USERDATA storage...
//SetWindowLong(widget, GWL_USERDATA, (UINT)(chd));
SetProp(widget, "CommandHandlerData", chd);
[self retain];
return self;
}
//----------------------------------------------------------------------------------------------------------------------------------
- (OFString*)label
{
int tlen = GetWindowTextLength(widget);
char *buff = (char *)malloc(tlen + 1);
GetWindowText(widget, buff, tlen+1);
OFString *ret = [OFString stringWithUTF8String : buff];
free(buff);
return ret;
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)setLabel: (OFString*)label
{
|
|
|
|
|
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
{
return [[[self alloc] init] autorelease];
}
//----------------------------------------------------------------------------------------------------------------------------------
- init
{
self = [super init];
//we're specifying a different class name...
//so we'll have to discard the default OGWidget HWND...
DestroyWindow(widget);
//and create a new one
widget = NULL;
HINSTANCE hInst = (HINSTANCE)GetModuleHandle(NULL);
widget = CreateWindow("button", "", BS_PUSHBUTTON,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInst, NULL);
SetWindowLong(widget, GWL_STYLE, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP);
//crazy workaround since we don't have control of our WNDPROC for default "button"s
CommandHandlerData *chd = (CommandHandlerData *)malloc(sizeof(CommandHandlerData));
chd->funct = CH_Command;
chd->object = self;
//and another workaround because "button" class seems to mess with our GWL_USERDATA storage...
//SetWindowLong(widget, GWL_USERDATA, (UINT)(chd));
SetProp(widget, "CommandHandlerData", chd);
[self retain];
return self;
}
//----------------------------------------------------------------------------------------------------------------------------------
- (OFString*)label
{
int tlen = GetWindowTextLength(widget);
char *buff = (char *)malloc(tlen + 1);
GetWindowText(widget, buff, tlen+1);
OFString *ret = [OFString stringWithUTF8String : buff];
free(buff);
return ret;
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)setLabel: (OFString*)label
{
|