Mercurial > dwindows
comparison gtk/dw.c @ 155:840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
completely on Windows now and added DW_CLR_DEFAULT. Also color pairs don't
need to be of the same type anymore.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 07 Nov 2002 22:31:02 +0000 |
parents | a371875d5486 |
children | a07dd2e819f3 |
comparison
equal
deleted
inserted
replaced
154:7f8fcce45bdd | 155:840c54766306 |
---|---|
1322 gtk_object_set_data(GTK_OBJECT(handle), "backgdk", (gpointer)backgdk); | 1322 gtk_object_set_data(GTK_OBJECT(handle), "backgdk", (gpointer)backgdk); |
1323 } | 1323 } |
1324 | 1324 |
1325 int _set_color(HWND handle, unsigned long fore, unsigned long back) | 1325 int _set_color(HWND handle, unsigned long fore, unsigned long back) |
1326 { | 1326 { |
1327 /* Remember that each color component in X11 use 16 bit no matter | |
1328 * what the destination display supports. (and thus GDK) | |
1329 */ | |
1330 GdkColor forecolor, backcolor; | |
1327 #if GTK_MAJOR_VERSION < 2 | 1331 #if GTK_MAJOR_VERSION < 2 |
1328 GtkStyle *style; | 1332 GtkStyle *style = gtk_style_copy(gtk_widget_get_style(handle)); |
1329 #endif | 1333 #endif |
1330 | 1334 |
1331 if(fore & DW_RGB_COLOR || back & DW_RGB_COLOR) | 1335 if(fore & DW_RGB_COLOR) |
1332 { | 1336 { |
1333 /* Remember that each color component in X11 use 16 bit no matter | 1337 forecolor.pixel = 0; |
1334 * what the destination display supports. (and thus GDK) | 1338 forecolor.red = DW_RED_VALUE(fore) << 8; |
1335 */ | 1339 forecolor.green = DW_GREEN_VALUE(fore) << 8; |
1336 GdkColor forecolor = { 0, DW_RED_VALUE(fore) << 8, DW_GREEN_VALUE(fore) << 8, DW_BLUE_VALUE(fore) << 8 }; | 1340 forecolor.blue = DW_BLUE_VALUE(fore) << 8; |
1337 GdkColor backcolor = { 0, DW_RED_VALUE(back) << 8, DW_GREEN_VALUE(back) << 8, DW_BLUE_VALUE(back) << 8 }; | |
1338 | 1341 |
1339 gdk_color_alloc(_dw_cmap, &forecolor); | 1342 gdk_color_alloc(_dw_cmap, &forecolor); |
1340 gdk_color_alloc(_dw_cmap, &backcolor); | |
1341 | 1343 |
1342 #if GTK_MAJOR_VERSION > 1 | 1344 #if GTK_MAJOR_VERSION > 1 |
1343 gtk_widget_modify_text(handle, 0, &forecolor); | 1345 gtk_widget_modify_text(handle, 0, &forecolor); |
1344 gtk_widget_modify_text(handle, 1, &forecolor); | 1346 gtk_widget_modify_text(handle, 1, &forecolor); |
1345 gtk_widget_modify_fg(handle, 0, &forecolor); | 1347 gtk_widget_modify_fg(handle, 0, &forecolor); |
1346 gtk_widget_modify_fg(handle, 1, &forecolor); | 1348 gtk_widget_modify_fg(handle, 1, &forecolor); |
1349 #else | |
1350 if(style) | |
1351 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = forecolor; | |
1352 #endif | |
1353 } | |
1354 else if(fore != DW_CLR_DEFAULT) | |
1355 { | |
1356 forecolor = _colors[fore]; | |
1357 | |
1358 #if GTK_MAJOR_VERSION > 1 | |
1359 gtk_widget_modify_text(handle, 0, &_colors[fore]); | |
1360 gtk_widget_modify_text(handle, 1, &_colors[fore]); | |
1361 gtk_widget_modify_fg(handle, 0, &_colors[fore]); | |
1362 gtk_widget_modify_fg(handle, 1, &_colors[fore]); | |
1363 #else | |
1364 if(style) | |
1365 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = _colors[fore]; | |
1366 #endif | |
1367 } | |
1368 if(back & DW_RGB_COLOR) | |
1369 { | |
1370 backcolor.pixel = 0; | |
1371 backcolor.red = DW_RED_VALUE(back) << 8; | |
1372 backcolor.green = DW_GREEN_VALUE(back) << 8; | |
1373 backcolor.blue = DW_BLUE_VALUE(back) << 8; | |
1374 | |
1375 gdk_color_alloc(_dw_cmap, &backcolor); | |
1376 | |
1377 #if GTK_MAJOR_VERSION > 1 | |
1347 gtk_widget_modify_base(handle, 0, &backcolor); | 1378 gtk_widget_modify_base(handle, 0, &backcolor); |
1348 gtk_widget_modify_base(handle, 1, &backcolor); | 1379 gtk_widget_modify_base(handle, 1, &backcolor); |
1349 gtk_widget_modify_bg(handle, 0, &backcolor); | 1380 gtk_widget_modify_bg(handle, 0, &backcolor); |
1350 gtk_widget_modify_bg(handle, 1, &backcolor); | 1381 gtk_widget_modify_bg(handle, 1, &backcolor); |
1351 #else | 1382 #else |
1352 style = gtk_style_copy(gtk_widget_get_style(handle)); | |
1353 if(style) | 1383 if(style) |
1354 { | |
1355 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = forecolor; | |
1356 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = backcolor; | 1384 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = backcolor; |
1357 gtk_widget_set_style(handle, style); | 1385 #endif |
1358 gtk_style_unref(style); | 1386 } |
1359 } | 1387 else if(back != DW_CLR_DEFAULT) |
1360 #endif | 1388 { |
1361 | 1389 backcolor = _colors[back]; |
1362 _save_gdk_colors(handle, forecolor, backcolor); | 1390 |
1363 | |
1364 if(GTK_IS_CLIST(handle)) | |
1365 { | |
1366 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount"); | |
1367 | |
1368 for(z=0;z<rowcount;z++) | |
1369 { | |
1370 gtk_clist_set_foreground(GTK_CLIST(handle), z, &forecolor); | |
1371 gtk_clist_set_background(GTK_CLIST(handle), z, &backcolor); | |
1372 } | |
1373 } | |
1374 } | |
1375 else | |
1376 { | |
1377 #if GTK_MAJOR_VERSION > 1 | 1391 #if GTK_MAJOR_VERSION > 1 |
1378 gtk_widget_modify_text(handle, 0, &_colors[fore]); | |
1379 gtk_widget_modify_text(handle, 1, &_colors[fore]); | |
1380 gtk_widget_modify_fg(handle, 0, &_colors[fore]); | |
1381 gtk_widget_modify_fg(handle, 1, &_colors[fore]); | |
1382 gtk_widget_modify_base(handle, 0, &_colors[back]); | 1392 gtk_widget_modify_base(handle, 0, &_colors[back]); |
1383 gtk_widget_modify_base(handle, 1, &_colors[back]); | 1393 gtk_widget_modify_base(handle, 1, &_colors[back]); |
1384 gtk_widget_modify_bg(handle, 0, &_colors[back]); | 1394 gtk_widget_modify_bg(handle, 0, &_colors[back]); |
1385 gtk_widget_modify_bg(handle, 1, &_colors[back]); | 1395 gtk_widget_modify_bg(handle, 1, &_colors[back]); |
1386 #else | 1396 #else |
1387 style = gtk_style_copy(gtk_widget_get_style(handle)); | |
1388 if(style) | 1397 if(style) |
1389 { | |
1390 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = _colors[fore]; | |
1391 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = _colors[back]; | 1398 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = _colors[back]; |
1392 gtk_widget_set_style(handle, style); | 1399 #endif |
1393 } | 1400 } |
1394 #endif | 1401 |
1395 | 1402 _save_gdk_colors(handle, forecolor, backcolor); |
1396 _save_gdk_colors(handle, _colors[fore], _colors[back]); | 1403 |
1397 | 1404 if(GTK_IS_CLIST(handle)) |
1398 if(GTK_IS_CLIST(handle)) | 1405 { |
1399 { | 1406 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount"); |
1400 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount"); | 1407 |
1401 | 1408 for(z=0;z<rowcount;z++) |
1402 for(z=0;z<rowcount;z++) | 1409 { |
1403 { | 1410 gtk_clist_set_foreground(GTK_CLIST(handle), z, &forecolor); |
1404 gtk_clist_set_foreground(GTK_CLIST(handle), z, &_colors[fore]); | 1411 gtk_clist_set_background(GTK_CLIST(handle), z, &backcolor); |
1405 gtk_clist_set_background(GTK_CLIST(handle), z, &_colors[back]); | 1412 } |
1406 } | 1413 } |
1407 } | 1414 |
1408 } | 1415 #if GTK_MAJOR_VERSION < 2 |
1409 | 1416 if(style) |
1417 { | |
1418 gtk_widget_set_style(handle, style); | |
1419 gtk_style_unref(style); | |
1420 } | |
1421 #endif | |
1410 return TRUE; | 1422 return TRUE; |
1411 } | 1423 } |
1412 /* | 1424 /* |
1413 * Sets the colors used by a specified window (widget) handle. | 1425 * Sets the colors used by a specified window (widget) handle. |
1414 * Parameters: | 1426 * Parameters: |