OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
datetime.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1998 by Yura Bidus, All Rights Reserved
4//
5/// \file
6/// Definition of class TDateTimePicker.
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_DATETIME_H)
10#define OWL_DATETIME_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/control.h>
18#include <owl/commctrl.h>
19
20namespace owl {
21
22#include <owl/preclass.h>
23
25{
26 public:
28 const TSystemTime& dt = TSystemTime::LocalTime(),
29 const TSystemTime& mind = TSystemTime(1980,0,0),
30 const TSystemTime& maxd = TSystemTime(2100,0,0)
31 )
32 : DateTime(dt), MaxDate(maxd), MinDate(mind)
33 {}
34
36 TSystemTime MaxDate; ///< default TSystemTime(0) not set
37 TSystemTime MinDate; ///< default TSystemTime(0) not set
38};
39
40/// \addtogroup newctrl
41/// @{
42
43//
44/// \class TDateTimePicker
45//
47 : public TControl
48{
49 public:
51 {
52 dtBackColor=MCSC_BACKGROUND,
53 dtTextColor=MCSC_TEXT,
54 dtTitleBackColor=MCSC_TITLEBK,
55 dtTitleTextColor=MCSC_TITLETEXT,
56 dtMonthBackColor=MCSC_MONTHBK,
57 dtTrailingTextColor=MCSC_TRAILINGTEXT,
58 };
59
60 TDateTimePicker(TWindow* parent, int id, int x, int y, int w, int h, TModule* module = 0);
61 TDateTimePicker(TWindow* parent, int resourceId, TModule* module = 0);
62 TDateTimePicker(THandle hWnd, TModule* module = 0);
64
65 void SetColor(TDateTimeColors index, const TColor& clr);
66 TColor GetColor(TDateTimeColors index) const;
67
68 bool SetFormat(LPCTSTR format);
69 bool SetFormat(const tstring& format) {return SetFormat(format.c_str());}
70 HFONT GetFont() const;
71 void SetFont(HFONT font, bool redraw = true);
72
73 bool SetTime(const TSystemTime& dt);
74 bool SetNoTime();
75 int GetTime(TSystemTime& dt) const;
76 TSystemTime GetTime() const {TSystemTime t; GetTime(t); return t;} // TODO: Add error handling.
77
78 bool SetRange(const TSystemTime& mint, const TSystemTime& maxt);
79 void GetRange(TSystemTime& mint, TSystemTime& maxt) const;
80
81 HWND GetMonthCalCtrl();
82
83 //
84 /// Safe overload
85 //
87
88 protected:
89 //
90 /// Override TWindow virtual member functions
91 //
92 uint Transfer(void* buffer, TTransferDirection direction);
93 virtual auto GetWindowClassName() -> TWindowClassName;
94
95 private:
96 //
97 // Hidden to prevent accidental copying or assignment
98 //
101};
102
103/// @}
104
105#include <owl/posclass.h>
106
107//
108// inlines
109//
110
111//
113{
115 SendMessage(DTM_SETMCCOLOR, TParam1(index), TParam2(clr.GetValue()));
116}
117
118//
120{
122 return static_cast<COLORREF>(::SendMessage(GetHandle(), DTM_GETMCCOLOR, TParam1(index),0));
123}
124
125//
127{
129 return static_cast<bool>(SendMessage(DTM_SETFORMAT, 0, reinterpret_cast<TParam2>(format)));
130}
131
132//
134{
136 return reinterpret_cast<HFONT>(::SendMessage(GetHandle(), DTM_GETMCFONT,0,0)); //Jogy: Why not call the member SendMessage??
137}
138
139//
141{
143 SendMessage(DTM_SETMCFONT, reinterpret_cast<TParam1>(font), MkUint32(static_cast<uint16>(redraw), 0));
144}
145
146//
148{
150 return reinterpret_cast<HWND>(SendMessage(DTM_GETMONTHCAL, 0, 0));
151}
152
153//
155{
157 return static_cast<bool>(SendMessage(DTM_SETSYSTEMTIME, static_cast<TParam1>(GDT_VALID), reinterpret_cast<TParam2>(&dt)));
158}
159
160//
162{
164 return static_cast<bool>(SendMessage(DTM_SETSYSTEMTIME, static_cast<TParam1>(GDT_NONE), 0));
165}
166
167// return GDT_VALID,GDT_NONE,GDT_ERROR
169{
171 return static_cast<int>(::SendMessage(GetHandle(), DTM_GETSYSTEMTIME, 0, reinterpret_cast<TParam2>(&dt))); //Jogy: Why not call the member SendMessage??
172}
173
174} // OWL namespace
175
176#endif // OWL_DATETIME_H
#define PRECONDITION(condition)
Definition checks.h:227
Class wrapper for management of color values.
Definition color.h:245
TControl unifies its derived control classes, such as TScrollBar, TControlGadget, and TButton.
Definition control.h:38
TSystemTime MinDate
default TSystemTime(0) not set
Definition datetime.h:37
TDateTimePickerData(const TSystemTime &dt=TSystemTime::LocalTime(), const TSystemTime &mind=TSystemTime(1980, 0, 0), const TSystemTime &maxd=TSystemTime(2100, 0, 0))
Definition datetime.h:27
TSystemTime MaxDate
default TSystemTime(0) not set
Definition datetime.h:36
bool SetTime(const TSystemTime &dt)
Definition datetime.h:154
HFONT GetFont() const
Definition datetime.h:133
bool SetFormat(const tstring &format)
Definition datetime.h:69
void SetFont(HFONT font, bool redraw=true)
Definition datetime.h:140
bool SetFormat(LPCTSTR format)
Definition datetime.h:126
TColor GetColor(TDateTimeColors index) const
Definition datetime.h:119
void SetColor(TDateTimeColors index, const TColor &clr)
Definition datetime.h:112
TSystemTime GetTime() const
Definition datetime.h:76
uint Transfer(TDateTimePickerData &data, TTransferDirection direction)
Safe overload.
Definition datetime.h:86
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TSystemTime is a class derived from the structure SYSTEMTIME.
Definition wsyscls.h:420
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
Definition module.h:47
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
Definition window.cpp:3288
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
Definition of classes for CommonControl encapsulation.
Definition of class TControl.
TTransferDirection
The TTransferDirection enum describes the constants that the transfer function uses to determine how ...
Definition window.h:92
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
uint32 MkUint32(uint16 lo, uint16 hi)
Definition defs.h:261
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
#define _OWLCLASS
Definition defs.h:338