CClockControl

Derived from: BControl.h

Declared in: CClockControl.h

Library: Chronology.so

[method summary]

This class provides you with a gui-element that looks like a clock. It's fingers can be turned to adjust the time, a popup-menu lets the user switch from am to pm. It also supports drag and drop, you can drag it to the desktop to create a file containing the time, drag it to an editors view to insert the time into the text and you can drag it onto another CClockControl to set the destination to the same value as the source CClockControl.


Constructor and Destructor


CClockControl()

      CClockControl(BPoint position, const char *name, BMessage *message, uint32 flags)

Creates a new instance of CClockControl and sets the currently represented time to the current time.

point is the location in the window, where it appears. As the size of the clock is defined by the size of the background image the user choses, you only have to specify the point and not a rectangle.

name is the name of the object, which can be used for scripting, as name in BControl.

flags as in BControl, but B_WILL_DRAW is always or()ed to it in the constructor.

The user can chose what the face of the clock should look like. He can therefore specify an image, which is loaded from disk and can be in any format for that a translator exists. The size of the CClockControl is defined by the size of the image, and can therefore vary. Use GetPreferredSize() to determine the size of the clock.

If you use more than one instance of this object in your application, the bitmap that is loaded is only loaded once and is shared between all instances of the object, so it is in memory only once. If you start two applications that use CClockControl, the bitmap is in memory twice. I don't like this fact and am trying to figure out how it could be shared between multiple applications.


~CClockControl()

      ~CClockControl()

This deletes the object, deleting the popupmenu and (if this was the last instance of CClockcontrol, the bitmap.


Hook Functions


MessageReceived()

      virtual void MessageReceived( BMessage *message )

Is called whenever the handler receives a message. If it contains an int32 with the name "CTime::Seconds" the value is interpreted as seconds and sets the current time the this value.

You can call this function to see any incoming messages, but don't forget to call CClockControl::MessageReceived().


AttachedToWindow()

      virtual void AttachedToWindow()

This one's called after the object was attached to a window, and can be implemented to make your own initialisations. Currently it does nothing more than set the origin to the center of the clock, which is half the width of the loaded bitmap;


GetPreferredSize()

      virtual void GetPreferredSize(float *width, float *height)

Returns the preferred width and height. Those values are defined by the backgroundimage.


GetTime()

      const CTime &GetTime()

Returns a reference to a CTime representing the time currently displayed in the object.


SetTime()

      virtual void SetTime(const CTime &time)

With this function you can set the time, the object represents. You can also use this function to be notified whenever the stored time changes.


Hidden and Functions


There are some functions that have been made private and should therefire not be overwritteb, although there might be a need for this. The functions will be made public again in future, so just be patient.

The functions that are hidden are:






The Cronology Library, in lovely HTML, for BeOS Release 4.

Copyright © 1999 Michael Praschl. All rights reserved.

Last modified: 17. Feb 1999