summaryrefslogtreecommitdiff
path: root/app/wlib/gtklib/control.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2024-11-14 19:35:45 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2024-11-14 19:35:45 +0100
commitdf5520aa2dae5b3ce7abf8733dcdd152898af163 (patch)
tree00d3047bfb14f682bfb5a21010c731ed649bfed7 /app/wlib/gtklib/control.c
parentdf247efec654e512242e4f4f1b0212034f9e01fe (diff)
parentec3c0f6f6e7153fa797dc57a0e95779cbc63a23b (diff)
Merge branch 'release/debian/1_5.3.0GA-1'debian/1_5.3.0GA-1
Diffstat (limited to 'app/wlib/gtklib/control.c')
-rw-r--r--app/wlib/gtklib/control.c259
1 files changed, 129 insertions, 130 deletions
diff --git a/app/wlib/gtklib/control.c b/app/wlib/gtklib/control.c
index 07d9210..d43d2b6 100644
--- a/app/wlib/gtklib/control.c
+++ b/app/wlib/gtklib/control.c
@@ -1,7 +1,7 @@
/** \file control.c
* Control Utilities
*/
-/*
+/*
* Copyright 2016 Martin Fischer <m_fischer@sf.net>
*
* This program is free software; you can redistribute it and/or modify
@@ -46,31 +46,31 @@
*/
void wControlShow(
- wControl_p b,
- wBool_t show)
+ wControl_p b,
+ wBool_t show)
{
- if (b->type == B_LINES) {
- wlibLineShow((wLine_p)b, show);
- return;
- }
-
- if (b->widget == NULL) {
- abort();
- }
-
- if (show) {
- gtk_widget_show(b->widget);
-
- if (b->label) {
- gtk_widget_show(b->label);
- }
- } else {
- gtk_widget_hide(b->widget);
-
- if (b->label) {
- gtk_widget_hide(b->label);
- }
- }
+ if (b->type == B_LINES) {
+ wlibLineShow((wLine_p)b, show);
+ return;
+ }
+
+ if (b->widget == NULL) {
+ abort();
+ }
+
+ if (show) {
+ gtk_widget_show(b->widget);
+
+ if (b->label) {
+ gtk_widget_show(b->label);
+ }
+ } else {
+ gtk_widget_hide(b->widget);
+
+ if (b->label) {
+ gtk_widget_hide(b->label);
+ }
+ }
}
/**
@@ -82,14 +82,24 @@ void wControlShow(
*/
void wControlActive(
- wControl_p b,
- int active)
+ wControl_p b,
+ int active)
{
- if (b->widget == NULL) {
- abort();
- }
+ if (b->widget == NULL) {
+ abort();
+ }
+
+ if (b->type == B_LIST || b->type == B_DROPLIST ) {
+
+ gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(b->widget)), active);
+ gtk_combo_box_set_button_sensitivity(GTK_COMBO_BOX(b->widget),
+ active?GTK_SENSITIVITY_ON:GTK_SENSITIVITY_OFF);
- gtk_widget_set_sensitive(GTK_WIDGET(b->widget), active);
+ } else {
+
+ gtk_widget_set_sensitive(GTK_WIDGET(b->widget), active);
+
+ }
}
/**
@@ -102,17 +112,17 @@ void wControlActive(
* \returns width of label including some space
*/
-wPos_t wLabelWidth(
- const char * label)
+wWinPix_t wLabelWidth(
+ const char * label)
{
- GtkWidget * widget;
- GtkRequisition requisition;
- widget = gtk_label_new(wlibConvertInput(label));
- gtk_widget_size_request(widget, &requisition);
- g_object_ref_sink (widget);
- gtk_widget_destroy(widget);
- g_object_unref(widget);
- return requisition.width+8;
+ GtkWidget * widget;
+ GtkRequisition requisition;
+ widget = gtk_label_new(wlibConvertInput(label));
+ gtk_widget_size_request(widget, &requisition);
+ g_object_ref_sink (widget);
+ gtk_widget_destroy(widget);
+ g_object_unref(widget);
+ return requisition.width+8;
}
/**
@@ -122,10 +132,10 @@ wPos_t wLabelWidth(
* \returns width
*/
-wPos_t wControlGetWidth(
- wControl_p b)
+wWinPix_t wControlGetWidth(
+ wControl_p b)
{
- return b->w;
+ return b->w;
}
/**
@@ -135,10 +145,10 @@ wPos_t wControlGetWidth(
* \returns height
*/
-wPos_t wControlGetHeight(
- wControl_p b)
+wWinPix_t wControlGetHeight(
+ wControl_p b)
{
- return b->h;
+ return b->h;
}
/**
@@ -148,10 +158,10 @@ wPos_t wControlGetHeight(
* \returns position
*/
-wPos_t wControlGetPosX(
- wControl_p b) /* Control */
+wWinPix_t wControlGetPosX(
+ wControl_p b) /* Control */
{
- return b->realX;
+ return b->realX;
}
/**
@@ -161,10 +171,11 @@ wPos_t wControlGetPosX(
* \returns position
*/
-wPos_t wControlGetPosY(
- wControl_p b) /* Control */
+wWinPix_t wControlGetPosY(
+ wControl_p b) /* Control */
{
- return b->realY - BORDERSIZE - ((b->parent->option&F_MENUBAR)?b->parent->menu_height:0);
+ return b->realY - BORDERSIZE - ((b->parent->option&F_MENUBAR)
+ ?b->parent->menu_height:0);
}
/**
@@ -176,27 +187,29 @@ wPos_t wControlGetPosY(
*/
void wControlSetPos(
- wControl_p b,
- wPos_t x,
- wPos_t y)
+ wControl_p b,
+ wWinPix_t x,
+ wWinPix_t y)
{
- b->realX = x;
- b->realY = y + BORDERSIZE + ((b->parent->option&F_MENUBAR)?b->parent->menu_height:0);
-
- if (b->widget) {
- gtk_fixed_move(GTK_FIXED(b->parent->widget), b->widget, b->realX, b->realY);
- }
-
- if (b->label) {
- GtkRequisition requisition, reqwidget;
- gtk_widget_size_request(b->label, &requisition);
- if (b->widget)
- gtk_widget_size_request(b->widget, &reqwidget);
- else
- reqwidget.height = requisition.height;
- gtk_fixed_move(GTK_FIXED(b->parent->widget), b->label, b->realX-b->labelW,
- b->realY+(reqwidget.height/2 - requisition.height/2));
- }
+ b->realX = x;
+ b->realY = y + BORDERSIZE + ((b->parent->option&F_MENUBAR)
+ ?b->parent->menu_height:0);
+
+ if (b->widget) {
+ gtk_fixed_move(GTK_FIXED(b->parent->widget), b->widget, b->realX, b->realY);
+ }
+
+ if (b->label) {
+ GtkRequisition requisition, reqwidget;
+ gtk_widget_size_request(b->label, &requisition);
+ if (b->widget) {
+ gtk_widget_size_request(b->widget, &reqwidget);
+ } else {
+ reqwidget.height = requisition.height;
+ }
+ gtk_fixed_move(GTK_FIXED(b->parent->widget), b->label, b->realX-b->labelW,
+ b->realY+(reqwidget.height/2 - requisition.height/2));
+ }
}
/**
@@ -207,24 +220,25 @@ void wControlSetPos(
*/
void wControlSetLabel(
- wControl_p b,
- const char * labelStr)
+ wControl_p b,
+ const char * labelStr)
{
- GtkRequisition requisition,reqwidget;
-
- if (b->label) {
- gtk_label_set_text(GTK_LABEL(b->label), wlibConvertInput(labelStr));
- gtk_widget_size_request(b->label, &requisition);
- if (b->widget)
- gtk_widget_size_request(b->widget, &reqwidget);
- else
- reqwidget.height = requisition.height;
- b->labelW = requisition.width+8;
- gtk_fixed_move(GTK_FIXED(b->parent->widget), b->label, b->realX-b->labelW,
- b->realY+(reqwidget.height/2 - requisition.height/2));
- } else {
- b->labelW = wlibAddLabel(b, labelStr);
- }
+ GtkRequisition requisition,reqwidget;
+
+ if (b->label) {
+ gtk_label_set_text(GTK_LABEL(b->label), wlibConvertInput(labelStr));
+ gtk_widget_size_request(b->label, &requisition);
+ if (b->widget) {
+ gtk_widget_size_request(b->widget, &reqwidget);
+ } else {
+ reqwidget.height = requisition.height;
+ }
+ b->labelW = requisition.width+8;
+ gtk_fixed_move(GTK_FIXED(b->parent->widget), b->label, b->realX-b->labelW,
+ b->realY+(reqwidget.height/2 - requisition.height/2));
+ } else {
+ b->labelW = wlibAddLabel(b, labelStr);
+ }
}
/**
@@ -235,10 +249,10 @@ void wControlSetLabel(
*/
void wControlSetContext(
- wControl_p b,
- void * context)
+ wControl_p b,
+ void * context)
{
- b->data = context;
+ b->data = context;
}
/**
@@ -248,31 +262,21 @@ void wControlSetContext(
*/
void wControlSetFocus(
- wControl_p b)
+ wControl_p b)
{
}
wBool_t wControlExpose (
- GtkWidget * widget,
- GdkEventExpose * event,
- wControl_p b
- )
+ GtkWidget * widget,
+ GdkEventExpose * event,
+ wControl_p b
+)
{
GdkWindow * win = gtk_widget_get_window(b->widget);
cairo_t * cr = NULL;
if (win) {
cr = gdk_cairo_create(win);
- } else return TRUE;
-
-#ifdef CURSOR_SURFACE
- if (b && b->cursor_surface.surface && b->cursor_surface.show) {
- cairo_set_source_surface(cr,b->cursor_surface.surface,event->area.x, event->area.y);
- cairo_set_operator(cr,CAIRO_OPERATOR_OVER);
- cairo_rectangle(cr,event->area.x, event->area.y,
- event->area.width, event->area.height);
- cairo_fill(cr);
- }
-#endif
+ } else { return TRUE; }
if (b->outline) {
cairo_set_source_rgb(cr, 0.23, 0.37, 0.80);
@@ -281,7 +285,7 @@ wBool_t wControlExpose (
cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
cairo_set_line_join(cr, CAIRO_LINE_JOIN_MITER);
cairo_rectangle(cr,event->area.x+2, event->area.y+2,
- event->area.width-4, event->area.height-4);
+ event->area.width-4, event->area.height-4);
cairo_stroke(cr);
}
@@ -289,7 +293,7 @@ wBool_t wControlExpose (
cairo_destroy(cr);
- return FALSE;
+ return FALSE;
}
/**
@@ -301,26 +305,21 @@ wBool_t wControlExpose (
*
*/
void wControlHilite(
- wControl_p b,
- wBool_t hilite)
+ wControl_p b,
+ wBool_t hilite)
{
- cairo_t *cr;
- int off = GTKCONTROLHILITEWIDTH/2+1;
-
- if (b->widget == NULL) {
- return;
- }
-
- if (! gtk_widget_get_visible(b->widget)) {
- return;
- }
-
- if (! gtk_widget_get_visible(b->parent->widget)) {
- return;
- }
+// cairo_t *cr;
+// int off = GTKCONTROLHILITEWIDTH/2+1;
+ if ( debugWindow >= 1 ) {
+ printf( "wControlHIlite( %s, %d )\n", b->labelStr, hilite );
+ }
- b->outline = hilite;
+ if (b->widget == NULL) {
+ return;
+ }
+ b->outline = hilite;
- if (b->widget)
- gtk_widget_queue_draw(b->widget);
+ if (b->widget) {
+ gtk_widget_queue_draw(b->widget);
+ }
}