1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887
|
/*
* ===========================
* VDK Visual Development Kit
* Version 0.4
* October 1998
* ===========================
*
* Copyright (C) 1998, Mario Motta
* Developed by Mario Motta <mmotta@guest.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
#include "vdk/forms.h"
#include "vdk/vdkobj.h"
#include <gdk/gdkkeysyms.h>
#include <assert.h>
#include "vdk/colors.h"
#include "vdk/vdkfont.h"
#include "vdk/boxes.h"
#include "vdk/rawpixmap.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <config.h>
#if HAVE_GNOME
#include <gnome.h>
#endif
#ifdef VDKDEBUG
int formC = 0;
int formD = 0;
int childRemoved = 0;
int objRemoved = 0;
#endif
#define VERBOSE 0
/////////// ICONIFY STUFF /////////////
/* to test if ... */
static gboolean window_is_iconified (GdkWindow *window);
/* to test if window is iconized */
gboolean
window_is_iconified (GdkWindow *window)
{
XWindowAttributes xattr;
XGetWindowAttributes(GDK_WINDOW_XDISPLAY(window), GDK_WINDOW_XWINDOW(window), &xattr);
return (xattr.map_state == IsUnmapped);
}
/*
*/
bool
VDKForm::GetIconized()
{
g_return_val_if_fail (window->window != NULL,false);
return window_is_iconified(window->window);
}
/*
*/
void
VDKForm::SetIconized(bool flag)
{
if(flag && ! GetIconized())
{
gtk_window_iconify(GTK_WINDOW(window));
OnIconize(this);
}
else if (! flag && GetIconized())
{
gtk_window_deiconify(GTK_WINDOW(window));
OnRestore(this);
}
}
/*
*/
void
VDKForm::OnIconize(VDKForm* sender) {}
void
VDKForm::OnRestore(VDKForm* sender) {}
/////////////////////////////////////
/*
Delete event handler.
Checks if there are some
modals open up to the hierarchy,
in such case does not allow closure,
otherwise call CanClose()
*/
int VDKForm::DeleteEvent(GtkWidget* , GdkEvent* , gpointer gp)
{
g_return_val_if_fail(gp != NULL,TRUE);
VDKForm* form = reinterpret_cast<VDKForm*>(gp);
if(!form->isModal)
{
bool doclose = !form->modalCount;
VDKForm* own;
for(own = form->Owner(); own; own = own->Owner())
{
if(own->modalCount)
{
doclose = false;
break;
}
}
if(!doclose)
return TRUE;
}
return form->CanClose() ? FALSE : TRUE;
}
/*
Destroy event handler:
- if the form is modal one,close it.
- if the form is main form terminate app
Closes recursively all childs, remove himself
from owner list and notify his closure to
owner.
*/
int
VDKForm::DestroyEvent (GtkWidget*, gpointer gp)
{
g_return_val_if_fail(gp != NULL,FALSE);
VDKForm* form = reinterpret_cast<VDKForm*>(gp);
// in modal form stops inner event loop
// and re-activates parent
if(form->IsModal())
{
form->Owner()->modalCount--;
gtk_window_set_modal (GTK_WINDOW(form->Window()),FALSE);
gtk_main_quit();
}
// Only MainForm does not have parent, so closes application
if(!form->Owner())
form->Application()->Terminate();
else
{
form->CloseChilds();
form->Owner()->RemoveChild(form);
form->Owner()->OnChildClosing(form);
}
return TRUE;
}
/*
*/
//static int count = 0;
int
VDKForm::ConfigureEvent(GtkWidget* wid ,
GdkEventConfigure* ev ,
gpointer gp)
{
#if VERBOSE
printf("\nOnConfigure");
fflush(stdout);
#endif
g_return_val_if_fail(gp != NULL,FALSE);
g_return_val_if_fail(wid != NULL, FALSE);
VDKForm* form = reinterpret_cast<VDKForm*>(gp);
if (!GTK_WIDGET_VISIBLE(wid))
return FALSE; /* Can't get its size/pos */
VDKPoint p;
if(form->never_showed)
p = VDKPoint(wid->allocation.x,wid->allocation.y);
else
p = form->Position;
// VDKPoint p = form->Position;
VDKPoint s(ev->width,ev->height);
if(form->never_showed)
{
form->never_showed = false;
// sets form initial position
form->_oldPos = p;
form->Position(form->_oldPos);
form->_oldSize = s;
form->OnShow(form);
}
else if (p != form->_oldPos)
{
form->_oldPos = p;
form->OnMove(form);
}
form->OnConfigure(form);
return FALSE;// TRUE;
}
void
VDKForm::SizeAllocateSignal(GtkWidget *widget,
GtkAllocation *allocation,
gpointer gp)
{
VDKForm* form = reinterpret_cast<VDKForm*>(gp);
VDKPoint s(allocation->width,allocation->height);
#if VERBOSE
printf("\nVDKForm::SizeAllocateSignal()");
fflush(stdout);
#endif
if(s != form->_oldSize)
{
form->_oldSize = s;
#if VERBOSE
printf("\nold size(%d,%d) - new size(%d,%d)",
form->_oldSize.x,
form->_oldSize.y,
s.x,
s.y);
fflush(stdout);
#endif
form->OnResize(form,s);
}
}
/*
*/
int
VDKForm::ExposeEvent(GtkWidget* , GdkEventExpose* ev, gpointer gp)
{
// handle only last expose event
// TODO: check if it is a good strategy...
g_return_val_if_fail(ev != NULL, FALSE);
g_return_val_if_fail(gp != NULL, FALSE);
if(ev->count == 0)
{
VDKForm* form = reinterpret_cast<VDKForm*>(gp);
form->OnExpose(form, ev->area);
}
return FALSE; //TRUE;
}
/*
*/
void
VDKForm::RealizeSignal(GtkWidget* , gpointer gp)
{
g_return_if_fail(gp != NULL);
VDKForm* form = reinterpret_cast<VDKForm*>(gp);
VDKPoint pos = form->Position;
form->OnRealize(form);
}
int
VDKForm::MapEvent(GtkWidget* , GdkEvent* ev ,gpointer gp)
{
g_return_val_if_fail(gp != NULL, FALSE);
VDKForm* form = reinterpret_cast<VDKForm*>(gp);
if( ! form->never_showed)
form->OnRestore(form);
return FALSE;// TRUE;
}
int
VDKForm::UnmapEvent(GtkWidget* , GdkEvent* ev ,gpointer gp)
{
g_return_val_if_fail(gp != NULL, FALSE);
VDKForm* form = reinterpret_cast<VDKForm*>(gp);
form->OnIconize(form);
return FALSE;// TRUE;
}
/*
*/
gboolean
VDKForm::WindowStateEvent (GtkWidget *widget,
GdkEventWindowState *event)
{
#if VERBOSE
printf("\nWindowStateEvent - changed_masks:%d - new_state:%d",
event->changed_mask,event->new_window_state);
fflush(stdout);
#endif
return FALSE;
}
/*
*/
int VDKForm::FocusInEvent(GtkWidget* , GdkEvent* ev ,gpointer gp)
{
g_return_val_if_fail(gp != NULL, FALSE);
VDKForm* form = reinterpret_cast<VDKForm*>(gp);
form->OnFormActivate(form,true);
return FALSE; //TRUE;
}
/*
*/
int VDKForm::FocusOutEvent(GtkWidget* , GdkEvent* ev ,gpointer gp)
{
g_return_val_if_fail(gp != NULL, FALSE);
VDKForm* form = reinterpret_cast<VDKForm*>(gp);
form->OnFormActivate(form,false);
return FALSE; //TRUE;
}
/*
==================================================
*/
// MainForm constructor
VDKForm::VDKForm(VDKApplication* app, gchar *title,
int mode, GtkWindowType display):
VDKObject(NULL),
app(app),
// properties
Visible("Visible",this,true,&VDKForm::SetVisible,&VDKForm::GetVisible),
Title("Title",this,
title ? VDKString(title) : VDKString(""),&VDKForm::SetTitle),
Position("Position",this,VDKPoint(-1,-1),
&VDKForm::SetPosition,&VDKForm::GetPosition),
Iconized("Iconized",this,false,
&VDKForm::SetIconized,&VDKForm::GetIconized),
BackgroundPixmap("BackgroundPixmap",this,NULL,
&VDKForm::SetBackgroundPixmap),
FocusWidget("FocusWidget",this,NULL,&VDKForm::SetFocusWidget)
{
isModal = false;
modalCount = 0;
never_showed = true;
assert(app->MainForm == NULL || ! "MainForm");
widget = window = sigwid = gtk_window_new (display);
if(title)
gtk_window_set_title(GTK_WINDOW(window),title);
// sets the border width of the window
gtk_container_border_width (GTK_CONTAINER (window),2);
box = new VDKBox(this,mode);
items.add(box);
gtk_widget_set_name(box->Widget(),"VDKForm::Box");
gtk_container_add(GTK_CONTAINER(window),box->Widget());
gtk_widget_show(box->Widget());
box->Parent(this);
//////////////////////////////////////////////
//connect signals
SignalsConnect();
gtk_widget_realize(window);
#ifdef VDKDEBUG
formC++;
#endif
}
/*
*/
void VDKForm::SignalsConnect()
{
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (VDKForm::DeleteEvent), this);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC (VDKForm::DestroyEvent), this);
gtk_signal_connect (GTK_OBJECT (window), "configure_event",
GTK_SIGNAL_FUNC(VDKForm::ConfigureEvent),this);
gtk_signal_connect(GTK_OBJECT(window),"realize",
GTK_SIGNAL_FUNC(VDKForm::RealizeSignal),this);
gtk_signal_connect(GTK_OBJECT (window), "expose_event",
GTK_SIGNAL_FUNC(VDKForm::ExposeEvent),this);
gtk_signal_connect(GTK_OBJECT(window),"map_event",
GTK_SIGNAL_FUNC(VDKForm::MapEvent),this);
gtk_signal_connect(GTK_OBJECT(window),"unmap_event",
GTK_SIGNAL_FUNC(VDKForm::UnmapEvent),this);
gtk_signal_connect(GTK_OBJECT(window),"focus_in_event",
GTK_SIGNAL_FUNC(VDKForm::FocusInEvent),this);
gtk_signal_connect(GTK_OBJECT(window),"focus_out_event",
GTK_SIGNAL_FUNC(VDKForm::FocusOutEvent),this);
gtk_signal_connect_after(GTK_OBJECT(window),"size_allocate",
GTK_SIGNAL_FUNC(VDKForm::SizeAllocateSignal),this);
/*
gtk_signal_connect_after(GTK_OBJECT(window),"window_state_event",
GTK_SIGNAL_FUNC(VDKForm::WindowStateEvent),this);
*/
gtk_widget_add_events(Window(),GDK_KEY_RELEASE_MASK);
gtk_widget_add_events(Window(),GDK_KEY_PRESS_MASK);
}
/*
*/
VDKForm::VDKForm(VDKForm* owner, gchar* title ,
int mode, GtkWindowType display):
VDKObject(owner),
app(owner->Application()),
Visible("Visible",this,true,&VDKForm::SetVisible,&VDKForm::GetVisible),
Title("Title",this,
title ? VDKString(title) : VDKString(""),&VDKForm::SetTitle),
Position("Position",this,VDKPoint(0,0),
&VDKForm::SetPosition,&VDKForm::GetPosition),
Iconized("Iconized",this,false,
&VDKForm::SetIconized,&VDKForm::GetIconized),
BackgroundPixmap("BackgroundPixmap",this,NULL,
&VDKForm::SetBackgroundPixmap),
FocusWidget("FocusWidget",this,NULL,&VDKForm::SetFocusWidget)
{
isModal = false;
modalCount = 0;
never_showed = true;
widget = window = sigwid = gtk_window_new (display);
if(title)
gtk_window_set_title(GTK_WINDOW(window),title);
// sets the border width of the window
gtk_container_border_width (GTK_CONTAINER (window), 1);
box = new VDKBox(this,mode);
items.add(box);
gtk_widget_set_name(box->Widget(),"VDKForm::Box");
gtk_container_add(GTK_CONTAINER(window),box->Widget());
gtk_widget_show(box->Widget());
box->Parent(this);
//////////////////////////////////////////////
// connect signals
SignalsConnect();
gtk_widget_realize(window);
owner->AddChild(this);
#ifdef VDKDEBUG
formC++;
#endif
}
/*
called whenever user does not override
since now VDKForm is an abstract class
this is cancelled
void VDKForm::Setup(void)
{
gtk_widget_set_usize(GTK_WIDGET(box->Widget()),300,150);
}
*/
/*
Destructor
*/
VDKForm::~VDKForm()
{
// delete childs
ChildListIterator li(childs);
for(;li;li++)
delete li.current();
CollectGarbage();
#ifdef VDKDEBUG
formD++;
#endif
}
/*
CollectGarbage
*/
void VDKForm::CollectGarbage()
{
#ifdef VDKDEBUG
int childs = 0;
int objs = 0;
#endif
// delete childs garbage
ChildListIterator li(childsGarbage);
VDKItem<VDKForm> *p = li.Head();
VDKItem<VDKForm> *p1;
while(p)
{
#ifdef VDKDEBUG
childs++;
#endif
p1 = li.Next(p);
delete li.Now(p);
p = p1;
}
// this should be done
// now so a new garbage will find
// an empty list.
childsGarbage.flush();
// delete items garbage
ItemListIterator lo(garbages);
VDKItem<VDKObject> *o = lo.Head();
VDKItem<VDKObject> *o1;
while(o)
{
#ifdef VDKDEBUG
objs++;
#endif
o1 = lo.Next(o);
delete lo.Now(o);
o = o1;
}
// this should be done
// now..
garbages.flush();
#ifdef VDKDEBUG
if(childs || objs)
{
printf("\nGarbage collect: %d child(s), %d object(s)",
childs,objs);
fflush(stdout);
}
#endif
}
/*
removes child
*/
void VDKForm::RemoveChild(VDKForm* child)
{
if(childs.remove(child))
{
childsGarbage.add(child);
#ifdef VDKDEBUG
childRemoved++;
#endif
// removes child objects
ItemListIterator li(child->Items());
for(;li;li++)
{
li.current()->RemoveItems();
child->Garbages().add(li.current());
}
#ifdef VDKDEBUG
objRemoved += child->Items().size();
#endif
child->Items().flush();
}
}
/*
explicitely destroy this
*/
bool VDKForm::Destroy()
{
if(Owner() && ( Owner()->Childs().remove(this) ||
Owner()->ChildsGarbage().remove(this)) )
{
delete this;
return true;
}
else
return false;
}
/*
shows form:
pos can be:
- GTK_WIN_POS_NONE, (default)
- GTK_WIN_POS_CENTER,
- GTK_WIN_POS_CENTER_ALWAYS (for gtk+ version >= 1.2.5),
- GTK_WIN_POS_MOUSE
iteratively shows all childs
*/
void VDKForm::Show( GtkWindowPosition pos)
{
if(pos != GTK_WIN_POS_NONE)
gtk_window_position(GTK_WINDOW(Window()),pos);
gtk_widget_show(window);
ChildListIterator li(childs);
for(;li;li++)
gtk_widget_show (li.current()->Window());
#if 0
printf("\nallocation.width:%d,allocation.height:%d",
window->allocation.width,window->allocation.height);
fflush(stdout);
#endif
}
/*
iteratively hides all childs
*/
void VDKForm::Hide()
{
gtk_widget_hide (window);
ChildListIterator li(childs);
for(;li;li++)
gtk_widget_hide (li.current()->Window());
}
/*
shows modal
*/
void VDKForm::ShowModal(GtkWindowPosition pos)
{
isModal = true;
Owner()->modalCount++;
gtk_window_set_modal (GTK_WINDOW(window),TRUE);
//gtk_grab_add(GTK_WIDGET(window));
if(owner)
// this makes modal child
// to stay always on top
// of his parent.
// modal cannot be closed with WM sys menu
// if parent is iconized modal will be as well
gtk_window_set_transient_for(
GTK_WINDOW(window),
GTK_WINDOW(owner->Window())
);
Show(pos);
// initiates inner loop
gtk_main();
#if 0
printf("\nallocation.width:%d,allocation.height:%d",
window->allocation.width,window->allocation.height);
fflush(stdout);
#endif
}
/*
add a child window
*/
void VDKForm::AddChild(VDKForm* child)
{
childs.add(child);
child->Parent(this);
}
/*
add an object
*/
void VDKForm::Add(VDKObject* obj, int justify,
int expand, int fill, int padding)
{
items.add(obj);
// gtk+1.2.4
switch (justify)
{
case l_justify:
gtk_box_pack_start(GTK_BOX(box->Widget()),
obj->Widget(),expand,fill,padding);
break;
case r_justify:
gtk_box_pack_end(GTK_BOX(box->Widget()),
obj->Widget(),expand,fill,padding);
break;
default:
gtk_box_pack_start(GTK_BOX(box->Widget()),
obj->Widget(),expand,fill,padding);
}
obj->Parent(box);
// call setup on added object
// since Setup is virtual user can override it.
obj->Setup();
gtk_widget_show(obj->Widget());
}
/*
closes form
*/
void VDKForm::Close(void)
{
if( GTK_IS_WIDGET(window) && !DeleteEvent(NULL,NULL,this))
gtk_widget_destroy(window);
}
/*
closes form childs
(internally used)
*/
void VDKForm::CloseChilds(void)
{
ChildListIterator li(childs);
VDKItem<VDKForm> *p = li.Head();
VDKItem<VDKForm> *p1;
while(p)
{
p1 = li.Next(p);
li.Now(p)->Close();
p = p1;
}
/* */
childs.flush();
}
/*
query to close form
*/
bool VDKForm::CanClose()
{
return true;
}
/*
*/
void VDKForm::Raise()
{
if(Visible)
gdk_window_raise(window->window);
}
/*
*/
void VDKForm::Lower()
{
if(Visible)
gdk_window_lower(window->window);
}
/*
*/
void VDKForm::SetIcon(VDKRawPixmap* pix)
{
gdk_window_set_icon (window->window, NULL,
*pix, pix->Mask());
/*
gdk_window_set_decorations (window->window,
GdkWMDecoration(GDK_DECOR_ALL | GDK_DECOR_MENU));
gdk_window_set_functions (window->window,
GdkWMFunction(GDK_FUNC_ALL | GDK_FUNC_RESIZE));
*/
}
/*
*/
void VDKForm::SetIconName(char* name)
{
gdk_window_set_icon_name (window->window,name);
}
/*
*/
void
VDKForm::SetPosition(VDKPoint p)
{
if(never_showed)
gtk_widget_set_uposition(GTK_WIDGET(window), p.X(),p.Y());
else
gdk_window_move(window->window,p.X(),p.Y());
}
/*
*/
VDKPoint
VDKForm::GetPosition()
{
int x = -1,y = -1;
VDKPoint p(x,y);
/*
if(window->window && (!never_showed))
{
*/
gdk_window_get_root_origin(window->window,&x,&y);
//gdk_window_get_deskrelative_origin(window->window,&x,&y);
// gdk_window_get_position (window->window,&x,&y);
p.x = x;
p.y = y;
/*
}
else
p = VDKPoint(window->allocation.x,window->allocation.y);
*/
return p;
}
/*
*/
void
VDKForm::SetDefaultSize(VDKPoint p)
{
if(window)
{
gtk_window_set_default_size(GTK_WINDOW(window),p.X(),p.Y());
_oldSize = p;
}
}
/*
*/
void
VDKForm::SetBackgroundPixmap(VDKRawPixmap* pix)
{
GtkStyle *style;
/*
since a particular theme engine might not respect
the background pixmap, instead of copying the widget's
current style, i would create a new style from scratch:
*/
style = gtk_style_new ();
g_return_if_fail(style != NULL);
if(pix == NULL)
style->bg_pixmap[GTK_STATE_NORMAL] = NULL;
else
style->bg_pixmap[GTK_STATE_NORMAL] = pix->AsGdkPixmap();
// style->bg_pixmap[GTK_STATE_NORMAL] = pix ? *pix : NULL;
gtk_widget_set_style( Window(), style );
/*
Don't forget to unref the new style, or it will leak.
*/
gtk_style_unref(style);
}
void
VDKForm::SetFocusWidget(VDKObject* focuswidget)
{
g_return_if_fail(focuswidget != NULL);
focuswidget->GrabFocus();
}
/*
================================================
General responses (place holders for subclasses)
================================================
*/
void VDKForm::OnExpose( VDKForm*, GdkRectangle) { }
void VDKForm::OnChildClosing(VDKForm* ) { }
void VDKForm::OnShow(VDKForm*) { }
void VDKForm::OnRealize(VDKForm*) { }
void VDKForm::OnConfigure(VDKForm*) {}
void VDKForm::OnMove(VDKForm* sender) {}
void VDKForm::OnResize(VDKForm* sender,VDKPoint& ) {}
void VDKForm::OnFormActivate(VDKForm* sender,bool in_out ) {}
/*
=====================
GNOME STUFF GOES HERE
=====================
*/
VDKForm::VDKForm(VDKApplication* app,
GtkWidget* wid,
gchar *title):
VDKObject(NULL),
app(app),
// properties
Visible("Visible",this,true,&VDKForm::SetVisible,&VDKForm::GetVisible),
Title("Title",this,
title ? VDKString(title) : VDKString(""),&VDKForm::SetTitle),
Position("Position",this,VDKPoint(-1,-1),
&VDKForm::SetPosition,&VDKForm::GetPosition),
Iconized("Iconized",this,false,
&VDKForm::SetIconized,&VDKForm::GetIconized),
BackgroundPixmap("BackgroundPixmap",this,NULL,
&VDKForm::SetBackgroundPixmap),
FocusWidget("FocusWidget",this,NULL,&VDKForm::SetFocusWidget)
{
isModal = false;
modalCount = 0;
never_showed = true;
assert(app->MainForm == NULL || ! "MainForm");
assert(wid != NULL);
widget = window = sigwid = wid;
if(title)
gtk_window_set_title(GTK_WINDOW(window),title);
box = NULL;
//connect signals
SignalsConnect();
#ifdef VDKDEBUG
formC++;
#endif
}
// for builder only
#if HAVE_GNOME
VDKForm::VDKForm(VDKForm* owner,
GtkWidget* wid,
char* title):
VDKObject(NULL),
app(owner->Application()),
// properties
Visible("Visible",this,true,&VDKForm::SetVisible,&VDKForm::GetVisible),
Title("Title",this,
title ? VDKString(title) : VDKString(""),&VDKForm::SetTitle),
Position("Position",this,VDKPoint(-1,-1),
&VDKForm::SetPosition,&VDKForm::GetPosition),
Iconized("Iconized",this,false,
&VDKForm::SetIconized,&VDKForm::GetIconized),
BackgroundPixmap("BackgroundPixmap",this,NULL,
&VDKForm::SetBackgroundPixmap),
FocusWidget("FocusWidget",this,NULL,&VDKForm::SetFocusWidget)
{
isModal = false;
modalCount = 0;
never_showed = true;
assert(wid != NULL);
widget = window = sigwid = wid;
if(title)
gtk_window_set_title(GTK_WINDOW(window),title);
// set an inner box
// check if widget is a gnome app
box = new VDKBox(this,v_box);
items.add(box);
gtk_widget_set_name(box->Widget(),"VDKGnomeForm::Box");
gnome_app_set_contents(GNOME_APP(window),box->Widget());
gtk_widget_show(box->Widget());
box->Parent(this);
//connect signals
SignalsConnect();
owner->AddChild(this);
#ifdef VDKDEBUG
formC++;
#endif
}
#endif
|