Cleaned up from the previous merge and added it to the README.
This commit is contained in:
parent
d02784838e
commit
ca1079f344
|
@ -5,6 +5,9 @@ This README is being written.<br>
|
||||||
|
|
||||||
## Announcements
|
## Announcements
|
||||||
|
|
||||||
|
* **13 May 2018**
|
||||||
|
* Added new functions to work with uiDateTimePickers: `uiDateTimePickerTime()`, `uiDateTimePickerSetTime()`, and `uiDateTimePickerOnChanged()`. These operate on standard `<time.h>` `struct tm`s. Thanks @cody271!
|
||||||
|
|
||||||
* **2 May 2018**
|
* **2 May 2018**
|
||||||
* On Windows, you no longer need to carry around a `libui.res` file with static builds. You do need to link in the appropriate manifest file, such as the one in the `windows/` folder (I still need to figure out exactly what is needed apart from the Common Controls v6 dependency, or at least to create a complete-ish template), or at least include it alongside your executables. This also means you should no longer see random cmake errors when building the static libraries.
|
* On Windows, you no longer need to carry around a `libui.res` file with static builds. You do need to link in the appropriate manifest file, such as the one in the `windows/` folder (I still need to figure out exactly what is needed apart from the Common Controls v6 dependency, or at least to create a complete-ish template), or at least include it alongside your executables. This also means you should no longer see random cmake errors when building the static libraries.
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,10 @@ struct uiDateTimePicker {
|
||||||
void *onChangedData;
|
void *onChangedData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO see if target-action works here or not; I forgot what cody271@ originally said
|
||||||
|
// the primary advantage of the delegate is the ability to reject changes, but libui doesn't support that yet — we should consider that API option as well
|
||||||
@interface uiprivDatePickerDelegateClass : NSObject<NSDatePickerCellDelegate> {
|
@interface uiprivDatePickerDelegateClass : NSObject<NSDatePickerCellDelegate> {
|
||||||
struct uiprivMap *pickers;
|
uiprivMap *pickers;
|
||||||
}
|
}
|
||||||
- (void)datePickerCell:(NSDatePickerCell *)aDatePickerCell validateProposedDateValue:(NSDate **)proposedDateValue timeInterval:(NSTimeInterval *)proposedTimeInterval;
|
- (void)datePickerCell:(NSDatePickerCell *)aDatePickerCell validateProposedDateValue:(NSDate **)proposedDateValue timeInterval:(NSTimeInterval *)proposedTimeInterval;
|
||||||
- (void)doTimer:(NSTimer *)timer;
|
- (void)doTimer:(NSTimer *)timer;
|
||||||
|
@ -33,13 +35,11 @@ struct uiDateTimePicker {
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)datePickerCell:(NSDatePickerCell *)aDatePickerCell
|
- (void)datePickerCell:(NSDatePickerCell *)cell validateProposedDateValue:(NSDate **)proposedDateValue timeInterval:(NSTimeInterval *)proposedTimeInterval
|
||||||
validateProposedDateValue:(NSDate **)proposedDateValue
|
|
||||||
timeInterval:(NSTimeInterval *)proposedTimeInterval
|
|
||||||
{
|
{
|
||||||
uiDateTimePicker *d;
|
uiDateTimePicker *d;
|
||||||
|
|
||||||
d = (uiDateTimePicker *) uiprivMapGet(self->pickers, aDatePickerCell);
|
d = (uiDateTimePicker *) uiprivMapGet(self->pickers, cell);
|
||||||
[NSTimer scheduledTimerWithTimeInterval:0
|
[NSTimer scheduledTimerWithTimeInterval:0
|
||||||
target:self
|
target:self
|
||||||
selector:@selector(doTimer:)
|
selector:@selector(doTimer:)
|
||||||
|
@ -49,9 +49,11 @@ struct uiDateTimePicker {
|
||||||
|
|
||||||
- (void)doTimer:(NSTimer *)timer
|
- (void)doTimer:(NSTimer *)timer
|
||||||
{
|
{
|
||||||
|
NSValue *v;
|
||||||
uiDateTimePicker *d;
|
uiDateTimePicker *d;
|
||||||
|
|
||||||
d = (uiDateTimePicker *) [((NSValue *)[timer userInfo]) pointerValue];
|
v = (NSValue *) [timer userInfo];
|
||||||
|
d = (uiDateTimePicker *) [v pointerValue];
|
||||||
(*(d->onChanged))(d, d->onChangedData);
|
(*(d->onChanged))(d, d->onChangedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +80,7 @@ static void defaultOnChanged(uiDateTimePicker *d, void *data)
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO consider using NSDateComponents iff we ever need the extra accuracy of not using NSTimeInterval
|
||||||
void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time)
|
void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time)
|
||||||
{
|
{
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
|
@ -23,11 +23,6 @@ _add_example(histogram
|
||||||
${_EXAMPLE_RESOURCES_RC}
|
${_EXAMPLE_RESOURCES_RC}
|
||||||
)
|
)
|
||||||
|
|
||||||
_add_example(datetime
|
|
||||||
datetime/main.c
|
|
||||||
${_EXAMPLE_RESOURCES_RC}
|
|
||||||
)
|
|
||||||
|
|
||||||
_add_example(cpp-multithread
|
_add_example(cpp-multithread
|
||||||
cpp-multithread/main.cpp
|
cpp-multithread/main.cpp
|
||||||
${_EXAMPLE_RESOURCES_RC}
|
${_EXAMPLE_RESOURCES_RC}
|
||||||
|
@ -52,11 +47,16 @@ _add_example(timer
|
||||||
${_EXAMPLE_RESOURCES_RC}
|
${_EXAMPLE_RESOURCES_RC}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_add_example(datetime
|
||||||
|
datetime/main.c
|
||||||
|
${_EXAMPLE_RESOURCES_RC}
|
||||||
|
)
|
||||||
|
|
||||||
add_custom_target(examples
|
add_custom_target(examples
|
||||||
DEPENDS
|
DEPENDS
|
||||||
controlgallery
|
controlgallery
|
||||||
histogram
|
histogram
|
||||||
cpp-multithread
|
cpp-multithread
|
||||||
drawtext
|
drawtext
|
||||||
datetime
|
timer
|
||||||
timer)
|
datetime)
|
||||||
|
|
|
@ -17,7 +17,6 @@ const char *timeFormat(uiDateTimePicker *d)
|
||||||
fmt = "%X";
|
fmt = "%X";
|
||||||
else
|
else
|
||||||
fmt = "";
|
fmt = "";
|
||||||
|
|
||||||
return fmt;
|
return fmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,14 +58,19 @@ int onClosing(uiWindow *w, void *data)
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
uiInitOptions o;
|
uiInitOptions o;
|
||||||
|
const char *err;
|
||||||
uiWindow *w;
|
uiWindow *w;
|
||||||
uiGrid *g;
|
uiGrid *g;
|
||||||
uiLabel *l;
|
uiLabel *l;
|
||||||
uiButton *b;
|
uiButton *b;
|
||||||
|
|
||||||
memset(&o, 0, sizeof (uiInitOptions));
|
memset(&o, 0, sizeof (uiInitOptions));
|
||||||
if (uiInit(&o) != NULL)
|
err = uiInit(&o);
|
||||||
abort();
|
if (err != NULL) {
|
||||||
|
fprintf(stderr, "error initializing ui: %s\n", err);
|
||||||
|
uiFreeInitError(err);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
w = uiNewWindow("Date / Time", 320, 240, 0);
|
w = uiNewWindow("Date / Time", 320, 240, 0);
|
||||||
uiWindowSetMargined(w, 1);
|
uiWindowSetMargined(w, 1);
|
||||||
|
|
|
@ -116,6 +116,7 @@ static void dateTimeChanged(uiprivDateTimePickerWidget *d)
|
||||||
{
|
{
|
||||||
g_signal_emit(d, changedSignal, 0);
|
g_signal_emit(d, changedSignal, 0);
|
||||||
setLabel(d);
|
setLabel(d);
|
||||||
|
// TODO fire event here instead?
|
||||||
}
|
}
|
||||||
|
|
||||||
// we don't want ::toggled to be sent again
|
// we don't want ::toggled to be sent again
|
||||||
|
|
|
@ -191,7 +191,6 @@ void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time)
|
||||||
toSystemTime(time, &systime);
|
toSystemTime(time, &systime);
|
||||||
if (SendMessageW(d->hwnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM) (&systime)) == 0)
|
if (SendMessageW(d->hwnd, DTM_SETSYSTEMTIME, GDT_VALID, (LPARAM) (&systime)) == 0)
|
||||||
logLastError(L"error setting date and time");
|
logLastError(L"error setting date and time");
|
||||||
(*(d->onChanged))(d, d->onChangedData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data)
|
void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data)
|
||||||
|
|
Loading…
Reference in New Issue