Class reference manual

Version 1.0.1 - october 1999

 

 

Mario Motta

mmotta@guest.net

Intentionally left blank page

The Visual Development Kit


Version 1.0.1

October 1999

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

By Mario Motta

mmotta@guest.net


Copyright ã 1998,1999 Mario Motta

Permission is granted to make and distribute verbatim copies of this manual provided that the copyright notice and this permission notice are preserved in all copies.

Permission is granted to copy and distribute modified version, including translation in other languages, of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Any translated version of this permission notice must have been approved by Mario Motta.

Intentionally left blank page

INDEX

General informations

General considerations pag. 7

Signals and events

Using static tables pag. 8

Using dynamic tables pag. 14

About properties pag. 16

VDK classes hierarchy pag. 20

VDK components hierarchy pag. 21

CLASS REFERENCE

Application pag. 25

objects gtk+ wrapped

Form GtkWindow pag. 28

Scrolled GtkScrolled pag. 32

Scrolled Form pag. 33

Paned Form pag. 34

Base object pag. 35

Box GtkBox pag. 40

Event box pag. 41

Object Container GtkContainer pag. 42

Canvas GtkDrawingArea pag. 43

Check buttons GtkCheckButton pag. 45

Custom Button GtkButton pag. 46

Custom class pag. 48

Custom List GtkClist pag. 50

Custom Tree GtkCTree pag. 53

Custom Sorted List pag. 55

File selection GtkFileSelection pag. 56

Fixed GtkFixed pag. 57

Frames GtkFrame pag. 58

Entry GtkEntry pag. 59

NumericEntry pag. 60

HandleBox GtkHandleBox pag. 61

Label GtkLabel pag. 62

Label Button GtkButton pag. 63

Menus GtkMenu’s pag. 64

MenuBar pag. 66

OptionMenu pag. 67

Menu Programming Tips pag. 67

Tab Page pag. 68

Notebook GtkNotebook pag. 68

Packer GtkPacker pag. 70

Paned GtkPaned pag. 71

Pixmap GtkPixmap pag. 72

Pixmap Button pag. 73

ProgressBar GtkProgressBar pag. 74

Radio buttons GtkRadioButton pag. 75

Separator GtkSeparator pag. 77

Slider GtkScale pag. 78

Spin buttons GtkSpinButton pag. 79

Status bar GtkStatusbar pag. 80

Table GtkTable pag. 81

Text GtkText pag. 82

Timer timeout pag. 84

Toolbar GtkToolbar pag. 85

Tooltip GtkTooltips pag. 87

MISCELLANEOUS

Array pag. 88

Btree pag. 89

Btree Iterator pag. 90

Calendar date pag. 91

Heap pag. 93

Point pag. 94

Rect pag. 95

Rgb pag. 96

Strings pag. 97

ValueLists (value semantic) pag. 98

ValueList Iterator pag. 99

Lists (ref semantic) pag. 100

raw objects pag. 101

Color pag. 101

Font pag. 102

Raw Pixmap pag. 103

components

Chart pag. 107

Color browser pag. 110

Cool Buttons and Coolbar pag. 111

Combo box GtkCombo pag. 113

Data box GtkDataBox pag. 116

File dialog pag. 120

File save as dialog pag. 120

File tree dialog pag. 120

Grid GtkSheet pag. 121

Panel bar pag. 124

APPENDICES

Gtk enumerations and types pag. 127

VDK plugin components pag. 131

VDKCalendar pag. 132

VDKDigitalClock pag. 133

Wrapping gtk+ widgets example pag. 134

Other widgets/objects undocumented or not documented here

VDKInput ./contrib/input

VDKThread ./contrib/thread/vdkthread.txt

VDKToggleButton ./include/vdk/togglebutton.h

VDKLabelToggleButton ./include/vdk/label_togglebutton.h

VDKPixmapToggleButton ./include/vdk/pix_togglebutton.h

Note:

This manual is a living document and changes with the development of VDK. I hope that the hints and tips will be useful.

More information can be obtained from the examples source files in ./testvdk

Comments and suggestions are welcome.

Credits

I’m grateful to Dave Freese DFreese@osc.uscg.mil for assistance in proof reading this manual.

This applies to all VDK team and contributors.

 

General considerations

  1. Almost all VDKObjects must be constructed on the heap with the new operator, any copy-initializing and/or assignement operations between objects are prohibited and will be flagged as a compilation error.
  2. No memory freeing and/or deleting is required, all new’ed objects will be automatically destroyed immediately before application termination or with a timed garbage collection that can be installed/uninstalled by programmer. However VDKObject(s) can be explicitely freed with the Destroy() method.
  3. Both GTK+ "signals" mechanism and the "event" dispatch are available for programmer use but are handled in a different way.
  4. VDK uses the "property" concepts introduced with RAD, therefore using properties is encouraged even if it’s also possible to have usual functions to set/get objects attributes.
  5. The word "window" used in Gtk+ is here replaced with "Form".
  6. VDK is consists into two separated modules:

VDK DESIGN NOTES

VDK was designed to be more a C++ framework based on Gtk+ widget set library than a thin-layer wrapper. VDK hides on the background as much gtk+ work as possible rather than wrap all gtk+ function calls. Using VDK one will realize that many one-to-one statement with gtk+ are not wrapped. Even if is possible to make use of VDK without knowing gtk+, more experienced user will take advantage of knowing gtk+ calls and conventions. At this end VDK provides method to access and use underlying gtk+ widgets.

Gtk+ enums and naming conventions are reported into Appendix A, user should also read and know following gtk+/gdk distribution files:

VDK is used as base library of VDKBuilder RAD tool, using VDK with VDKBuilder is highly encouraged since user can concentrate his attention to the application rather than gui construction. Also in this case a good knowledge of VDK is a good way to take advantage from using VDKBuilder.

VDK ON THE NET

VDK and VDKBuilder have their own web site:

VDK

http://www.programmers.net/artic/Motta/vdk (primary site)

http://www.guest.net/homepages/mmotta/vdkhome (alternate site)

VDKBuilder

http://www.programmers.net/artic/Motta/vdkbuilder (primary site)

http://www.guest.net/homepages/mmotta/vdkbuilder (alternate site)

In order to support VDK/VDKBuilder users two mailing list are now active, users are encouraged to subscribe them.

Signals and events

General

There are two strategies available to manage signals and events . The programmer can choose to implement either or both. The first one, used by VDK itself, must be established at compile-time and uses static signal tables. The second one uses dynamic signal tables and allows the programmer to connect and disconnect both signals and events at run-time and is very similar to that which Gtk+ uses. Here some considerations about the differences between the two methods:

The example files hello.cc and hello2.cc demonstrate the two different strategies.

signal and events with static tables

Signals and events are connected with class methods using two different tables: SIGNAL_MAP and EVENT_MAP. With this strategy callbacks are converted into form class methods that can directly answer to widgets signals and/or events.

To construct signal map user make use of these macros:

To construct the event map the programmer must use the following macros:

Response methods (were callbacks in Gtk+)

bool SomeFormClass::AnswerMethod(VDKObject* sender);

so they receive the address of signal generating object.

bool SomeFormClass:AnswerEvent(VDKObject* sender, GdkEvent* event);

(Hint: make a cast from GdkEvent event to GdkEventXxxx* to use it effectively:

bool SomeFormClass::OnMouseMotion(VDKObject* sender, GdkEvent* ev)

{

GdkEventMotion* event = (GdkEventXxxx*) ev;

// .. use event

}

Multiple response methods for signal and events

It is possible to establish more than one response method for a single signal on a single object just adding a line to signal table with ON_SIGNAL or ON_EVENT macro. Response method will be called on the same order they appear on signal/event table. Each single response method will be considered indipendently from previous one, thus will be called even if the previous is already been "treated".

Detaching signals/events

Some VDKObject member functions are provided to manage signal/event connecting/disconnecting:

Disconnect signal <signal> from <object>, the response method previously declared into SIGNAL_MAP will stop answering to <signal>. Method returns the signal "slot" number that was deactivated and that should be used in order to reconnect the signal later. Answering –1 means that the signal was not detached. Multiple response method will be detached in the same order they appear on signal table.

Reactivate the signal into slot <slot>. This number should be previously achieved with a SIGNAL_DETACH() call on a signal.

Same as SignalDetach()

Same as SignalAttach()

The following code:

static int slots[X+1];

// where X is the number of response methods on that signal/object

void MyForm::DetachAllButtonSignals()

{

int slot,t;

for( t= 0; (slot = SignalDetach(button ,clicked_signal)) != -1; t++)

slots[t] = slot;

slot[t] = -1;

}

will detach all clicked signals on <button> and store slot numbers into slots[] array for a later use.

These functions are provided in the aim to maintain Gtk+ similarity but, as will be explained later, the broadcasting and hierarchy strategy that VDK adopts in dispatching signals should make it be rare that you need above functions.

 

Signals dispatching

Signals are emitted by objects to a recursive "pattern visiting" dispatching algorithm. A first recursion is made into the object hierarchy (so called class level) , another is made into object parent hierarchy (so called parent level). Signal flow will be stopped as soon as signal is flagged as "treated" , that is the dispatching algorithm finds a defined signal response table entry (so called slot) for that signal on that object that answered "true".

Here a typical signal path:

  1. Signal emitted by an object
  2. Signal goes to object class , if "treated" stops, otherwise recursively goes up to object hierarchy until "treated" or reach object root class.
  3. If not yet "treated" and object has a parent goes to parent class, if "treated" stops otherwise goes up to parent hierarchy until "treated" or reaches parent root class. If parent has a parent step 3 is repeated until no parent is found.
  4. Tip: into parent hierarchy there is only an object that surely does’nt have parent, this is the application main form..

  5. If not yet "treated" signal is lost.

Tip: above and below considerations apply to events as well.

This mechanism permits a wide broadcasting strategy and allows to inherit response tables among objects hierarchy.

Signals can be emitted in two ways:

Tip: events cannot be user emitted.

ownership , parenthood and signal flow levels

The concepts explained below are intended mainly for signal flow only and should not be confused with same concepts regarding object organisation and management specially in Gtk+ side.

Ownership

All objects have an owner, the owner is always a form where the object is contained in, owner takes care of objects displacement and memory freeing, does not interest signal flow.

Parenthood

A parent is an object , usually a form, a box, a table, a frame or others container but generally it speaking can be any object. Parent groups objects into a logical unit respect to signal flow. Normally objects have a parent (owner form is their outmost parent by default), but user can set the object parenthood using VDKObject::Parent(parent) class method. Adding any object to a container sets by default the container as object parent so the user does’nt have to call Parent() explicitely.

Class level

This is the first level a signal goes through. In VDK stock hierarchy no class answers to signals at this level. The purpose is to allow the programmer to derive his or her own objects and to let them answer "internally" to signals before emitting the same or another signal to upper levels. In this case macros for established static response tables are slightly different:

bool SomeObjectClass::AnswerMethod(VDKObject* sender);

Emitting a signal from a derived object can be made in two ways:

Parent level

If the signal is not responded to at the class it goes to the next object parent and recursively into the parent hierarchy until it reaches the parent root class. This process is repeated until the outer most parent is reached. If the signal is not responded to, it can therefore reach the application main form that surely is "the mother af all parents".

Parent level is most used when you want make a composite object that manages several "inner" objects catching their signal and sending a unified or modified answer to his parent. This gives the possibility to make components completely abstracted from the application that is using them. The application can only answer to a signal coming from one of it’s components and nothing knows about component internals.

Providing flexibility

The above topics discuss the signal dispatch system flexibility. Here is an example. Imagine you want to derive a specialized class of VDKEntry widget that intends to do some checks on end-user input before it forwards the "activate" signal to the parent. In this case we should define a:

ON_OBJECT_SIGNAL(activate_signal, HandleActivateSignal)

in response table and write in the handler something like this:

bool MyVDKEntry::HandleActivatedSignal(MyVDKEntry* sender)

{

if(some_checks_on_entry_are_ok())

return false; // signal proceeds to object ancestor (no treated) and then to parent.

else

{

prompts_to_the_user() ||

makes_correcting_actions();

}

return true; // signal is treated, stops here.

}

This tecnique allows to derive new object from VDK stock hierarchy implementing new features and mantaining inheritance of signal tables as well.

Another possibility is to directly address activate_signal to a parent level using SignalEmitParent (signal).

bool MyVDKEntry::HandleActivateSignal(MyVDKEntry* sender)

{

if(some_checks_on_entry_are_ok())

SignalEmitParent (activated_signal);

else

{

prompts_to_the_user() ||

makes_correcting_actions();

}

return true; // signal is treated, stops here.

}

user defined signal

The programmer can define his or her own signals and dispatch them using SignalEmit(signal) or SignalEmitParent (signal). I strongly suggest to define your signal using:

#define MYSIGNAL user_signal + <somevalue>

to avoid possible conflicts with already defined signals.

Composite objects (components)

Signal dispatching lets the user construct composite objects that can manage signals of their inner objects and send their own signals to the outer world.

Let’s assume an object made of 3 buttons packed into a box:

#define MYSIGNAL (user_signal+1)

class MyComposite: public VDKBox

{

protected:

VDKLabelButton * button1;

VDKLabelButton * button2;

public:

VDKLabelButton * button0; // could be a property

int ButtonPressed;

MyComposite(VDKForm * owner, int mode = v_box );

~MyComposite();

bool SignalCallback(VDKObject *);

int button;DECLARE_SIGNAL_MAP(MyComposite);

};

DEFINE_SIGNAL_MAP(MyComposite,VDKBox)

ON_SIGNAL(button0,clicked_signal,SignalCallback),

ON_SIGNAL(button1,clicked_signal,SignalCallback),

ON_SIGNAL(button2,clicked_signal,SignalCallback)

END_SIGNAL_MAP

bool MyComposite::SignalCallback(VDKObject * sender)

{

if(sender == button0)

{

ButtonPressed = 0;

return false;

}

else if(sender == button1)

ButtonPressed = 1;

else if(sender == button2)

ButtonPressed = 2;

SignalEmitParent(MYSIGNAL);

return true;

}

SignalCallback() catches buttons signals and send an unified answer emitting his own MYSIGNAL to parent, since SignalCallback() return true button signals are trapped into MyComposite scope. (except <button0> whose signal is’nt trapped, the reason will be explained soon)

Answering signal at any level of parenthood

It is possible (even if not very useful in a OO point of view) to answer to a signal coming from some lower level. Following the above example you can answer at form level that contains MyComposite object to signals coming from <button0> provided that you can know address of the object whose signals you want answer to (that’s the reason why <button0> was declared as public member). This piece of code shows how you can do:

class MyForm: public VDKForm

{

protected:

MyComposite *composite;

VDKLabelButton *label_button;

public:

MyForm(/*….*/):VDKForm(/*…*/) {}

/…

void Setup()

{

composite = new MyComposite(/*….*/);

// here you store button0 address

label_button = composite->button0;

}

DECLARE_SIGNAL_MAP(MyForm);

};

DEFINE_SIGNAL_MAP(MyForm, VDKForm)

ON_SIGNAL(label_button,clicked_signal, MyCallback)

END_SIGNAL_MAP

bool MyForm::MyCallback(VDKObject*) { /*…..*/ return true; }

Since MyComposite::SignalCallback() answers false if sender is button0, the signal flows up the parent hierarchy and will be answered by signal table at MyForm level, so MyForm::MyCallback() will be called.

 

signal and events with dynamic tables

signals

To connect/disconnect with signal user must write these macros:

After that user makes use of these class methods:

bool (_owner_class::*Pmf)(VDKObject* sender) , bool gtk = true, bool after = false)

Connect <object> of a method of <this> trough <signal>. Return an integer that is the connected "slot" number.

Usage: int slot = Connect(button,"clicked",&MyForm::ButtonClicked)

Tip: use this to connect a object contained into a form or another container with a container method.

Tip: signal names are those provided by Gtk+

bool (_owner_class::*Pmf)(VDKObject* sender) , bool gtk = true, bool after = false)

Connect <this> of a method of <this> trough <signal>. Return an integer that is the connected "slot" number.

Usage: int slot = Connect("clicked",&MyButton::ButtonClicked);

Tip: use this to connect an object with an object method.

Disconnect signal, <slot> must be retrieved from a SignalConnect () call.

Tip

If you set gtk=false no "real" connection will be made with Gtk+and signal continues to be handled if explicitely generated by a SignalEmit() call..

Here is an example:

class MyForm: public VDKForm

{

VDKSomeObject *someobject;

//…

DECLARE_SIGNAL_LIST(MyForm);

};

DEFINE_SIGNAL_LIST(MyForm,VDKForm);

void MyForm::Setup()

{

Add(someobject = new VDKSomeObject(this));

//… Gtk+ would refuse to connect this since does not know "MySignal"..

// but gtk=false will override Gtk+ connecting stuff

SignalConnect(someobject,"MySignal",&MyForm::HandleMySignal,false);

// HandleMySignal will be called.

someobject->SignalEmit("MySignal");

}

events

To connect/disconnect with events user must write these macros:

After that the programmer makes use of these class methods:

bool (_owner_class::*Pmf)(VDKObject* sender, GdkEvent*), bool after = false) )

Connect <object> of a method of <this> trough <event>. Return an integer that is the connected "slot" number.

Usage: int slot = EventConnect(button,"button_press_event",&MyForm::ButtonPressed)

Tip: use this to connect a object contained into a form or another container with a container method.

Tip: event names are those provided by Gtk+

bool (_owner_class::*Pmf)(VDKObject* sender, GdkEvent*), bool after = false) )

Connect <this> of a method of <this> trough <event>. Return an integer that is the connected "slot" number.

Usage: int slot = EventConnect("button_press-event",&MyButton::ButtonPressed);

Tip: use this to connect an object with an object method.

Disconnect event, <slot> must be retrieved from a EventConnect () call.

Response methods (were callbacks in Gtk+)

Same rules as static tables apply.

emitting signals

To emit signal using dynamic tables the programmer uses:

void SignalEmit(char* sig);

void SignalEmitParent(char* sig);

The same rules as static tables apply.

Multiple response methods for signals and events

It is possible to establish more than one response method for a single signal/event on a single object by adding more SignalConnect() or EventConnect() calls. Response method will be called in the same order as connecting calls. Each single response method will be considered separately from previous one, thus each will be called even if the previous is already been responded to.

Signals dispatching, ownership , parenthood and signal flow levels

The same rules as static tables apply.

 

About properties

Properties behave the same as in other modern RAD tools. You can set/get properties to obtain different behaviours from objects.

As an example let Visible be a form or object property, writing:

form->Visible = false; // hides form

form->Visible = true/ // shows form again.

It’s also possible to use properties to evaluate an expression:

if(form->Visible)

form->Visible = false;

else

form->Visible = true;

or better:

form->Visible = form->Visible ? false : true;

toggles form visibility.

Properties are implemented as templates on <class T> and have following method available:

Converts property to the property type.

Assign property value.

Return property name.

Refer to each class for a better explanation how to use properties.

Properties have some limitations:

bool visible = form->Visible;

form1->Visible = visible;

or

form->Visible = bool(form1->Visible);

 

User defined properties

VDK allows the programmer to define his or her own properties that can be used with forms and objects. In order to use properties effectively some internal things should be known.

Properties are declared as template classes on owner class and type:

VDKReadWriteValueProp< ownerClass, propertyType> where ownerClass is the class that owns the property and propertyType is the parameter type. For instance the Visible property of VDKForm class is declared into public part of VDKForm as:

VDKReadWriteValueProp<VDKForm,bool> Visible;

A property must be instantiated into owner class constructor where we must pass to property constructor following argument:

For instance VDKForm::Visible property is instantiated like this:

Visible("Visible",this,true,&VDKForm::SetVisible,&VDKForm::GetVisible)

Where

In most cases the "getting" function is not necessary since a raw read of property value is sufficient, in other few cases also the "setting" is redundant, for this reason the property constructor is declared like this:

VDKReadWriteValueProp( char* name, T* object, S defValue,

void (T::*write)(S) = NULL, S (T::*read)(void) = NULL)

If setting/getting functions are set to NULL no setting/getting function will be called. In such cases writing: property = something; or something = property; leads into a raw write/read of property internal value. Otherwise if setting/getting function are set to a valid <owner class member function> besides the raw value write/read a function call will be made.

void SetPropertyFunction(propertyType value);

Thus VDKForm::Visible property setting function is declared and defined like this:

void SetVisible(bool flag) {

if(flag) Show();

else Hide();

}

As you can see writing myform->Visible = true; turns out in calling myform->SetVisible(true) and than myform.>Show();

propertyType GetPropertyFunction(void);

Thus VDKForm::Visible property getting function is declared and defined like this:

bool GetVisible() { return GTK_WIDGET_VISIBLE(window); };

As you can see writing bool visible = myform->Visible; turns out in calling myform->GetVisible().

There is also a convenience macro that helps to declare properties:

- __rwproperty(ownerClass, propertyType) // declare a read/write property

Let’s show an example, assume an user form class like this:

class MyForm: public VDKForm

{

public:

_rwproperty(MyForm, int) MyProperty;

MyForm(VDKApplication* app, gchar* title = "", int mode = v_box,

GtkWindowType display = GTK_WINDOW_TOPLEVEL);

~MyForm() {}

void SetMyProperty(int value) { //….. }

int GetMyProperty() { //….}

};

// MyProperty initialization will be done into MyForm constructor like this:

MyForm ::MyForm(VDKApplication* app,

gchar* title, int mode,GtkWindowType display ):

VDKForm(app, title,mode,display),

MyProperty("MyProperty",this,0,

&MyForm::SetMyProperty,&MyForm::GetMyProperty)

{ //….}

That’s all.

Read only property is a subclass of write/read property with a restricted interface, any attempt to write a read-only property will be flagged as compilation error. A read only property is declared as:

VDKReadOnlyValueProp< ownerClass, propertyType >

Property constructor is declared as:

VDKReadOnlyValueProp(char* name,T* object, S defValue,

S (T::*read)(void) = NULL, (T::*write)(S) = NULL );

where <write> argument will be always NULL.

A convenience macro also exists:

__rproperty(ownerClass, propertyType) to declare a read-only property.

Property initialization is same as read/write properties recalling that <write> argument should be left always to NULL.

It may sometimes be useful to directly set a property value without calling the setting function even if present, in this case you can use the "function" operator of a property.

See this example:

myproperty = something; // set property value calling setting function

myproperty(something); // set property value without calling setting function.

Recall that last construct is a violation of "data hiding" concept and should be used with caution. To prevent potential errors this direct setting of a property should leave the property in the same state that a normal call would have.

More on properties

Properties are convenient for several reasons:

VDK library use extensively the property concept and therefore its use is encouraged even if raw function call like a myform->SetVisible() is possible.



VDK 1.0.1 classes hierarchy












































vdk 1.0.1 components hierarchy













Blank page

 

 

 

 

 

 

 

 

 

 

 

 

VDK classes reference

 

Intentionally left blank page

 

VDKApplication class <application.h>

Description

This class initializes GTK+ library and start events loop. Normally user overrides this class using his own application object. Application objects are responsible to manage also terminating and clean-up procedures.

Public members

VDKForm* MainForm

Is the application main form, must be user initialized otherwise a useless default main form will be constructed by the VDKApplication base object.

Properties

None

Methods

Constructor, receives main() arguments and pass them to GTK+ library. Normally user overrides this using his own Application object. (See programming tips). If <rc> arg isn’t NULL <rc> resource file will be laoded and parsed. Setting <have_locale> to true let's vdk to invoke gtk_set_locale() and support any languages that Gtk supports.

Destructor.

Indicates if the resource file was loaded and parsed or not.

Initiates event loop.

Terminates event loop and quit GTK+ library. (Tip: This method is called after a destroy event on MainForm, user doesn’t care of it)

Return application mainform underlying gtk+ window.

Initialize MainWindow, normally user override this to provide his own initializing procedures (see tips).

Set a resource file.

Tip: this should be done before Run()ning app.

Returns screen size in pixels.

 

Sets idle callback function, if a previous idle callback was installed, uninstall it.

Tip: <data> will be passed to <idlecb> user defined function and must a be a non NULL pointer otherwise SetIdleCallback() won’t work.

<idlecb> must be declared as: void idlecb(gpointer data);

Set a timed garbage collection that will be invoked each <timing> msecs.

Remove timed garbage collection.

char* text,

int mode = MB_OK,

char *oktext = NULL,

char *canceltext = NULL.

unsigned int wait = 0);

Provide a modal dialog window for messages to user.

Modes:

Mode can be ored with:

MessageBox returns an integer that depends on modes and user response:

Both OK,YES and NO buttons captions can be customized using oktext and canceltext arguments.

<wait> arg if set other than 0 makes MessageBox automatically closed after <wait> msecs with IDCANCEL or IDNO result.

MessageBox() accepts CR as "yes" and ESC as "no" default answers.

Others

VDK_VERSION_MAJOR

VDK_VERSION_MINOR

VDK_REVISION

For instance:

printf("VDK %d.%d.%d", VDK_VERSION_MAJOR,VDK_VERSION_MINOR ,VDK_REVISION);

fflush(stdout);

will ouput VDK 1.0.1

Programming Tips

Using Application object is straightforward, normally user derives his own application object from wich initializes MainWindow and runs app object. Here some code extracted from a simple Hello program:

#include <vdk.h>

class MyApp: public VDKApplication

{

public:

MyApp(int* argc, char** argv): VDKApplication(argc,argv) {}

~MyApp() {}

void Setup()

{

MainForm = new MyForm(this,"hello world");

MainForm->Setup();

MainForm->Show();

}

};

 

int main (int argc, char *argv[])

{

MyApp app(&argc, argv);

// Run() calls app.Setup() and initiates event loop

app.Run();

return 0;

}

 

 

VDKForm class <forms.h>

Inherits from VDKObject

Description

This class provides a common interface with GTK+ windows that are here called "Forms". VDKForm provides common functionalities for all derived classes.

Public members

None

Properties

VDKString Title

bool Iconized

VDKPoint Position

VDKRawPixmap* BackgroundPixmap

VDKObject* FocusWidget

Methods

GtkWindowType display = GTK_WINDOW_TOPLEVEL);

Constructor, makes a form wich belong to an application object. Usually invoke this constructor to make the application MainForm. Form displays title if arg <title> isn’t null. Form is made with an inner "box" that is vertical if arg <mode> is v_box, horizontal otherwise. Display mode is according to <display> arg that follows usual GTK+ definitions.

GtkWindowType display = GTK_WINDOW_TOPLEVEL);

Constructor, makes a form wich belong to another form. Usually invoke this constructor to make a "child" form wich will be "added" to form.

Destructor.

Used to add child forms to a form. (Tip: Normally user do not need to explicitely add a form to a form, appropriate constructor makes the job)

Returns the application wich form belongs. If form is a child the parent application will be returned.

Return inner box.

Tip: gtk_container_border_width (GTK_CONTAINER (Box->Widget()), 10);

This function is invoked from Window Manager "delete" and "destroy" events and Close() function as well. Answering true allows the form to be closed and destroyed, otherwise form will not be closed. Recall that closing MainForm will terminate application. VDKForm::CanClose() answers always "true", user should override this to obtain different behaviours (i.e: asking to a confirmation or memory clean-up and closing files).

Return form child list.

Triggers destroy event, CanClose() will be called before actually closing. If CanClose() answers true the form will be closed and destroyed. If user overrides this, recall to make an ancestor VDKForm::Close() after his operations.

Explicitely destroy a form freeing associated memory and collecting garbage if any Tips :

Hides form.

Return true if form was showed as modal.

Return form objects list.

Return form owner, if it is the MainForm Owner() returns NULL.

Remove the form from child list adding it to the garbage list that will be destroyed eith GC

(Tip: Normally user don’t need to use explicitly this function, VDKForm::Close() does the job)

Set <pix> as window icon

Set <name> as window icon name

The purposes is to fill the form with interface objects, user must override this, otherwise will obtain a compilation error.

Sets form title

Gets form title.

Show the form. Window position follows <pos> arg as documented in Gtk+ Reference manual.

Show the form in a modal behave. Modal forms deactivate their parent and parent childs if any. Window position follows <pos> arg as documented in Gtk+ Reference manual. Modal forms aren’t clipped or shadowed by their parents.

Returns the underlying GTK+ window.

Raises the form on windows stack top, thus if it is hidden by other windows will appear on the screen.

Opposite as Raise() do.

Set form default size

Change form size

Using properties

Setting this property will set the form title.

Use this property to iconize/restore the form or know if form is iconized or not.

Lets to set a pixmap as form background.

Here a code frag:

VDKRawPixmap *pix = new VDKRawPixmap(this,"pix_file.xpm");

if(pix) BackgroundPixmap = pix;

Set/get the widget that will have the focus when form is showed

At VDKForm level all these functions are placeholder for subclasses. User should override these in order to intercept appropriate events.

Answers to an Expose event, <area> arg contains the form rectangle interested to. (Tip: many expose events are normally generated during form motions, OnExpose() answers only to the last one, when the event->count drops to 0)

Called immediately after form is displayed into the screen.

Child forward this event to the parent when is to be closing.

Called whenever form is iconized

Called whenever form is restored.

Answer to a move event

Answer to a resize event

Programming Tips

Here an example code extracted form a simple hello program that shows how to define a simple Form:

/* helloworld.c */

#include <vdk.h>

#include "kill.xpm"

class MyForm: public VDKForm

{

VDKLabelButton *helloButton;

VDKPixmapButton *closeButton;

VDKLabel* label;

public:

MyForm(VDKApplication* app, gchar* title):

VDKForm(app,title) {}

~MyForm() {}

void Setup();

bool SayHello(VDKObject*) { label->Caption = "Hello world !"; return true;}

bool Quit(VDKObject*) { Close(); return true; }

DECLARE_SIGNAL_MAP(MyForm);

};

DEFINE_SIGNAL_MAP(MyForm,VDKForm)

ON_SIGNAL(helloButton,clicked_signal,SayHello),

ON_SIGNAL(closeButton,clicked_signal,Quit)

END_SIGNAL_MAP

void MyForm::Setup()

{

VDKBox* box = new VDKBox(this);

box->Add(helloButton = new VDKLabelButton(this, "Hello","Says \"hello\""));

box->Add(closeButton = new VDKPixmapButton(this, kill_xpm , "DISMISS",

"Closes hello application"));

box->Add(label = new VDKLabel(this,""));

Add(box);

SetSize(200,100);

}

class MyApp: public VDKApplication

{

public:

MyApp(int* argc, char** argv): VDKApplication(argc,argv) {}

~MyApp() {}

void Setup()

{

MainForm = new MyForm(this,"hello world");

MainForm->Setup();

MainForm->Show();

}

};

int main (int argc, char *argv[])

{

MyApp app(&argc, argv);

app.Run();

return 0;

}

 

EXAMPLES: Almost all ./test/*.cc and ./test/*.h

VDKScrolled class <scrolled.h>

Inherits from VDKObjectContainer

This class wraps gtk+ gtkscrolled widget

properties

none

public members

none

methods

Add a self-scrollable object to widget

Tip:only first arg is used

Add a non-self scrollable object

to add those self scrolling widgets.

 

VDKScrolledForm class <scrolledForm.h>

Inherits from VDKForm

Description

This class provides a scrollable form.

**WARNING**

This class will be no longer supported into new versions, its use is deprecated

Public members

None

Properties

None

Methods

GtkWindowType display = GTK_WINDOW_TOPLEVEL)

Constructor, makes a scrolled form wich belong to an application object. Usually invoke this constructor to make the application MainForm. Form dimension are fixed with <w> width and <h> height args. Form displays title if arg <title> is’nt empty. Display mode is according to <display> arg that follows usual GTK+ definitions.

gchar* title = "", GtkWindowType display = GTK_WINDOW_TOPLEVEL)

Constructor, makes a form wich belong to another form. Usually invoke this constructor to make a "child" form wich will be "added" to form child list.

Destructor.

Add a non scrollable object.

 

EXAMPLES: ./test/scrollwin.h and .cc

VDKPanedForm class <panedform.h>

Inherits from VDKForm

Description

This class provides a paned form.

**WARNING**

This class will be no longer supported into new version, its use is deprecated

Public members

None

Properties

None

Methods

GtkWindowType display = GTK_WINDOW_TOPLEVEL);

Constructor, make a paned form either vertically (v_box) or horizontally (h_box) paned.

GtkWindowType display = GTK_WINDOW_TOPLEVEL);

Constructor, as above

Add an object to pane 1 or 2

Destructor.

 

VDKObject class <vdkobj.h>

Description

This class is the base class of a wide hierarchy, provides common functionalities to all derived classes.

Public members

int Tag an int value at user hand (default 0)

Properties

VDKRgb NormalBackground

VDKRgb PrelightBackground

VDKRgb InsensitiveBackground

VDKRgb ActiveBackground

VDKRgb SelectedBackground

VDKRgb Foreground

VDKFont* Font

bool Enabled

VDKCursorType Cursor

VDKPoint Usize

bool Visible

Methods

Constructor, make an object that belongs to <owner> form.

Contructor, makes an object instance from an already gtk+ created object.

(See tips)

Destructor.

Explicitely destroy an object freeing associated memory.

Tip: never use delete operator otherwise garbage collection will fail and program probably will crash.

Draw the object into the interested area, if area = NULL the entire object will be drawn. This call generate an expose event.

Returns object owner form.

If parent != NULL set object parent and returns old parent, otherwise returns parent.

Returns underlying GTK+ widget.

Returns underlying wrapped Gtk+ widget, useful in those cases when VDKObject is a composite one.

An example is VDKText where Widget() return packing box not text itself.

Tip: In doubt use always this instead of Widget(), is always safe.

 

Set object font.

Makes the widget to gain focus.

Get object used font

Set object cursor

Get object cursor

GtkStateType state = GTK_STATE_NORMAL);

Set object foreground color.

GtkStateType state = GTK_STATE_NORMAL);

Set object background color.

Set object size.

Set object sensitive/unsensitive.

Returns if object is sensitive or not.

Set object tip.

int fill = TRUE , int padding = 1);

Add an object to the object.

Return contained objects list.

Internal use only, user does’nt care.

Called whewnever a VDKObject is added to a container. At base class level does nothing, user can override it to initialize his own derived object when added to a container.

Useful to access to actual colors in use.

Using signals and events

Tip:

All non-container widget can answer to realize_signal using static tables.

Static tables

Macro, disables <object> answering to<signal>. Returns disabled slot, -1 on failure.

Reactivates the signal into <slot>. <slot> should be achieved with a previous SIGNAL_DETACH call.

Macro, disables <object> answering to<event>. Returns disabled slot, -1 on failure.

Reactivates the event into <slot>. <slot> should be achieved with a previous EVENT_DETACH call.

Emit signal <signal>

Emit signal <signal> starting at parent level

Dynamic tables

bool (_owner_class::*Pmf)(VDKObject* sender), bool gtk = true, bool after = false )

Connect <object> of a method of <this> trough <signal>. Return an integer that is the connected "slot" number.

Usage: int slot = Connect(button,"clicked",&MyForm::ButtonClicked)

Tip: use this to connect a object contained into a form or another container with a container method.

Tip: signal names are those provided by Gtk+

bool (_owner_class::*Pmf)(VDKObject* sender), bool gtk = true, bool after = false )

Connect <this> of a method of <this> trough <signal>. Return an integer that is the connected "slot" number.

Usage: int slot = Connect("clicked",&MyButton::ButtonClicked);

Tip: use this to connect an object with an object method.

Disconnect signal, <slot> must be retrieved from a ConnectSignal() call.

bool (_owner_class::*Pmf)(VDKObject* sender, GdkEvent*) , bool after = false)

Connect <object> of a method of <this> trough <event>. Return an integer that is the connected "slot" number.

Usage: int slot = Connect(button,"button_press_event",&MyForm::ButtonPressed)

Tip: use this to connect a object contained into a form or another container with a container method.

Tip: event names are those provided by Gtk+

bool (_owner_class::*Pmf)(VDKObject* sender, GdkEvent*) , bool after = false)

Connect <this> of a method of <this> trough <event>. Return an integer that is the connected "slot" number.

Usage: int slot = Connect("button_press-event",&MyButton::ButtonPressed);

Tip: use this to connect an object with an object method.

 

Disconnect event, <slot> must be retrieved from a ConnectEvent() call.

Emit signal <signal>

Emit signal <signal> starting at parent level

Using properties

Setting this property will set/get object background color. Naming convention follows Gtk+ one.

Example: form->NormalBackground = VDKRgb(255,0,0);

(Tip: VDKRgb is a structure defined in vdkutils.h. Remember that some objects are transparent, so if you want to set the background color, you actually have to set the background color of the parent, VDKlabel is an example.

Setting this property will set/get object foreground color.

Setting this property will set/get object cursor type.

Setting this property will set/get object minimu size.

Setting this property will set/get object sensitivity.

Setting this property will set the object font.

obj->Font = new VDKFont(obj,"X-font-string-chock-full-o-dashes-goes-in-here");

Setting this property will show/hide or get object visibility.

Programming tips

void MyForm::Setup()

{

GtkWidget *not_implemented_in_VDK = gtk_somewidget_new();

VDKObject *v_object = new VDKObject(this, not_implemented_in_VDK);

// use it in a OOP framework

gtk_somewidget_make_something(GTK_SOMEWIDGET(object->Widget()));

}

In this case you can construct a Gtk+ object and still use VDKObjects methods.

VDKBox class <boxes.h>

Inherits from VDKObjectContainer

 

Description

This class provides boxes used as objects container.

Public members

None

Properties

None

Methods

Constructor, make a box owned by <owner>, either vertical (mode == v_box) ot horizontal (mode == h_box).

Destructor.

int expand = TRUE, int fill = TRUE, int padding = 1);

Add an object to the box, If <justify> arg is l_justify object will be packed "start", to "end" otherwise. For others args refer to Gtk+ Tutorial or reference manual.

EXAMPLES: Allmost all ./test/*.cc

VDKEventBox <eventbox.h>

Inherits from VDKObjectContainer

VDKEventBox acts like and has same methods of VDKBox but reacts to all events.

methods

Returns a VDKPoint containing VDKEventBox coordinates relatives to parent form.

Tip: event handling must be done using dynamics tables

VDKObjectContainer class <widcontain.h>

Inherits from VDKObject

 

Description

This class provides a container widget, common class for specialized containers such ad: VDKBox, VDKTable, VDKFrame, VDKPaned. Since VDKObjectContainer is a common base class, normally user should not construct this type of object.

Methods

Constructor

Destructor

Add an object.

Tip: user normally does not make use of this, subclasses overridden methods do the job correctly.

Sets container border width. Returns container border width if arg <w> is < 0.

Remove an object from container.

Remove all contained objects.

Find an object with Tag <tag>, returns NULL if fails.

Apply user defined <action> to all contained object.

Selects those contained objects that satisfy to user defined <condition>. Fills arg <list> with those objects addresses.

 

 

VDKCanvas class <canvas.h>

Inherits from VDKObject

Description

This class provides a canvas widget.

properties

EnableClear , boolean, default is true.

It clears and refresh the screen during the configure event. User can disable it to control the draw during the configure event.

EnableDrag boolean, default is true.

It enables DragStart/Dragging/DragStop events. The user can disable it, then EventMotion occures.

(It is very usefull if the user is not persuated with the implemented drag handling...)

Captured boolean, default is false.

if it is true, the canvas will receive EventMotion/Drag... events if the cursor is outside of the area.

Methods

Constructor.

Destructor

Clear the canvas.

Arg <filled> can be either 1 (rect will be filled with color) or 0.

Redraw the canvas without generate an expose event, normally called after a drawing operations.

Tip:

Drawing operations on canvas are not done directly on the screen but using an offscreen backing pixmap. When necessary relevant portions of (or all) backing image is copied to screen. This tecnique makes drawing operations an order of magnitude faster and avoids screen flickering. So all drawing should be followed by Draw() or Redraw() to effectively see the wanted effect. When applicable the best way is to establish an expose_event response function and make drawing there followed by a Redraw() call. See canvaswin.cc on testvdk dir for more detailed informations.

Signals

None

Events

configure_event

expose_event

button_press_event

motion_notify_event

drag_start_event

Generated when user begin to drag mouse

drag_stop_event

Generated when user ends to drag mouse

dragging_event

During user drag operations

Tip: drag_start and drag_stop use a GdkEventButton* structure, dragging_event a GdkEventMotion*.

By default canvas uses owner background and foreground, these can be set using properties. (see canvaswin.cc on ./testvdk dir for more informations)

EXAMPLES: ./testvdk/canvaswin.cc

VDKCheckButton class <checkbutton.h>

Inherits from VDKAbstractButton

Description

This class provides a check button widget.

Public members

None

Properties

bool Checked

char* Caption

bool CaptionWrap

Methods

Constructor

Destructor

Toggles check button status checked/unchecked

Set/unset check button.

Get check button status

Signals

toggled_signal

Received whenever check button is pressed

using properties

bool Checked

Setting this properties toggles check button status and emits toggled_signal. Can be used to get check button status as well

EXAMPLES: In signalwin.cc and .h

VDKCustomButton class <vdkcustombutton.h>

Inherits from VDKObject

DESCRIPTION

This class provides an unified wrapper for: GtkButton and GtkToggleButton.

Substitutes previous:

VDKLabelButton, VDKPixmapButton, VDKToggleLabelButton,VDKTogglePixmapButton.

This classes should be considered obsolete, its use is deprecated since will be cancelled in future vdk versions.

PUBLIC MEMBERS

None

PROPERTIES

VDKBox *ButtonBox (read-only)VDKLabel *Label (read-only)VDKPixmap *Pixmap (read-only)char *Captionbool CaptionWrapbool CheckedGtkReliefStyle ReliefMETHODSVDKCustomButton(VDKForm* owner, char* label,

unsigned int type = VDK_CBUTTON_UNTOGGLED | VDK_CBUTTON_NORMAL);

Makes a labeled button.

char* pixfile, char* label,

unsigned int type = VDK_CBUTTON_UNTOGGLED | VDK_CBUTTON_NORMAL,

GtkPositionType position = GTK_POS_RIGHT);

Makes a pixmapped button using <pixfile> file. <position> refers to label position into the button box.

char** pixdata,char* label,

unsigned int type = VDK_CBUTTON_UNTOGGLED | VDK_CBUTTON_NORMAL,

GtkPositionType position = GTK_POS_RIGHT);

Makes a pixmapped button using <pixdata> mem data.

Tips:

toggled:

VDK_CBUTTON_UNTOGGLED

VDK_CBUTTON_TOGGLED

type:

VDK_CBUTTON_NORMAL

VDK_CBUTTON_COMBO

toggled and type can be ored togheter.

VDK_CBUTTON_TOGGLED | VDK_CBUTTON_COMBO does not produce a combo toggled button.

Destructor

USING PROPERTIES

Label

Permits to access embedded VDKLabel.

Tip:

// this code permits to change label justification

VDKCustomButton *button = new VDKCustomButton(this, "A label");

VDKLabel* label = button->Label;

if(label)

label->Justify = GTK_JUSTIFY_RIGHT;

Pixmap

Permits to access embedded VDKPixmap.

Tip:

// this code permits to change button pixmap

VDKCustomButton *button = new VDKCustomButton(this, "A label");

VDKPixmap* pixmap = button->Pixmap;

if(pixmap)

pixmap->SetPixmap("pixmap.xpm");

ButtonBox

Permits to access embedded VDKBox that contains a VDKLabel and a VDKPixmap.

Caption

Permits to set/get label caption

CaptionWrap

Permits to set/get label caption wrap mode

Checked

Permits to set/get cheked state. (Meaningless if button is a toggle button)

Relief

Permits to set/get button relief mode. (Meaningfull if button isn't a toggle button)

Signals

clicked_signal

emitted when user clicks over button

enter_signal

emitted when mouse goes over button

leave_signal

emitted when mouse leaves button

VDKCustom class <vdkcustom.h>

Inherits from VDKObject

This is base class for derived VDKCustomList and VDKCustomTree, provides common functionalities for both child classes. User will never use an instance of this class however.

properties

GtkPolicyType VPolicy;

GtkPolicyType HPolicy;

GtkShadowType BorderShadow;

int RowHeight;

bool AutoResize;

public members

VDKObjectArray Titles;

int SelectedTitle;

VDKColor *UnselectedBackground, *UnselectedForeground, *SelectedBackground, *SelectedForeground;

methods

Returns wich column was clicked

Returns selection mode.

Returns underliyng custom widget.

Tip: use this to access to custom widget, using VDKObject::Widget() will access to container not to custom widget itself.

Set/Unset <col> title active

Set/Unsets all titles active

Set/Unset all titles button sensitive

Same gtk+

Same as gtk+

Clear custom widget

Returns how many rows/nodes are into custom widget

Set a <col> column fixed size.

Set/unset <col> colums auto resize capability

Using properties and public members

Use this to set/get vert. scrollbar policy

Use this to set/get hor. scrollbar policy

Use this to set/get border type

Use this to set/get row height.

Tip: by default row height is computed using default font.

Use this to set/get auto-resize capability for all columns.

Since column titles are themselves objects you can use this to access them and set objects properties like this:

Titles[0]->Enabled = true;

Titles[0]->NormalBackground = VDKRgb(255,0,0);

Use this to know wich title was selected

Use this to set colors if they should be different from defaults. All new added rows will have these colors.

By default this members are set to NULL and defaults colors will be used.

Tip: to set background color for the entire widget better use NormalBackground,… properties.

Programming tips

Signals are available in all modes (except the browse one) but the way you can use them is different for each mode. Basically in single mode use Selection property while in other modes you may use Selections() method.

VDKCustomList class <vdkclist.h>

Inherits from VDKCustom

This wraps gtk+ gtkclist widget

properties

SelectionProp Selected;

int Selected.Row();

int Selected.Col();

SelectionProp Unselected;

int Unselected.Row();

int Unselected.Col();

public members

TupleList Tuples;

methods

int columns = 1,

char **titles = NULL,

GtkSelectionMode mode = GTK_SELECTION_SINGLE);

Constructor, makes a custom list with <columns> number of columns, having <titles> titles with <mode> selection mode

Destructor

Add a row to list, row can have one <pixdata> pixmap at column <col>

Update row at <row> position, row can have one <pixdata> pixmap at column <col>.

Same as above, but receive a tuple instead of a string pointer array.

Update a single cell at <row>,<col> position, cell can have <pixdata> pixmap

Remove row at<row> position

Returns selected cell

Returns unselected cell (meaningfull only on GTK_SELECTION_SINGLE)

Selects cell at <row>,<col> position

Selects cell at <p.X()>,<p.Y()> position

Same as above but unselects

Same as above

Returns an array filled with all selected rows numbers. (valid only for GTK_SELECTION_EXTENDED, in other case returned array will have a null size)

Signals

select_row_signal

Emitted on selecting a list cell (or double-clicking a row in extended selection mode), after that Selected property is set with cell coordinates.

(Tip: use Selected property like this:

// into a response function

// Selected is (-1,-1) if no row is selected.

VDKPoint = list->Selected;

int row = list->p.X();

int col = list->p.Y();

or simpler

int row = list->Selected.Row();

int col = list->Selected.Col();

)

unselect_row_signal

Emitted on unselecting a list cell, after that Unselected property is set with cell coordinates. (See tip above)

click_column_signal

Emitted on clicking over a column title, after that use ColumnClicked() to know wich column was clicked.

Using properties and public members

Use this to know wich cell was selected or

int Selected.Row() (run-time read only)

Use this to know wich row is selected

int Selected.Col()(run-time read only)

Use this to know wich column is selected

Same as above applied to unselection.

int Unselected.Row()

int Unselected.Col()

A Tuple is a VDKArray<VDKString>.

Use this property to acces data on row/cell basis like this:

Tuple tuple = Tuples[0]; // access to first row

char* p = (char*) tuple[0]; // access to first cell

or more simply: char* p = (char*) Tuples[0][0];

 

Programming tips

VDKTuple tuple = list->Tuples[j]; // access to j-th tuple

VDKString s = list->Tuples[j][i]; // acces to j-th,i-th string.

Recall that Tuples is a read-only property, if you directly modify a tuple this not reflects into the list widget, use UpdateRow() class method at this end.

 

EXAMPLES: ./test/testvdk.cc and .h

 

VDKCustomTree class <vdkctree.h>

Inherits from VDKCustom

This wraps gtk+ gtkctree widget

properties

int Spacing;

VDKTreeNode SelectedNode;

int SelectedColumn;

VDKTreeNode UnselectedNode;

int UnselectedColumn;

GtkCTreeLineStyle LineStyle;

GtkCTreeExpanderStyle ExpanderStyle;

Tip: VDKTreeNode is defined as GtkCTreeNode*

public members

none

methods

GtkSelectionMode mode = GTK_SELECTION_SINGLE, int tree_column = 0);

Constructor, make a VDKCustomTree with<columns> columns, <titles>, <mode> selection mode, tree will be constructed using <tree_column> text as key.

Destructor

bool expanded = true, bool isLeaf = false,

char **pixmap_closed = NULL, char** pixmap_opened = NULL );

Add a node to <parent> tree, if <parent> is NULL add the node as a new root (same as adding a row to a VDKCustomList), two pixmaps can be provided to that node, <pixmap_closed> to be showed when that node is collapsed and <pixmap_opened> when is expanded.

Remove <node> node, return true on success.

Remove all nodes with key == <key>, returns the number of removed nodes.

Returns the selected node.

Returns the unselected node.

In extended mode return an array of selected nodes.

 

Return a tuple of <node> node, thus an array containing all columns texts.

Return a list of nodes that matches <key>. Tip: returned list should be deleted by user.

Returns true if <node> is a leaf

Returns <node> key

Returns true if <node> is expanded.

Signals

Using properties

Set/get spacing style arg (as in gtk+)

Set/get selected node. Setting SelectedNode = NULL will select root node, an answer NULL means no node selected

Set/get selected column. An answer –1 means no column selected

Set/get unselected node

Set/get unselected column

Set/get line style arg (as in gtk+)

Set/get expander style arg (as in gtk+)

EXAMPLES: /test/ctreewin.cc and .h

VDKCustomSortedList class <vdkcsortlist.h>

Inherits from VDKCustomList

Description

This class provides a sorted custom list

Public members

bool Unique

Properties

None

Methods

Constructor, makes a CustomList sorted on column <keyPos>. Other args as per VDKCustomList::AddRow()

Destructor.

Add a row containing <key> field.

char** pixdata = NULL, int col = 0);

Update row containing <key> key. If <key> does not exist nothing will be updated.

Update cell containing <key>.

Remove row containing key. If <key> does not exist nothing will be removed.

Returns the row containing <key>, -1 if not found.

Returns the column of the list key.

Using Public members

Setting Unique to true (false is default) forces the list to do not insert duplicate keys.

Programming tips

All methods act as in VDKCustomList but inserting rows in ascending order. Currently only char* keys are supported.

EXAMPLES: ./test/sortlistwin.cc and .h

VDKFileSel <filedlg.h>

Inherits from VDKForm

This class is a file selection modal form ala Gtk+

usage:

Here an example extracted from testvdk.cc:

char selection[256];

strcpy(selection,"*.h"); // set default file mask

VDKFileSel* child = new VDKFileSel( TheApplication->MainForm,

selection, "File selection (ala Gtk+)");

child->ShowModal();

if(*selection)

{

printf("\nselection:%s",selection);

fflush(stdout);

}

// On return selection will be empty if user presses "cancel" button.

 

VDKFixed class <fixed.h>

Inherits from VDKObjectContainer

This class wraps gtk+ gtkfixed widget

properties

none

public members

none

methods

Constructor

Destructor

int x = 0, int y = 0 , int padding = 0);

Add an object to a fixed at x,y coordinates

Tip: users should ignore this method since is internally used by VDKBuilder only, use below one.

Add an object to x,y position relative to widget origin.

VDKFrame class <frame.h>

Inherits from VDKObjectContainer

Description

This class provides a Gtk+ frame widget wrapper

Properties

char* Label

int Shadow

int Align;

methods

Constructor, makes a frame with label <label> and shadowed as <shadow> arg., frame will be horizontal or vertical shaped pending on <mode> arg.

Destructor

int expand = TRUE, int fill = TRUE , int padding = 1)

Add an object to frame.

Using properties

Set/get frame label

Set/get shadow type (shadow_none, shadow_in, shadow_out,shadow_etched_in, shadow_etched_out)

Set/get frame label alignement (l_justify, c_justify, r_justify)

Shadow and align args enums are defined in vdktypes.h

EXAMPLES: in rbuttonwin.cc and .h

 

 

VDKEntry class <entry.h>

Inherits from VDKObject

Description

This class provides a custom Entry widget wrapper.

Properties

char* Text

bool Editable

bool Hidden

Methods

Constructor, make an entry objects that allows <maxLen> chars be entered (0 means no limit) and that displays <def> value.

Destructor.

Set entry text.

Set/unset entry text editable.

Get entry text editable flag.

Set/unset entry text visibility

Get entry text visibility flag.

Get entry text.

Signals

activate_signal

received when the end-user press CR key on entry

changed_signal

received when end-user press other than editing keys into entry widget

focus_in_signal

received when entry gain focus

focus_out_signal

received when entry loose focus

Using propeties

Read/write entry text like this:

char* p = "a text";

entry->Text = p;

printf("\nentry text:%s", (char*) entry->Text);

fflush(stdout);

Setting this property to true/false enable/disable editing.

Setting this property to true/false enable/disable text visibility.

Tip: use this property to make a "secret" entry field.

 

 

VDKNumericEntry class <numentry.h>

Inherits from VDKEntry

Description

This class provides a custom Entry widget that accept numeric input only.

Methods

Constructor, make a numeric entry objects that allows <maxLen> chars be entered (0 means no limit) and that display <def> value.

Destructor.

EXAMPLES: ./test/entrieswin.cc and .h

VDKHandleBox class <handlebox.h>

Inherits from VDKObjectContainer

Description

This class provides a Gtk+ Handle box wrapper

properties

VDKObject* Child

Methods

Constructor, makes an handlebox

Destructor

Add a VDKObject* to handle box.

Signals

child_attached_signal

Received whenever child object is attached to handle box

child_detached_signal

Received whenever child object is detached from handle box

using properties

Child

Use this property to access to the object contained into an handle box.

EXAMPLES: In ./test/tbarwin.cc

VDKLabel class <label.h>

Inherits from VDKObject

Description

This class provides a label widget.

Public members

None

Properties

GtkJustification Justify

char* Caption

bool CaptionWrap

Methods

Constructor. Makes a label with caption <label>.

Destructor.

 

EXAMPLES: Allmost all ./test/*.cc and *.h

VDKLabelButton class <label_button.h>

Inherits from VDKButton => VDKAbstractButton

Description

This class provides a labeled button.

Public members

None

Properties

char* Caption

bool CaptionWrap

GtkReliefStyle Relief

Methods

Constructor, makes a labeled button. Button caption will be <label>, it tip is’nt NULL a tip will be assigned to button.

Destructor.

GtkStateType state = GTK_STATE_NORMAL);

Set button foreground color.

Set button font.

Signals

clicked_signal

Emitted when user clicks over buttom

enter_signal

Emitted when mouse goes over button

leave_signal

Emitted when mouse leaves button.

EXAMPLES: Allmost all ./test/*.cc and *.h

VDK Menu classes <menu.h>

VDKMenu class

Inherits from VDKObjectContainer

Description

This class provides a menu item container

Public members

None

Properties

None

Methods

Constructor, makes a menu owned by <owner> form.

Destructor;

Provides a separator.

Set menu font. (Tip: applyng a font to menu will spread the font to all menu items contained)

Pops menu.

<obj> must be a VDKMenuItem or a derived type, adding other widgets generates a warning message and nothing will be added.

 

VDKMenuItem class

Inherits from VDKObject

Description

This class provides a menu item.

Public members

None

Properties

bool Checked

char* Caption

Methods

guint key = GDK_VoidSymbol,guint8 modkey = GDK_MOD1_MASK);

Constructor, makes a menu item that shoud be contained into a menu. A pixmap will be packed at start if <pixmap> isn’t NULL. Leaving <key> to default value makes <label> to be parsed for accelerator key.

For instance: label = "_Quit" makes the accelerator as Alt+q. Setting <key> to other than default overrides parsing label. Setting <modkey> to other than default overrides <Alt> modifier.

(Tip: use this constructor to make a menu item to be contained into a menu,thus is a sub-menu)

int align = l_justify,guint key = GDK_VoidSymbol,

guint8 modkey = GDK_MOD1_MASK);

Constructor, makes a menu item to be attached to a menubar. Argument <align> follows aligning conventions.

Destructor.

Add a submenu to this menu. (Tip: this allows submenus to be attached in cascade)

Mark menu with a little dot.

Set menu item font.

Sets menu item pixmap at run-time.

Tips

Signals

activate_signal

Emitted when user select a menu item.

 

VDKMenubar class

Inherits from VDKObjectContainer

Description

This class provides a menu bar.

Public members

None

Properties

None

Methods

Constructor.

Destructor.

Set menu bar font. (Tip: applying a font to menu bar will spread the font to all menu and submenus contained)

<obj> must be a VDKMenuItem or derived types, adding other widgets generates a warning message and nothing will be added.

VDKOptionMenu class

Inherits from VDKObject

Description

This class wraps GtkOptionMenu

Methods

Constructor

Destructor

Add a menu

 

Programming tips

Making a menu should be easier than the "hard way" in GTK+. Here an example:

ChildWindow::Setup()

{

// makes a new menu bar

menubar = new VDKMenubar(this);

// makes a menu to be attached as first menu to menu bar

menu1 = new VDKMenuItem(menubar,"Menu..",mini_ofolder_xpm);

// makes menu1 submenu

VDKMenu *menu = new VDKMenu(this);

menu11 = new VDKMenuItem(menu,"Shows a scrolled window");

menu12 = new VDKMenuItem(menu,"Is child Visible ?");

menu13 = new VDKMenuItem(menu,"Toggle Help..");

menu->Separator();

menu14 = new VDKMenuItem(menu,"Quit..");

// attach menu to menu1

menu1->Add(menu);

// attach menu2 to menu bar

menu2 = new VDKMenuItem(menubar,"Help",book_xpm,r_justify);

// add menubar and an empty labelto form

Add(menubar);

add(label = new VDKLabel(this,""));

}

VDKTabPage class <notebook.h>

Inherits from VDKObject

Description

This class represents a single page of a notebook widget

public members

VDKLabel* TabLabel

PageList class <notebook.h>

Description

Represents page list of a notebook widget

Methods

Access to a single page

Returns how many pages are into notebook

 

 

VDKNotebook class <notebook.h>

Inherits from VDKObjectContainer

Description

This class provides a notebook widget

public members

PageList Pages;

Properties

int ActivePage;

int TabPosition;

bool Scrollable

bool PopUp

SIGNALS

switch_page_signal

Methods

Constructor

Destructor

char **pixmap_open = NULL);

Add a page to notebook putting into page <obj> (normally a box or table containing other objects), tab can show two different pixmaps, <pixmap_closed> when the page is’nt the active one and <pixmap_open> when the page is currently active. (Pixmaps should not exceed 16 pixels in height)

Adding <obj> actually adds a new page that contains <obj>

Remove the page from notebook.

Using properties

PageList Pages; // run-time read only

You can access to a single page to set TabLabel object properties, like this:

// disables last page

book->Pages[Pages.size()-1]->TabLabel->Enabled = false;

int ActivePage

Returns/ set currently active page. This property have also increment/decrement operator:

book->ActivePage++;

book->ActivePage—;

int TabPosition

Change/returns notebook tab position, can be one of the GtkPositionType enum values

described into Gtk+ tutorial.

bool Scrollable

Sets/gets notebook page scrollable flag.

bool PopUp

Sets/gets notebook pop menu flag.

Programming tips:

Add the notebook to parent (namely a box or a form) before to add pages.

EXAMPLES: In ./test/nbookwin.cc and .h

VDKPacker class <vdkpacker.h>inherits from VDKObjectContainerDESCRIPTIONVDKPacker class wraps gtkpacker

PROPERTIES

int Spacing

VDKPoint Padding

PUBLIC MEMBERS

none

METHODS

Contructor

Destructor

int anchor = int(GTK_ANCHOR_NORTH),

int options = int(GTK_PACK_EXPAND| GTK_FILL_X| GTK_FILL_Y),

int borderwith = 0);

Add an object to packer.

<side> can be one of the following::

GTK_SIDE_TOP, GTK_SIDE_BOTTOM, GTK_SIDE_LEFT, GTK_SIDE_RIGHT

<anchor> can be one of the following:

GTK_ANCHOR_CENTER, GTK_ANCHOR_NORTH, GTK_ANCHOR_NORTH_WEST,

GTK_ANCHOR_NORTH_EAST, GTK_ANCHOR_SOUTH, GTK_ANCHOR_SOUTH_WEST,

GTK_ANCHOR_SOUTH_EAST, GTK_ANCHOR_WEST, GTK_ANCHOR_EAST

<options> can be one of the following:

GTK_PACK_EXPAND, GTK_FILL_X, GTK_FILL_Y

and can be ored togheter.

 

Readjust child into packer

EXAMPLES:

In testvdk/packerwin.cc

VDKPaned class <paned.h>

Inherits from VDKObjectContainer

Description

This class provides a paned widget

Methods

Constructor, makes a paned widget, both vertically (mode == v_box) or horizontally paned

Destructor

Add an object to pane. Pane = 1 means left pane or top pane pending on paned mode.

 

EXAMPLES: ./test/panedwin.h

 

 

VDKPixmap class <pixmaps.h>

Inherits from VDKObject

Description

This class provides a pixmap widget.

Public members

None

Properties

None

Methods

Constructor, makes a pixmap loading it from <pixfile>, pixmap will have a tip if <tip> is’nt NULL.

Constructor, makes a pixmap using <pixdata>, pixmap will have a tip if <tip> is’nt NULL.

Destructor.

Change the raw pixmap contained into VDKPixmap with the pixmap contained into <file>

Change the raw pixmap contained into VDKPixmap with the pixmap the <newpix>

Change the raw pixmap contained into VDKPixmap with the pixmap contained into <pixdata>

Events:

button_press_event

Events:

Calling constructors with <pixfile> or <pixdata> left to NULL will construct only the inner event box, leaving underlying GdkPixmap* and GtkPixmap* set to NULL. This allows construct an empty pixmap that can be later initialized with SetPixmap().

VDKPixmapButton class <pix_button.h>

Inherits from VDKButton => VDKAbstractButton

 

Description

This class provides a labeled and/or pixmap’ed button.

Public members

None

Properties

char* Caption

bool CaptionWrap

Methods

char* pixfile,

char* label = NULL,

char* tip = NULL,

bool defButton = false,

GtkPositionType positon = GTK_POS_RIGHT,

int padding = 0);

Constructor, makes a pixmap button using pixmap contained into <pixfile> file.

if <pixfile> arg is (char*) NULL makes a pixmap button with a default <nice fish> pixmap.

(Mainly for vdkbuilder use).Tip: Using <pixfile> as NULL be sure to cast it to char* to avoid ambiguity with others constructors.

char* label = NULL, char* tip = NULL, bool defButton = no,

GtkPositionType positon = GTK_POS_RIGHT);

Constructor, makes a pixmap button using pixmap contained into <pixdata>.

For additional information see VDKLabelButton class.

VDKProgressbar class <progressbar.h>

Inherits from VDKObject

Description

This class provides a progress bar widget.

Public members

None

Properties

double Value;

set/get bar value and position

int BlockCount;

set/get in how many discrete blocks bar is divided

int BarStyle;

set/get bar style, can be one of the following:

int BarOrientation;

set/get bar orientation, can be one of the following:

bool ActivityMode;

set/get activity mode

Methods

Constructor make a progress bar that will fit into <min> - <max> range

Destructor

Update bar position.

Return bar position.

EXAMPLES: in ./test/progresswin.cc and .h

VDKRadioButtonGroup class <radiobtngroup.h>

Inherits from VDKObjectContainer

Description

This class provides a radio button group

Properties

RadioButtonList& Buttons

int Selected

Methods

Constructor, makes a radio button group

Destructor

Sets the button that will be "selected" by default. <buttonNumber> goes from 0 to n-1 where n is the number of buttons into group.

Sets the button that will be "selected". <buttonNumber> goes from 0 to n-1 where n is the number of buttons into group.

Return selected button.

Removes a button from radio button group.

Adds a radio button to a radio button group.

<obj> must be a VDKRadioButton or a derived type, adding other widgets generates a warning message and nothing will be added.

signals

toggled_signal

Received when one of the buttons into group is toggled.

using properties

Selected

Use this property to set or know wich button was toggled after a toggled_signal or to force a selection.

Selected property reflects the number of toggled button (from 0 to n-1)

Buttons

Allow access to n-th RadioButton into group

 

VDKRadioButton class <radiobtngroup.h>

Inherits from VDKCheckButton

Description

This class provides a radio button

Methods

Constructor, make a new radio button to be inserted into <group> group.

Destructor.

 

Tips

Emits "toggled" signal so user can handle it with dynamic tables.User can :

SignalConnect("toggled",&MyForm::Response,false);

or

SignalConnect(group,"toggled",&MyForm::Response,false);

note false value as <gtk> arg, vdk will emit and treat signal internally overriding gtk+ system.

EXAMPLES: ./test/rbutton.cc and .h

VDKSeparator class <separator.h>

Inherits from VDKObject

Description

This class provides a separator widget.

Public members

None

Properties

None

Methods

Constructor, makes a separator either horizontal (<mode> == h_separator) or

vertical (<mode> == v_separator).

Destructor.

VDKSlider class <slider.h>

Inherits from VDKObject

Description

This class provides a slider or "scale" widget.

Public members

None

Properties

float Value;

int Digits;

VDKUpdateType UpdatePolicy;

Methods

float lower, float upper, float step_increment,

int mode = h_box, int w = 100, int h = 30);

Constructor makes a slider with a default value <defValue>, <lower> and <upper> bounds, packed into a

<mode> box (h_box or v_box), with size <w> and <h>

Destructor

Gets slider value

Get slider precision digits

Get update policy that can be one of the following:

update_continuos, update_discontinuos,update_delayed; meaning are the same as Gtk+

Set the slider precision

Set update policy

signals

value_changed_signal

Received whenever slider value change. Depends also in update policy.

using properties

Value

Sets/gets slider value

Digits

Sets/gets slider precision

UpdatePolycy

Set/gets slider update policy.

EXAMPLES: ./test/rangewin.cc

VDKSpinButton class <spins.h>

Inherits from VDKObject

Description

This class provides a spin button widget.

Public members

None

Properties

float ValueAsFloat;

int ValueAsInt; (read only)

int Digits;

float LowerBound;

float UpperBound;

Methods

float lower, float upper, float step_increment, float climb_rate);

Constructor, args follows Gtk+ spin widget convention.

Destructor

Returns spin precision.

Set spin precision

Get spin value as float

Set spin value as float

Get spin value as integer

signals

value_changed_signal

Received whenever spin value change.

focus_out_signal

Received whenever the entry part of spin loose focus.

using properties

ValueAsFloat

Sets/gets slider value as float value

ValueAsInt

Gets slider value as integer value

Digits

Sets/gets slider precision

Tips

Since "value_changed" signal is hooked to internal adjustment object is possible to connect to it using dynamic tables:

SignalConnect("value_changed",&MyForm::Response,false);

or

SignalConnect(spin,"value_changed",&MyForm::Response,false);

Tip:note false value as <gtk> arg, vdk will emit and treat signal internally overriding gtk+ system.

EXAMPLES: ./test/rangewin.cc

VDKStatusbar class <statusbar.h>

Inherits from VDKObject

Description

This class provides a statusbar widget. VDKStatusbar does not handle contexts, each statusbar has his own context.

Public members

None

Properties

int Shadow

Methods

Constructor

Destructor

As Gtk+ does.

As Gtk+ does.

 

VDKTable class <tables.h>

Inherits from VDKObject

Description

This class provides a table widget.

Public members

None

Properties

int ColSpacing; Sets/gets between column spacing

int RowSpacing; Sets/gets between rows spacing

Methods

Constructor

Destructor

int top_attach,int bottom_attach)

Attach an object to table. (Tips: use default attach parameters)

int opt = int(GTK_FILL | GTK_EXPAND), int padding = 1);

Add an abject using table row,col and setting <opt> both for row and col

int y_o = int(GTK_FILL | GTK_EXPAND), int x_p = 0, int y_p = 0);

Add an object using all args provided by Gtk+.

EXAMPLES: in ./test/entrieswin.cc and .h

VDKText class <text.h>

Inherits from VDKObject

Description

This class provides a gtk+ text widget wrapper.

public members

bool Changed

VDKTextFont TextFont

GdkColor* TextFont.foreground

GdkColor* TextFont.background

char* TextFont.font

Properties

bool WordWrap

int Pointer

bool Editable

unsigned int Length

Methods

Gets text length.

Load file <filename> and insert it into text. Returns TRUE if succesfull.

Save text into file <filename>. Returns TRUE if succesfull.

GtkStateType state = GTK_STATE_NORMAL);

Sets text background.

Sets text font.

Insert <nchars> of text at insertion point. (nchars == -1 means all).

Same as gtk+ gtk_text_freeze();

Same as gtk+ gtk_text_thaw();

Insert a end of line to text.

Delete backward <nchars> chars.

Delete forward <nchars> chars.

Gets chars from text starting at <start> position until <end> position.

(end == -1 means get all chars from <start>).

Get insertion point position.

Set insertion point position.

Get word wrap flag.

Set word wrap flag.

Get editable flag.

Set editable flag.

Clear all text.

Using properties and public members

Use this properties to set text font, foreground and background. Setting any property to NULL restore defaults. (See /test/textwin.cc on distribution for more informations.)

Setting this property to true/false enable/disable word wrapping, default is false.

Set to true if the text was changed. This property should set to false by the user.

EXAMPLES: in ./testvdk/textwin.cc,.h and textwindow.cc,.h

Tip

Any updating operations on this widget (setting fore/back included) should be done after widget is realized. This means that is a good practice hook up with "realize" signal and do these operation on "realize" response function.

See textwindow.cc source file on testvdk dir for more detailed informations.

VDKTimer class <timer.h>

Inherits from VDKObject

Description

This class provides a timer.

Public members

None

Properties

None

Methods

Constructor, makes a timer with <tick> interval, if <start> is true, timer will start at creation.

Destructor.

Starts timer.

Stops and reset timer.

Returns true if timer is already started.

signals

timer_tick_signal

Received whenever timer <interval> expires

EXAMPLES: in ./test/progresswin.cc and .h

VDKToolbar class <toolbar.h>

Inherits from VDKObjectContainer

Description

This class provides a Gtk* toolbar widget wrapper.

Public members

None

Properties

ToolWidgetList* WidgetList

GtkWidgetList* ButtonList

int ButtonPressed

GtkOrientation Orientation

GtkToolbarStyle Style

bool Borderless

GtkReliefStyle Relief

int Spacing

GtkToolbarStyle Style

Methods

Constructs a toolbar with orientation as <orientation> arg says.

Add a generic object to the toolbar

Add a pixmap’ed button to toolbar.

Add a pixmap’ed button to toolbar.

Destructor.

Add a space to toolbar.

Set toolbar orientation. <orientation> arg follows Gtk+ convention.

Set toolbar style. <style> arg follows Gtk+ convention.

Returns the n.th buttons into toolbar

signals

clicked_signal

Received whenever a tool button was pressed

Using properties

Is a list of VDKObject* inserted into tool bar. Use this properties to access them

Is a list of GtkWidget* inserted into tool bar. Use this properties to access them

Use it to know which button wae pressed as toolbar emit the clicked_signal. Pressed is a value betwwen 0 and n-1 where n is the number of buttons inserted into toolbar.

Set/get toolbar orientation

Set/get toolbar style, can be:

EXAMPLES: in ./test/tbarwin.cc and .h

VDKTooltip class <tooltip.h>

Inherits from VDKObject

Description

This class provides a tooltip.

Public members

None

Properties

None

Methods

char* tip, int delay = 0);

Constructor, makes a tooltip owned by <owner> form and to be applied to <tipped> object having <tip> prompt and <delay> delay.

Destructor.

int bred, int bgreen, int bblue);

Set foreground (fred,fgreen,fblue) and background (bred,bgreen,bblue) colors.

Tip: this method is actually void, don’t use it.

Set tip prompt.

Set tip delay.

VDKArray<T> template class <vdkarray.h>

Description

An array can contain type<T> objects, and can resize itself to accomodate others objects. Resizing operations must be explicit.

A generic type<T> must provide consistent:

T() default constructor

T(T& t) copy initializer

T& =(T& t) assignement operator

in order to assure correct array deep-copying

A generic type<T> should provide also:

int operator==(T& t) equality operator

int operator<(T& t) less than operator

in order to correctly use heapsort routine.

I recommend using typedef to consistently declare a type<T> Array:

typedef Array<someClass> SomeClassArray;

Public members

None

Properties

None

Methods

Constructor, makes an array of <n> elements.

Resize array to <n> elements.

Accessing

(Tip: operator[] can used both in left or right side of an expression, like this:

typedef VDKArray<int> IntArray;

IntArray integers(10);

integers[0] = 6;

int i = integers[0];

)

Sort array.

Returns true if two arrays are equal.

VDKBtree<T> template class <vdkbtrees..h>

Description

VDKBtree<T> class has a value semantic, so all managed objects are copied from original values. VDKBtree<T> class implements red/black balanced trees.

I suggest to use typedef's like:

typedef VDKBtree<someClass> SomeClassBtree;

Public members

VDKBtree::Iterator (VDKBtree& tree, BtreeIteratorMode start = BtMinKey);

Iterator is implemented as a member of VDKBtree, not an external object like in lists.

Properties

None

Methods

Constructor, makes an empty tree

Copy-initializer

Assignement

Destructor

Add a type <T> object to tree.

Remove a type<T> from tree.

Find a type<T> object address that matches <q>. Return T* NULL if not found.

Return true if this is an empty tree

Check tree integrity (for debugging purposes). Returns TRUE on success.

Return tree size in nodes.

VDKBtree<T> Iterator class <vdkbtrees..h>

Constructor, makes an iterator starting with <start> mode:

Start iterator over at the minimum, maximum or root node of the binary tree.

Destructor

Dereferencing operators, return the object of the node currently pointed to by the iterator.

Returns a pointer to the object of the node currently pointed to (as opposed to returning a copy of the node, as the dereferencing operator above does)

Move iterator to next key

Move iterator to prev key

Move iterator to the parent of the node currently pointed.

Returns 0 if the iterator does not point at a valid node, thus was moved behind the lowest/highest key.

PROGRAMMING TIPS

Here an example how to construct, fill and trasverse a tree:

typedef VDKBtree<int> intbt;

int v[LUNG];

main(int , char **)

{

intbt btree;

//…….

// add nodes to tree

for (t=0; t < LUNG ;t++)

btree.Add(v[t]);

// makes an iterator

intbt::Iterator iter(btree);

for (; iter;iter++)

{

int i = iter.current();

// make whatever with i

}

// removes all nodes

for (t=0; t < LUNG; t++)

btree.unlink(v[t]);

}

EXAMPLES: in ./example/template/ttest.cc and .h

calendardate class <vdkdate.h>

Description

This class provide a date object.

Public members

None

Properties

None

Methods

Default constructor, uses system date. If <mode> is mmddyyyy uses English format, otherwise uses European format (<mode> == ddmmyyyy).

Constructor, makes a date from string <s>, accepts one of <sep> separator chars.

Destructor.

Returns julian date.

Return day index: 0 = sunday, 1 = monday,... 6 = saturday

Returns day

Return month

Return year.

Returns an internal buffer formatted in "week-day month day year" format, do not modify directly this buffer, copy it before use.

OPERATORS

Returns an internal buffer formatted in "dd/mm/yyyy" or "mm/dd/yyyy" format,

do not modify directly this buffer, copy it before use.

Returns an internal buffer formatted in "yyyymmdd" format, do not modify directly this buffer, copy it before use.

Returns true if is a valid date.

RELATIONAL OPERATORS

Returns true if date year is leap.

VDKHeap class <vdkheap.h>

Description

This class provide a template heap object.

Public members

None

Properties

None

Methods

Constructor, makes an heap from an array of types T

Destructor

Sort routine.

Access to n-th heap node

Returns heap size

Return true if heaps are equal

VDKPoint class <vdkutils.h>

Description

This class provide a simple point object.

Public members

None

Properties

int x,y

Methods

Void constructor

Constructor, makes a point of x,y coordinates

Destructor

Equality operator

Disequality operator

Returns a new point offset by dx,dy

Return a new point with negative x,y coordinates

Offset this point of dx,dy

 

 

VDKRect class <vdkutils.h>

Description

This class provide a simple rectangle object.

Public members

None

Properties

None

Methods

Void constructor

Constructor, makes a rect with origin x,y and <w> width, <h> height

Copy initializer

Return rect origin

Returns rect width.

Returns rect height

Return true if this contains <point>

Returns true if this intersect <r>.

VDKRgb class <vdkutils.h>

Description

This class provide a simple RGB color structure.

Public members

int red,green,blue;

Properties

None

Methods

 

Constructor, <name> is chosen from those provided in rgb X database (normally on /usr/lib/X11/rgb.txt )

VDKString class <vdkstring.h>

Description

This class provides famous count referenced string objects.

Public members

None

Properties

None

Methods

Constructors

Assignment

Destructor

Conversion

(Caution this violates OOP data hiding concept !)

Relational operators

strcat’s

Returns true if is an empty string.

VDKValueList<T> template class <value_sem_list.h>

Description

VDKValueList class has a value semantic, so all managed object are copied from original values. VDKValueList class can manage all T type object provided that:

Implementation notes:

I suggest using typedef's as follows:

typedef VDKValueList<someClass> SomeClassVDKValueListList;

typedef VDKValueListIterator<SomeClass> SomeClassVDKValueListIterator;

Public members

None

Properties

None

Methods

Constructor

Copy-initializer

Assignement

Destructor

Append a T type to list

Prepend a T type to list.

Insert in order a T type to list.

Flushes list

Access to list by ordinal position

Find <t> T type

Returns list size

Detach T type at <ndx> position.

Find the position of <t> T type.

VDKValueListIterator<T> template class <value_sem_list.h>

Description

This is the list iterator

Public members

None

Properties

None

Methods

Void constructor (user doesn’t care)

Constructor, makes an iterator over <l> list

Destructor.

Incremental operator (posfix)

Incremental operator (infix)

Convert iterator into a boolean (0 at list end)

Return type T currently accessed.

Rewind iterator to list head

Programming tips

Using iterators is straightforward:

typedef VDKValueList<int> IntList;

typedef VDKValueListIterator<int> IntListIterator;

IntList list;

// some code to fill list goes here..

// ...

// ...

IntListIterator li(list);

while(li)

{

// make whatever

makewhatever(li.current());

li++;

}

or

for(IntListIterator li(list);li;li++)

printf("\n%d",li.current();

VDKList<T> template class <dlist.h>

Description

VDKList class has a reference semantic, so all managed object are pointer to original values. This type of list is widely used for VDK internals, reference is provided because some properties refer to these lists.

Implementation notes:

I suggest to use typedef's like:

typedef VDKList<someClass> SomeClassVDKListList;

typedef VDKListIterator<SomeClass> SomeClassVDKListIterator;

Public members

None

Methods

Constructs an empty list

Destructor. This type of list doed not owns the object pointed thus do not provide to their destruction. Destruction of pointed objects must be explicit. Here an example extracted from forms.cc code where the form delete all contained objects:

// delete objects

ObjectListIterator lo(objects);

for(;lo;lo++)

delete lo.current();

Append a pointer to a type T object to the list.To maintain reference integrity no same pointer will be added twice.

Prepend a pointer to a type T object to the list. To maintain reference integrity no same pointer will be added twice.

Check if the object pointed by x is into the list. Return NULL if not found.

Return the object pointed by the list head.

Find ordinal position of the object pointed by x.

Return pointer to <n> position.

Remove the pointer from list.

Returns list size.

flushes the list.

VDKRawObject class <rawobj.h>

Description

This class provides a base class for derived raw objects. Usually you do not create base raw objects but

derived fonts, colors and raw pixmaps.

Methods

Remove this from garbage collection and explicitely destroy raw object.

 

 

VDKColor class <colors.h>

Inherits from VDKRawObject

Description

This class provides a color.

Public members

None

Properties

None

Methods

Constructor, makes a color owned by <obj>.

Constructor, makes a color owned by <obj>.

Constructor with an X color name, <name> should be chosen from those provided in rgb X database (normally on /usr/lib/X11/rgb.txt )

Returns true if color was properly loaded and initialized

Destructor.

Both operators convert a VDKColor into a GdkColor*.

EXAMPLES: ./test/canvaswin.cc and .h

VDKFont class <vdkfont.h>

Inherits from VDKRawObject

Description

This class provides a raw font. Fonts can be owned either by an object or a form.

Methods

Constructors <name> is as usual a "X-font-string-chock-full-o-dashes-goes-in-here"

Destructor

Return font height

Return string width

Returns true if two font are equivalent

Returns font name

Convert a VDKFont into a gdk one

Return font id

VDKRawPixmap class <rawpixmap.h>

Inherits from VDKRawObject

Description

This class provides a raw pixmap . Raw pixmaps can be owned either by an object or a form.

Methods

Constructors.

Destructor

Convert a raw pixmap into a gdk pixmaps

Return pixmap mask

Return pixmap style

Paint the pixmap on owner at coordinates x,y.Leaving x and y at 0 value will paint the pixmap in the last position where was painted before.

Returns pixmap width and height in pixels.

EXAMPLES: ./test/canvaswin.cc and .h

Intentionally left blank page

 

 

 

 

 

 

 

 

 

 

 

 

 

VDK components reference

 

Intentionally left blank page

VDKChart class <chart.h>

VDKChart is a component that allows to plot 2D data in various formats. VDKChart is a base class that implements common functionalities to all subclasses actually supported:

VDKLineChart plots data as line graph

VDKScatteredChart plots data as scattered points

VDKBarChart plots data as bar graph

COMPONENT USAGE

Use of a VDKChart is straigthforward, normally user adds 2D points to a Series, eventually sets some Series property like color and fonts. After that adds Series to a VDKChart that is responsible to plot data and to take care of scaling/resizing stuff.

See testvdk/tchart.cc for further informations.

VDKChart Classes

Coord class

DESCRIPTIONCoord is a 2D point objectPUBLIC MEMBERSdouble x,yMETHODSCoord(double x = 0.0, double y = 0.0)Constructor.

Series class

DESCRIPTION

Series is mainly a list of 2D points with some properties and behaviours added.

PROPERTIES

VDKRgb Color;

GdkLineStyle LineStyle;

int LineWidth;

GdkCapStyle LineCapStyle;

GdkJoinStyle LineJoinStyle;

METHODS

Contructor, makes a series with title <title>.

Destructor

Add a 2D point to series.

Add an <n> length array of 2D points to series.

Returns series title

Returns true if this as the same title of <s>

 

VDKChart classinherits from VDKCanvasDESCRIPTIONVDKChart is base class of various subclasses. This class implements common functionalities for all chart types.

PROPERTIES

int ChartBorder;

Sets/gets chart border. This area is left to draw axis, title and axis labels.

Default is 20, but larger border is advisable.

VDKString Title;

Sets/gets chart title, title is draw in the middle of char upper border.

VDKString LabelX;

Sets/gets x axis label.

VDKString LabelY;

Sets/gets y axis label.

int LabelXDigits

int LabelYDigits

Control how many decimal digits are displayed into x,y ticks labels.

METHODS

Add series <s> to chart. Series title is checked for unicity.

Clears chart destroying all series

Self explanatory

PLOTTING/DRAWING FUNCTIONS

Actually plots data into chart. Plots <t>-th item of series <s>.

Items has <p> coordinates ready to be plotted, scaled and/or resized accordling

to chart size and data domain. At VDKChart level does nothing subclasses

should override this to draw data in various formats.See VDKLineChart::Draw(),

VDKScatteredChart::Draw() and VDKBarChart::Draw() for further informations.

Returns chart graphic context

Set drawing color, this affects plotting area only, to change axis, title and labels color

use Foreground property.

GdkJoinStyle joinStyle);

Sets plotting line attributes. Args follows Gdk enums.

SUBCLASSING VDKCHARTSubclassing is straigthforward, user normally need only to override Plot() functions in order to draw data in desired format. All others functionalitiessuch as scaling/resizing and redrawing are accomplished by VDKChart class functions.

See tchart.cc and chart.cc sources for further informations.

VDKColorBrowserusage:VDKColorBrowserParms parms;parms.title = "color browser window title";parms.ok = "ok button caption";parms.cancel = "cancel button caption";parms.loadvdk = "load vdk defaults button caption";

parms.loadrgb = "load rgb button caption";

VDKColorBrowser* child = new VDKColorBrowser(this, &parms);

child->Setup();

child->ShowModal();

// if user pressed cancel rgb.red,rgb.green,rgb.blue are left to -1

if(parms.rgb.red >= 0)

{

printf("\nselected color: VDKRgb(%d,%d,%d)",

parms.rgb.red,parms.rgb.green,parms.rgb.blue);

fflush(stdout);

}

VDKCoolButton class <coolbutton.h>

Inherits from VDKObject

Description

This class provides a cool button widget. A cool button normally shows a flat pixmap, it will revert in a pixmap button when mouse enter and flips again into a flat pixmap when mouse leaves.

** warning **

This widget is now considered obsolete, even if still supported its use is deprecated since won’t continue to be supported on next vdk versions.

Public members

None

Properties

None

Methods

char** pixdata, char** grayedpix = NULL,

char* tip = NULL);

Constructs a cool button, it must be inserted into a box that become button parent. Two pixmaps can be provided, the first arg <pixdata> for normal operations and <grayedpix> displayed when the button is disabled.

Destructor.

Overrides VDKObject::Enable() flipping between normal and grayed pixmap.

Tip: usually user does not construct a stand-alone cool buttons but inserts them into a cool bar (see below)

VDKCoolbar class <coolbar.h>

Inherits from VDKBox

** warning **

This widget is now considered obsolete, even if still supported its use is deprecated since won’t continue to be supported on next vdk versions.

Description

This class provides a container for cool buttons that manages their appearance and behaviour.

Public members

int ButtonPressed

Properties

CoolButtonList* ButtonList (read only)

Methods

Constructor, make a cool bar, coolbuttons will be inserted horizontally or vertically pending on<mode> arg.

Destructor

char* tip = NULL);

Add a cool button to coolbar and returns a pointer to added cool button.

Tip: All buttons into a coolbar acts as pixmap buttons. ButtonList property returns a list of all buttons inserted into coolbar. Since a coolbar is a box you can easily add other objects than coolbuttons .

Signal

clicked_signal

Emitted whenever a coolbutton is pressed. ButtonPressed property reports wich button was pressed, value starts from 0 and reflects the order they was inserted into coolbar.

Using properties and public members

ButtonList returns a pointer to inserted button (see VDKList)

ButtonPressed upon receive a clicked_signal ButtonPressed reports wich button was pressed.

EXAMPLES: in ./test/tbarwin.h and .cc

Tip:

This class is obsolete and it’s use is deprecated.

 

VDKCombo class <combo.h>

Inherits from VDKObject

Description

This class is a simplified wrapper for GtkCombo.

Typedefs

VDKValueList<VDKString> StringList

VDKValueListIterator<VDKString> StringListIterator

Properties

char* Text

bool Editable

bool Sorted

bool Hidden

bool CaseSensitive

StringList PopdownStrings

int Selected

Methods

Constructor. def is an optional initial value to be shown in the Entrybox.

Destructor.

Enable/Disable Arrowkeys to select listitems in the Entrybox.

Arrowkeys change value if current value not in list.

The text in the entry must be or not be in the list.

Clears all items in the Listbox. (Value in Entry is not affected.)

Programmatically select an item from the Listbox.

Programmatically unselect an item from the Listbox. (Hardly ever useful)

Properties Set/Get functions:

void SetText(char* text);

char* GetText();

void SetEditable(bool flag);

bool GetEditable();

void SetSorted(bool flag);

bool GetSorted();

void SetHidden(bool flag);

bool GetHidden()

void SetPopdownStrings(StringList);

StringList GetPopdownStrings();

void SetCaseSensitive(bool flag);

bool GetCaseSensitive();

int GetSelected();

Signals

activate_signal

received when the Enter key is pressed in the Entry.

changed_signal

received when text in Entry is changed.

selection_changed_signal

received when the selection in the List is changed. This happens when an item has been selected or unselected. This means that the signal is received more than once on a new selection. Always check the Selected property for a value of -1.

focus_in_signal

received when Entry gets focus.

focus_out_signal

received when Entry loses focus.

Using properties

Text

Set/Get the text in the Entry.

Editable

Same as Editable property in VDKEntry. Setting it to false allows you to provide a read-only list to select from,

without the user being able to enter text.

Sorted

Default: false. Setting Sorted to true will automatically sort the listitems alphabetically and maintain the list sorted whenever a new item is added.

Hidden

Entry text visibility flag. (As in VDKEntry)

CaseSensitive

Default: false. Whether the Combo box should check for equality in the list case-sensitive or not.

Selected

Returns the index of the currently selected item in the dropdown list or -1 if no item is selected. See PopdownStrings for example usage.

PopdownStrings

A StringList corresponding to the Text of the Listitems. Use this function to add items to the list,

i.e:

StringList sl = mycombo->PopdownStrings;

VDKString s("New line");

sl.add(s);

mycombo->PopdownStrings = sl;

Since StringList is of type VDKValueList<VDKString> you can use all functions of VDKValueList to manipulate the list.

It is very convenient to access the StringList by index:

int sel = mycombo->Selected;

char *seltext = (sel == -1) ? "None" : (char*)(mycombo->GetPopdownStrings())[sel];

printf("Selected item is %s\n",seltext);

Tip: Note the use of the Get-Function GetPopdownStrings() instead of the property because it was used within an expression. mycombo->PopdownStrings[sel] would result in a compilation error. You can however use a typecast:

((StringList)mycombo->PopdownStrings)[sel]

 

VDKDataBox class <vdkdatabox.h>inherits from VDKObjectDESCRIPTIONThis is a simple (almost 1:1) wrapper of GtkDatabox 0.1.11.0 developed by Roland Bock.

Shameless stolen to Ionutz Borcomann.

Styles The data box has the following styles: GTK_DATABOX_NOT_DISPLAYED GTK_DATABOX_POINTS GTK_DATABOX_LINES GTK_DATABOX_BARSZooming operationsWith zoom enabled, drag the area that needs to be zoomed and click on center button on the mouse.

To unzoom, right click on the mouse (repeated clicks unzoom to original scale).

PUBLIC MEMBERS

None

PROPERTIES

bool Rulersbool Crossbool Scrollbarsbool ZoomGtkDataboxValue Mark (read-only)

GtkDataboxValue Select (read-only)

GtkDataboxCoord TopLeft (read-only)

GtkDataboxCoord BottomRight (read-only)

METHODS

Shows or hides the axis cross. If you use the Cross property, setting it will call a Redraw(). If you don't want a Redraw(), use SetCross(bool, bool) function.

It is similar with SetCross(bool), but you can controll the call of Redraw() function.

Args:

val controls the show or hide state of the cross.

redraw controls if we call or not a subsequent Redraw().

Set to false if you don't want a redraw.

Show or hides the scrollbars.

Enable or disable the zoom.

VDKColor* GetColor(int index);Get the color of a dataset. The returned value is a pointer to a new allocated VDKColor. Therefore, it will not reflect furthure changes in the color of the index dataset. You can free memory associated with it using Destroy() method.

Set the color of a dataset.

Args:

dataset index

color new color for the dataset

redraw controls if we call or not a subsequent Redraw(). Set to false if you don't want a redraw.

get data value.

Args:

coord screen coordinates of a point.

data value associated with the coord.

bool visible = true);

Get the extreme values.

Args:

min returns the minimum x and y values of the databox.

max returns the maximum x and y values of the databox.

visible if true, then min and max are computed for the visible window; otherwise, they are computed for the whole databox.

Rescale the databox using given minimum and maximum values.

Args:

min the minimum x and y values.

max the maximum x and y values.

Redraw the databox. Use it after you change your datas.

Remove a single dataset.

Args:

index index of dataset to be removed.

return 0 on success.

Remove all datasets. Return 0 on success.

Remove a single dataset and destroy data associated with it.

Args:

index index of dataset to be destroyed.

return 0 on success.

Note: this function destroys data associated using g_free(). Do not use it, unless you have used g_new() to allocate

the memory for your data.

Remove all datasets and destroy data associated with them.

return 0 on success.

guint dotSize = 0);

Add a dataset. Both X and Y must be supplied. Also the number of points and a color to be used for ploting the dataset.

Return index of the dataset added, on success, or -1, on error.

Args:

length number of points from the dataset.

X pointer to x vector of data.

Y pointer to y vector of data.

color color for the ploting the dataset

type type of points.

dotsize size of the dots used.

 

guint indexSharedY,

VDKColor *color,

GtkDataboxDataType type = GTK_DATABOX_POINTS,

guint dotSize = 0);

Add a dataset. You must supply a X vector of data and an index to an existent Y vector.

also the number of points and a color to be used for ploting the dataset. If the number of points of X and shared Y vector are different, an error is generated. Returns index of the dataset added, on success, or -1, on error.

Args:

length number of points from the dataset.

X pointer to x vector of data.

indexSharedY index to a shared y vector of data.

color color for the ploting the dataset

type type of points.

dotsize size of the dots used.

guint indexSharedX,

VDKColor *color,

GtkDataboxDataType type = GTK_DATABOX_POINTS,

guint dotSize = 0);

Add a dataset. You must supply a Y vector of data and an index to an existent X vector. Also the number of points and a color to be used for ploting the dataset. If the number of points of X and shared Y vector are different, an error is generated. Return index of the dataset added, on success, or -1, on error.

Args:

length number of points from the dataset.

Y pointer to y vector of data.

indexSharedX index to a shared x vector of data.

color color for the ploting the dataset

type type of points.

dotsize size of the dots used.

USING PROPERTIES

BottomRight

Read the value of the bottom right corner of the window after a zoom.

Mark

Read the value of the marked (where you clicked down the mouse) point.

Select

Read the value of the selection.

TopLeft

Read the value of the top left corner of the window after a zoom

Static Table Signals- databox_zoomed_signal Emitted when databox is zoomed.- databox_marked_signal

Emitted when mouse is clicked in databox.

- databox_selection_started_signal

Emitted when a selection is started in databox.

- databox_selection_changed_signal

Emitted when the selection is changed.

- databox_selection_stopped_signal

Emitted when the selection is finished.

- databox_selection_canceled_signal

Emitted when the selection is canceled

(by clicking outside the selection).

Dynamic Table Signals

"databox_zoomed"

"databox_marked"

"databox_selection_started"

"databox_selection_changed"

"databox_selection_stopped"

"databox_selection_canceled"

Note:

Dynamic table signals are different from the equivalent databox signals in that they do not send values of the marked point or selection, for instance. These values can be read using the read-only properties.

EXAMPLES

See at /testvdk/databoxwin.cc .h

VDKFileDialog <FileDialog.h>

Inherits from VDKForm

This class is a file selection modal window that supports multiple file selection.

Properties

VDKString Filter

methods

FileStringArray* selections,

char* title = "",

GtkWindowType display = GTK_WINDOW_TOPLEVEL);

USAGE:

Here is an example:

#include <FileDialog.h>

FileStringArray selections;

VDKFileDialog *child = new VDKFileDialog( Application()->MainForm,

&selections,

"File Open dialog");

child->Filter = "*.cc";

child->ShowModal();

for( int t = 0; t < selections.size(); t++)

{

printf("\nselection:%s",(char*) selections[t]);

fflush(stdout);

}

// On return selections will be an empty array if user presses "cancel" button.

VDKFileSaveAsDialog <FileSaveAsDialog.h>

Inherits from VDKFileDialog

This class is a file "SaveAs" selection modal window .

USAGE:

Equal to VDKFileDialog, excpet that does not handle multiple file selections and warns end-user if he/she attempts to overwrite a file.

VDKFileTreeDialog <FileTreeDialog.h>

Inherits from VDKForm

This class is a file selection modal window that supports multiple file selection.

Uses DirTree widget: Dirtree widget is a part of Gtk see distribution. The original author is: Hotaru Lee <hotaru@163.net>

FileStringArray* selections,

char* title = "",

GtkWindowType display = GTK_WINDOW_TOPLEVEL);

USAGE: Same as FileDialog class

EXAMPLES: In ./test/testvdk.cc:

VDKGrid class <vdkgrid.h>

DESCRIPTION

VDKGrid is a wrapper of gtksheet widget made by Adrian E. Feiguin adrian@ifir.ifir.edu.ar.

Basically is a table of cells that can be editable or contain others widget as well. Table can be done with or without column/row headers.

 

VDKCell class

DESCRIPTIONRepresent a single grid cellPUBLIC MEMBERS

none

PROPERTIES

VDKString Text

GtkJustification Align

VDKObject* AttachedWidget (read-only)

METHODS

Set cell background

Set cell foreground

Attach a generic widget to cell

Returns cell row

Returns cell column

Set cell border

- <mask> can be any ored combination of:

GTK_SHEET_LEFT_BORDER, GTK_SHEET_RIGHT_BORDER,

GTK_SHEET_TOP_BORDER, GTK_SHEET_BOTTOM_BORDER

- <width> is line thickness in pixels

- <line_style> can be one of:

GDK_LINE_SOLID, GDK_LINE_ON_OFF_DASH, GDK_LINE_DOUBLE_DASH

VDKGridColumn classRepresents a grid column header

PROPERTIES

VDKString Title

int Width

bool Enabled

VDKRgb Background

VDKRgb Foreground

bool Visible

METHODS

none

USING PROPERTIES

Width

Setting this prop to 0 makes each row width to be adapted to contained text and used font dimensions

Enabled

Enable/disable columns titles, disabling makes them to act as titles only, enabling makes them to act as buttons, grid_select_column signal can be handled.

VDKGridRow class

Represents a grid column header

PROPERTIES

VDKString Title

int Height

bool Enabled

bool Visible

METHODS

none

USING PROPERTIES

Height

Setting this prop to 0 makes each row height to be adapted to used font dimensions

Enabled

Enable/disable row titles, disabling makes them to act as titles only, enabling makes them to act as buttons, grid_select_row signal can be handled.

VDKGrid class

The wrapper

 

PROPERTIES

VDKGridCell *ActiveCell

VDKGridCell *PreviousActiveCell

VDKGridCell *ChangedCell

int SelectedRow

int SelectedColumn

bool RowTitleVisible

bool ColumnTitleVisible

int MaxRows

int MaxColumns

METHODS

Constructor, makes a VDKGrid of <row> rows and <cols> columns.If <editable> is true cells can be edited.

<title> refers to grid title.

Destructor

Return a VDKGrid cell at <row,col> or <p> position.

Returns grid columns or row

Clear all cell contents.

Add a row getting values from a string array

Add <n> rows to table

Delete all grid rows.

 

SIGNALS

grid_select_cell

Emitted when a cell become selected (gain focus)

grid_unselect_cell

Emitted when a cell become unselected (looses focus)

grid_changed_cell

Emitted when a cell content is changed by user

grid_select_row

Emitted when a row is selected

grid_select_column

Emitted when a column is selected

EXAMPLE:

See at /testvdk/vdkgridwin.cc/.h

VDKPanelbar class <panelbar.h>

Inherits from VDKObject

 

Typedefs

typedef VDKList<VDKLabel> PanelList;

Description

This class implements a status bar that can accomodate one or more panels. Each panel is a VDKLabel.

Methods

Constructor, make a panelbar with <panels_num> panels.

Destructor.

Return panel list. Since each panel is a label use this to access to panels in order to set panel contents.

Ie:

panelbar->Panels()[0]->Caption = "a caption";

EXAMPLES: in ./test/testvdk.cc

 

 

 

 

 

 

 

 

 

 

 

 

 

APPENDICES

 

Intentionally left blank page

GTK ENUMS

/* Arrow types */

typedef enum

{

GTK_ARROW_UP, GTK_ARROW_DOWN, GTK_ARROW_LEFT, GTK_ARROW_RIGHT

} GtkArrowType;

/* Attach options (for tables) */

typedef enum

{

GTK_EXPAND = 1 << 0, GTK_SHRINK = 1 << 1, GTK_FILL = 1 << 2

} GtkAttachOptions;

/* Button box styles */

typedef enum

{

GTK_BUTTONBOX_DEFAULT_STYLE, GTK_BUTTONBOX_SPREAD,

GTK_BUTTONBOX_EDGE, GTK_BUTTONBOX_START,

GTK_BUTTONBOX_END

} GtkButtonBoxStyle;

/* Curve types */

typedef enum

{

GTK_CURVE_TYPE_LINEAR, /* linear interpolation */

GTK_CURVE_TYPE_SPLINE, /* spline interpolation */

GTK_CURVE_TYPE_FREE /* free form curve */

} GtkCurveType;

/* Focus movement types */

typedef enum

{

GTK_DIR_TAB_FORWARD, GTK_DIR_TAB_BACKWARD, GTK_DIR_UP,

GTK_DIR_DOWN, GTK_DIR_LEFT, GTK_DIR_RIGHT

} GtkDirectionType;

/* justification for label and maybe other widgets (text?) */

typedef enum

{

GTK_JUSTIFY_LEFT, GTK_JUSTIFY_RIGHT, GTK_JUSTIFY_CENTER,

GTK_JUSTIFY_FILL

} GtkJustification;

/* GtkPatternSpec match types */

typedef enum

{

GTK_MATCH_ALL, /* "*A?A*" */

GTK_MATCH_ALL_TAIL, /* "*A?AA" */

GTK_MATCH_HEAD, /* "AAAA*" */

GTK_MATCH_TAIL, /* "*AAAA" */

GTK_MATCH_EXACT, /* "AAAAA" */

GTK_MATCH_LAST

} GtkMatchType;

/* Menu keyboard movement types */

typedef enum

{

GTK_MENU_DIR_PARENT, GTK_MENU_DIR_CHILD, GTK_MENU_DIR_NEXT,

GTK_MENU_DIR_PREV

} GtkMenuDirectionType;

typedef enum

{

GTK_MENU_FACTORY_MENU, GTK_MENU_FACTORY_MENU_BAR,

GTK_MENU_FACTORY_OPTION_MENU

} GtkMenuFactoryType;

typedef enum

{

GTK_PIXELS, GTK_INCHES, GTK_CENTIMETERS

} GtkMetricType;

/* Orientation for toolbars, etc. */

typedef enum

{

GTK_ORIENTATION_HORIZONTAL, GTK_ORIENTATION_VERTICAL

} GtkOrientation;

/* Placement type for scrolled window */

typedef enum

{

GTK_CORNER_TOP_LEFT, GTK_CORNER_BOTTOM_LEFT, GTK_CORNER_TOP_RIGHT,

GTK_CORNER_BOTTOM_RIGHT

} GtkCornerType;

/* Packing types (for boxes) */

typedef enum

{

GTK_PACK_START, GTK_PACK_END

} GtkPackType;

/* priorities for path lookups */

typedef enum

{

GTK_PATH_PRIO_LOWEST = 0,

GTK_PATH_PRIO_GTK = 4,

GTK_PATH_PRIO_APPLICATION = 8,

GTK_PATH_PRIO_RC = 12,

GTK_PATH_PRIO_HIGHEST = 15,

GTK_PATH_PRIO_MASK = 0x0f

} GtkPathPriorityType;

/* widget path types */

typedef enum

{

GTK_PATH_WIDGET, GTK_PATH_WIDGET_CLASS, GTK_PATH_CLASS

} GtkPathType;

/* Scrollbar policy types (for scrolled windows) */

typedef enum

{

GTK_POLICY_ALWAYS, GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER

} GtkPolicyType;

typedef enum

{

GTK_POS_LEFT, GTK_POS_RIGHT, GTK_POS_TOP, GTK_POS_BOTTOM

} GtkPositionType;

typedef enum

{

GTK_PREVIEW_COLOR, GTK_PREVIEW_GRAYSCALE

} GtkPreviewType;

 

/* Style for buttons */

typedef enum

{

GTK_RELIEF_NORMAL, GTK_RELIEF_HALF, GTK_RELIEF_NONE

} GtkReliefStyle;

/* Resize type */

typedef enum

{

GTK_RESIZE_PARENT, /* Pass resize request to the parent */

GTK_RESIZE_QUEUE, /* Queue resizes on this widget */

GTK_RESIZE_IMMEDIATE /* Perform the resizes now */

} GtkResizeMode;

/* signal run types */

typedef enum /*< flags >*/

{

GTK_RUN_FIRST = 1 << 0,

GTK_RUN_LAST = 1 << 1,

GTK_RUN_BOTH = (GTK_RUN_FIRST | GTK_RUN_LAST),

GTK_RUN_NO_RECURSE = 1 << 2,

GTK_RUN_ACTION = 1 << 3,

GTK_RUN_NO_HOOKS = 1 << 4

} GtkSignalRunType;

/* scrolling types */

typedef enum

{

GTK_SCROLL_NONE, GTK_SCROLL_STEP_BACKWARD, GTK_SCROLL_STEP_FORWARD,

GTK_SCROLL_PAGE_BACKWARD, GTK_SCROLL_PAGE_FORWARD,

GTK_SCROLL_JUMP

} GtkScrollType;

/* list selection modes */

typedef enum

{

GTK_SELECTION_SINGLE, GTK_SELECTION_BROWSE, GTK_SELECTION_MULTIPLE,

GTK_SELECTION_EXTENDED

} GtkSelectionMode;

/* Shadow types */

typedef enum

{

GTK_SHADOW_NONE, GTK_SHADOW_IN, GTK_SHADOW_OUT,

GTK_SHADOW_ETCHED_IN, GTK_SHADOW_ETCHED_OUT

} GtkShadowType;

/* Widget states */

typedef enum

{

GTK_STATE_NORMAL, GTK_STATE_ACTIVE, GTK_STATE_PRELIGHT,

GTK_STATE_SELECTED, GTK_STATE_INSENSITIVE

} GtkStateType;

/* Directions for submenus */

typedef enum

{

GTK_DIRECTION_LEFT, GTK_DIRECTION_RIGHT

} GtkSubmenuDirection;

/* Placement of submenus */

typedef enum

{

GTK_TOP_BOTTOM, GTK_LEFT_RIGHT

} GtkSubmenuPlacement;

/* Style for toolbars */

typedef enum

{

GTK_TOOLBAR_ICONS, GTK_TOOLBAR_TEXT, GTK_TOOLBAR_BOTH

} GtkToolbarStyle;

/* Trough types for GtkRange */

typedef enum

{

GTK_TROUGH_NONE, GTK_TROUGH_START, GTK_TROUGH_END, GTK_TROUGH_JUMP

} GtkTroughType;

/* Data update types (for ranges) */

typedef enum

{

GTK_UPDATE_CONTINUOUS, GTK_UPDATE_DISCONTINUOUS, GTK_UPDATE_DELAYED

} GtkUpdateType;

/* Generic visibility flags */

typedef enum

{

GTK_VISIBILITY_NONE, GTK_VISIBILITY_PARTIAL, GTK_VISIBILITY_FULL

} GtkVisibility;

/* Window position types */

typedef enum

{

GTK_WIN_POS_NONE, GTK_WIN_POS_CENTER, GTK_WIN_POS_MOUSE,

GTK_WIN_POS_CENTER_ALWAYS

} GtkWindowPosition;

/* Window types */

typedef enum

{

GTK_WINDOW_TOPLEVEL, GTK_WINDOW_DIALOG, GTK_WINDOW_POPUP

} GtkWindowType;

/* How to sort */

typedef enum

{

GTK_SORT_ASCENDING, GTK_SORT_DESCENDING

} GtkSortType;

VDK Plugin Components

VDK plugins are components contained into shared libraries that can be linked with VDK applications. Even if are mainly used to be managed by VDKBuilder they can be used with VDK applications as well.

Plugins libraries are distributed with VDKBuilder on versions greater than 1.0.0, each shared library contains only one component.

Actually those distributed are:

VDKCalendar, a wrapper of gtk calendar.

VDKDigitalClock, a composite widget that behaves like a digital clock.

How to use VDK plugin component

VDK plugins can be used as normal shared libraries, users will #include VDK plugins headers into their sources and link with -lvdk<name>. Distributed VDK plugins source are into ./plugins dir, headers into ./include/vdkb. VDKBuilder installation procedure will put plugin headers into <prefix>/include/vdkb and shared libraries into <prefix>/lib, thus on the same directory where gennerally VDK libs themselves are installed.

VDKCalendar <vdkb/vdkcalendar.h>

Inherits from VDKObject

Link lib: -lvdkcalendar

DESCRIPTION

This widget wraps gtkcalendar

PROPERTIES

GtkCalendarDisplayOptions DisplayOptions

Default is GTK_CALENDAR_SHOW_HEADING and can be one or more of the following:

GTK_CALENDAR_SHOW_HEADING

GTK_CALENDAR_SHOW_DAY_NAMES

GTK_CALENDAR_NO_MONTH_CHANGE

GTK_CALENDAR_SHOW_WEEK_NUMBERS

GTK_CALENDAR_WEEK_START_MONDAY

various options can ored togheter.

calendardate SelectedDate (read-only)

Read selected date as calendardate object.

int SelectedDay

Set/get selected day.

VDKPoint SelectedMonth (read-only)

Read select month and year as a VDKPoint where x = month and y = year.

METHODS

VDKCalendar(VDKForm* owner);

Constructor

virtual ~VDKCalendar();

Destructor

SIGNALS

day_select_signal

Emitted when use clicks on a day

day_selected_double_click

Emitted when use double-clicks on a day

VDKDigitalClock <vdkb/vdkdclock.h>

Inherits from VDKObject

Link lib: -lvdkdclock

DESCRIPTION

VDKDigitalClock is a simple digital clock that shows time, date and can be set with an alarm time. The widget is a composite one, made by a canvas and a button.

Operations:

PROPERTIES

VDKRgb ClockBackground

Sets clock background

VDKRgb ClockForeground

Sets clock foreground, by default clock colors are green on black

VDKPoint Alarm;

Where x = hours and y = minutes, if x || y < 0 alarm is off. Setting an alarm time causes the "clock_alarm" signal be emitted for 60 seconds or less if user calls StopAlarm().

i.e: clock->Alarm = VDKPoint(10,35); // sets alarm at 10:35 am

METHODS

VDKDigitalClock(VDKForm* owner, bool activate = false);

Constructor, make a VDKDigitalClock. If <activate> arg is true the clock begins normal operations displaying time, date etc. Default is false and can be later activate using Activate() method.

~VDKDigitalClock();

Destructor

void Activate();

Activates clock opertaions.

void StopAlarm()

Stop alarm signal.

SIGNALS

"clock_alarm"

Received when and if an alarm time was set. Widget owner receives this signal for 60 secs. If the user calls StopAlarm() signal emission will be stopped.

"clock_alarm_set"

Received whenever user presses the "alarm" button.

Tip:

Since neither "clock_alarm" and "clock_alarm_set" are signal provided by

gtk+, user must connect with this signals using dynamic tables and setting

<gtk> arg to false.

i.e.:

SignalConnect(clock,"clock_alarm_set",&ClockForm::OnAlarmSet,false);

SignalConnect(clock,"clock_alarm",&ClockForm::OnAlarm,false);

How to wrap gtk+ widgets

/*

* ===========================

* VDK Visual Development Kit

* September 1999

* File: vdkcalendar.h

* ===========================

*

* 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.

*/

/*

OVERVIEW

--------

This file has the aim to be a footstep that shows how to make a

gtk+ widget wrapper in vdk. We choose here to wrap gtk_calendar() widget.

*/

#ifndef _VDKCALENDAR_H

#define _VDKCALENDAR_H

#include <vdk/vdk.h>

/*

defines for signals, we use user_signal as base in order to avoid

possible conflicts with vdk internal signal system

*/

#define day_select_signal user_signal + 1024

#define day_selected_double_click day_select_signal + 1

class VDKCalendar: public VDKObject

{

public:

VDKCalendar(VDKForm* owner = NULL);

virtual ~VDKCalendar();

/*

note: others gtk_calendar functions could be wrapped,

but since in most cases it will be a 1:1 wrapping we decide

to do not do it. User have at their hand: VDKObject::Widget () to access

directly to gtk_calendar. For instance to mark in bold face a day:

....

VDKCalendar calendar = new VDKCalendar(this);

calendardate today;

gtk_calendar_mark_day ( GTK_CALENDAR(calendar->Widget()),today.Day());

....

*/

 

//------------------

// signal section

//------------------

protected:

/*

to wrap signals we use static class function that bind a signal and propagates it into vdk hierarchy. To decide which signal can be wrapped we take a look atgtkcalendar.h in gtk+ distribution.

We see:

void (* month_changed) (GtkCalendar *calendar);

void (* day_selected) (GtkCalendar *calendar);

void (* day_selected_double_click) (GtkCalendar *calendar);

void (* prev_month) (GtkCalendar *calendar);

void (* next_month) (GtkCalendar *calendar);

void (* prev_year) (GtkCalendar *calendar);

void (* next_year) (GtkCalendar *calendar);

So we decide to wrap following signals;

- day_selected

- day_selected_double_click

for static tables, leaving others to be connected at user choice using dynamics tables. Now let's take a look to signal handlers to see how should be the signature of the handlers.Since they all have just the widget as parameter we know that the handler

will have the classic form:

-----------------------------------

void handler(GtkWidget*, gpointer);

-----------------------------------

(in many cases there is also an example how the widget works, both in testgtk.c or in examples dir. In our case there is a good one on example/calendar/gcalendar.c).

*/

static void DaySelectedHandler(GtkWidget*, gpointer);

static void DaySelectedDoubleClickHandler(GtkWidget*, gpointer);

//---------------------

// properties section

//---------------------

/*

To decide which properties are suitable to be wrapped, we take a look to gtkcalendar.h in gtk+ distribution to see wich gtk_set... or gtk_get... are available there.We see :

void gtk_calendar_display_options (GtkCalendar * calendar,

GtkCalendarDisplayOptions options);

void gtk_calendar_get_date (GtkCalendar *,

guint *year,

guint *month,

guint *day);

gint gtk_calendar_select_month(GtkCalendar *calendar,

guint month,

guint year);

void gtk_calendar_select_day(GtkCalendar *calendar,

guint day);

So we decide to have following properties:

- GtkCalendarOptions DisplayOptions

- calendardate SelectedDate (read only)

- int SelectedDay

- VDKPoint SelectedMonth (where point.x is mont and point.y is day)

(note: gtk+ numbers months using base 0:

january = 0, february =1,...december = 11

Instead we decide to use base 1 for the wrapper).

*/

/* --------- DisplayOptions property ----------

This property sets/gets how calendar displays, options can be one or more of the following: (can be ored togheter)

GTK_CALENDAR_SHOW_HEADING

GTK_CALENDAR_SHOW_DAY_NAMES

GTK_CALENDAR_NO_MONTH_CHANGE

GTK_CALENDAR_SHOW_WEEK_NUMBERS

GTK_CALENDAR_WEEK_START_MONDAY

*/

public:

__rwproperty(VDKCalendar, GtkCalendarDisplayOptions) DisplayOptions;

/* and setting/getting functions */

protected:

void SetDisplayOptions(GtkCalendarDisplayOptions options);

/*

getting function isn't necessary, since we use raw property read

( see vdk reference under "properties" section for further informations)

*/

/* ------------- SelectedDate property --------

This (read only) property read selected date in gtk_calendar widget.

We use here calendardate object in vdk stock as property type.

*/

public:

__rproperty(VDKCalendar,calendardate) SelectedDate;

/* and getting functions (since property is read-only */

protected:

calendardate GetSelectedDate();

/* ------ SelectedDay property --------------

this property set/get selected day

*/

public:

__rwproperty(VDKCalendar, int) SelectedDay;

protected:

void SetSelectedDay(int d);

/* getting function isn't necessary*/

/* -------- SelectedMonth property --------------

this property set/get selected month/year

*/

public:

__rwproperty(VDKCalendar, VDKPoint) SelectedMonth;

protected:

void SetSelectedMonth(VDKPoint p);

/* getting function isn't necessary*/

};

#endif

/*

* ===========================

* VDK Visual Development Kit

* File: vdkcalendar.cc

* ===========================

*

* 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.

*/

/*

OVERVIEW

--------

This file has the aim to be a footstep that shows how to make a

gtk+ widget wrapper in vdk.

We choose here to wrap gtk_calendar() widget.

*/

#include <vdkb/vdkcalendar.h>

#include <vdk/forms.h>

/*

Constructor, initializes properties:

args:

name conventionally we use a string equal to name

this obvious

default value the property init value

setting fun which function will be called

when the user writes: property = value;

getting fun which function will be called

when the user writes: value = property;

*/

VDKCalendar::VDKCalendar(VDKForm* owner):

VDKObject(owner),

DisplayOptions("DisplayOptions",this,GTK_CALENDAR_SHOW_HEADING,

&VDKCalendar::SetDisplayOptions,NULL),

SelectedDate("SelectedDate",this,calendardate(),

&VDKCalendar::GetSelectedDate,NULL),

SelectedDay("SelectedDay",this,0,

&VDKCalendar::SetSelectedDay,NULL),

SelectedMonth("SelectedMonth",this,VDKPoint(0,0),

&VDKCalendar::SetSelectedMonth,NULL)

{

 

// actually makes the gtk widget and assign widget pointer

widget = gtk_calendar_new();

calendardate today;

// by default gtk_calendar opens on 1st day of the current month

// we select today as well

SelectedDay = today.Day();

// marks today in bold face

gtk_calendar_mark_day ( GTK_CALENDAR(widget), today.Day());

// connecting signal handlers we pass <this> as user data arg so static handler // can access to calendar

gtk_signal_connect (GTK_OBJECT (widget), "day_selected",

GTK_SIGNAL_FUNC (VDKCalendar::DaySelectedHandler),

(gpointer) this);

gtk_signal_connect (GTK_OBJECT (widget), "day_selected_double_click",

GTK_SIGNAL_FUNC (VDKCalendar::DaySelectedDoubleClickHandler),

(gpointer)this);

}

/*

*/

VDKCalendar::~VDKCalendar()

{

// nothing to do

}

/* -----------------------

signal handling section

---------------------- */

void

VDKCalendar::DaySelectedHandler(GtkWidget* widget, gpointer p)

{

/* some usual checks for safety */

g_return_if_fail(widget != NULL);

g_return_if_fail(p != NULL);

/* cast to vdkcalendar */

VDKCalendar* obj = reinterpret_cast<VDKCalendar*>(p);

// month,year selected (month base = 1)

VDKPoint point(GTK_CALENDAR(widget)->month+1,GTK_CALENDAR(widget)->year);

// set properties using a raw write

obj->SelectedDay(GTK_CALENDAR(widget)->selected_day);

obj->SelectedMonth(point);

// feeds signal into vdk signal system

obj->SignalEmit(day_select_signal);

}

void

VDKCalendar::DaySelectedDoubleClickHandler(GtkWidget* widget, gpointer p)

{

/* same as above */

g_return_if_fail(widget != NULL);

g_return_if_fail(p != NULL);

VDKCalendar* obj = reinterpret_cast<VDKCalendar*>(p);

VDKPoint point(GTK_CALENDAR(widget)->month+1,GTK_CALENDAR(widget)->year);

obj->SelectedDay(GTK_CALENDAR(widget)->selected_day);

obj->SelectedMonth(point);

obj->SignalEmit(day_selected_double_click);

}

 

/*

----------------------------

properties handling section

----------------------------

*/

void

VDKCalendar::SetDisplayOptions(GtkCalendarDisplayOptions options)

{

gtk_calendar_display_options (GTK_CALENDAR(widget),options);

}

/*

*/

calendardate

VDKCalendar::GetSelectedDate()

{

unsigned int day,month,year;

GtkCalendar* calendar = GTK_CALENDAR(widget);

gtk_calendar_get_date(calendar, &year, &month, &day);

// months base 0 in gtk+

return calendardate(day,month+1,year);

}

/*

*/

void

VDKCalendar::SetSelectedDay(int day)

{

gtk_calendar_select_day(GTK_CALENDAR(widget),day);

}

/*

*/

void

VDKCalendar::SetSelectedMonth(VDKPoint p)

{

// gtk+ month base = 0

gtk_calendar_select_month(GTK_CALENDAR(widget), p.x-1, p.y);

}